summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-14 02:35:16 +0000
committerjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-14 02:35:16 +0000
commit611c31573a92d6db8b3117f15c5bf26c66923f82 (patch)
treeb57678064bd1ff4b7b9d112e71a635fd2771bcb1
parent6cb8334d0d92097a3a91d0499223b59868ffac51 (diff)
downloadchromium_src-611c31573a92d6db8b3117f15c5bf26c66923f82.zip
chromium_src-611c31573a92d6db8b3117f15c5bf26c66923f82.tar.gz
chromium_src-611c31573a92d6db8b3117f15c5bf26c66923f82.tar.bz2
Add DPI information to video packets.
The intention is that capturers can add this information and the client can make use of it to up-scale the desktop if it DPI is larger than that of the host by an integer multiple. For example, a standard-DPI host viewed on a retina-display Macbook Pro would no longer look tiny. BUG=135089 TEST=EncoderVp8Test.TestDpiPropagation Review URL: https://chromiumcodereview.appspot.com/10736046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146715 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/base/capture_data.cc5
-rw-r--r--remoting/base/capture_data.h7
-rw-r--r--remoting/base/encoder_row_based.cc5
-rw-r--r--remoting/base/encoder_vp8.cc5
-rw-r--r--remoting/base/encoder_vp8_unittest.cc31
-rw-r--r--remoting/proto/video.proto5
6 files changed, 56 insertions, 2 deletions
diff --git a/remoting/base/capture_data.cc b/remoting/base/capture_data.cc
index 4daa8dd..fb0d582 100644
--- a/remoting/base/capture_data.cc
+++ b/remoting/base/capture_data.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -20,7 +20,8 @@ CaptureData::CaptureData(const DataPlanes &data_planes,
size_(size),
pixel_format_(format),
capture_time_ms_(0),
- client_sequence_number_(0) {
+ client_sequence_number_(0),
+ dpi_(SkIPoint::Make(0, 0)) {
}
CaptureData::~CaptureData() {}
diff --git a/remoting/base/capture_data.h b/remoting/base/capture_data.h
index cea18ac..7e65b37 100644
--- a/remoting/base/capture_data.h
+++ b/remoting/base/capture_data.h
@@ -59,6 +59,10 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> {
client_sequence_number_ = client_sequence_number;
}
+ SkIPoint dpi() const { return dpi_; }
+
+ void set_dpi(const SkIPoint& dpi) { dpi_ = dpi; }
+
private:
friend class base::RefCountedThreadSafe<CaptureData>;
virtual ~CaptureData();
@@ -73,6 +77,9 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> {
// Sequence number supplied by client for performance tracking.
int64 client_sequence_number_;
+
+ // DPI for this frame.
+ SkIPoint dpi_;
};
} // namespace remoting
diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc
index 41d9e9e..c28c06c 100644
--- a/remoting/base/encoder_row_based.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -124,6 +124,11 @@ void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
packet->set_capture_time_ms(capture_data_->capture_time_ms());
packet->set_client_sequence_number(
capture_data_->client_sequence_number());
+ SkIPoint dpi(capture_data_->dpi());
+ if (dpi.x())
+ packet->mutable_format()->set_x_dpi(dpi.x());
+ if (dpi.y())
+ packet->mutable_format()->set_y_dpi(dpi.y());
if (last)
packet->set_flags(packet->flags() | VideoPacket::LAST_PARTITION);
DCHECK(row_pos == row_size);
diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc
index 2d8ae77..83fbffe 100644
--- a/remoting/base/encoder_vp8.cc
+++ b/remoting/base/encoder_vp8.cc
@@ -293,6 +293,11 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data,
packet->mutable_format()->set_screen_height(capture_data->size().height());
packet->set_capture_time_ms(capture_data->capture_time_ms());
packet->set_client_sequence_number(capture_data->client_sequence_number());
+ SkIPoint dpi(capture_data->dpi());
+ if (dpi.x())
+ packet->mutable_format()->set_x_dpi(dpi.x());
+ if (dpi.y())
+ packet->mutable_format()->set_y_dpi(dpi.y());
for (SkRegion::Iterator r(updated_region); !r.done(); r.next()) {
Rect* rect = packet->add_dirty_rects();
rect->set_x(r.rect().x());
diff --git a/remoting/base/encoder_vp8_unittest.cc b/remoting/base/encoder_vp8_unittest.cc
index 0060869..3f7f11c 100644
--- a/remoting/base/encoder_vp8_unittest.cc
+++ b/remoting/base/encoder_vp8_unittest.cc
@@ -62,4 +62,35 @@ TEST(EncoderVp8Test, TestSizeChangeNoLeak) {
base::Unretained(&callback)));
}
+class EncoderDpiCallback {
+ public:
+ void DataAvailable(scoped_ptr<VideoPacket> packet) {
+ EXPECT_EQ(packet->format().x_dpi(), 96);
+ EXPECT_EQ(packet->format().y_dpi(), 97);
+ }
+};
+
+// Test that the DPI information is correctly propagated from the CaptureData
+// to the VideoPacket.
+TEST(EncoderVp8Test, TestDpiPropagation) {
+ int height = 1;
+ int width = 1;
+ const int kBytesPerPixel = 4;
+
+ EncoderVp8 encoder;
+ EncoderDpiCallback callback;
+
+ std::vector<uint8> buffer(width * height * kBytesPerPixel);
+ DataPlanes planes;
+ planes.data[0] = &buffer.front();
+ planes.strides[0] = width;
+
+ scoped_refptr<CaptureData> capture_data(new CaptureData(
+ planes, SkISize::Make(width, height), media::VideoFrame::RGB32));
+ capture_data->set_dpi(SkIPoint::Make(96, 97));
+ encoder.Encode(capture_data, false,
+ base::Bind(&EncoderDpiCallback::DataAvailable,
+ base::Unretained(&callback)));
+}
+
} // namespace remoting
diff --git a/remoting/proto/video.proto b/remoting/proto/video.proto
index 14415af..01c57d4 100644
--- a/remoting/proto/video.proto
+++ b/remoting/proto/video.proto
@@ -33,6 +33,11 @@ message VideoPacketFormat {
// Width and height of the whole screen.
optional int32 screen_width = 6;
optional int32 screen_height = 7;
+
+ // Horizontal and vertical DPI of the screen. If either of these is zero or
+ // unset, the corresponding DPI should be assumed to be 96 (Windows' default)
+ optional int32 x_dpi = 8;
+ optional int32 y_dpi = 9;
}
// TODO(hclam): Remove this message once we can obtain dirty rects from libvpx.