Home | History | Annotate | Download | only in proxy
      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 PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_
      6 #define PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_
      7 
      8 #include "base/compiler_specific.h"
      9 #include "ppapi/proxy/plugin_resource.h"
     10 #include "ppapi/proxy/ppapi_proxy_export.h"
     11 #include "ppapi/thunk/ppb_graphics_2d_api.h"
     12 
     13 namespace ppapi {
     14 
     15 class TrackedCallback;
     16 
     17 namespace proxy {
     18 
     19 class PPAPI_PROXY_EXPORT Graphics2DResource
     20       : public PluginResource,
     21         public NON_EXPORTED_BASE(thunk::PPB_Graphics2D_API) {
     22  public:
     23   Graphics2DResource(Connection connection,
     24                      PP_Instance instance,
     25                      const PP_Size& size,
     26                      PP_Bool is_always_opaque);
     27 
     28   virtual ~Graphics2DResource();
     29 
     30   // Resource overrides.
     31   virtual thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API() OVERRIDE;
     32 
     33   // PPB_Graphics2D_API overrides.
     34   virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) OVERRIDE;
     35   virtual void PaintImageData(PP_Resource image_data,
     36                               const PP_Point* top_left,
     37                               const PP_Rect* src_rect) OVERRIDE;
     38   virtual void Scroll(const PP_Rect* clip_rect,
     39                       const PP_Point* amount) OVERRIDE;
     40   virtual void ReplaceContents(PP_Resource image_data) OVERRIDE;
     41   virtual PP_Bool SetScale(float scale) OVERRIDE;
     42   virtual float GetScale() OVERRIDE;
     43   virtual void SetOffset(const PP_Point* offset) OVERRIDE;
     44   virtual void SetResizeMode(PP_Graphics2D_Dev_ResizeMode resize_mode) OVERRIDE;
     45   virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
     46   virtual bool ReadImageData(PP_Resource image,
     47                              const PP_Point* top_left) OVERRIDE;
     48 
     49  private:
     50   void OnPluginMsgFlushACK(const ResourceMessageReplyParams& params);
     51 
     52   const PP_Size size_;
     53   const PP_Bool is_always_opaque_;
     54   float scale_;
     55 
     56   scoped_refptr<TrackedCallback> current_flush_callback_;
     57 
     58   DISALLOW_COPY_AND_ASSIGN(Graphics2DResource);
     59 };
     60 
     61 }  // namespace proxy
     62 }  // namespace ppapi
     63 
     64 #endif  // PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_
     65