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

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

Issue 1263043006: Implement the texture uploading of ASTC compression for WebGL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and Remove unnecessary enum/OES extensions. Created 5 years, 4 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 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 unsigned internalformat, 64 unsigned internalformat,
65 gfx::GpuMemoryBuffer::Format format) { 65 gfx::GpuMemoryBuffer::Format format) {
66 return ImageFormatToGpuMemoryBufferFormat(internalformat) == format; 66 return ImageFormatToGpuMemoryBufferFormat(internalformat) == format;
67 } 67 }
68 68
69 // static 69 // static
70 bool ImageFactory::IsGpuMemoryBufferFormatSupported( 70 bool ImageFactory::IsGpuMemoryBufferFormatSupported(
71 gfx::GpuMemoryBuffer::Format format, 71 gfx::GpuMemoryBuffer::Format format,
72 const gpu::Capabilities& capabilities) { 72 const gpu::Capabilities& capabilities) {
73 switch (format) { 73 switch (format) {
74 case gfx::GpuMemoryBuffer::ASTC:
75 return capabilities.texture_format_astc;
74 case gfx::GpuMemoryBuffer::ATC: 76 case gfx::GpuMemoryBuffer::ATC:
75 case gfx::GpuMemoryBuffer::ATCIA: 77 case gfx::GpuMemoryBuffer::ATCIA:
76 return capabilities.texture_format_atc; 78 return capabilities.texture_format_atc;
77 case gfx::GpuMemoryBuffer::BGRA_8888: 79 case gfx::GpuMemoryBuffer::BGRA_8888:
78 return capabilities.texture_format_bgra8888; 80 return capabilities.texture_format_bgra8888;
79 case gfx::GpuMemoryBuffer::DXT1: 81 case gfx::GpuMemoryBuffer::DXT1:
80 return capabilities.texture_format_dxt1; 82 return capabilities.texture_format_dxt1;
81 case gfx::GpuMemoryBuffer::DXT5: 83 case gfx::GpuMemoryBuffer::DXT5:
82 return capabilities.texture_format_dxt5; 84 return capabilities.texture_format_dxt5;
83 case gfx::GpuMemoryBuffer::ETC1: 85 case gfx::GpuMemoryBuffer::ETC1:
84 return capabilities.texture_format_etc1; 86 return capabilities.texture_format_etc1;
85 case gfx::GpuMemoryBuffer::R_8: 87 case gfx::GpuMemoryBuffer::R_8:
86 return capabilities.texture_rg; 88 return capabilities.texture_rg;
87 case gfx::GpuMemoryBuffer::RGBA_4444: 89 case gfx::GpuMemoryBuffer::RGBA_4444:
88 case gfx::GpuMemoryBuffer::RGBA_8888: 90 case gfx::GpuMemoryBuffer::RGBA_8888:
89 case gfx::GpuMemoryBuffer::RGBX_8888: 91 case gfx::GpuMemoryBuffer::RGBX_8888:
90 case gfx::GpuMemoryBuffer::YUV_420: 92 case gfx::GpuMemoryBuffer::YUV_420:
91 return true; 93 return true;
92 } 94 }
93 95
94 NOTREACHED(); 96 NOTREACHED();
95 return false; 97 return false;
96 } 98 }
97 99
98 // static 100 // static
99 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( 101 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(
100 const gfx::Size& size, 102 const gfx::Size& size,
101 gfx::GpuMemoryBuffer::Format format) { 103 gfx::GpuMemoryBuffer::Format format) {
102 switch (format) { 104 switch (format) {
105 case gfx::GpuMemoryBuffer::ASTC:
103 case gfx::GpuMemoryBuffer::ATC: 106 case gfx::GpuMemoryBuffer::ATC:
104 case gfx::GpuMemoryBuffer::ATCIA: 107 case gfx::GpuMemoryBuffer::ATCIA:
105 case gfx::GpuMemoryBuffer::DXT1: 108 case gfx::GpuMemoryBuffer::DXT1:
106 case gfx::GpuMemoryBuffer::DXT5: 109 case gfx::GpuMemoryBuffer::DXT5:
107 case gfx::GpuMemoryBuffer::ETC1: 110 case gfx::GpuMemoryBuffer::ETC1:
108 // Compressed images must have a width and height that's evenly divisible 111 // Compressed images must have a width and height that's evenly divisible
109 // by the block size. 112 // by the block size.
110 return size.width() % 4 == 0 && size.height() % 4 == 0; 113 return size.width() % 4 == 0 && size.height() % 4 == 0;
111 case gfx::GpuMemoryBuffer::R_8: 114 case gfx::GpuMemoryBuffer::R_8:
112 case gfx::GpuMemoryBuffer::RGBA_4444: 115 case gfx::GpuMemoryBuffer::RGBA_4444:
113 case gfx::GpuMemoryBuffer::RGBA_8888: 116 case gfx::GpuMemoryBuffer::RGBA_8888:
114 case gfx::GpuMemoryBuffer::BGRA_8888: 117 case gfx::GpuMemoryBuffer::BGRA_8888:
115 case gfx::GpuMemoryBuffer::RGBX_8888: 118 case gfx::GpuMemoryBuffer::RGBX_8888:
116 return true; 119 return true;
117 case gfx::GpuMemoryBuffer::YUV_420: 120 case gfx::GpuMemoryBuffer::YUV_420:
118 // U and V planes are subsampled by a factor of 2. 121 // U and V planes are subsampled by a factor of 2.
119 return size.width() % 2 == 0 && size.height() % 2 == 0; 122 return size.width() % 2 == 0 && size.height() % 2 == 0;
120 } 123 }
121 124
122 NOTREACHED(); 125 NOTREACHED();
123 return false; 126 return false;
124 } 127 }
125 128
126 } // namespace gpu 129 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698