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

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 feedback. 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
« no previous file with comments | « remoting/client/rectangle_update_decoder.h ('k') | remoting/webapp/client_plugin.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
56 const base::Closure& done) { 57 const base::Closure& done) {
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;
67 bool notify_size_or_dpi_change = false;
66 68
67 // If the packet includes a screen size, store it. 69 // If the packet includes screen size or DPI information, store them.
68 if (packet->format().has_screen_width() && 70 if (packet->format().has_screen_width() &&
69 packet->format().has_screen_height()) { 71 packet->format().has_screen_height()) {
70 SkISize source_size = SkISize::Make(packet->format().screen_width(), 72 SkISize source_size = SkISize::Make(packet->format().screen_width(),
71 packet->format().screen_height()); 73 packet->format().screen_height());
72 if (source_size_ != source_size) { 74 if (source_size_ != source_size) {
73 source_size_ = source_size; 75 source_size_ = source_size;
74 decoder_needs_reset = true; 76 decoder_needs_reset = true;
77 notify_size_or_dpi_change = true;
78 }
79 }
80 if (packet->format().has_x_dpi() && packet->format().has_y_dpi()) {
81 SkIPoint source_dpi(SkIPoint::Make(packet->format().x_dpi(),
82 packet->format().y_dpi()));
83 if (source_dpi != source_dpi_) {
84 source_dpi_ = source_dpi;
85 notify_size_or_dpi_change = true;
75 } 86 }
76 } 87 }
77 88
78 // If we've never seen a screen size, ignore the packet. 89 // If we've never seen a screen size, ignore the packet.
79 if (source_size_.isZero()) { 90 if (source_size_.isZero())
80 return; 91 return;
81 }
82 92
83 if (decoder_needs_reset) { 93 if (decoder_needs_reset)
84 decoder_->Initialize(source_size_); 94 decoder_->Initialize(source_size_);
85 consumer_->SetSourceSize(source_size_); 95 if (notify_size_or_dpi_change)
86 } 96 consumer_->SetSourceSize(source_size_, source_dpi_);
87 97
88 if (!decoder_->IsReadyForData()) { 98 if (!decoder_->IsReadyForData()) {
89 // TODO(ajwong): This whole thing should move into an invalid state. 99 // TODO(ajwong): This whole thing should move into an invalid state.
90 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; 100 LOG(ERROR) << "Decoder is unable to process data. Dropping packet.";
91 return; 101 return;
92 } 102 }
93 103
94 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE) 104 if (decoder_->DecodePacket(packet.get()) == Decoder::DECODE_DONE)
95 SchedulePaint(); 105 SchedulePaint();
96 } 106 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } else { 219 } else {
210 ++i; 220 ++i;
211 } 221 }
212 } 222 }
213 223
214 SchedulePaint(); 224 SchedulePaint();
215 } 225 }
216 } 226 }
217 227
218 } // namespace remoting 228 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/rectangle_update_decoder.h ('k') | remoting/webapp/client_plugin.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698