SkGetPackedA32(c));
}
+GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
+
////////////////////////////////////////////////////////////////////////////////
/**
//////////////////////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-static void make_texture_desc(const SkImageInfo& info, GrSurfaceDesc* desc) {
- desc->fFlags = kNone_GrSurfaceFlags;
- desc->fWidth = info.width();
- desc->fHeight = info.height();
- desc->fConfig = SkImageInfo2GrPixelConfig(info);
- desc->fSampleCnt = 0;
-}
static GrTexture* load_compressed_into_texture(GrContext* ctx, SkData* data, GrSurfaceDesc desc) {
const void* rawStart;
GrMakeKeyFromImageID(&key, fUniqueID, SkIRect::MakeWH(fInfo.width(), fInfo.height()),
*ctx->caps(), usage);
- GrSurfaceDesc desc;
- make_texture_desc(fInfo, &desc);
-
// 1. Check the cache for a pre-existing one
if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) {
return tex;
}
}
+ const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo);
+
// 3. Ask the generator to return a compressed form that the GPU might support
SkAutoTUnref<SkData> data(this->refEncoded());
if (data) {
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,
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;
}
}
}
-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 {
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()) {