| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 #ifdef NDEBUG | 400 #ifdef NDEBUG |
| 401 current_paint_.setColor(SK_ColorWHITE); | 401 current_paint_.setColor(SK_ColorWHITE); |
| 402 #else | 402 #else |
| 403 current_paint_.setColor(SK_ColorMAGENTA); | 403 current_paint_.setColor(SK_ColorMAGENTA); |
| 404 #endif | 404 #endif |
| 405 current_paint_.setAlpha(quad->opacity() * 255); | 405 current_paint_.setAlpha(quad->opacity() * 255); |
| 406 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), | 406 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), |
| 407 current_paint_); | 407 current_paint_); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void SoftwareRenderer::CopyCurrentRenderPassToBitmap(DrawingFrame* frame, | 410 void SoftwareRenderer::CopyCurrentRenderPassToBitmap( |
| 411 SkBitmap* bitmap) { | 411 DrawingFrame* frame, |
| 412 const CopyRenderPassCallback& callback) { |
| 412 gfx::Size render_pass_size = frame->current_render_pass->output_rect.size(); | 413 gfx::Size render_pass_size = frame->current_render_pass->output_rect.size(); |
| 414 |
| 415 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| 413 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 416 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
| 414 render_pass_size.width(), | 417 render_pass_size.width(), |
| 415 render_pass_size.height()); | 418 render_pass_size.height()); |
| 416 current_canvas_->readPixels(bitmap, 0, 0); | 419 current_canvas_->readPixels(bitmap.get(), 0, 0); |
| 420 |
| 421 callback.Run(bitmap.Pass()); |
| 417 } | 422 } |
| 418 | 423 |
| 419 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { | 424 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { |
| 420 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels"); | 425 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels"); |
| 421 SkBitmap subset_bitmap; | 426 SkBitmap subset_bitmap; |
| 422 output_device_->CopyToBitmap(rect, &subset_bitmap); | 427 output_device_->CopyToBitmap(rect, &subset_bitmap); |
| 423 subset_bitmap.copyPixelsTo(pixels, | 428 subset_bitmap.copyPixelsTo(pixels, |
| 424 4 * rect.width() * rect.height(), | 429 4 * rect.width() * rect.height(), |
| 425 4 * rect.width()); | 430 4 * rect.width()); |
| 426 } | 431 } |
| 427 | 432 |
| 428 void SoftwareRenderer::SetVisible(bool visible) { | 433 void SoftwareRenderer::SetVisible(bool visible) { |
| 429 if (visible_ == visible) | 434 if (visible_ == visible) |
| 430 return; | 435 return; |
| 431 visible_ = visible; | 436 visible_ = visible; |
| 432 } | 437 } |
| 433 | 438 |
| 434 } // namespace cc | 439 } // namespace cc |
| OLD | NEW |