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

Unified Diff: src/gpu/GrGpu.cpp

Issue 709133003: Snap optdrawstate in inorder draw buffer and pass into gpu (Closed) Base URL: https://skia.googlesource.com/skia.git@remove_friends
Patch Set: Created 6 years, 1 month 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/GrGpu.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpu.cpp
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 64ee29bde54bfb8206201f71b50af4d7baecf0e5..4c7450cbd2cf8ae5f78a74ef9aa62b0dd36d566a 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -26,14 +26,10 @@ GrGpu::GrGpu(GrContext* context)
, fResetBits(kAll_GrBackendState)
, fQuadIndexBuffer(NULL)
, fContext(context) {
- fDrawState = &fDefaultDrawState;
- // We assume that fDrawState always owns a ref to the object it points at.
- fDefaultDrawState.ref();
}
GrGpu::~GrGpu() {
SkSafeSetNull(fQuadIndexBuffer);
- SkSafeUnref(fDrawState);
SkSafeUnref(fGeoSrcState.fVertexBuffer);
SkSafeUnref(fGeoSrcState.fIndexBuffer);
}
@@ -190,13 +186,7 @@ void GrGpu::clear(const SkIRect* rect,
void GrGpu::clearStencilClip(const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget) {
- if (NULL == renderTarget) {
- renderTarget = this->getDrawState().getRenderTarget();
- }
- if (NULL == renderTarget) {
- SkASSERT(0);
- return;
- }
+ SkASSERT(renderTarget);
this->handleDirtyContext();
this->onClearStencilClip(renderTarget, rect, insideClip);
}
@@ -273,11 +263,11 @@ void GrGpu::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
}
}
-void GrGpu::setVertexSourceToBuffer(const GrVertexBuffer* buffer) {
+void GrGpu::setVertexSourceToBuffer(const GrVertexBuffer* buffer, size_t vertexStride) {
SkSafeUnref(fGeoSrcState.fVertexBuffer);
fGeoSrcState.fVertexBuffer = buffer;
buffer->ref();
- fGeoSrcState.fVertexSize = this->drawState()->getVertexStride();
+ fGeoSrcState.fVertexSize = vertexStride;
}
void GrGpu::setIndexSourceToBuffer(const GrIndexBuffer* buffer) {
@@ -286,18 +276,6 @@ void GrGpu::setIndexSourceToBuffer(const GrIndexBuffer* buffer) {
buffer->ref();
}
-void GrGpu::setDrawState(GrDrawState* drawState) {
- SkASSERT(fDrawState);
- if (NULL == drawState) {
- drawState = &fDefaultDrawState;
- }
- if (fDrawState != drawState) {
- fDrawState->unref();
- drawState->ref();
- fDrawState = drawState;
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1;
@@ -323,23 +301,26 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
////////////////////////////////////////////////////////////////////////////////
-void GrGpu::draw(const GrDrawTarget::DrawInfo& info,
- const GrClipMaskManager::ScissorState& scissorState) {
+void GrGpu::draw(const GrOptDrawState& ds,
+ const GrDrawTarget::DrawInfo& info,
+ const GrClipMaskManager::ScissorState& scissorState) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(PrimTypeToDrawType(info.primitiveType()),
+ if (!this->flushGraphicsState(ds,
+ PrimTypeToDrawType(info.primitiveType()),
scissorState,
info.getDstCopy())) {
return;
}
- this->onDraw(info);
+ this->onDraw(ds, info);
}
-void GrGpu::stencilPath(const GrPath* path,
- const GrClipMaskManager::ScissorState& scissorState,
- const GrStencilSettings& stencilSettings) {
+void GrGpu::stencilPath(const GrOptDrawState& ds,
+ const GrPath* path,
+ const GrClipMaskManager::ScissorState& scissorState,
+ const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(kStencilPath_DrawType, scissorState, NULL)) {
+ if (!this->flushGraphicsState(ds, kStencilPath_DrawType, scissorState, NULL)) {
return;
}
@@ -347,30 +328,32 @@ void GrGpu::stencilPath(const GrPath* path,
}
-void GrGpu::drawPath(const GrPath* path,
- const GrClipMaskManager::ScissorState& scissorState,
- const GrStencilSettings& stencilSettings,
- const GrDeviceCoordTexture* dstCopy) {
+void GrGpu::drawPath(const GrOptDrawState& ds,
+ const GrPath* path,
+ const GrClipMaskManager::ScissorState& scissorState,
+ const GrStencilSettings& stencilSettings,
+ const GrDeviceCoordTexture* dstCopy) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(kDrawPath_DrawType, scissorState, dstCopy)) {
+ if (!this->flushGraphicsState(ds, kDrawPath_DrawType, scissorState, dstCopy)) {
return;
}
this->pathRendering()->drawPath(path, stencilSettings);
}
-void GrGpu::drawPaths(const GrPathRange* pathRange,
- const uint32_t indices[],
- int count,
- const float transforms[],
- GrDrawTarget::PathTransformType transformsType,
- const GrClipMaskManager::ScissorState& scissorState,
- const GrStencilSettings& stencilSettings,
- const GrDeviceCoordTexture* dstCopy) {
+void GrGpu::drawPaths(const GrOptDrawState& ds,
+ const GrPathRange* pathRange,
+ const uint32_t indices[],
+ int count,
+ const float transforms[],
+ GrDrawTarget::PathTransformType transformsType,
+ const GrClipMaskManager::ScissorState& scissorState,
+ const GrStencilSettings& stencilSettings,
+ const GrDeviceCoordTexture* dstCopy) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(kDrawPaths_DrawType, scissorState, dstCopy)) {
+ if (!this->flushGraphicsState(ds, kDrawPaths_DrawType, scissorState, dstCopy)) {
return;
}
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698