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

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

Issue 695813003: Add class GrGLTextureRenderTarget for GL texture/rendertarget objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: forgot to save file Created 6 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 "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 10
11 #define GPUGL static_cast<GrGpuGL*>(getGpu()) 11 #define GPUGL static_cast<GrGpuGL*>(this->getGpu())
12
13 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) 12 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
14 13
15 void GrGLTexture::init(GrGpuGL* gpu, 14 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor.
16 const GrSurfaceDesc& desc, 15 GrGLTexture::GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
17 const IDDesc& idDesc, 16 : GrSurface(gpu, idDesc.fIsWrapped, desc)
18 const GrGLRenderTarget::IDDesc* rtIDDesc) { 17 , INHERITED(gpu, idDesc.fIsWrapped, desc) {
18 this->init(desc, idDesc);
19 this->registerWithCache();
20 }
19 21
22 GrGLTexture::GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc, Derived)
23 : GrSurface(gpu, idDesc.fIsWrapped, desc)
24 , INHERITED(gpu, idDesc.fIsWrapped, desc) {
25 this->init(desc, idDesc);
26 }
27
28 void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
20 SkASSERT(0 != idDesc.fTextureID); 29 SkASSERT(0 != idDesc.fTextureID);
21
22 fTexParams.invalidate(); 30 fTexParams.invalidate();
23 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; 31 fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
24 fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(), 32 fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(),
25 idDesc.fTextureID, 33 idDesc.fTextureID,
26 idDesc.fIsWrapped))); 34 idDesc.fIsWrapped)));
27
28 if (rtIDDesc) {
29 GrGLIRect vp;
30 vp.fLeft = 0;
31 vp.fWidth = desc.fWidth;
32 vp.fBottom = 0;
33 vp.fHeight = desc.fHeight;
34
35 fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtIDDesc, vp, fT exIDObj, this)));
36 }
37 this->registerWithCache();
38 }
39
40 GrGLTexture::GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
41 : INHERITED(gpu, idDesc.fIsWrapped, desc) {
42 this->init(gpu, desc, idDesc, NULL);
43 }
44
45 GrGLTexture::GrGLTexture(GrGpuGL* gpu,
46 const GrSurfaceDesc& desc,
47 const IDDesc& idDesc,
48 const GrGLRenderTarget::IDDesc& rtIDDesc)
49 : INHERITED(gpu, idDesc.fIsWrapped, desc) {
50 this->init(gpu, desc, idDesc, &rtIDDesc);
51 } 35 }
52 36
53 void GrGLTexture::onRelease() { 37 void GrGLTexture::onRelease() {
54 fTexIDObj.reset(NULL); 38 fTexIDObj.reset(NULL);
55 INHERITED::onRelease(); 39 INHERITED::onRelease();
56 } 40 }
57 41
58 void GrGLTexture::onAbandon() { 42 void GrGLTexture::onAbandon() {
59 if (fTexIDObj.get()) { 43 if (fTexIDObj.get()) {
60 fTexIDObj->abandon(); 44 fTexIDObj->abandon();
61 fTexIDObj.reset(NULL); 45 fTexIDObj.reset(NULL);
62 } 46 }
63 47
64 INHERITED::onAbandon(); 48 INHERITED::onAbandon();
65 } 49 }
66 50
67 GrBackendObject GrGLTexture::getTextureHandle() const { 51 GrBackendObject GrGLTexture::getTextureHandle() const {
68 return static_cast<GrBackendObject>(this->textureID()); 52 return static_cast<GrBackendObject>(this->textureID());
69 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698