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
3 // found in the LICENSE file.
5 #include "ui/gl/gl_image.h"
7 #include "base/debug/trace_event.h"
8 #include "ui/gl/gl_image_glx.h"
9 #include "ui/gl/gl_image_shm.h"
10 #include "ui/gl/gl_image_stub.h"
11 #include "ui/gl/gl_implementation.h"
15 scoped_refptr
<GLImage
> GLImage::CreateGLImage(gfx::PluginWindowHandle window
) {
16 TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
17 switch (GetGLImplementation()) {
18 case kGLImplementationOSMesaGL
:
20 case kGLImplementationDesktopGL
: {
21 scoped_refptr
<GLImageGLX
> image(new GLImageGLX(window
));
22 if (!image
->Initialize())
27 case kGLImplementationEGLGLES2
:
29 case kGLImplementationMockGL
:
30 return new GLImageStub
;
37 scoped_refptr
<GLImage
> GLImage::CreateGLImageForGpuMemoryBuffer(
38 gfx::GpuMemoryBufferHandle buffer
,
40 unsigned internalformat
) {
41 TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer");
42 switch (GetGLImplementation()) {
43 case kGLImplementationOSMesaGL
:
44 case kGLImplementationDesktopGL
:
45 case kGLImplementationEGLGLES2
:
46 switch (buffer
.type
) {
47 case SHARED_MEMORY_BUFFER
: {
48 scoped_refptr
<GLImageShm
> image(
49 new GLImageShm(size
, internalformat
));
50 if (!image
->Initialize(buffer
))
59 case kGLImplementationMockGL
:
60 return new GLImageStub
;