Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: ppapi/proxy/compositor_resource.h

Issue 298023004: [PPAPI] Compositor API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_def_new
Patch Set: Update Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <vector>
10 9
10 #include "base/callback.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ppapi/c/ppb_compositor_layer.h"
11 #include "ppapi/proxy/plugin_resource.h" 14 #include "ppapi/proxy/plugin_resource.h"
12 #include "ppapi/proxy/ppapi_proxy_export.h" 15 #include "ppapi/proxy/ppapi_proxy_export.h"
16 #include "ppapi/shared_impl/compositor_layer.h"
17 #include "ppapi/shared_impl/scoped_pp_resource.h"
13 #include "ppapi/thunk/ppb_compositor_api.h" 18 #include "ppapi/thunk/ppb_compositor_api.h"
14 19
15 namespace ppapi { 20 namespace ppapi {
16 namespace proxy { 21 namespace proxy {
17 22
18 class PPAPI_PROXY_EXPORT CompositorResource 23 class PPAPI_PROXY_EXPORT CompositorResource
19 : public PluginResource, 24 : public PluginResource,
20 public thunk::PPB_Compositor_API { 25 public thunk::PPB_Compositor_API {
21 public: 26 public:
27 // Release callback for texture or image.
28 typedef base::Callback<void(uint32_t, bool)> ReleaseCallback;
29
30 class Layer : public base::SupportsWeakPtr<Layer> {
raymes 2014/06/02 03:51:08 How come you don't just put this stuff in Composit
Peng 2014/06/02 19:01:55 I think use a WeakPtr is more convenient for the i
raymes 2014/06/03 00:43:22 Could you explain a bit more about the difficulty?
Peng 2014/06/03 18:32:23 The problem for me is how PP_Resource ref is maint
31 public:
32 Layer(CompositorResource* compositor);
33 ~Layer();
34
35 // Methods for CompositorLayerResource:
36 int32_t SetColor(uint8_t red,
37 uint8_t green,
38 uint8_t blue,
39 uint8_t alpha,
40 const struct PP_Size* size);
41 int32_t SetTexture(PP_Resource context,
42 uint32_t texture,
43 const struct PP_Size* size,
44 const scoped_refptr<TrackedCallback>& release_callback);
45 int32_t SetImage(PP_Resource image_data,
46 const struct PP_Size* size,
47 const scoped_refptr<TrackedCallback>& release_callback);
48 int32_t SetClipRect(const struct PP_Rect* rect);
49 int32_t SetTransform(const float matrix[16]);
50 int32_t SetOpacity(uint8_t opacity);
51 int32_t SetBlendMode(PP_BlendMode mode);
52 int32_t SetSourceRect(const struct PP_FloatRect* rect);
53 int32_t SetPremultipliedAlpha(PP_Bool premult);
54
55 const CompositorLayer& data() const { return data_; }
56 const ReleaseCallback& release_callback() const {
57 return release_callback_;
58 }
59 void ResetReleaseCallback() { release_callback_.Reset(); }
60
61 private:
62 bool SetType(CompositorLayer::Type type);
63
64 void OnTextureReleased(
65 const ScopedPPResource& context,
66 uint32_t texture,
67 const scoped_refptr<TrackedCallback>& release_callback,
68 uint32_t sync_point,
69 bool is_lost);
70
71 void OnImageReleased(
72 const ScopedPPResource& image,
73 const scoped_refptr<TrackedCallback>& release_callback,
74 uint32_t sync_point,
75 bool is_lost);
76
77 CompositorResource* compositor_;
78
79 // Release callback for texture or image layer.
80 ReleaseCallback release_callback_;
81
82 PP_FloatSize source_size_;
83
84 CompositorLayer data_;
85
86 DISALLOW_COPY_AND_ASSIGN(Layer);
87 };
88
22 CompositorResource(Connection connection, 89 CompositorResource(Connection connection,
23 PP_Instance instance); 90 PP_Instance instance);
24 91
25 private: 92 private:
26 virtual ~CompositorResource(); 93 virtual ~CompositorResource();
27 94
95 bool IsInProgress() const {
96 return TrackedCallback::IsPending(commit_callback_);
97 }
98
99 int32_t GenerateResourceId() {
100 return ++last_resource_id_;
101 }
102
28 // Resource overrides: 103 // Resource overrides:
29 virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() OVERRIDE; 104 virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() OVERRIDE;
30 105
106 // PluginResource overrides:
107 virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
108 const IPC::Message& msg) OVERRIDE;
109
31 // thunk::PPB_Compositor_API overrides: 110 // thunk::PPB_Compositor_API overrides:
32 virtual PP_Resource AddLayer() OVERRIDE; 111 virtual PP_Resource AddLayer() OVERRIDE;
33 virtual int32_t CommitLayers( 112 virtual int32_t CommitLayers(
34 const scoped_refptr<ppapi::TrackedCallback>& callback) OVERRIDE; 113 const scoped_refptr<TrackedCallback>& callback) OVERRIDE;
35 virtual int32_t ResetLayers() OVERRIDE; 114 virtual int32_t ResetLayers() OVERRIDE;
36 115
116 // IPC msg handlers:
117 void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params);
118 void OnPluginMsgReleaseResource(
119 const ResourceMessageReplyParams& params,
120 int32_t id,
121 uint32_t sync_point,
122 bool is_lost);
123
124 scoped_refptr<TrackedCallback> commit_callback_;
125
126 bool layer_changed_;
127
128 ScopedVector<Layer> layers_;
129
130 int32_t last_resource_id_;
131 typedef std::map<int32_t, ReleaseCallback > ReleaseCallbackMap;
132 ReleaseCallbackMap release_callback_map_;
133
37 DISALLOW_COPY_AND_ASSIGN(CompositorResource); 134 DISALLOW_COPY_AND_ASSIGN(CompositorResource);
38 }; 135 };
39 136
40 } // namespace proxy 137 } // namespace proxy
41 } // namespace ppapi 138 } // namespace ppapi
42 139
43 #endif // PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ 140 #endif // PPAPI_PROXY_COMPOSITOR_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698