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