| OLD | NEW |
| 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 #ifndef GrTexture_DEFINED | 9 #ifndef GrTexture_DEFINED |
| 10 #define GrTexture_DEFINED | 10 #define GrTexture_DEFINED |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 void setFlag(GrTextureFlags flags) { | 37 void setFlag(GrTextureFlags flags) { |
| 38 fDesc.fFlags = fDesc.fFlags | flags; | 38 fDesc.fFlags = fDesc.fFlags | flags; |
| 39 } | 39 } |
| 40 void resetFlag(GrTextureFlags flags) { | 40 void resetFlag(GrTextureFlags flags) { |
| 41 fDesc.fFlags = fDesc.fFlags & ~flags; | 41 fDesc.fFlags = fDesc.fFlags & ~flags; |
| 42 } | 42 } |
| 43 bool isSetFlag(GrTextureFlags flags) const { | 43 bool isSetFlag(GrTextureFlags flags) const { |
| 44 return 0 != (fDesc.fFlags & flags); | 44 return 0 != (fDesc.fFlags & flags); |
| 45 } | 45 } |
| 46 |
| 47 void dirtyMipMaps(bool mipMapsDirty) { |
| 48 fMipMapsDirty = mipMapsDirty; |
| 49 } |
| 50 |
| 51 bool mipMapsAreDirty() const { |
| 52 return fMipMapsDirty; |
| 53 } |
| 46 | 54 |
| 47 /** | 55 /** |
| 48 * Approximate number of bytes used by the texture | 56 * Approximate number of bytes used by the texture |
| 49 */ | 57 */ |
| 50 virtual size_t sizeInBytes() const SK_OVERRIDE { | 58 virtual size_t sizeInBytes() const SK_OVERRIDE { |
| 51 return (size_t) fDesc.fWidth * | 59 return (size_t) fDesc.fWidth * |
| 52 fDesc.fHeight * | 60 fDesc.fHeight * |
| 53 GrBytesPerPixel(fDesc.fConfig); | 61 GrBytesPerPixel(fDesc.fConfig); |
| 54 } | 62 } |
| 55 | 63 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 static bool NeedsResizing(const GrResourceKey& key); | 137 static bool NeedsResizing(const GrResourceKey& key); |
| 130 static bool NeedsBilerp(const GrResourceKey& key); | 138 static bool NeedsBilerp(const GrResourceKey& key); |
| 131 | 139 |
| 132 protected: | 140 protected: |
| 133 // A texture refs its rt representation but not vice-versa. It is up to | 141 // A texture refs its rt representation but not vice-versa. It is up to |
| 134 // the subclass constructor to initialize this pointer. | 142 // the subclass constructor to initialize this pointer. |
| 135 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 143 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 136 | 144 |
| 137 GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) | 145 GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) |
| 138 : INHERITED(gpu, isWrapped, desc) | 146 : INHERITED(gpu, isWrapped, desc) |
| 139 , fRenderTarget(NULL) { | 147 , fRenderTarget(NULL) |
| 148 , fMipMapsDirty(true) { |
| 140 | 149 |
| 141 // only make sense if alloc size is pow2 | 150 // only make sense if alloc size is pow2 |
| 142 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); | 151 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); |
| 143 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); | 152 fShiftFixedY = 31 - SkCLZ(fDesc.fHeight); |
| 144 } | 153 } |
| 145 virtual ~GrTexture(); | 154 virtual ~GrTexture(); |
| 146 | 155 |
| 147 // GrResource overrides | 156 // GrResource overrides |
| 148 virtual void onRelease() SK_OVERRIDE; | 157 virtual void onRelease() SK_OVERRIDE; |
| 149 virtual void onAbandon() SK_OVERRIDE; | 158 virtual void onAbandon() SK_OVERRIDE; |
| 150 | 159 |
| 151 void validateDesc() const; | 160 void validateDesc() const; |
| 152 | 161 |
| 153 private: | 162 private: |
| 154 // these two shift a fixed-point value into normalized coordinates | 163 // these two shift a fixed-point value into normalized coordinates |
| 155 // for this texture if the texture is power of two sized. | 164 // for this texture if the texture is power of two sized. |
| 156 int fShiftFixedX; | 165 int fShiftFixedX; |
| 157 int fShiftFixedY; | 166 int fShiftFixedY; |
| 167 |
| 168 bool fMipMapsDirty; |
| 158 | 169 |
| 159 virtual void internal_dispose() const SK_OVERRIDE; | 170 virtual void internal_dispose() const SK_OVERRIDE; |
| 160 | 171 |
| 161 typedef GrSurface INHERITED; | 172 typedef GrSurface INHERITED; |
| 162 }; | 173 }; |
| 163 | 174 |
| 164 /** | 175 /** |
| 165 * Represents a texture that is intended to be accessed in device coords with an
offset. | 176 * Represents a texture that is intended to be accessed in device coords with an
offset. |
| 166 */ | 177 */ |
| 167 class GrDeviceCoordTexture { | 178 class GrDeviceCoordTexture { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 193 GrTexture* setTexture(GrTexture* texture) { | 204 GrTexture* setTexture(GrTexture* texture) { |
| 194 fTexture.reset(SkSafeRef(texture)); | 205 fTexture.reset(SkSafeRef(texture)); |
| 195 return texture; | 206 return texture; |
| 196 } | 207 } |
| 197 private: | 208 private: |
| 198 SkAutoTUnref<GrTexture> fTexture; | 209 SkAutoTUnref<GrTexture> fTexture; |
| 199 SkIPoint fOffset; | 210 SkIPoint fOffset; |
| 200 }; | 211 }; |
| 201 | 212 |
| 202 #endif | 213 #endif |
| OLD | NEW |