| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 case gfx::BufferFormat::DXT5: | 81 case gfx::BufferFormat::DXT5: |
| 82 return capabilities.texture_format_dxt5; | 82 return capabilities.texture_format_dxt5; |
| 83 case gfx::BufferFormat::ETC1: | 83 case gfx::BufferFormat::ETC1: |
| 84 return capabilities.texture_format_etc1; | 84 return capabilities.texture_format_etc1; |
| 85 case gfx::BufferFormat::R_8: | 85 case gfx::BufferFormat::R_8: |
| 86 return capabilities.texture_rg; | 86 return capabilities.texture_rg; |
| 87 case gfx::BufferFormat::RGBA_4444: | 87 case gfx::BufferFormat::RGBA_4444: |
| 88 case gfx::BufferFormat::RGBA_8888: | 88 case gfx::BufferFormat::RGBA_8888: |
| 89 case gfx::BufferFormat::RGBX_8888: | 89 case gfx::BufferFormat::RGBX_8888: |
| 90 case gfx::BufferFormat::YUV_420: | 90 case gfx::BufferFormat::YUV_420: |
| 91 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 91 return true; | 92 return true; |
| 92 } | 93 } |
| 93 | 94 |
| 94 NOTREACHED(); | 95 NOTREACHED(); |
| 95 return false; | 96 return false; |
| 96 } | 97 } |
| 97 | 98 |
| 98 // static | 99 // static |
| 99 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 100 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
| 100 const gfx::Size& size, | 101 const gfx::Size& size, |
| 101 gfx::BufferFormat format) { | 102 gfx::BufferFormat format) { |
| 102 switch (format) { | 103 switch (format) { |
| 103 case gfx::BufferFormat::ATC: | 104 case gfx::BufferFormat::ATC: |
| 104 case gfx::BufferFormat::ATCIA: | 105 case gfx::BufferFormat::ATCIA: |
| 105 case gfx::BufferFormat::DXT1: | 106 case gfx::BufferFormat::DXT1: |
| 106 case gfx::BufferFormat::DXT5: | 107 case gfx::BufferFormat::DXT5: |
| 107 case gfx::BufferFormat::ETC1: | 108 case gfx::BufferFormat::ETC1: |
| 108 // Compressed images must have a width and height that's evenly divisible | 109 // Compressed images must have a width and height that's evenly divisible |
| 109 // by the block size. | 110 // by the block size. |
| 110 return size.width() % 4 == 0 && size.height() % 4 == 0; | 111 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 111 case gfx::BufferFormat::R_8: | 112 case gfx::BufferFormat::R_8: |
| 112 case gfx::BufferFormat::RGBA_4444: | 113 case gfx::BufferFormat::RGBA_4444: |
| 113 case gfx::BufferFormat::RGBA_8888: | 114 case gfx::BufferFormat::RGBA_8888: |
| 114 case gfx::BufferFormat::BGRA_8888: | 115 case gfx::BufferFormat::BGRA_8888: |
| 115 case gfx::BufferFormat::RGBX_8888: | 116 case gfx::BufferFormat::RGBX_8888: |
| 116 return true; | 117 return true; |
| 117 case gfx::BufferFormat::YUV_420: | 118 case gfx::BufferFormat::YUV_420: |
| 119 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 118 // U and V planes are subsampled by a factor of 2. | 120 // U and V planes are subsampled by a factor of 2. |
| 119 return size.width() % 2 == 0 && size.height() % 2 == 0; | 121 return size.width() % 2 == 0 && size.height() % 2 == 0; |
| 120 } | 122 } |
| 121 | 123 |
| 122 NOTREACHED(); | 124 NOTREACHED(); |
| 123 return false; | 125 return false; |
| 124 } | 126 } |
| 125 | 127 |
| 126 } // namespace gpu | 128 } // namespace gpu |
| OLD | NEW |