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

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

Issue 1062853002: Add gfx::GpuMemoryBuffer::YUV_420 and GpuMemoryBufferImplSharedMemory support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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_memory.h" 5 #include "ui/gl/gl_image_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "ui/gl/gl_bindings.h" 9 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/scoped_binders.h" 10 #include "ui/gl/scoped_binders.h"
(...skipping 20 matching lines...) Expand all
31 switch (format) { 31 switch (format) {
32 case gfx::GpuMemoryBuffer::ATC: 32 case gfx::GpuMemoryBuffer::ATC:
33 case gfx::GpuMemoryBuffer::ATCIA: 33 case gfx::GpuMemoryBuffer::ATCIA:
34 case gfx::GpuMemoryBuffer::DXT1: 34 case gfx::GpuMemoryBuffer::DXT1:
35 case gfx::GpuMemoryBuffer::DXT5: 35 case gfx::GpuMemoryBuffer::DXT5:
36 case gfx::GpuMemoryBuffer::ETC1: 36 case gfx::GpuMemoryBuffer::ETC1:
37 case gfx::GpuMemoryBuffer::RGBA_8888: 37 case gfx::GpuMemoryBuffer::RGBA_8888:
38 case gfx::GpuMemoryBuffer::BGRA_8888: 38 case gfx::GpuMemoryBuffer::BGRA_8888:
39 return true; 39 return true;
40 case gfx::GpuMemoryBuffer::RGBX_8888: 40 case gfx::GpuMemoryBuffer::RGBX_8888:
41 case gfx::GpuMemoryBuffer::YUV_420:
41 return false; 42 return false;
42 } 43 }
43 44
44 NOTREACHED(); 45 NOTREACHED();
45 return false; 46 return false;
46 } 47 }
47 48
48 bool IsCompressedFormat(gfx::GpuMemoryBuffer::Format format) { 49 bool IsCompressedFormat(gfx::GpuMemoryBuffer::Format format) {
49 switch (format) { 50 switch (format) {
50 case gfx::GpuMemoryBuffer::ATC: 51 case gfx::GpuMemoryBuffer::ATC:
51 case gfx::GpuMemoryBuffer::ATCIA: 52 case gfx::GpuMemoryBuffer::ATCIA:
52 case gfx::GpuMemoryBuffer::DXT1: 53 case gfx::GpuMemoryBuffer::DXT1:
53 case gfx::GpuMemoryBuffer::DXT5: 54 case gfx::GpuMemoryBuffer::DXT5:
54 case gfx::GpuMemoryBuffer::ETC1: 55 case gfx::GpuMemoryBuffer::ETC1:
56 case gfx::GpuMemoryBuffer::YUV_420:
55 return true; 57 return true;
56 case gfx::GpuMemoryBuffer::RGBA_8888: 58 case gfx::GpuMemoryBuffer::RGBA_8888:
57 case gfx::GpuMemoryBuffer::BGRA_8888: 59 case gfx::GpuMemoryBuffer::BGRA_8888:
58 case gfx::GpuMemoryBuffer::RGBX_8888: 60 case gfx::GpuMemoryBuffer::RGBX_8888:
59 return false; 61 return false;
60 } 62 }
61 63
62 NOTREACHED(); 64 NOTREACHED();
63 return false; 65 return false;
64 } 66 }
65 67
66 GLenum TextureFormat(gfx::GpuMemoryBuffer::Format format) { 68 GLenum TextureFormat(gfx::GpuMemoryBuffer::Format format) {
67 switch (format) { 69 switch (format) {
68 case gfx::GpuMemoryBuffer::ATC: 70 case gfx::GpuMemoryBuffer::ATC:
69 return GL_ATC_RGB_AMD; 71 return GL_ATC_RGB_AMD;
70 case gfx::GpuMemoryBuffer::ATCIA: 72 case gfx::GpuMemoryBuffer::ATCIA:
71 return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD; 73 return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD;
72 case gfx::GpuMemoryBuffer::DXT1: 74 case gfx::GpuMemoryBuffer::DXT1:
73 return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; 75 return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
74 case gfx::GpuMemoryBuffer::DXT5: 76 case gfx::GpuMemoryBuffer::DXT5:
75 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; 77 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
76 case gfx::GpuMemoryBuffer::ETC1: 78 case gfx::GpuMemoryBuffer::ETC1:
77 return GL_ETC1_RGB8_OES; 79 return GL_ETC1_RGB8_OES;
78 case gfx::GpuMemoryBuffer::RGBA_8888: 80 case gfx::GpuMemoryBuffer::RGBA_8888:
79 return GL_RGBA; 81 return GL_RGBA;
80 case gfx::GpuMemoryBuffer::BGRA_8888: 82 case gfx::GpuMemoryBuffer::BGRA_8888:
81 return GL_BGRA_EXT; 83 return GL_BGRA_EXT;
82 case gfx::GpuMemoryBuffer::RGBX_8888: 84 case gfx::GpuMemoryBuffer::RGBX_8888:
85 case gfx::GpuMemoryBuffer::YUV_420:
83 NOTREACHED(); 86 NOTREACHED();
84 return 0; 87 return 0;
85 } 88 }
86 89
87 NOTREACHED(); 90 NOTREACHED();
88 return 0; 91 return 0;
89 } 92 }
90 93
91 GLenum DataFormat(gfx::GpuMemoryBuffer::Format format) { 94 GLenum DataFormat(gfx::GpuMemoryBuffer::Format format) {
92 return TextureFormat(format); 95 return TextureFormat(format);
93 } 96 }
94 97
95 GLenum DataType(gfx::GpuMemoryBuffer::Format format) { 98 GLenum DataType(gfx::GpuMemoryBuffer::Format format) {
96 switch (format) { 99 switch (format) {
97 case gfx::GpuMemoryBuffer::RGBA_8888: 100 case gfx::GpuMemoryBuffer::RGBA_8888:
98 case gfx::GpuMemoryBuffer::BGRA_8888: 101 case gfx::GpuMemoryBuffer::BGRA_8888:
99 return GL_UNSIGNED_BYTE; 102 return GL_UNSIGNED_BYTE;
100 case gfx::GpuMemoryBuffer::ATC: 103 case gfx::GpuMemoryBuffer::ATC:
101 case gfx::GpuMemoryBuffer::ATCIA: 104 case gfx::GpuMemoryBuffer::ATCIA:
102 case gfx::GpuMemoryBuffer::DXT1: 105 case gfx::GpuMemoryBuffer::DXT1:
103 case gfx::GpuMemoryBuffer::DXT5: 106 case gfx::GpuMemoryBuffer::DXT5:
104 case gfx::GpuMemoryBuffer::ETC1: 107 case gfx::GpuMemoryBuffer::ETC1:
105 case gfx::GpuMemoryBuffer::RGBX_8888: 108 case gfx::GpuMemoryBuffer::RGBX_8888:
109 case gfx::GpuMemoryBuffer::YUV_420:
106 NOTREACHED(); 110 NOTREACHED();
107 return 0; 111 return 0;
108 } 112 }
109 113
110 NOTREACHED(); 114 NOTREACHED();
111 return 0; 115 return 0;
112 } 116 }
113 117
114 GLsizei SizeInBytes(const gfx::Size& size, 118 GLsizei SizeInBytes(const gfx::Size& size,
115 gfx::GpuMemoryBuffer::Format format) { 119 gfx::GpuMemoryBuffer::Format format) {
(...skipping 30 matching lines...) Expand all
146 DCHECK_EQ(0u, egl_texture_id_); 150 DCHECK_EQ(0u, egl_texture_id_);
147 #endif 151 #endif
148 } 152 }
149 153
150 // static 154 // static
151 bool GLImageMemory::StrideInBytes(size_t width, 155 bool GLImageMemory::StrideInBytes(size_t width,
152 gfx::GpuMemoryBuffer::Format format, 156 gfx::GpuMemoryBuffer::Format format,
153 size_t* stride_in_bytes) { 157 size_t* stride_in_bytes) {
154 base::CheckedNumeric<size_t> s = width; 158 base::CheckedNumeric<size_t> s = width;
155 switch (format) { 159 switch (format) {
156 case gfx::GpuMemoryBuffer::ATCIA:
157 case gfx::GpuMemoryBuffer::DXT5:
158 *stride_in_bytes = width;
159 return true;
160 case gfx::GpuMemoryBuffer::ATC: 160 case gfx::GpuMemoryBuffer::ATC:
161 case gfx::GpuMemoryBuffer::DXT1: 161 case gfx::GpuMemoryBuffer::DXT1:
162 case gfx::GpuMemoryBuffer::ETC1: 162 case gfx::GpuMemoryBuffer::ETC1:
163 DCHECK_EQ(width % 2, 0U); 163 DCHECK_EQ(width % 2, 0U);
164 s /= 2; 164 s /= 2;
165 if (!s.IsValid()) 165 if (!s.IsValid())
166 return false; 166 return false;
167
168 *stride_in_bytes = s.ValueOrDie(); 167 *stride_in_bytes = s.ValueOrDie();
169 return true; 168 return true;
169 case gfx::GpuMemoryBuffer::ATCIA:
170 case gfx::GpuMemoryBuffer::DXT5:
171 *stride_in_bytes = width;
172 return true;
170 case gfx::GpuMemoryBuffer::RGBA_8888: 173 case gfx::GpuMemoryBuffer::RGBA_8888:
171 case gfx::GpuMemoryBuffer::BGRA_8888: 174 case gfx::GpuMemoryBuffer::BGRA_8888:
172 s *= 4; 175 s *= 4;
173 if (!s.IsValid()) 176 if (!s.IsValid())
174 return false; 177 return false;
175
176 *stride_in_bytes = s.ValueOrDie(); 178 *stride_in_bytes = s.ValueOrDie();
177 return true; 179 return true;
178 case gfx::GpuMemoryBuffer::RGBX_8888: 180 case gfx::GpuMemoryBuffer::RGBX_8888:
181 case gfx::GpuMemoryBuffer::YUV_420:
179 NOTREACHED(); 182 NOTREACHED();
180 return false; 183 return false;
181 } 184 }
182 185
183 NOTREACHED(); 186 NOTREACHED();
184 return false; 187 return false;
185 } 188 }
186 189
187 bool GLImageMemory::Initialize(const unsigned char* memory, 190 bool GLImageMemory::Initialize(const unsigned char* memory,
188 gfx::GpuMemoryBuffer::Format format) { 191 gfx::GpuMemoryBuffer::Format format) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 size_.width(), 394 size_.width(),
392 size_.height(), 395 size_.height(),
393 0, // border 396 0, // border
394 DataFormat(format_), 397 DataFormat(format_),
395 DataType(format_), 398 DataType(format_),
396 memory_); 399 memory_);
397 } 400 }
398 } 401 }
399 402
400 } // namespace gfx 403 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698