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

Unified Diff: ui/views/animation/ink_drop_painted_layer_delegates.cc

Issue 1430153003: Moved the *PaintedLayerDelegates from ink_drop_animation.cc to ink_drop_painted_layer_delegates.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added use of BasePaintedLayerDelegate::GetCenterPoint(). 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 | « ui/views/animation/ink_drop_painted_layer_delegates.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_painted_layer_delegates.cc
diff --git a/ui/views/animation/ink_drop_painted_layer_delegates.cc b/ui/views/animation/ink_drop_painted_layer_delegates.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bdb79460e4964608ee017d113e685e212c9c0585
--- /dev/null
+++ b/ui/views/animation/ink_drop_painted_layer_delegates.cc
@@ -0,0 +1,85 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
+
+#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/compositor/paint_recorder.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/point_conversions.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// BasePaintedLayerDelegate
+//
+
+BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color)
+ : color_(color) {}
+
+BasePaintedLayerDelegate::~BasePaintedLayerDelegate() {}
+
+void BasePaintedLayerDelegate::OnDelegatedFrameDamage(
+ const gfx::Rect& damage_rect_in_dip) {}
+
+void BasePaintedLayerDelegate::OnDeviceScaleFactorChanged(
+ float device_scale_factor) {}
+
+base::Closure BasePaintedLayerDelegate::PrepareForLayerBoundsChange() {
+ return base::Closure();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// CircleLayerDelegate
+//
+
+CircleLayerDelegate::CircleLayerDelegate(SkColor color, int radius)
+ : BasePaintedLayerDelegate(color), radius_(radius) {}
+
+CircleLayerDelegate::~CircleLayerDelegate() {}
+
+gfx::PointF CircleLayerDelegate::GetCenterPoint() const {
+ return gfx::PointF(radius_, radius_);
+}
+
+void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
+ SkPaint paint;
+ paint.setColor(color());
+ paint.setFlags(SkPaint::kAntiAlias_Flag);
+ paint.setStyle(SkPaint::kFill_Style);
+
+ ui::PaintRecorder recorder(context, gfx::Size(radius_, radius_));
+ gfx::Canvas* canvas = recorder.canvas();
+
+ canvas->DrawCircle(ToRoundedPoint(GetCenterPoint()), radius_, paint);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// RectangleLayerDelegate
+//
+
+RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size)
+ : BasePaintedLayerDelegate(color), size_(size) {}
+
+RectangleLayerDelegate::~RectangleLayerDelegate() {}
+
+gfx::PointF RectangleLayerDelegate::GetCenterPoint() const {
+ return gfx::PointF(size_.width() / 2.0f, size_.height() / 2.0f);
+}
+
+void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
+ SkPaint paint;
+ paint.setColor(color());
+ paint.setFlags(SkPaint::kAntiAlias_Flag);
+ paint.setStyle(SkPaint::kFill_Style);
+
+ ui::PaintRecorder recorder(context, size_);
+ gfx::Canvas* canvas = recorder.canvas();
+ canvas->DrawRect(gfx::Rect(size_), paint);
+}
+
+} // namespace views
« no previous file with comments | « ui/views/animation/ink_drop_painted_layer_delegates.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698