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

Unified Diff: chrome/browser/android/vr_shell/textures/ui_texture.cc

Issue 2818553002: Rendering Insecure WebVR Warnings into a texture with Skia. (Closed)
Patch Set: Adding comments Created 3 years, 8 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
« no previous file with comments | « chrome/browser/android/vr_shell/textures/ui_texture.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/textures/ui_texture.cc
diff --git a/chrome/browser/android/vr_shell/textures/ui_texture.cc b/chrome/browser/android/vr_shell/textures/ui_texture.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c93ca29e39126d88f285412d152d386b04552ae5
--- /dev/null
+++ b/chrome/browser/android/vr_shell/textures/ui_texture.cc
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/textures/ui_texture.h"
+
+#include <string>
+#include <vector>
+
+#include "base/memory/ptr_util.h"
+#include "base/strings/string_util.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gl/gl_bindings.h"
+
+namespace vr_shell {
+
+// TODO(acondor): Create non-square textures to reduce memory usage.
+UITexture::UITexture(int texture_handle, int texture_size)
+ : texture_handle_(texture_handle),
+ texture_size_(texture_size),
+ surface_(SkSurface::MakeRasterN32Premul(texture_size_, texture_size_)) {}
+
+UITexture::~UITexture() = default;
+
+void UITexture::DrawAndLayout() {
+ cc::SkiaPaintCanvas paint_canvas(surface_->getCanvas());
+ gfx::Canvas canvas(&paint_canvas, 1.0f);
+ canvas.DrawColor(0x00000000);
+ Draw(&canvas);
+ SetSize();
+}
+
+void UITexture::Flush() {
+ cc::SkiaPaintCanvas paint_canvas(surface_->getCanvas());
+ paint_canvas.flush();
+ SkPixmap pixmap;
+ CHECK(surface_->peekPixels(&pixmap));
+
+ glBindTexture(GL_TEXTURE_2D, texture_handle_);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr());
+ 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_NEAREST);
+}
+
+} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/textures/ui_texture.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698