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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 years, 2 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
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 "ui/gl/gl_image.h" 8 #include "ui/gl/gl_image.h"
9 #include "ui/gl/gl_image_shared_memory.h" 9 #include "ui/gl/gl_image_shared_memory.h"
10 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" 10 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h"
11 11
12 namespace content { 12 namespace content {
13 namespace { 13 namespace {
14 14
15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { 15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory {
16 public: 16 public:
17 // Overridden from GpuMemoryBufferFactory: 17 // Overridden from GpuMemoryBufferFactory:
18 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( 18 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
19 const gfx::GpuMemoryBufferHandle& handle, 19 const gfx::GpuMemoryBufferHandle& handle,
20 const gfx::Size& size, 20 const gfx::Size& size,
21 unsigned internalformat, 21 gfx::GpuMemoryBuffer::Format format,
22 unsigned usage) override { 22 gfx::GpuMemoryBuffer::Usage usage) override {
23 switch (handle.type) { 23 switch (handle.type) {
24 case gfx::OZONE_NATIVE_BUFFER: 24 case gfx::OZONE_NATIVE_BUFFER:
25 return ozone_buffer_factory_.CreateGpuMemoryBuffer( 25 return ozone_buffer_factory_.CreateGpuMemoryBuffer(
26 handle.global_id, size, internalformat, usage) 26 handle.global_id, size, format, usage)
27 ? handle 27 ? handle
28 : gfx::GpuMemoryBufferHandle(); 28 : gfx::GpuMemoryBufferHandle();
29 default: 29 default:
30 NOTREACHED(); 30 NOTREACHED();
31 return gfx::GpuMemoryBufferHandle(); 31 return gfx::GpuMemoryBufferHandle();
32 } 32 }
33 } 33 }
34 virtual void DestroyGpuMemoryBuffer( 34 virtual void DestroyGpuMemoryBuffer(
35 const gfx::GpuMemoryBufferHandle& handle) override { 35 const gfx::GpuMemoryBufferHandle& handle) override {
36 switch (handle.type) { 36 switch (handle.type) {
37 case gfx::OZONE_NATIVE_BUFFER: 37 case gfx::OZONE_NATIVE_BUFFER:
38 ozone_buffer_factory_.DestroyGpuMemoryBuffer(handle.global_id); 38 ozone_buffer_factory_.DestroyGpuMemoryBuffer(handle.global_id);
39 break; 39 break;
40 default: 40 default:
41 NOTREACHED(); 41 NOTREACHED();
42 break; 42 break;
43 } 43 }
44 } 44 }
45 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( 45 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
46 const gfx::GpuMemoryBufferHandle& handle, 46 const gfx::GpuMemoryBufferHandle& handle,
47 const gfx::Size& size, 47 const gfx::Size& size,
48 gfx::GpuMemoryBuffer::Format format,
48 unsigned internalformat, 49 unsigned internalformat,
49 int client_id) override { 50 int client_id) override {
50 switch (handle.type) { 51 switch (handle.type) {
51 case gfx::SHARED_MEMORY_BUFFER: { 52 case gfx::SHARED_MEMORY_BUFFER: {
52 scoped_refptr<gfx::GLImageSharedMemory> image( 53 scoped_refptr<gfx::GLImageSharedMemory> image(
53 new gfx::GLImageSharedMemory(size, internalformat)); 54 new gfx::GLImageSharedMemory(size, internalformat));
54 if (!image->Initialize(handle)) 55 if (!image->Initialize(handle, format))
55 return NULL; 56 return NULL;
56 57
57 return image; 58 return image;
58 } 59 }
59 case gfx::OZONE_NATIVE_BUFFER: 60 case gfx::OZONE_NATIVE_BUFFER:
60 // Verify that client is the owner of the buffer we're about to use. 61 // Verify that client is the owner of the buffer we're about to use.
61 if (handle.global_id.secondary_id != client_id) 62 if (handle.global_id.secondary_id != client_id)
62 return scoped_refptr<gfx::GLImage>(); 63 return scoped_refptr<gfx::GLImage>();
63 64
64 return ozone_buffer_factory_.CreateImageForGpuMemoryBuffer( 65 return ozone_buffer_factory_.CreateImageForGpuMemoryBuffer(
(...skipping 10 matching lines...) Expand all
75 76
76 } // namespace 77 } // namespace
77 78
78 // static 79 // static
79 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { 80 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
80 return make_scoped_ptr<GpuMemoryBufferFactory>( 81 return make_scoped_ptr<GpuMemoryBufferFactory>(
81 new GpuMemoryBufferFactoryImpl); 82 new GpuMemoryBufferFactoryImpl);
82 } 83 }
83 84
84 } // namespace content 85 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory_mac.cc ('k') | content/common/gpu/gpu_memory_buffer_factory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698