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

Side by Side Diff: src/gpu/GrGpu.cpp

Issue 870103002: Zap the scratch key on non-RT textures when scratch textures are disabled. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add SkToBool Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 22 matching lines...) Expand all
33 void GrGpu::contextAbandoned() {} 33 void GrGpu::contextAbandoned() {}
34 34
35 //////////////////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////////////////
36 36
37 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, 37 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted,
38 const void* srcData, size_t rowBytes) { 38 const void* srcData, size_t rowBytes) {
39 if (!this->caps()->isConfigTexturable(desc.fConfig)) { 39 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
40 return NULL; 40 return NULL;
41 } 41 }
42 42
43 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && 43 bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
44 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 44 if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
45 return NULL; 45 return NULL;
46 } 46 }
47 47
48 GrTexture *tex = NULL; 48 GrTexture *tex = NULL;
49 if (GrPixelConfigIsCompressed(desc.fConfig)) { 49 if (GrPixelConfigIsCompressed(desc.fConfig)) {
50 // We shouldn't be rendering into this 50 // We shouldn't be rendering into this
51 SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0); 51 SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0);
52 52
53 if (!this->caps()->npotTextureTileSupport() && 53 if (!this->caps()->npotTextureTileSupport() &&
54 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) { 54 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 this->handleDirtyContext(); 58 this->handleDirtyContext();
59 tex = this->onCreateCompressedTexture(desc, budgeted, srcData); 59 tex = this->onCreateCompressedTexture(desc, budgeted, srcData);
60 } else { 60 } else {
61 this->handleDirtyContext(); 61 this->handleDirtyContext();
62 tex = this->onCreateTexture(desc, budgeted, srcData, rowBytes); 62 tex = this->onCreateTexture(desc, budgeted, srcData, rowBytes);
63 if (tex && 63 if (tex &&
64 (kRenderTarget_GrSurfaceFlag & desc.fFlags) && 64 (kRenderTarget_GrSurfaceFlag & desc.fFlags) &&
65 !(kNoStencil_GrSurfaceFlag & desc.fFlags)) { 65 !(kNoStencil_GrSurfaceFlag & desc.fFlags)) {
66 SkASSERT(tex->asRenderTarget()); 66 SkASSERT(tex->asRenderTarget());
67 // TODO: defer this and attach dynamically 67 // TODO: defer this and attach dynamically
68 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) { 68 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) {
69 tex->unref(); 69 tex->unref();
70 return NULL; 70 return NULL;
71 } 71 }
72 } 72 }
73 } 73 }
74 if (!this->caps()->reuseScratchTextures() && !isRT) {
75 tex->cacheAccess().removeScratchKey();
76 }
74 return tex; 77 return tex;
75 } 78 }
76 79
77 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { 80 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
78 SkASSERT(NULL == rt->getStencilBuffer()); 81 SkASSERT(NULL == rt->getStencilBuffer());
79 GrScratchKey sbKey; 82 GrScratchKey sbKey;
80 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb Key); 83 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb Key);
81 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( 84 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>(
82 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey ))); 85 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey )));
83 if (sb) { 86 if (sb) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 GrDrawTarget::PathIndexType indexType, 302 GrDrawTarget::PathIndexType indexType,
300 const float transformValues[], 303 const float transformValues[],
301 GrDrawTarget::PathTransformType transformType, 304 GrDrawTarget::PathTransformType transformType,
302 int count, 305 int count,
303 const GrStencilSettings& stencilSettings) { 306 const GrStencilSettings& stencilSettings) {
304 this->handleDirtyContext(); 307 this->handleDirtyContext();
305 pathRange->willDrawPaths(indices, indexType, count); 308 pathRange->willDrawPaths(indices, indexType, count);
306 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, 309 this->onDrawPaths(args, pathRange, indices, indexType, transformValues,
307 transformType, count, stencilSettings); 310 transformType, count, stencilSettings);
308 } 311 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698