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

Side by Side Diff: chrome/browser/android/vr_shell/textures/close_button_texture.cc

Issue 2878543002: Refactor VR Shell Input. Locks input to click/scroll targets. (Closed)
Patch Set: Address comments Created 3 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h"
6
7 #include "cc/paint/skia_paint_canvas.h"
8 #include "ui/gfx/canvas.h"
9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/vector2d.h"
11 #include "ui/gfx/paint_vector_icon.h"
12 #include "ui/gfx/vector_icon_types.h"
13 #include "ui/vector_icons/vector_icons.h"
14
15 namespace vr_shell {
16
17 namespace {
18
19 const SkColor kBackgroundColor = SK_ColorWHITE;
20 const SkColor kBackgroundColorHover = 0xFFE5E5E5;
21 const SkColor kBackgroundColorDown = 0xFFD5D5D5;
22 const SkColor kForegroundColor = 0xFF444444;
23 constexpr float kIconScaleFactor = 0.75;
24
25 } // namespace
26
27 CloseButtonTexture::CloseButtonTexture() = default;
28
29 CloseButtonTexture::~CloseButtonTexture() = default;
30
31 void CloseButtonTexture::Draw(SkCanvas* sk_canvas,
32 const gfx::Size& texture_size) {
33 DCHECK_EQ(texture_size.height(), texture_size.width());
34 cc::SkiaPaintCanvas paint_canvas(sk_canvas);
35 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f);
36 gfx::Canvas* canvas = &gfx_canvas;
37
38 size_.set_height(texture_size.height());
39 size_.set_width(texture_size.width());
40
41 cc::PaintFlags flags;
42 SkColor color =
43 (GetDrawFlags() & FLAG_HOVER) ? kBackgroundColorHover : kBackgroundColor;
44 color = (GetDrawFlags() & FLAG_DOWN) ? kBackgroundColorDown : color;
45 flags.setColor(color);
46 canvas->DrawCircle(gfx::PointF(size_.width() / 2, size_.height() / 2),
47 size_.width() / 2, flags);
48
49 canvas->Save();
50 canvas->Translate(gfx::Vector2d(size_.height() * (1 - kIconScaleFactor) / 2,
51 size_.height() * (1 - kIconScaleFactor) / 2));
52 PaintVectorIcon(canvas, ui::kCloseIcon, size_.height() * kIconScaleFactor,
53 kForegroundColor);
54 canvas->Restore();
55 }
56
57 gfx::Size CloseButtonTexture::GetPreferredTextureSize(int maximum_width) const {
58 return gfx::Size(maximum_width, maximum_width);
59 }
60
61 gfx::SizeF CloseButtonTexture::GetDrawnSize() const {
62 return size_;
63 }
64
65 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/textures/close_button_texture.h ('k') | chrome/browser/android/vr_shell/textures/ui_texture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698