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

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

Issue 659883003: gpu: Move image creation part of GpuMemoryBufferFactory interface to gpu namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-gpu-memory-buffer-manager-to-gpu
Patch Set: rebase 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
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_io_surface.h" 8 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h"
9 #include "gpu/command_buffer/service/image_factory.h"
9 #include "ui/gl/gl_image.h" 10 #include "ui/gl/gl_image.h"
10 #include "ui/gl/gl_image_shared_memory.h" 11 #include "ui/gl/gl_image_shared_memory.h"
11 12
12 namespace content { 13 namespace content {
13 namespace { 14 namespace {
14 15
15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { 16 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory,
17 public gpu::ImageFactory {
16 public: 18 public:
17 // Overridden from GpuMemoryBufferFactory: 19 // Overridden from GpuMemoryBufferFactory:
18 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( 20 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
19 const gfx::GpuMemoryBufferHandle& handle, 21 const gfx::GpuMemoryBufferHandle& handle,
20 const gfx::Size& size, 22 const gfx::Size& size,
21 gfx::GpuMemoryBuffer::Format format, 23 gfx::GpuMemoryBuffer::Format format,
22 gfx::GpuMemoryBuffer::Usage usage) override { 24 gfx::GpuMemoryBuffer::Usage usage) override {
23 switch (handle.type) { 25 switch (handle.type) {
24 case gfx::IO_SURFACE_BUFFER: 26 case gfx::IO_SURFACE_BUFFER:
25 return io_surface_factory_.CreateGpuMemoryBuffer( 27 return io_surface_factory_.CreateGpuMemoryBuffer(
26 handle.global_id, size, format); 28 handle.global_id, size, format);
27 default: 29 default:
28 NOTREACHED(); 30 NOTREACHED();
29 return gfx::GpuMemoryBufferHandle(); 31 return gfx::GpuMemoryBufferHandle();
30 } 32 }
31 } 33 }
32 void DestroyGpuMemoryBuffer( 34 void DestroyGpuMemoryBuffer(
33 const gfx::GpuMemoryBufferHandle& handle) override { 35 const gfx::GpuMemoryBufferHandle& handle) override {
34 switch (handle.type) { 36 switch (handle.type) {
35 case gfx::IO_SURFACE_BUFFER: 37 case gfx::IO_SURFACE_BUFFER:
36 io_surface_factory_.DestroyGpuMemoryBuffer(handle.global_id); 38 io_surface_factory_.DestroyGpuMemoryBuffer(handle.global_id);
37 break; 39 break;
38 default: 40 default:
39 NOTREACHED(); 41 NOTREACHED();
40 break; 42 break;
41 } 43 }
42 } 44 }
45 gpu::ImageFactory* AsImageFactory() override { return this; }
46
47 // Overridden from gpu::ImageFactory:
43 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( 48 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
44 const gfx::GpuMemoryBufferHandle& handle, 49 const gfx::GpuMemoryBufferHandle& handle,
45 const gfx::Size& size, 50 const gfx::Size& size,
46 gfx::GpuMemoryBuffer::Format format, 51 gfx::GpuMemoryBuffer::Format format,
47 unsigned internalformat, 52 unsigned internalformat,
48 int client_id) override { 53 int client_id) override {
49 switch (handle.type) { 54 switch (handle.type) {
50 case gfx::SHARED_MEMORY_BUFFER: { 55 case gfx::SHARED_MEMORY_BUFFER: {
51 scoped_refptr<gfx::GLImageSharedMemory> image( 56 scoped_refptr<gfx::GLImageSharedMemory> image(
52 new gfx::GLImageSharedMemory(size, internalformat)); 57 new gfx::GLImageSharedMemory(size, internalformat));
(...skipping 22 matching lines...) Expand all
75 80
76 } // namespace 81 } // namespace
77 82
78 // static 83 // static
79 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { 84 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() {
80 return make_scoped_ptr<GpuMemoryBufferFactory>( 85 return make_scoped_ptr<GpuMemoryBufferFactory>(
81 new GpuMemoryBufferFactoryImpl); 86 new GpuMemoryBufferFactoryImpl);
82 } 87 }
83 88
84 } // namespace content 89 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory_android.cc ('k') | content/common/gpu/gpu_memory_buffer_factory_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698