aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-09-16 10:09:24 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-16 10:09:24 -0700
commit3322a8137d12255258a937897389ea90ca1ee6fa (patch)
tree6e8304a13f506af4538acdddeb0c0e1999f7e572 /src/gpu
parent5d08d44c68f65c71c9fdbbdda601119d87a7beb6 (diff)
share code between SkGr and Cacherator
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/SkGpuDevice.cpp14
-rw-r--r--src/gpu/SkGr.cpp17
2 files changed, 18 insertions, 13 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index bba352569a..d897f3ce88 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1042,6 +1042,13 @@ static void draw_aa_bitmap(GrDrawContext* drawContext, GrContext* context,
drawContext->drawBatch(renderTarget, clip, grPaint, batch);
}
+static bool can_ignore_strict_subset_constraint(const SkBitmap& bitmap, const SkRect& subset) {
+ GrTexture* tex = bitmap.getTexture();
+ int width = tex ? tex->width() : bitmap.width();
+ int height = tex ? tex->height() : bitmap.height();
+ return subset.contains(SkRect::MakeIWH(width, height));
+}
+
void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
const SkBitmap& bitmap,
const SkRect* srcRectPtr,
@@ -1065,11 +1072,8 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
srcRect = *srcRectPtr;
dstSize = *dstSizePtr;
}
- GrTexture* tex = bitmap.getTexture();
- int width = tex ? tex->width() : bitmap.width();
- int height = tex ? tex->height() : bitmap.height();
- if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 &&
- srcRect.fRight >= width && srcRect.fBottom >= height) {
+
+ if (can_ignore_strict_subset_constraint(bitmap, srcRect)) {
constraint = SkCanvas::kFast_SrcRectConstraint;
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ee06f3eef6..9ab2f6393a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -205,12 +205,14 @@ static void make_image_keys(uint32_t imageID, const SkIRect& subset, const Stret
}
}
-static void generate_bitmap_texture_desc(const SkBitmap& bitmap, GrSurfaceDesc* desc) {
- desc->fFlags = kNone_GrSurfaceFlags;
- desc->fWidth = bitmap.width();
- desc->fHeight = bitmap.height();
- desc->fConfig = SkImageInfo2GrPixelConfig(bitmap.info());
- desc->fSampleCnt = 0;
+GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) {
+ GrSurfaceDesc desc;
+ desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fWidth = info.width();
+ desc.fHeight = info.height();
+ desc.fConfig = SkImageInfo2GrPixelConfig(info);
+ desc.fSampleCnt = 0;
+ return desc;
}
namespace {
@@ -433,8 +435,7 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx,
const SkBitmap* bitmap = &origBitmap;
- GrSurfaceDesc desc;
- generate_bitmap_texture_desc(*bitmap, &desc);
+ GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap->info());
const GrCaps* caps = ctx->caps();
if (kIndex_8_SkColorType == bitmap->colorType()) {