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

Side by Side Diff: chrome/browser/android/vr_shell/ui_elements/textured_element.cc

Issue 2864903002: Add tracing to TexturedElement (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 "cc/paint/skia_paint_canvas.h" 8 #include "cc/paint/skia_paint_canvas.h"
8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" 9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
9 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h" 10 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
10 #include "third_party/skia/include/core/SkSurface.h" 11 #include "third_party/skia/include/core/SkSurface.h"
11 12
12 namespace vr_shell { 13 namespace vr_shell {
13 14
14 TexturedElement::TexturedElement(int maximum_width) 15 TexturedElement::TexturedElement(int maximum_width)
15 : texture_handle_(-1), maximum_width_(maximum_width) {} 16 : texture_handle_(-1), maximum_width_(maximum_width) {}
16 17
17 TexturedElement::~TexturedElement() = default; 18 TexturedElement::~TexturedElement() = default;
18 19
19 void TexturedElement::Initialize() { 20 void TexturedElement::Initialize() {
21 TRACE_EVENT0("gpu", "TexturedElement::Initialize");
20 glGenTextures(1, &texture_handle_); 22 glGenTextures(1, &texture_handle_);
21 DCHECK(GetTexture() != nullptr); 23 DCHECK(GetTexture() != nullptr);
22 texture_size_ = GetTexture()->GetPreferredTextureSize(maximum_width_); 24 texture_size_ = GetTexture()->GetPreferredTextureSize(maximum_width_);
23 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( 25 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
24 texture_size_.width(), texture_size_.height()); 26 texture_size_.width(), texture_size_.height());
25 GetTexture()->DrawAndLayout(surface->getCanvas(), texture_size_); 27 GetTexture()->DrawAndLayout(surface->getCanvas(), texture_size_);
26 Flush(surface.get()); 28 Flush(surface.get());
27 set_fill(Fill::SELF); 29 set_fill(Fill::SELF);
28 gfx::SizeF drawn_size = GetTexture()->GetDrawnSize(); 30 gfx::SizeF drawn_size = GetTexture()->GetDrawnSize();
29 float y = drawn_size.height() / drawn_size.width() * size().x(); 31 float y = drawn_size.height() / drawn_size.width() * size().x();
(...skipping 18 matching lines...) Expand all
48 glBindTexture(GL_TEXTURE_2D, texture_handle_); 50 glBindTexture(GL_TEXTURE_2D, texture_handle_);
49 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 51 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
50 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 52 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
51 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 53 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
52 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 54 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
53 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0, 55 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0,
54 GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr()); 56 GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr());
55 } 57 }
56 58
57 } // namespace vr_shell 59 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698