| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/graphics_2d.h" | 10 #include "ppapi/cpp/graphics_2d.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 case protocol::ConnectionToHost::FAILED: | 256 case protocol::ConnectionToHost::FAILED: |
| 257 SetSolidFill(kFailedColor); | 257 SetSolidFill(kFailedColor); |
| 258 scriptable_obj->SetConnectionStatus( | 258 scriptable_obj->SetConnectionStatus( |
| 259 ChromotingScriptableObject::STATUS_FAILED, | 259 ChromotingScriptableObject::STATUS_FAILED, |
| 260 ConvertConnectionError(error)); | 260 ConvertConnectionError(error)); |
| 261 break; | 261 break; |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool PepperView::SetPluginSize(const SkISize& plugin_size) { | 265 bool PepperView::SetViewSize(const SkISize& view_size) { |
| 266 if (plugin_size_ == plugin_size) | 266 if (view_size_ == view_size) |
| 267 return false; | 267 return false; |
| 268 plugin_size_ = plugin_size; | 268 view_size_ = view_size; |
| 269 | 269 |
| 270 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); | 270 pp::Size pp_size = pp::Size(view_size.width(), view_size.height()); |
| 271 | 271 |
| 272 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); | 272 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
| 273 if (!instance_->BindGraphics(graphics2d_)) { | 273 if (!instance_->BindGraphics(graphics2d_)) { |
| 274 LOG(ERROR) << "Couldn't bind the device context."; | 274 LOG(ERROR) << "Couldn't bind the device context."; |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (plugin_size.isEmpty()) | 278 if (view_size.isEmpty()) |
| 279 return false; | 279 return false; |
| 280 | 280 |
| 281 // Allocate the backing store to save the desktop image. | 281 // Allocate the backing store to save the desktop image. |
| 282 if ((backing_store_.get() == NULL) || | 282 if ((backing_store_.get() == NULL) || |
| 283 (backing_store_->size() != pp_size)) { | 283 (backing_store_->size() != pp_size)) { |
| 284 VLOG(1) << "Allocate backing store: " | 284 VLOG(1) << "Allocate backing store: " |
| 285 << plugin_size.width() << " x " << plugin_size.height(); | 285 << view_size.width() << " x " << view_size.height(); |
| 286 backing_store_.reset( | 286 backing_store_.reset( |
| 287 new pp::ImageData(instance_, pp::ImageData::GetNativeImageDataFormat(), | 287 new pp::ImageData(instance_, pp::ImageData::GetNativeImageDataFormat(), |
| 288 pp_size, false)); | 288 pp_size, false)); |
| 289 DCHECK(backing_store_.get() && !backing_store_->is_null()) | 289 DCHECK(backing_store_.get() && !backing_store_->is_null()) |
| 290 << "Not enough memory for backing store."; | 290 << "Not enough memory for backing store."; |
| 291 } | 291 } |
| 292 return true; | 292 return true; |
| 293 } | 293 } |
| 294 | 294 |
| 295 double PepperView::GetHorizontalScaleRatio() const { | |
| 296 if (instance_->DoScaling()) { | |
| 297 DCHECK(!host_size_.isEmpty()); | |
| 298 return 1.0 * plugin_size_.width() / host_size_.width(); | |
| 299 } | |
| 300 return 1.0; | |
| 301 } | |
| 302 | |
| 303 double PepperView::GetVerticalScaleRatio() const { | |
| 304 if (instance_->DoScaling()) { | |
| 305 DCHECK(!host_size_.isEmpty()); | |
| 306 return 1.0 * plugin_size_.height() / host_size_.height(); | |
| 307 } | |
| 308 return 1.0; | |
| 309 } | |
| 310 | |
| 311 void PepperView::AllocateFrame(media::VideoFrame::Format format, | 295 void PepperView::AllocateFrame(media::VideoFrame::Format format, |
| 312 const SkISize& size, | 296 const SkISize& size, |
| 313 scoped_refptr<media::VideoFrame>* frame_out, | 297 scoped_refptr<media::VideoFrame>* frame_out, |
| 314 const base::Closure& done) { | 298 const base::Closure& done) { |
| 315 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | 299 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); |
| 316 | 300 |
| 317 *frame_out = media::VideoFrame::CreateFrame( | 301 *frame_out = media::VideoFrame::CreateFrame( |
| 318 media::VideoFrame::RGB32, size.width(), size.height(), | 302 media::VideoFrame::RGB32, size.width(), size.height(), |
| 319 base::TimeDelta(), base::TimeDelta()); | 303 base::TimeDelta(), base::TimeDelta()); |
| 320 (*frame_out)->AddRef(); | 304 (*frame_out)->AddRef(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 345 (base::Time::Now() - paint_start).InMilliseconds()); | 329 (base::Time::Now() - paint_start).InMilliseconds()); |
| 346 | 330 |
| 347 // If the last flush failed because there was already another one in progress | 331 // If the last flush failed because there was already another one in progress |
| 348 // then we perform the flush now. | 332 // then we perform the flush now. |
| 349 if (flush_blocked_) | 333 if (flush_blocked_) |
| 350 FlushGraphics(base::Time::Now()); | 334 FlushGraphics(base::Time::Now()); |
| 351 return; | 335 return; |
| 352 } | 336 } |
| 353 | 337 |
| 354 } // namespace remoting | 338 } // namespace remoting |
| OLD | NEW |