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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 task_factory_.RevokeAll(); | 47 task_factory_.RevokeAll(); |
48 } | 48 } |
49 | 49 |
50 void PepperView::Paint() { | 50 void PepperView::Paint() { |
51 DCHECK(CurrentlyOnPluginThread()); | 51 DCHECK(CurrentlyOnPluginThread()); |
52 | 52 |
53 TraceContext::tracer()->PrintString("Start Paint."); | 53 TraceContext::tracer()->PrintString("Start Paint."); |
54 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This | 54 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This |
55 // is wrong. | 55 // is wrong. |
56 if (is_static_fill_) { | 56 if (is_static_fill_) { |
57 instance_->Log(logging::LOG_INFO, | 57 LOG(INFO) << "Static filling " << static_fill_color_; |
58 "Static filling %08x", static_fill_color_); | |
59 pp::ImageData image(instance_, pp::ImageData::GetNativeImageDataFormat(), | 58 pp::ImageData image(instance_, pp::ImageData::GetNativeImageDataFormat(), |
60 pp::Size(host_width_, host_height_), | 59 pp::Size(host_width_, host_height_), |
61 false); | 60 false); |
62 if (image.is_null()) { | 61 if (image.is_null()) { |
63 instance_->Log(logging::LOG_ERROR, | 62 LOG(ERROR) << "Unable to allocate image of size: " |
64 "Unable to allocate image of size: %dx%d", | 63 << host_width_ << "x" << host_height_; |
65 host_width_, host_height_); | |
66 return; | 64 return; |
67 } | 65 } |
68 | 66 |
69 for (int y = 0; y < image.size().height(); y++) { | 67 for (int y = 0; y < image.size().height(); y++) { |
70 for (int x = 0; x < image.size().width(); x++) { | 68 for (int x = 0; x < image.size().width(); x++) { |
71 *image.GetAddr32(pp::Point(x, y)) = static_fill_color_; | 69 *image.GetAddr32(pp::Point(x, y)) = static_fill_color_; |
72 } | 70 } |
73 } | 71 } |
74 | 72 |
75 // For ReplaceContents, make sure the image size matches the device context | 73 // For ReplaceContents, make sure the image size matches the device context |
(...skipping 15 matching lines...) Expand all Loading... |
91 | 89 |
92 TraceContext::tracer()->PrintString("Start Paint Frame."); | 90 TraceContext::tracer()->PrintString("Start Paint Frame."); |
93 | 91 |
94 SetViewport(0, 0, frame->width(), frame->height()); | 92 SetViewport(0, 0, frame->width(), frame->height()); |
95 | 93 |
96 uint8* frame_data = frame->data(media::VideoFrame::kRGBPlane); | 94 uint8* frame_data = frame->data(media::VideoFrame::kRGBPlane); |
97 const int kFrameStride = frame->stride(media::VideoFrame::kRGBPlane); | 95 const int kFrameStride = frame->stride(media::VideoFrame::kRGBPlane); |
98 const int kBytesPerPixel = GetBytesPerPixel(media::VideoFrame::RGB32); | 96 const int kBytesPerPixel = GetBytesPerPixel(media::VideoFrame::RGB32); |
99 | 97 |
100 if (!backing_store_.get() || backing_store_->is_null()) { | 98 if (!backing_store_.get() || backing_store_->is_null()) { |
101 instance_->Log(logging::LOG_ERROR, "Backing store is not available."); | 99 LOG(ERROR) << "Backing store is not available."; |
102 return; | 100 return; |
103 } | 101 } |
104 if (DoScaling()) { | 102 if (DoScaling()) { |
105 if (!scaled_backing_store_.get() || scaled_backing_store_->is_null()) { | 103 if (!scaled_backing_store_.get() || scaled_backing_store_->is_null()) { |
106 instance_->Log(logging::LOG_ERROR, | 104 LOG(ERROR) << "Scaled backing store is not available."; |
107 "Scaled backing store is not available."); | |
108 } | 105 } |
109 } | 106 } |
110 | 107 |
111 // 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. |
112 for (size_t i = 0; i < rects->size(); ++i) { | 109 for (size_t i = 0; i < rects->size(); ++i) { |
113 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This | 110 // TODO(ajwong): We're assuming the native format is BGRA_PREMUL below. This |
114 // is wrong. | 111 // is wrong. |
115 const gfx::Rect& r = (*rects)[i]; | 112 const gfx::Rect& r = (*rects)[i]; |
116 | 113 |
117 // TODO(hclam): Make sure rectangles are valid. | 114 // TODO(hclam): Make sure rectangles are valid. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 graphics2d_.Flush(TaskToCompletionCallback( | 335 graphics2d_.Flush(TaskToCompletionCallback( |
339 task_factory_.NewRunnableMethod(&PepperView::OnRefreshPaintDone))); | 336 task_factory_.NewRunnableMethod(&PepperView::OnRefreshPaintDone))); |
340 } | 337 } |
341 } | 338 } |
342 | 339 |
343 void PepperView::ResizeInternals() { | 340 void PepperView::ResizeInternals() { |
344 graphics2d_ = pp::Graphics2D(instance_, | 341 graphics2d_ = pp::Graphics2D(instance_, |
345 pp::Size(host_width_, host_height_), | 342 pp::Size(host_width_, host_height_), |
346 false); | 343 false); |
347 if (!instance_->BindGraphics(graphics2d_)) { | 344 if (!instance_->BindGraphics(graphics2d_)) { |
348 instance_->Log(logging::LOG_ERROR, "Couldn't bind the device context."); | 345 LOG(ERROR) << "Couldn't bind the device context."; |
349 return; | 346 return; |
350 } | 347 } |
351 | 348 |
352 if (host_width_ == 0 && host_height_ == 0) | 349 if (host_width_ == 0 && host_height_ == 0) |
353 return; | 350 return; |
354 | 351 |
355 // Allocate the backing store to save the desktop image. | 352 // Allocate the backing store to save the desktop image. |
356 pp::Size host_size(host_width_, host_height_); | 353 pp::Size host_size(host_width_, host_height_); |
357 if ((backing_store_.get() == NULL) || (backing_store_->size() != host_size)) { | 354 if ((backing_store_.get() == NULL) || (backing_store_->size() != host_size)) { |
358 backing_store_.reset( | 355 backing_store_.reset( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 base::TimeDelta()); | 433 base::TimeDelta()); |
437 (*frame_out)->AddRef(); | 434 (*frame_out)->AddRef(); |
438 done->Run(); | 435 done->Run(); |
439 delete done; | 436 delete done; |
440 } | 437 } |
441 | 438 |
442 void PepperView::ReleaseFrame(media::VideoFrame* frame) { | 439 void PepperView::ReleaseFrame(media::VideoFrame* frame) { |
443 DCHECK(CurrentlyOnPluginThread()); | 440 DCHECK(CurrentlyOnPluginThread()); |
444 | 441 |
445 if (frame) { | 442 if (frame) { |
446 instance_->Log(logging::LOG_WARNING, "Frame released."); | 443 LOG(WARNING) << "Frame released."; |
447 frame->Release(); | 444 frame->Release(); |
448 } | 445 } |
449 } | 446 } |
450 | 447 |
451 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, | 448 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, |
452 UpdatedRects* rects, | 449 UpdatedRects* rects, |
453 Task* done) { | 450 Task* done) { |
454 DCHECK(CurrentlyOnPluginThread()); | 451 DCHECK(CurrentlyOnPluginThread()); |
455 | 452 |
456 TraceContext::tracer()->PrintString("Calling PaintFrame"); | 453 TraceContext::tracer()->PrintString("Calling PaintFrame"); |
(...skipping 10 matching lines...) Expand all Loading... |
467 instance_->GetStats()->video_paint_ms()->Record( | 464 instance_->GetStats()->video_paint_ms()->Record( |
468 (base::Time::Now() - paint_start).InMilliseconds()); | 465 (base::Time::Now() - paint_start).InMilliseconds()); |
469 return; | 466 return; |
470 } | 467 } |
471 | 468 |
472 void PepperView::OnRefreshPaintDone() { | 469 void PepperView::OnRefreshPaintDone() { |
473 DCHECK(CurrentlyOnPluginThread()); | 470 DCHECK(CurrentlyOnPluginThread()); |
474 } | 471 } |
475 | 472 |
476 } // namespace remoting | 473 } // namespace remoting |
OLD | NEW |