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

Side by Side Diff: gpu/command_buffer/service/image_factory.cc

Issue 962723002: Change CHROMIUM_image declarations to support multi planar input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reveman@ comments. 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
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 "gpu/command_buffer/service/image_factory.h" 5 #include "gpu/command_buffer/service/image_factory.h"
6 6
7 #include "gpu/command_buffer/common/capabilities.h" 7 #include "gpu/command_buffer/common/capabilities.h"
8 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
9 9
10 namespace gpu { 10 namespace gpu {
11 11
12 ImageFactory::ImageFactory() { 12 ImageFactory::ImageFactory() {
13 } 13 }
14 14
15 ImageFactory::~ImageFactory() { 15 ImageFactory::~ImageFactory() {
16 } 16 }
17 17
18 // static 18 // static
19 bool ImageFactory::IsImageFormatSupported(unsigned internalformat) {
20 switch (internalformat) {
21 case GL_RGB:
22 case GL_RGBA:
23 case GL_ATC_RGB_AMD:
24 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
25 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
26 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
27 case GL_ETC1_RGB8_OES:
28 return true;
29 default:
30 NOTREACHED();
31 return false;
32 }
33 }
34
35 // static
36 size_t ImageFactory::NumberOfPlanesForImageFormat(unsigned internalformat) {
37 switch (internalformat) {
38 case GL_RGB:
39 case GL_RGBA:
40 case GL_ATC_RGB_AMD:
41 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
42 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
43 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
44 case GL_ETC1_RGB8_OES:
45 return 1;
46 default:
47 NOTREACHED();
48 return 0;
49 }
50 }
51
52 // static
19 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( 53 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat(
20 unsigned internalformat) { 54 unsigned internalformat,
55 size_t plane) {
56 DCHECK_EQ(plane, 0u);
21 switch (internalformat) { 57 switch (internalformat) {
22 case GL_RGB: 58 case GL_RGB:
23 return gfx::GpuMemoryBuffer::RGBX_8888;
24 case GL_RGBA: 59 case GL_RGBA:
25 return gfx::GpuMemoryBuffer::RGBA_8888; 60 return gfx::GpuMemoryBuffer::RGBA_8888;
26 case GL_ATC_RGB_AMD: 61 case GL_ATC_RGB_AMD:
27 return gfx::GpuMemoryBuffer::ATC; 62 return gfx::GpuMemoryBuffer::ATC;
28 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: 63 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
29 return gfx::GpuMemoryBuffer::ATCIA; 64 return gfx::GpuMemoryBuffer::ATCIA;
30 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 65 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
31 return gfx::GpuMemoryBuffer::DXT1; 66 return gfx::GpuMemoryBuffer::DXT1;
32 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 67 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
33 return gfx::GpuMemoryBuffer::DXT5; 68 return gfx::GpuMemoryBuffer::DXT5;
(...skipping 15 matching lines...) Expand all
49 return gfx::GpuMemoryBuffer::SCANOUT; 84 return gfx::GpuMemoryBuffer::SCANOUT;
50 default: 85 default:
51 NOTREACHED(); 86 NOTREACHED();
52 return gfx::GpuMemoryBuffer::MAP; 87 return gfx::GpuMemoryBuffer::MAP;
53 } 88 }
54 } 89 }
55 90
56 // static 91 // static
57 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( 92 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
58 unsigned internalformat, 93 unsigned internalformat,
94 size_t plane,
59 gfx::GpuMemoryBuffer::Format format) { 95 gfx::GpuMemoryBuffer::Format format) {
96 DCHECK_EQ(plane, 0u);
60 switch (internalformat) { 97 switch (internalformat) {
61 case GL_RGB: 98 case GL_RGB:
62 switch (format) { 99 switch (format) {
63 case gfx::GpuMemoryBuffer::ATC: 100 case gfx::GpuMemoryBuffer::ATC:
64 case gfx::GpuMemoryBuffer::ATCIA: 101 case gfx::GpuMemoryBuffer::ATCIA:
65 case gfx::GpuMemoryBuffer::DXT1: 102 case gfx::GpuMemoryBuffer::DXT1:
66 case gfx::GpuMemoryBuffer::DXT5: 103 case gfx::GpuMemoryBuffer::DXT5:
67 case gfx::GpuMemoryBuffer::ETC1: 104 case gfx::GpuMemoryBuffer::ETC1:
68 case gfx::GpuMemoryBuffer::RGBX_8888: 105 case gfx::GpuMemoryBuffer::RGBX_8888:
69 return true; 106 return true;
70 case gfx::GpuMemoryBuffer::RGBA_8888: 107 case gfx::GpuMemoryBuffer::RGBA_8888:
71 case gfx::GpuMemoryBuffer::BGRA_8888: 108 case gfx::GpuMemoryBuffer::BGRA_8888:
72 return false; 109 return false;
73 } 110 }
74 NOTREACHED();
75 return false;
76 case GL_RGBA: 111 case GL_RGBA:
77 switch (format) { 112 switch (format) {
78 case gfx::GpuMemoryBuffer::RGBX_8888: 113 case gfx::GpuMemoryBuffer::RGBX_8888:
79 return false; 114 return false;
80 case gfx::GpuMemoryBuffer::ATC: 115 case gfx::GpuMemoryBuffer::ATC:
81 case gfx::GpuMemoryBuffer::ATCIA: 116 case gfx::GpuMemoryBuffer::ATCIA:
82 case gfx::GpuMemoryBuffer::DXT1: 117 case gfx::GpuMemoryBuffer::DXT1:
83 case gfx::GpuMemoryBuffer::DXT5: 118 case gfx::GpuMemoryBuffer::DXT5:
84 case gfx::GpuMemoryBuffer::ETC1: 119 case gfx::GpuMemoryBuffer::ETC1:
85 case gfx::GpuMemoryBuffer::RGBA_8888: 120 case gfx::GpuMemoryBuffer::RGBA_8888:
86 case gfx::GpuMemoryBuffer::BGRA_8888: 121 case gfx::GpuMemoryBuffer::BGRA_8888:
87 return true; 122 return true;
88 } 123 }
89 NOTREACHED();
90 return false;
91 default: 124 default:
92 NOTREACHED(); 125 NOTREACHED();
93 return false; 126 return false;
94 } 127 }
95 } 128 }
96 129
97 // static 130 // static
98 bool ImageFactory::IsGpuMemoryBufferFormatSupported( 131 bool ImageFactory::IsGpuMemoryBufferFormatSupported(
99 gfx::GpuMemoryBuffer::Format format, 132 gfx::GpuMemoryBuffer::Format format,
100 const gpu::Capabilities& capabilities) { 133 const gpu::Capabilities& capabilities) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 case gfx::GpuMemoryBuffer::BGRA_8888: 169 case gfx::GpuMemoryBuffer::BGRA_8888:
137 case gfx::GpuMemoryBuffer::RGBX_8888: 170 case gfx::GpuMemoryBuffer::RGBX_8888:
138 return true; 171 return true;
139 } 172 }
140 173
141 NOTREACHED(); 174 NOTREACHED();
142 return false; 175 return false;
143 } 176 }
144 177
145 } // namespace gpu 178 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698