| 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 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "cc/paint/skia_paint_canvas.h" | 8 #include "cc/paint/skia_paint_canvas.h" |
| 9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_element_renderer.h" | 10 #include "chrome/browser/android/vr_shell/ui_element_renderer.h" |
| 11 #include "third_party/skia/include/core/SkSurface.h" | 11 #include "third_party/skia/include/core/SkSurface.h" |
| 12 #include "ui/gfx/geometry/rect_f.h" | 12 #include "ui/gfx/geometry/rect_f.h" |
| 13 | 13 |
| 14 namespace vr_shell { | 14 namespace vr_shell { |
| 15 | 15 |
| 16 TexturedElement::TexturedElement(int maximum_width) | 16 TexturedElement::TexturedElement(int id, int maximum_width) |
| 17 : texture_handle_(-1), maximum_width_(maximum_width) {} | 17 : UiElement(id), texture_handle_(-1), maximum_width_(maximum_width) {} |
| 18 | 18 |
| 19 TexturedElement::~TexturedElement() = default; | 19 TexturedElement::~TexturedElement() = default; |
| 20 | 20 |
| 21 void TexturedElement::Initialize() { | 21 void TexturedElement::Initialize() { |
| 22 TRACE_EVENT0("gpu", "TexturedElement::Initialize"); | 22 TRACE_EVENT0("gpu", "TexturedElement::Initialize"); |
| 23 glGenTextures(1, &texture_handle_); | 23 glGenTextures(1, &texture_handle_); |
| 24 DCHECK(GetTexture() != nullptr); | 24 DCHECK(GetTexture() != nullptr); |
| 25 texture_size_ = GetTexture()->GetPreferredTextureSize(maximum_width_); | 25 texture_size_ = GetTexture()->GetPreferredTextureSize(maximum_width_); |
| 26 initialized_ = true; | 26 initialized_ = true; |
| 27 UpdateTexture(); | 27 UpdateTexture(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0, | 71 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0, |
| 72 GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr()); | 72 GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void TexturedElement::OnSetMode() { | 75 void TexturedElement::OnSetMode() { |
| 76 GetTexture()->SetMode(mode()); | 76 GetTexture()->SetMode(mode()); |
| 77 UpdateTexture(); | 77 UpdateTexture(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace vr_shell | 80 } // namespace vr_shell |
| OLD | NEW |