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

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 48593003: Avoid re-rendering stencil clip for every draw with reducable clip stack (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: gcc-4.2 mac os 10.6 fix Created 7 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/GrClipMaskManager.h ('k') | src/gpu/GrReducedClip.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipMaskManager.cpp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 0f915666fb617ee65ad2560a4c9dc381413e133f..3aef3dee67d1b36d4f0a498516de0ad46c783533 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -113,6 +113,7 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
fCurrClipMaskType = kNone_ClipMaskType;
ElementList elements(16);
+ int32_t genID;
InitialState initialState;
SkIRect clipSpaceIBounds;
bool requiresAA;
@@ -132,6 +133,7 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
ReduceClipStack(*clipDataIn->fClipStack,
clipSpaceRTIBounds,
&elements,
+ &genID,
&initialState,
&clipSpaceIBounds,
&requiresAA);
@@ -156,7 +158,6 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
// If MSAA is enabled we can do everything in the stencil buffer.
if (0 == rt->numSamples() && requiresAA) {
- int32_t genID = clipDataIn->fClipStack->getTopmostGenID();
GrTexture* result = NULL;
if (this->useSWOnlyPath(elements)) {
@@ -207,7 +208,8 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
// use the stencil clip if we can't represent the clip as a rectangle.
SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin;
- this->createStencilClipMask(initialState,
+ this->createStencilClipMask(genID,
+ initialState,
elements,
clipSpaceIBounds,
clipSpaceToStencilSpaceOffset);
@@ -390,11 +392,11 @@ void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
// Handles caching & allocation (if needed) of a clip alpha-mask texture for both the sw-upload
// or gpu-rendered cases. Returns true if there is no more work to be done (i.e., we got a cache
// hit)
-bool GrClipMaskManager::getMaskTexture(int32_t clipStackGenID,
+bool GrClipMaskManager::getMaskTexture(int32_t elementsGenID,
const SkIRect& clipSpaceIBounds,
GrTexture** result,
bool willUpload) {
- bool cached = fAACache.canReuse(clipStackGenID, clipSpaceIBounds);
+ bool cached = fAACache.canReuse(elementsGenID, clipSpaceIBounds);
if (!cached) {
// There isn't a suitable entry in the cache so we create a new texture to store the mask.
@@ -412,7 +414,7 @@ bool GrClipMaskManager::getMaskTexture(int32_t clipStackGenID,
desc.fConfig = kAlpha_8_GrPixelConfig;
}
- fAACache.acquireMask(clipStackGenID, desc, clipSpaceIBounds);
+ fAACache.acquireMask(elementsGenID, desc, clipSpaceIBounds);
}
*result = fAACache.getLastMask();
@@ -421,14 +423,14 @@ bool GrClipMaskManager::getMaskTexture(int32_t clipStackGenID,
////////////////////////////////////////////////////////////////////////////////
// Create a 8-bit clip mask in alpha
-GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t clipStackGenID,
+GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
InitialState initialState,
const ElementList& elements,
const SkIRect& clipSpaceIBounds) {
SkASSERT(kNone_ClipMaskType == fCurrClipMaskType);
GrTexture* result;
- if (this->getMaskTexture(clipStackGenID, clipSpaceIBounds, &result, false)) {
+ if (this->getMaskTexture(elementsGenID, clipSpaceIBounds, &result, false)) {
fCurrClipMaskType = kAlpha_ClipMaskType;
return result;
}
@@ -569,7 +571,8 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t clipStackGenID,
////////////////////////////////////////////////////////////////////////////////
// Create a 1-bit clip mask in the stencil buffer. 'devClipBounds' are in device
// (as opposed to canvas) coordinates
-bool GrClipMaskManager::createStencilClipMask(InitialState initialState,
+bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID,
+ InitialState initialState,
const ElementList& elements,
const SkIRect& clipSpaceIBounds,
const SkIPoint& clipSpaceToStencilOffset) {
@@ -587,11 +590,10 @@ bool GrClipMaskManager::createStencilClipMask(InitialState initialState,
if (NULL == stencilBuffer) {
return false;
}
- int32_t genID = elements.tail()->getGenID();
- if (stencilBuffer->mustRenderClip(genID, clipSpaceIBounds, clipSpaceToStencilOffset)) {
+ if (stencilBuffer->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpaceToStencilOffset)) {
- stencilBuffer->setLastClip(genID, clipSpaceIBounds, clipSpaceToStencilOffset);
+ stencilBuffer->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToStencilOffset);
// Set the matrix so that rendered clip elements are transformed from clip to stencil space.
SkVector translate = {
@@ -921,14 +923,14 @@ void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings,
}
////////////////////////////////////////////////////////////////////////////////
-GrTexture* GrClipMaskManager::createSoftwareClipMask(int32_t clipStackGenID,
+GrTexture* GrClipMaskManager::createSoftwareClipMask(int32_t elementsGenID,
GrReducedClip::InitialState initialState,
const GrReducedClip::ElementList& elements,
const SkIRect& clipSpaceIBounds) {
SkASSERT(kNone_ClipMaskType == fCurrClipMaskType);
GrTexture* result;
- if (this->getMaskTexture(clipStackGenID, clipSpaceIBounds, &result, true)) {
+ if (this->getMaskTexture(elementsGenID, clipSpaceIBounds, &result, true)) {
return result;
}
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrReducedClip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698