summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authortomhudson <tomhudson@google.com>2015-11-23 13:52:54 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-23 21:53:53 +0000
commit15223e977e59eafbb2476c7224641adc1589d860 (patch)
treeedf69e073a1549c236c8a04a41bdfbcd8915d918 /ui/base
parent60b29f0509636a9c6b34cc770a0347d46422f5a7 (diff)
downloadchromium_src-15223e977e59eafbb2476c7224641adc1589d860.zip
chromium_src-15223e977e59eafbb2476c7224641adc1589d860.tar.gz
chromium_src-15223e977e59eafbb2476c7224641adc1589d860.tar.bz2
We're deprecating SkDevice usage in Chromium; this change should
isolate it to skia/ext/ for simpler refactoring. I took the opportunity to also change calls to the deprecated SkCanvas::getDeviceSize() to the preferred replacement, SkCanvas::getBaseLayerSize(). R=fmalita@chromium.org,junov@chromium.org BUG=543755 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1432443004 Cr-Commit-Position: refs/heads/master@{#361196}
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/clipboard/clipboard_win.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index 2743755d..92f0ef0 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -160,10 +160,10 @@ HGLOBAL CreateGlobalData(const std::basic_string<charT>& str) {
return data;
}
-bool BitmapHasInvalidPremultipliedColors(const SkBitmap& bitmap) {
- for (int x = 0; x < bitmap.width(); ++x) {
- for (int y = 0; y < bitmap.height(); ++y) {
- uint32_t pixel = *bitmap.getAddr32(x, y);
+bool BitmapHasInvalidPremultipliedColors(const SkPixmap& pixmap) {
+ for (int x = 0; x < pixmap.width(); ++x) {
+ for (int y = 0; y < pixmap.height(); ++y) {
+ uint32_t pixel = *pixmap.addr32(x, y);
if (SkColorGetR(pixel) > SkColorGetA(pixel) ||
SkColorGetG(pixel) > SkColorGetA(pixel) ||
SkColorGetB(pixel) > SkColorGetA(pixel))
@@ -173,10 +173,10 @@ bool BitmapHasInvalidPremultipliedColors(const SkBitmap& bitmap) {
return false;
}
-void MakeBitmapOpaque(const SkBitmap& bitmap) {
- for (int x = 0; x < bitmap.width(); ++x) {
- for (int y = 0; y < bitmap.height(); ++y) {
- *bitmap.getAddr32(x, y) = SkColorSetA(*bitmap.getAddr32(x, y), 0xFF);
+void MakeBitmapOpaque(SkPixmap* pixmap) {
+ for (int x = 0; x < pixmap->width(); ++x) {
+ for (int y = 0; y < pixmap->height(); ++y) {
+ *pixmap->writable_addr32(x, y) = SkColorSetA(*pixmap->addr32(x, y), 0xFF);
}
}
}
@@ -631,14 +631,13 @@ SkBitmap ClipboardWin::ReadImage(ClipboardType type) const {
// we assume the alpha channel contains garbage and force the bitmap to be
// opaque as well. Note that this heuristic will fail on a transparent bitmap
// containing only black pixels...
- const SkBitmap& device_bitmap =
- canvas.sk_canvas()->getDevice()->accessBitmap(true);
+ SkPixmap device_pixels;
+ skia::GetWritablePixels(canvas.sk_canvas(), &device_pixels);
{
- SkAutoLockPixels lock(device_bitmap);
bool has_invalid_alpha_channel = bitmap->bmiHeader.biBitCount < 32 ||
- BitmapHasInvalidPremultipliedColors(device_bitmap);
+ BitmapHasInvalidPremultipliedColors(device_pixels);
if (has_invalid_alpha_channel) {
- MakeBitmapOpaque(device_bitmap);
+ MakeBitmapOpaque(&device_pixels);
}
}