| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "cc/surfaces/surface_factory_client.h" | 18 #include "cc/surfaces/surface_factory_client.h" |
| 19 #include "third_party/skia/include/core/SkRegion.h" | 19 #include "third_party/skia/include/core/SkRegion.h" |
| 20 #include "third_party/skia/include/core/SkXfermode.h" | 20 #include "third_party/skia/include/core/SkXfermode.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
| 23 #include "ui/compositor/compositor_observer.h" | 23 #include "ui/compositor/compositor_observer.h" |
| 24 #include "ui/compositor/layer_owner_delegate.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 namespace trace_event { | 28 namespace trace_event { |
| 28 class TracedValue; | 29 class TracedValue; |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace cc { | 33 namespace cc { |
| 33 class SurfaceFactory; | 34 class SurfaceFactory; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 release_callbacks_; | 75 release_callbacks_; |
| 75 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; | 76 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; |
| 76 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 77 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 77 Surface* surface_; | 78 Surface* surface_; |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 // This class represents a rectangular area that is displayed on the screen. | 81 // This class represents a rectangular area that is displayed on the screen. |
| 81 // It has a location, size and pixel contents. | 82 // It has a location, size and pixel contents. |
| 82 class Surface : public aura::Window, | 83 class Surface : public aura::Window, |
| 83 public aura::WindowObserver, | 84 public aura::WindowObserver, |
| 85 public ui::LayerOwnerDelegate, |
| 84 public ui::CompositorObserver { | 86 public ui::CompositorObserver { |
| 85 public: | 87 public: |
| 86 Surface(); | 88 Surface(); |
| 87 ~Surface() override; | 89 ~Surface() override; |
| 88 | 90 |
| 89 // Type-checking downcast routine. | 91 // Type-checking downcast routine. |
| 90 static Surface* AsSurface(const aura::Window* window); | 92 static Surface* AsSurface(const aura::Window* window); |
| 91 | 93 |
| 92 // Sets whether to put the contents in a SurfaceLayer or a TextureLayer. | 94 // Sets whether to put the contents in a SurfaceLayer or a TextureLayer. |
| 93 static void SetUseSurfaceLayer(bool use_surface_layer); | 95 static void SetUseSurfaceLayer(bool use_surface_layer); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 197 |
| 196 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { | 198 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { |
| 197 return pending_damage_.contains(gfx::RectToSkIRect(damage)); | 199 return pending_damage_.contains(gfx::RectToSkIRect(damage)); |
| 198 } | 200 } |
| 199 | 201 |
| 200 // Overridden from aura::WindowObserver: | 202 // Overridden from aura::WindowObserver: |
| 201 void OnWindowAddedToRootWindow(aura::Window* window) override; | 203 void OnWindowAddedToRootWindow(aura::Window* window) override; |
| 202 void OnWindowRemovingFromRootWindow(aura::Window* window, | 204 void OnWindowRemovingFromRootWindow(aura::Window* window, |
| 203 aura::Window* new_root) override; | 205 aura::Window* new_root) override; |
| 204 | 206 |
| 207 // Overridden from ui::LayerOwnerDelegate: |
| 208 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; |
| 209 |
| 205 // Overridden from ui::CompositorObserver: | 210 // Overridden from ui::CompositorObserver: |
| 206 void OnCompositingDidCommit(ui::Compositor* compositor) override; | 211 void OnCompositingDidCommit(ui::Compositor* compositor) override; |
| 207 void OnCompositingStarted(ui::Compositor* compositor, | 212 void OnCompositingStarted(ui::Compositor* compositor, |
| 208 base::TimeTicks start_time) override; | 213 base::TimeTicks start_time) override; |
| 209 void OnCompositingEnded(ui::Compositor* compositor) override; | 214 void OnCompositingEnded(ui::Compositor* compositor) override; |
| 210 void OnCompositingAborted(ui::Compositor* compositor) override; | 215 void OnCompositingAborted(ui::Compositor* compositor) override; |
| 211 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} | 216 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} |
| 212 void OnCompositingShuttingDown(ui::Compositor* compositor) override; | 217 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 213 | 218 |
| 214 void WillDraw(cc::SurfaceId surface_id); | 219 void WillDraw(cc::SurfaceId surface_id); |
| 215 | 220 |
| 216 private: | 221 private: |
| 217 bool needs_commit_surface_hierarchy() const { | 222 bool needs_commit_surface_hierarchy() const { |
| 218 return needs_commit_surface_hierarchy_; | 223 return needs_commit_surface_hierarchy_; |
| 219 } | 224 } |
| 220 | 225 |
| 221 // Commit the current attached buffer to a TextureLayer. | 226 // Commit the current attached buffer to a TextureLayer. |
| 222 void CommitLayerContents(); | 227 void CommitTextureContents(); |
| 223 | 228 |
| 224 // Commit the current attached buffer to a SurfaceLayer. | 229 // Commit the current attached buffer to a SurfaceLayer. |
| 225 void CommitSurfaceContents(); | 230 void CommitSurfaceContents(); |
| 226 | 231 |
| 232 // Set TextureLayer contents to the current buffer. |
| 233 void SetTextureLayerContents(ui::Layer* layer); |
| 234 |
| 235 // Set SurfaceLayer contents to the current buffer. |
| 236 void SetSurfaceLayerContents(ui::Layer* layer); |
| 237 |
| 227 // This returns true when the surface has some contents assigned to it. | 238 // This returns true when the surface has some contents assigned to it. |
| 228 bool has_contents() const { return !!current_buffer_; } | 239 bool has_contents() const { return !!current_buffer_; } |
| 229 | 240 |
| 230 // This is true if the buffer contents should be put in a SurfaceLayer | 241 // This is true if the buffer contents should be put in a SurfaceLayer |
| 231 // rather than a TextureLayer. | 242 // rather than a TextureLayer. |
| 232 static bool use_surface_layer_; | 243 static bool use_surface_layer_; |
| 233 | 244 |
| 234 // This is true when Attach() has been called and new contents should take | 245 // This is true when Attach() has been called and new contents should take |
| 235 // effect next time Commit() is called. | 246 // effect next time Commit() is called. |
| 236 bool has_pending_contents_; | 247 bool has_pending_contents_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; | 287 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; |
| 277 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; | 288 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; |
| 278 SubSurfaceEntryList pending_sub_surfaces_; | 289 SubSurfaceEntryList pending_sub_surfaces_; |
| 279 | 290 |
| 280 // The viewport to take effect when Commit() is called. | 291 // The viewport to take effect when Commit() is called. |
| 281 gfx::Size pending_viewport_; | 292 gfx::Size pending_viewport_; |
| 282 | 293 |
| 283 // The crop rectangle to take effect when Commit() is called. | 294 // The crop rectangle to take effect when Commit() is called. |
| 284 gfx::RectF pending_crop_; | 295 gfx::RectF pending_crop_; |
| 285 | 296 |
| 297 // The active crop rectangle. |
| 298 gfx::RectF crop_; |
| 299 |
| 286 // The secure output visibility state to take effect when Commit() is called. | 300 // The secure output visibility state to take effect when Commit() is called. |
| 287 bool pending_only_visible_on_secure_output_; | 301 bool pending_only_visible_on_secure_output_; |
| 288 | 302 |
| 303 // The active secure output visibility state. |
| 304 bool only_visible_on_secure_output_; |
| 305 |
| 289 // The blend mode state to take effect when Commit() is called. | 306 // The blend mode state to take effect when Commit() is called. |
| 290 SkXfermode::Mode pending_blend_mode_; | 307 SkXfermode::Mode pending_blend_mode_; |
| 291 | 308 |
| 292 // The alpha state to take effect when Commit() is called. | 309 // The alpha state to take effect when Commit() is called. |
| 293 float pending_alpha_; | 310 float pending_alpha_; |
| 294 | 311 |
| 312 // The active alpha state. |
| 313 float alpha_; |
| 314 |
| 295 // The buffer that is currently set as content of surface. | 315 // The buffer that is currently set as content of surface. |
| 296 base::WeakPtr<Buffer> current_buffer_; | 316 base::WeakPtr<Buffer> current_buffer_; |
| 297 | 317 |
| 298 // The active input region used for hit testing. | 318 // The active input region used for hit testing. |
| 299 SkRegion input_region_; | 319 SkRegion input_region_; |
| 300 | 320 |
| 301 // This is true if a call to Commit() as been made but | 321 // This is true if a call to Commit() as been made but |
| 302 // CommitSurfaceHierarchy() has not yet been called. | 322 // CommitSurfaceHierarchy() has not yet been called. |
| 303 bool needs_commit_surface_hierarchy_; | 323 bool needs_commit_surface_hierarchy_; |
| 304 | 324 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 326 | 346 |
| 327 // Surface observer list. Surface does not own the observers. | 347 // Surface observer list. Surface does not own the observers. |
| 328 base::ObserverList<SurfaceObserver, true> observers_; | 348 base::ObserverList<SurfaceObserver, true> observers_; |
| 329 | 349 |
| 330 DISALLOW_COPY_AND_ASSIGN(Surface); | 350 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 331 }; | 351 }; |
| 332 | 352 |
| 333 } // namespace exo | 353 } // namespace exo |
| 334 | 354 |
| 335 #endif // COMPONENTS_EXO_SURFACE_H_ | 355 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |