| Index: ui/compositor/compositor.cc
|
| diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
|
| index 1b6f342aade256f319beba3178b41f7f781062bb..4d07e1ee1d0c31001fd5aea5f39da6fe87217315 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::InsertSurfaceSequenceForNextFrame() {
|
| + 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);
|
|
|