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

Side by Side Diff: remoting/test/cyclic_frame_generator.cc

Issue 2431513003: Revert of Don't use barcodes in ProtocolPerfTests (Closed)
Patch Set: 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 | « remoting/test/cyclic_frame_generator.h ('k') | remoting/test/frame_generator_util.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/test/cyclic_frame_generator.h" 5 #include "remoting/test/cyclic_frame_generator.h"
6 6
7 #include "base/time/default_tick_clock.h" 7 #include "base/time/default_tick_clock.h"
8 #include "remoting/test/frame_generator_util.h" 8 #include "remoting/test/frame_generator_util.h"
9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
10 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 10 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
(...skipping 30 matching lines...) Expand all
41 CyclicFrameGenerator::~CyclicFrameGenerator() {} 41 CyclicFrameGenerator::~CyclicFrameGenerator() {}
42 42
43 void CyclicFrameGenerator::SetTickClock(base::TickClock* tick_clock) { 43 void CyclicFrameGenerator::SetTickClock(base::TickClock* tick_clock) {
44 clock_ = tick_clock; 44 clock_ = tick_clock;
45 started_time_ = clock_->NowTicks(); 45 started_time_ = clock_->NowTicks();
46 } 46 }
47 47
48 std::unique_ptr<webrtc::DesktopFrame> CyclicFrameGenerator::GenerateFrame( 48 std::unique_ptr<webrtc::DesktopFrame> CyclicFrameGenerator::GenerateFrame(
49 webrtc::SharedMemoryFactory* shared_memory_factory) { 49 webrtc::SharedMemoryFactory* shared_memory_factory) {
50 base::TimeTicks now = clock_->NowTicks(); 50 base::TimeTicks now = clock_->NowTicks();
51
52 int frame_id = (now - started_time_) / cursor_blink_period_; 51 int frame_id = (now - started_time_) / cursor_blink_period_;
53 int reference_frame = 52 int reference_frame =
54 ((now - started_time_) / frame_cycle_period_) % reference_frames_.size(); 53 ((now - started_time_) / frame_cycle_period_) % reference_frames_.size();
55 bool cursor_state = frame_id % 2; 54 bool cursor_state = frame_id % 2;
56 55
57 std::unique_ptr<webrtc::DesktopFrame> frame( 56 std::unique_ptr<webrtc::DesktopFrame> frame(
58 new webrtc::BasicDesktopFrame(screen_size_)); 57 new webrtc::BasicDesktopFrame(screen_size_));
59 frame->CopyPixelsFrom(*reference_frames_[reference_frame], 58 frame->CopyPixelsFrom(*reference_frames_[reference_frame],
60 webrtc::DesktopVector(), 59 webrtc::DesktopVector(),
61 webrtc::DesktopRect::MakeSize(screen_size_)); 60 webrtc::DesktopRect::MakeSize(screen_size_));
(...skipping 12 matching lines...) Expand all
74 last_frame_type_ = ChangeType::FULL; 73 last_frame_type_ = ChangeType::FULL;
75 } else if (last_cursor_state_ != cursor_state) { 74 } else if (last_cursor_state_ != cursor_state) {
76 // Cursor state has changed. 75 // Cursor state has changed.
77 frame->mutable_updated_region()->AddRect(cursor_rect); 76 frame->mutable_updated_region()->AddRect(cursor_rect);
78 last_frame_type_ = ChangeType::CURSOR; 77 last_frame_type_ = ChangeType::CURSOR;
79 } else { 78 } else {
80 // No changes. 79 // No changes.
81 last_frame_type_ = ChangeType::NO_CHANGES; 80 last_frame_type_ = ChangeType::NO_CHANGES;
82 } 81 }
83 82
83 if (draw_barcode_)
84 DrawBarcode(frame_id, frame_id != last_frame_id_, frame.get());
85
84 last_reference_frame_ = reference_frame; 86 last_reference_frame_ = reference_frame;
85 last_cursor_state_ = cursor_state; 87 last_cursor_state_ = cursor_state;
88 last_frame_id_ = frame_id;
86 89
87 return frame; 90 return frame;
88 } 91 }
89 92
90 CyclicFrameGenerator::ChangeInfoList CyclicFrameGenerator::GetChangeList( 93 CyclicFrameGenerator::ChangeInfoList CyclicFrameGenerator::GetChangeList(
91 base::TimeTicks timestamp) { 94 webrtc::DesktopFrame* frame) {
92 int frame_id = (timestamp - started_time_) / cursor_blink_period_; 95 CHECK(draw_barcode_);
96 int frame_id = ReadBarcode(*frame);
93 CHECK_GE(frame_id, last_identifier_frame_); 97 CHECK_GE(frame_id, last_identifier_frame_);
94 98
95 ChangeInfoList result; 99 ChangeInfoList result;
96 for (int i = last_identifier_frame_ + 1; i <= frame_id; ++i) { 100 for (int i = last_identifier_frame_ + 1; i <= frame_id; ++i) {
97 ChangeType type = (i % (frame_cycle_period_ / cursor_blink_period_) == 0) 101 ChangeType type = (i % (frame_cycle_period_ / cursor_blink_period_) == 0)
98 ? ChangeType::FULL 102 ? ChangeType::FULL
99 : ChangeType::CURSOR; 103 : ChangeType::CURSOR;
100 base::TimeTicks timestamp = 104 base::TimeTicks timestamp =
101 started_time_ + i * base::TimeDelta(cursor_blink_period_); 105 started_time_ + i * base::TimeDelta(cursor_blink_period_);
102 result.push_back(ChangeInfo(type, timestamp)); 106 result.push_back(ChangeInfo(type, timestamp));
103 } 107 }
104 last_identifier_frame_ = frame_id; 108 last_identifier_frame_ = frame_id;
105 109
106 return result; 110 return result;
107 } 111 }
108 112
109 protocol::InputEventTimestamps CyclicFrameGenerator::TakeLastEventTimestamps() {
110 base::TimeTicks now = clock_->NowTicks();
111 return protocol::InputEventTimestamps{now, now};
112 }
113
114 } // namespace test 113 } // namespace test
115 } // namespace remoting 114 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/cyclic_frame_generator.h ('k') | remoting/test/frame_generator_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698