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

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_android.cc

Issue 331723003: gpu: Remove Create/DeleteImage IPC by adding an X11_PIXMAP_BUFFER GpuMemoryBuffer type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wip Created 6 years, 5 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
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "content/common/gpu/gpu_memory_buffer_factory.h"
6
7 #include "ui/gl/gl_image.h"
8 #include "ui/gl/gl_image_android_native_buffer.h"
9 #include "ui/gl/gl_image_shared_memory.h"
10 #include "ui/gl/gl_image_surface_texture.h"
11
12 namespace content {
13 namespace {
14
15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory {
16 public:
17 // Overridden from GpuMemoryBufferFactory:
18 virtual bool CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle,
19 const gfx::Size& size,
20 unsigned internalformat,
21 unsigned usage) OVERRIDE {
22 NOTREACHED();
23 return false;
24 }
25 virtual void DestroyGpuMemoryBuffer(
26 const gfx::GpuMemoryBufferHandle& handle) OVERRIDE {
27 NOTREACHED();
28 }
29 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
30 const gfx::GpuMemoryBufferHandle& handle,
31 const gfx::Size& size,
32 unsigned internalformat,
33 int client_id) OVERRIDE {
34 switch (handle.type) {
35 case gfx::SHARED_MEMORY_BUFFER: {
36 scoped_refptr<gfx::GLImageSharedMemory> image(
37 new gfx::GLImageSharedMemory(size, internalformat));
38 if (!image->Initialize(handle))
39 return NULL;
40
41 return image;
42 }
43 case gfx::ANDROID_NATIVE_BUFFER: {
44 scoped_refptr<gfx::GLImageAndroidNativeBuffer> image(
45 new gfx::GLImageAndroidNativeBuffer(size));
46 if (!image->Initialize(buffer))
47 return NULL;
48
49 return image;
50 }
51 case gfx::SURFACE_TEXTURE_BUFFER: {
52 scoped_refptr<gfx::GLImageSurfaceTexture> image(
53 new gfx::GLImageSurfaceTexture(size));
54 if (!image->Initialize(buffer))
55 return NULL;
56
57 return image;
58 }
59 default:
60 NOTREACHED();
61 return scoped_refptr<gfx::GLImage>();
62 }
63 }
64 };
65
66 } // namespace
67
68 // static
69 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
70 return make_scoped_ptr<GpuMemoryBufferFactory>(
71 new GpuMemoryBufferFactoryImpl);
72 }
73
74 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698