Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: src/gpu/SkGr.cpp

Issue 880983008: More cleanup around GrContext, textures, and SkGr.cpp (Closed) Base URL: https://skia.googlesource.com/skia.git@npot_out
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrTexture.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 2a153af5be2b338bd41b1f41dbcbdc11f8388108..472fcfe59d8d32432ce61e1ae8df781549c67ca9 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;
@@ -184,7 +180,7 @@ static GrTexture* create_texture_for_bmp(GrContext* ctx,
const void* pixels,
size_t rowBytes) {
GrTexture* result;
- if (optionalKey.isValid()) {
+ if (optionalKey.isValid() || GrPixelConfigIsCompressed(desc.fConfig)) {
result = ctx->createTexture(desc, pixels, rowBytes);
if (result) {
SkAssertResult(ctx->addResourceToCache(optionalKey, result));
@@ -415,7 +411,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);
@@ -434,18 +430,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;
@@ -453,12 +445,11 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx,
}
#endif // SK_IGNORE_ETC1_SUPPORT
- else {
- 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;
« no previous file with comments | « src/gpu/GrTexture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698