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

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

Issue 1401423003: Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix stream texture issue Created 5 years, 2 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_ozone_native_pixmap.h ('k') | ui/gl/gl_image_ref_counted_memory.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ozone_native_pixmap.h" 5 #include "ui/gl/gl_image_ozone_native_pixmap.h"
6 6
7 #define FOURCC(a, b, c, d) \ 7 #define FOURCC(a, b, c, d) \
8 ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \ 8 ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
9 (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24)) 9 (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
10 10
11 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') 11 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4')
12 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4') 12 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4')
13 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') 13 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
14 14
15 namespace gfx { 15 namespace gfx {
16 namespace { 16 namespace {
17 17
18 bool ValidInternalFormat(unsigned internalformat) { 18 bool ValidInternalFormat(unsigned internalformat) {
19 switch (internalformat) { 19 switch (internalformat) {
20 case GL_RGB: 20 case GL_RGB:
21 case GL_RGBA: 21 case GL_RGBA:
22 case GL_BGRA_EXT: 22 case GL_BGRA_EXT:
23 return true; 23 return true;
24 default: 24 default:
25 return false; 25 return false;
26 } 26 }
27 } 27 }
28 28
29 bool ValidFormat(gfx::BufferFormat format) { 29 bool ValidFormat(BufferFormat format) {
30 switch (format) { 30 switch (format) {
31 case BufferFormat::RGBA_8888: 31 case BufferFormat::RGBA_8888:
32 case BufferFormat::BGRA_8888: 32 case BufferFormat::BGRA_8888:
33 case BufferFormat::BGRX_8888: 33 case BufferFormat::BGRX_8888:
34 return true; 34 return true;
35 case BufferFormat::ATC: 35 case BufferFormat::ATC:
36 case BufferFormat::ATCIA: 36 case BufferFormat::ATCIA:
37 case BufferFormat::DXT1: 37 case BufferFormat::DXT1:
38 case BufferFormat::DXT5: 38 case BufferFormat::DXT5:
39 case BufferFormat::ETC1: 39 case BufferFormat::ETC1:
40 case BufferFormat::R_8: 40 case BufferFormat::R_8:
41 case BufferFormat::RGBA_4444: 41 case BufferFormat::RGBA_4444:
42 case BufferFormat::YUV_420: 42 case BufferFormat::YUV_420:
43 case BufferFormat::YUV_420_BIPLANAR: 43 case BufferFormat::YUV_420_BIPLANAR:
44 case BufferFormat::UYVY_422: 44 case BufferFormat::UYVY_422:
45 return false; 45 return false;
46 } 46 }
47 47
48 NOTREACHED(); 48 NOTREACHED();
49 return false; 49 return false;
50 } 50 }
51 51
52 EGLint FourCC(gfx::BufferFormat format) { 52 EGLint FourCC(BufferFormat format) {
53 switch (format) { 53 switch (format) {
54 case BufferFormat::RGBA_8888: 54 case BufferFormat::RGBA_8888:
55 return DRM_FORMAT_ABGR8888; 55 return DRM_FORMAT_ABGR8888;
56 case BufferFormat::BGRA_8888: 56 case BufferFormat::BGRA_8888:
57 return DRM_FORMAT_ARGB8888; 57 return DRM_FORMAT_ARGB8888;
58 case BufferFormat::BGRX_8888: 58 case BufferFormat::BGRX_8888:
59 return DRM_FORMAT_XRGB8888; 59 return DRM_FORMAT_XRGB8888;
60 case BufferFormat::ATC: 60 case BufferFormat::ATC:
61 case BufferFormat::ATCIA: 61 case BufferFormat::ATCIA:
62 case BufferFormat::DXT1: 62 case BufferFormat::DXT1:
(...skipping 17 matching lines...) Expand all
80 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const Size& size, 80 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const Size& size,
81 unsigned internalformat) 81 unsigned internalformat)
82 : GLImageEGL(size), internalformat_(internalformat) {} 82 : GLImageEGL(size), internalformat_(internalformat) {}
83 83
84 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() { 84 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {
85 } 85 }
86 86
87 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, 87 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap,
88 BufferFormat format) { 88 BufferFormat format) {
89 DCHECK(!pixmap_); 89 DCHECK(!pixmap_);
90
91 bool result = true;
92 if (pixmap->GetEGLClientBuffer()) { 90 if (pixmap->GetEGLClientBuffer()) {
93 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; 91 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
94 result = GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, 92 if (!GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR,
95 pixmap->GetEGLClientBuffer(), attrs); 93 pixmap->GetEGLClientBuffer(), attrs)) {
94 return false;
95 }
96 } else if (pixmap->GetDmaBufFd() >= 0) { 96 } else if (pixmap->GetDmaBufFd() >= 0) {
97 if (!ValidInternalFormat(internalformat_)) { 97 if (!ValidInternalFormat(internalformat_)) {
98 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 98 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
99 return false; 99 return false;
100 } 100 }
101 101
102 if (!ValidFormat(format)) { 102 if (!ValidFormat(format)) {
103 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 103 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
104 return false; 104 return false;
105 } 105 }
106 106
107 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT 107 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT
108 // target, the EGL will take a reference to the dma_buf. 108 // target, the EGL will take a reference to the dma_buf.
109 EGLint attrs[] = {EGL_WIDTH, 109 EGLint attrs[] = {EGL_WIDTH,
110 size_.width(), 110 size_.width(),
111 EGL_HEIGHT, 111 EGL_HEIGHT,
112 size_.height(), 112 size_.height(),
113 EGL_LINUX_DRM_FOURCC_EXT, 113 EGL_LINUX_DRM_FOURCC_EXT,
114 FourCC(format), 114 FourCC(format),
115 EGL_DMA_BUF_PLANE0_FD_EXT, 115 EGL_DMA_BUF_PLANE0_FD_EXT,
116 pixmap->GetDmaBufFd(), 116 pixmap->GetDmaBufFd(),
117 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 117 EGL_DMA_BUF_PLANE0_OFFSET_EXT,
118 0, 118 0,
119 EGL_DMA_BUF_PLANE0_PITCH_EXT, 119 EGL_DMA_BUF_PLANE0_PITCH_EXT,
120 pixmap->GetDmaBufPitch(), 120 pixmap->GetDmaBufPitch(),
121 EGL_NONE}; 121 EGL_NONE};
122 result = GLImageEGL::Initialize( 122 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
123 EGL_LINUX_DMA_BUF_EXT, static_cast<EGLClientBuffer>(nullptr), attrs); 123 static_cast<EGLClientBuffer>(nullptr), attrs)) {
124 return false;
125 }
124 } 126 }
125 127
126 if (result) 128 pixmap_ = pixmap;
127 pixmap_ = pixmap; 129 return true;
128 return result;
129 } 130 }
130 131
131 unsigned GLImageOzoneNativePixmap::GetInternalFormat() { 132 unsigned GLImageOzoneNativePixmap::GetInternalFormat() {
132 return internalformat_; 133 return internalformat_;
133 } 134 }
134 135
135 void GLImageOzoneNativePixmap::Destroy(bool have_context) { 136 void GLImageOzoneNativePixmap::Destroy(bool have_context) {
136 GLImageEGL::Destroy(have_context); 137 GLImageEGL::Destroy(have_context);
137 } 138 }
138 139
139 bool GLImageOzoneNativePixmap::ScheduleOverlayPlane(AcceleratedWidget widget, 140 bool GLImageOzoneNativePixmap::ScheduleOverlayPlane(AcceleratedWidget widget,
140 int z_order, 141 int z_order,
141 OverlayTransform transform, 142 OverlayTransform transform,
142 const Rect& bounds_rect, 143 const Rect& bounds_rect,
143 const RectF& crop_rect) { 144 const RectF& crop_rect) {
144 DCHECK(pixmap_); 145 DCHECK(pixmap_);
145 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, 146 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect,
146 crop_rect); 147 crop_rect);
147 } 148 }
148 149
149 void GLImageOzoneNativePixmap::OnMemoryDump( 150 void GLImageOzoneNativePixmap::OnMemoryDump(
150 base::trace_event::ProcessMemoryDump* pmd, 151 base::trace_event::ProcessMemoryDump* pmd,
151 uint64_t process_tracing_id, 152 uint64_t process_tracing_id,
152 const std::string& dump_name) { 153 const std::string& dump_name) {
153 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 154 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914
154 } 155 }
155 156
156 } // namespace gfx 157 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ozone_native_pixmap.h ('k') | ui/gl/gl_image_ref_counted_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698