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

Unified Diff: chrome/browser/android/vr_shell/ui_elements/textured_element.cc

Issue 2861343002: Enable gpu rasterization in the vr shell
Patch Set: additional trace instrumentation 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/ui_elements/textured_element.cc
diff --git a/chrome/browser/android/vr_shell/ui_elements/textured_element.cc b/chrome/browser/android/vr_shell/ui_elements/textured_element.cc
index 3623c1e4529105dbc6381f1d1d13b609bc2b1fbb..9649a813a9f0aa5497d57bc85bb41e02ad7905eb 100644
--- a/chrome/browser/android/vr_shell/ui_elements/textured_element.cc
+++ b/chrome/browser/android/vr_shell/ui_elements/textured_element.cc
@@ -4,10 +4,12 @@
#include "chrome/browser/android/vr_shell/ui_elements/textured_element.h"
-#include "cc/paint/skia_paint_canvas.h"
+#include "base/trace_event/trace_event.h"
#include "chrome/browser/android/vr_shell/textures/ui_texture.h"
#include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
-#include "third_party/skia/include/core/SkSurface.h"
+#include "chrome/browser/android/vr_shell/vr_surface_provider.h"
+#include "skia/ext/texture_handle.h"
+#include "third_party/skia/include/core/SkCanvas.h"
namespace vr_shell {
@@ -17,17 +19,33 @@ TexturedElement::TexturedElement(int maximum_width)
TexturedElement::~TexturedElement() = default;
void TexturedElement::Initialize() {
- glGenTextures(1, &texture_handle_);
- DCHECK(GetTexture() != nullptr);
+ TRACE_EVENT0("gpu,vr", "TexturedElement::Initialize");
texture_size_ = GetTexture()->GetPreferredTextureSize(maximum_width_);
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
+ DCHECK_NE(nullptr, surface_provider());
+ sk_sp<SkSurface> surface_ = surface_provider()->MakeSurface(
texture_size_.width(), texture_size_.height());
- GetTexture()->DrawAndLayout(surface->getCanvas(), texture_size_);
- Flush(surface.get());
+ DCHECK_NE(nullptr, surface_.get());
+ SkCanvas* canvas = surface_->getCanvas();
+ {
+ TRACE_EVENT0("gpu,vr", "TexturedElement::Initialize DrawAndLayout");
+ GetTexture()->DrawAndLayout(canvas, texture_size_);
+ }
+ {
+ TRACE_EVENT0("gpu,vr", "TexturedElement::Initialize Flush");
+ canvas->flush();
+ }
set_fill(Fill::SELF);
gfx::SizeF drawn_size = GetTexture()->GetDrawnSize();
float y = drawn_size.height() / drawn_size.width() * size().x();
set_size({size().x(), y, 1});
+
+ {
+ TRACE_EVENT0("gpu,vr", "TexturedElement::Initialize getTextureHandle");
+ texture_handle_ = skia::GrBackendObjectToGrGLTextureInfo(
+ surface_->getTextureHandle(
+ SkSurface::kDiscardWrite_TextureHandleAccess))
+ ->fID;
+ }
}
void TexturedElement::Render(VrShellRenderer* renderer,
@@ -39,19 +57,4 @@ void TexturedElement::Render(VrShellRenderer* renderer,
texture_handle_, view_proj_matrix, copy_rect, opacity());
}
-void TexturedElement::Flush(SkSurface* surface) {
- cc::SkiaPaintCanvas paint_canvas(surface->getCanvas());
- paint_canvas.flush();
- SkPixmap pixmap;
- CHECK(surface->peekPixels(&pixmap));
-
- glBindTexture(GL_TEXTURE_2D, texture_handle_);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr());
-}
-
} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698