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

Side by Side Diff: ppapi/proxy/ppb_graphics_2d_proxy.h

Issue 6905088: New thunk system for Pepper proxy and implementation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 PPAPI_PPB_GRAPHICS_2D_PROXY_H_ 5 #ifndef PPAPI_PPB_GRAPHICS_2D_PROXY_H_
6 #define PPAPI_PPB_GRAPHICS_2D_PROXY_H_ 6 #define PPAPI_PPB_GRAPHICS_2D_PROXY_H_
7 7
8 #include "ppapi/c/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/pp_module.h" 10 #include "ppapi/c/pp_module.h"
11 #include "ppapi/c/pp_module.h" 11 #include "ppapi/c/pp_module.h"
12 #include "ppapi/c/pp_resource.h" 12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/c/pp_size.h" 13 #include "ppapi/c/pp_size.h"
14 #include "ppapi/c/pp_var.h" 14 #include "ppapi/c/pp_var.h"
15 #include "ppapi/cpp/completion_callback.h" 15 #include "ppapi/cpp/completion_callback.h"
16 #include "ppapi/proxy/host_resource.h" 16 #include "ppapi/proxy/host_resource.h"
17 #include "ppapi/proxy/interface_proxy.h" 17 #include "ppapi/proxy/interface_proxy.h"
18 #include "ppapi/proxy/plugin_resource.h"
18 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" 19 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
20 #include "ppapi/thunk/ppb_graphics_2d_api.h"
19 21
20 struct PPB_Graphics2D; 22 struct PPB_Graphics2D;
21 struct PP_Point; 23 struct PP_Point;
22 struct PP_Rect; 24 struct PP_Rect;
23 25
24 namespace pp { 26 namespace pp {
25 namespace proxy { 27 namespace proxy {
26 28
27 class PPB_Graphics2D_Proxy : public InterfaceProxy { 29 class PPB_Graphics2D_Proxy : public InterfaceProxy {
28 public: 30 public:
29 PPB_Graphics2D_Proxy(Dispatcher* dispatcher, const void* target_interface); 31 PPB_Graphics2D_Proxy(Dispatcher* dispatcher, const void* target_interface);
30 virtual ~PPB_Graphics2D_Proxy(); 32 virtual ~PPB_Graphics2D_Proxy();
31 33
32 static const Info* GetInfo(); 34 static const Info* GetInfo();
33 35
34 const PPB_Graphics2D* ppb_graphics_2d_target() const { 36 const PPB_Graphics2D* ppb_graphics_2d_target() const {
35 return static_cast<const PPB_Graphics2D*>(target_interface()); 37 return static_cast<const PPB_Graphics2D*>(target_interface());
36 } 38 }
37 39
38 // InterfaceProxy implementation. 40 // InterfaceProxy implementation.
39 virtual bool OnMessageReceived(const IPC::Message& msg); 41 virtual bool OnMessageReceived(const IPC::Message& msg);
40 42
41 private: 43 private:
42 // Plugin->renderer message handlers. 44 // Plugin->renderer message handlers.
43 void OnMsgCreate(PP_Module module,
44 const PP_Size& size,
45 PP_Bool is_always_opaque,
46 HostResource* result);
47 void OnMsgPaintImageData(const HostResource& graphics_2d, 45 void OnMsgPaintImageData(const HostResource& graphics_2d,
48 const HostResource& image_data, 46 const HostResource& image_data,
49 const PP_Point& top_left, 47 const PP_Point& top_left,
50 bool src_rect_specified, 48 bool src_rect_specified,
51 const PP_Rect& src_rect); 49 const PP_Rect& src_rect);
52 void OnMsgScroll(const HostResource& graphics_2d, 50 void OnMsgScroll(const HostResource& graphics_2d,
53 bool clip_specified, 51 bool clip_specified,
54 const PP_Rect& clip, 52 const PP_Rect& clip,
55 const PP_Point& amount); 53 const PP_Point& amount);
56 void OnMsgReplaceContents(const HostResource& graphics_2d, 54 void OnMsgReplaceContents(const HostResource& graphics_2d,
57 const HostResource& image_data); 55 const HostResource& image_data);
58 void OnMsgFlush(const HostResource& graphics_2d); 56 void OnMsgFlush(const HostResource& graphics_2d);
59 57
60 // Renderer->plugin message handlers. 58 // Renderer->plugin message handlers.
61 void OnMsgFlushACK(const HostResource& graphics_2d, 59 void OnMsgFlushACK(const HostResource& graphics_2d,
62 int32_t pp_error); 60 int32_t pp_error);
63 61
64 // Called in the renderer to send the given flush ACK to the plugin. 62 // Called in the renderer to send the given flush ACK to the plugin.
65 void SendFlushACKToPlugin(int32_t result, 63 void SendFlushACKToPlugin(int32_t result,
66 const HostResource& graphics_2d); 64 const HostResource& graphics_2d);
67 65
68 CompletionCallbackFactory<PPB_Graphics2D_Proxy, 66 CompletionCallbackFactory<PPB_Graphics2D_Proxy,
69 ProxyNonThreadSafeRefCount> callback_factory_; 67 ProxyNonThreadSafeRefCount> callback_factory_;
70 }; 68 };
71 69
70 class Graphics2D : public PluginResource,
71 public ::ppapi::thunk::PPB_Graphics2D_API {
72 public:
73 Graphics2D(const HostResource& host_resource,
74 const PP_Size& size,
75 PP_Bool is_always_opaque)
76 : PluginResource(host_resource),
77 size_(size),
78 is_always_opaque_(is_always_opaque),
79 current_flush_callback_(PP_BlockUntilComplete()) {
80 }
81 virtual ~Graphics2D() {
82 }
83
84 // Resource overrides.
85 virtual Graphics2D* AsGraphics2D() { return this; }
86
87 const PP_Size& size() const { return size_; }
88 PP_Bool is_always_opaque() const { return is_always_opaque_; }
89
90 bool is_flush_pending() const { return !!current_flush_callback_.func; }
91
92 PP_CompletionCallback current_flush_callback() const {
93 return current_flush_callback_;
94 }
95 void set_current_flush_callback(PP_CompletionCallback cb) {
96 current_flush_callback_ = cb;
97 }
98
99 // ResourceObjectBase.
100 virtual PPB_Graphics2D_API* AsGraphics2D_API();
101
102 // PPB_Graphics_2D_API.
103 PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque);
104 void PaintImageData(PP_Resource image_data,
105 const PP_Point* top_left,
106 const PP_Rect* src_rect);
107 void Scroll(const PP_Rect* clip_rect,
108 const PP_Point* amount);
109 void ReplaceContents(PP_Resource image_data);
110 int32_t Flush(PP_CompletionCallback callback);
111
112 private:
113 PP_Size size_;
114 PP_Bool is_always_opaque_;
115
116 // In the plugin, this is the current callback set for Flushes. When the
117 // callback function pointer is non-NULL, we're waiting for a flush ACK.
118 PP_CompletionCallback current_flush_callback_;
119
120 DISALLOW_COPY_AND_ASSIGN(Graphics2D);
121 };
122
123
72 } // namespace proxy 124 } // namespace proxy
73 } // namespace pp 125 } // namespace pp
74 126
75 #endif // PPAPI_PPB_GRAPHICS_2D_PROXY_H_ 127 #endif // PPAPI_PPB_GRAPHICS_2D_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698