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

Unified Diff: ui/compositor/compositor.cc

Issue 553213003: Avoid destroying surface before the parent surface stops referencing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/compositor/compositor.cc
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 1b6f342aade256f319beba3178b41f7f781062bb..d33a012db4523f9307d410ce0839d6f63dbc19f9 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -20,6 +20,7 @@
#include "cc/layers/layer.h"
#include "cc/output/begin_frame_args.h"
#include "cc/output/context_provider.h"
+#include "cc/surfaces/surface_id_allocator.h"
#include "cc/trees/layer_tree_host.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/compositor/compositor_observer.h"
@@ -68,12 +69,31 @@ namespace {} // namespace
namespace ui {
+class SatisfySwapPromise : public cc::SwapPromise {
+ public:
+ explicit SatisfySwapPromise(uint32_t id) : id_(id) {}
+
+ private:
+ virtual void DidSwap(cc::CompositorFrameMetadata* metadata) OVERRIDE {
+ metadata->satisfies_sequences.push_back(id_);
+ }
+
+ virtual void DidNotSwap(DidNotSwapReason reason) OVERRIDE {
+ // TODO(jbauman): Send to the SurfaceManager immediately.
+ DCHECK(false);
+ }
+ virtual int64 TraceId() const OVERRIDE { return 0; }
+ uint32_t id_;
+};
+
Compositor::Compositor(gfx::AcceleratedWidget widget,
ui::ContextFactory* context_factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: context_factory_(context_factory),
root_layer_(NULL),
widget_(widget),
+ surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()),
+ surface_sequence_number_(0),
compositor_thread_loop_(context_factory->GetCompositorMessageLoop()),
task_runner_(task_runner),
vsync_manager_(new CompositorVSyncManager()),
@@ -406,6 +426,16 @@ void Compositor::SetLayerTreeDebugState(
host_->SetDebugState(debug_state);
}
+cc::SurfaceSequence Compositor::CreateSurfaceSequenceForNextFrame() {
danakj 2014/10/09 17:47:38 Create -> Insert ?
+ cc::SurfaceSequence sequence;
+ sequence.id_namespace = surface_id_allocator_->id_namespace();
+ sequence.sequence = ++surface_sequence_number_;
+ scoped_ptr<cc::SwapPromise> promise(
+ new SatisfySwapPromise(surface_sequence_number_));
+ host_->QueueSwapPromise(promise.Pass());
+ return sequence;
+}
+
scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
if (!compositor_lock_) {
compositor_lock_ = new CompositorLock(this);

Powered by Google App Engine
This is Rietveld 408576698