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" |
| 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 void SetScale(float scale) OVERRIDE { graphics_2d_->scale_ = scale; } |
| 56 float GetScale() const OVERRIDE { return graphics_2d_->scale_; } |
| 57 |
| 58 bool IsAlwaysOpaque() const OVERRIDE { |
| 59 return graphics_2d_->is_always_opaque_; |
| 60 } |
| 61 |
| 62 webkit::ppapi::PPB_ImageData_Impl* ImageData() OVERRIDE { |
| 63 return graphics_2d_->image_data_.get(); |
| 64 } |
| 65 |
| 66 bool IsGraphics2DHost() const OVERRIDE { return true; } |
| 67 |
| 68 private: |
| 69 PepperGraphics2DHost(RendererPpapiHost* host, |
| 70 PP_Instance instance, |
| 71 PP_Resource resource); |
| 72 |
| 73 int32_t OnHostMsgPaintImageData(ppapi::host::HostMessageContext* context, |
| 74 const ppapi::HostResource& image_data, |
| 75 const PP_Point& top_left, |
| 76 bool src_rect_specified, |
| 77 const PP_Rect& src_rect); |
| 78 int32_t OnHostMsgScroll(ppapi::host::HostMessageContext* context, |
| 79 bool clip_specified, |
| 80 const PP_Rect& clip, |
| 81 const PP_Point& amount); |
| 82 int32_t OnHostMsgReplaceContents(ppapi::host::HostMessageContext* context, |
| 83 const ppapi::HostResource& image_data); |
| 84 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); |
| 85 int32_t OnHostMsgSetScale(ppapi::host::HostMessageContext* context, |
| 86 float scale); |
| 87 int32_t OnHostMsgReadImageData(ppapi::host::HostMessageContext* context, |
| 88 PP_Resource image, |
| 89 const PP_Point& top_left); |
| 90 |
| 91 static void SendFlushACKToPlugin(void* data, int32_t pp_error); |
| 92 |
| 93 // TODO: merge this delegation into this host class. |
| 94 scoped_refptr<webkit::ppapi::PPB_Graphics2D_Impl> graphics_2d_; |
| 95 |
| 96 ppapi::host::ReplyMessageContext flush_reply_context_; |
| 97 |
| 98 bool is_running_in_process_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(PepperGraphics2DHost); |
| 101 }; |
| 102 |
| 103 } // namespace content |
| 104 |
| 105 #endif // CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ |
OLD | NEW |