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
3 // found in the LICENSE file.
5 #ifndef PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
6 #define PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
8 #include "ppapi/c/ppb_compositor_layer.h"
9 #include "ppapi/proxy/plugin_resource.h"
10 #include "ppapi/proxy/ppapi_proxy_export.h"
11 #include "ppapi/shared_impl/compositor_layer_data.h"
12 #include "ppapi/shared_impl/scoped_pp_resource.h"
13 #include "ppapi/thunk/ppb_compositor_layer_api.h"
18 class CompositorResource
;
20 class PPAPI_PROXY_EXPORT CompositorLayerResource
21 : public PluginResource
,
22 public thunk::PPB_CompositorLayer_API
{
24 // Release callback for texture or image layer.
25 typedef base::Callback
<void(int32_t, uint32_t, bool)> ReleaseCallback
;
27 CompositorLayerResource(Connection connection
,
29 const CompositorResource
* compositor
);
31 const CompositorLayerData
& data() const { return data_
; }
32 const ReleaseCallback
& release_callback() const {
33 return release_callback_
;
35 void ResetReleaseCallback() { release_callback_
.Reset(); }
36 void Invalidate() { compositor_
= NULL
; }
45 ~CompositorLayerResource() override
;
47 // Resource overrides:
48 thunk::PPB_CompositorLayer_API
* AsPPB_CompositorLayer_API() override
;
50 // thunk::PPB_Compositor_API overrides:
51 int32_t SetColor(float red
,
55 const PP_Size
* size
) override
;
56 int32_t SetTexture0_1(
60 const scoped_refptr
<ppapi::TrackedCallback
>& callback
) override
;
66 const scoped_refptr
<TrackedCallback
>& callback
) override
;
68 PP_Resource image_data
,
70 const scoped_refptr
<TrackedCallback
>& callback
) override
;
71 int32_t SetClipRect(const PP_Rect
* rect
) override
;
72 int32_t SetTransform(const float matrix
[16]) override
;
73 int32_t SetOpacity(float opacity
) override
;
74 int32_t SetBlendMode(PP_BlendMode mode
) override
;
75 int32_t SetSourceRect(const PP_FloatRect
* rect
) override
;
76 int32_t SetPremultipliedAlpha(PP_Bool premult
) override
;
78 bool SetType(LayerType type
);
79 int32_t CheckForSetTextureAndImage(
81 const scoped_refptr
<TrackedCallback
>& release_callback
);
83 // The CompositorResource which own the layer. The layer is invalidated if
84 // compositor_ is NULL.
85 const CompositorResource
* compositor_
;
87 // Release callback for uncommitted texture or image. When CommitLayers() on
88 // the compositor_ is called, the callback will be copied into a map in the
89 // compositor_, and it will be reset to NULL.
90 ReleaseCallback release_callback_
;
92 // Size of texture or image. It is used to verify the rect arg of
94 PP_FloatSize source_size_
;
97 CompositorLayerData data_
;
99 DISALLOW_COPY_AND_ASSIGN(CompositorLayerResource
);
105 #endif // PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_