OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_PEPPER_BUFFER_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_BUFFER_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "webkit/glue/plugins/pepper_resource.h" | 10 #include "webkit/plugins/ppapi/resource.h" |
11 | 11 |
12 struct PPB_Buffer_Dev; | 12 struct PPB_Buffer_Dev; |
13 | 13 |
14 namespace pepper { | 14 namespace webkit { |
| 15 namespace plugins { |
| 16 namespace ppapi { |
15 | 17 |
16 class PluginInstance; | 18 class PluginInstance; |
17 | 19 |
18 class Buffer : public Resource { | 20 class PPB_Buffer_Impl : public Resource { |
19 public: | 21 public: |
20 explicit Buffer(PluginModule* module); | 22 explicit PPB_Buffer_Impl(PluginModule* module); |
21 virtual ~Buffer(); | 23 virtual ~PPB_Buffer_Impl(); |
22 | 24 |
23 uint32_t size() const { return size_; } | 25 uint32_t size() const { return size_; } |
24 unsigned char* mapped_buffer() { return mem_buffer_.get(); } | 26 unsigned char* mapped_buffer() { return mem_buffer_.get(); } |
25 | 27 |
26 // Returns true if this buffer is mapped. False means that the buffer is | 28 // Returns true if this buffer is mapped. False means that the buffer is |
27 // either invalid or not mapped. | 29 // either invalid or not mapped. |
28 bool is_mapped() const { return !!mem_buffer_.get(); } | 30 bool is_mapped() const { return !!mem_buffer_.get(); } |
29 | 31 |
30 // Returns a pointer to the interface implementing PPB_Buffer that is | 32 // Returns a pointer to the interface implementing PPB_PPB_Buffer_Impl that is |
31 // exposed to the plugin. | 33 // exposed to the plugin. |
32 static const PPB_Buffer_Dev* GetInterface(); | 34 static const PPB_Buffer_Dev* GetInterface(); |
33 | 35 |
34 // Resource overrides. | 36 // Resource overrides. |
35 virtual Buffer* AsBuffer(); | 37 virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl(); |
36 | 38 |
37 // PPB_Buffer implementation. | 39 // PPB_PPB_Buffer_Impl implementation. |
38 bool Init(uint32_t size); | 40 bool Init(uint32_t size); |
39 void Describe(uint32_t* size_in_bytes) const; | 41 void Describe(uint32_t* size_in_bytes) const; |
40 void* Map(); | 42 void* Map(); |
41 void Unmap(); | 43 void Unmap(); |
42 | 44 |
43 // Swaps the guts of this buffer with another. | |
44 void Swap(Buffer* other); | |
45 | |
46 private: | 45 private: |
47 uint32_t size_; | 46 uint32_t size_; |
48 scoped_array<unsigned char> mem_buffer_; | 47 scoped_array<unsigned char> mem_buffer_; |
49 | 48 |
50 DISALLOW_COPY_AND_ASSIGN(Buffer); | 49 DISALLOW_COPY_AND_ASSIGN(PPB_Buffer_Impl); |
51 }; | 50 }; |
52 | 51 |
53 } // namespace pepper | 52 } // namespace ppapi |
| 53 } // namespace plugins |
| 54 } // namespace webkit |
54 | 55 |
55 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_BUFFER_H_ | 56 #endif // WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_ |
56 | 57 |
OLD | NEW |