OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ |
6 #define PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ | 6 #define PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ppapi/proxy/compositor_layer_resource.h" | 10 #include "ppapi/proxy/compositor_layer_resource.h" |
11 #include "ppapi/proxy/plugin_resource.h" | 11 #include "ppapi/proxy/plugin_resource.h" |
12 #include "ppapi/proxy/ppapi_proxy_export.h" | 12 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 13 #include "ppapi/shared_impl/proxy_lock.h" |
13 #include "ppapi/thunk/ppb_compositor_api.h" | 14 #include "ppapi/thunk/ppb_compositor_api.h" |
14 | 15 |
15 namespace ppapi { | 16 namespace ppapi { |
16 namespace proxy { | 17 namespace proxy { |
17 | 18 |
18 class PPAPI_PROXY_EXPORT CompositorResource | 19 class PPAPI_PROXY_EXPORT CompositorResource |
19 : public PluginResource, | 20 : public PluginResource, |
20 public thunk::PPB_Compositor_API { | 21 public thunk::PPB_Compositor_API { |
21 public: | 22 public: |
22 CompositorResource(Connection connection, | 23 CompositorResource(Connection connection, |
23 PP_Instance instance); | 24 PP_Instance instance); |
24 | 25 |
25 bool IsInProgress() const { | 26 bool IsInProgress() const; |
26 return TrackedCallback::IsPending(commit_callback_); | |
27 } | |
28 | 27 |
29 int32_t GenerateResourceId() const { | 28 int32_t GenerateResourceId() const; |
30 return ++last_resource_id_; | |
31 } | |
32 | 29 |
33 private: | 30 private: |
34 virtual ~CompositorResource(); | 31 virtual ~CompositorResource(); |
35 | 32 |
36 // Resource overrides: | 33 // Resource overrides: |
37 virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() OVERRIDE; | 34 virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() OVERRIDE; |
38 | 35 |
39 // PluginResource overrides: | 36 // PluginResource overrides: |
40 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, | 37 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
41 const IPC::Message& msg) OVERRIDE; | 38 const IPC::Message& msg) OVERRIDE; |
42 | 39 |
43 // thunk::PPB_Compositor_API overrides: | 40 // thunk::PPB_Compositor_API overrides: |
44 virtual PP_Resource AddLayer() OVERRIDE; | 41 virtual PP_Resource AddLayer() OVERRIDE; |
45 virtual int32_t CommitLayers( | 42 virtual int32_t CommitLayers( |
46 const scoped_refptr<TrackedCallback>& callback) OVERRIDE; | 43 const scoped_refptr<TrackedCallback>& callback) OVERRIDE; |
47 virtual int32_t ResetLayers() OVERRIDE; | 44 virtual int32_t ResetLayers() OVERRIDE; |
48 | 45 |
49 // IPC msg handlers: | 46 // IPC msg handlers: |
50 void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params); | 47 void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params); |
51 void OnPluginMsgReleaseResource( | 48 void OnPluginMsgReleaseResource( |
52 const ResourceMessageReplyParams& params, | 49 const ResourceMessageReplyParams& params, |
53 int32_t id, | 50 int32_t id, |
54 uint32_t sync_point, | 51 uint32_t sync_point, |
55 bool is_lost); | 52 bool is_lost); |
56 | 53 |
57 void ResetLayersInternal(); | 54 void ResetLayersInternal(bool is_aborted); |
58 | 55 |
59 // Callback for CommitLayers(). | 56 // Callback for CommitLayers(). |
60 scoped_refptr<TrackedCallback> commit_callback_; | 57 scoped_refptr<TrackedCallback> commit_callback_; |
61 | 58 |
62 // True if layers_ has been reset by ResetLayers(). | 59 // True if layers_ has been reset by ResetLayers(). |
63 bool layer_reset_; | 60 bool layer_reset_; |
64 | 61 |
65 // Layer stack. | 62 // Layer stack. |
66 typedef std::vector<scoped_refptr<CompositorLayerResource> > LayerList; | 63 typedef std::vector<scoped_refptr<CompositorLayerResource> > LayerList; |
67 LayerList layers_; | 64 LayerList layers_; |
68 | 65 |
69 // Release callback map for texture and image. | 66 // Release callback map for texture and image. |
70 typedef CompositorLayerResource::ReleaseCallback ReleaseCallback; | 67 typedef CompositorLayerResource::ReleaseCallback ReleaseCallback; |
71 typedef std::map<int32_t, ReleaseCallback> ReleaseCallbackMap; | 68 typedef std::map<int32_t, ReleaseCallback> ReleaseCallbackMap; |
72 ReleaseCallbackMap release_callback_map_; | 69 ReleaseCallbackMap release_callback_map_; |
73 | 70 |
74 // The last resource id for texture or image. | 71 // The last resource id for texture or image. |
75 mutable int32_t last_resource_id_; | 72 mutable int32_t last_resource_id_; |
76 | 73 |
77 DISALLOW_COPY_AND_ASSIGN(CompositorResource); | 74 DISALLOW_COPY_AND_ASSIGN(CompositorResource); |
78 }; | 75 }; |
79 | 76 |
80 } // namespace proxy | 77 } // namespace proxy |
81 } // namespace ppapi | 78 } // namespace ppapi |
82 | 79 |
83 #endif // PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ | 80 #endif // PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ |
OLD | NEW |