Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: src/gpu/GrRectBatch.cpp

Issue 1127713002: Move RectBatch to GrRectBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@command-builder
Patch Set: more Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrRectBatch.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrRectBatch.cpp
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrRectBatch.cpp
similarity index 50%
copy from src/gpu/GrInOrderDrawBuffer.cpp
copy to src/gpu/GrRectBatch.cpp
index 1e8f3ae6593c92fd3b6ee28578c56f2d295f9874..ba63db1e0f38649d41058906fca1a17db2a95665 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrRectBatch.cpp
@@ -1,35 +1,18 @@
/*
- * Copyright 2011 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GrInOrderDrawBuffer.h"
+#include "GrRectBatch.h"
+#include "GrBatch.h"
+#include "GrBatchTarget.h"
#include "GrDefaultGeoProcFactory.h"
+#include "GrPrimitiveProcessor.h"
#include "GrTemplates.h"
-GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context,
- GrVertexBufferAllocPool* vertexPool,
- GrIndexBufferAllocPool* indexPool)
- : INHERITED(context, vertexPool, indexPool)
- , fCommands(SkNEW_ARGS(GrCommandBuilder, (context->getGpu(), vertexPool, indexPool)))
- , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
- , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
- , fPipelineBuffer(kPipelineBufferMinReserve)
- , fDrawID(0) {
-
- SkASSERT(vertexPool);
- SkASSERT(indexPool);
-}
-
-GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
- this->reset();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
/** We always use per-vertex colors so that rects can be batched across color changes. Sometimes we
have explicit local coords and sometimes not. We *could* always provide explicit local coords
and just duplicate the positions when the caller hasn't provided a local coord rect, but we
@@ -236,12 +219,13 @@ private:
SkSTArray<1, Geometry, true> fGeoData;
};
-void GrInOrderDrawBuffer::onDrawRect(GrPipelineBuilder* pipelineBuilder,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
+namespace GrRectBatch {
+
+GrBatch* Create(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
RectBatch::Geometry geometry;
geometry.fColor = color;
geometry.fViewMatrix = viewMatrix;
@@ -261,181 +245,7 @@ void GrInOrderDrawBuffer::onDrawRect(GrPipelineBuilder* pipelineBuilder,
geometry.fHasLocalMatrix = false;
}
- SkAutoTUnref<GrBatch> batch(RectBatch::Create(geometry));
- this->drawBatch(pipelineBuilder, batch);
-}
-
-void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,
- const PipelineInfo& pipelineInfo) {
- State* state = this->setupPipelineAndShouldDraw(batch, pipelineInfo);
- if (!state) {
- return;
- }
-
- GrTargetCommands::Cmd* cmd = fCommands->recordDrawBatch(state, batch);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder,
- const GrPathProcessor* pathProc,
- const GrPath* path,
- const GrScissorState& scissorState,
- const GrStencilSettings& stencilSettings) {
- GrTargetCommands::Cmd* cmd = fCommands->recordStencilPath(pipelineBuilder,
- pathProc, path, scissorState,
- stencilSettings);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc,
- const GrPath* path,
- const GrStencilSettings& stencilSettings,
- const PipelineInfo& pipelineInfo) {
- State* state = this->setupPipelineAndShouldDraw(pathProc, pipelineInfo);
- if (!state) {
- return;
- }
- GrTargetCommands::Cmd* cmd = fCommands->recordDrawPath(state, pathProc, path, stencilSettings);
- this->recordTraceMarkersIfNecessary(cmd);
+ return RectBatch::Create(geometry);
}
-void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc,
- const GrPathRange* pathRange,
- const void* indices,
- PathIndexType indexType,
- const float transformValues[],
- PathTransformType transformType,
- int count,
- const GrStencilSettings& stencilSettings,
- const PipelineInfo& pipelineInfo) {
- State* state = this->setupPipelineAndShouldDraw(pathProc, pipelineInfo);
- if (!state) {
- return;
- }
- GrTargetCommands::Cmd* cmd = fCommands->recordDrawPaths(state, this, pathProc, pathRange,
- indices, indexType, transformValues,
- transformType, count,
- stencilSettings, pipelineInfo);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color,
- bool canIgnoreRect, GrRenderTarget* renderTarget) {
- GrTargetCommands::Cmd* cmd = fCommands->recordClear(rect, color, canIgnoreRect, renderTarget);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect,
- bool insideClip,
- GrRenderTarget* renderTarget) {
- GrTargetCommands::Cmd* cmd = fCommands->recordClearStencilClip(rect, insideClip, renderTarget);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
- if (!this->caps()->discardRenderTargetSupport()) {
- return;
- }
-
- GrTargetCommands::Cmd* cmd = fCommands->recordDiscard(renderTarget);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::onReset() {
- fCommands->reset();
- fPathIndexBuffer.rewind();
- fPathTransformBuffer.rewind();
- fGpuCmdMarkers.reset();
-
- fPrevState.reset(NULL);
- // Note, fPrevState points into fPipelineBuffer's allocation, so we have to reset first.
- // Furthermore, we have to reset fCommands before fPipelineBuffer too.
- if (fDrawID % kPipelineBufferHighWaterMark) {
- fPipelineBuffer.rewind();
- } else {
- fPipelineBuffer.reset();
- }
-}
-
-void GrInOrderDrawBuffer::onFlush() {
- fCommands->flush(this);
- ++fDrawID;
-}
-
-void GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
- SkASSERT(this->getGpu()->canCopySurface(dst, src, srcRect, dstPoint));
- GrTargetCommands::Cmd* cmd = fCommands->recordCopySurface(dst, src, srcRect, dstPoint);
- this->recordTraceMarkersIfNecessary(cmd);
-}
-
-void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(GrTargetCommands::Cmd* cmd) {
- if (!cmd) {
- return;
- }
- const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
- if (activeTraceMarkers.count() > 0) {
- if (cmd->isTraced()) {
- fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers);
- } else {
- cmd->setMarkerID(fGpuCmdMarkers.count());
- fGpuCmdMarkers.push_back(activeTraceMarkers);
- }
- }
-}
-
-GrTargetCommands::State*
-GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* primProc,
- const GrDrawTarget::PipelineInfo& pipelineInfo) {
- State* state = this->allocState(primProc);
- this->setupPipeline(pipelineInfo, state->pipelineLocation());
-
- if (state->getPipeline()->mustSkip()) {
- this->unallocState(state);
- return NULL;
- }
-
- state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker,
- state->getPipeline()->getInitBatchTracker());
-
- if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
- fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
- *state->fPrimitiveProcessor,
- state->fBatchTracker) &&
- fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
- this->unallocState(state);
- } else {
- fPrevState.reset(state);
- }
-
- this->recordTraceMarkersIfNecessary(
- fCommands->recordXferBarrierIfNecessary(*fPrevState->getPipeline(), *this->caps()));
- return fPrevState;
-}
-
-GrTargetCommands::State*
-GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch,
- const GrDrawTarget::PipelineInfo& pipelineInfo) {
- State* state = this->allocState();
- this->setupPipeline(pipelineInfo, state->pipelineLocation());
-
- if (state->getPipeline()->mustSkip()) {
- this->unallocState(state);
- return NULL;
- }
-
- batch->initBatchTracker(state->getPipeline()->getInitBatchTracker());
-
- if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
- fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
- this->unallocState(state);
- } else {
- fPrevState.reset(state);
- }
-
- this->recordTraceMarkersIfNecessary(
- fCommands->recordXferBarrierIfNecessary(*fPrevState->getPipeline(), *this->caps()));
- return fPrevState;
-}
+};
« no previous file with comments | « src/gpu/GrRectBatch.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698