OLD | NEW |
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 "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
8 | 9 |
9 namespace gpu { | 10 namespace gpu { |
10 | 11 |
11 ImageFactory::ImageFactory() { | 12 ImageFactory::ImageFactory() { |
12 } | 13 } |
13 | 14 |
14 ImageFactory::~ImageFactory() { | 15 ImageFactory::~ImageFactory() { |
15 } | 16 } |
16 | 17 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return true; | 87 return true; |
87 } | 88 } |
88 NOTREACHED(); | 89 NOTREACHED(); |
89 return false; | 90 return false; |
90 default: | 91 default: |
91 NOTREACHED(); | 92 NOTREACHED(); |
92 return false; | 93 return false; |
93 } | 94 } |
94 } | 95 } |
95 | 96 |
| 97 // static |
| 98 bool ImageFactory::IsGpuMemoryBufferFormatSupported( |
| 99 gfx::GpuMemoryBuffer::Format format, |
| 100 const gpu::Capabilities& capabilities) { |
| 101 switch (format) { |
| 102 case gfx::GpuMemoryBuffer::ATC: |
| 103 case gfx::GpuMemoryBuffer::ATCIA: |
| 104 return capabilities.texture_format_atc; |
| 105 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 106 return capabilities.texture_format_bgra8888; |
| 107 case gfx::GpuMemoryBuffer::DXT1: |
| 108 return capabilities.texture_format_dxt1; |
| 109 case gfx::GpuMemoryBuffer::DXT5: |
| 110 return capabilities.texture_format_dxt5; |
| 111 case gfx::GpuMemoryBuffer::ETC1: |
| 112 return capabilities.texture_format_etc1; |
| 113 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 114 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 115 return true; |
| 116 } |
| 117 |
| 118 NOTREACHED(); |
| 119 return false; |
| 120 } |
| 121 |
| 122 // static |
| 123 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
| 124 const gfx::Size& size, |
| 125 gfx::GpuMemoryBuffer::Format format) { |
| 126 switch (format) { |
| 127 case gfx::GpuMemoryBuffer::ATC: |
| 128 case gfx::GpuMemoryBuffer::ATCIA: |
| 129 case gfx::GpuMemoryBuffer::DXT1: |
| 130 case gfx::GpuMemoryBuffer::DXT5: |
| 131 case gfx::GpuMemoryBuffer::ETC1: |
| 132 // Compressed images must have a width and height that's evenly divisible |
| 133 // by the block size. |
| 134 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 135 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 136 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 137 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 138 return true; |
| 139 } |
| 140 |
| 141 NOTREACHED(); |
| 142 return false; |
| 143 } |
| 144 |
96 } // namespace gpu | 145 } // namespace gpu |
OLD | NEW |