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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_util.h"
12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "ui/gfx/canvas.h"
14 #include "ui/gl/gl_bindings.h"
15
16 namespace vr_shell {
17
18 // TODO(acondor): Create non-square textures to reduce memory usage.
19 UITexture::UITexture(int texture_handle, int texture_size)
20 : texture_handle_(texture_handle),
21 texture_size_(texture_size),
22 surface_(SkSurface::MakeRasterN32Premul(texture_size_, texture_size_)) {}
23
24 UITexture::~UITexture() = default;
25
26 void UITexture::DrawAndLayout() {
27 cc::SkiaPaintCanvas paint_canvas(surface_->getCanvas());
28 gfx::Canvas canvas(&paint_canvas, 1.0f);
29 canvas.DrawColor(0x00000000);
30 Draw(&canvas);
31 SetSize();
32 }
33
34 void UITexture::Flush() {
35 cc::SkiaPaintCanvas paint_canvas(surface_->getCanvas());
36 paint_canvas.flush();
37 SkPixmap pixmap;
38 CHECK(surface_->peekPixels(&pixmap));
39
40 glBindTexture(GL_TEXTURE_2D, texture_handle_);
41 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0,
42 GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr());
43 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
44 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
45 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
46 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
47 }
48
49 } // namespace vr_shell
OLDNEW
« 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