[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 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 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 10 | #include "base/compiler_specific.h" |
| 11 | #include "ppapi/proxy/plugin_resource.h" |
| 12 | #include "ppapi/proxy/ppapi_proxy_export.h" |
| 13 | #include "ppapi/thunk/ppb_graphics_2d_api.h" |
| 14 | |
| 15 | namespace ppapi { |
| 16 | |
| 17 | class TrackedCallback; |
| 18 | |
| 19 | namespace proxy { |
| 20 | |
Nico Weber | 43ddd7a3 | 2017-08-15 19:19:27 | [diff] [blame] | 21 | class PPAPI_PROXY_EXPORT Graphics2DResource : public PluginResource, |
| 22 | public thunk::PPB_Graphics2D_API { |
[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 23 | public: |
| 24 | Graphics2DResource(Connection connection, |
| 25 | PP_Instance instance, |
| 26 | const PP_Size& size, |
| 27 | PP_Bool is_always_opaque); |
| 28 | |
Peter Boström | 3d5b3cb | 2021-09-23 21:35:45 | [diff] [blame] | 29 | Graphics2DResource(const Graphics2DResource&) = delete; |
| 30 | Graphics2DResource& operator=(const Graphics2DResource&) = delete; |
| 31 | |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 32 | ~Graphics2DResource() override; |
[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 33 | |
| 34 | // Resource overrides. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 35 | thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API() override; |
[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 36 | |
| 37 | // PPB_Graphics2D_API overrides. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 38 | PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) override; |
| 39 | void PaintImageData(PP_Resource image_data, |
| 40 | const PP_Point* top_left, |
| 41 | const PP_Rect* src_rect) override; |
| 42 | void Scroll(const PP_Rect* clip_rect, const PP_Point* amount) override; |
| 43 | void ReplaceContents(PP_Resource image_data) override; |
| 44 | PP_Bool SetScale(float scale) override; |
| 45 | float GetScale() override; |
alessandroa | d55efd0 | 2016-04-21 19:35:25 | [diff] [blame] | 46 | PP_Bool SetLayerTransform(float scale, |
| 47 | const PP_Point* origin, |
| 48 | const PP_Point* translate) override; |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 49 | int32_t Flush(scoped_refptr<TrackedCallback> callback) override; |
| 50 | bool ReadImageData(PP_Resource image, const PP_Point* top_left) override; |
[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 51 | |
| 52 | private: |
| 53 | void OnPluginMsgFlushACK(const ResourceMessageReplyParams& params); |
| 54 | |
| 55 | const PP_Size size_; |
| 56 | const PP_Bool is_always_opaque_; |
| 57 | float scale_; |
| 58 | |
| 59 | scoped_refptr<TrackedCallback> current_flush_callback_; |
[email protected] | 08e65c1 | 2012-11-29 18:53:29 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | } // namespace proxy |
| 63 | } // namespace ppapi |
| 64 | |
| 65 | #endif // PPAPI_PROXY_GRAPHICS_2D_RESOURCE_H_ |