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

Unified Diff: src/gpu/GrResourceProvider.cpp

Issue 1333383002: Move some of the adding stencil attachment logic of Gpu and into Render Target. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: spelling Created 5 years, 3 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/GrResourceProvider.h ('k') | src/gpu/GrTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceProvider.cpp
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index d3ab8ccfa1646d860dbb8d3789f3bcb49126a7dc..bd9cc9ac6b04d1845098b63f261c22b6c4e7919c 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -10,8 +10,11 @@
#include "GrGpu.h"
#include "GrIndexBuffer.h"
#include "GrPathRendering.h"
+#include "GrRenderTarget.h"
+#include "GrRenderTargetPriv.h"
#include "GrResourceCache.h"
#include "GrResourceKey.h"
+#include "GrStencilAttachment.h"
#include "GrVertexBuffer.h"
GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
@@ -163,3 +166,52 @@ GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config,
}
return new GrBatchAtlas(texture, numPlotsX, numPlotsY);
}
+
+GrStencilAttachment* GrResourceProvider::attachStencilAttachment(GrRenderTarget* rt) {
+ SkASSERT(rt);
+ if (rt->renderTargetPriv().getStencilAttachment()) {
+ return rt->renderTargetPriv().getStencilAttachment();
+ }
+
+ if (!rt->wasDestroyed() && rt->canAttemptStencilAttachment()) {
+ GrUniqueKey sbKey;
+
+ int width = rt->width();
+ int height = rt->height();
+#if 0
+ if (this->caps()->oversizedStencilSupport()) {
+ width = SkNextPow2(width);
+ height = SkNextPow2(height);
+ }
+#endif
+ bool newStencil = false;
+ GrStencilAttachment::ComputeSharedStencilAttachmentKey(width, height,
+ rt->numStencilSamples(), &sbKey);
+ GrStencilAttachment* stencil = static_cast<GrStencilAttachment*>(
+ this->findAndRefResourceByUniqueKey(sbKey));
+ if (!stencil) {
+ // Need to try and create a new stencil
+ stencil = this->gpu()->createStencilAttachmentForRenderTarget(rt, width, height);
+ if (stencil) {
+ stencil->resourcePriv().setUniqueKey(sbKey);
+ newStencil = true;
+ }
+ }
+ if (rt->renderTargetPriv().attachStencilAttachment(stencil)) {
+ if (newStencil) {
+ // Right now we're clearing the stencil attachment here after it is
+ // attached to an RT for the first time. When we start matching
+ // stencil buffers with smaller color targets this will no longer
+ // be correct because it won't be guaranteed to clear the entire
+ // sb.
+ // We used to clear down in the GL subclass using a special purpose
+ // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported
+ // FBO status.
+ this->gpu()->clearStencil(rt);
+ }
+ }
+ }
+ return rt->renderTargetPriv().getStencilAttachment();
+}
+
+
« no previous file with comments | « src/gpu/GrResourceProvider.h ('k') | src/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698