diff options
Diffstat (limited to 'skia/ext/platform_canvas.cc')
-rw-r--r-- | skia/ext/platform_canvas.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc index 279af45..f4510744 100644 --- a/skia/ext/platform_canvas.cc +++ b/skia/ext/platform_canvas.cc @@ -76,10 +76,23 @@ void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, int x, platform_device->DrawToNativeContext(context, x, y, src_rect); } +static SkPMColor MakeOpaqueXfermodeProc(SkPMColor src, SkPMColor dst) { + return dst | (0xFF << SK_A32_SHIFT); +} + void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) { - PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); - if (platform_device) - platform_device->MakeOpaque(x, y, width, height); + if (width <= 0 || height <= 0) + return; + + SkRect rect; + rect.setXYWH(SkIntToScalar(x), SkIntToScalar(y), + SkIntToScalar(width), SkIntToScalar(height)); + SkPaint paint; + // so we don't draw anything on a device that ignores xfermodes + paint.setColor(0); + // install our custom mode + paint.setXfermode(new SkProcXfermode(MakeOpaqueXfermodeProc))->unref(); + canvas->drawRect(rect, paint); } } // namespace skia |