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

Unified Diff: ui/compositor/compositor.cc

Issue 1513053002: WIP - Gutterless resize on Windows Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 5 years 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 fbc801dbe7cd13b8708985c76eb565c09859e038..762bbabab3c1214fe6a2f4253aab9ff4f8f2115c 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -41,6 +41,32 @@ const double kTestRefreshRate = 200.0;
} // namespace
namespace ui {
+// ResizeSwapPromise is used to track the progression of a frame of a given size
+// through commit/draw/post. Once complete, this class updates Compositor's
+// pending swapped frame size.
+class Compositor::ResizeSwapPromise : public cc::SwapPromise {
+ public:
+ ResizeSwapPromise(Compositor* compositor, const gfx::Size& pending_size)
+ : compositor_(compositor), pending_size_(pending_size) {}
+ ~ResizeSwapPromise() override {}
+
+ // cc::SwapPromise implementation:
+ void DidActivate() override {}
+ void DidNotSwap(DidNotSwapReason reason) override {}
+ void DidSwap(cc::CompositorFrameMetadata* metadata) override {
+ // This will come in on the impl thread - schedule the update on the main
+ // thread.
piman 2015/12/15 07:15:36 We have only one thread on the browser side now, s
+ compositor_->task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&Compositor::set_pending_swapped_frame_size,
+ compositor_->weak_ptr_factory_.GetWeakPtr(), pending_size_));
+ }
+ virtual int64 TraceId() const { return 0; }
+
+ private:
+ Compositor* compositor_;
+ gfx::Size pending_size_;
+};
CompositorLock::CompositorLock(Compositor* compositor)
: compositor_(compositor) {
@@ -281,6 +307,10 @@ void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
host_->SetViewportSize(size_in_pixel);
root_web_layer_->SetBounds(size_in_pixel);
context_factory_->ResizeDisplay(this, size_in_pixel);
+
+ scoped_ptr<ResizeSwapPromise> resize_swap_promise(
+ new ResizeSwapPromise(this, size_in_pixel));
+ host_->QueueSwapPromise(resize_swap_promise.Pass());
}
if (device_scale_factor_ != scale) {
device_scale_factor_ = scale;
@@ -446,6 +476,12 @@ void Compositor::DidPostSwapBuffers() {
base::TimeTicks start_time = base::TimeTicks::Now();
FOR_EACH_OBSERVER(CompositorObserver, observer_list_,
OnCompositingStarted(this, start_time));
+
+ // Enqueue the last_swapped update on our task runner. to ensure ordering with
+ // relation to the ResizeSwapPromise's call to set_pending_swapped_size.
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&Compositor::UpdateLastSwappedFrameSize,
+ weak_ptr_factory_.GetWeakPtr()));
piman 2015/12/15 07:15:35 You don't need to post the task any more (see abov
}
void Compositor::DidAbortSwapBuffers() {

Powered by Google App Engine
This is Rietveld 408576698