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

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

Issue 1429863009: Use a struct for client GL texture handles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 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 unified diff | Download patch
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 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor. 15 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor.
16 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc) 16 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
17 : GrSurface(gpu, idDesc.fLifeCycle, desc) 17 : GrSurface(gpu, idDesc.fLifeCycle, desc)
18 , INHERITED(gpu, idDesc.fLifeCycle, desc) { 18 , INHERITED(gpu, idDesc.fLifeCycle, desc) {
19 this->init(desc, idDesc); 19 this->init(desc, idDesc);
20 this->registerWithCache(); 20 this->registerWithCache();
21 } 21 }
22 22
23 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, Derived) 23 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, Derived)
24 : GrSurface(gpu, idDesc.fLifeCycle, desc) 24 : GrSurface(gpu, idDesc.fLifeCycle, desc)
25 , INHERITED(gpu, idDesc.fLifeCycle, desc) { 25 , INHERITED(gpu, idDesc.fLifeCycle, desc) {
26 this->init(desc, idDesc); 26 this->init(desc, idDesc);
27 } 27 }
28 28
29 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { 29 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
30 SkASSERT(0 != idDesc.fTextureID); 30 SkASSERT(0 != idDesc.fInfo.fID);
31 fTexParams.invalidate(); 31 fTexParams.invalidate();
32 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; 32 fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
33 fTarget = idDesc.fTarget; 33 fInfo = idDesc.fInfo;
34 fTextureID = idDesc.fTextureID;
35 fTextureIDLifecycle = idDesc.fLifeCycle; 34 fTextureIDLifecycle = idDesc.fLifeCycle;
36 } 35 }
37 36
38 void GrGLTexture::onRelease() { 37 void GrGLTexture::onRelease() {
39 if (fTextureID) { 38 if (fInfo.fID) {
40 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { 39 if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) {
41 GL_CALL(DeleteTextures(1, &fTextureID)); 40 GL_CALL(DeleteTextures(1, &fInfo.fID));
42 } 41 }
43 fTextureID = 0; 42 fInfo.fID = 0;
44 } 43 }
45 INHERITED::onRelease(); 44 INHERITED::onRelease();
46 } 45 }
47 46
48 void GrGLTexture::onAbandon() { 47 void GrGLTexture::onAbandon() {
49 fTextureID = 0; 48 fInfo.fTarget = 0;
49 fInfo.fID = 0;
50 INHERITED::onAbandon(); 50 INHERITED::onAbandon();
51 } 51 }
52 52
53 GrBackendObject GrGLTexture::getTextureHandle() const { 53 GrBackendObject GrGLTexture::getTextureHandle() const {
54 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
54 return static_cast<GrBackendObject>(this->textureID()); 55 return static_cast<GrBackendObject>(this->textureID());
56 #else
57 return reinterpret_cast<GrBackendObject>(&fInfo);
58 #endif
55 } 59 }
56 60
57 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, 61 void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
58 const SkString& dumpName) const { 62 const SkString& dumpName) const {
59 SkString texture_id; 63 SkString texture_id;
60 texture_id.appendU32(this->textureID()); 64 texture_id.appendU32(this->textureID());
61 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", 65 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture",
62 texture_id.c_str()); 66 texture_id.c_str());
63 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698