summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorreed <reed@google.com>2014-12-03 12:28:37 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-03 20:29:02 +0000
commitd17918c510e868efeb9690692852d889c07c7131 (patch)
tree9f1d458fe496299f9861f2c6c83baa918f738257 /skia
parent612eeacedc04772e9a6071a5c3e04136f75917eb (diff)
downloadchromium_src-d17918c510e868efeb9690692852d889c07c7131.zip
chromium_src-d17918c510e868efeb9690692852d889c07c7131.tar.gz
chromium_src-d17918c510e868efeb9690692852d889c07c7131.tar.bz2
remove calls to (deprecated) SkDevice::clear
BUG= Review URL: https://codereview.chromium.org/774233002 Cr-Commit-Position: refs/heads/master@{#306664}
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device_cairo.cc4
-rw-r--r--skia/ext/bitmap_platform_device_mac.cc29
-rw-r--r--skia/ext/bitmap_platform_device_mac.h7
-rw-r--r--skia/ext/bitmap_platform_device_skia.cc9
-rw-r--r--skia/ext/bitmap_platform_device_skia.h5
-rw-r--r--skia/ext/bitmap_platform_device_win.cc31
-rw-r--r--skia/ext/bitmap_platform_device_win.h8
7 files changed, 30 insertions, 63 deletions
diff --git a/skia/ext/bitmap_platform_device_cairo.cc b/skia/ext/bitmap_platform_device_cairo.cc
index 97fc92a..e9dcf3b 100644
--- a/skia/ext/bitmap_platform_device_cairo.cc
+++ b/skia/ext/bitmap_platform_device_cairo.cc
@@ -127,8 +127,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
BitmapPlatformDevice* device = Create(width, height, is_opaque, surface);
#ifndef NDEBUG
- if (device && is_opaque) // Fill with bright bluish green
- device->eraseColor(SkColorSetARGB(255, 0, 255, 128));
+ if (device && is_opaque) // Fill with bright bluish green
+ SkCanvas(device).drawColor(0xFF00FF80);
#endif
return device;
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc
index 871ca83..53569c8 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);
}
diff --git a/skia/ext/bitmap_platform_device_mac.h b/skia/ext/bitmap_platform_device_mac.h
index 8921117..33ce214 100644
--- a/skia/ext/bitmap_platform_device_mac.h
+++ b/skia/ext/bitmap_platform_device_mac.h
@@ -35,12 +35,7 @@ class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice
// is not initialized.
static BitmapPlatformDevice* Create(CGContextRef context,
int width, int height,
- bool is_opaque);
-
- // Creates a BitmapPlatformDevice instance. If |is_opaque| is false,
- // then the bitmap is initialzed to 0.
- static BitmapPlatformDevice* CreateAndClear(int width, int height,
- bool is_opaque);
+ bool is_opaque, bool do_clear = false);
// Creates a context for |data| and calls Create.
// If |data| is NULL, then the bitmap backing store is not initialized.
diff --git a/skia/ext/bitmap_platform_device_skia.cc b/skia/ext/bitmap_platform_device_skia.cc
index 1dcf13b..d057913 100644
--- a/skia/ext/bitmap_platform_device_skia.cc
+++ b/skia/ext/bitmap_platform_device_skia.cc
@@ -20,15 +20,6 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
return NULL;
}
-BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width,
- int height,
- bool is_opaque) {
- BitmapPlatformDevice* device = Create(width, height, is_opaque);
- if (!is_opaque)
- device->clear(0);
- return device;
-}
-
BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque,
uint8_t* data) {
diff --git a/skia/ext/bitmap_platform_device_skia.h b/skia/ext/bitmap_platform_device_skia.h
index 3b8a28d..dfbee56 100644
--- a/skia/ext/bitmap_platform_device_skia.h
+++ b/skia/ext/bitmap_platform_device_skia.h
@@ -25,11 +25,6 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {
// The bitmap is not initialized.
static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
- // Construct a BitmapPlatformDevice, as above.
- // If |is_opaque| is false, the bitmap is initialized to 0.
- static BitmapPlatformDevice* CreateAndClear(int width, int height,
- bool is_opaque);
-
// This doesn't take ownership of |data|. If |data| is null, the bitmap
// is not initialized to 0.
static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc
index 3901ad5..71bb800 100644
--- a/skia/ext/bitmap_platform_device_win.cc
+++ b/skia/ext/bitmap_platform_device_win.cc
@@ -120,7 +120,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
int width,
int height,
bool is_opaque,
- HANDLE shared_section) {
+ HANDLE shared_section,
+ bool do_clear) {
void* data;
HBITMAP hbitmap = CreateHBitmap(width, height, is_opaque, shared_section,
@@ -132,6 +133,9 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
if (!InstallHBitmapPixels(&bitmap, width, height, is_opaque, data, hbitmap))
return NULL;
+ if (do_clear)
+ bitmap.eraseColor(0);
+
#ifndef NDEBUG
// If we were given data, then don't clobber it!
if (!shared_section && is_opaque)
@@ -148,18 +152,9 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
// static
BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque) {
- return Create(width, height, is_opaque, NULL);
-}
-
-// static
-BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width,
- int height,
- bool is_opaque) {
- BitmapPlatformDevice* device = BitmapPlatformDevice::Create(width, height,
- is_opaque);
- if (device && !is_opaque)
- device->clear(0);
- return device;
+ const HANDLE shared_section = NULL;
+ const bool do_clear = false;
+ return Create(width, height, is_opaque, shared_section, do_clear);
}
// The device will own the HBITMAP, which corresponds to also owning the pixel
@@ -271,11 +266,11 @@ const SkBitmap& BitmapPlatformDevice::onAccessBitmap() {
}
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(info.width(), info.height(), info.isOpaque(), NULL, do_clear);
}
// PlatformCanvas impl
diff --git a/skia/ext/bitmap_platform_device_win.h b/skia/ext/bitmap_platform_device_win.h
index 92b1408..9e32de9 100644
--- a/skia/ext/bitmap_platform_device_win.h
+++ b/skia/ext/bitmap_platform_device_win.h
@@ -35,17 +35,13 @@ class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice
// for details. If |shared_section| is null, the bitmap backing store is not
// initialized.
static BitmapPlatformDevice* Create(int width, int height,
- bool is_opaque, HANDLE shared_section);
+ bool is_opaque, HANDLE shared_section,
+ bool do_clear = false);
// Create a BitmapPlatformDevice with no shared section. The bitmap is not
// initialized to 0.
static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
- // Creates a BitmapPlatformDevice instance respecting the parameters as above.
- // If |is_opaque| is false, then the bitmap is initialzed to 0.
- static BitmapPlatformDevice* CreateAndClear(int width, int height,
- bool is_opaque);
-
virtual ~BitmapPlatformDevice();
// PlatformDevice overrides