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

Unified Diff: ui/base/clipboard/clipboard_win.cc

Issue 1432443004: Remove SkDevice and SkBaseDevice outside skia/ext/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pass SkPixmap by pointer to MakeBitmapOpaque Created 5 years, 1 month 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 | « third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp ('k') | ui/gfx/canvas.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..92f0ef0d391231ac70ecb4702f92e28e9ebb792b 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);
}
}
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp ('k') | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698