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

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

Issue 2801713002: GLImageEGL: add dmabuf queries
Patch Set: remove enum BufferFormatModifier 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 | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_native_pixmap.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 #define MAX_FORMATS 100
11 #define MAX_MODIFIERS 20
12 #define DRM_FORMAT_MOD_NONE 0
13
10 namespace gl { 14 namespace gl {
11 15
12 GLImageEGL::GLImageEGL(const gfx::Size& size) 16 GLImageEGL::GLImageEGL(const gfx::Size& size)
13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {} 17 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {}
14 18
15 GLImageEGL::~GLImageEGL() { 19 GLImageEGL::~GLImageEGL() {
16 DCHECK(thread_checker_.CalledOnValidThread()); 20 DCHECK(thread_checker_.CalledOnValidThread());
17 if (egl_image_ != EGL_NO_IMAGE_KHR) { 21 if (egl_image_ != EGL_NO_IMAGE_KHR) {
18 EGLBoolean result = 22 EGLBoolean result =
19 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 23 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
(...skipping 12 matching lines...) Expand all
32 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), 36 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
33 EGL_NO_CONTEXT, target, buffer, attrs); 37 EGL_NO_CONTEXT, target, buffer, attrs);
34 if (egl_image_ == EGL_NO_IMAGE_KHR) { 38 if (egl_image_ == EGL_NO_IMAGE_KHR) {
35 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString(); 39 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString();
36 return false; 40 return false;
37 } 41 }
38 42
39 return true; 43 return true;
40 } 44 }
41 45
46 std::vector<std::pair<EGLint, EGLuint64KHR>>
47 GLImageEGL::GetDmaBufFormatsWithModifiers() {
48 EGLDisplay dpy = GLSurfaceEGL::GetHardwareDisplay();
49 std::vector<std::pair<EGLint, EGLuint64KHR>> supported;
50 EGLint drm_formats[MAX_FORMATS];
51 EGLint num_formats = 0;
52
53 eglQueryDmaBufFormatsEXT(dpy, MAX_FORMATS, &drm_formats[0], &num_formats);
54
55 for (int i = 0; i < num_formats; i++) {
56 EGLuint64KHR drm_modifiers[MAX_MODIFIERS];
57 EGLint num_modifiers = 0;
58
59 eglQueryDmaBufModifiersEXT(dpy, drm_formats[i], MAX_MODIFIERS,
60 &drm_modifiers[0], NULL, &num_modifiers);
61
62 if (num_modifiers == 0)
63 supported.push_back(std::make_pair(drm_formats[i], DRM_FORMAT_MOD_NONE));
64 for (int j = 0; j < num_modifiers; j++)
65 supported.push_back(std::make_pair(drm_formats[i], drm_modifiers[j]));
66 }
67 return supported;
68 }
69
42 gfx::Size GLImageEGL::GetSize() { 70 gfx::Size GLImageEGL::GetSize() {
43 return size_; 71 return size_;
44 } 72 }
45 73
46 unsigned GLImageEGL::GetInternalFormat() { return GL_RGBA; } 74 unsigned GLImageEGL::GetInternalFormat() { return GL_RGBA; }
47 75
48 bool GLImageEGL::BindTexImage(unsigned target) { 76 bool GLImageEGL::BindTexImage(unsigned target) {
49 DCHECK(thread_checker_.CalledOnValidThread()); 77 DCHECK(thread_checker_.CalledOnValidThread());
50 if (egl_image_ == EGL_NO_IMAGE_KHR) 78 if (egl_image_ == EGL_NO_IMAGE_KHR)
51 return false; 79 return false;
(...skipping 15 matching lines...) Expand all
67 95
68 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 96 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
69 int z_order, 97 int z_order,
70 gfx::OverlayTransform transform, 98 gfx::OverlayTransform transform,
71 const gfx::Rect& bounds_rect, 99 const gfx::Rect& bounds_rect,
72 const gfx::RectF& crop_rect) { 100 const gfx::RectF& crop_rect) {
73 return false; 101 return false;
74 } 102 }
75 103
76 } // namespace gl 104 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_native_pixmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698