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

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: thread check in gl image 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
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_surface_egl.h" 7 #include "ui/gl/gl_surface_egl.h"
8 8
9 namespace gfx { 9 namespace gfx {
10 10
11 GLImageEGL::GLImageEGL(const gfx::Size& size) 11 GLImageEGL::GLImageEGL(const gfx::Size& size)
12 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) { 12 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {
13 } 13 }
14 14
15 GLImageEGL::~GLImageEGL() { 15 GLImageEGL::~GLImageEGL() {
16 DCHECK(thread_checker_.CalledOnValidThread());
16 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 17 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
17 } 18 }
18 19
19 bool GLImageEGL::Initialize(EGLenum target, 20 bool GLImageEGL::Initialize(EGLenum target,
20 EGLClientBuffer buffer, 21 EGLClientBuffer buffer,
21 const EGLint* attrs) { 22 const EGLint* attrs) {
23 DCHECK(thread_checker_.CalledOnValidThread());
22 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 24 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
23 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), 25 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
24 EGL_NO_CONTEXT, 26 EGL_NO_CONTEXT,
25 target, 27 target,
26 buffer, 28 buffer,
27 attrs); 29 attrs);
28 if (egl_image_ == EGL_NO_IMAGE_KHR) { 30 if (egl_image_ == EGL_NO_IMAGE_KHR) {
29 EGLint error = eglGetError(); 31 EGLint error = eglGetError();
30 LOG(ERROR) << "Error creating EGLImage: " << error; 32 LOG(ERROR) << "Error creating EGLImage: " << error;
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 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 42 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
40 egl_image_ = EGL_NO_IMAGE_KHR; 43 egl_image_ = EGL_NO_IMAGE_KHR;
41 } 44 }
42 } 45 }
43 46
44 gfx::Size GLImageEGL::GetSize() { return size_; } 47 gfx::Size GLImageEGL::GetSize() { return size_; }
45 48
46 bool GLImageEGL::BindTexImage(unsigned target) { 49 bool GLImageEGL::BindTexImage(unsigned target) {
50 DCHECK(thread_checker_.CalledOnValidThread());
47 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); 51 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
48 glEGLImageTargetTexture2DOES(target, egl_image_); 52 glEGLImageTargetTexture2DOES(target, egl_image_);
49 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 53 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
50 return true; 54 return true;
51 } 55 }
52 56
53 bool GLImageEGL::CopyTexImage(unsigned target) { 57 bool GLImageEGL::CopyTexImage(unsigned target) {
54 return false; 58 return false;
55 } 59 }
56 60
57 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 61 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
58 int z_order, 62 int z_order,
59 OverlayTransform transform, 63 OverlayTransform transform,
60 const Rect& bounds_rect, 64 const Rect& bounds_rect,
61 const RectF& crop_rect) { 65 const RectF& crop_rect) {
62 return false; 66 return false;
63 } 67 }
64 68
65 } // namespace gfx 69 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698