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

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

Issue 2914543002: [vr] Bail on unhandled code points. (Closed)
Patch Set: 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/system_indicator_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/system_indicator_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 "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); 43 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f);
44 gfx::Canvas* canvas = &gfx_canvas; 44 gfx::Canvas* canvas = &gfx_canvas;
45 45
46 DCHECK(texture_size.height() * kHeightWidthRatio == texture_size.width()); 46 DCHECK(texture_size.height() * kHeightWidthRatio == texture_size.width());
47 size_.set_height(texture_size.height()); 47 size_.set_height(texture_size.height());
48 SkPaint paint; 48 SkPaint paint;
49 paint.setColor(kBackgroundColor); 49 paint.setColor(kBackgroundColor);
50 50
51 base::string16 text = l10n_util::GetStringUTF16(message_id_); 51 base::string16 text = l10n_util::GetStringUTF16(message_id_);
52 52
53 auto fonts = GetFontList(size_.height() * kFontSizeFactor, text); 53 gfx::FontList fonts;
54 GetFontList(size_.height() * kFontSizeFactor, text, &fonts);
54 gfx::Rect text_size(0, kTextHeightFactor * size_.height()); 55 gfx::Rect text_size(0, kTextHeightFactor * size_.height());
55 56
56 std::vector<std::unique_ptr<gfx::RenderText>> lines = 57 std::vector<std::unique_ptr<gfx::RenderText>> lines =
57 PrepareDrawStringRect(text, fonts, kForegroundColor, &text_size, 58 PrepareDrawStringRect(text, fonts, kForegroundColor, &text_size,
58 kTextAlignmentNone, kWrappingBehaviorNoWrap); 59 kTextAlignmentNone, kWrappingBehaviorNoWrap);
59 60
60 DCHECK_LE(text_size.width(), kTextWidthFactor * size_.height()); 61 DCHECK_LE(text_size.width(), kTextWidthFactor * size_.height());
61 // Setting background size giving some extra lateral padding to the text. 62 // Setting background size giving some extra lateral padding to the text.
62 size_.set_width((kHeightWidthRatio * kBorderFactor + kIconSizeFactor) * 63 size_.set_width((kHeightWidthRatio * kBorderFactor + kIconSizeFactor) *
63 size_.height() + 64 size_.height() +
(...skipping 26 matching lines...) Expand all
90 // Ensuring height is a quarter of the width. 91 // Ensuring height is a quarter of the width.
91 int height = maximum_width / kHeightWidthRatio; 92 int height = maximum_width / kHeightWidthRatio;
92 return gfx::Size(height * kHeightWidthRatio, height); 93 return gfx::Size(height * kHeightWidthRatio, height);
93 } 94 }
94 95
95 gfx::SizeF SystemIndicatorTexture::GetDrawnSize() const { 96 gfx::SizeF SystemIndicatorTexture::GetDrawnSize() const {
96 return size_; 97 return size_;
97 } 98 }
98 99
99 } // namespace vr_shell 100 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698