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

Unified Diff: ui/views/controls/button/label_button_border.cc

Issue 22744003: Fix LabelButtonBorder image blending during state transitions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit addressed. Created 7 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/label_button_border.cc
diff --git a/ui/views/controls/button/label_button_border.cc b/ui/views/controls/button/label_button_border.cc
index efb80df3a1b5b672855f1151b26902216cd3ac0d..a06376a0efcf9da32d25aff899f0544ac41667b8 100644
--- a/ui/views/controls/button/label_button_border.cc
+++ b/ui/views/controls/button/label_button_border.cc
@@ -6,6 +6,8 @@
#include "base/logging.h"
#include "grit/ui_resources.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/base/animation/animation.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
@@ -119,17 +121,27 @@ void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) {
ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra);
if (animation && animation->is_animating()) {
- // Composite the background and foreground painters during state animations.
- int alpha = animation->CurrentValueBetween(0, 0xff);
+ // Fade from the background to the foreground painter during state
+ // animations. This is done by performing an additive blending of the two
+ // states in an intermediate layer.
+ canvas->sk_canvas()->saveLayer(NULL, NULL);
+ SkPaint paint;
+ paint.setXfermode(SkXfermode::Create(SkXfermode::kPlus_Mode));
+
state = native_theme_delegate->GetBackgroundThemeState(&extra);
- canvas->SaveLayerAlpha(static_cast<uint8>(0xff - alpha));
+ int alpha = animation->CurrentValueBetween(0, 0xff);
+ paint.setAlpha(0xff - alpha);
+ canvas->sk_canvas()->saveLayer(NULL, &paint);
PaintHelper(this, canvas, theme, part, state, rect, extra);
- canvas->Restore();
+ canvas->sk_canvas()->restore();
state = native_theme_delegate->GetForegroundThemeState(&extra);
- canvas->SaveLayerAlpha(static_cast<uint8>(alpha));
+ paint.setAlpha(alpha);
+ canvas->sk_canvas()->saveLayer(NULL, &paint);
PaintHelper(this, canvas, theme, part, state, rect, extra);
- canvas->Restore();
+ canvas->sk_canvas()->restore();
+
+ canvas->sk_canvas()->restore();
} else {
PaintHelper(this, canvas, theme, part, state, rect, extra);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698