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

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

Issue 2687093002: Rename GLImageOzoneNativePixmap to GLImageNativePixmap and move it from ui/ozone/gl to ui/gl (Closed)
Patch Set: Rebase Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ozone/gl/gl_image_ozone_native_pixmap.h" 5 #include "ui/gl/gl_image_native_pixmap.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ui/gfx/buffer_format_util.h" 9 #include "ui/gfx/buffer_format_util.h"
10 #include "ui/gl/gl_surface_egl.h" 10 #include "ui/gl/gl_surface_egl.h"
11 11
12 #define FOURCC(a, b, c, d) \ 12 #define FOURCC(a, b, c, d) \
13 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ 13 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
14 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) 14 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24))
15 15
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 NOTREACHED(); 105 NOTREACHED();
106 return 0; 106 return 0;
107 } 107 }
108 108
109 NOTREACHED(); 109 NOTREACHED();
110 return 0; 110 return 0;
111 } 111 }
112 112
113 } // namespace 113 } // namespace
114 114
115 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, 115 GLImageNativePixmap::GLImageNativePixmap(const gfx::Size& size,
116 unsigned internalformat) 116 unsigned internalformat)
117 : GLImageEGL(size), 117 : GLImageEGL(size),
118 internalformat_(internalformat), 118 internalformat_(internalformat),
119 has_image_flush_external_( 119 has_image_flush_external_(
120 gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {} 120 gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {}
121 121
122 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {} 122 GLImageNativePixmap::~GLImageNativePixmap() {}
123 123
124 bool GLImageOzoneNativePixmap::Initialize(NativePixmap* pixmap, 124 bool GLImageNativePixmap::Initialize(NativePixmap* pixmap,
125 gfx::BufferFormat format) { 125 gfx::BufferFormat format) {
126 DCHECK(!pixmap_); 126 DCHECK(!pixmap_);
127 if (pixmap->GetEGLClientBuffer()) { 127 if (pixmap->GetEGLClientBuffer()) {
128 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; 128 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
129 if (!GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, 129 if (!GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR,
130 pixmap->GetEGLClientBuffer(), attrs)) { 130 pixmap->GetEGLClientBuffer(), attrs)) {
131 return false; 131 return false;
132 } 132 }
133 } else if (pixmap->AreDmaBufFdsValid()) { 133 } else if (pixmap->AreDmaBufFdsValid()) {
134 if (!ValidFormat(format)) { 134 if (!ValidFormat(format)) {
135 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 135 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 static_cast<EGLClientBuffer>(nullptr), 187 static_cast<EGLClientBuffer>(nullptr),
188 &attrs[0])) { 188 &attrs[0])) {
189 return false; 189 return false;
190 } 190 }
191 } 191 }
192 192
193 pixmap_ = pixmap; 193 pixmap_ = pixmap;
194 return true; 194 return true;
195 } 195 }
196 196
197 unsigned GLImageOzoneNativePixmap::GetInternalFormat() { 197 unsigned GLImageNativePixmap::GetInternalFormat() {
198 return internalformat_; 198 return internalformat_;
199 } 199 }
200 200
201 bool GLImageOzoneNativePixmap::CopyTexImage(unsigned target) { 201 bool GLImageNativePixmap::CopyTexImage(unsigned target) {
202 if (egl_image_ == EGL_NO_IMAGE_KHR) { 202 if (egl_image_ == EGL_NO_IMAGE_KHR) {
203 // Pass-through image type fails to bind and copy; make sure we 203 // Pass-through image type fails to bind and copy; make sure we
204 // don't draw with uninitialized texture. 204 // don't draw with uninitialized texture.
205 std::vector<unsigned char> data(size_.width() * size_.height() * 4); 205 std::vector<unsigned char> data(size_.width() * size_.height() * 4);
206 glTexImage2D(target, 0, GL_RGBA, size_.width(), size_.height(), 0, GL_RGBA, 206 glTexImage2D(target, 0, GL_RGBA, size_.width(), size_.height(), 0, GL_RGBA,
207 GL_UNSIGNED_BYTE, data.data()); 207 GL_UNSIGNED_BYTE, data.data());
208 return true; 208 return true;
209 } 209 }
210 return GLImageEGL::CopyTexImage(target); 210 return GLImageEGL::CopyTexImage(target);
211 } 211 }
212 212
213 bool GLImageOzoneNativePixmap::ScheduleOverlayPlane( 213 bool GLImageNativePixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
214 gfx::AcceleratedWidget widget, 214 int z_order,
215 int z_order, 215 gfx::OverlayTransform transform,
216 gfx::OverlayTransform transform, 216 const gfx::Rect& bounds_rect,
217 const gfx::Rect& bounds_rect, 217 const gfx::RectF& crop_rect) {
218 const gfx::RectF& crop_rect) {
219 DCHECK(pixmap_); 218 DCHECK(pixmap_);
220 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, 219 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect,
221 crop_rect); 220 crop_rect);
222 } 221 }
223 222
224 void GLImageOzoneNativePixmap::Flush() { 223 void GLImageNativePixmap::Flush() {
225 if (!has_image_flush_external_) 224 if (!has_image_flush_external_)
226 return; 225 return;
227 226
228 EGLDisplay display = gl::GLSurfaceEGL::GetHardwareDisplay(); 227 EGLDisplay display = gl::GLSurfaceEGL::GetHardwareDisplay();
229 const EGLAttrib attribs[] = { 228 const EGLAttrib attribs[] = {
230 EGL_NONE, 229 EGL_NONE,
231 }; 230 };
232 if (!eglImageFlushExternalEXT(display, egl_image_, attribs)) { 231 if (!eglImageFlushExternalEXT(display, egl_image_, attribs)) {
233 LOG(ERROR) << "Failed to flush rendering"; 232 LOG(ERROR) << "Failed to flush rendering";
234 return; 233 return;
235 } 234 }
236 } 235 }
237 236
238 void GLImageOzoneNativePixmap::OnMemoryDump( 237 void GLImageNativePixmap::OnMemoryDump(
239 base::trace_event::ProcessMemoryDump* pmd, 238 base::trace_event::ProcessMemoryDump* pmd,
240 uint64_t process_tracing_id, 239 uint64_t process_tracing_id,
241 const std::string& dump_name) { 240 const std::string& dump_name) {
242 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 241 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914
243 } 242 }
244 243
245 // static 244 // static
246 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( 245 unsigned GLImageNativePixmap::GetInternalFormatForTesting(
247 gfx::BufferFormat format) { 246 gfx::BufferFormat format) {
248 DCHECK(ValidFormat(format)); 247 DCHECK(ValidFormat(format));
249 switch (format) { 248 switch (format) {
250 case gfx::BufferFormat::R_8: 249 case gfx::BufferFormat::R_8:
251 return GL_RED_EXT; 250 return GL_RED_EXT;
252 case gfx::BufferFormat::RG_88: 251 case gfx::BufferFormat::RG_88:
253 return GL_RG_EXT; 252 return GL_RG_EXT;
254 case gfx::BufferFormat::BGR_565: 253 case gfx::BufferFormat::BGR_565:
255 case gfx::BufferFormat::RGBX_8888: 254 case gfx::BufferFormat::RGBX_8888:
256 case gfx::BufferFormat::BGRX_8888: 255 case gfx::BufferFormat::BGRX_8888:
(...skipping 15 matching lines...) Expand all
272 case gfx::BufferFormat::UYVY_422: 271 case gfx::BufferFormat::UYVY_422:
273 NOTREACHED(); 272 NOTREACHED();
274 return GL_NONE; 273 return GL_NONE;
275 } 274 }
276 275
277 NOTREACHED(); 276 NOTREACHED();
278 return GL_NONE; 277 return GL_NONE;
279 } 278 }
280 279
281 } // namespace ui 280 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698