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/host_message_context.h" |
| 13 #include "ppapi/host/resource_host.h" |
| 14 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 15 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
| 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 virtual bool ReadImageData(PP_Resource image, |
| 47 const PP_Point* top_left) OVERRIDE; |
| 48 virtual bool BindToInstance( |
| 49 webkit::ppapi::PluginInstance* new_instance) OVERRIDE; |
| 50 virtual void Paint(WebKit::WebCanvas* canvas, |
| 51 const gfx::Rect& plugin_rect, |
| 52 const gfx::Rect& paint_rect) OVERRIDE; |
| 53 virtual void ViewWillInitiatePaint() OVERRIDE; |
| 54 virtual void ViewInitiatedPaint() OVERRIDE; |
| 55 virtual void ViewFlushedPaint() OVERRIDE; |
| 56 virtual void SetScale(float scale) OVERRIDE; |
| 57 virtual float GetScale() const OVERRIDE; |
| 58 virtual bool IsAlwaysOpaque() const OVERRIDE; |
| 59 virtual webkit::ppapi::PPB_ImageData_Impl* ImageData() OVERRIDE; |
| 60 virtual bool IsGraphics2DHost() const OVERRIDE; |
| 61 |
| 62 private: |
| 63 PepperGraphics2DHost(RendererPpapiHost* host, |
| 64 PP_Instance instance, |
| 65 PP_Resource resource); |
| 66 |
| 67 int32_t OnHostMsgPaintImageData(ppapi::host::HostMessageContext* context, |
| 68 const ppapi::HostResource& image_data, |
| 69 const PP_Point& top_left, |
| 70 bool src_rect_specified, |
| 71 const PP_Rect& src_rect); |
| 72 int32_t OnHostMsgScroll(ppapi::host::HostMessageContext* context, |
| 73 bool clip_specified, |
| 74 const PP_Rect& clip, |
| 75 const PP_Point& amount); |
| 76 int32_t OnHostMsgReplaceContents(ppapi::host::HostMessageContext* context, |
| 77 const ppapi::HostResource& image_data); |
| 78 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); |
| 79 int32_t OnHostMsgSetScale(ppapi::host::HostMessageContext* context, |
| 80 float scale); |
| 81 int32_t OnHostMsgReadImageData(ppapi::host::HostMessageContext* context, |
| 82 PP_Resource image, |
| 83 const PP_Point& top_left); |
| 84 |
| 85 static void SendFlushACKToPlugin(void* data, int32_t pp_error); |
| 86 |
| 87 // TODO: merge this delegation into this host class. |
| 88 scoped_refptr<webkit::ppapi::PPB_Graphics2D_Impl> graphics_2d_; |
| 89 |
| 90 ppapi::host::ReplyMessageContext flush_reply_context_; |
| 91 |
| 92 bool is_running_in_process_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(PepperGraphics2DHost); |
| 95 }; |
| 96 |
| 97 } // namespace content |
| 98 |
| 99 #endif // CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ |
OLD | NEW |