OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/command_buffer/service/image_factory.h" |
| 6 |
| 7 #include "ui/gl/gl_bindings.h" |
| 8 |
| 9 namespace gpu { |
| 10 |
| 11 ImageFactory::ImageFactory() { |
| 12 } |
| 13 |
| 14 ImageFactory::~ImageFactory() { |
| 15 } |
| 16 |
| 17 // static |
| 18 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( |
| 19 unsigned internalformat) { |
| 20 switch (internalformat) { |
| 21 case GL_RGB: |
| 22 return gfx::GpuMemoryBuffer::RGBX_8888; |
| 23 case GL_RGBA: |
| 24 return gfx::GpuMemoryBuffer::RGBA_8888; |
| 25 default: |
| 26 NOTREACHED(); |
| 27 return gfx::GpuMemoryBuffer::RGBA_8888; |
| 28 } |
| 29 } |
| 30 |
| 31 // static |
| 32 gfx::GpuMemoryBuffer::Usage ImageFactory::ImageUsageToGpuMemoryBufferUsage( |
| 33 unsigned usage) { |
| 34 switch (usage) { |
| 35 case GL_MAP_CHROMIUM: |
| 36 return gfx::GpuMemoryBuffer::MAP; |
| 37 case GL_SCANOUT_CHROMIUM: |
| 38 return gfx::GpuMemoryBuffer::SCANOUT; |
| 39 default: |
| 40 NOTREACHED(); |
| 41 return gfx::GpuMemoryBuffer::MAP; |
| 42 } |
| 43 } |
| 44 |
| 45 // static |
| 46 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
| 47 unsigned internalformat, |
| 48 gfx::GpuMemoryBuffer::Format format) { |
| 49 switch (internalformat) { |
| 50 case GL_RGB: |
| 51 switch (format) { |
| 52 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 53 return true; |
| 54 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 55 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 56 return false; |
| 57 } |
| 58 NOTREACHED(); |
| 59 return false; |
| 60 case GL_RGBA: |
| 61 switch (format) { |
| 62 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 63 return false; |
| 64 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 65 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 66 return true; |
| 67 } |
| 68 NOTREACHED(); |
| 69 return false; |
| 70 default: |
| 71 NOTREACHED(); |
| 72 return false; |
| 73 } |
| 74 } |
| 75 |
| 76 } // namespace gpu |
OLD | NEW |