diff options
-rw-r--r-- | samplecode/SampleRegion.cpp | 18 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 1 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 11 |
3 files changed, 29 insertions, 1 deletions
diff --git a/samplecode/SampleRegion.cpp b/samplecode/SampleRegion.cpp index d3fe062..fd20a81 100644 --- a/samplecode/SampleRegion.cpp +++ b/samplecode/SampleRegion.cpp @@ -219,6 +219,24 @@ protected: } this->drawBG(canvas); + if (false) { + SkPaint paint; + paint.setAntiAlias(true); + SkBitmap bm; + bm.setConfig(SkBitmap::kA8_Config, 100, 100); + bm.allocPixels(); + bm.eraseColor(0); + SkCanvas c(bm); + c.drawCircle(50, 50, 50, paint); + + paint.setColor(SK_ColorBLUE); + canvas->drawBitmap(bm, 0, 0, &paint); + canvas->scale(SK_Scalar1/2, SK_Scalar1/2); + paint.setColor(SK_ColorRED); + canvas->drawBitmap(bm, 0, 0, &paint); + return; + } + #ifdef SK_DEBUG if (true) { SkRegion a, b, c; diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index aa03f59..3558573 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -379,6 +379,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { case SkBitmap::kA8_Config: index |= 32; fPaintPMColor = SkPreMultiplyColor(paint.getColor()); + break; default: return false; } diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index d59b813..1d3263f 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -932,7 +932,16 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, c.translate(-SkIntToScalar(mask.fBounds.fLeft), -SkIntToScalar(mask.fBounds.fTop)); c.concat(*fMatrix); - c.drawBitmap(bitmap, 0, 0, NULL); + + // We can't call drawBitmap, or we'll infinitely recurse. Instead + // we manually build a shader and draw that into our new mask + SkPaint tmpPaint; + tmpPaint.setFlags(paint.getFlags()); + SkAutoBitmapShaderInstall install(bitmap, &tmpPaint); + SkRect rr; + rr.set(0, 0, SkIntToScalar(bitmap.width()), + SkIntToScalar(bitmap.height())); + c.drawRect(rr, tmpPaint); } this->drawDevMask(mask, paint); } |