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

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

Issue 699643002: ui: Remove GLImageGLX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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 "base/logging.h"
8 #include "content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h"
9 #include "gpu/command_buffer/service/image_factory.h"
10 #include "ui/gl/gl_image.h"
11 #include "ui/gl/gl_image_shared_memory.h"
12
13 namespace content {
14 namespace {
15
16 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory,
17 public gpu::ImageFactory {
18 public:
19 // Overridden from GpuMemoryBufferFactory:
20 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
21 const gfx::GpuMemoryBufferHandle& handle,
22 const gfx::Size& size,
23 gfx::GpuMemoryBuffer::Format format,
24 gfx::GpuMemoryBuffer::Usage usage) override {
25 switch (handle.type) {
26 case gfx::X11_PIXMAP_BUFFER:
27 x11_pixmap_factory_.CreateGpuMemoryBuffer(handle.global_id,
28 handle.pixmap);
29 return handle;
30 default:
31 NOTREACHED();
32 return gfx::GpuMemoryBufferHandle();
33 }
34 }
35 void DestroyGpuMemoryBuffer(
36 const gfx::GpuMemoryBufferHandle& handle) override {
37 switch (handle.type) {
38 case gfx::X11_PIXMAP_BUFFER:
39 x11_pixmap_factory_.DestroyGpuMemoryBuffer(handle.global_id);
40 break;
41 default:
42 NOTREACHED();
43 break;
44 }
45 }
46 gpu::ImageFactory* AsImageFactory() override { return this; }
47
48 // Overridden from gpu::GpuMemoryBufferFactory:
49 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
50 const gfx::GpuMemoryBufferHandle& handle,
51 const gfx::Size& size,
52 gfx::GpuMemoryBuffer::Format format,
53 unsigned internalformat,
54 int client_id) override {
55 switch (handle.type) {
56 case gfx::SHARED_MEMORY_BUFFER: {
57 scoped_refptr<gfx::GLImageSharedMemory> image(
58 new gfx::GLImageSharedMemory(size, internalformat));
59 if (!image->Initialize(handle, format))
60 return NULL;
61
62 return image;
63 }
64 case gfx::X11_PIXMAP_BUFFER:
65 // Verify that client is the owner of the buffer we're about to use.
66 if (handle.global_id.secondary_id != client_id)
67 return scoped_refptr<gfx::GLImage>();
68
69 return x11_pixmap_factory_.CreateImageForGpuMemoryBuffer(
70 handle.global_id, size, internalformat);
71 default:
72 NOTREACHED();
73 return scoped_refptr<gfx::GLImage>();
74 }
75 }
76
77 private:
78 GpuMemoryBufferFactoryX11Pixmap x11_pixmap_factory_;
79 };
80
81 } // namespace
82
83 // static
84 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
85 return make_scoped_ptr<GpuMemoryBufferFactory>(
86 new GpuMemoryBufferFactoryImpl);
87 }
88
89 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory_linux.cc ('k') | content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698