| 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 { |
| 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 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( | 19 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( |
| 20 unsigned internalformat) { | 20 unsigned internalformat) { |
| 21 switch (internalformat) { | 21 switch (internalformat) { |
| 22 case GL_R8: |
| 23 return gfx::GpuMemoryBuffer::R_8; |
| 22 case GL_RGB: | 24 case GL_RGB: |
| 23 return gfx::GpuMemoryBuffer::RGBX_8888; | 25 return gfx::GpuMemoryBuffer::RGBX_8888; |
| 24 case GL_RGBA: | 26 case GL_RGBA: |
| 25 return gfx::GpuMemoryBuffer::RGBA_8888; | 27 return gfx::GpuMemoryBuffer::RGBA_8888; |
| 26 case GL_BGRA_EXT: | 28 case GL_BGRA_EXT: |
| 27 return gfx::GpuMemoryBuffer::BGRA_8888; | 29 return gfx::GpuMemoryBuffer::BGRA_8888; |
| 28 case GL_ATC_RGB_AMD: | 30 case GL_ATC_RGB_AMD: |
| 29 return gfx::GpuMemoryBuffer::ATC; | 31 return gfx::GpuMemoryBuffer::ATC; |
| 30 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 32 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
| 31 return gfx::GpuMemoryBuffer::ATCIA; | 33 return gfx::GpuMemoryBuffer::ATCIA; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 case gfx::GpuMemoryBuffer::ATCIA: | 73 case gfx::GpuMemoryBuffer::ATCIA: |
| 72 return capabilities.texture_format_atc; | 74 return capabilities.texture_format_atc; |
| 73 case gfx::GpuMemoryBuffer::BGRA_8888: | 75 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 74 return capabilities.texture_format_bgra8888; | 76 return capabilities.texture_format_bgra8888; |
| 75 case gfx::GpuMemoryBuffer::DXT1: | 77 case gfx::GpuMemoryBuffer::DXT1: |
| 76 return capabilities.texture_format_dxt1; | 78 return capabilities.texture_format_dxt1; |
| 77 case gfx::GpuMemoryBuffer::DXT5: | 79 case gfx::GpuMemoryBuffer::DXT5: |
| 78 return capabilities.texture_format_dxt5; | 80 return capabilities.texture_format_dxt5; |
| 79 case gfx::GpuMemoryBuffer::ETC1: | 81 case gfx::GpuMemoryBuffer::ETC1: |
| 80 return capabilities.texture_format_etc1; | 82 return capabilities.texture_format_etc1; |
| 83 case gfx::GpuMemoryBuffer::R_8: |
| 84 return capabilities.texture_rg; |
| 81 case gfx::GpuMemoryBuffer::RGBA_8888: | 85 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 82 case gfx::GpuMemoryBuffer::RGBX_8888: | 86 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 83 case gfx::GpuMemoryBuffer::YUV_420: | 87 case gfx::GpuMemoryBuffer::YUV_420: |
| 84 return true; | 88 return true; |
| 85 } | 89 } |
| 86 | 90 |
| 87 NOTREACHED(); | 91 NOTREACHED(); |
| 88 return false; | 92 return false; |
| 89 } | 93 } |
| 90 | 94 |
| 91 // static | 95 // static |
| 92 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 96 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
| 93 const gfx::Size& size, | 97 const gfx::Size& size, |
| 94 gfx::GpuMemoryBuffer::Format format) { | 98 gfx::GpuMemoryBuffer::Format format) { |
| 95 switch (format) { | 99 switch (format) { |
| 96 case gfx::GpuMemoryBuffer::ATC: | 100 case gfx::GpuMemoryBuffer::ATC: |
| 97 case gfx::GpuMemoryBuffer::ATCIA: | 101 case gfx::GpuMemoryBuffer::ATCIA: |
| 98 case gfx::GpuMemoryBuffer::DXT1: | 102 case gfx::GpuMemoryBuffer::DXT1: |
| 99 case gfx::GpuMemoryBuffer::DXT5: | 103 case gfx::GpuMemoryBuffer::DXT5: |
| 100 case gfx::GpuMemoryBuffer::ETC1: | 104 case gfx::GpuMemoryBuffer::ETC1: |
| 101 // Compressed images must have a width and height that's evenly divisible | 105 // Compressed images must have a width and height that's evenly divisible |
| 102 // by the block size. | 106 // by the block size. |
| 103 return size.width() % 4 == 0 && size.height() % 4 == 0; | 107 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 108 case gfx::GpuMemoryBuffer::R_8: |
| 104 case gfx::GpuMemoryBuffer::RGBA_8888: | 109 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 105 case gfx::GpuMemoryBuffer::BGRA_8888: | 110 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 106 case gfx::GpuMemoryBuffer::RGBX_8888: | 111 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 107 case gfx::GpuMemoryBuffer::YUV_420: | 112 case gfx::GpuMemoryBuffer::YUV_420: |
| 108 return true; | 113 return true; |
| 109 } | 114 } |
| 110 | 115 |
| 111 NOTREACHED(); | 116 NOTREACHED(); |
| 112 return false; | 117 return false; |
| 113 } | 118 } |
| 114 | 119 |
| 115 } // namespace gpu | 120 } // namespace gpu |
| OLD | NEW |