OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef GrTextureProvider_DEFINED | 8 #ifndef GrTextureProvider_DEFINED |
9 #define GrTextureProvider_DEFINED | 9 #define GrTextureProvider_DEFINED |
10 | 10 |
11 #include "GrTexture.h" | 11 #include "GrTexture.h" |
| 12 #include "SkMipMapLevel.h" |
| 13 #include "SkTArray.h" |
12 | 14 |
13 class SK_API GrTextureProvider { | 15 class SK_API GrTextureProvider { |
14 public: | 16 public: |
15 /////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////// |
16 // Textures | 18 // Textures |
17 | 19 |
18 /** | 20 /** |
19 * Creates a new texture in the resource cache and returns it. The caller ow
ns a | 21 * Creates a new texture in the resource cache and returns it. The caller ow
ns a |
20 * ref on the returned texture which must be balanced by a call to unref. | 22 * ref on the returned texture which must be balanced by a call to unref. |
21 * | 23 * |
22 * @param desc Description of the texture properties. | 24 * @param desc Description of the texture properties. |
23 * @param budgeted Does the texture count against the resource cache budget
? | 25 * @param budgeted Does the texture count against the resource cache budget
? |
24 * @param srcData Pointer to the pixel values (optional). | 26 * @param srcData Pointer to the pixel values (optional). |
25 * @param rowBytes The number of bytes between rows of the texture. Zero | 27 * @param rowBytes The number of bytes between rows of the texture. Zero |
26 * implies tightly packed rows. For compressed pixel config
s, this | 28 * implies tightly packed rows. For compressed pixel config
s, this |
27 * field is ignored. | 29 * field is ignored. |
28 */ | 30 */ |
29 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, const voi
d* srcData, | 31 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, const voi
d* srcData, |
30 size_t rowBytes); | 32 size_t rowBytes); |
31 | 33 |
32 /** Shortcut for creating a texture with no initial data to upload. */ | 34 /** Shortcut for creating a texture with no initial data to upload. */ |
33 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted) { | 35 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted) { |
34 return this->createTexture(desc, budgeted, NULL, 0); | 36 return this->createTexture(desc, budgeted, NULL, 0); |
35 } | 37 } |
36 | 38 |
| 39 /** |
| 40 * Creates a new texture in the resource cache and returns it. The caller ow
ns a |
| 41 * ref on the returned texture which must be balanced by a call to unref. |
| 42 * |
| 43 * @param desc Description of the texture properties. |
| 44 * @param budgeted Does the texture count against the resource cache budget? |
| 45 * @param texels An array of mipmap levels |
| 46 */ |
| 47 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| 48 const SkTArray<SkMipMapLevel>& texels); |
| 49 |
37 /** Assigns a unique key to the texture. The texture will be findable via th
is key using | 50 /** Assigns a unique key to the texture. The texture will be findable via th
is key using |
38 findTextureByUniqueKey(). If an existing texture has this key, it's key
will be removed. */ | 51 findTextureByUniqueKey(). If an existing texture has this key, it's key
will be removed. */ |
39 void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) { | 52 void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) { |
40 this->assignUniqueKeyToResource(key, texture); | 53 this->assignUniqueKeyToResource(key, texture); |
41 } | 54 } |
42 | 55 |
43 /** Finds a texture by unique key. If the texture is found it is ref'ed and
returned. */ | 56 /** Finds a texture by unique key. If the texture is found it is ref'ed and
returned. */ |
44 GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key) { | 57 GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key) { |
45 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 58 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
46 if (resource) { | 59 if (resource) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); | 169 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); |
157 return !SkToBool(fCache); | 170 return !SkToBool(fCache); |
158 } | 171 } |
159 | 172 |
160 private: | 173 private: |
161 GrResourceCache* fCache; | 174 GrResourceCache* fCache; |
162 GrGpu* fGpu; | 175 GrGpu* fGpu; |
163 }; | 176 }; |
164 | 177 |
165 #endif | 178 #endif |
OLD | NEW |