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

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

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

Powered by Google App Engine
This is Rietveld 408576698