Index: src/gpu/SkGr.cpp |
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
index ba6b197fa38631aa37d56f7250e8fea8562f41f6..5a823af8c6817d6dcaeeb90919ec191b24fdea8c 100644 |
--- a/src/gpu/SkGr.cpp |
+++ b/src/gpu/SkGr.cpp |
@@ -7,9 +7,6 @@ |
#include "SkGr.h" |
-#include "GrDrawTargetCaps.h" |
-#include "GrGpu.h" |
-#include "GrGpuResourceCacheAccess.h" |
#include "GrXferProcessor.h" |
#include "SkColorFilter.h" |
#include "SkConfig8888.h" |
@@ -96,8 +93,7 @@ enum Stretch { |
static Stretch get_stretch_type(const GrContext* ctx, int width, int height, |
const GrTextureParams* params) { |
if (params && params->isTiled()) { |
- const GrDrawTargetCaps* caps = ctx->getGpu()->caps(); |
- if (!caps->npotTextureTileSupport() && (!SkIsPow2(width) || !SkIsPow2(height))) { |
+ if (!ctx->npotTextureTileSupport() && (!SkIsPow2(width) || !SkIsPow2(height))) { |
switch(params->filterMode()) { |
case GrTextureParams::kNone_FilterMode: |
return kNearest_Stretch; |
@@ -220,7 +216,7 @@ GrTexture* resize_texture(GrTexture* inputTexture, Stretch stretch, |
} |
} |
- GrTexture* resized = context->getGpu()->createTexture(rtDesc, true, NULL, 0); |
+ GrTexture* resized = context->createTexture(rtDesc); |
if (!resized) { |
return NULL; |
@@ -254,7 +250,8 @@ static GrTexture* sk_gr_allocate_texture(GrContext* ctx, |
const void* pixels, |
size_t rowBytes) { |
GrTexture* result; |
- if (optionalKey.isValid()) { |
+ // Compressed textures cannot be scratch. |
+ if (optionalKey.isValid() || GrPixelConfigIsCompressed(desc.fConfig)) { |
result = ctx->createTexture(desc, pixels, rowBytes); |
if (result) { |
SkASSERT(ctx->addResourceToCache(optionalKey, result)); |
@@ -420,7 +417,7 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx, |
generate_bitmap_texture_desc(*bitmap, &desc); |
if (kIndex_8_SkColorType == bitmap->colorType()) { |
- if (ctx->supportsIndex8PixelConfig()) { |
+ if (ctx->isConfigTexturable(kIndex_8_GrPixelConfig)) { |
size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig, |
bitmap->width(), bitmap->height()); |
SkAutoMalloc storage(imageSize); |
@@ -439,18 +436,14 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx, |
// Is this an ETC1 encoded texture? |
#ifndef SK_IGNORE_ETC1_SUPPORT |
- else if ( |
- // We do not support scratch ETC1 textures, hence they should all be at least |
- // trying to go to the cache. |
- optionalKey.isValid() |
- // Make sure that the underlying device supports ETC1 textures before we go ahead |
- // and check the data. |
- && ctx->getGpu()->caps()->isConfigTexturable(kETC1_GrPixelConfig) |
- // If the bitmap had compressed data and was then uncompressed, it'll still return |
- // compressed data on 'refEncodedData' and upload it. Probably not good, since if |
- // the bitmap has available pixels, then they might not be what the decompressed |
- // data is. |
- && !(bitmap->readyToDraw())) { |
+ // Make sure that the underlying device supports ETC1 textures before we go ahead |
+ // and check the data. |
+ else if (ctx->isConfigTexturable(kETC1_GrPixelConfig) |
+ // If the bitmap had compressed data and was then uncompressed, it'll still return |
+ // compressed data on 'refEncodedData' and upload it. Probably not good, since if |
+ // the bitmap has available pixels, then they might not be what the decompressed |
+ // data is. |
+ && !(bitmap->readyToDraw())) { |
GrTexture *texture = load_etc1_texture(ctx, optionalKey, *bitmap, desc); |
if (texture) { |
return texture; |
@@ -458,12 +451,11 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx, |
} |
#endif // SK_IGNORE_ETC1_SUPPORT |
- else { |
bsalomon
2015/02/01 03:37:50
This else meant that when etc1 was compiled in and
|
- GrTexture *texture = load_yuv_texture(ctx, optionalKey, *bitmap, desc); |
- if (texture) { |
- return texture; |
- } |
+ GrTexture *texture = load_yuv_texture(ctx, optionalKey, *bitmap, desc); |
+ if (texture) { |
+ return texture; |
} |
+ |
SkAutoLockPixels alp(*bitmap); |
if (!bitmap->readyToDraw()) { |
return NULL; |
@@ -504,7 +496,7 @@ static GrTexture* get_texture_backing_bmp(const SkBitmap& bitmap, const GrContex |
// content-key cached resources. Rather than invest in that legacy code path, we'll just |
// take the horribly slow route of causing a cache miss which will cause the pixels to be |
// read and reuploaded to a texture with a content key. |
- if (params && !context->getGpu()->caps()->npotTextureTileSupport() && |
+ if (params && !context->npotTextureTileSupport() && |
(params->isTiled() || GrTextureParams::kMipMap_FilterMode == params->filterMode())) { |
return NULL; |
} |