| 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/graphics_2d.h" | 9 #include "ppapi/cpp/graphics_2d.h" |
| 10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 task_factory_.RevokeAll(); | 42 task_factory_.RevokeAll(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void PepperView::Paint() { | 45 void PepperView::Paint() { |
| 46 DCHECK(CurrentlyOnPluginThread()); | 46 DCHECK(CurrentlyOnPluginThread()); |
| 47 | 47 |
| 48 TraceContext::tracer()->PrintString("Start Paint."); | 48 TraceContext::tracer()->PrintString("Start Paint."); |
| 49 | 49 |
| 50 if (is_static_fill_) { | 50 if (is_static_fill_) { |
| 51 instance_->Log(logging::LOG_INFO, | 51 LOG(INFO) << "Static filling " << static_fill_color_; |
| 52 "Static filling %08x", static_fill_color_); | |
| 53 pp::ImageData image(instance_, pp::ImageData::GetNativeImageDataFormat(), | 52 pp::ImageData image(instance_, pp::ImageData::GetNativeImageDataFormat(), |
| 54 pp::Size(graphics2d_.size().width(), | 53 pp::Size(graphics2d_.size().width(), |
| 55 graphics2d_.size().height()), | 54 graphics2d_.size().height()), |
| 56 false); | 55 false); |
| 57 if (image.is_null()) { | 56 if (image.is_null()) { |
| 58 instance_->Log(logging::LOG_ERROR, | 57 LOG(ERROR) << "Unable to allocate image of size: " |
| 59 "Unable to allocate image of size: %dx%d", | 58 << graphics2d_.size().width() << " x " |
| 60 graphics2d_.size().width(), graphics2d_.size().height()); | 59 << graphics2d_.size().height(); |
| 61 return; | 60 return; |
| 62 } | 61 } |
| 63 | 62 |
| 64 for (int y = 0; y < image.size().height(); y++) { | 63 for (int y = 0; y < image.size().height(); y++) { |
| 65 for (int x = 0; x < image.size().width(); x++) { | 64 for (int x = 0; x < image.size().width(); x++) { |
| 66 *image.GetAddr32(pp::Point(x, y)) = static_fill_color_; | 65 *image.GetAddr32(pp::Point(x, y)) = static_fill_color_; |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 // For ReplaceContents, make sure the image size matches the device context | 69 // For ReplaceContents, make sure the image size matches the device context |
| (...skipping 22 matching lines...) Expand all Loading... |
| 93 } | 92 } |
| 94 | 93 |
| 95 void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) { | 94 void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) { |
| 96 DCHECK(CurrentlyOnPluginThread()); | 95 DCHECK(CurrentlyOnPluginThread()); |
| 97 | 96 |
| 98 TraceContext::tracer()->PrintString("Start Paint Frame."); | 97 TraceContext::tracer()->PrintString("Start Paint Frame."); |
| 99 | 98 |
| 100 SetHostSize(gfx::Size(frame->width(), frame->height())); | 99 SetHostSize(gfx::Size(frame->width(), frame->height())); |
| 101 | 100 |
| 102 if (!backing_store_.get() || backing_store_->is_null()) { | 101 if (!backing_store_.get() || backing_store_->is_null()) { |
| 103 instance_->Log(logging::LOG_ERROR, "Backing store is not available."); | 102 LOG(ERROR) << "Backing store is not available."; |
| 104 return; | 103 return; |
| 105 } | 104 } |
| 106 | 105 |
| 107 base::Time start_time = base::Time::Now(); | 106 base::Time start_time = base::Time::Now(); |
| 108 | 107 |
| 109 // Copy updated regions to the backing store and then paint the regions. | 108 // Copy updated regions to the backing store and then paint the regions. |
| 110 bool changes_made = false; | 109 bool changes_made = false; |
| 111 for (size_t i = 0; i < rects->size(); ++i) | 110 for (size_t i = 0; i < rects->size(); ++i) |
| 112 changes_made |= PaintRect(frame, (*rects)[i]); | 111 changes_made |= PaintRect(frame, (*rects)[i]); |
| 113 | 112 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 233 |
| 235 bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { | 234 bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { |
| 236 if (plugin_size_ == plugin_size) | 235 if (plugin_size_ == plugin_size) |
| 237 return false; | 236 return false; |
| 238 plugin_size_ = plugin_size; | 237 plugin_size_ = plugin_size; |
| 239 | 238 |
| 240 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); | 239 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); |
| 241 | 240 |
| 242 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); | 241 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
| 243 if (!instance_->BindGraphics(graphics2d_)) { | 242 if (!instance_->BindGraphics(graphics2d_)) { |
| 244 instance_->Log(logging::LOG_ERROR, "Couldn't bind the device context."); | 243 LOG(ERROR) << "Couldn't bind the device context."; |
| 245 return false; | 244 return false; |
| 246 } | 245 } |
| 247 | 246 |
| 248 if (plugin_size.IsEmpty()) | 247 if (plugin_size.IsEmpty()) |
| 249 return false; | 248 return false; |
| 250 | 249 |
| 251 // Allocate the backing store to save the desktop image. | 250 // Allocate the backing store to save the desktop image. |
| 252 if ((backing_store_.get() == NULL) || | 251 if ((backing_store_.get() == NULL) || |
| 253 (backing_store_->size() != pp_size)) { | 252 (backing_store_->size() != pp_size)) { |
| 254 instance_->Log(logging::LOG_INFO, "Allocate backing store: %d x %d", | 253 LOG(INFO) << "Allocate backing store: " |
| 255 plugin_size.width(), plugin_size.height()); | 254 << plugin_size.width() << " x " << plugin_size.height(); |
| 256 backing_store_.reset( | 255 backing_store_.reset( |
| 257 new pp::ImageData(instance_, pp::ImageData::GetNativeImageDataFormat(), | 256 new pp::ImageData(instance_, pp::ImageData::GetNativeImageDataFormat(), |
| 258 pp_size, false)); | 257 pp_size, false)); |
| 259 DCHECK(backing_store_.get() && !backing_store_->is_null()) | 258 DCHECK(backing_store_.get() && !backing_store_->is_null()) |
| 260 << "Not enough memory for backing store."; | 259 << "Not enough memory for backing store."; |
| 261 } | 260 } |
| 262 return true; | 261 return true; |
| 263 } | 262 } |
| 264 | 263 |
| 265 double PepperView::GetHorizontalScaleRatio() const { | 264 double PepperView::GetHorizontalScaleRatio() const { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 293 base::TimeDelta()); | 292 base::TimeDelta()); |
| 294 (*frame_out)->AddRef(); | 293 (*frame_out)->AddRef(); |
| 295 done->Run(); | 294 done->Run(); |
| 296 delete done; | 295 delete done; |
| 297 } | 296 } |
| 298 | 297 |
| 299 void PepperView::ReleaseFrame(media::VideoFrame* frame) { | 298 void PepperView::ReleaseFrame(media::VideoFrame* frame) { |
| 300 DCHECK(CurrentlyOnPluginThread()); | 299 DCHECK(CurrentlyOnPluginThread()); |
| 301 | 300 |
| 302 if (frame) { | 301 if (frame) { |
| 303 instance_->Log(logging::LOG_WARNING, "Frame released."); | 302 LOG(WARNING) << "Frame released."; |
| 304 frame->Release(); | 303 frame->Release(); |
| 305 } | 304 } |
| 306 } | 305 } |
| 307 | 306 |
| 308 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, | 307 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, |
| 309 UpdatedRects* rects, | 308 UpdatedRects* rects, |
| 310 Task* done) { | 309 Task* done) { |
| 311 DCHECK(CurrentlyOnPluginThread()); | 310 DCHECK(CurrentlyOnPluginThread()); |
| 312 | 311 |
| 313 TraceContext::tracer()->PrintString("Calling PaintFrame"); | 312 TraceContext::tracer()->PrintString("Calling PaintFrame"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 325 (base::Time::Now() - paint_start).InMilliseconds()); | 324 (base::Time::Now() - paint_start).InMilliseconds()); |
| 326 | 325 |
| 327 // If the last flush failed because there was already another one in progress | 326 // If the last flush failed because there was already another one in progress |
| 328 // then we perform the flush now. | 327 // then we perform the flush now. |
| 329 if (pending_flush_) | 328 if (pending_flush_) |
| 330 FlushGraphics(base::Time::Now()); | 329 FlushGraphics(base::Time::Now()); |
| 331 return; | 330 return; |
| 332 } | 331 } |
| 333 | 332 |
| 334 } // namespace remoting | 333 } // namespace remoting |
| OLD | NEW |