| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/gpu/client/gpu_memory_buffer_impl.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 6 | 6 |
| 7 #include "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 GpuMemoryBufferImpl::GpuMemoryBufferImpl(const gfx::Size& size, | 11 GpuMemoryBufferImpl::GpuMemoryBufferImpl(const gfx::Size& size, |
| 12 unsigned internalformat) | 12 unsigned internalformat) |
| 13 : size_(size), internalformat_(internalformat), mapped_(false) { | 13 : size_(size), internalformat_(internalformat), mapped_(false) { |
| 14 DCHECK(IsFormatValid(internalformat)); | 14 DCHECK(IsFormatValid(internalformat)); |
| 15 } | 15 } |
| 16 | 16 |
| 17 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {} | 17 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {} |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) { | 20 bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) { |
| 21 switch (internalformat) { | 21 switch (internalformat) { |
| 22 case GL_BGRA8_EXT: | 22 case GL_BGRA8_EXT: |
| 23 case GL_RGBA8_OES: | 23 case GL_RGBA8_OES: |
| 24 case GL_RGB8_OES: |
| 24 return true; | 25 return true; |
| 25 default: | 26 default: |
| 26 return false; | 27 return false; |
| 27 } | 28 } |
| 28 } | 29 } |
| 29 | 30 |
| 30 // static | 31 // static |
| 31 bool GpuMemoryBufferImpl::IsUsageValid(unsigned usage) { | 32 bool GpuMemoryBufferImpl::IsUsageValid(unsigned usage) { |
| 32 switch (usage) { | 33 switch (usage) { |
| 33 case GL_IMAGE_MAP_CHROMIUM: | 34 case GL_IMAGE_MAP_CHROMIUM: |
| 34 case GL_IMAGE_SCANOUT_CHROMIUM: | 35 case GL_IMAGE_SCANOUT_CHROMIUM: |
| 35 return true; | 36 return true; |
| 36 default: | 37 default: |
| 37 return false; | 38 return false; |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 // static | 42 // static |
| 42 size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) { | 43 size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) { |
| 43 switch (internalformat) { | 44 switch (internalformat) { |
| 44 case GL_BGRA8_EXT: | 45 case GL_BGRA8_EXT: |
| 45 case GL_RGBA8_OES: | 46 case GL_RGBA8_OES: |
| 47 case GL_RGB8_OES: |
| 46 return 4; | 48 return 4; |
| 47 default: | 49 default: |
| 48 NOTREACHED(); | 50 NOTREACHED(); |
| 49 return 0; | 51 return 0; |
| 50 } | 52 } |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool GpuMemoryBufferImpl::IsMapped() const { return mapped_; } | 55 bool GpuMemoryBufferImpl::IsMapped() const { return mapped_; } |
| 54 | 56 |
| 55 } // namespace content | 57 } // namespace content |
| OLD | NEW |