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

Unified Diff: chrome/browser/ui/libgtkui/gtk_util.cc

Issue 2682593006: Gtk3: Bugfixes on several themes (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | chrome/browser/ui/libgtkui/native_theme_gtk3.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtkui/gtk_util.cc
diff --git a/chrome/browser/ui/libgtkui/gtk_util.cc b/chrome/browser/ui/libgtkui/gtk_util.cc
index c6ef9db93efd3148de7d9b7218b15d9ac3264a0a..0f6144f81fe5901ffb770c64104401e462bef738 100644
--- a/chrome/browser/ui/libgtkui/gtk_util.cc
+++ b/chrome/browser/ui/libgtkui/gtk_util.cc
@@ -228,14 +228,16 @@ CairoSurface::~CairoSurface() {
}
SkColor CairoSurface::GetAveragePixelValue(bool only_frame_pixels) {
+ cairo_surface_flush(surface_);
int num_samples = 0;
long a = 0, r = 0, g = 0, b = 0;
SkColor* data =
reinterpret_cast<SkColor*>(cairo_image_surface_get_data(surface_));
int width = cairo_image_surface_get_width(surface_);
int height = cairo_image_surface_get_height(surface_);
+ DCHECK(4 * width == cairo_image_surface_get_stride(surface_));
auto accumulate = [&](int x, int y) mutable {
- SkColor color = data[x * width + y];
+ SkColor color = data[y * width + x];
int alpha = SkColorGetA(color);
a += alpha;
r += alpha * SkColorGetR(color);
@@ -258,6 +260,8 @@ SkColor CairoSurface::GetAveragePixelValue(bool only_frame_pixels) {
for (int y = 1; y < height - 1; y++)
accumulate(x, y);
}
+ if (a == 0)
+ return SK_ColorTRANSPARENT;
return SkColorSetARGB(a / num_samples, r / a, g / a, b / a);
}
« no previous file with comments | « no previous file | chrome/browser/ui/libgtkui/native_theme_gtk3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698