OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ | |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "content/common/content_export.h" | |
11 #include "ppapi/c/ppb_graphics_2d.h" | |
12 #include "ppapi/host/resource_host.h" | |
13 #include "ppapi/host/host_message_context.h" | |
14 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
15 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" // TODO: merge to here | |
brettw
2012/10/19 21:44:13
Let's just remove this TODO for now. It's not very
victorhsieh
2012/10/22 02:18:53
Yes, removed.
| |
16 | |
17 namespace webkit { | |
18 namespace ppapi { | |
19 class PPB_ImageData_Impl; | |
20 class PluginInstance; | |
21 } | |
22 } | |
23 | |
24 namespace content { | |
25 | |
26 class RendererPpapiHost; | |
27 | |
28 class CONTENT_EXPORT PepperGraphics2DHost | |
29 : public ppapi::host::ResourceHost, | |
30 public webkit::ppapi::PluginDelegate::PlatformGraphics2D, | |
31 public base::SupportsWeakPtr<PepperGraphics2DHost> { | |
32 public: | |
33 static PepperGraphics2DHost* Create(RendererPpapiHost* host, | |
34 PP_Instance instance, | |
35 PP_Resource resource, | |
36 const PP_Size& size, | |
37 PP_Bool is_always_opaque); | |
38 | |
39 virtual ~PepperGraphics2DHost(); | |
40 | |
41 virtual int32_t OnResourceMessageReceived( | |
42 const IPC::Message& msg, | |
43 ppapi::host::HostMessageContext* context) OVERRIDE; | |
44 | |
45 // PlatformGraphics2D overrides. | |
46 bool ReadImageData(PP_Resource image, const PP_Point* top_left) OVERRIDE; | |
47 bool BindToInstance(webkit::ppapi::PluginInstance* new_instance) OVERRIDE; | |
48 void Paint(WebKit::WebCanvas* canvas, | |
49 const gfx::Rect& plugin_rect, | |
50 const gfx::Rect& paint_rect) OVERRIDE; | |
51 void ViewWillInitiatePaint() OVERRIDE; | |
52 void ViewInitiatedPaint() OVERRIDE; | |
53 void ViewFlushedPaint() OVERRIDE; | |
54 | |
55 float GetScale() const OVERRIDE { return graphics_2d_->scale_; } | |
56 | |
57 bool IsAlwaysOpaque() const OVERRIDE { | |
58 return graphics_2d_->is_always_opaque_; | |
59 } | |
60 | |
61 webkit::ppapi::PPB_ImageData_Impl* ImageData() OVERRIDE { | |
62 return graphics_2d_->image_data_.get(); | |
63 } | |
64 | |
65 bool IsGraphics2DHost() const OVERRIDE { return true; } | |
66 | |
67 private: | |
68 PepperGraphics2DHost(RendererPpapiHost* host, | |
69 PP_Instance instance, | |
70 PP_Resource resource); | |
71 | |
72 int32_t OnHostMsgPaintImageData(ppapi::host::HostMessageContext* context, | |
73 const ppapi::HostResource& image_data, | |
74 const PP_Point& top_left, | |
75 bool src_rect_specified, | |
76 const PP_Rect& src_rect); | |
77 int32_t OnHostMsgScroll(ppapi::host::HostMessageContext* context, | |
78 bool clip_specified, | |
79 const PP_Rect& clip, | |
80 const PP_Point& amount); | |
81 int32_t OnHostMsgReplaceContents(ppapi::host::HostMessageContext* context, | |
82 const ppapi::HostResource& image_data); | |
83 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); | |
84 int32_t OnHostMsgSetScale(ppapi::host::HostMessageContext* context, | |
85 float scale); | |
86 int32_t OnHostMsgReadImageData(ppapi::host::HostMessageContext* context, | |
87 PP_Resource image, | |
88 const PP_Point& top_left); | |
89 | |
90 static void SendFlushACKToPlugin(void* data, int32_t pp_error); | |
91 | |
92 // TODO: merge this delegation into this host class. | |
93 scoped_refptr<webkit::ppapi::PPB_Graphics2D_Impl> graphics_2d_; | |
94 | |
95 ppapi::host::ReplyMessageContext flush_reply_context_; | |
96 | |
97 bool is_running_in_process_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(PepperGraphics2DHost); | |
100 }; | |
101 | |
102 } // namespace content | |
103 | |
104 #endif // CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ | |
OLD | NEW |