aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-24 12:19:05 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-24 12:19:06 -0800
commit19cd0f1813c4050e7604e1c5b9b5c7ca3de85e7b (patch)
treec637ddfec1b517b372e8bf6612672ead4e151816 /src
parent90d0ff013bbd8e5295d1517d41cb408e9d9f4d93 (diff)
Revert "Use scratch keys for stencil buffers."
This reverts commit 91175f19664a62851da4ca4e0984a7c7c45b258f. Revert "Cleanup res cache bench and split out into a unit test." This reverts commit 4e4303f002c5958c6c958e7ba8e49b24c25f0b22. Revert "rebaselines" This reverts commit 65ba7b57759bfca60b24bc34dc46fc8caaf146f0. TBR=tomhudson@google.com Review URL: https://codereview.chromium.org/752233002
Diffstat (limited to 'src')
-rwxr-xr-xsrc/gpu/GrContext.cpp17
-rw-r--r--src/gpu/GrGpu.cpp9
-rw-r--r--src/gpu/GrStencilBuffer.cpp6
-rw-r--r--src/gpu/GrStencilBuffer.h4
-rw-r--r--src/gpu/gl/GrGpuGL.cpp4
5 files changed, 33 insertions, 7 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 607d3c3cc7..657e57da33 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -24,6 +24,7 @@
#include "GrPathUtils.h"
#include "GrResourceCache2.h"
#include "GrSoftwarePathRenderer.h"
+#include "GrStencilBuffer.h"
#include "GrStencilAndCoverTextContext.h"
#include "GrStrokeInfo.h"
#include "GrSurfacePriv.h"
@@ -251,6 +252,22 @@ bool GrContext::isTextureInCache(const GrSurfaceDesc& desc,
return fResourceCache2->hasContentKey(resourceKey);
}
+void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
+ // TODO: Make GrStencilBuffers use the scratch mechanism rather than content keys.
+ ASSERT_OWNED_RESOURCE(sb);
+
+ GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(),
+ sb->height(),
+ sb->numSamples());
+ SkAssertResult(sb->cacheAccess().setContentKey(resourceKey));
+}
+
+GrStencilBuffer* GrContext::findAndRefStencilBuffer(int width, int height, int sampleCnt) {
+ GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, height, sampleCnt);
+ GrGpuResource* resource = this->findAndRefCachedResource(resourceKey);
+ return static_cast<GrStencilBuffer*>(resource);
+}
+
static void stretch_image(void* dst,
int dstW,
int dstH,
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 6b742c4cc3..2bda594b9a 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -13,12 +13,14 @@
#include "GrContext.h"
#include "GrDrawTargetCaps.h"
#include "GrIndexBuffer.h"
-#include "GrResourceCache2.h"
#include "GrStencilBuffer.h"
#include "GrVertexBuffer.h"
////////////////////////////////////////////////////////////////////////////////
+#define DEBUG_INVAL_BUFFER 0xdeadcafe
+#define DEBUG_INVAL_START_IDX -1
+
GrGpu::GrGpu(GrContext* context)
: fResetTimestamp(kExpiredTimestamp+1)
, fResetBits(kAll_GrBackendState)
@@ -76,9 +78,8 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc,
bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
SkASSERT(NULL == rt->getStencilBuffer());
- GrResourceKey sbKey = GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples());
- SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>(
- this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey)));
+ SkAutoTUnref<GrStencilBuffer> sb(
+ this->getContext()->findAndRefStencilBuffer(rt->width(), rt->height(), rt->numSamples()));
if (sb) {
rt->setStencilBuffer(sb);
bool attached = this->attachStencilBufferToRenderTarget(sb, rt);
diff --git a/src/gpu/GrStencilBuffer.cpp b/src/gpu/GrStencilBuffer.cpp
index 5aa56e0717..16b0150a4d 100644
--- a/src/gpu/GrStencilBuffer.cpp
+++ b/src/gpu/GrStencilBuffer.cpp
@@ -12,10 +12,14 @@
#include "GrGpu.h"
#include "GrResourceCache2.h"
+void GrStencilBuffer::transferToCache() {
+ this->getGpu()->getContext()->addStencilBuffer(this);
+}
+
namespace {
// we should never have more than one stencil buffer with same combo of (width,height,samplecount)
void gen_cache_id(int width, int height, int sampleCnt, GrCacheID* cacheID) {
- static const GrCacheID::Domain gStencilBufferDomain = GrResourceKey::ScratchDomain();
+ static const GrCacheID::Domain gStencilBufferDomain = GrCacheID::GenerateDomain();
GrCacheID::Key key;
uint32_t* keyData = key.fData32;
keyData[0] = width;
diff --git a/src/gpu/GrStencilBuffer.h b/src/gpu/GrStencilBuffer.h
index 187556bd4c..86fef50225 100644
--- a/src/gpu/GrStencilBuffer.h
+++ b/src/gpu/GrStencilBuffer.h
@@ -47,6 +47,9 @@ public:
!fLastClipStackRect.contains(clipSpaceRect);
}
+ // Places the sb in the cache. The cache takes a ref of the stencil buffer.
+ void transferToCache();
+
static GrResourceKey ComputeKey(int width, int height, int sampleCnt);
protected:
@@ -57,7 +60,6 @@ protected:
, fBits(bits)
, fSampleCnt(sampleCnt)
, fLastClipStackGenID(SkClipStack::kInvalidGenID) {
- this->setScratchKey(ComputeKey(width, height, sampleCnt));
fLastClipStackRect.setEmpty();
}
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index c873c1d0df..9e1f754a82 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1121,7 +1121,8 @@ void inline get_stencil_rb_sizes(const GrGLInterface* gl,
}
}
-bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) {
+bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
+ int width, int height) {
// All internally created RTs are also textures. We don't create
// SBs for a client's standalone RT (that is a RT that isn't also a texture).
@@ -1175,6 +1176,7 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width,
sbID = 0;
if (this->attachStencilBufferToRenderTarget(sb, rt)) {
fLastSuccessfulStencilFmtIdx = sIdx;
+ sb->transferToCache();
rt->setStencilBuffer(sb);
return true;
}