Adam Barth 752ff89710 Improve vsync provider
Now we actually use the vsync signal to trigger work. Previously, we'd hit the
pipeline depth limit too early and fall back to swap buffers-triggered
rendering.

Also, rename Vsync to VSync on recommendation from jamesr.
2015-07-29 14:25:51 -07:00

51 lines
1.1 KiB
C++

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_UI_ANIMATOR_H_
#define SKY_SHELL_UI_ANIMATOR_H_
#include "base/memory/weak_ptr.h"
#include "sky/services/vsync/vsync.mojom.h"
#include "sky/shell/ui/engine.h"
namespace sky {
namespace shell {
class Animator {
public:
explicit Animator(const Engine::Config& config, Engine* engine);
~Animator();
void RequestFrame();
void Start();
void Stop();
void set_vsync_provider(vsync::VSyncProviderPtr vsync_provider) {
vsync_provider_ = vsync_provider.Pass();
}
private:
void BeginFrame(int64_t time_stamp);
void OnFrameComplete();
bool AwaitVSync();
Engine::Config config_;
Engine* engine_;
vsync::VSyncProviderPtr vsync_provider_;
int outstanding_requests_;
bool did_defer_frame_request_;
bool engine_requested_frame_;
bool paused_;
base::WeakPtrFactory<Animator> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Animator);
};
} // namespace shell
} // namespace sky
#endif // SKY_SHELL_UI_ANIMATOR_H_