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

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

Issue 2420183002: Don't use barcodes in ProtocolPerfTests (Closed)
Patch Set: Update ChromotingHost::OnSessionAuthenticated() to fix test crash 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
51 int frame_id = (now - started_time_) / cursor_blink_period_; 52 int frame_id = (now - started_time_) / cursor_blink_period_;
52 int reference_frame = 53 int reference_frame =
53 ((now - started_time_) / frame_cycle_period_) % reference_frames_.size(); 54 ((now - started_time_) / frame_cycle_period_) % reference_frames_.size();
54 bool cursor_state = frame_id % 2; 55 bool cursor_state = frame_id % 2;
55 56
56 std::unique_ptr<webrtc::DesktopFrame> frame( 57 std::unique_ptr<webrtc::DesktopFrame> frame(
57 new webrtc::BasicDesktopFrame(screen_size_)); 58 new webrtc::BasicDesktopFrame(screen_size_));
58 frame->CopyPixelsFrom(*reference_frames_[reference_frame], 59 frame->CopyPixelsFrom(*reference_frames_[reference_frame],
59 webrtc::DesktopVector(), 60 webrtc::DesktopVector(),
60 webrtc::DesktopRect::MakeSize(screen_size_)); 61 webrtc::DesktopRect::MakeSize(screen_size_));
(...skipping 12 matching lines...) Expand all
73 last_frame_type_ = ChangeType::FULL; 74 last_frame_type_ = ChangeType::FULL;
74 } else if (last_cursor_state_ != cursor_state) { 75 } else if (last_cursor_state_ != cursor_state) {
75 // Cursor state has changed. 76 // Cursor state has changed.
76 frame->mutable_updated_region()->AddRect(cursor_rect); 77 frame->mutable_updated_region()->AddRect(cursor_rect);
77 last_frame_type_ = ChangeType::CURSOR; 78 last_frame_type_ = ChangeType::CURSOR;
78 } else { 79 } else {
79 // No changes. 80 // No changes.
80 last_frame_type_ = ChangeType::NO_CHANGES; 81 last_frame_type_ = ChangeType::NO_CHANGES;
81 } 82 }
82 83
83 if (draw_barcode_)
84 DrawBarcode(frame_id, frame_id != last_frame_id_, frame.get());
85
86 last_reference_frame_ = reference_frame; 84 last_reference_frame_ = reference_frame;
87 last_cursor_state_ = cursor_state; 85 last_cursor_state_ = cursor_state;
88 last_frame_id_ = frame_id;
89 86
90 return frame; 87 return frame;
91 } 88 }
92 89
93 CyclicFrameGenerator::ChangeInfoList CyclicFrameGenerator::GetChangeList( 90 CyclicFrameGenerator::ChangeInfoList CyclicFrameGenerator::GetChangeList(
94 webrtc::DesktopFrame* frame) { 91 base::TimeTicks timestamp) {
95 CHECK(draw_barcode_); 92 int frame_id = (timestamp - started_time_) / cursor_blink_period_;
96 int frame_id = ReadBarcode(*frame);
97 CHECK_GE(frame_id, last_identifier_frame_); 93 CHECK_GE(frame_id, last_identifier_frame_);
98 94
99 ChangeInfoList result; 95 ChangeInfoList result;
100 for (int i = last_identifier_frame_ + 1; i <= frame_id; ++i) { 96 for (int i = last_identifier_frame_ + 1; i <= frame_id; ++i) {
101 ChangeType type = (i % (frame_cycle_period_ / cursor_blink_period_) == 0) 97 ChangeType type = (i % (frame_cycle_period_ / cursor_blink_period_) == 0)
102 ? ChangeType::FULL 98 ? ChangeType::FULL
103 : ChangeType::CURSOR; 99 : ChangeType::CURSOR;
104 base::TimeTicks timestamp = 100 base::TimeTicks timestamp =
105 started_time_ + i * base::TimeDelta(cursor_blink_period_); 101 started_time_ + i * base::TimeDelta(cursor_blink_period_);
106 result.push_back(ChangeInfo(type, timestamp)); 102 result.push_back(ChangeInfo(type, timestamp));
107 } 103 }
108 last_identifier_frame_ = frame_id; 104 last_identifier_frame_ = frame_id;
109 105
110 return result; 106 return result;
111 } 107 }
112 108
109 protocol::InputEventTimestamps CyclicFrameGenerator::TakeLastEventTimestamps() {
110 base::TimeTicks now = clock_->NowTicks();
111 return protocol::InputEventTimestamps{now, now};
112 }
113
113 } // namespace test 114 } // namespace test
114 } // namespace remoting 115 } // 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