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

Side by Side Diff: ui/gl/gl_image_egl.cc

Issue 66033009: [Android] Add workaround to unbind gpu memory buffer only on NVIDIA (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comma Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/gl/gl_image_egl.h" 5 #include "ui/gl/gl_image_egl.h"
6 6
7 #include "ui/gl/gl_bindings.h" 7 #include "ui/gl/gl_bindings.h"
8 #include "ui/gl/gl_surface_egl.h" 8 #include "ui/gl/gl_surface_egl.h"
9 9
10 namespace gfx { 10 namespace gfx {
11 11
12 GLImageEGL::GLImageEGL(gfx::Size size) 12 GLImageEGL::GLImageEGL(gfx::Size size)
13 : egl_image_(EGL_NO_IMAGE_KHR), 13 : egl_image_(EGL_NO_IMAGE_KHR),
14 size_(size), 14 size_(size),
15 need_unbind_after_use_(false),
15 in_use_(false) { 16 in_use_(false) {
16 } 17 }
17 18
18 GLImageEGL::~GLImageEGL() { 19 GLImageEGL::~GLImageEGL() {
19 Destroy(); 20 Destroy();
20 } 21 }
21 22
22 bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) { 23 bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) {
23 DCHECK(buffer.native_buffer); 24 DCHECK(buffer.native_buffer);
24 EGLint attrs[] = { 25 EGLint attrs[] = {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Defer ImageTargetTexture2D if not currently in use. 70 // Defer ImageTargetTexture2D if not currently in use.
70 if (!in_use_) 71 if (!in_use_)
71 return true; 72 return true;
72 73
73 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); 74 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
74 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 75 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
75 return true; 76 return true;
76 } 77 }
77 78
78 void GLImageEGL::ReleaseTexImage() { 79 void GLImageEGL::ReleaseTexImage() {
79 // Nothing to do here as image is released after each use. 80 // Nothing to do here as image is released after each use or there is no need
81 // to release image.
80 } 82 }
81 83
82 void GLImageEGL::WillUseTexImage() { 84 void GLImageEGL::WillUseTexImage() {
83 DCHECK(egl_image_); 85 DCHECK(egl_image_);
84 DCHECK(!in_use_); 86 DCHECK(!in_use_);
85 in_use_ = true; 87 in_use_ = true;
86 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); 88 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
87 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 89 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
88 } 90 }
89 91
90 void GLImageEGL::DidUseTexImage() { 92 void GLImageEGL::DidUseTexImage() {
91 DCHECK(in_use_); 93 DCHECK(in_use_);
92 in_use_ = false; 94 in_use_ = false;
95
96 if (!need_unbind_after_use_)
97 return;
98
93 char zero[4] = { 0, }; 99 char zero[4] = { 0, };
94 glTexImage2D(GL_TEXTURE_2D, 100 glTexImage2D(GL_TEXTURE_2D,
95 0, 101 0,
96 GL_RGBA, 102 GL_RGBA,
97 1, 103 1,
98 1, 104 1,
99 0, 105 0,
100 GL_RGBA, 106 GL_RGBA,
101 GL_UNSIGNED_BYTE, 107 GL_UNSIGNED_BYTE,
102 &zero); 108 &zero);
103 } 109 }
104 110
111 void GLImageEGL::SetReleaseAfterUse() {
112 need_unbind_after_use_ = true;
113 }
114
105 } // namespace gfx 115 } // namespace gfx
OLDNEW
« ui/gl/gl_image_egl.h ('K') | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_glx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698