| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_EXO_SURFACE_H_ | 5 #ifndef COMPONENTS_EXO_SURFACE_H_ |
| 6 #define COMPONENTS_EXO_SURFACE_H_ | 6 #define COMPONENTS_EXO_SURFACE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 void OnCompositingDidCommit(ui::Compositor* compositor) override; | 213 void OnCompositingDidCommit(ui::Compositor* compositor) override; |
| 214 void OnCompositingStarted(ui::Compositor* compositor, | 214 void OnCompositingStarted(ui::Compositor* compositor, |
| 215 base::TimeTicks start_time) override; | 215 base::TimeTicks start_time) override; |
| 216 void OnCompositingEnded(ui::Compositor* compositor) override; | 216 void OnCompositingEnded(ui::Compositor* compositor) override; |
| 217 void OnCompositingAborted(ui::Compositor* compositor) override; | 217 void OnCompositingAborted(ui::Compositor* compositor) override; |
| 218 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} | 218 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
| 219 void OnCompositingShuttingDown(ui::Compositor* compositor) override; | 219 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 220 | 220 |
| 221 void WillDraw(cc::SurfaceId surface_id); | 221 void WillDraw(cc::SurfaceId surface_id); |
| 222 | 222 |
| 223 // Check whether this Surface and its children need to create new cc::Surface |
| 224 // IDs for their contents next time they get new buffer contents. |
| 225 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 226 |
| 223 private: | 227 private: |
| 228 struct State { |
| 229 State(); |
| 230 ~State(); |
| 231 |
| 232 bool operator==(const State& other); |
| 233 bool operator!=(const State& other) { return !(*this == other); } |
| 234 |
| 235 SkRegion opaque_region; |
| 236 SkRegion input_region; |
| 237 float buffer_scale = 1.f; |
| 238 gfx::Size viewport; |
| 239 gfx::RectF crop; |
| 240 bool only_visible_on_secure_output = false; |
| 241 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
| 242 float alpha = 1.0f; |
| 243 ; |
| 244 }; |
| 245 |
| 224 bool needs_commit_surface_hierarchy() const { | 246 bool needs_commit_surface_hierarchy() const { |
| 225 return needs_commit_surface_hierarchy_; | 247 return needs_commit_surface_hierarchy_; |
| 226 } | 248 } |
| 227 | 249 |
| 250 // Returns true if this surface or any child surface needs a commit and has |
| 251 // has_pending_layer_changes_ true. |
| 252 bool HasLayerHierarchyChanged() const; |
| 253 |
| 254 // Sets that all children must create new cc::SurfaceIds for their contents. |
| 255 void SetSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 256 |
| 228 // Commit the current attached buffer to a TextureLayer. | 257 // Commit the current attached buffer to a TextureLayer. |
| 229 void CommitTextureContents(); | 258 void CommitTextureContents(); |
| 230 | 259 |
| 231 // Commit the current attached buffer to a SurfaceLayer. | 260 // Commit the current attached buffer to a SurfaceLayer. |
| 232 void CommitSurfaceContents(); | 261 void CommitSurfaceContents(); |
| 233 | 262 |
| 234 // Set TextureLayer contents to the current buffer. | 263 // Set TextureLayer contents to the current buffer. |
| 235 void SetTextureLayerContents(ui::Layer* layer); | 264 void SetTextureLayerContents(ui::Layer* layer); |
| 236 | 265 |
| 237 // Set SurfaceLayer contents to the current buffer. | 266 // Set SurfaceLayer contents to the current buffer. |
| 238 void SetSurfaceLayerContents(ui::Layer* layer); | 267 void SetSurfaceLayerContents(ui::Layer* layer); |
| 239 | 268 |
| 240 // This returns true when the surface has some contents assigned to it. | 269 // This returns true when the surface has some contents assigned to it. |
| 241 bool has_contents() const { return !!current_buffer_; } | 270 bool has_contents() const { return !!current_buffer_; } |
| 242 | 271 |
| 243 // This is true if the buffer contents should be put in a SurfaceLayer | 272 // This is true if the buffer contents should be put in a SurfaceLayer |
| 244 // rather than a TextureLayer. | 273 // rather than a TextureLayer. |
| 245 static bool use_surface_layer_; | 274 static bool use_surface_layer_; |
| 246 | 275 |
| 247 // This window has the layer which contains the Surface contents. | 276 // This window has the layer which contains the Surface contents. |
| 248 std::unique_ptr<aura::Window> window_; | 277 std::unique_ptr<aura::Window> window_; |
| 249 | 278 |
| 279 // This is true if it's possible that the layer properties (size, opacity, |
| 280 // etc.) may have been modified since the last commit. Attaching a new |
| 281 // buffer with the same size as the old shouldn't set this to true. |
| 282 bool has_pending_layer_changes_ = true; |
| 283 |
| 284 // This is true if the next commit to this surface should put its contents |
| 285 // into a new cc::SurfaceId. This allows for synchronization between Surface |
| 286 // and layer changes. |
| 287 bool needs_commit_to_new_surface_ = true; |
| 288 |
| 250 // This is true when Attach() has been called and new contents should take | 289 // This is true when Attach() has been called and new contents should take |
| 251 // effect next time Commit() is called. | 290 // effect next time Commit() is called. |
| 252 bool has_pending_contents_; | 291 bool has_pending_contents_; |
| 253 | 292 |
| 254 // The buffer that will become the content of surface when Commit() is called. | 293 // The buffer that will become the content of surface when Commit() is called. |
| 255 base::WeakPtr<Buffer> pending_buffer_; | 294 base::WeakPtr<Buffer> pending_buffer_; |
| 256 | 295 |
| 257 cc::SurfaceManager* surface_manager_; | 296 cc::SurfaceManager* surface_manager_; |
| 258 | 297 |
| 259 scoped_refptr<SurfaceFactoryOwner> factory_owner_; | 298 scoped_refptr<SurfaceFactoryOwner> factory_owner_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 270 // These lists contains the callbacks to notify the client when it is a good | 309 // These lists contains the callbacks to notify the client when it is a good |
| 271 // time to start producing a new frame. These callbacks move to | 310 // time to start producing a new frame. These callbacks move to |
| 272 // |frame_callbacks_| when Commit() is called. Later they are moved to | 311 // |frame_callbacks_| when Commit() is called. Later they are moved to |
| 273 // |active_frame_callbacks_| when the effect of the Commit() is reflected in | 312 // |active_frame_callbacks_| when the effect of the Commit() is reflected in |
| 274 // the compositor's active layer tree. The callbacks fire once we're notified | 313 // the compositor's active layer tree. The callbacks fire once we're notified |
| 275 // that the compositor started drawing that active layer tree. | 314 // that the compositor started drawing that active layer tree. |
| 276 std::list<FrameCallback> pending_frame_callbacks_; | 315 std::list<FrameCallback> pending_frame_callbacks_; |
| 277 std::list<FrameCallback> frame_callbacks_; | 316 std::list<FrameCallback> frame_callbacks_; |
| 278 std::list<FrameCallback> active_frame_callbacks_; | 317 std::list<FrameCallback> active_frame_callbacks_; |
| 279 | 318 |
| 280 // The opaque region to take effect when Commit() is called. | 319 // This is the state that has yet to be committed. |
| 281 SkRegion pending_opaque_region_; | 320 State pending_state_; |
| 282 | 321 |
| 283 // The input region to take effect when Commit() is called. | 322 // This is the state that has been committed. |
| 284 SkRegion pending_input_region_; | 323 State state_; |
| 285 | |
| 286 // The buffer scaling factor to take effect when Commit() is called. | |
| 287 float pending_buffer_scale_; | |
| 288 | 324 |
| 289 // The stack of sub-surfaces to take effect when Commit() is called. | 325 // The stack of sub-surfaces to take effect when Commit() is called. |
| 290 // Bottom-most sub-surface at the front of the list and top-most sub-surface | 326 // Bottom-most sub-surface at the front of the list and top-most sub-surface |
| 291 // at the back. | 327 // at the back. |
| 292 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; | 328 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; |
| 293 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; | 329 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; |
| 294 SubSurfaceEntryList pending_sub_surfaces_; | 330 SubSurfaceEntryList pending_sub_surfaces_; |
| 295 | 331 |
| 296 // The viewport to take effect when Commit() is called. | |
| 297 gfx::Size pending_viewport_; | |
| 298 | |
| 299 // The crop rectangle to take effect when Commit() is called. | |
| 300 gfx::RectF pending_crop_; | |
| 301 | |
| 302 // The active crop rectangle. | |
| 303 gfx::RectF crop_; | |
| 304 | |
| 305 // The secure output visibility state to take effect when Commit() is called. | |
| 306 bool pending_only_visible_on_secure_output_; | |
| 307 | |
| 308 // The active secure output visibility state. | |
| 309 bool only_visible_on_secure_output_; | |
| 310 | |
| 311 // The blend mode state to take effect when Commit() is called. | |
| 312 SkXfermode::Mode pending_blend_mode_; | |
| 313 | |
| 314 // The alpha state to take effect when Commit() is called. | |
| 315 float pending_alpha_; | |
| 316 | |
| 317 // The active alpha state. | |
| 318 float alpha_; | |
| 319 | |
| 320 // The buffer that is currently set as content of surface. | 332 // The buffer that is currently set as content of surface. |
| 321 base::WeakPtr<Buffer> current_buffer_; | 333 base::WeakPtr<Buffer> current_buffer_; |
| 322 | 334 |
| 323 // The last resource that was sent to a surface. | 335 // The last resource that was sent to a surface. |
| 324 cc::TransferableResource current_resource_; | 336 cc::TransferableResource current_resource_; |
| 325 | 337 |
| 326 // The active input region used for hit testing. | |
| 327 SkRegion input_region_; | |
| 328 | |
| 329 // This is true if a call to Commit() as been made but | 338 // This is true if a call to Commit() as been made but |
| 330 // CommitSurfaceHierarchy() has not yet been called. | 339 // CommitSurfaceHierarchy() has not yet been called. |
| 331 bool needs_commit_surface_hierarchy_; | 340 bool needs_commit_surface_hierarchy_; |
| 332 | 341 |
| 333 // This is set when the compositing starts and passed to active frame | 342 // This is set when the compositing starts and passed to active frame |
| 334 // callbacks when compositing successfully ends. | 343 // callbacks when compositing successfully ends. |
| 335 base::TimeTicks last_compositing_start_time_; | 344 base::TimeTicks last_compositing_start_time_; |
| 336 | 345 |
| 337 // This is true when the contents of the surface should be updated next time | 346 // This is true when the contents of the surface should be updated next time |
| 338 // the compositor successfully ends compositing. | 347 // the compositor successfully ends compositing. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 354 | 363 |
| 355 // Surface observer list. Surface does not own the observers. | 364 // Surface observer list. Surface does not own the observers. |
| 356 base::ObserverList<SurfaceObserver, true> observers_; | 365 base::ObserverList<SurfaceObserver, true> observers_; |
| 357 | 366 |
| 358 DISALLOW_COPY_AND_ASSIGN(Surface); | 367 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 359 }; | 368 }; |
| 360 | 369 |
| 361 } // namespace exo | 370 } // namespace exo |
| 362 | 371 |
| 363 #endif // COMPONENTS_EXO_SURFACE_H_ | 372 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |