OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/output/software_renderer.h" | 5 #include "cc/output/software_renderer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 current_paint_.setColor(SK_ColorMAGENTA); | 445 current_paint_.setColor(SK_ColorMAGENTA); |
446 #endif | 446 #endif |
447 current_paint_.setAlpha(quad->opacity() * 255); | 447 current_paint_.setAlpha(quad->opacity() * 255); |
448 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), | 448 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), |
449 current_paint_); | 449 current_paint_); |
450 } | 450 } |
451 | 451 |
452 void SoftwareRenderer::CopyCurrentRenderPassToBitmap( | 452 void SoftwareRenderer::CopyCurrentRenderPassToBitmap( |
453 DrawingFrame* frame, | 453 DrawingFrame* frame, |
454 scoped_ptr<CopyOutputRequest> request) { | 454 scoped_ptr<CopyOutputRequest> request) { |
| 455 gfx::Rect copy_rect = frame->current_render_pass->output_rect; |
| 456 if (request->has_area()) { |
| 457 // Intersect with the request's area, positioned with its origin at the |
| 458 // origin of the full copy_rect. |
| 459 copy_rect.Intersect(request->area() - copy_rect.OffsetFromOrigin()); |
| 460 } |
| 461 gfx::Rect window_copy_rect = MoveFromDrawToWindowSpace(copy_rect); |
| 462 |
455 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 463 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
456 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 464 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
457 current_viewport_rect_.width(), | 465 window_copy_rect.width(), |
458 current_viewport_rect_.height()); | 466 window_copy_rect.height()); |
459 current_canvas_->readPixels( | 467 current_canvas_->readPixels( |
460 bitmap.get(), current_viewport_rect_.x(), current_viewport_rect_.y()); | 468 bitmap.get(), window_copy_rect.x(), window_copy_rect.y()); |
461 | 469 |
462 request->SendBitmapResult(bitmap.Pass()); | 470 request->SendBitmapResult(bitmap.Pass()); |
463 } | 471 } |
464 | 472 |
465 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { | 473 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { |
466 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels"); | 474 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels"); |
467 SkBitmap subset_bitmap; | 475 SkBitmap subset_bitmap; |
468 rect += current_viewport_rect_.OffsetFromOrigin(); | 476 rect += current_viewport_rect_.OffsetFromOrigin(); |
469 output_device_->CopyToBitmap(rect, &subset_bitmap); | 477 output_device_->CopyToBitmap(rect, &subset_bitmap); |
470 subset_bitmap.copyPixelsTo(pixels, | 478 subset_bitmap.copyPixelsTo(pixels, |
471 4 * rect.width() * rect.height(), | 479 4 * rect.width() * rect.height(), |
472 4 * rect.width()); | 480 4 * rect.width()); |
473 } | 481 } |
474 | 482 |
475 void SoftwareRenderer::SetVisible(bool visible) { | 483 void SoftwareRenderer::SetVisible(bool visible) { |
476 if (visible_ == visible) | 484 if (visible_ == visible) |
477 return; | 485 return; |
478 visible_ = visible; | 486 visible_ = visible; |
479 } | 487 } |
480 | 488 |
481 } // namespace cc | 489 } // namespace cc |
OLD | NEW |