| 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 "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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 case gfx::BufferFormat::BGRX_8888: | 70 case gfx::BufferFormat::BGRX_8888: |
| 71 case gfx::BufferFormat::DXT1: | 71 case gfx::BufferFormat::DXT1: |
| 72 case gfx::BufferFormat::DXT5: | 72 case gfx::BufferFormat::DXT5: |
| 73 case gfx::BufferFormat::ETC1: | 73 case gfx::BufferFormat::ETC1: |
| 74 case gfx::BufferFormat::R_8: | 74 case gfx::BufferFormat::R_8: |
| 75 case gfx::BufferFormat::RGBA_8888: | 75 case gfx::BufferFormat::RGBA_8888: |
| 76 case gfx::BufferFormat::YUV_420: | 76 case gfx::BufferFormat::YUV_420: |
| 77 return format == DefaultBufferFormatForImageFormat(internalformat); | 77 return format == DefaultBufferFormatForImageFormat(internalformat); |
| 78 case gfx::BufferFormat::RGBA_4444: | 78 case gfx::BufferFormat::RGBA_4444: |
| 79 return internalformat == GL_RGBA; | 79 return internalformat == GL_RGBA; |
| 80 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 81 return internalformat == GL_R8; |
| 80 case gfx::BufferFormat::UYVY_422: | 82 case gfx::BufferFormat::UYVY_422: |
| 81 return internalformat == GL_RGB; | 83 return internalformat == GL_RGB; |
| 82 } | 84 } |
| 83 | 85 |
| 84 NOTREACHED(); | 86 NOTREACHED(); |
| 85 return false; | 87 return false; |
| 86 } | 88 } |
| 87 | 89 |
| 88 // static | 90 // static |
| 89 bool ImageFactory::IsGpuMemoryBufferFormatSupported( | 91 bool ImageFactory::IsGpuMemoryBufferFormatSupported( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 100 case gfx::BufferFormat::DXT5: | 102 case gfx::BufferFormat::DXT5: |
| 101 return capabilities.texture_format_dxt5; | 103 return capabilities.texture_format_dxt5; |
| 102 case gfx::BufferFormat::ETC1: | 104 case gfx::BufferFormat::ETC1: |
| 103 return capabilities.texture_format_etc1; | 105 return capabilities.texture_format_etc1; |
| 104 case gfx::BufferFormat::R_8: | 106 case gfx::BufferFormat::R_8: |
| 105 return capabilities.texture_rg; | 107 return capabilities.texture_rg; |
| 106 case gfx::BufferFormat::RGBA_4444: | 108 case gfx::BufferFormat::RGBA_4444: |
| 107 case gfx::BufferFormat::RGBA_8888: | 109 case gfx::BufferFormat::RGBA_8888: |
| 108 case gfx::BufferFormat::BGRX_8888: | 110 case gfx::BufferFormat::BGRX_8888: |
| 109 case gfx::BufferFormat::YUV_420: | 111 case gfx::BufferFormat::YUV_420: |
| 112 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 110 case gfx::BufferFormat::UYVY_422: | 113 case gfx::BufferFormat::UYVY_422: |
| 111 return true; | 114 return true; |
| 112 } | 115 } |
| 113 | 116 |
| 114 NOTREACHED(); | 117 NOTREACHED(); |
| 115 return false; | 118 return false; |
| 116 } | 119 } |
| 117 | 120 |
| 118 // static | 121 // static |
| 119 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 122 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
| 120 const gfx::Size& size, | 123 const gfx::Size& size, |
| 121 gfx::BufferFormat format) { | 124 gfx::BufferFormat format) { |
| 122 switch (format) { | 125 switch (format) { |
| 123 case gfx::BufferFormat::ATC: | 126 case gfx::BufferFormat::ATC: |
| 124 case gfx::BufferFormat::ATCIA: | 127 case gfx::BufferFormat::ATCIA: |
| 125 case gfx::BufferFormat::DXT1: | 128 case gfx::BufferFormat::DXT1: |
| 126 case gfx::BufferFormat::DXT5: | 129 case gfx::BufferFormat::DXT5: |
| 127 case gfx::BufferFormat::ETC1: | 130 case gfx::BufferFormat::ETC1: |
| 128 // Compressed images must have a width and height that's evenly divisible | 131 // Compressed images must have a width and height that's evenly divisible |
| 129 // by the block size. | 132 // by the block size. |
| 130 return size.width() % 4 == 0 && size.height() % 4 == 0; | 133 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 131 case gfx::BufferFormat::R_8: | 134 case gfx::BufferFormat::R_8: |
| 132 case gfx::BufferFormat::RGBA_4444: | 135 case gfx::BufferFormat::RGBA_4444: |
| 133 case gfx::BufferFormat::RGBA_8888: | 136 case gfx::BufferFormat::RGBA_8888: |
| 134 case gfx::BufferFormat::BGRA_8888: | 137 case gfx::BufferFormat::BGRA_8888: |
| 135 case gfx::BufferFormat::BGRX_8888: | 138 case gfx::BufferFormat::BGRX_8888: |
| 136 return true; | 139 return true; |
| 137 case gfx::BufferFormat::YUV_420: | 140 case gfx::BufferFormat::YUV_420: |
| 141 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 138 // U and V planes are subsampled by a factor of 2. | 142 // U and V planes are subsampled by a factor of 2. |
| 139 return size.width() % 2 == 0 && size.height() % 2 == 0; | 143 return size.width() % 2 == 0 && size.height() % 2 == 0; |
| 140 case gfx::BufferFormat::UYVY_422: | 144 case gfx::BufferFormat::UYVY_422: |
| 141 return size.width() % 2 == 0; | 145 return size.width() % 2 == 0; |
| 142 } | 146 } |
| 143 | 147 |
| 144 NOTREACHED(); | 148 NOTREACHED(); |
| 145 return false; | 149 return false; |
| 146 } | 150 } |
| 147 | 151 |
| 148 } // namespace gpu | 152 } // namespace gpu |
| OLD | NEW |