diff options
author | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-20 03:02:58 +0000 |
---|---|---|
committer | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-20 03:02:58 +0000 |
commit | 67809c080e613e92eea5f3241b8e797ce4185edb (patch) | |
tree | c4ae9246dac0d6784ee9fb2b332de5c4ce8de46b /remoting | |
parent | a7fe9110edf7ad578f19655e6d86030cc01e53e2 (diff) | |
download | chromium_src-67809c080e613e92eea5f3241b8e797ce4185edb.zip chromium_src-67809c080e613e92eea5f3241b8e797ce4185edb.tar.gz chromium_src-67809c080e613e92eea5f3241b8e797ce4185edb.tar.bz2 |
Propagate DPI information to web-app.
BUG=135089
TEST=
Review URL: https://chromiumcodereview.appspot.com/10801003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/frame_consumer.h | 3 | ||||
-rw-r--r-- | remoting/client/frame_consumer_proxy.cc | 7 | ||||
-rw-r--r-- | remoting/client/frame_consumer_proxy.h | 3 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 11 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.h | 4 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.cc | 9 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.h | 6 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.cc | 22 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.h | 3 | ||||
-rw-r--r-- | remoting/webapp/client_plugin.js | 4 | ||||
-rw-r--r-- | remoting/webapp/client_plugin_async.js | 6 | ||||
-rw-r--r-- | remoting/webapp/client_session.js | 4 |
12 files changed, 62 insertions, 20 deletions
diff --git a/remoting/client/frame_consumer.h b/remoting/client/frame_consumer.h index 22701f4..a315054 100644 --- a/remoting/client/frame_consumer.h +++ b/remoting/client/frame_consumer.h @@ -36,7 +36,8 @@ class FrameConsumer { virtual void ReturnBuffer(pp::ImageData* buffer) = 0; // Set the dimension of the entire host screen. - virtual void SetSourceSize(const SkISize& source_size) = 0; + virtual void SetSourceSize(const SkISize& source_size, + const SkIPoint& dpi) = 0; protected: FrameConsumer() {} diff --git a/remoting/client/frame_consumer_proxy.cc b/remoting/client/frame_consumer_proxy.cc index 11ac1e3..cce34f1 100644 --- a/remoting/client/frame_consumer_proxy.cc +++ b/remoting/client/frame_consumer_proxy.cc @@ -42,15 +42,16 @@ void FrameConsumerProxy::ReturnBuffer(pp::ImageData* buffer) { frame_consumer_->ReturnBuffer(buffer); } -void FrameConsumerProxy::SetSourceSize(const SkISize& source_size) { +void FrameConsumerProxy::SetSourceSize(const SkISize& source_size, + const SkIPoint& source_dpi) { if (!task_runner_->BelongsToCurrentThread()) { task_runner_->PostTask(FROM_HERE, base::Bind( - &FrameConsumerProxy::SetSourceSize, this, source_size)); + &FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi)); return; } if (frame_consumer_) - frame_consumer_->SetSourceSize(source_size); + frame_consumer_->SetSourceSize(source_size, source_dpi); } void FrameConsumerProxy::Attach( diff --git a/remoting/client/frame_consumer_proxy.h b/remoting/client/frame_consumer_proxy.h index d5dfd45..58bbd7d 100644 --- a/remoting/client/frame_consumer_proxy.h +++ b/remoting/client/frame_consumer_proxy.h @@ -34,7 +34,8 @@ class FrameConsumerProxy pp::ImageData* buffer, const SkRegion& region) OVERRIDE; virtual void ReturnBuffer(pp::ImageData* buffer) OVERRIDE; - virtual void SetSourceSize(const SkISize& source_size) OVERRIDE; + virtual void SetSourceSize(const SkISize& source_size, + const SkIPoint& dpi) OVERRIDE; // Attaches to |frame_consumer_|. // This must only be called from |frame_consumer_message_loop_|. diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 77cd55f..ea212b2 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -352,10 +352,15 @@ bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { return input_handler_->HandleInputEvent(event); } -void ChromotingInstance::SetDesktopSize(int width, int height) { +void ChromotingInstance::SetDesktopSize(const SkISize& size, + const SkIPoint& dpi) { scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); - data->SetInteger("width", width); - data->SetInteger("height", height); + data->SetInteger("width", size.width()); + data->SetInteger("height", size.height()); + if (dpi.x()) + data->SetInteger("x_dpi", dpi.x()); + if (dpi.y()) + data->SetInteger("y_dpi", dpi.y()); PostChromotingMessage("onDesktopSize", data.Pass()); } diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h index dbc840d..c00f57b 100644 --- a/remoting/client/plugin/chromoting_instance.h +++ b/remoting/client/plugin/chromoting_instance.h @@ -17,6 +17,8 @@ #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/cpp/var.h" +#include "third_party/skia/include/core/SkPoint.h" +#include "third_party/skia/include/core/SkSize.h" // Windows defines 'PostMessage', so we have to undef it before we // include instance_private.h @@ -132,7 +134,7 @@ class ChromotingInstance : OVERRIDE; // Called by PepperView. - void SetDesktopSize(int width, int height); + void SetDesktopSize(const SkISize& size, const SkIPoint& dpi); void SetConnectionState(ConnectionState state, ConnectionError error); void OnFirstFrameReceived(); diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index 35976e4..0d19b88 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -77,6 +77,7 @@ PepperView::PepperView(ChromotingInstance* instance, view_size_(SkISize::Make(0, 0)), clip_area_(SkIRect::MakeEmpty()), source_size_(SkISize::Make(0, 0)), + source_dpi_(SkIPoint::Make(0, 0)), flush_pending_(false), is_initialized_(false), frame_received_(false) { @@ -227,16 +228,18 @@ void PepperView::ReturnBuffer(pp::ImageData* buffer) { } } -void PepperView::SetSourceSize(const SkISize& source_size) { +void PepperView::SetSourceSize(const SkISize& source_size, + const SkIPoint& source_dpi) { DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); - if (source_size_ == source_size) + if (source_size_ == source_size && source_dpi_ == source_dpi) return; source_size_ = source_size; + source_dpi_ = source_dpi; // Notify JavaScript of the change in source size. - instance_->SetDesktopSize(source_size.width(), source_size.height()); + instance_->SetDesktopSize(source_size, source_dpi); } pp::ImageData* PepperView::AllocateBuffer() { diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h index 949703a..9cfa8b8 100644 --- a/remoting/client/plugin/pepper_view.h +++ b/remoting/client/plugin/pepper_view.h @@ -48,7 +48,8 @@ class PepperView : public ChromotingView, pp::ImageData* buffer, const SkRegion& region) OVERRIDE; virtual void ReturnBuffer(pp::ImageData* buffer) OVERRIDE; - virtual void SetSourceSize(const SkISize& source_size) OVERRIDE; + virtual void SetSourceSize(const SkISize& source_size, + const SkIPoint& dpi) OVERRIDE; // Sets the display size and clipping area of this view. void SetView(const SkISize& view_size, const SkIRect& clip_area); @@ -110,6 +111,9 @@ class PepperView : public ChromotingView, // The size of the host screen. SkISize source_size_; + // The DPI of the host screen. + SkIPoint source_dpi_; + // True if there is already a Flush() pending on the Graphics2D context. bool flush_pending_; diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index ffc95f0..1b4a771 100644 --- a/remoting/client/rectangle_update_decoder.cc +++ b/remoting/client/rectangle_update_decoder.cc @@ -30,6 +30,7 @@ RectangleUpdateDecoder::RectangleUpdateDecoder( : task_runner_(task_runner), consumer_(consumer), source_size_(SkISize::Make(0, 0)), + source_dpi_(SkIPoint::Make(0, 0)), view_size_(SkISize::Make(0, 0)), clip_area_(SkIRect::MakeEmpty()), paint_scheduled_(false) { @@ -63,8 +64,9 @@ void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet, base::ScopedClosureRunner done_runner(done); bool decoder_needs_reset = false; + bool notify_size_or_dpi_change = false; - // If the packet includes a screen size, store it. + // If the packet includes screen size or DPI information, store them. if (packet->format().has_screen_width() && packet->format().has_screen_height()) { SkISize source_size = SkISize::Make(packet->format().screen_width(), @@ -72,18 +74,26 @@ void RectangleUpdateDecoder::DecodePacket(scoped_ptr<VideoPacket> packet, if (source_size_ != source_size) { source_size_ = source_size; decoder_needs_reset = true; + notify_size_or_dpi_change = true; + } + } + if (packet->format().has_x_dpi() && packet->format().has_y_dpi()) { + SkIPoint source_dpi(SkIPoint::Make(packet->format().x_dpi(), + packet->format().y_dpi())); + if (source_dpi != source_dpi_) { + source_dpi_ = source_dpi; + notify_size_or_dpi_change = true; } } // If we've never seen a screen size, ignore the packet. - if (source_size_.isZero()) { + if (source_size_.isZero()) return; - } - if (decoder_needs_reset) { + if (decoder_needs_reset) decoder_->Initialize(source_size_); - consumer_->SetSourceSize(source_size_); - } + if (notify_size_or_dpi_change) + consumer_->SetSourceSize(source_size_, source_dpi_); if (!decoder_->IsReadyForData()) { // TODO(ajwong): This whole thing should move into an invalid state. diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index 557aee2..fdee520 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -75,6 +75,9 @@ class RectangleUpdateDecoder // Remote screen size in pixels. SkISize source_size_; + // Vertical and horizontal DPI of the remote screen. + SkIPoint source_dpi_; + // The current dimentions of the frame consumer view. SkISize view_size_; SkIRect clip_area_; diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js index 9210ab7..c6b66ef 100644 --- a/remoting/webapp/client_plugin.js +++ b/remoting/webapp/client_plugin.js @@ -16,6 +16,10 @@ remoting.ClientPlugin = function() { remoting.ClientPlugin.prototype.desktopWidth; /** @type {number} Desktop height */ remoting.ClientPlugin.prototype.desktopHeight; +/** @type {number} Desktop x DPI */ +remoting.ClientPlugin.prototype.desktopXDpi; +/** @type {number} Desktop y DPI */ +remoting.ClientPlugin.prototype.desktopYDpi; /** @type {function(string): void} Outgoing signaling message callback. */ remoting.ClientPlugin.prototype.onOutgoingIqHandler; diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js index e57902eb..dd1b5cd 100644 --- a/remoting/webapp/client_plugin_async.js +++ b/remoting/webapp/client_plugin_async.js @@ -26,6 +26,8 @@ remoting.ClientPluginAsync = function(plugin) { this.desktopWidth = 0; this.desktopHeight = 0; + this.desktopXDpi = 96; + this.desktopYDpi = 96; /** @param {string} iq The Iq stanza received from the host. */ this.onOutgoingIqHandler = function (iq) {}; @@ -162,6 +164,10 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) { } this.desktopWidth = /** @type {number} */ message.data['width']; this.desktopHeight = /** @type {number} */ message.data['height']; + this.desktopXDpi = (typeof message.data['x_dpi'] == 'number') ? + /** @type {number} */ (message.data['x_dpi']) : 96; + this.desktopYDpi = (typeof message.data['y_dpi'] == 'number') ? + /** @type {number} */ (message.data['y_dpi']) : 96; this.onDesktopSizeUpdateHandler(); } else if (message.method == 'onPerfStats') { if (typeof message.data['videoBandwidth'] != 'number' || diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js index fbd38d3..24a5d23 100644 --- a/remoting/webapp/client_session.js +++ b/remoting/webapp/client_session.js @@ -555,7 +555,9 @@ remoting.ClientSession.prototype.pauseVideo = function(pause) { remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() { console.log('desktop size changed: ' + this.plugin.desktopWidth + 'x' + - this.plugin.desktopHeight); + this.plugin.desktopHeight +' @ ' + + this.plugin.desktopXDpi + 'x' + + this.plugin.desktopYDpi + ' DPI'); this.updateDimensions(); }; |