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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl.h

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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/gfx/gpu_memory_buffer.h" 10 #include "ui/gfx/gpu_memory_buffer.h"
11 #include "ui/gfx/size.h" 11 #include "ui/gfx/size.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 // Provides common implementation of a GPU memory buffer. 15 // Provides common implementation of a GPU memory buffer.
16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 16 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
17 public: 17 public:
18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)> 18 typedef base::Callback<void(scoped_ptr<GpuMemoryBufferImpl> buffer)>
19 CreationCallback; 19 CreationCallback;
20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> 20 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>
21 AllocationCallback; 21 AllocationCallback;
22 typedef base::Closure DestructionCallback; 22 typedef base::Closure DestructionCallback;
23 23
24 virtual ~GpuMemoryBufferImpl(); 24 virtual ~GpuMemoryBufferImpl();
25 25
26 // Creates a GPU memory buffer instance with |size| and |internalformat| for 26 // Creates a GPU memory buffer instance with |size| and |format| for |usage|
27 // |usage| by the current process and |client_id|. 27 // by the current process and |client_id|.
28 static void Create(const gfx::Size& size, 28 static void Create(const gfx::Size& size,
29 unsigned internalformat, 29 Format format,
30 unsigned usage, 30 Usage usage,
31 int client_id, 31 int client_id,
32 const CreationCallback& callback); 32 const CreationCallback& callback);
33 33
34 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage| 34 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage|
35 // by |child_process| and |child_client_id|. The |handle| returned can be 35 // by |child_process| and |child_client_id|. The |handle| returned can be
36 // used by the |child_process| to create an instance of this class. 36 // used by the |child_process| to create an instance of this class.
37 static void AllocateForChildProcess(const gfx::Size& size, 37 static void AllocateForChildProcess(const gfx::Size& size,
38 unsigned internalformat, 38 Format format,
39 unsigned usage, 39 Usage usage,
40 base::ProcessHandle child_process, 40 base::ProcessHandle child_process,
41 int child_client_id, 41 int child_client_id,
42 const AllocationCallback& callback); 42 const AllocationCallback& callback);
43 43
44 // Notify that GPU memory buffer has been deleted by |child_process|. 44 // Notify that GPU memory buffer has been deleted by |child_process|.
45 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type, 45 static void DeletedByChildProcess(gfx::GpuMemoryBufferType type,
46 const gfx::GpuMemoryBufferId& id, 46 const gfx::GpuMemoryBufferId& id,
47 base::ProcessHandle child_process); 47 base::ProcessHandle child_process);
48 48
49 // Creates an instance from the given |handle|. |size| and |internalformat| 49 // Creates an instance from the given |handle|. |size| and |internalformat|
50 // should match what was used to allocate the |handle|. |callback| is 50 // should match what was used to allocate the |handle|. |callback| is
51 // called when instance is deleted, which is not necessarily on the same 51 // called when instance is deleted, which is not necessarily on the same
52 // thread as this function was called on and instance was created on. 52 // thread as this function was called on and instance was created on.
53 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle( 53 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle(
54 const gfx::GpuMemoryBufferHandle& handle, 54 const gfx::GpuMemoryBufferHandle& handle,
55 const gfx::Size& size, 55 const gfx::Size& size,
56 unsigned internalformat, 56 Format format,
57 const DestructionCallback& callback); 57 const DestructionCallback& callback);
58 58
59 // Returns true if |internalformat| is a format recognized by this base class. 59 // Type-checking upcast routine. Returns an NULL on failure.
60 static bool IsFormatValid(unsigned internalformat); 60 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer);
61
62 // Returns true if |usage| is recognized by this base class.
63 static bool IsUsageValid(unsigned usage);
64 61
65 // Returns the number of bytes per pixel that must be used by an 62 // Returns the number of bytes per pixel that must be used by an
66 // implementation when using |internalformat|. 63 // implementation when using |format|.
67 static size_t BytesPerPixel(unsigned internalformat); 64 static size_t BytesPerPixel(Format format);
68 65
69 // Overridden from gfx::GpuMemoryBuffer: 66 // Overridden from gfx::GpuMemoryBuffer:
70 virtual bool IsMapped() const override; 67 virtual bool IsMapped() const override;
68 virtual Format GetFormat() const override;
69 virtual ClientBuffer AsClientBuffer() override;
71 70
72 protected: 71 protected:
73 GpuMemoryBufferImpl(const gfx::Size& size, 72 GpuMemoryBufferImpl(const gfx::Size& size,
74 unsigned internalformat, 73 Format format,
75 const DestructionCallback& callback); 74 const DestructionCallback& callback);
76 75
77 const gfx::Size size_; 76 const gfx::Size size_;
78 const unsigned internalformat_; 77 const Format format_;
79 const DestructionCallback callback_; 78 const DestructionCallback callback_;
80 bool mapped_; 79 bool mapped_;
81 80
82 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); 81 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl);
83 }; 82 };
84 83
85 } // namespace content 84 } // namespace content
86 85
87 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ 86 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_factory_host.h ('k') | content/common/gpu/client/gpu_memory_buffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698