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

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

Issue 1050923003: zero-copy: Clarify to allocate/destroy GpuMemoryBuffer on any thread and use it on the main thread o (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rephrase comment in gpu_channel_manager.cc Created 5 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 | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/egl_util.h" 7 #include "ui/gl/egl_util.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(const gfx::Size& size) 12 GLImageEGL::GLImageEGL(const gfx::Size& size)
13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) { 13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {
14 } 14 }
15 15
16 GLImageEGL::~GLImageEGL() { 16 GLImageEGL::~GLImageEGL() {
17 DCHECK(thread_checker_.CalledOnValidThread());
17 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 18 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
18 } 19 }
19 20
20 bool GLImageEGL::Initialize(EGLenum target, 21 bool GLImageEGL::Initialize(EGLenum target,
21 EGLClientBuffer buffer, 22 EGLClientBuffer buffer,
22 const EGLint* attrs) { 23 const EGLint* attrs) {
24 DCHECK(thread_checker_.CalledOnValidThread());
23 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 25 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
24 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), 26 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
25 EGL_NO_CONTEXT, 27 EGL_NO_CONTEXT,
26 target, 28 target,
27 buffer, 29 buffer,
28 attrs); 30 attrs);
29 if (egl_image_ == EGL_NO_IMAGE_KHR) { 31 if (egl_image_ == EGL_NO_IMAGE_KHR) {
30 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString(); 32 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString();
31 return false; 33 return false;
32 } 34 }
33 35
34 return true; 36 return true;
35 } 37 }
36 38
37 void GLImageEGL::Destroy(bool have_context) { 39 void GLImageEGL::Destroy(bool have_context) {
40 DCHECK(thread_checker_.CalledOnValidThread());
38 if (egl_image_ != EGL_NO_IMAGE_KHR) { 41 if (egl_image_ != EGL_NO_IMAGE_KHR) {
39 EGLBoolean result = 42 EGLBoolean result =
40 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 43 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
41 if (result == EGL_FALSE) { 44 if (result == EGL_FALSE) {
42 DLOG(ERROR) << "Error destroying EGLImage: " 45 DLOG(ERROR) << "Error destroying EGLImage: "
43 << ui::GetLastEGLErrorString(); 46 << ui::GetLastEGLErrorString();
44 } 47 }
45 egl_image_ = EGL_NO_IMAGE_KHR; 48 egl_image_ = EGL_NO_IMAGE_KHR;
46 } 49 }
47 } 50 }
48 51
49 gfx::Size GLImageEGL::GetSize() { return size_; } 52 gfx::Size GLImageEGL::GetSize() { return size_; }
50 53
51 bool GLImageEGL::BindTexImage(unsigned target) { 54 bool GLImageEGL::BindTexImage(unsigned target) {
55 DCHECK(thread_checker_.CalledOnValidThread());
52 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); 56 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
53 glEGLImageTargetTexture2DOES(target, egl_image_); 57 glEGLImageTargetTexture2DOES(target, egl_image_);
54 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 58 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
55 return true; 59 return true;
56 } 60 }
57 61
58 bool GLImageEGL::CopyTexImage(unsigned target) { 62 bool GLImageEGL::CopyTexImage(unsigned target) {
59 return false; 63 return false;
60 } 64 }
61 65
62 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 66 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
63 int z_order, 67 int z_order,
64 OverlayTransform transform, 68 OverlayTransform transform,
65 const Rect& bounds_rect, 69 const Rect& bounds_rect,
66 const RectF& crop_rect) { 70 const RectF& crop_rect) {
67 return false; 71 return false;
68 } 72 }
69 73
70 } // namespace gfx 74 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698