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

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

Issue 2938833002: Add SurfaceWillDraw notification (Closed)
Patch Set: add unit test to verify that OnSurfaceWillDraw is called only for surfaces added to the CompositorF… Created 3 years, 6 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_surface_observer.h" 5 #include "cc/test/fake_surface_observer.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 FakeSurfaceObserver::FakeSurfaceObserver(bool damage_display) 9 FakeSurfaceObserver::FakeSurfaceObserver(bool damage_display)
10 : damage_display_(damage_display) {} 10 : damage_display_(damage_display) {}
11 11
12 FakeSurfaceObserver::~FakeSurfaceObserver() {} 12 FakeSurfaceObserver::~FakeSurfaceObserver() {}
13 13
14 void FakeSurfaceObserver::Reset() { 14 void FakeSurfaceObserver::Reset() {
15 last_ack_ = BeginFrameAck(); 15 last_ack_ = BeginFrameAck();
16 damaged_surfaces_.clear(); 16 damaged_surfaces_.clear();
17 will_draw_surfaces_.clear();
17 last_surface_info_ = SurfaceInfo(); 18 last_surface_info_ = SurfaceInfo();
18 last_created_surface_id_ = SurfaceId(); 19 last_created_surface_id_ = SurfaceId();
19 } 20 }
20 21
21 bool FakeSurfaceObserver::IsSurfaceDamaged(const SurfaceId& surface_id) const { 22 bool FakeSurfaceObserver::IsSurfaceDamaged(const SurfaceId& surface_id) const {
22 return damaged_surfaces_.count(surface_id) > 0; 23 return damaged_surfaces_.count(surface_id) > 0;
23 } 24 }
24 25
26 bool FakeSurfaceObserver::SurfaceWillDrawCalled(
27 const SurfaceId& surface_id) const {
28 return will_draw_surfaces_.count(surface_id) > 0;
29 }
30
25 bool FakeSurfaceObserver::OnSurfaceDamaged(const SurfaceId& surface_id, 31 bool FakeSurfaceObserver::OnSurfaceDamaged(const SurfaceId& surface_id,
26 const BeginFrameAck& ack) { 32 const BeginFrameAck& ack) {
27 if (ack.has_damage) 33 if (ack.has_damage)
28 damaged_surfaces_.insert(surface_id); 34 damaged_surfaces_.insert(surface_id);
29 last_ack_ = ack; 35 last_ack_ = ack;
30 return ack.has_damage && damage_display_; 36 return ack.has_damage && damage_display_;
31 } 37 }
32 38
39 void FakeSurfaceObserver::OnSurfaceWillDraw(const SurfaceId& surface_id) {
40 will_draw_surfaces_.insert(surface_id);
41 }
42
33 void FakeSurfaceObserver::OnSurfaceCreated(const SurfaceInfo& surface_info) { 43 void FakeSurfaceObserver::OnSurfaceCreated(const SurfaceInfo& surface_info) {
34 last_created_surface_id_ = surface_info.id(); 44 last_created_surface_id_ = surface_info.id();
35 last_surface_info_ = surface_info; 45 last_surface_info_ = surface_info;
36 } 46 }
37 47
38 } // namespace cc 48 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_surface_observer.h ('k') | components/viz/service/frame_sinks/mojo_frame_sink_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698