| 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/resources/transferable_resource.h" | 18 #include "cc/resources/transferable_resource.h" |
| 19 #include "cc/surfaces/surface_factory_client.h" | 19 #include "cc/surfaces/surface_factory_client.h" |
| 20 #include "third_party/skia/include/core/SkRegion.h" | 20 #include "third_party/skia/include/core/SkRegion.h" |
| 21 #include "third_party/skia/include/core/SkXfermode.h" | 21 #include "third_party/skia/include/core/SkXfermode.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/compositor/compositor.h" | 23 #include "ui/compositor/compositor.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 std::unique_ptr<cc::SingleReleaseCallback>>> | 82 std::unique_ptr<cc::SingleReleaseCallback>>> |
| 82 release_callbacks_; | 83 release_callbacks_; |
| 83 cc::FrameSinkId frame_sink_id_; | 84 cc::FrameSinkId frame_sink_id_; |
| 84 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; | 85 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; |
| 85 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 86 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 86 Surface* surface_ = nullptr; | 87 Surface* surface_ = nullptr; |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 // This class represents a rectangular area that is displayed on the screen. | 90 // This class represents a rectangular area that is displayed on the screen. |
| 90 // It has a location, size and pixel contents. | 91 // It has a location, size and pixel contents. |
| 91 class Surface : public ui::ContextFactoryObserver { | 92 class Surface : public ui::LayerOwnerDelegate, |
| 93 public ui::ContextFactoryObserver { |
| 92 public: | 94 public: |
| 93 using PropertyDeallocator = void (*)(int64_t value); | 95 using PropertyDeallocator = void (*)(int64_t value); |
| 94 | 96 |
| 95 Surface(); | 97 Surface(); |
| 96 ~Surface() override; | 98 ~Surface() override; |
| 97 | 99 |
| 98 // Type-checking downcast routine. | 100 // Type-checking downcast routine. |
| 99 static Surface* AsSurface(const aura::Window* window); | 101 static Surface* AsSurface(const aura::Window* window); |
| 100 | 102 |
| 101 aura::Window* window() { return window_.get(); } | 103 aura::Window* window() { return window_.get(); } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void RemoveSurfaceObserver(SurfaceObserver* observer); | 203 void RemoveSurfaceObserver(SurfaceObserver* observer); |
| 202 bool HasSurfaceObserver(const SurfaceObserver* observer) const; | 204 bool HasSurfaceObserver(const SurfaceObserver* observer) const; |
| 203 | 205 |
| 204 // Returns a trace value representing the state of the surface. | 206 // Returns a trace value representing the state of the surface. |
| 205 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; | 207 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; |
| 206 | 208 |
| 207 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { | 209 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { |
| 208 return pending_damage_.contains(gfx::RectToSkIRect(damage)); | 210 return pending_damage_.contains(gfx::RectToSkIRect(damage)); |
| 209 } | 211 } |
| 210 | 212 |
| 213 // Overridden from ui::LayerOwnerDelegate: |
| 214 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; |
| 215 |
| 211 // Overridden from ui::ContextFactoryObserver. | 216 // Overridden from ui::ContextFactoryObserver. |
| 212 void OnLostResources() override; | 217 void OnLostResources() override; |
| 213 | 218 |
| 214 void WillDraw(const cc::LocalFrameId& local_frame_id); | 219 void WillDraw(const cc::LocalFrameId& local_frame_id); |
| 215 | 220 |
| 216 // Check whether this Surface and its children need to create new cc::Surface | 221 // Check whether this Surface and its children need to create new cc::Surface |
| 217 // IDs for their contents next time they get new buffer contents. | 222 // IDs for their contents next time they get new buffer contents. |
| 218 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); | 223 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 219 | 224 |
| 220 gfx::Size content_size() const { return content_size_; } | 225 gfx::Size content_size() const { return content_size_; } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 401 |
| 397 // Surface observer list. Surface does not own the observers. | 402 // Surface observer list. Surface does not own the observers. |
| 398 base::ObserverList<SurfaceObserver, true> observers_; | 403 base::ObserverList<SurfaceObserver, true> observers_; |
| 399 | 404 |
| 400 DISALLOW_COPY_AND_ASSIGN(Surface); | 405 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 401 }; | 406 }; |
| 402 | 407 |
| 403 } // namespace exo | 408 } // namespace exo |
| 404 | 409 |
| 405 #endif // COMPONENTS_EXO_SURFACE_H_ | 410 #endif // COMPONENTS_EXO_SURFACE_H_ |
| OLD | NEW |