OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gl/gl_image.h" | 5 #include "ui/gl/gl_image.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "ui/gl/gl_image_shm.h" | 8 #include "ui/gl/gl_image_shm.h" |
9 #include "ui/gl/gl_image_stub.h" | 9 #include "ui/gl/gl_image_stub.h" |
10 #include "ui/gl/gl_implementation.h" | 10 #include "ui/gl/gl_implementation.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 | 13 |
14 scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) { | 14 scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) { |
15 TRACE_EVENT0("gpu", "GLImage::CreateGLImage"); | 15 TRACE_EVENT0("gpu", "GLImage::CreateGLImage"); |
16 switch (GetGLImplementation()) { | 16 switch (GetGLImplementation()) { |
17 case kGLImplementationOSMesaGL: | 17 case kGLImplementationOSMesaGL: |
18 case kGLImplementationDesktopGL: | 18 case kGLImplementationDesktopGL: |
19 case kGLImplementationEGLGLES2: | 19 case kGLImplementationEGLGLES2: |
20 return NULL; | 20 return NULL; |
21 case kGLImplementationMockGL: | 21 case kGLImplementationMockGL: |
22 return new GLImageStub; | 22 return new GLImageStub; |
23 default: | 23 default: |
24 NOTREACHED(); | 24 NOTREACHED(); |
25 return NULL; | 25 return NULL; |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer( | 29 scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer( |
30 gfx::GpuMemoryBufferHandle buffer, gfx::Size size) { | 30 gfx::GpuMemoryBufferHandle buffer, |
| 31 gfx::Size size, |
| 32 unsigned internalformat) { |
31 TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer"); | 33 TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer"); |
32 switch (GetGLImplementation()) { | 34 switch (GetGLImplementation()) { |
33 case kGLImplementationOSMesaGL: | 35 case kGLImplementationOSMesaGL: |
34 case kGLImplementationDesktopGL: | 36 case kGLImplementationDesktopGL: |
35 case kGLImplementationEGLGLES2: | 37 case kGLImplementationEGLGLES2: |
36 switch (buffer.type) { | 38 switch (buffer.type) { |
37 case SHARED_MEMORY_BUFFER: { | 39 case SHARED_MEMORY_BUFFER: { |
38 scoped_refptr<GLImageShm> image(new GLImageShm(size)); | 40 scoped_refptr<GLImageShm> image( |
| 41 new GLImageShm(size, internalformat)); |
39 if (!image->Initialize(buffer)) | 42 if (!image->Initialize(buffer)) |
40 return NULL; | 43 return NULL; |
41 | 44 |
42 return image; | 45 return image; |
43 } | 46 } |
44 default: | 47 default: |
45 NOTREACHED(); | 48 NOTREACHED(); |
46 return NULL; | 49 return NULL; |
47 } | 50 } |
48 case kGLImplementationMockGL: | 51 case kGLImplementationMockGL: |
49 return new GLImageStub; | 52 return new GLImageStub; |
50 default: | 53 default: |
51 NOTREACHED(); | 54 NOTREACHED(); |
52 return NULL; | 55 return NULL; |
53 } | 56 } |
54 } | 57 } |
55 | 58 |
56 } // namespace gfx | 59 } // namespace gfx |
OLD | NEW |