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

Side by Side Diff: cc/test/fake_compositor_frame_sink.cc

Issue 2402173002: cc: Get rid of PostSwapBuffersComplete. (Closed)
Patch Set: postswap: fix-blimp-unittest-post-swap-acks Created 4 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 unified diff | Download patch
« no previous file with comments | « cc/test/fake_compositor_frame_sink.h ('k') | cc/test/fake_output_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #include "cc/test/fake_compositor_frame_sink.h" 5 #include "cc/test/fake_compositor_frame_sink.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "cc/output/compositor_frame_sink_client.h" 9 #include "cc/output/compositor_frame_sink_client.h"
10 #include "cc/resources/returned_resource.h" 10 #include "cc/resources/returned_resource.h"
11 #include "cc/test/begin_frame_args_test.h" 11 #include "cc/test/begin_frame_args_test.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 FakeCompositorFrameSink::FakeCompositorFrameSink( 16 FakeCompositorFrameSink::FakeCompositorFrameSink(
17 scoped_refptr<ContextProvider> context_provider, 17 scoped_refptr<ContextProvider> context_provider,
18 scoped_refptr<ContextProvider> worker_context_provider) 18 scoped_refptr<ContextProvider> worker_context_provider)
19 : CompositorFrameSink(std::move(context_provider), 19 : CompositorFrameSink(std::move(context_provider),
20 std::move(worker_context_provider)) {} 20 std::move(worker_context_provider)),
21 weak_ptr_factory_(this) {}
21 22
22 FakeCompositorFrameSink::~FakeCompositorFrameSink() = default; 23 FakeCompositorFrameSink::~FakeCompositorFrameSink() = default;
23 24
24 void FakeCompositorFrameSink::SwapBuffers(CompositorFrame frame) { 25 void FakeCompositorFrameSink::SwapBuffers(CompositorFrame frame) {
25 ReturnResourcesHeldByParent(); 26 ReturnResourcesHeldByParent();
26 27
27 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); 28 last_sent_frame_.reset(new CompositorFrame(std::move(frame)));
28 ++num_sent_frames_; 29 ++num_sent_frames_;
29 30
30 if (last_sent_frame_->delegated_frame_data) { 31 if (last_sent_frame_->delegated_frame_data) {
31 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 32 auto* frame_data = last_sent_frame_->delegated_frame_data.get();
32 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect; 33 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect;
33 last_swap_rect_valid_ = true; 34 last_swap_rect_valid_ = true;
34 } else { 35 } else {
35 last_swap_rect_ = gfx::Rect(); 36 last_swap_rect_ = gfx::Rect();
36 last_swap_rect_valid_ = false; 37 last_swap_rect_valid_ = false;
37 } 38 }
38 39
39 if (last_sent_frame_->delegated_frame_data || !context_provider()) { 40 if (last_sent_frame_->delegated_frame_data || !context_provider()) {
40 if (last_sent_frame_->delegated_frame_data) { 41 if (last_sent_frame_->delegated_frame_data) {
41 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 42 auto* frame_data = last_sent_frame_->delegated_frame_data.get();
42 resources_held_by_parent_.insert(resources_held_by_parent_.end(), 43 resources_held_by_parent_.insert(resources_held_by_parent_.end(),
43 frame_data->resource_list.begin(), 44 frame_data->resource_list.begin(),
44 frame_data->resource_list.end()); 45 frame_data->resource_list.end());
45 } 46 }
46 } 47 }
47 48
48 PostSwapBuffersComplete(); 49 base::ThreadTaskRunnerHandle::Get()->PostTask(
50 FROM_HERE, base::Bind(&FakeCompositorFrameSink::SwapBuffersAck,
51 weak_ptr_factory_.GetWeakPtr()));
52 }
53
54 void FakeCompositorFrameSink::SwapBuffersAck() {
55 client_->DidSwapBuffersComplete();
49 } 56 }
50 57
51 bool FakeCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) { 58 bool FakeCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) {
52 if (CompositorFrameSink::BindToClient(client)) { 59 if (CompositorFrameSink::BindToClient(client)) {
53 client_ = client; 60 client_ = client;
54 return true; 61 return true;
55 } else { 62 } else {
56 return false; 63 return false;
57 } 64 }
58 } 65 }
(...skipping 10 matching lines...) Expand all
69 // Return the last frame's resources immediately. 76 // Return the last frame's resources immediately.
70 ReturnedResourceArray resources; 77 ReturnedResourceArray resources;
71 for (const auto& resource : resources_held_by_parent_) 78 for (const auto& resource : resources_held_by_parent_)
72 resources.push_back(resource.ToReturnedResource()); 79 resources.push_back(resource.ToReturnedResource());
73 resources_held_by_parent_.clear(); 80 resources_held_by_parent_.clear();
74 client_->ReclaimResources(resources); 81 client_->ReclaimResources(resources);
75 } 82 }
76 } 83 }
77 84
78 } // namespace cc 85 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_compositor_frame_sink.h ('k') | cc/test/fake_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698