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

Side by Side Diff: cc/output/software_renderer.cc

Issue 15435003: cc: Add CopyAsBitmapRequest class to hold the readback callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nolint Created 7 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
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/quads/render_pass.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "cc/output/compositor_frame_metadata.h" 11 #include "cc/output/compositor_frame_metadata.h"
12 #include "cc/output/copy_output_request.h"
12 #include "cc/output/output_surface.h" 13 #include "cc/output/output_surface.h"
13 #include "cc/output/software_output_device.h" 14 #include "cc/output/software_output_device.h"
14 #include "cc/quads/debug_border_draw_quad.h" 15 #include "cc/quads/debug_border_draw_quad.h"
15 #include "cc/quads/picture_draw_quad.h" 16 #include "cc/quads/picture_draw_quad.h"
16 #include "cc/quads/render_pass_draw_quad.h" 17 #include "cc/quads/render_pass_draw_quad.h"
17 #include "cc/quads/solid_color_draw_quad.h" 18 #include "cc/quads/solid_color_draw_quad.h"
18 #include "cc/quads/texture_draw_quad.h" 19 #include "cc/quads/texture_draw_quad.h"
19 #include "cc/quads/tile_draw_quad.h" 20 #include "cc/quads/tile_draw_quad.h"
20 #include "third_party/skia/include/core/SkCanvas.h" 21 #include "third_party/skia/include/core/SkCanvas.h"
21 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 #else 429 #else
429 current_paint_.setColor(SK_ColorMAGENTA); 430 current_paint_.setColor(SK_ColorMAGENTA);
430 #endif 431 #endif
431 current_paint_.setAlpha(quad->opacity() * 255); 432 current_paint_.setAlpha(quad->opacity() * 255);
432 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), 433 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()),
433 current_paint_); 434 current_paint_);
434 } 435 }
435 436
436 void SoftwareRenderer::CopyCurrentRenderPassToBitmap( 437 void SoftwareRenderer::CopyCurrentRenderPassToBitmap(
437 DrawingFrame* frame, 438 DrawingFrame* frame,
438 const CopyRenderPassCallback& callback) { 439 scoped_ptr<CopyOutputRequest> request) {
439 gfx::Size render_pass_size = frame->current_render_pass->output_rect.size(); 440 gfx::Size render_pass_size = frame->current_render_pass->output_rect.size();
440 441
441 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 442 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
442 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 443 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
443 render_pass_size.width(), 444 render_pass_size.width(),
444 render_pass_size.height()); 445 render_pass_size.height());
445 current_canvas_->readPixels(bitmap.get(), 0, 0); 446 current_canvas_->readPixels(bitmap.get(), 0, 0);
446 447
447 callback.Run(bitmap.Pass()); 448 request->SendBitmapResult(bitmap.Pass());
448 } 449 }
449 450
450 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { 451 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
451 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels"); 452 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels");
452 SkBitmap subset_bitmap; 453 SkBitmap subset_bitmap;
453 output_device_->CopyToBitmap(rect, &subset_bitmap); 454 output_device_->CopyToBitmap(rect, &subset_bitmap);
454 subset_bitmap.copyPixelsTo(pixels, 455 subset_bitmap.copyPixelsTo(pixels,
455 4 * rect.width() * rect.height(), 456 4 * rect.width() * rect.height(),
456 4 * rect.width()); 457 4 * rect.width());
457 } 458 }
458 459
459 void SoftwareRenderer::SetVisible(bool visible) { 460 void SoftwareRenderer::SetVisible(bool visible) {
460 if (visible_ == visible) 461 if (visible_ == visible)
461 return; 462 return;
462 visible_ = visible; 463 visible_ = visible;
463 } 464 }
464 465
465 } // namespace cc 466 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/quads/render_pass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698