Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | |
| 9 | 10 |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" | |
| 13 #include "ui/gfx/geometry/rect.h" | |
| 11 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 12 #include "ui/gfx/geometry/size_f.h" | 15 #include "ui/gfx/geometry/size_f.h" |
| 13 | 16 |
| 14 class SkCanvas; | 17 class SkCanvas; |
| 15 | 18 |
| 16 namespace gfx { | 19 namespace gfx { |
| 20 | |
| 17 class FontList; | 21 class FontList; |
| 22 class RenderText; | |
| 23 | |
| 18 } // namespace gfx | 24 } // namespace gfx |
| 19 | 25 |
| 20 namespace vr_shell { | 26 namespace vr_shell { |
| 21 | 27 |
| 22 class UiTexture { | 28 class UiTexture { |
| 23 public: | 29 public: |
| 30 enum { | |
| 31 // Flags to configure PrepareDrawStringRect | |
| 32 | |
|
cjgrant
2017/05/11 21:15:40
Probably no need for either blank line in here.
acondor_
2017/05/11 22:26:49
Done.
| |
| 33 TEXT_ALIGN_LEFT = 1 << 0, | |
| 34 TEXT_ALIGN_CENTER = 1 << 1, | |
| 35 TEXT_ALIGN_RIGHT = 1 << 2, | |
| 36 | |
| 37 MULTI_LINE = 1 << 3 | |
| 38 }; | |
| 39 | |
| 24 UiTexture(); | 40 UiTexture(); |
| 25 virtual ~UiTexture(); | 41 virtual ~UiTexture(); |
| 26 | 42 |
| 27 void DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size); | 43 void DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size); |
| 28 virtual gfx::Size GetPreferredTextureSize(int maximum_width) const = 0; | 44 virtual gfx::Size GetPreferredTextureSize(int maximum_width) const = 0; |
| 29 virtual gfx::SizeF GetDrawnSize() const = 0; | 45 virtual gfx::SizeF GetDrawnSize() const = 0; |
| 30 | 46 |
| 31 protected: | 47 protected: |
| 32 virtual void Draw(SkCanvas* canvas, const gfx::Size& texture_size) = 0; | 48 virtual void Draw(SkCanvas* canvas, const gfx::Size& texture_size) = 0; |
| 33 | 49 |
| 50 // Prepares a set of RenderText objects with the given color and fonts. | |
| 51 // Attempts to fit the text within the provided size. |flags| specifies how | |
| 52 // the text should be rendered. If multiline is requested and provided height | |
| 53 // is 0, it will be set to the minimum needed to fit the whole text. If | |
| 54 // multiline is not requested and provided width is 0, it will be set to the | |
| 55 // minimum needed to fit the whole text. | |
| 56 static std::vector<std::unique_ptr<gfx::RenderText>> PrepareDrawStringRect( | |
| 57 const base::string16& text, | |
| 58 const gfx::FontList& font_list, | |
| 59 SkColor color, | |
| 60 gfx::Rect* bounds, | |
| 61 int flags); | |
| 62 | |
| 34 static bool IsRTL(); | 63 static bool IsRTL(); |
| 35 static gfx::FontList GetDefaultFontList(int size); | 64 static gfx::FontList GetDefaultFontList(int size); |
| 36 static gfx::FontList GetFontList(int size, base::string16 text); | 65 static gfx::FontList GetFontList(int size, base::string16 text); |
| 37 }; | 66 }; |
| 38 | 67 |
| 39 } // namespace vr_shell | 68 } // namespace vr_shell |
| 40 | 69 |
| 41 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ | 70 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ |
| OLD | NEW |