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

Side by Side Diff: ash/touch_hud/touch_hud_renderer.cc

Issue 2679423002: ash: Clean up naming of paint-related identifiers (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 unified diff | Download patch
« no previous file with comments | « ash/touch/touch_hud_debug.cc ('k') | ash/utility/screenshot_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/touch_hud/touch_hud_renderer.h" 5 #include "ash/touch_hud/touch_hud_renderer.h"
6 6
7 #include "third_party/skia/include/effects/SkGradientShader.h" 7 #include "third_party/skia/include/effects/SkGradientShader.h"
8 #include "ui/compositor/layer.h" 8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/layer_owner.h" 9 #include "ui/compositor/layer_owner.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 22 matching lines...) Expand all
33 public views::WidgetObserver { 33 public views::WidgetObserver {
34 public: 34 public:
35 explicit TouchPointView(views::Widget* parent_widget) 35 explicit TouchPointView(views::Widget* parent_widget)
36 : circle_center_(kPointRadius + 1, kPointRadius + 1), 36 : circle_center_(kPointRadius + 1, kPointRadius + 1),
37 gradient_center_(SkPoint::Make(kPointRadius + 1, kPointRadius + 1)) { 37 gradient_center_(SkPoint::Make(kPointRadius + 1, kPointRadius + 1)) {
38 SetPaintToLayer(); 38 SetPaintToLayer();
39 layer()->SetFillsBoundsOpaquely(false); 39 layer()->SetFillsBoundsOpaquely(false);
40 40
41 SetSize(gfx::Size(2 * kPointRadius + 2, 2 * kPointRadius + 2)); 41 SetSize(gfx::Size(2 * kPointRadius + 2, 2 * kPointRadius + 2));
42 42
43 stroke_paint_.setStyle(cc::PaintFlags::kStroke_Style); 43 stroke_flags_.setStyle(cc::PaintFlags::kStroke_Style);
44 stroke_paint_.setColor(kProjectionStrokeColor); 44 stroke_flags_.setColor(kProjectionStrokeColor);
45 45
46 gradient_colors_[0] = kProjectionFillColor; 46 gradient_colors_[0] = kProjectionFillColor;
47 gradient_colors_[1] = kProjectionStrokeColor; 47 gradient_colors_[1] = kProjectionStrokeColor;
48 48
49 gradient_pos_[0] = SkFloatToScalar(0.9f); 49 gradient_pos_[0] = SkFloatToScalar(0.9f);
50 gradient_pos_[1] = SkFloatToScalar(1.0f); 50 gradient_pos_[1] = SkFloatToScalar(1.0f);
51 51
52 parent_widget->GetContentsView()->AddChildView(this); 52 parent_widget->GetContentsView()->AddChildView(this);
53 53
54 parent_widget->AddObserver(this); 54 parent_widget->AddObserver(this);
(...skipping 20 matching lines...) Expand all
75 ~TouchPointView() override { 75 ~TouchPointView() override {
76 GetWidget()->RemoveObserver(this); 76 GetWidget()->RemoveObserver(this);
77 parent()->RemoveChildView(this); 77 parent()->RemoveChildView(this);
78 } 78 }
79 79
80 // Overridden from views::View. 80 // Overridden from views::View.
81 void OnPaint(gfx::Canvas* canvas) override { 81 void OnPaint(gfx::Canvas* canvas) override {
82 int alpha = kProjectionAlpha; 82 int alpha = kProjectionAlpha;
83 if (fadeout_) 83 if (fadeout_)
84 alpha = static_cast<int>(fadeout_->CurrentValueBetween(alpha, 0)); 84 alpha = static_cast<int>(fadeout_->CurrentValueBetween(alpha, 0));
85 fill_paint_.setAlpha(alpha); 85 fill_flags_.setAlpha(alpha);
86 stroke_paint_.setAlpha(alpha); 86 stroke_flags_.setAlpha(alpha);
87 fill_paint_.setShader(SkGradientShader::MakeRadial( 87 fill_flags_.setShader(SkGradientShader::MakeRadial(
88 gradient_center_, SkIntToScalar(kPointRadius), gradient_colors_, 88 gradient_center_, SkIntToScalar(kPointRadius), gradient_colors_,
89 gradient_pos_, arraysize(gradient_colors_), 89 gradient_pos_, arraysize(gradient_colors_),
90 SkShader::kMirror_TileMode)); 90 SkShader::kMirror_TileMode));
91 canvas->DrawCircle(circle_center_, SkIntToScalar(kPointRadius), 91 canvas->DrawCircle(circle_center_, SkIntToScalar(kPointRadius),
92 fill_paint_); 92 fill_flags_);
93 canvas->DrawCircle(circle_center_, SkIntToScalar(kPointRadius), 93 canvas->DrawCircle(circle_center_, SkIntToScalar(kPointRadius),
94 stroke_paint_); 94 stroke_flags_);
95 } 95 }
96 96
97 // Overridden from gfx::AnimationDelegate. 97 // Overridden from gfx::AnimationDelegate.
98 void AnimationEnded(const gfx::Animation* animation) override { 98 void AnimationEnded(const gfx::Animation* animation) override {
99 DCHECK_EQ(fadeout_.get(), animation); 99 DCHECK_EQ(fadeout_.get(), animation);
100 delete this; 100 delete this;
101 } 101 }
102 102
103 void AnimationProgressed(const gfx::Animation* animation) override { 103 void AnimationProgressed(const gfx::Animation* animation) override {
104 DCHECK_EQ(fadeout_.get(), animation); 104 DCHECK_EQ(fadeout_.get(), animation);
105 SchedulePaint(); 105 SchedulePaint();
106 } 106 }
107 107
108 void AnimationCanceled(const gfx::Animation* animation) override { 108 void AnimationCanceled(const gfx::Animation* animation) override {
109 AnimationEnded(animation); 109 AnimationEnded(animation);
110 } 110 }
111 111
112 // Overridden from views::WidgetObserver. 112 // Overridden from views::WidgetObserver.
113 void OnWidgetDestroying(views::Widget* widget) override { 113 void OnWidgetDestroying(views::Widget* widget) override {
114 if (fadeout_) 114 if (fadeout_)
115 fadeout_->Stop(); 115 fadeout_->Stop();
116 else 116 else
117 Destroy(); 117 Destroy();
118 } 118 }
119 119
120 const gfx::Point circle_center_; 120 const gfx::Point circle_center_;
121 const SkPoint gradient_center_; 121 const SkPoint gradient_center_;
122 122
123 cc::PaintFlags fill_paint_; 123 cc::PaintFlags fill_flags_;
124 cc::PaintFlags stroke_paint_; 124 cc::PaintFlags stroke_flags_;
125 SkColor gradient_colors_[2]; 125 SkColor gradient_colors_[2];
126 SkScalar gradient_pos_[2]; 126 SkScalar gradient_pos_[2];
127 127
128 std::unique_ptr<gfx::Animation> fadeout_; 128 std::unique_ptr<gfx::Animation> fadeout_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(TouchPointView); 130 DISALLOW_COPY_AND_ASSIGN(TouchPointView);
131 }; 131 };
132 132
133 TouchHudRenderer::TouchHudRenderer(views::Widget* parent_widget) 133 TouchHudRenderer::TouchHudRenderer(views::Widget* parent_widget)
134 : parent_widget_(parent_widget) {} 134 : parent_widget_(parent_widget) {}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (event.type() == ui::ET_TOUCH_RELEASED || 171 if (event.type() == ui::ET_TOUCH_RELEASED ||
172 event.type() == ui::ET_TOUCH_CANCELLED || 172 event.type() == ui::ET_TOUCH_CANCELLED ||
173 event.type() == ui::ET_POINTER_UP || 173 event.type() == ui::ET_POINTER_UP ||
174 event.type() == ui::ET_POINTER_CANCELLED) 174 event.type() == ui::ET_POINTER_CANCELLED)
175 points_.erase(iter); 175 points_.erase(iter);
176 } 176 }
177 } 177 }
178 } 178 }
179 179
180 } // namespace ash 180 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_hud_debug.cc ('k') | ash/utility/screenshot_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698