add private flag for sprite-as-bitmap

BUG=skia:3272

Review URL: https://codereview.chromium.org/806853005
This commit is contained in:
reed 2014-12-22 16:12:38 -08:00 committed by Commit bot
parent 8fc6c2d82c
commit 0acf1b4b36
2 changed files with 18 additions and 0 deletions

View File

@ -1145,6 +1145,8 @@ public:
// don't call
static void Internal_Private_SetIgnoreSaveLayerBounds(bool);
static bool Internal_Private_GetIgnoreSaveLayerBounds();
static void Internal_Private_SetTreatSpriteAsBitmap(bool);
static bool Internal_Private_GetTreatSpriteAsBitmap();
protected:
// default impl defers to getDevice()->newSurface(info)

View File

@ -42,6 +42,14 @@ bool SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds() {
return gIgnoreSaveLayerBounds;
}
static bool gTreatSpriteAsBitmap;
void SkCanvas::Internal_Private_SetTreatSpriteAsBitmap(bool spriteAsBitmap) {
gTreatSpriteAsBitmap = spriteAsBitmap;
}
bool SkCanvas::Internal_Private_GetTreatSpriteAsBitmap() {
return gTreatSpriteAsBitmap;
}
// experimental for faster tiled drawing...
//#define SK_ENABLE_CLIP_QUICKREJECT
@ -1190,6 +1198,14 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y,
void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
const SkPaint* paint) {
if (gTreatSpriteAsBitmap) {
this->save();
this->resetMatrix();
this->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), paint);
this->restore();
return;
}
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawSprite()");
if (bitmap.drawsNothing()) {
return;