Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: components/exo/surface.h

Issue 2066493004: exo: Remove TextureLayer implementation of Surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add todo, format Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/sub_surface_unittest.cc ('k') | components/exo/surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/aura/window_observer.h"
24 #include "ui/compositor/compositor_observer.h"
25 #include "ui/compositor/layer_owner_delegate.h" 23 #include "ui/compositor/layer_owner_delegate.h"
26 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
27 25
28 namespace base { 26 namespace base {
29 namespace trace_event { 27 namespace trace_event {
30 class TracedValue; 28 class TracedValue;
31 } 29 }
32 } 30 }
33 31
34 namespace cc { 32 namespace cc {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 std::pair<scoped_refptr<SurfaceFactoryOwner>, 72 std::pair<scoped_refptr<SurfaceFactoryOwner>,
75 std::unique_ptr<cc::SingleReleaseCallback>>> 73 std::unique_ptr<cc::SingleReleaseCallback>>>
76 release_callbacks_; 74 release_callbacks_;
77 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; 75 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_;
78 std::unique_ptr<cc::SurfaceFactory> surface_factory_; 76 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
79 Surface* surface_; 77 Surface* surface_;
80 }; 78 };
81 79
82 // This class represents a rectangular area that is displayed on the screen. 80 // This class represents a rectangular area that is displayed on the screen.
83 // It has a location, size and pixel contents. 81 // It has a location, size and pixel contents.
84 class Surface : public aura::WindowObserver, 82 class Surface : public ui::LayerOwnerDelegate {
85 public ui::LayerOwnerDelegate,
86 public ui::CompositorObserver {
87 public: 83 public:
88 Surface(); 84 Surface();
89 ~Surface() override; 85 ~Surface() override;
90 86
91 // Type-checking downcast routine. 87 // Type-checking downcast routine.
92 static Surface* AsSurface(const aura::Window* window); 88 static Surface* AsSurface(const aura::Window* window);
93 89
94 // Sets whether to put the contents in a SurfaceLayer or a TextureLayer.
95 static void SetUseSurfaceLayer(bool use_surface_layer);
96
97 aura::Window* window() { return window_.get(); } 90 aura::Window* window() { return window_.get(); }
98 91
99 // Set a buffer as the content of this surface. A buffer can only be attached 92 // Set a buffer as the content of this surface. A buffer can only be attached
100 // to one surface at a time. 93 // to one surface at a time.
101 void Attach(Buffer* buffer); 94 void Attach(Buffer* buffer);
102 95
103 // Describe the regions where the pending buffer is different from the 96 // Describe the regions where the pending buffer is different from the
104 // current surface contents, and where the surface therefore needs to be 97 // current surface contents, and where the surface therefore needs to be
105 // repainted. 98 // repainted.
106 void Damage(const gfx::Rect& rect); 99 void Damage(const gfx::Rect& rect);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void RemoveSurfaceObserver(SurfaceObserver* observer); 187 void RemoveSurfaceObserver(SurfaceObserver* observer);
195 bool HasSurfaceObserver(const SurfaceObserver* observer) const; 188 bool HasSurfaceObserver(const SurfaceObserver* observer) const;
196 189
197 // Returns a trace value representing the state of the surface. 190 // Returns a trace value representing the state of the surface.
198 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; 191 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
199 192
200 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { 193 bool HasPendingDamageForTesting(const gfx::Rect& damage) const {
201 return pending_damage_.contains(gfx::RectToSkIRect(damage)); 194 return pending_damage_.contains(gfx::RectToSkIRect(damage));
202 } 195 }
203 196
204 // Overridden from aura::WindowObserver:
205 void OnWindowAddedToRootWindow(aura::Window* window) override;
206 void OnWindowRemovingFromRootWindow(aura::Window* window,
207 aura::Window* new_root) override;
208
209 // Overridden from ui::LayerOwnerDelegate: 197 // Overridden from ui::LayerOwnerDelegate:
210 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; 198 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override;
211 199
212 // Overridden from ui::CompositorObserver:
213 void OnCompositingDidCommit(ui::Compositor* compositor) override;
214 void OnCompositingStarted(ui::Compositor* compositor,
215 base::TimeTicks start_time) override;
216 void OnCompositingEnded(ui::Compositor* compositor) override;
217 void OnCompositingAborted(ui::Compositor* compositor) override;
218 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
219 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
220
221 void WillDraw(cc::SurfaceId surface_id); 200 void WillDraw(cc::SurfaceId surface_id);
222 201
223 // Check whether this Surface and its children need to create new cc::Surface 202 // 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. 203 // IDs for their contents next time they get new buffer contents.
225 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 204 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
226 205
227 private: 206 private:
228 struct State { 207 struct State {
229 State(); 208 State();
230 ~State(); 209 ~State();
(...skipping 16 matching lines...) Expand all
247 return needs_commit_surface_hierarchy_; 226 return needs_commit_surface_hierarchy_;
248 } 227 }
249 228
250 // Returns true if this surface or any child surface needs a commit and has 229 // Returns true if this surface or any child surface needs a commit and has
251 // has_pending_layer_changes_ true. 230 // has_pending_layer_changes_ true.
252 bool HasLayerHierarchyChanged() const; 231 bool HasLayerHierarchyChanged() const;
253 232
254 // Sets that all children must create new cc::SurfaceIds for their contents. 233 // Sets that all children must create new cc::SurfaceIds for their contents.
255 void SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 234 void SetSurfaceHierarchyNeedsCommitToNewSurfaces();
256 235
257 // Commit the current attached buffer to a TextureLayer.
258 void CommitTextureContents();
259
260 // Commit the current attached buffer to a SurfaceLayer.
261 void CommitSurfaceContents();
262
263 // Set TextureLayer contents to the current buffer.
264 void SetTextureLayerContents(ui::Layer* layer);
265
266 // Set SurfaceLayer contents to the current buffer. 236 // Set SurfaceLayer contents to the current buffer.
267 void SetSurfaceLayerContents(ui::Layer* layer); 237 void SetSurfaceLayerContents(ui::Layer* layer);
268 238
269 // This returns true when the surface has some contents assigned to it. 239 // This returns true when the surface has some contents assigned to it.
270 bool has_contents() const { return !!current_buffer_; } 240 bool has_contents() const { return !!current_buffer_; }
271 241
272 // This is true if the buffer contents should be put in a SurfaceLayer
273 // rather than a TextureLayer.
274 static bool use_surface_layer_;
275
276 // This window has the layer which contains the Surface contents. 242 // This window has the layer which contains the Surface contents.
277 std::unique_ptr<aura::Window> window_; 243 std::unique_ptr<aura::Window> window_;
278 244
279 // This is true if it's possible that the layer properties (size, opacity, 245 // 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 246 // 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. 247 // buffer with the same size as the old shouldn't set this to true.
282 bool has_pending_layer_changes_ = true; 248 bool has_pending_layer_changes_ = true;
283 249
284 // This is true if the next commit to this surface should put its contents 250 // 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 251 // into a new cc::SurfaceId. This allows for synchronization between Surface
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 cc::TransferableResource current_resource_; 302 cc::TransferableResource current_resource_;
337 303
338 // This is true if a call to Commit() as been made but 304 // This is true if a call to Commit() as been made but
339 // CommitSurfaceHierarchy() has not yet been called. 305 // CommitSurfaceHierarchy() has not yet been called.
340 bool needs_commit_surface_hierarchy_; 306 bool needs_commit_surface_hierarchy_;
341 307
342 // This is set when the compositing starts and passed to active frame 308 // This is set when the compositing starts and passed to active frame
343 // callbacks when compositing successfully ends. 309 // callbacks when compositing successfully ends.
344 base::TimeTicks last_compositing_start_time_; 310 base::TimeTicks last_compositing_start_time_;
345 311
346 // This is true when the contents of the surface should be updated next time
347 // the compositor successfully ends compositing.
348 bool update_contents_after_successful_compositing_;
349
350 // The compsitor being observer or null if not observing a compositor.
351 ui::Compositor* compositor_;
352
353 // Cursor providers. Surface does not own the cursor providers. 312 // Cursor providers. Surface does not own the cursor providers.
354 std::set<CursorProvider*> cursor_providers_; 313 std::set<CursorProvider*> cursor_providers_;
355 314
356 // Texture size.
357 gfx::Size texture_size_in_dip_;
358
359 // This can be set to have some functions delegated. E.g. ShellSurface class 315 // This can be set to have some functions delegated. E.g. ShellSurface class
360 // can set this to handle Commit() and apply any double buffered state it 316 // can set this to handle Commit() and apply any double buffered state it
361 // maintains. 317 // maintains.
362 SurfaceDelegate* delegate_; 318 SurfaceDelegate* delegate_;
363 319
364 // Surface observer list. Surface does not own the observers. 320 // Surface observer list. Surface does not own the observers.
365 base::ObserverList<SurfaceObserver, true> observers_; 321 base::ObserverList<SurfaceObserver, true> observers_;
366 322
367 DISALLOW_COPY_AND_ASSIGN(Surface); 323 DISALLOW_COPY_AND_ASSIGN(Surface);
368 }; 324 };
369 325
370 } // namespace exo 326 } // namespace exo
371 327
372 #endif // COMPONENTS_EXO_SURFACE_H_ 328 #endif // COMPONENTS_EXO_SURFACE_H_
OLDNEW
« no previous file with comments | « components/exo/sub_surface_unittest.cc ('k') | components/exo/surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698