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 const DestructionCallback& callback) | 13 const DestructionCallback& callback) |
14 : size_(size), | 14 : size_(size), |
15 internalformat_(internalformat), | 15 internalformat_(internalformat), |
16 callback_(callback), | 16 callback_(callback), |
17 mapped_(false) { | 17 mapped_(false) { |
18 DCHECK(IsFormatValid(internalformat)); | 18 DCHECK(IsFormatValid(internalformat)); |
19 } | 19 } |
20 | 20 |
21 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { | 21 GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { |
22 callback_.Run(); | 22 callback_.Run(); |
23 } | 23 } |
24 | 24 |
25 // static | 25 // static |
26 bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) { | 26 bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) { |
27 switch (internalformat) { | 27 switch (internalformat) { |
28 case GL_BGRA8_EXT: | 28 case GL_BGRA8_EXT: |
29 case GL_RGBA8_OES: | 29 case GL_RGBA8_OES: |
| 30 case GL_RGB8_OES: |
30 return true; | 31 return true; |
31 default: | 32 default: |
32 return false; | 33 return false; |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 // static | 37 // static |
37 bool GpuMemoryBufferImpl::IsUsageValid(unsigned usage) { | 38 bool GpuMemoryBufferImpl::IsUsageValid(unsigned usage) { |
38 switch (usage) { | 39 switch (usage) { |
39 case GL_IMAGE_MAP_CHROMIUM: | 40 case GL_IMAGE_MAP_CHROMIUM: |
40 case GL_IMAGE_SCANOUT_CHROMIUM: | 41 case GL_IMAGE_SCANOUT_CHROMIUM: |
41 return true; | 42 return true; |
42 default: | 43 default: |
43 return false; | 44 return false; |
44 } | 45 } |
45 } | 46 } |
46 | 47 |
47 // static | 48 // static |
48 size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) { | 49 size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) { |
49 switch (internalformat) { | 50 switch (internalformat) { |
50 case GL_BGRA8_EXT: | 51 case GL_BGRA8_EXT: |
51 case GL_RGBA8_OES: | 52 case GL_RGBA8_OES: |
| 53 case GL_RGB8_OES: |
52 return 4; | 54 return 4; |
53 default: | 55 default: |
54 NOTREACHED(); | 56 NOTREACHED(); |
55 return 0; | 57 return 0; |
56 } | 58 } |
57 } | 59 } |
58 | 60 |
59 bool GpuMemoryBufferImpl::IsMapped() const { return mapped_; } | 61 bool GpuMemoryBufferImpl::IsMapped() const { return mapped_; } |
60 | 62 |
61 } // namespace content | 63 } // namespace content |
OLD | NEW |