12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/proxy/plugin_resource.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/proxy/ppapi_proxy_export.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/thunk/ppb_graphics_2d_api.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace ppapi {
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class TrackedCallback;
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace proxy {
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PPAPI_PROXY_EXPORT Graphics2DResource
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      : public PluginResource,
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        public NON_EXPORTED_BASE(thunk::PPB_Graphics2D_API) {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Graphics2DResource(Connection connection,
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     PP_Instance instance,
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     const PP_Size& size,
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     PP_Bool is_always_opaque);
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~Graphics2DResource();
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Resource overrides.
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API() OVERRIDE;
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // PPB_Graphics2D_API overrides.
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) OVERRIDE;
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void PaintImageData(PP_Resource image_data,
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                              const PP_Point* top_left,
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                              const PP_Rect* src_rect) OVERRIDE;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void Scroll(const PP_Rect* clip_rect,
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                      const PP_Point* amount) OVERRIDE;
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void ReplaceContents(PP_Resource image_data) OVERRIDE;
41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual PP_Bool SetScale(float scale) OVERRIDE;
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual float GetScale() OVERRIDE;
43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ReadImageData(PP_Resource image,
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                             const PP_Point* top_left) OVERRIDE;
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnPluginMsgFlushACK(const ResourceMessageReplyParams& params);
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const PP_Size size_;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const PP_Bool is_always_opaque_;
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float scale_;
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_refptr<TrackedCallback> current_flush_callback_;
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(Graphics2DResource);
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace proxy
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace ppapi
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_
63