| 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 return true; | 87 return true; |
| 84 } | 88 } |
| 85 | 89 |
| 86 NOTREACHED(); | 90 NOTREACHED(); |
| 87 return false; | 91 return false; |
| 88 } | 92 } |
| 89 | 93 |
| 90 // static | 94 // static |
| 91 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 95 bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
| 92 const gfx::Size& size, | 96 const gfx::Size& size, |
| 93 gfx::GpuMemoryBuffer::Format format) { | 97 gfx::GpuMemoryBuffer::Format format) { |
| 94 switch (format) { | 98 switch (format) { |
| 95 case gfx::GpuMemoryBuffer::ATC: | 99 case gfx::GpuMemoryBuffer::ATC: |
| 96 case gfx::GpuMemoryBuffer::ATCIA: | 100 case gfx::GpuMemoryBuffer::ATCIA: |
| 97 case gfx::GpuMemoryBuffer::DXT1: | 101 case gfx::GpuMemoryBuffer::DXT1: |
| 98 case gfx::GpuMemoryBuffer::DXT5: | 102 case gfx::GpuMemoryBuffer::DXT5: |
| 99 case gfx::GpuMemoryBuffer::ETC1: | 103 case gfx::GpuMemoryBuffer::ETC1: |
| 100 // Compressed images must have a width and height that's evenly divisible | 104 // Compressed images must have a width and height that's evenly divisible |
| 101 // by the block size. | 105 // by the block size. |
| 102 return size.width() % 4 == 0 && size.height() % 4 == 0; | 106 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 107 case gfx::GpuMemoryBuffer::R_8: |
| 103 case gfx::GpuMemoryBuffer::RGBA_8888: | 108 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 104 case gfx::GpuMemoryBuffer::BGRA_8888: | 109 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 105 case gfx::GpuMemoryBuffer::RGBX_8888: | 110 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 106 return true; | 111 return true; |
| 107 } | 112 } |
| 108 | 113 |
| 109 NOTREACHED(); | 114 NOTREACHED(); |
| 110 return false; | 115 return false; |
| 111 } | 116 } |
| 112 | 117 |
| 113 } // namespace gpu | 118 } // namespace gpu |
| OLD | NEW |