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

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_linux.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
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/gpu/gpu_memory_buffer_factory_x11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "content/common/gpu/gpu_memory_buffer_factory.h" 5 #include "content/common/gpu/gpu_memory_buffer_factory.h"
6 6
7 #include "base/logging.h" 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" 8 #include "gpu/command_buffer/service/image_factory.h"
10 #include "ui/gl/gl_image.h" 9 #include "ui/gl/gl_image.h"
11 #include "ui/gl/gl_image_shared_memory.h" 10 #include "ui/gl/gl_image_shared_memory.h"
12 11
13 namespace content { 12 namespace content {
14 namespace { 13 namespace {
15 14
16 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory, 15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory,
17 public gpu::ImageFactory { 16 public gpu::ImageFactory {
18 public: 17 public:
19 // Overridden from GpuMemoryBufferFactory: 18 // Overridden from GpuMemoryBufferFactory:
20 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( 19 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
21 const gfx::GpuMemoryBufferHandle& handle, 20 const gfx::GpuMemoryBufferHandle& handle,
22 const gfx::Size& size, 21 const gfx::Size& size,
23 gfx::GpuMemoryBuffer::Format format, 22 gfx::GpuMemoryBuffer::Format format,
24 gfx::GpuMemoryBuffer::Usage usage) override { 23 gfx::GpuMemoryBuffer::Usage usage) override {
25 switch (handle.type) { 24 NOTREACHED();
26 case gfx::X11_PIXMAP_BUFFER: 25 return gfx::GpuMemoryBufferHandle();
27 x11_pixmap_factory_.CreateGpuMemoryBuffer(handle.global_id,
28 handle.pixmap);
29 return handle;
30 default:
31 NOTREACHED();
32 return gfx::GpuMemoryBufferHandle();
33 }
34 } 26 }
35 void DestroyGpuMemoryBuffer( 27 void DestroyGpuMemoryBuffer(
36 const gfx::GpuMemoryBufferHandle& handle) override { 28 const gfx::GpuMemoryBufferHandle& handle) override {
37 switch (handle.type) { 29 NOTREACHED();
38 case gfx::X11_PIXMAP_BUFFER:
39 x11_pixmap_factory_.DestroyGpuMemoryBuffer(handle.global_id);
40 break;
41 default:
42 NOTREACHED();
43 break;
44 }
45 } 30 }
46 gpu::ImageFactory* AsImageFactory() override { return this; } 31 gpu::ImageFactory* AsImageFactory() override { return this; }
47 32
48 // Overridden from gpu::GpuMemoryBufferFactory: 33 // Overridden from gpu::ImageFactory:
49 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( 34 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
50 const gfx::GpuMemoryBufferHandle& handle, 35 const gfx::GpuMemoryBufferHandle& handle,
51 const gfx::Size& size, 36 const gfx::Size& size,
52 gfx::GpuMemoryBuffer::Format format, 37 gfx::GpuMemoryBuffer::Format format,
53 unsigned internalformat, 38 unsigned internalformat,
54 int client_id) override { 39 int client_id) override {
55 switch (handle.type) { 40 switch (handle.type) {
56 case gfx::SHARED_MEMORY_BUFFER: { 41 case gfx::SHARED_MEMORY_BUFFER: {
57 scoped_refptr<gfx::GLImageSharedMemory> image( 42 scoped_refptr<gfx::GLImageSharedMemory> image(
58 new gfx::GLImageSharedMemory(size, internalformat)); 43 new gfx::GLImageSharedMemory(size, internalformat));
59 if (!image->Initialize(handle, format)) 44 if (!image->Initialize(handle, format))
60 return NULL; 45 return NULL;
61 46
62 return image; 47 return image;
63 } 48 }
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: 49 default:
72 NOTREACHED(); 50 NOTREACHED();
73 return scoped_refptr<gfx::GLImage>(); 51 return scoped_refptr<gfx::GLImage>();
74 } 52 }
75 } 53 }
76
77 private:
78 GpuMemoryBufferFactoryX11Pixmap x11_pixmap_factory_;
79 }; 54 };
80 55
81 } // namespace 56 } // namespace
82 57
83 // static 58 // static
84 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { 59 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
85 return make_scoped_ptr<GpuMemoryBufferFactory>( 60 return make_scoped_ptr<GpuMemoryBufferFactory>(
86 new GpuMemoryBufferFactoryImpl); 61 new GpuMemoryBufferFactoryImpl);
87 } 62 }
88 63
89 } // namespace content 64 } // namespace content
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/gpu/gpu_memory_buffer_factory_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698