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

Side by Side Diff: src/gpu/GrTexture.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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
10 #include "GrContext.h" 9 #include "GrContext.h"
11 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
12 #include "GrGpu.h" 11 #include "GrGpu.h"
13 #include "GrRenderTarget.h"
14 #include "GrResourceCache.h" 12 #include "GrResourceCache.h"
15 #include "GrTexture.h" 13 #include "GrTexture.h"
16 #include "GrTexturePriv.h" 14 #include "GrTexturePriv.h"
17 15
18 GrTexture::~GrTexture() {
19 if (fRenderTarget.get()) {
20 fRenderTarget.get()->owningTextureDestroyed();
21 }
22 }
23
24 void GrTexture::dirtyMipMaps(bool mipMapsDirty) { 16 void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
25 if (mipMapsDirty) { 17 if (mipMapsDirty) {
26 if (kValid_MipMapsStatus == fMipMapsStatus) { 18 if (kValid_MipMapsStatus == fMipMapsStatus) {
27 fMipMapsStatus = kAllocated_MipMapsStatus; 19 fMipMapsStatus = kAllocated_MipMapsStatus;
28 } 20 }
29 } else { 21 } else {
30 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; 22 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
31 fMipMapsStatus = kValid_MipMapsStatus; 23 fMipMapsStatus = kValid_MipMapsStatus;
32 if (sizeChanged) { 24 if (sizeChanged) {
33 // This must not be called until after changing fMipMapsStatus. 25 // This must not be called until after changing fMipMapsStatus.
(...skipping 12 matching lines...) Expand all
46 } 38 }
47 39
48 if (this->texturePriv().hasMipMaps()) { 40 if (this->texturePriv().hasMipMaps()) {
49 // We don't have to worry about the mipmaps being a different size than 41 // We don't have to worry about the mipmaps being a different size than
50 // we'd expect because we never change fDesc.fWidth/fHeight. 42 // we'd expect because we never change fDesc.fWidth/fHeight.
51 textureSize *= 2; 43 textureSize *= 2;
52 } 44 }
53 return textureSize; 45 return textureSize;
54 } 46 }
55 47
56 void GrTexture::onRelease() {
57
58 INHERITED::onRelease();
59 }
60
61 void GrTexture::onAbandon() {
62 if (fRenderTarget.get()) {
63 fRenderTarget->abandon();
64 }
65 INHERITED::onAbandon();
66 }
67
68 void GrTexture::validateDesc() const { 48 void GrTexture::validateDesc() const {
69 if (this->asRenderTarget()) { 49 if (this->asRenderTarget()) {
70 // This texture has a render target 50 // This texture has a render target
71 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); 51 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag));
72 52
73 if (this->asRenderTarget()->getStencilBuffer()) { 53 if (this->asRenderTarget()->getStencilBuffer()) {
74 SkASSERT(0 != (fDesc.fFlags & kNoStencil_GrSurfaceFlag)); 54 SkASSERT(0 != (fDesc.fFlags & kNoStencil_GrSurfaceFlag));
75 } else { 55 } else {
76 SkASSERT(0 == (fDesc.fFlags & kNoStencil_GrSurfaceFlag)); 56 SkASSERT(0 == (fDesc.fFlags & kNoStencil_GrSurfaceFlag));
77 } 57 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; 113 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin;
134 } else { 114 } else {
135 return desc.fOrigin; 115 return desc.fOrigin;
136 } 116 }
137 } 117 }
138 } 118 }
139 119
140 ////////////////////////////////////////////////////////////////////////////// 120 //////////////////////////////////////////////////////////////////////////////
141 GrTexture::GrTexture(GrGpu* gpu, bool isWrapped, const GrSurfaceDesc& desc) 121 GrTexture::GrTexture(GrGpu* gpu, bool isWrapped, const GrSurfaceDesc& desc)
142 : INHERITED(gpu, isWrapped, desc) 122 : INHERITED(gpu, isWrapped, desc)
143 , fRenderTarget(NULL)
144 , fMipMapsStatus(kNotAllocated_MipMapsStatus) { 123 , fMipMapsStatus(kNotAllocated_MipMapsStatus) {
145 this->setScratchKey(GrTexturePriv::ComputeScratchKey(desc)); 124 this->setScratchKey(GrTexturePriv::ComputeScratchKey(desc));
146 // only make sense if alloc size is pow2 125 // only make sense if alloc size is pow2
147 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); 126 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
148 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); 127 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
149 } 128 }
150 129
151 GrResourceKey GrTexturePriv::ComputeKey(const GrGpu* gpu, 130 GrResourceKey GrTexturePriv::ComputeKey(const GrGpu* gpu,
152 const GrTextureParams* params, 131 const GrTextureParams* params,
153 const GrSurfaceDesc& desc, 132 const GrSurfaceDesc& desc,
(...skipping 21 matching lines...) Expand all
175 return GrResourceKey(cacheID, ResourceType(), 0); 154 return GrResourceKey(cacheID, ResourceType(), 0);
176 } 155 }
177 156
178 bool GrTexturePriv::NeedsResizing(const GrResourceKey& key) { 157 bool GrTexturePriv::NeedsResizing(const GrResourceKey& key) {
179 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); 158 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag);
180 } 159 }
181 160
182 bool GrTexturePriv::NeedsBilerp(const GrResourceKey& key) { 161 bool GrTexturePriv::NeedsBilerp(const GrResourceKey& key) {
183 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); 162 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag);
184 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698