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

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

Issue 23058003: Use SkLerpXfermode to blend LabelButton images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup linear interpolation via animation; etc. 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 | « ui/views/controls/button/blue_button.cc ('k') | 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..6dbf1e1858cc8a6f7b9f67322f15d9309c3d2bb0 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/effects/SkLerpXfermode.h"
#include "ui/base/animation/animation.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
@@ -119,17 +121,19 @@ 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);
+ // Linearly interpolate background and foreground painters during animation.
+ canvas->sk_canvas()->saveLayer(NULL, NULL);
reed1 2013/08/14 13:33:56 Not specific to this CL, but.. Skia definitely ta
msw 2013/08/14 16:17:11 Done.
state = native_theme_delegate->GetBackgroundThemeState(&extra);
- canvas->SaveLayerAlpha(static_cast<uint8>(0xff - alpha));
PaintHelper(this, canvas, theme, part, state, rect, extra);
- canvas->Restore();
+ SkPaint paint;
+ paint.setXfermode(SkLerpXfermode::Create(animation->GetCurrentValue()));
reed1 2013/08/14 13:33:56 Create returns an object of reference-count 1 setX
msw 2013/08/14 16:17:11 Done. I too easily forgot how tricky using skia in
+ canvas->sk_canvas()->saveLayer(NULL, &paint);
reed1 2013/08/14 13:33:56 Same comment here about the value of passing in a
msw 2013/08/14 16:17:11 Done.
state = native_theme_delegate->GetForegroundThemeState(&extra);
- canvas->SaveLayerAlpha(static_cast<uint8>(alpha));
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 | « ui/views/controls/button/blue_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698