| 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 TEXT_ALIGN_LEFT = 1 << 0, |
| 33 TEXT_ALIGN_CENTER = 1 << 1, |
| 34 TEXT_ALIGN_RIGHT = 1 << 2, |
| 35 MULTI_LINE = 1 << 3 |
| 36 }; |
| 37 |
| 24 UiTexture(); | 38 UiTexture(); |
| 25 virtual ~UiTexture(); | 39 virtual ~UiTexture(); |
| 26 | 40 |
| 27 void DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size); | 41 void DrawAndLayout(SkCanvas* canvas, const gfx::Size& texture_size); |
| 28 virtual gfx::Size GetPreferredTextureSize(int maximum_width) const = 0; | 42 virtual gfx::Size GetPreferredTextureSize(int maximum_width) const = 0; |
| 29 virtual gfx::SizeF GetDrawnSize() const = 0; | 43 virtual gfx::SizeF GetDrawnSize() const = 0; |
| 30 | 44 |
| 31 protected: | 45 protected: |
| 32 virtual void Draw(SkCanvas* canvas, const gfx::Size& texture_size) = 0; | 46 virtual void Draw(SkCanvas* canvas, const gfx::Size& texture_size) = 0; |
| 33 | 47 |
| 48 // Prepares a set of RenderText objects with the given color and fonts. |
| 49 // Attempts to fit the text within the provided size. |flags| specifies how |
| 50 // the text should be rendered. If multiline is requested and provided height |
| 51 // is 0, it will be set to the minimum needed to fit the whole text. If |
| 52 // multiline is not requested and provided width is 0, it will be set to the |
| 53 // minimum needed to fit the whole text. |
| 54 static std::vector<std::unique_ptr<gfx::RenderText>> PrepareDrawStringRect( |
| 55 const base::string16& text, |
| 56 const gfx::FontList& font_list, |
| 57 SkColor color, |
| 58 gfx::Rect* bounds, |
| 59 int flags); |
| 60 |
| 34 static bool IsRTL(); | 61 static bool IsRTL(); |
| 35 static gfx::FontList GetDefaultFontList(int size); | 62 static gfx::FontList GetDefaultFontList(int size); |
| 36 static gfx::FontList GetFontList(int size, base::string16 text); | 63 static gfx::FontList GetFontList(int size, base::string16 text); |
| 37 }; | 64 }; |
| 38 | 65 |
| 39 } // namespace vr_shell | 66 } // namespace vr_shell |
| 40 | 67 |
| 41 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ | 68 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_TEXTURES_UI_TEXTURE_H_ |
| OLD | NEW |