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

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_android.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 "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" 8 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h"
9 #include "ui/gl/gl_image.h" 9 #include "ui/gl/gl_image.h"
10 #include "ui/gl/gl_image_shared_memory.h" 10 #include "ui/gl/gl_image_shared_memory.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::SURFACE_TEXTURE_BUFFER: 24 case gfx::SURFACE_TEXTURE_BUFFER:
25 return surface_texture_factory_.CreateGpuMemoryBuffer( 25 return surface_texture_factory_.CreateGpuMemoryBuffer(
26 handle.global_id, size, internalformat); 26 handle.global_id, size, format);
27 default: 27 default:
28 NOTREACHED(); 28 NOTREACHED();
29 return gfx::GpuMemoryBufferHandle(); 29 return gfx::GpuMemoryBufferHandle();
30 } 30 }
31 } 31 }
32 virtual void DestroyGpuMemoryBuffer( 32 virtual void DestroyGpuMemoryBuffer(
33 const gfx::GpuMemoryBufferHandle& handle) override { 33 const gfx::GpuMemoryBufferHandle& handle) override {
34 switch (handle.type) { 34 switch (handle.type) {
35 case gfx::SURFACE_TEXTURE_BUFFER: 35 case gfx::SURFACE_TEXTURE_BUFFER:
36 surface_texture_factory_.DestroyGpuMemoryBuffer(handle.global_id); 36 surface_texture_factory_.DestroyGpuMemoryBuffer(handle.global_id);
37 break; 37 break;
38 default: 38 default:
39 NOTREACHED(); 39 NOTREACHED();
40 break; 40 break;
41 } 41 }
42 } 42 }
43 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( 43 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
44 const gfx::GpuMemoryBufferHandle& handle, 44 const gfx::GpuMemoryBufferHandle& handle,
45 const gfx::Size& size, 45 const gfx::Size& size,
46 gfx::GpuMemoryBuffer::Format format,
46 unsigned internalformat, 47 unsigned internalformat,
47 int client_id) override { 48 int client_id) override {
48 switch (handle.type) { 49 switch (handle.type) {
49 case gfx::SHARED_MEMORY_BUFFER: { 50 case gfx::SHARED_MEMORY_BUFFER: {
50 scoped_refptr<gfx::GLImageSharedMemory> image( 51 scoped_refptr<gfx::GLImageSharedMemory> image(
51 new gfx::GLImageSharedMemory(size, internalformat)); 52 new gfx::GLImageSharedMemory(size, internalformat));
52 if (!image->Initialize(handle)) 53 if (!image->Initialize(handle, format))
53 return NULL; 54 return NULL;
54 55
55 return image; 56 return image;
56 } 57 }
57 case gfx::SURFACE_TEXTURE_BUFFER: { 58 case gfx::SURFACE_TEXTURE_BUFFER: {
58 // Verify that client is the owner of the buffer we're about to use. 59 // Verify that client is the owner of the buffer we're about to use.
59 if (handle.global_id.secondary_id != client_id) 60 if (handle.global_id.secondary_id != client_id)
60 return scoped_refptr<gfx::GLImage>(); 61 return scoped_refptr<gfx::GLImage>();
61 62
62 return surface_texture_factory_.CreateImageForGpuMemoryBuffer( 63 return surface_texture_factory_.CreateImageForGpuMemoryBuffer(
(...skipping 11 matching lines...) Expand all
74 75
75 } // namespace 76 } // namespace
76 77
77 // static 78 // static
78 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { 79 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
79 return make_scoped_ptr<GpuMemoryBufferFactory>( 80 return make_scoped_ptr<GpuMemoryBufferFactory>(
80 new GpuMemoryBufferFactoryImpl); 81 new GpuMemoryBufferFactoryImpl);
81 } 82 }
82 83
83 } // namespace content 84 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory.h ('k') | content/common/gpu/gpu_memory_buffer_factory_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698