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

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

Issue 2902043005: [vr] Add incognito coloring (Closed)
Patch Set: merged changes from aldo and amp Created 3 years, 6 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/android/vr_shell/textures/url_bar_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "cc/paint/skia_paint_canvas.h" 8 #include "cc/paint/skia_paint_canvas.h"
9 #include "components/security_state/core/security_state.h" 9 #include "components/security_state/core/security_state.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 set_dirty(); 133 set_dirty();
134 hovered_ = hovered; 134 hovered_ = hovered;
135 } 135 }
136 136
137 void UrlBarTexture::SetPressed(bool pressed) { 137 void UrlBarTexture::SetPressed(bool pressed) {
138 if (pressed_ != pressed) 138 if (pressed_ != pressed)
139 set_dirty(); 139 set_dirty();
140 pressed_ = pressed; 140 pressed_ = pressed;
141 } 141 }
142 142
143 void UrlBarTexture::SetIncognito(bool incognito) {
144 if (incognito_ != incognito)
145 set_dirty();
146 incognito_ = incognito;
147 }
148
149 SkColor UrlBarTexture::AdjustColorForIncognito(SkColor c) const {
150 if (incognito_)
151 return SkColorSetA(c, 255);
152 return c;
153 }
154
143 void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) { 155 void UrlBarTexture::Draw(SkCanvas* canvas, const gfx::Size& texture_size) {
144 size_.set_height(texture_size.height()); 156 size_.set_height(texture_size.height());
145 size_.set_width(texture_size.width()); 157 size_.set_width(texture_size.width());
146 158
147 canvas->save(); 159 canvas->save();
148 canvas->scale(size_.width() / kWidth, size_.width() / kWidth); 160 canvas->scale(size_.width() / kWidth, size_.width() / kWidth);
149 161
150 // Make a gfx canvas to support utility drawing methods. 162 // Make a gfx canvas to support utility drawing methods.
151 cc::SkiaPaintCanvas paint_canvas(canvas); 163 cc::SkiaPaintCanvas paint_canvas(canvas);
152 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); 164 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f);
153 165
154 // Back button area. 166 // Back button area.
155 SkRRect round_rect; 167 SkRRect round_rect;
156 SkVector rounded_corner = {kHeight / 2, kHeight / 2}; 168 SkVector rounded_corner = {kHeight / 2, kHeight / 2};
157 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner}; 169 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner};
158 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners); 170 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners);
159 SkColor color = hovered_ ? kBackgroundHover : kBackground; 171 SkColor color = hovered_ ? kBackgroundHover : kBackground;
160 color = pressed_ ? kBackgroundDown : color; 172 color = pressed_ ? kBackgroundDown : color;
161 SkPaint paint; 173 SkPaint paint;
162 paint.setColor(color); 174 paint.setColor(AdjustColorForIncognito(color));
163 canvas->drawRRect(round_rect, paint); 175 canvas->drawRRect(round_rect, paint);
164 176
165 // URL area. 177 // URL area.
166 paint.setColor(kBackground); 178 paint.setColor(AdjustColorForIncognito(kBackground));
167 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}}; 179 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}};
168 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners); 180 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners);
169 canvas->drawRRect(round_rect, paint); 181 canvas->drawRRect(round_rect, paint);
170 182
171 // Back button / URL separator vertical line. 183 // Back button / URL separator vertical line.
172 paint.setColor(kSeparatorColor); 184 paint.setColor(kSeparatorColor);
173 canvas->drawRect(SkRect::MakeXYWH(kHeight, 0, kSeparatorWidth, kHeight), 185 canvas->drawRect(SkRect::MakeXYWH(kHeight, 0, kSeparatorWidth, kHeight),
174 paint); 186 paint);
175 187
176 // Back button icon. 188 // Back button icon.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 235
224 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 236 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
225 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 237 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
226 } 238 }
227 239
228 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 240 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
229 return size_; 241 return size_;
230 } 242 }
231 243
232 } // namespace vr_shell 244 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698