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

Side by Side Diff: remoting/client/rectangle_update_decoder.cc

Issue 10801003: Propagate DPI information to web-app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed typo. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/client/rectangle_update_decoder.h" 5 #include "remoting/client/rectangle_update_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 12 matching lines...) Expand all
23 using remoting::protocol::SessionConfig; 23 using remoting::protocol::SessionConfig;
24 24
25 namespace remoting { 25 namespace remoting {
26 26
27 RectangleUpdateDecoder::RectangleUpdateDecoder( 27 RectangleUpdateDecoder::RectangleUpdateDecoder(
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
29 scoped_refptr<FrameConsumerProxy> consumer) 29 scoped_refptr<FrameConsumerProxy> consumer)
30 : task_runner_(task_runner), 30 : task_runner_(task_runner),
31 consumer_(consumer), 31 consumer_(consumer),
32 source_size_(SkISize::Make(0, 0)), 32 source_size_(SkISize::Make(0, 0)),
33 source_dpi_(SkIPoint::Make(0, 0)),
33 view_size_(SkISize::Make(0, 0)), 34 view_size_(SkISize::Make(0, 0)),
34 clip_area_(SkIRect::MakeEmpty()), 35 clip_area_(SkIRect::MakeEmpty()),
35 paint_scheduled_(false) { 36 paint_scheduled_(false) {
36 } 37 }
37 38
38 RectangleUpdateDecoder::~RectangleUpdateDecoder() { 39 RectangleUpdateDecoder::~RectangleUpdateDecoder() {
39 } 40 }
40 41
41 void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { 42 void RectangleUpdateDecoder::Initialize(const SessionConfig& config) {
42 // Initialize decoder based on the selected codec. 43 // Initialize decoder based on the selected codec.
(...skipping 25 matching lines...) Expand all
68 if (packet->format().has_screen_width() && 69 if (packet->format().has_screen_width() &&
69 packet->format().has_screen_height()) { 70 packet->format().has_screen_height()) {
70 SkISize source_size = SkISize::Make(packet->format().screen_width(), 71 SkISize source_size = SkISize::Make(packet->format().screen_width(),
71 packet->format().screen_height()); 72 packet->format().screen_height());
72 if (source_size_ != source_size) { 73 if (source_size_ != source_size) {
73 source_size_ = source_size; 74 source_size_ = source_size;
74 decoder_needs_reset = true; 75 decoder_needs_reset = true;
75 } 76 }
76 } 77 }
77 78
79 // If the source DPI has changed, store it. 96 is the default DPI as defined
80 // in video.proto.
81 SkIPoint source_dpi(SkIPoint::Make(packet->format().x_dpi(),
82 packet->format().y_dpi()));
83 if (source_dpi.x() == 0) {
84 source_dpi.setX(96);
Wez 2012/07/19 01:00:42 See comment elsewhere re faking the DPI here.
Jamie 2012/07/19 23:00:06 Done.
85 }
86 if (source_dpi.y() == 0) {
87 source_dpi.setY(96);
88 }
89 if (source_dpi != source_dpi_) {
90 source_dpi_ = source_dpi;
91 decoder_needs_reset = true;
92 }
93
78 // If we've never seen a screen size, ignore the packet. 94 // If we've never seen a screen size, ignore the packet.
79 if (source_size_.isZero()) { 95 if (source_size_.isZero()) {
80 return; 96 return;
81 } 97 }
82 98
83 if (decoder_needs_reset) { 99 if (decoder_needs_reset) {
84 decoder_->Initialize(source_size_); 100 decoder_->Initialize(source_size_);
85 consumer_->SetSourceSize(source_size_); 101 consumer_->SetSourceSize(source_size_, source_dpi_);
86 } 102 }
87 103
88 if (!decoder_->IsReadyForData()) { 104 if (!decoder_->IsReadyForData()) {
89 // TODO(ajwong): This whole thing should move into an invalid state. 105 // TODO(ajwong): This whole thing should move into an invalid state.
90 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; 106 LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
91 return; 107 return;
92 } 108 }
93 109
94 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE) 110 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE)
95 SchedulePaint(); 111 SchedulePaint();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } else { 225 } else {
210 ++i; 226 ++i;
211 } 227 }
212 } 228 }
213 229
214 SchedulePaint(); 230 SchedulePaint();
215 } 231 }
216 } 232 }
217 233
218 } // namespace remoting 234 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698