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

Unified Diff: ui/gfx/image/image_unittest_util.cc

Issue 10946031: Modifies GetPlatformImageColor() to check the color of a given point. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile. Created 8 years, 3 months 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 | « ui/gfx/image/image_unittest_util.h ('k') | ui/gfx/image/image_unittest_util_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image_unittest_util.cc
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 6291b23486868cc6c2a854f565e6b87dd781716f..a9110dbd1717f26fcd8506823a5320c3c7c83325 100644
--- a/ui/gfx/image/image_unittest_util.cc
+++ b/ui/gfx/image/image_unittest_util.cc
@@ -139,15 +139,19 @@ PlatformImage CopyPlatformType(const gfx::Image& image) {
#if defined(OS_MACOSX)
// Defined in image_unittest_util_mac.mm.
#elif defined(TOOLKIT_GTK)
-SkColor GetPlatformImageColor(PlatformImage image) {
+SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
+ int n_channels = gdk_pixbuf_get_n_channels(image);
+ int rowstride = gdk_pixbuf_get_rowstride(image);
guchar* gdk_pixels = gdk_pixbuf_get_pixels(image);
- guchar alpha = gdk_pixbuf_get_has_alpha(image) ? gdk_pixels[3] : 255;
- return SkColorSetARGB(alpha, gdk_pixels[0], gdk_pixels[1], gdk_pixels[2]);
+
+ guchar* pixel = gdk_pixels + (y * rowstride) + (x * n_channels);
Elliot Glaysher 2012/09/19 17:47:11 This is probably correct everywhere. (At least you
+ guchar alpha = gdk_pixbuf_get_has_alpha(image) ? pixel[3] : 255;
+ return SkColorSetARGB(alpha, pixel[0], pixel[1], pixel[2]);
}
#else
-SkColor GetPlatformImageColor(PlatformImage image) {
+SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
SkAutoLockPixels auto_lock(image);
- return image.getColor(10, 10);
+ return image.getColor(x, y);
}
#endif
« no previous file with comments | « ui/gfx/image/image_unittest_util.h ('k') | ui/gfx/image/image_unittest_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698