| 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 | 9 |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 // These flags need to fit in a GrResourceKey::ResourceFlags so they can be fold
ed into the texture | 107 // These flags need to fit in a GrResourceKey::ResourceFlags so they can be fold
ed into the texture |
| 108 // key | 108 // key |
| 109 enum TextureFlags { | 109 enum TextureFlags { |
| 110 /** | 110 /** |
| 111 * The kStretchToPOT bit is set when the texture is NPOT and is being repeat
ed but the | 111 * The kStretchToPOT bit is set when the texture is NPOT and is being repeat
ed but the |
| 112 * hardware doesn't support that feature. | 112 * hardware doesn't support that feature. |
| 113 */ | 113 */ |
| 114 kStretchToPOT_TextureFlag = 0x1, | 114 kStretchToPOT_TextureFlag = 0x1, |
| 115 /** | 115 /** |
| 116 * The kFilter bit can only be set when the kStretchToPOT flag is set and in
dicates whether the | 116 * The kBilerp bit can only be set when the kStretchToPOT flag is set and in
dicates whether the |
| 117 * stretched texture should be bilerp filtered or point sampled. | 117 * stretched texture should be bilerped. |
| 118 */ | 118 */ |
| 119 kFilter_TextureFlag = 0x2, | 119 kBilerp_TextureFlag = 0x2, |
| 120 /** |
| 121 * The kMipMap bit can only be set when the kStretchToPOT flag is set and in
dicates whether the |
| 122 * stretched texture should have mipmaps computed. |
| 123 */ |
| 124 kMipMap_TextureFlag = 0x4, |
| 120 }; | 125 }; |
| 121 | 126 |
| 122 namespace { | 127 namespace { |
| 123 GrResourceKey::ResourceFlags get_texture_flags(const GrGpu* gpu, | 128 GrResourceKey::ResourceFlags get_texture_flags(const GrGpu* gpu, |
| 124 const GrTextureParams* params, | 129 const GrTextureParams* params, |
| 125 const GrTextureDesc& desc) { | 130 const GrTextureDesc& desc) { |
| 126 GrResourceKey::ResourceFlags flags = 0; | 131 GrResourceKey::ResourceFlags flags = 0; |
| 127 bool tiled = NULL != params && params->isTiled(); | 132 bool tiled = NULL != params && params->isTiled(); |
| 128 if (tiled && !gpu->caps()->npotTextureTileSupport()) { | 133 if (tiled && !gpu->caps()->npotTextureTileSupport()) { |
| 129 if (!GrIsPow2(desc.fWidth) || !GrIsPow2(desc.fHeight)) { | 134 if (!GrIsPow2(desc.fWidth) || !GrIsPow2(desc.fHeight)) { |
| 130 flags |= kStretchToPOT_TextureFlag; | 135 flags |= kStretchToPOT_TextureFlag; |
| 131 if (params->isBilerp()) { | 136 switch(params->filterMode()) { |
| 132 flags |= kFilter_TextureFlag; | 137 case GrTextureParams::kNone_FilterMode: |
| 138 break; |
| 139 case GrTextureParams::kBilerp_FilterMode: |
| 140 flags |= kBilerp_TextureFlag; |
| 141 break; |
| 142 case GrTextureParams::kMipMap_FilterMode: |
| 143 flags |= kMipMap_TextureFlag; |
| 144 break; |
| 133 } | 145 } |
| 134 } | 146 } |
| 135 } | 147 } |
| 136 return flags; | 148 return flags; |
| 137 } | 149 } |
| 138 | 150 |
| 139 GrResourceKey::ResourceType texture_resource_type() { | 151 GrResourceKey::ResourceType texture_resource_type() { |
| 140 static const GrResourceKey::ResourceType gType = GrResourceKey::GenerateReso
urceType(); | 152 static const GrResourceKey::ResourceType gType = GrResourceKey::GenerateReso
urceType(); |
| 141 return gType; | 153 return gType; |
| 142 } | 154 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 memset(idKey.fData8 + 16, 0, kPadSize); | 191 memset(idKey.fData8 + 16, 0, kPadSize); |
| 180 | 192 |
| 181 GrCacheID cacheID(GrResourceKey::ScratchDomain(), idKey); | 193 GrCacheID cacheID(GrResourceKey::ScratchDomain(), idKey); |
| 182 return GrResourceKey(cacheID, texture_resource_type(), 0); | 194 return GrResourceKey(cacheID, texture_resource_type(), 0); |
| 183 } | 195 } |
| 184 | 196 |
| 185 bool GrTexture::NeedsResizing(const GrResourceKey& key) { | 197 bool GrTexture::NeedsResizing(const GrResourceKey& key) { |
| 186 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 198 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
| 187 } | 199 } |
| 188 | 200 |
| 189 bool GrTexture::NeedsFiltering(const GrResourceKey& key) { | 201 bool GrTexture::NeedsBilerp(const GrResourceKey& key) { |
| 190 return SkToBool(key.getResourceFlags() & kFilter_TextureFlag); | 202 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
| 191 } | 203 } |
| 204 |
| 205 bool GrTexture::NeedsMipMap(const GrResourceKey& key) { |
| 206 return SkToBool(key.getResourceFlags() & kMipMap_TextureFlag); |
| 207 } |
| OLD | NEW |