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

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

Issue 298023004: [PPAPI] Compositor API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_def_new
Patch Set: Use a clip parent for clip_rect 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_LAYER_RESOURCE_H_ 5 #ifndef PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
6 #define PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_ 6 #define PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
7 7
8 #include "ppapi/c/ppb_compositor_layer.h" 8 #include "ppapi/c/ppb_compositor_layer.h"
9 #include "ppapi/proxy/plugin_resource.h" 9 #include "ppapi/proxy/plugin_resource.h"
10 #include "ppapi/proxy/ppapi_proxy_export.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"
11 #include "ppapi/thunk/ppb_compositor_layer_api.h" 13 #include "ppapi/thunk/ppb_compositor_layer_api.h"
12 14
13 namespace ppapi { 15 namespace ppapi {
14 namespace proxy { 16 namespace proxy {
15 17
18 class CompositorResource;
19
16 class PPAPI_PROXY_EXPORT CompositorLayerResource 20 class PPAPI_PROXY_EXPORT CompositorLayerResource
17 : public PluginResource, 21 : public PluginResource,
18 public thunk::PPB_CompositorLayer_API { 22 public thunk::PPB_CompositorLayer_API {
19 public: 23 public:
24 // Release callback for texture or image layer.
25 typedef base::Callback<void(uint32_t, bool)> ReleaseCallback;
26
20 CompositorLayerResource(Connection connection, 27 CompositorLayerResource(Connection connection,
21 PP_Instance instance); 28 PP_Instance instance,
29 const CompositorResource* compositor);
30
31 const CompositorLayerData& data() const { return data_; }
32 const ReleaseCallback& release_callback() const {
33 return release_callback_;
34 }
35 void ResetReleaseCallback() { release_callback_.Reset(); }
36 void Invalidate() { compositor_ = NULL; }
22 37
23 private: 38 private:
24 virtual ~CompositorLayerResource(); 39 virtual ~CompositorLayerResource();
25 40
26 // Resource overrides: 41 // Resource overrides:
27 virtual thunk::PPB_CompositorLayer_API* AsPPB_CompositorLayer_API() OVERRIDE; 42 virtual thunk::PPB_CompositorLayer_API* AsPPB_CompositorLayer_API() OVERRIDE;
28 43
29 // thunk::PPB_Compositor_API overrides: 44 // thunk::PPB_Compositor_API overrides:
30 virtual int32_t SetColor(float red, 45 virtual int32_t SetColor(float red,
31 float green, 46 float green,
32 float blue, 47 float blue,
33 float alpha, 48 float alpha,
34 const PP_Size* size) OVERRIDE; 49 const PP_Size* size) OVERRIDE;
35 virtual int32_t SetTexture( 50 virtual int32_t SetTexture(
36 PP_Resource context, 51 PP_Resource context,
37 uint32_t texture, 52 uint32_t texture,
38 const PP_Size* size, 53 const PP_Size* size,
39 const scoped_refptr<ppapi::TrackedCallback>& callback) OVERRIDE; 54 const scoped_refptr<TrackedCallback>& callback) OVERRIDE;
40 virtual int32_t SetImage( 55 virtual int32_t SetImage(
41 PP_Resource image_data, 56 PP_Resource image_data,
42 const PP_Size* size, 57 const PP_Size* size,
43 const scoped_refptr<ppapi::TrackedCallback>& callback) OVERRIDE; 58 const scoped_refptr<TrackedCallback>& callback) OVERRIDE;
44 virtual int32_t SetClipRect(const PP_Rect* rect) OVERRIDE; 59 virtual int32_t SetClipRect(const PP_Rect* rect) OVERRIDE;
45 virtual int32_t SetTransform(const float matrix[16]) OVERRIDE; 60 virtual int32_t SetTransform(const float matrix[16]) OVERRIDE;
46 virtual int32_t SetOpacity(float opacity) OVERRIDE; 61 virtual int32_t SetOpacity(float opacity) OVERRIDE;
47 virtual int32_t SetBlendMode(PP_BlendMode mode) OVERRIDE; 62 virtual int32_t SetBlendMode(PP_BlendMode mode) OVERRIDE;
48 virtual int32_t SetSourceRect(const PP_FloatRect* rect) OVERRIDE; 63 virtual int32_t SetSourceRect(const PP_FloatRect* rect) OVERRIDE;
49 virtual int32_t SetPremultipliedAlpha(PP_Bool premult) OVERRIDE; 64 virtual int32_t SetPremultipliedAlpha(PP_Bool premult) OVERRIDE;
50 65
66 bool SetType(CompositorLayerData::Type type);
67 int32_t CheckForSetTextureAndImage(
68 CompositorLayerData::Type type,
69 const scoped_refptr<TrackedCallback>& release_callback);
70
71 // Release callbacks:
72 static void OnTextureReleased(
73 const ScopedPPResource& context,
74 uint32_t texture,
75 const scoped_refptr<TrackedCallback>& release_callback,
76 uint32_t sync_point,
77 bool is_lost);
78 static void OnImageReleased(
79 const ScopedPPResource& image,
80 const scoped_refptr<TrackedCallback>& release_callback,
81 uint32_t sync_point,
82 bool is_lost);
83
84 // The CompositorResource which own the layer. The layer is invalidated if
85 // compositor_ is NULL.
86 const CompositorResource* compositor_;
87
88 // Release callback for uncommitted texture or image. When CommitLayers() on
89 // the compositor_ is called, the callback will be copied into a map in the
90 // compositor_, and it will be reset to NULL.
91 ReleaseCallback release_callback_;
92
93 // Size of texture or image. It is used to verify the rect arg of
94 // SetSourceRect().
95 PP_FloatSize source_size_;
96
97 // Layer data.
98 CompositorLayerData data_;
99
51 DISALLOW_COPY_AND_ASSIGN(CompositorLayerResource); 100 DISALLOW_COPY_AND_ASSIGN(CompositorLayerResource);
52 }; 101 };
53 102
54 } // namespace proxy 103 } // namespace proxy
55 } // namespace ppapi 104 } // namespace ppapi
56 105
57 #endif // PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_ 106 #endif // PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698