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

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_x11.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: crown of aragorn 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 "content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h"
8 #include "ui/gl/gl_image.h"
9 #include "ui/gl/gl_image_shared_memory.h"
10
11 namespace content {
12 namespace {
13
14 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory {
15 public:
16 // Overridden from GpuMemoryBufferFactory:
17 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
18 const gfx::GpuMemoryBufferHandle& handle,
19 const gfx::Size& size,
20 unsigned internalformat,
21 unsigned usage) OVERRIDE {
22 switch (handle.type) {
23 case gfx::X11_PIXMAP_BUFFER:
24 x11_pixmap_factory_.CreateGpuMemoryBuffer(handle.global_id,
25 handle.pixmap);
26 return handle;
27 default:
28 NOTREACHED();
29 return gfx::GpuMemoryBufferHandle();
30 }
31 }
32 virtual void DestroyGpuMemoryBuffer(
33 const gfx::GpuMemoryBufferHandle& handle) OVERRIDE {
34 switch (handle.type) {
35 case gfx::X11_PIXMAP_BUFFER:
36 x11_pixmap_factory_.DestroyGpuMemoryBuffer(handle.global_id);
37 break;
38 default:
39 NOTREACHED();
40 break;
41 }
42 }
43 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
44 const gfx::GpuMemoryBufferHandle& handle,
45 const gfx::Size& size,
46 unsigned internalformat,
47 int client_id) OVERRIDE {
48 switch (handle.type) {
49 case gfx::SHARED_MEMORY_BUFFER: {
50 scoped_refptr<gfx::GLImageSharedMemory> image(
51 new gfx::GLImageSharedMemory(size, internalformat));
52 if (!image->Initialize(handle))
53 return NULL;
54
55 return image;
56 }
57 case gfx::X11_PIXMAP_BUFFER:
58 // Verify that client is the owner of the buffer we're about to acquire.
59 if (handle.global_id.secondary_id != client_id)
60 return scoped_refptr<gfx::GLImage>();
61
62 return x11_pixmap_factory_.AcquireImageForGpuMemoryBuffer(
63 handle.global_id, size, internalformat);
64 default:
65 NOTREACHED();
66 return scoped_refptr<gfx::GLImage>();
67 }
68 }
69
70 private:
71 GpuMemoryBufferFactoryX11Pixmap x11_pixmap_factory_;
72 };
73
74 } // namespace
75
76 // static
77 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
78 return make_scoped_ptr<GpuMemoryBufferFactory>(
79 new GpuMemoryBufferFactoryImpl);
80 }
81
82 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698