Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: ui/gl/gl_image_x11.cc

Issue 288343004: working copy of "zero_copy" Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <linux/types.h>
7 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/gl/gl_image_egl.h"
8 #include "ui/gl/gl_image_glx.h" 10 #include "ui/gl/gl_image_glx.h"
9 #include "ui/gl/gl_image_shm.h" 11 #include "ui/gl/gl_image_shm.h"
10 #include "ui/gl/gl_image_stub.h" 12 #include "ui/gl/gl_image_stub.h"
11 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
12 14
13 namespace gfx { 15 namespace gfx {
14 16
17 #define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
18 ((__u32)(c) << 16) | ((__u32)(d) << 24))
19 #define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4')
20
15 scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) { 21 scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) {
16 TRACE_EVENT0("gpu", "GLImage::CreateGLImage"); 22 TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
17 switch (GetGLImplementation()) { 23 switch (GetGLImplementation()) {
18 case kGLImplementationOSMesaGL: 24 case kGLImplementationOSMesaGL:
19 return NULL; 25 return NULL;
20 case kGLImplementationDesktopGL: { 26 case kGLImplementationDesktopGL: {
21 scoped_refptr<GLImageGLX> image(new GLImageGLX(window)); 27 scoped_refptr<GLImageGLX> image(new GLImageGLX(window));
22 if (!image->Initialize()) 28 if (!image->Initialize())
23 return NULL; 29 return NULL;
24 30
(...skipping 20 matching lines...) Expand all
45 case kGLImplementationEGLGLES2: 51 case kGLImplementationEGLGLES2:
46 switch (buffer.type) { 52 switch (buffer.type) {
47 case SHARED_MEMORY_BUFFER: { 53 case SHARED_MEMORY_BUFFER: {
48 scoped_refptr<GLImageShm> image( 54 scoped_refptr<GLImageShm> image(
49 new GLImageShm(size, internalformat)); 55 new GLImageShm(size, internalformat));
50 if (!image->Initialize(buffer)) 56 if (!image->Initialize(buffer))
51 return NULL; 57 return NULL;
52 58
53 return image; 59 return image;
54 } 60 }
61
62 case DMA_BUFFER: {
63 // TODO(kalyan): We should get stride as part of buffer handle ?
64 EGLint attr[] = {
65 EGL_WIDTH, size.width(),
66 EGL_HEIGHT, size.height(),
67 EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
68 EGL_DMA_BUF_PLANE0_FD_EXT, buffer.handle.fd,
69 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
70 EGL_DMA_BUF_PLANE0_PITCH_EXT, buffer.stride,
71 EGL_NONE
72 };
73
74 scoped_refptr<GLImageEGL> image(
75 new GLImageEGL(size));
76 if (!image->Initialize(EGL_LINUX_DMA_BUF_EXT,
77 (EGLClientBuffer)NULL,
78 attr))
79 return NULL;
80
81 return image;
82 }
55 default: 83 default:
56 NOTREACHED(); 84 NOTREACHED();
57 return NULL; 85 return NULL;
58 } 86 }
59 case kGLImplementationMockGL: 87 case kGLImplementationMockGL:
60 return new GLImageStub; 88 return new GLImageStub;
61 default: 89 default:
62 NOTREACHED(); 90 NOTREACHED();
63 return NULL; 91 return NULL;
64 } 92 }
65 } 93 }
66 94
67 } // namespace gfx 95 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698