OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 CC_LAYERS_TEXTURE_LAYER_H_ | 5 #ifndef CC_LAYERS_TEXTURE_LAYER_H_ |
6 #define CC_LAYERS_TEXTURE_LAYER_H_ | 6 #define CC_LAYERS_TEXTURE_LAYER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // This lock guards the sync_point_ and is_lost_ fields because they can be | 74 // This lock guards the sync_point_ and is_lost_ fields because they can be |
75 // accessed on both the impl and main thread. We do this to ensure that the | 75 // accessed on both the impl and main thread. We do this to ensure that the |
76 // values of these fields are well-ordered such that the last call to | 76 // values of these fields are well-ordered such that the last call to |
77 // ReturnAndReleaseOnImplThread() defines their values. | 77 // ReturnAndReleaseOnImplThread() defines their values. |
78 base::Lock arguments_lock_; | 78 base::Lock arguments_lock_; |
79 uint32 sync_point_; | 79 uint32 sync_point_; |
80 bool is_lost_; | 80 bool is_lost_; |
81 DISALLOW_COPY_AND_ASSIGN(TextureMailboxHolder); | 81 DISALLOW_COPY_AND_ASSIGN(TextureMailboxHolder); |
82 }; | 82 }; |
83 | 83 |
84 // If this texture layer requires special preparation logic for each frame | |
85 // driven by the compositor, pass in a non-nil client. Pass in a nil client | |
86 // pointer if texture updates are driven by an external process. | |
87 static scoped_refptr<TextureLayer> Create(TextureLayerClient* client); | |
88 | |
89 // Used when mailbox names are specified instead of texture IDs. | 84 // Used when mailbox names are specified instead of texture IDs. |
90 static scoped_refptr<TextureLayer> CreateForMailbox( | 85 static scoped_refptr<TextureLayer> CreateForMailbox( |
91 TextureLayerClient* client); | 86 TextureLayerClient* client); |
92 | 87 |
93 // Resets the client, which also resets the texture. This may synchronize with | 88 // Resets the client, which also resets the texture. |
94 // the impl thread if it is currently drawing a texture from the client, that | |
95 // was given via TextureLayerClient::PrepareTexture. After this call it is | |
96 // safe to destroy that texture. Note: it doesn't synchronize for mailboxes, | |
97 // those can only be destroyed after the release callback has been called. | |
98 void ClearClient(); | 89 void ClearClient(); |
99 | 90 |
100 // Resets the texture. This may synchronize with the impl thread if it is | 91 // Resets the texture. |
101 // currently drawing a texture from the client, that was given via | |
102 // TextureLayerClient::PrepareTexture. After this call it is safe to destroy | |
103 // that texture. Note: it doesn't synchronize for mailboxes, those can only be | |
104 // destroyed after the release callback has been called. | |
105 void ClearTexture(); | 92 void ClearTexture(); |
106 | 93 |
107 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 94 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
108 OVERRIDE; | 95 OVERRIDE; |
109 | 96 |
110 // Sets whether this texture should be Y-flipped at draw time. Defaults to | 97 // Sets whether this texture should be Y-flipped at draw time. Defaults to |
111 // true. | 98 // true. |
112 void SetFlipped(bool flipped); | 99 void SetFlipped(bool flipped); |
113 | 100 |
114 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1). | 101 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1). |
(...skipping 13 matching lines...) Expand all Loading... |
128 // Sets whether the texture should be blended with the background color | 115 // Sets whether the texture should be blended with the background color |
129 // at draw time. Defaults to false. | 116 // at draw time. Defaults to false. |
130 void SetBlendBackgroundColor(bool blend); | 117 void SetBlendBackgroundColor(bool blend); |
131 | 118 |
132 // Sets whether this context should rate limit on damage to prevent too many | 119 // Sets whether this context should rate limit on damage to prevent too many |
133 // frames from being queued up before the compositor gets a chance to run. | 120 // frames from being queued up before the compositor gets a chance to run. |
134 // Requires a non-nil client. Defaults to false. | 121 // Requires a non-nil client. Defaults to false. |
135 void SetRateLimitContext(bool rate_limit); | 122 void SetRateLimitContext(bool rate_limit); |
136 | 123 |
137 // Code path for plugins which supply their own mailbox. | 124 // Code path for plugins which supply their own mailbox. |
138 bool uses_mailbox() const { return uses_mailbox_; } | |
139 void SetTextureMailbox(const TextureMailbox& mailbox, | 125 void SetTextureMailbox(const TextureMailbox& mailbox, |
140 scoped_ptr<SingleReleaseCallback> release_callback); | 126 scoped_ptr<SingleReleaseCallback> release_callback); |
141 | 127 |
142 // Use this for special cases where the same texture is used to back the | 128 // Use this for special cases where the same texture is used to back the |
143 // TextureLayer across all frames. | 129 // TextureLayer across all frames. |
144 // WARNING: DON'T ACTUALLY USE THIS WHAT YOU ARE DOING IS WRONG. | 130 // WARNING: DON'T ACTUALLY USE THIS WHAT YOU ARE DOING IS WRONG. |
145 // TODO(danakj): Remove this when pepper doesn't need it. crbug.com/350204 | 131 // TODO(danakj): Remove this when pepper doesn't need it. crbug.com/350204 |
146 void SetTextureMailboxWithoutReleaseCallback(const TextureMailbox& mailbox); | 132 void SetTextureMailboxWithoutReleaseCallback(const TextureMailbox& mailbox); |
147 | 133 |
148 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE; | 134 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE; |
149 | 135 |
150 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; | 136 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; |
151 virtual bool DrawsContent() const OVERRIDE; | 137 virtual bool DrawsContent() const OVERRIDE; |
152 virtual bool Update(ResourceUpdateQueue* queue, | 138 virtual bool Update(ResourceUpdateQueue* queue, |
153 const OcclusionTracker<Layer>* occlusion) OVERRIDE; | 139 const OcclusionTracker<Layer>* occlusion) OVERRIDE; |
154 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 140 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
155 virtual Region VisibleContentOpaqueRegion() const OVERRIDE; | 141 virtual Region VisibleContentOpaqueRegion() const OVERRIDE; |
156 | 142 |
157 protected: | 143 protected: |
158 TextureLayer(TextureLayerClient* client, bool uses_mailbox); | 144 explicit TextureLayer(TextureLayerClient* client); |
159 virtual ~TextureLayer(); | 145 virtual ~TextureLayer(); |
160 | 146 |
161 private: | 147 private: |
162 void SetTextureMailboxInternal( | 148 void SetTextureMailboxInternal( |
163 const TextureMailbox& mailbox, | 149 const TextureMailbox& mailbox, |
164 scoped_ptr<SingleReleaseCallback> release_callback, | 150 scoped_ptr<SingleReleaseCallback> release_callback, |
165 bool requires_commit, | 151 bool requires_commit, |
166 bool allow_mailbox_reuse); | 152 bool allow_mailbox_reuse); |
167 | 153 |
168 TextureLayerClient* client_; | 154 TextureLayerClient* client_; |
169 bool uses_mailbox_; | |
170 | 155 |
171 bool flipped_; | 156 bool flipped_; |
172 gfx::PointF uv_top_left_; | 157 gfx::PointF uv_top_left_; |
173 gfx::PointF uv_bottom_right_; | 158 gfx::PointF uv_bottom_right_; |
174 // [bottom left, top left, top right, bottom right] | 159 // [bottom left, top left, top right, bottom right] |
175 float vertex_opacity_[4]; | 160 float vertex_opacity_[4]; |
176 bool premultiplied_alpha_; | 161 bool premultiplied_alpha_; |
177 bool blend_background_color_; | 162 bool blend_background_color_; |
178 bool rate_limit_context_; | 163 bool rate_limit_context_; |
179 bool impl_may_draw_client_data_; | |
180 | 164 |
181 unsigned texture_id_; | |
182 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; | 165 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; |
183 bool needs_set_mailbox_; | 166 bool needs_set_mailbox_; |
184 | 167 |
185 DISALLOW_COPY_AND_ASSIGN(TextureLayer); | 168 DISALLOW_COPY_AND_ASSIGN(TextureLayer); |
186 }; | 169 }; |
187 | 170 |
188 } // namespace cc | 171 } // namespace cc |
189 #endif // CC_LAYERS_TEXTURE_LAYER_H_ | 172 #endif // CC_LAYERS_TEXTURE_LAYER_H_ |
OLD | NEW |