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

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

Issue 2862283002: VR: Add initial URL bar element and texture. (Closed)
Patch Set: Drop anti-aliasing. 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
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/ui_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/i18n/char_iterator.h" 11 #include "base/i18n/char_iterator.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/ports/SkFontMgr.h" 17 #include "third_party/skia/include/ports/SkFontMgr.h"
18 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/font_list.h" 19 #include "ui/gfx/font_list.h"
20 #include "ui/gl/gl_bindings.h" 20 #include "ui/gl/gl_bindings.h"
21 21
22 namespace vr_shell { 22 namespace vr_shell {
23 23
24 namespace { 24 namespace {
25 constexpr char kDefaultFontFamily[] = "sans-serif"; 25
26 static constexpr char kDefaultFontFamily[] = "sans-serif";
27
26 } // namespace 28 } // namespace
27 29
28 UiTexture::UiTexture() = default; 30 UiTexture::UiTexture() = default;
29 31
30 UiTexture::~UiTexture() = default; 32 UiTexture::~UiTexture() = default;
31 33
32 void UiTexture::DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size) { 34 void UiTexture::DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size) {
33 cc::SkiaPaintCanvas paint_canvas(canvas); 35 canvas->drawColor(SK_ColorTRANSPARENT);
34 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); 36 Draw(canvas, texture_size);
35 gfx_canvas.DrawColor(SK_ColorTRANSPARENT);
36 Draw(&gfx_canvas, texture_size);
37 } 37 }
38 38
39 bool UiTexture::IsRTL() { 39 bool UiTexture::IsRTL() {
40 return base::i18n::IsRTL(); 40 return base::i18n::IsRTL();
41 } 41 }
42 42
43 gfx::FontList UiTexture::GetDefaultFontList(int size) {
44 return gfx::FontList(gfx::Font(kDefaultFontFamily, size));
45 }
46
43 gfx::FontList UiTexture::GetFontList(int size, base::string16 text) { 47 gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
44 gfx::Font default_font(kDefaultFontFamily, size); 48 gfx::Font default_font(kDefaultFontFamily, size);
45 std::vector<gfx::Font> fonts{default_font}; 49 std::vector<gfx::Font> fonts{default_font};
46 50
47 std::set<wchar_t> characters; 51 std::set<wchar_t> characters;
48 for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) { 52 for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) {
49 characters.insert(it.get()); 53 characters.insert(it.get());
50 } 54 }
51 // TODO(acondor): Obtain fallback fonts with gfx::GetFallbackFonts 55 // TODO(acondor): Obtain fallback fonts with gfx::GetFallbackFonts
52 // (which is not implemented for android yet) in order to avoid 56 // (which is not implemented for android yet) in order to avoid
(...skipping 14 matching lines...) Expand all
67 std::string name(sk_name.c_str()); 71 std::string name(sk_name.c_str());
68 if (name != kDefaultFontFamily) 72 if (name != kDefaultFontFamily)
69 names.insert(name); 73 names.insert(name);
70 } 74 }
71 for (const auto& name : names) 75 for (const auto& name : names)
72 fonts.push_back(gfx::Font(name, size)); 76 fonts.push_back(gfx::Font(name, size));
73 return gfx::FontList(fonts); 77 return gfx::FontList(fonts);
74 } 78 }
75 79
76 } // namespace vr_shell 80 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/textures/ui_texture.h ('k') | chrome/browser/android/vr_shell/textures/url_bar_texture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698