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

Unified Diff: remoting/test/scroll_frame_generator.cc

Issue 2182833002: Add scroll perf test for protocol in chromoting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gyp Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/test/scroll_frame_generator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/test/scroll_frame_generator.cc
diff --git a/remoting/test/scroll_frame_generator.cc b/remoting/test/scroll_frame_generator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1a6a1ec0b6834d89306d5a3dffc81980f8141410
--- /dev/null
+++ b/remoting/test/scroll_frame_generator.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/test/scroll_frame_generator.h"
+
+#include "remoting/test/frame_generator_util.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+
+namespace remoting {
+namespace test {
+
+namespace {
+int kScrollSpeedPixelsPerSecond = 500;
+} // namespace
+
+ScrollFrameGenerator::ScrollFrameGenerator()
+ : base_frame_(LoadDesktopFrameFromPng("test_frame2.png")),
+ start_time_(base::TimeTicks::Now()) {}
+ScrollFrameGenerator::~ScrollFrameGenerator() {}
+
+std::unique_ptr<webrtc::DesktopFrame> ScrollFrameGenerator::GenerateFrame(
+ webrtc::SharedMemoryFactory* shared_memory_factory) {
+ base::TimeTicks now = base::TimeTicks::Now();
+ int position = static_cast<int>(kScrollSpeedPixelsPerSecond *
+ (now - start_time_).InSecondsF()) %
+ base_frame_->size().height();
+ std::unique_ptr<webrtc::DesktopFrame> result(
+ new webrtc::BasicDesktopFrame(base_frame_->size()));
+
+ int top_height = base_frame_->size().height() - position;
+
+ result->CopyPixelsFrom(*base_frame_, webrtc::DesktopVector(0, position),
+ webrtc::DesktopRect::MakeLTRB(
+ 0, 0, base_frame_->size().width(), top_height));
+ result->CopyPixelsFrom(
+ *base_frame_, webrtc::DesktopVector(0, 0),
+ webrtc::DesktopRect::MakeLTRB(0, top_height, base_frame_->size().width(),
+ base_frame_->size().height()));
+
+ result->mutable_updated_region()->SetRect(
+ webrtc::DesktopRect::MakeSize(result->size()));
+
+ ++last_frame_id_;
+ frame_timestamp_[last_frame_id_] = now;
+ DrawBarcode(last_frame_id_, true, result.get());
+
+ return result;
+}
+
+base::TimeDelta ScrollFrameGenerator::GetFrameLatency(
+ const webrtc::DesktopFrame& frame) {
+ int frame_id = ReadBarcode(frame);
+ if (!frame_timestamp_.count(frame_id))
+ LOG(FATAL) << "Unknown frame_id.";
+ return base::TimeTicks::Now() - frame_timestamp_[frame_id];
+}
+
+} // namespace test
+} // namespace remoting
« no previous file with comments | « remoting/test/scroll_frame_generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698