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

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

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix browser test 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 | « no previous file | components/exo/surface.cc » ('j') | components/exo/surface.cc » ('J')
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/compositor/compositor.h"
23 #include "ui/compositor/layer_owner_delegate.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 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 std::pair<scoped_refptr<SurfaceFactoryOwner>, 80 std::pair<scoped_refptr<SurfaceFactoryOwner>,
80 std::unique_ptr<cc::SingleReleaseCallback>>> 81 std::unique_ptr<cc::SingleReleaseCallback>>>
81 release_callbacks_; 82 release_callbacks_;
82 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; 83 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_;
83 std::unique_ptr<cc::SurfaceFactory> surface_factory_; 84 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
84 Surface* surface_; 85 Surface* surface_;
85 }; 86 };
86 87
87 // This class represents a rectangular area that is displayed on the screen. 88 // This class represents a rectangular area that is displayed on the screen.
88 // It has a location, size and pixel contents. 89 // It has a location, size and pixel contents.
89 class Surface : public ui::LayerOwnerDelegate { 90 class Surface : public ui::LayerOwnerDelegate,
91 public ui::ContextFactoryObserver {
90 public: 92 public:
91 typedef void (*PropertyDeallocator)(int64_t value); 93 typedef void (*PropertyDeallocator)(int64_t value);
92 94
93 Surface(); 95 Surface();
94 ~Surface() override; 96 ~Surface() override;
95 97
96 // Type-checking downcast routine. 98 // Type-checking downcast routine.
97 static Surface* AsSurface(const aura::Window* window); 99 static Surface* AsSurface(const aura::Window* window);
98 100
99 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
199 // Returns a trace value representing the state of the surface. 201 // Returns a trace value representing the state of the surface.
200 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; 202 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
201 203
202 bool HasPendingDamageForTesting(const gfx::Rect& damage) const { 204 bool HasPendingDamageForTesting(const gfx::Rect& damage) const {
203 return pending_damage_.contains(gfx::RectToSkIRect(damage)); 205 return pending_damage_.contains(gfx::RectToSkIRect(damage));
204 } 206 }
205 207
206 // Overridden from ui::LayerOwnerDelegate: 208 // Overridden from ui::LayerOwnerDelegate:
207 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; 209 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override;
208 210
211 // Overridden from ui::ContextFactoryObserver.
212 void OnLostResources() override;
213
209 void WillDraw(cc::SurfaceId surface_id); 214 void WillDraw(cc::SurfaceId surface_id);
210 215
211 // 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
212 // IDs for their contents next time they get new buffer contents. 217 // IDs for their contents next time they get new buffer contents.
213 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 218 void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
214 219
215 gfx::Size content_size() const { return content_size_; } 220 gfx::Size content_size() const { return content_size_; }
216 221
217 // Sets the |value| of the given surface |property|. Setting to the default 222 // Sets the |value| of the given surface |property|. Setting to the default
218 // value (e.g., NULL) removes the property. The caller is responsible for the 223 // value (e.g., NULL) removes the property. The caller is responsible for the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Returns true if this surface or any child surface needs a commit and has 263 // Returns true if this surface or any child surface needs a commit and has
259 // has_pending_layer_changes_ true. 264 // has_pending_layer_changes_ true.
260 bool HasLayerHierarchyChanged() const; 265 bool HasLayerHierarchyChanged() const;
261 266
262 // Sets that all children must create new cc::SurfaceIds for their contents. 267 // Sets that all children must create new cc::SurfaceIds for their contents.
263 void SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 268 void SetSurfaceHierarchyNeedsCommitToNewSurfaces();
264 269
265 // Set SurfaceLayer contents to the current buffer. 270 // Set SurfaceLayer contents to the current buffer.
266 void SetSurfaceLayerContents(ui::Layer* layer); 271 void SetSurfaceLayerContents(ui::Layer* layer);
267 272
273 // Updates current_resource_ with a new resource id corresponding to the
274 // contents of the attached buffer (or id 0, if no buffer is attached).
275 // UpdateSurface must be called afterwards to ensure the release callback
276 // will be called.
277 void CreateResource(bool for_commit);
278
279 // Updates the current Surface with a new frame referring to the resource in
280 // current_resource_.
281 void UpdateSurface(bool for_commit);
282
268 int64_t SetPropertyInternal(const void* key, 283 int64_t SetPropertyInternal(const void* key,
269 const char* name, 284 const char* name,
270 PropertyDeallocator deallocator, 285 PropertyDeallocator deallocator,
271 int64_t value, 286 int64_t value,
272 int64_t default_value); 287 int64_t default_value);
273 int64_t GetPropertyInternal(const void* key, int64_t default_value) const; 288 int64_t GetPropertyInternal(const void* key, int64_t default_value) const;
274 289
275 // This returns true when the surface has some contents assigned to it. 290 // This returns true when the surface has some contents assigned to it.
276 bool has_contents() const { return !!current_buffer_; } 291 bool has_contents() const { return !!current_buffer_; }
277 292
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // The stack of sub-surfaces to take effect when Commit() is called. 345 // The stack of sub-surfaces to take effect when Commit() is called.
331 // Bottom-most sub-surface at the front of the list and top-most sub-surface 346 // Bottom-most sub-surface at the front of the list and top-most sub-surface
332 // at the back. 347 // at the back.
333 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; 348 using SubSurfaceEntry = std::pair<Surface*, gfx::Point>;
334 using SubSurfaceEntryList = std::list<SubSurfaceEntry>; 349 using SubSurfaceEntryList = std::list<SubSurfaceEntry>;
335 SubSurfaceEntryList pending_sub_surfaces_; 350 SubSurfaceEntryList pending_sub_surfaces_;
336 351
337 // The buffer that is currently set as content of surface. 352 // The buffer that is currently set as content of surface.
338 base::WeakPtr<Buffer> current_buffer_; 353 base::WeakPtr<Buffer> current_buffer_;
339 354
355 bool frame_is_opaque_ = false;
356
340 // The last resource that was sent to a surface. 357 // The last resource that was sent to a surface.
341 cc::TransferableResource current_resource_; 358 cc::TransferableResource current_resource_;
342 359
343 // This is true if a call to Commit() as been made but 360 // This is true if a call to Commit() as been made but
344 // CommitSurfaceHierarchy() has not yet been called. 361 // CommitSurfaceHierarchy() has not yet been called.
345 bool needs_commit_surface_hierarchy_; 362 bool needs_commit_surface_hierarchy_;
346 363
347 // This is set when the compositing starts and passed to active frame 364 // This is set when the compositing starts and passed to active frame
348 // callbacks when compositing successfully ends. 365 // callbacks when compositing successfully ends.
349 base::TimeTicks last_compositing_start_time_; 366 base::TimeTicks last_compositing_start_time_;
(...skipping 16 matching lines...) Expand all
366 383
367 // Surface observer list. Surface does not own the observers. 384 // Surface observer list. Surface does not own the observers.
368 base::ObserverList<SurfaceObserver, true> observers_; 385 base::ObserverList<SurfaceObserver, true> observers_;
369 386
370 DISALLOW_COPY_AND_ASSIGN(Surface); 387 DISALLOW_COPY_AND_ASSIGN(Surface);
371 }; 388 };
372 389
373 } // namespace exo 390 } // namespace exo
374 391
375 #endif // COMPONENTS_EXO_SURFACE_H_ 392 #endif // COMPONENTS_EXO_SURFACE_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/surface.cc » ('j') | components/exo/surface.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698