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

Side by Side Diff: src/gpu/gl/GrGLTexture.cpp

Issue 1862043002: Refactor to separate backend object lifecycle and GpuResource budget decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unrelated GrBuffer::onGpuMemorySize() lack of override keyword compile error Created 4 years, 8 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 | « src/gpu/gl/GrGLTexture.h ('k') | src/gpu/gl/GrGLTextureRenderTarget.h » ('j') | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLTexture.h" 8 #include "GrGLTexture.h"
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "SkTraceMemoryDump.h" 10 #include "SkTraceMemoryDump.h"
11 11
12 #define GPUGL static_cast<GrGLGpu*>(this->getGpu()) 12 #define GPUGL static_cast<GrGLGpu*>(this->getGpu())
13 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) 13 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
14 14
15 inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrG LGpu* gpu) { 15 inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrG LGpu* gpu) {
16 if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) { 16 if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
17 SkASSERT(gpu->glCaps().glslCaps()->externalTextureSupport()); 17 SkASSERT(gpu->glCaps().glslCaps()->externalTextureSupport());
18 return kSamplerExternal_GrSLType; 18 return kSamplerExternal_GrSLType;
19 } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) { 19 } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) {
20 SkASSERT(gpu->glCaps().rectangleTextureSupport()); 20 SkASSERT(gpu->glCaps().rectangleTextureSupport());
21 return kSampler2DRect_GrSLType; 21 return kSampler2DRect_GrSLType;
22 } else { 22 } else {
23 SkASSERT(idDesc.fInfo.fTarget == GR_GL_TEXTURE_2D); 23 SkASSERT(idDesc.fInfo.fTarget == GR_GL_TEXTURE_2D);
24 return kSampler2D_GrSLType; 24 return kSampler2D_GrSLType;
25 } 25 }
26 } 26 }
27 27
28 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor. 28 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor.
29 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc) 29 GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
30 : GrSurface(gpu, idDesc.fLifeCycle, desc) 30 const IDDesc& idDesc)
31 , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), false) { 31 : GrSurface(gpu, desc)
32 , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
32 this->init(desc, idDesc); 33 this->init(desc, idDesc);
33 this->registerWithCache(); 34 this->registerWithCache(budgeted);
34 } 35 }
35 36
36 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, 37 GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
38 const IDDesc& idDesc,
37 bool wasMipMapDataProvided) 39 bool wasMipMapDataProvided)
38 : GrSurface(gpu, idDesc.fLifeCycle, desc) 40 : GrSurface(gpu, desc)
39 , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), wasMipM apDataProvided) { 41 , INHERITED(gpu, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
40 this->init(desc, idDesc); 42 this->init(desc, idDesc);
41 this->registerWithCache(); 43 this->registerWithCache(budgeted);
42 } 44 }
43 45
44 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, Derived) 46 GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const IDDesc& idDesc)
45 : GrSurface(gpu, idDesc.fLifeCycle, desc) 47 : GrSurface(gpu, desc)
46 , INHERITED(gpu, idDesc.fLifeCycle, desc, sampler_type(idDesc, gpu), false) { 48 , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
49 this->init(desc, idDesc);
50 this->registerWithCacheWrapped();
51 }
52
53 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
54 : GrSurface(gpu, desc)
55 , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
47 this->init(desc, idDesc); 56 this->init(desc, idDesc);
48 } 57 }
49 58
50 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { 59 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
51 SkASSERT(0 != idDesc.fInfo.fID); 60 SkASSERT(0 != idDesc.fInfo.fID);
52 fTexParams.invalidate(); 61 fTexParams.invalidate();
53 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; 62 fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
54 fInfo = idDesc.fInfo; 63 fInfo = idDesc.fInfo;
55 fTextureIDLifecycle = idDesc.fLifeCycle; 64 fTextureIDOwnership = idDesc.fOwnership;
56 } 65 }
57 66
58 void GrGLTexture::onRelease() { 67 void GrGLTexture::onRelease() {
59 if (fInfo.fID) { 68 if (fInfo.fID) {
60 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { 69 if (GrBackendObjectOwnership::kBorrowed != fTextureIDOwnership) {
61 GL_CALL(DeleteTextures(1, &fInfo.fID)); 70 GL_CALL(DeleteTextures(1, &fInfo.fID));
62 } 71 }
63 fInfo.fID = 0; 72 fInfo.fID = 0;
64 } 73 }
65 INHERITED::onRelease(); 74 INHERITED::onRelease();
66 } 75 }
67 76
68 void GrGLTexture::onAbandon() { 77 void GrGLTexture::onAbandon() {
69 fInfo.fTarget = 0; 78 fInfo.fTarget = 0;
70 fInfo.fID = 0; 79 fInfo.fID = 0;
71 INHERITED::onAbandon(); 80 INHERITED::onAbandon();
72 } 81 }
73 82
74 GrBackendObject GrGLTexture::getTextureHandle() const { 83 GrBackendObject GrGLTexture::getTextureHandle() const {
75 #ifdef SK_IGNORE_GL_TEXTURE_TARGET 84 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
76 return static_cast<GrBackendObject>(this->textureID()); 85 return static_cast<GrBackendObject>(this->textureID());
77 #else 86 #else
78 return reinterpret_cast<GrBackendObject>(&fInfo); 87 return reinterpret_cast<GrBackendObject>(&fInfo);
79 #endif 88 #endif
80 } 89 }
81 90
82 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, 91 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
83 const SkString& dumpName) const { 92 const SkString& dumpName) const {
84 SkString texture_id; 93 SkString texture_id;
85 texture_id.appendU32(this->textureID()); 94 texture_id.appendU32(this->textureID());
86 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", 95 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture",
87 texture_id.c_str()); 96 texture_id.c_str());
88 } 97 }
98
99 GrGLTexture* GrGLTexture::CreateWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
100 const IDDesc& idDesc) {
101 return new GrGLTexture(gpu, kWrapped, desc, idDesc);
102 }
103
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLTexture.h ('k') | src/gpu/gl/GrGLTextureRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698