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

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: Reviewer comments. 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 14 matching lines...) Expand all
57 if (!task_runner_->BelongsToCurrentThread()) { 58 if (!task_runner_->BelongsToCurrentThread()) {
58 task_runner_->PostTask( 59 task_runner_->PostTask(
59 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket, 60 FROM_HERE, base::Bind(&RectangleUpdateDecoder::DecodePacket,
60 this, base::Passed(&packet), done)); 61 this, base::Passed(&packet), done));
61 return; 62 return;
62 } 63 }
63 64
64 base::ScopedClosureRunner done_runner(done); 65 base::ScopedClosureRunner done_runner(done);
65 bool decoder_needs_reset = false; 66 bool decoder_needs_reset = false;
66 67
67 // If the packet includes a screen size, store it. 68 // If the packet includes screen size or DPI information, store them.
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 }
78 if (packet->format().has_x_dpi() && packet->format().has_y_dpi()) {
79 SkIPoint source_dpi(SkIPoint::Make(packet->format().x_dpi(),
80 packet->format().y_dpi()));
81 if (source_dpi != source_dpi_) {
82 source_dpi_ = source_dpi;
83 decoder_needs_reset = true;
Wez 2012/07/19 23:15:29 nit: The Decoder doesn't actually need resetting,
Jamie 2012/07/20 00:42:14 Done.
84 }
85 }
77 86
78 // If we've never seen a screen size, ignore the packet. 87 // If we've never seen a screen size, ignore the packet.
79 if (source_size_.isZero()) { 88 if (source_size_.isZero()) {
80 return; 89 return;
81 } 90 }
82 91
83 if (decoder_needs_reset) { 92 if (decoder_needs_reset) {
84 decoder_->Initialize(source_size_); 93 decoder_->Initialize(source_size_);
85 consumer_->SetSourceSize(source_size_); 94 consumer_->SetSourceSize(source_size_, source_dpi_);
86 } 95 }
87 96
88 if (!decoder_->IsReadyForData()) { 97 if (!decoder_->IsReadyForData()) {
89 // TODO(ajwong): This whole thing should move into an invalid state. 98 // TODO(ajwong): This whole thing should move into an invalid state.
90 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; 99 LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
91 return; 100 return;
92 } 101 }
93 102
94 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE) 103 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE)
95 SchedulePaint(); 104 SchedulePaint();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } else { 218 } else {
210 ++i; 219 ++i;
211 } 220 }
212 } 221 }
213 222
214 SchedulePaint(); 223 SchedulePaint();
215 } 224 }
216 } 225 }
217 226
218 } // namespace remoting 227 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698