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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 247 |
249 bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { | 248 bool PepperView::SetPluginSize(const gfx::Size& plugin_size) { |
250 if (plugin_size_ == plugin_size) | 249 if (plugin_size_ == plugin_size) |
251 return false; | 250 return false; |
252 plugin_size_ = plugin_size; | 251 plugin_size_ = plugin_size; |
253 | 252 |
254 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); | 253 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); |
255 | 254 |
256 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); | 255 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
257 if (!instance_->BindGraphics(graphics2d_)) { | 256 if (!instance_->BindGraphics(graphics2d_)) { |
258 instance_->Log(logging::LOG_ERROR, "Couldn't bind the device context."); | 257 LOG(ERROR) << "Couldn't bind the device context."; |
259 return false; | 258 return false; |
260 } | 259 } |
261 | 260 |
262 if (plugin_size.IsEmpty()) | 261 if (plugin_size.IsEmpty()) |
263 return false; | 262 return false; |
264 | 263 |
265 // Allocate the backing store to save the desktop image. | 264 // Allocate the backing store to save the desktop image. |
266 if ((backing_store_.get() == NULL) || | 265 if ((backing_store_.get() == NULL) || |
267 (backing_store_->size() != pp_size)) { | 266 (backing_store_->size() != pp_size)) { |
268 instance_->Log(logging::LOG_INFO, "Allocate backing store: %d x %d", | 267 LOG(INFO) << "Allocate backing store: " |
269 plugin_size.width(), plugin_size.height()); | 268 << plugin_size.width() << " x " << plugin_size.height(); |
270 backing_store_.reset( | 269 backing_store_.reset( |
271 new pp::ImageData(instance_, pp::ImageData::GetNativeImageDataFormat(), | 270 new pp::ImageData(instance_, pp::ImageData::GetNativeImageDataFormat(), |
272 pp_size, false)); | 271 pp_size, false)); |
273 DCHECK(backing_store_.get() && !backing_store_->is_null()) | 272 DCHECK(backing_store_.get() && !backing_store_->is_null()) |
274 << "Not enough memory for backing store."; | 273 << "Not enough memory for backing store."; |
275 } | 274 } |
276 return true; | 275 return true; |
277 } | 276 } |
278 | 277 |
279 double PepperView::GetHorizontalScaleRatio() const { | 278 double PepperView::GetHorizontalScaleRatio() const { |
(...skipping 27 matching lines...) Expand all Loading... |
307 base::TimeDelta()); | 306 base::TimeDelta()); |
308 (*frame_out)->AddRef(); | 307 (*frame_out)->AddRef(); |
309 done->Run(); | 308 done->Run(); |
310 delete done; | 309 delete done; |
311 } | 310 } |
312 | 311 |
313 void PepperView::ReleaseFrame(media::VideoFrame* frame) { | 312 void PepperView::ReleaseFrame(media::VideoFrame* frame) { |
314 DCHECK(CurrentlyOnPluginThread()); | 313 DCHECK(CurrentlyOnPluginThread()); |
315 | 314 |
316 if (frame) { | 315 if (frame) { |
317 instance_->Log(logging::LOG_WARNING, "Frame released."); | 316 LOG(WARNING) << "Frame released."; |
318 frame->Release(); | 317 frame->Release(); |
319 } | 318 } |
320 } | 319 } |
321 | 320 |
322 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, | 321 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, |
323 UpdatedRects* rects, | 322 UpdatedRects* rects, |
324 Task* done) { | 323 Task* done) { |
325 DCHECK(CurrentlyOnPluginThread()); | 324 DCHECK(CurrentlyOnPluginThread()); |
326 | 325 |
327 TraceContext::tracer()->PrintString("Calling PaintFrame"); | 326 TraceContext::tracer()->PrintString("Calling PaintFrame"); |
(...skipping 11 matching lines...) Expand all Loading... |
339 (base::Time::Now() - paint_start).InMilliseconds()); | 338 (base::Time::Now() - paint_start).InMilliseconds()); |
340 | 339 |
341 // If the last flush failed because there was already another one in progress | 340 // If the last flush failed because there was already another one in progress |
342 // then we perform the flush now. | 341 // then we perform the flush now. |
343 if (flush_blocked_) | 342 if (flush_blocked_) |
344 FlushGraphics(base::Time::Now()); | 343 FlushGraphics(base::Time::Now()); |
345 return; | 344 return; |
346 } | 345 } |
347 | 346 |
348 } // namespace remoting | 347 } // namespace remoting |
OLD | NEW |