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