OLD | NEW |
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*>(getGpu()) |
12 | 12 |
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 void GrGLTexture::init(GrGpuGL* gpu, | 15 void GrGLTexture::init(GrGpuGL* gpu, |
16 const Desc& textureDesc, | 16 const Desc& textureDesc, |
17 const GrGLRenderTarget::Desc* rtDesc) { | 17 const GrGLRenderTarget::Desc* rtDesc) { |
18 | 18 |
19 SkASSERT(0 != textureDesc.fTextureID); | 19 SkASSERT(0 != textureDesc.fTextureID); |
20 | 20 |
21 fTexParams.invalidate(); | 21 fTexParams.invalidate(); |
22 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; | 22 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; |
23 fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(), | 23 fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(), |
24 textureDesc.fTextureID, | 24 textureDesc.fTextureID, |
25 textureDesc.fIsWrapped))); | 25 textureDesc.fIsWrapped))); |
26 | 26 |
27 if (NULL != rtDesc) { | 27 if (rtDesc) { |
28 GrGLIRect vp; | 28 GrGLIRect vp; |
29 vp.fLeft = 0; | 29 vp.fLeft = 0; |
30 vp.fWidth = textureDesc.fWidth; | 30 vp.fWidth = textureDesc.fWidth; |
31 vp.fBottom = 0; | 31 vp.fBottom = 0; |
32 vp.fHeight = textureDesc.fHeight; | 32 vp.fHeight = textureDesc.fHeight; |
33 | 33 |
34 fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtDesc, vp, fTex
IDObj, this))); | 34 fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtDesc, vp, fTex
IDObj, this))); |
35 } | 35 } |
36 this->registerWithCache(); | 36 this->registerWithCache(); |
37 } | 37 } |
(...skipping 10 matching lines...) Expand all Loading... |
48 : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) { | 48 : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) { |
49 this->init(gpu, textureDesc, &rtDesc); | 49 this->init(gpu, textureDesc, &rtDesc); |
50 } | 50 } |
51 | 51 |
52 void GrGLTexture::onRelease() { | 52 void GrGLTexture::onRelease() { |
53 fTexIDObj.reset(NULL); | 53 fTexIDObj.reset(NULL); |
54 INHERITED::onRelease(); | 54 INHERITED::onRelease(); |
55 } | 55 } |
56 | 56 |
57 void GrGLTexture::onAbandon() { | 57 void GrGLTexture::onAbandon() { |
58 if (NULL != fTexIDObj.get()) { | 58 if (fTexIDObj.get()) { |
59 fTexIDObj->abandon(); | 59 fTexIDObj->abandon(); |
60 fTexIDObj.reset(NULL); | 60 fTexIDObj.reset(NULL); |
61 } | 61 } |
62 | 62 |
63 INHERITED::onAbandon(); | 63 INHERITED::onAbandon(); |
64 } | 64 } |
65 | 65 |
66 GrBackendObject GrGLTexture::getTextureHandle() const { | 66 GrBackendObject GrGLTexture::getTextureHandle() const { |
67 return static_cast<GrBackendObject>(this->textureID()); | 67 return static_cast<GrBackendObject>(this->textureID()); |
68 } | 68 } |
OLD | NEW |