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

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

Issue 263553009: content: Cleanup GpuMemoryBuffer allocation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac build fix Created 6 years, 7 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 | Annotate | Revision Log
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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "ui/gfx/gpu_memory_buffer.h" 9 #include "ui/gfx/gpu_memory_buffer.h"
10 #include "ui/gfx/size.h" 10 #include "ui/gfx/size.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 // Provides common implementation of a GPU memory buffer. 14 // Provides common implementation of a GPU memory buffer.
15 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 15 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
16 public: 16 public:
17 static scoped_ptr<GpuMemoryBufferImpl> Create( 17 virtual ~GpuMemoryBufferImpl();
18
19 // Creates a GPU memory buffer instance with |size| and |internalformat| for
20 // |usage|.
21 static scoped_ptr<GpuMemoryBufferImpl> Create(const gfx::Size& size,
22 unsigned internalformat,
23 unsigned usage);
24
25 // Allocates a GPU memory buffer with |size| and |internalformat| for |usage|
26 // by |child_process|. The |handle| returned can be used by the
27 // |child_process| to create an instance of this class.
28 static void AllocateForChildProcess(const gfx::Size& size,
29 unsigned internalformat,
30 unsigned usage,
31 base::ProcessHandle child_process,
32 gfx::GpuMemoryBufferHandle* handle);
33
34 // Creates an instance from the given |handle|. |size| and |internalformat|
35 // should match what was used to allocate the |handle|.
36 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle(
18 gfx::GpuMemoryBufferHandle handle, 37 gfx::GpuMemoryBufferHandle handle,
19 gfx::Size size, 38 const gfx::Size& size,
20 unsigned internalformat); 39 unsigned internalformat);
21 40
22 virtual ~GpuMemoryBufferImpl(); 41 // Returns true if |internalformat| is a format recognized by this base class.
42 static bool IsFormatValid(unsigned internalformat);
23 43
24 static bool IsFormatValid(unsigned internalformat); 44 // Returns true if |usage| is recognized by this base class.
25 static bool IsUsageValid(unsigned usage); 45 static bool IsUsageValid(unsigned usage);
46
47 // Returns the number of bytes per pixel that must be used by an
48 // implementation when using |internalformat|.
26 static size_t BytesPerPixel(unsigned internalformat); 49 static size_t BytesPerPixel(unsigned internalformat);
27 50
28 // Overridden from gfx::GpuMemoryBuffer: 51 // Overridden from gfx::GpuMemoryBuffer:
29 virtual bool IsMapped() const OVERRIDE; 52 virtual bool IsMapped() const OVERRIDE;
30 virtual uint32 GetStride() const OVERRIDE;
31 53
32 protected: 54 protected:
33 GpuMemoryBufferImpl(gfx::Size size, unsigned internalformat); 55 GpuMemoryBufferImpl(const gfx::Size& size, unsigned internalformat);
34 56
35 const gfx::Size size_; 57 const gfx::Size size_;
36 unsigned internalformat_; 58 const unsigned internalformat_;
37 bool mapped_; 59 bool mapped_;
38 60
39 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); 61 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl);
40 }; 62 };
41 63
42 } // namespace content 64 } // namespace content
43 65
44 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_ 66 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_message_filter.cc ('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