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_glx.h" | 8 #include "ui/gl/gl_image_glx.h" |
| 9 #include "ui/gl/gl_image_linux_dma_buffer.h" |
9 #include "ui/gl/gl_image_shm.h" | 10 #include "ui/gl/gl_image_shm.h" |
10 #include "ui/gl/gl_image_stub.h" | 11 #include "ui/gl/gl_image_stub.h" |
11 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
12 | 13 |
13 namespace gfx { | 14 namespace gfx { |
14 | 15 |
15 scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) { | 16 scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) { |
16 TRACE_EVENT0("gpu", "GLImage::CreateGLImage"); | 17 TRACE_EVENT0("gpu", "GLImage::CreateGLImage"); |
17 switch (GetGLImplementation()) { | 18 switch (GetGLImplementation()) { |
18 case kGLImplementationOSMesaGL: | 19 case kGLImplementationOSMesaGL: |
(...skipping 14 matching lines...) Expand all Loading... |
33 return NULL; | 34 return NULL; |
34 } | 35 } |
35 } | 36 } |
36 | 37 |
37 scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer( | 38 scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer( |
38 gfx::GpuMemoryBufferHandle buffer, | 39 gfx::GpuMemoryBufferHandle buffer, |
39 gfx::Size size, | 40 gfx::Size size, |
40 unsigned internalformat) { | 41 unsigned internalformat) { |
41 TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer"); | 42 TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer"); |
42 switch (GetGLImplementation()) { | 43 switch (GetGLImplementation()) { |
| 44 case kGLImplementationEGLGLES2: |
| 45 switch (buffer.type) { |
| 46 case INTEL_DRM_BUFFER: { |
| 47 scoped_refptr<GLImageLinuxDMABuffer> image( |
| 48 new GLImageLinuxDMABuffer(size, internalformat)); |
| 49 if (!image->Initialize(buffer)) |
| 50 return NULL; |
| 51 |
| 52 return image; |
| 53 } |
| 54 default: |
| 55 break; |
| 56 } |
| 57 // Fall-through. |
43 case kGLImplementationOSMesaGL: | 58 case kGLImplementationOSMesaGL: |
44 case kGLImplementationDesktopGL: | 59 case kGLImplementationDesktopGL: |
45 case kGLImplementationEGLGLES2: | |
46 switch (buffer.type) { | 60 switch (buffer.type) { |
47 case SHARED_MEMORY_BUFFER: { | 61 case SHARED_MEMORY_BUFFER: { |
48 scoped_refptr<GLImageShm> image( | 62 scoped_refptr<GLImageShm> image( |
49 new GLImageShm(size, internalformat)); | 63 new GLImageShm(size, internalformat)); |
50 if (!image->Initialize(buffer)) | 64 if (!image->Initialize(buffer)) |
51 return NULL; | 65 return NULL; |
52 | 66 |
53 return image; | 67 return image; |
54 } | 68 } |
55 default: | 69 default: |
56 NOTREACHED(); | 70 NOTREACHED(); |
57 return NULL; | 71 return NULL; |
58 } | 72 } |
59 case kGLImplementationMockGL: | 73 case kGLImplementationMockGL: |
60 return new GLImageStub; | 74 return new GLImageStub; |
61 default: | 75 default: |
62 NOTREACHED(); | 76 NOTREACHED(); |
63 return NULL; | 77 return NULL; |
64 } | 78 } |
65 } | 79 } |
66 | 80 |
67 } // namespace gfx | 81 } // namespace gfx |
OLD | NEW |