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

Side by Side Diff: remoting/client/plugin/pepper_view.cc

Issue 10785041: Make Chromoting client plugin always render at device DPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/plugin/pepper_view.h" 5 #include "remoting/client/plugin/pepper_view.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "ppapi/cpp/completion_callback.h" 12 #include "ppapi/cpp/completion_callback.h"
13 #include "ppapi/cpp/graphics_2d.h" 13 #include "ppapi/cpp/dev/graphics_2d_dev.h"
14 #include "ppapi/cpp/dev/view_dev.h"
14 #include "ppapi/cpp/image_data.h" 15 #include "ppapi/cpp/image_data.h"
15 #include "ppapi/cpp/point.h" 16 #include "ppapi/cpp/point.h"
16 #include "ppapi/cpp/rect.h" 17 #include "ppapi/cpp/rect.h"
17 #include "ppapi/cpp/size.h" 18 #include "ppapi/cpp/size.h"
18 #include "remoting/base/util.h" 19 #include "remoting/base/util.h"
19 #include "remoting/client/chromoting_stats.h" 20 #include "remoting/client/chromoting_stats.h"
20 #include "remoting/client/client_context.h" 21 #include "remoting/client/client_context.h"
21 #include "remoting/client/frame_producer.h" 22 #include "remoting/client/frame_producer.h"
22 #include "remoting/client/plugin/chromoting_instance.h" 23 #include "remoting/client/plugin/chromoting_instance.h"
23 #include "remoting/client/plugin/pepper_util.h" 24 #include "remoting/client/plugin/pepper_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ClientContext* context, 71 ClientContext* context,
71 FrameProducer* producer) 72 FrameProducer* producer)
72 : instance_(instance), 73 : instance_(instance),
73 context_(context), 74 context_(context),
74 producer_(producer), 75 producer_(producer),
75 merge_buffer_(NULL), 76 merge_buffer_(NULL),
76 merge_clip_area_(SkIRect::MakeEmpty()), 77 merge_clip_area_(SkIRect::MakeEmpty()),
77 view_size_(SkISize::Make(0, 0)), 78 view_size_(SkISize::Make(0, 0)),
78 clip_area_(SkIRect::MakeEmpty()), 79 clip_area_(SkIRect::MakeEmpty()),
79 source_size_(SkISize::Make(0, 0)), 80 source_size_(SkISize::Make(0, 0)),
81 view_size_dips_(SkISize::Make(0, 0)),
82 view_scale_(1.0f),
80 flush_pending_(false), 83 flush_pending_(false),
81 is_initialized_(false), 84 is_initialized_(false),
82 frame_received_(false) { 85 frame_received_(false) {
83 } 86 }
84 87
85 PepperView::~PepperView() { 88 PepperView::~PepperView() {
86 DCHECK(merge_buffer_ == NULL); 89 DCHECK(merge_buffer_ == NULL);
87 DCHECK(buffers_.empty()); 90 DCHECK(buffers_.empty());
88 } 91 }
89 92
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 150 }
148 151
149 protocol::ClipboardStub* PepperView::GetClipboardStub() { 152 protocol::ClipboardStub* PepperView::GetClipboardStub() {
150 return instance_; 153 return instance_;
151 } 154 }
152 155
153 protocol::CursorShapeStub* PepperView::GetCursorShapeStub() { 156 protocol::CursorShapeStub* PepperView::GetCursorShapeStub() {
154 return instance_; 157 return instance_;
155 } 158 }
156 159
157 void PepperView::SetView(const SkISize& view_size, const SkIRect& clip_area) { 160 void PepperView::SetView(const pp::View& view) {
158 bool view_changed = false; 161 bool view_changed = false;
159 162
160 if (view_size_ != view_size) { 163 pp::ViewDev view_dev(view);
164
165 pp::Rect pp_size = view.GetRect();
166 SkISize new_size_dips = SkISize::Make(pp_size.width(), pp_size.height());
167
168 if (view_size_dips_ != new_size_dips ||
169 view_dev.GetDeviceScale() != view_scale_) {
161 view_changed = true; 170 view_changed = true;
162 view_size_ = view_size; 171 view_scale_ = view_dev.GetDeviceScale();
172 view_size_dips_ = new_size_dips;
173 view_size_ = SkISize::Make(view_size_dips_.width() * view_scale_,
174 view_size_dips_.height() * view_scale_);
163 175
164 pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height()); 176 pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height());
165 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); 177 pp::Graphics2DDev graphics2d = pp::Graphics2D(instance_, pp_size, true);
Sergey Ulanov 2012/07/17 19:36:06 why can't set graphics2d_ directly?
Wez 2012/07/17 20:11:43 The |graphics2d_| member in the class is still a G
178
179 // Ideally we would always let Graphics2D scale us, but the output quality
180 // is lousy, so we don't.
181 graphics2d.SetScale(1.0f / view_scale_);
182
183 graphics2d_ = graphics2d;
166 bool result = instance_->BindGraphics(graphics2d_); 184 bool result = instance_->BindGraphics(graphics2d_);
167 185
168 // There is no good way to handle this error currently. 186 // There is no good way to handle this error currently.
169 DCHECK(result) << "Couldn't bind the device context."; 187 DCHECK(result) << "Couldn't bind the device context.";
170 } 188 }
171 189
172 if (clip_area_ != clip_area) { 190 pp::Rect pp_clip = view.GetClipRect();
191 SkIRect new_clip = SkIRect::MakeXYWH(pp_clip.x() * view_scale_,
192 pp_clip.y() * view_scale_,
193 pp_clip.width() * view_scale_,
Sergey Ulanov 2012/07/17 19:36:06 ceil(pp_clip.width() * view_scale_)?
Wez 2012/07/17 20:11:43 That shouldn't be necessary for the scaling factor
Wez 2012/07/17 20:11:43 Done.
194 pp_clip.height() * view_scale_);
195 if (clip_area_ != new_clip) {
173 view_changed = true; 196 view_changed = true;
174 197
175 // YUV to RGB conversion may require even X and Y coordinates for 198 // YUV to RGB conversion may require even X and Y coordinates for
176 // the top left corner of the clipping area. 199 // the top left corner of the clipping area.
177 clip_area_ = AlignRect(clip_area); 200 clip_area_ = AlignRect(new_clip);
178 clip_area_.intersect(SkIRect::MakeSize(view_size_)); 201 clip_area_.intersect(SkIRect::MakeSize(view_size_));
179 } 202 }
180 203
181 if (view_changed) { 204 if (view_changed) {
182 producer_->SetOutputSizeAndClip(view_size_, clip_area_); 205 producer_->SetOutputSizeAndClip(view_size_, clip_area_);
183 InitiateDrawing(); 206 InitiateDrawing();
184 } 207 }
185 } 208 }
186 209
187 void PepperView::ApplyBuffer(const SkISize& view_size, 210 void PepperView::ApplyBuffer(const SkISize& view_size,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 371
349 // If there is a buffer queued for rendering then render it now. 372 // If there is a buffer queued for rendering then render it now.
350 if (merge_buffer_ != NULL) { 373 if (merge_buffer_ != NULL) {
351 buffer = merge_buffer_; 374 buffer = merge_buffer_;
352 merge_buffer_ = NULL; 375 merge_buffer_ = NULL;
353 FlushBuffer(merge_clip_area_, buffer, merge_region_); 376 FlushBuffer(merge_clip_area_, buffer, merge_region_);
354 } 377 }
355 } 378 }
356 379
357 } // namespace remoting 380 } // namespace remoting
OLDNEW
« remoting/client/plugin/chromoting_instance.cc ('K') | « remoting/client/plugin/pepper_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698