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 |
11 | 11 |
12 #include "GrSurface.h" | 12 #include "GrSurface.h" |
13 #include "GrRenderTarget.h" | |
14 #include "SkPoint.h" | 13 #include "SkPoint.h" |
15 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
16 | 15 |
17 class GrResourceKey; | 16 class GrResourceKey; |
18 class GrTextureParams; | 17 class GrTextureParams; |
19 class GrTexturePriv; | 18 class GrTexturePriv; |
20 | 19 |
21 class GrTexture : public GrSurface { | 20 class GrTexture : virtual public GrSurface { |
22 public: | 21 public: |
23 /** | 22 /** |
24 * Approximate number of bytes used by the texture | 23 * Approximate number of bytes used by the texture |
25 */ | 24 */ |
26 virtual size_t gpuMemorySize() const SK_OVERRIDE; | 25 virtual size_t gpuMemorySize() const SK_OVERRIDE; |
27 | 26 |
28 virtual GrTexture* asTexture() SK_OVERRIDE { return this; } | 27 virtual GrTexture* asTexture() SK_OVERRIDE { return this; } |
29 virtual const GrTexture* asTexture() const SK_OVERRIDE { return this; } | 28 virtual const GrTexture* asTexture() const SK_OVERRIDE { return this; } |
30 virtual GrRenderTarget* asRenderTarget() SK_OVERRIDE { return fRenderTarget.
get(); } | |
31 virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return fR
enderTarget.get(); } | |
32 | 29 |
33 /** | 30 /** |
34 * Return the native ID or handle to the texture, depending on the | 31 * Return the native ID or handle to the texture, depending on the |
35 * platform. e.g. on OpenGL, return the texture ID. | 32 * platform. e.g. on OpenGL, return the texture ID. |
36 */ | 33 */ |
37 virtual GrBackendObject getTextureHandle() const = 0; | 34 virtual GrBackendObject getTextureHandle() const = 0; |
38 | 35 |
39 /** | 36 /** |
40 * This function indicates that the texture parameters (wrap mode, filtering
, ...) have been | 37 * This function indicates that the texture parameters (wrap mode, filtering
, ...) have been |
41 * changed externally to Skia. | 38 * changed externally to Skia. |
42 */ | 39 */ |
43 virtual void textureParamsModified() = 0; | 40 virtual void textureParamsModified() = 0; |
44 | 41 |
45 #ifdef SK_DEBUG | 42 #ifdef SK_DEBUG |
46 void validate() const { | 43 void validate() const { |
47 this->INHERITED::validate(); | 44 this->INHERITED::validate(); |
48 this->validateDesc(); | 45 this->validateDesc(); |
49 } | 46 } |
50 #endif | 47 #endif |
51 | 48 |
52 /** Access methods that are only to be used within Skia code. */ | 49 /** Access methods that are only to be used within Skia code. */ |
53 inline GrTexturePriv texturePriv(); | 50 inline GrTexturePriv texturePriv(); |
54 inline const GrTexturePriv texturePriv() const; | 51 inline const GrTexturePriv texturePriv() const; |
55 | 52 |
56 protected: | 53 protected: |
57 // A texture refs its rt representation but not vice-versa. It is up to | |
58 // the subclass constructor to initialize this pointer. | |
59 SkAutoTUnref<GrRenderTarget> fRenderTarget; | |
60 | |
61 GrTexture(GrGpu* gpu, bool isWrapped, const GrSurfaceDesc& desc); | 54 GrTexture(GrGpu* gpu, bool isWrapped, const GrSurfaceDesc& desc); |
62 | 55 |
63 virtual ~GrTexture(); | |
64 | |
65 // GrResource overrides | |
66 virtual void onRelease() SK_OVERRIDE; | |
67 virtual void onAbandon() SK_OVERRIDE; | |
68 | |
69 void validateDesc() const; | 56 void validateDesc() const; |
70 | 57 |
71 private: | 58 private: |
72 void dirtyMipMaps(bool mipMapsDirty); | 59 void dirtyMipMaps(bool mipMapsDirty); |
73 | 60 |
74 enum MipMapsStatus { | 61 enum MipMapsStatus { |
75 kNotAllocated_MipMapsStatus, | 62 kNotAllocated_MipMapsStatus, |
76 kAllocated_MipMapsStatus, | 63 kAllocated_MipMapsStatus, |
77 kValid_MipMapsStatus | 64 kValid_MipMapsStatus |
78 }; | 65 }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 fTexture.reset(SkSafeRef(texture)); | 108 fTexture.reset(SkSafeRef(texture)); |
122 return texture; | 109 return texture; |
123 } | 110 } |
124 | 111 |
125 private: | 112 private: |
126 SkAutoTUnref<GrTexture> fTexture; | 113 SkAutoTUnref<GrTexture> fTexture; |
127 SkIPoint fOffset; | 114 SkIPoint fOffset; |
128 }; | 115 }; |
129 | 116 |
130 #endif | 117 #endif |
OLD | NEW |