Chromium Code Reviews| Index: ui/base/clipboard/clipboard_win.cc |
| diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc |
| index 2743755dfd4d3470db499f111965414e93ab2aa4..6682801a1071b26ddb18973e84a417a33312ef74 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) { |
|
dcheng
2015/11/18 18:10:35
I can't tell from the header comments. Is SkPixmap
Tom Hudson
2015/11/20 15:20:48
Yep! (Sorry that I missed responding to this.)
I'
dcheng
2015/11/20 19:25:27
Compare:
https://code.google.com/p/chromium/codese
Tom Hudson
2015/11/20 20:09:09
D'oh, yes, done.
There are lots of places around
|
| + 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); |
| } |
| } |