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