Chromium Code Reviews| Index: ppapi/proxy/compositor_resource.h |
| diff --git a/ppapi/proxy/compositor_resource.h b/ppapi/proxy/compositor_resource.h |
| index adeb7efd9634bc609fc21838f01394b285303d6e..5aec5a53c865ab6433fbe3659cc98d2a348e974c 100644 |
| --- a/ppapi/proxy/compositor_resource.h |
| +++ b/ppapi/proxy/compositor_resource.h |
| @@ -6,10 +6,15 @@ |
| #define PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ |
| #include <map> |
| -#include <vector> |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "ppapi/c/ppb_compositor_layer.h" |
| #include "ppapi/proxy/plugin_resource.h" |
| #include "ppapi/proxy/ppapi_proxy_export.h" |
| +#include "ppapi/shared_impl/compositor_layer.h" |
| +#include "ppapi/shared_impl/scoped_pp_resource.h" |
| #include "ppapi/thunk/ppb_compositor_api.h" |
| namespace ppapi { |
| @@ -19,21 +24,113 @@ class PPAPI_PROXY_EXPORT CompositorResource |
| : public PluginResource, |
| public thunk::PPB_Compositor_API { |
| public: |
| + // Release callback for texture or image. |
| + typedef base::Callback<void(uint32_t, bool)> ReleaseCallback; |
| + |
| + 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
|
| + public: |
| + Layer(CompositorResource* compositor); |
| + ~Layer(); |
| + |
| + // Methods for CompositorLayerResource: |
| + int32_t SetColor(uint8_t red, |
| + uint8_t green, |
| + uint8_t blue, |
| + uint8_t alpha, |
| + const struct PP_Size* size); |
| + int32_t SetTexture(PP_Resource context, |
| + uint32_t texture, |
| + const struct PP_Size* size, |
| + const scoped_refptr<TrackedCallback>& release_callback); |
| + int32_t SetImage(PP_Resource image_data, |
| + const struct PP_Size* size, |
| + const scoped_refptr<TrackedCallback>& release_callback); |
| + int32_t SetClipRect(const struct PP_Rect* rect); |
| + int32_t SetTransform(const float matrix[16]); |
| + int32_t SetOpacity(uint8_t opacity); |
| + int32_t SetBlendMode(PP_BlendMode mode); |
| + int32_t SetSourceRect(const struct PP_FloatRect* rect); |
| + int32_t SetPremultipliedAlpha(PP_Bool premult); |
| + |
| + const CompositorLayer& data() const { return data_; } |
| + const ReleaseCallback& release_callback() const { |
| + return release_callback_; |
| + } |
| + void ResetReleaseCallback() { release_callback_.Reset(); } |
| + |
| + private: |
| + bool SetType(CompositorLayer::Type type); |
| + |
| + void OnTextureReleased( |
| + const ScopedPPResource& context, |
| + uint32_t texture, |
| + const scoped_refptr<TrackedCallback>& release_callback, |
| + uint32_t sync_point, |
| + bool is_lost); |
| + |
| + void OnImageReleased( |
| + const ScopedPPResource& image, |
| + const scoped_refptr<TrackedCallback>& release_callback, |
| + uint32_t sync_point, |
| + bool is_lost); |
| + |
| + CompositorResource* compositor_; |
| + |
| + // Release callback for texture or image layer. |
| + ReleaseCallback release_callback_; |
| + |
| + PP_FloatSize source_size_; |
| + |
| + CompositorLayer data_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Layer); |
| + }; |
| + |
| CompositorResource(Connection connection, |
| PP_Instance instance); |
| private: |
| virtual ~CompositorResource(); |
| + bool IsInProgress() const { |
| + return TrackedCallback::IsPending(commit_callback_); |
| + } |
| + |
| + int32_t GenerateResourceId() { |
| + return ++last_resource_id_; |
| + } |
| + |
| // Resource overrides: |
| virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() OVERRIDE; |
| + // PluginResource overrides: |
| + virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
| + const IPC::Message& msg) OVERRIDE; |
| + |
| // thunk::PPB_Compositor_API overrides: |
| virtual PP_Resource AddLayer() OVERRIDE; |
| virtual int32_t CommitLayers( |
| - const scoped_refptr<ppapi::TrackedCallback>& callback) OVERRIDE; |
| + const scoped_refptr<TrackedCallback>& callback) OVERRIDE; |
| virtual int32_t ResetLayers() OVERRIDE; |
| + // IPC msg handlers: |
| + void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params); |
| + void OnPluginMsgReleaseResource( |
| + const ResourceMessageReplyParams& params, |
| + int32_t id, |
| + uint32_t sync_point, |
| + bool is_lost); |
| + |
| + scoped_refptr<TrackedCallback> commit_callback_; |
| + |
| + bool layer_changed_; |
| + |
| + ScopedVector<Layer> layers_; |
| + |
| + int32_t last_resource_id_; |
| + typedef std::map<int32_t, ReleaseCallback > ReleaseCallbackMap; |
| + ReleaseCallbackMap release_callback_map_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(CompositorResource); |
| }; |