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

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

Issue 916083002: Add support for compressed GPU memory buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ozone Created 5 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
« no previous file with comments | « ui/gfx/gpu_memory_buffer.h ('k') | ui/gl/gl_image_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_linux_dma_buffer.h" 5 #include "ui/gl/gl_image_linux_dma_buffer.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #define FOURCC(a, b, c, d) \ 9 #define FOURCC(a, b, c, d) \
10 ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \ 10 ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
11 (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24)) 11 (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
12 12
13 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') 13 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4')
14 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') 14 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
15 15
16 namespace gfx { 16 namespace gfx {
17 namespace { 17 namespace {
18 18
19 bool ValidFormat(unsigned internalformat, gfx::GpuMemoryBuffer::Format format) { 19 bool ValidFormat(unsigned internalformat, gfx::GpuMemoryBuffer::Format format) {
20 switch (internalformat) { 20 switch (internalformat) {
21 case GL_ATC_RGB_AMD:
22 return format == gfx::GpuMemoryBuffer::ATC;
23 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
24 return format == gfx::GpuMemoryBuffer::ATCIA;
25 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
26 return format == gfx::GpuMemoryBuffer::DXT1;
27 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
28 return format == gfx::GpuMemoryBuffer::DXT5;
29 case GL_ETC1_RGB8_OES:
30 return format == gfx::GpuMemoryBuffer::ETC1;
21 case GL_RGB: 31 case GL_RGB:
22 switch (format) { 32 switch (format) {
23 case gfx::GpuMemoryBuffer::RGBX_8888: 33 case gfx::GpuMemoryBuffer::RGBX_8888:
24 return true; 34 return true;
35 case gfx::GpuMemoryBuffer::ATC:
36 case gfx::GpuMemoryBuffer::ATCIA:
37 case gfx::GpuMemoryBuffer::DXT1:
38 case gfx::GpuMemoryBuffer::DXT5:
39 case gfx::GpuMemoryBuffer::ETC1:
25 case gfx::GpuMemoryBuffer::RGBA_8888: 40 case gfx::GpuMemoryBuffer::RGBA_8888:
26 case gfx::GpuMemoryBuffer::BGRA_8888: 41 case gfx::GpuMemoryBuffer::BGRA_8888:
27 return false; 42 return false;
28 } 43 }
29 NOTREACHED(); 44 NOTREACHED();
30 return false; 45 return false;
31 case GL_RGBA: 46 case GL_RGBA:
32 switch (format) { 47 switch (format) {
33 case gfx::GpuMemoryBuffer::BGRA_8888: 48 case gfx::GpuMemoryBuffer::BGRA_8888:
34 return true; 49 return true;
50 case gfx::GpuMemoryBuffer::ATC:
51 case gfx::GpuMemoryBuffer::ATCIA:
52 case gfx::GpuMemoryBuffer::DXT1:
53 case gfx::GpuMemoryBuffer::DXT5:
54 case gfx::GpuMemoryBuffer::ETC1:
35 case gfx::GpuMemoryBuffer::RGBX_8888: 55 case gfx::GpuMemoryBuffer::RGBX_8888:
36 case gfx::GpuMemoryBuffer::RGBA_8888: 56 case gfx::GpuMemoryBuffer::RGBA_8888:
37 return false; 57 return false;
38 } 58 }
39 NOTREACHED(); 59 NOTREACHED();
40 return false; 60 return false;
41 default: 61 default:
42 return false; 62 return false;
43 } 63 }
44 } 64 }
45 65
46 EGLint FourCC(gfx::GpuMemoryBuffer::Format format) { 66 EGLint FourCC(gfx::GpuMemoryBuffer::Format format) {
47 switch (format) { 67 switch (format) {
48 case gfx::GpuMemoryBuffer::BGRA_8888: 68 case gfx::GpuMemoryBuffer::BGRA_8888:
49 return DRM_FORMAT_ARGB8888; 69 return DRM_FORMAT_ARGB8888;
50 case gfx::GpuMemoryBuffer::RGBX_8888: 70 case gfx::GpuMemoryBuffer::RGBX_8888:
51 return DRM_FORMAT_XRGB8888; 71 return DRM_FORMAT_XRGB8888;
72 case gfx::GpuMemoryBuffer::ATC:
73 case gfx::GpuMemoryBuffer::ATCIA:
74 case gfx::GpuMemoryBuffer::DXT1:
75 case gfx::GpuMemoryBuffer::DXT5:
76 case gfx::GpuMemoryBuffer::ETC1:
52 case gfx::GpuMemoryBuffer::RGBA_8888: 77 case gfx::GpuMemoryBuffer::RGBA_8888:
53 NOTREACHED(); 78 NOTREACHED();
54 return 0; 79 return 0;
55 } 80 }
56 81
57 NOTREACHED(); 82 NOTREACHED();
58 return 0; 83 return 0;
59 } 84 }
60 85
61 bool IsHandleValid(const base::FileDescriptor& handle) { 86 bool IsHandleValid(const base::FileDescriptor& handle) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 123 EGL_DMA_BUF_PLANE0_OFFSET_EXT,
99 0, 124 0,
100 EGL_DMA_BUF_PLANE0_PITCH_EXT, 125 EGL_DMA_BUF_PLANE0_PITCH_EXT,
101 pitch, 126 pitch,
102 EGL_NONE}; 127 EGL_NONE};
103 return GLImageEGL::Initialize( 128 return GLImageEGL::Initialize(
104 EGL_LINUX_DMA_BUF_EXT, static_cast<EGLClientBuffer>(NULL), attrs); 129 EGL_LINUX_DMA_BUF_EXT, static_cast<EGLClientBuffer>(NULL), attrs);
105 } 130 }
106 131
107 } // namespace gfx 132 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gpu_memory_buffer.h ('k') | ui/gl/gl_image_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698