Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: skia/ext/bitmap_platform_device_mac.cc

Issue 773373002: Update from https://crrev.com/306706 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/ext/bitmap_platform_device_mac.h ('k') | skia/ext/bitmap_platform_device_skia.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/bitmap_platform_device_mac.cc
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc
index 871ca832b2f2a16577f246acd1490c931852877a..53569c8b7c0013cbd64b283d98906dc5f8a2e18b 100644
--- a/skia/ext/bitmap_platform_device_mac.cc
+++ b/skia/ext/bitmap_platform_device_mac.cc
@@ -96,7 +96,8 @@ void BitmapPlatformDevice::LoadConfig() {
BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
int width,
int height,
- bool is_opaque) {
+ bool is_opaque,
+ bool do_clear) {
if (RasterDeviceTooBigToAllocate(width, height))
return NULL;
@@ -114,6 +115,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
return NULL;
data = bitmap.getPixels();
}
+ if (do_clear)
+ memset(data, 0, bitmap.getSafeSize());
// If we were given data, then don't clobber it!
#ifndef NDEBUG
@@ -140,15 +143,6 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
return rv;
}
-BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width,
- int height,
- bool is_opaque) {
- BitmapPlatformDevice* device = Create(NULL, width, height, is_opaque);
- if (!is_opaque)
- device->clear(0);
- return device;
-}
-
BitmapPlatformDevice* BitmapPlatformDevice::CreateWithData(uint8_t* data,
int width,
int height,
@@ -157,7 +151,7 @@ BitmapPlatformDevice* BitmapPlatformDevice::CreateWithData(uint8_t* data,
if (data)
context = CGContextForData(data, width, height);
- BitmapPlatformDevice* rv = Create(context, width, height, is_opaque);
+ BitmapPlatformDevice* rv = Create(context, width, height, is_opaque, false);
// The device object took ownership of the graphics context with its own
// CGContextRetain call.
@@ -238,19 +232,20 @@ void BitmapPlatformDevice::DrawToNativeContext(CGContextRef context, int x,
}
SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
- const CreateInfo& info) {
- SkASSERT(info.fInfo.colorType() == kN32_SkColorType);
- return BitmapPlatformDevice::CreateAndClear(info.fInfo.width(),
- info.fInfo.height(),
- info.fInfo.isOpaque());
+ const CreateInfo& cinfo) {
+ const SkImageInfo& info = cinfo.fInfo;
+ const bool do_clear = !info.isOpaque();
+ SkASSERT(info.colorType() == kN32_SkColorType);
+ return Create(NULL, info.width(), info.height(), info.isOpaque(), do_clear);
}
// PlatformCanvas impl
SkCanvas* CreatePlatformCanvas(CGContextRef ctx, int width, int height,
bool is_opaque, OnFailureType failureType) {
+ const bool do_clear = false;
skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef(
- BitmapPlatformDevice::Create(ctx, width, height, is_opaque));
+ BitmapPlatformDevice::Create(ctx, width, height, is_opaque, do_clear));
return CreateCanvas(dev, failureType);
}
« no previous file with comments | « skia/ext/bitmap_platform_device_mac.h ('k') | skia/ext/bitmap_platform_device_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698