| 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 namespace { |
| 13 } | 13 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { |
| 14 | |
| 15 ImageFactory::~ImageFactory() { | |
| 16 } | |
| 17 | |
| 18 // static | |
| 19 gfx::BufferFormat ImageFactory::DefaultBufferFormatForImageFormat( | |
| 20 unsigned internalformat) { | |
| 21 switch (internalformat) { | 14 switch (internalformat) { |
| 22 case GL_RED: | 15 case GL_RED: |
| 23 return gfx::BufferFormat::R_8; | 16 return gfx::BufferFormat::R_8; |
| 24 case GL_RGB: | 17 case GL_RGB: |
| 25 return gfx::BufferFormat::BGRX_8888; | 18 return gfx::BufferFormat::BGRX_8888; |
| 26 case GL_RGBA: | 19 case GL_RGBA: |
| 27 return gfx::BufferFormat::RGBA_8888; | 20 return gfx::BufferFormat::RGBA_8888; |
| 28 case GL_BGRA_EXT: | 21 case GL_BGRA_EXT: |
| 29 return gfx::BufferFormat::BGRA_8888; | 22 return gfx::BufferFormat::BGRA_8888; |
| 30 case GL_ATC_RGB_AMD: | 23 case GL_ATC_RGB_AMD: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 case GL_RGB_YCBCR_420V_CHROMIUM: | 35 case GL_RGB_YCBCR_420V_CHROMIUM: |
| 43 return gfx::BufferFormat::YUV_420_BIPLANAR; | 36 return gfx::BufferFormat::YUV_420_BIPLANAR; |
| 44 case GL_RGB_YCBCR_422_CHROMIUM: | 37 case GL_RGB_YCBCR_422_CHROMIUM: |
| 45 return gfx::BufferFormat::UYVY_422; | 38 return gfx::BufferFormat::UYVY_422; |
| 46 default: | 39 default: |
| 47 NOTREACHED(); | 40 NOTREACHED(); |
| 48 return gfx::BufferFormat::RGBA_8888; | 41 return gfx::BufferFormat::RGBA_8888; |
| 49 } | 42 } |
| 50 } | 43 } |
| 51 | 44 |
| 45 } // namespace |
| 46 |
| 47 ImageFactory::ImageFactory() { |
| 48 } |
| 49 |
| 50 ImageFactory::~ImageFactory() { |
| 51 } |
| 52 |
| 53 // static |
| 54 gfx::BufferFormat ImageFactory::DefaultBufferFormatForImageFormat( |
| 55 unsigned internalformat) { |
| 56 switch (internalformat) { |
| 57 case GL_RGB: |
| 58 return gfx::BufferFormat::BGRX_8888; |
| 59 case GL_RGBA: |
| 60 return gfx::BufferFormat::RGBA_8888; |
| 61 default: |
| 62 NOTREACHED(); |
| 63 return gfx::BufferFormat::RGBA_8888; |
| 64 } |
| 65 } |
| 66 |
| 52 // static | 67 // static |
| 53 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 68 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
| 54 unsigned internalformat, | 69 unsigned internalformat, |
| 55 gfx::BufferFormat format) { | 70 gfx::BufferFormat format) { |
| 56 switch (format) { | 71 switch (format) { |
| 57 case gfx::BufferFormat::ATC: | 72 case gfx::BufferFormat::ATC: |
| 58 case gfx::BufferFormat::ATCIA: | 73 case gfx::BufferFormat::ATCIA: |
| 59 case gfx::BufferFormat::BGRA_8888: | 74 case gfx::BufferFormat::BGRA_8888: |
| 60 case gfx::BufferFormat::BGRX_8888: | 75 case gfx::BufferFormat::BGRX_8888: |
| 61 case gfx::BufferFormat::DXT1: | 76 case gfx::BufferFormat::DXT1: |
| 62 case gfx::BufferFormat::DXT5: | 77 case gfx::BufferFormat::DXT5: |
| 63 case gfx::BufferFormat::ETC1: | 78 case gfx::BufferFormat::ETC1: |
| 64 case gfx::BufferFormat::R_8: | 79 case gfx::BufferFormat::R_8: |
| 65 case gfx::BufferFormat::RGBA_8888: | 80 case gfx::BufferFormat::RGBA_8888: |
| 66 case gfx::BufferFormat::RGBX_8888: | 81 case gfx::BufferFormat::RGBX_8888: |
| 67 case gfx::BufferFormat::YUV_420: | 82 case gfx::BufferFormat::YUV_420: |
| 68 case gfx::BufferFormat::YUV_420_BIPLANAR: | 83 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 69 case gfx::BufferFormat::UYVY_422: | 84 case gfx::BufferFormat::UYVY_422: |
| 70 return format == DefaultBufferFormatForImageFormat(internalformat); | 85 return format == BufferFormatForInternalFormat(internalformat); |
| 71 case gfx::BufferFormat::RGBA_4444: | 86 case gfx::BufferFormat::RGBA_4444: |
| 72 return internalformat == GL_RGBA; | 87 return internalformat == GL_RGBA; |
| 73 } | 88 } |
| 74 | 89 |
| 75 NOTREACHED(); | 90 NOTREACHED(); |
| 76 return false; | 91 return false; |
| 77 } | 92 } |
| 78 | 93 |
| 79 // static | 94 // static |
| 80 bool ImageFactory::IsGpuMemoryBufferFormatSupported( | 95 bool ImageFactory::IsGpuMemoryBufferFormatSupported( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return size.width() % 2 == 0 && size.height() % 2 == 0; | 151 return size.width() % 2 == 0 && size.height() % 2 == 0; |
| 137 case gfx::BufferFormat::UYVY_422: | 152 case gfx::BufferFormat::UYVY_422: |
| 138 return size.width() % 2 == 0; | 153 return size.width() % 2 == 0; |
| 139 } | 154 } |
| 140 | 155 |
| 141 NOTREACHED(); | 156 NOTREACHED(); |
| 142 return false; | 157 return false; |
| 143 } | 158 } |
| 144 | 159 |
| 145 } // namespace gpu | 160 } // namespace gpu |
| OLD | NEW |