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

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

Issue 22867046: Optimize alpha software PictureDrawQuads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert gl_renderer changes Created 7 years, 3 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
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | skia/ext/opacity_draw_filter.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/copy_output_request.h"
13 #include "cc/output/output_surface.h" 13 #include "cc/output/output_surface.h"
14 #include "cc/output/software_output_device.h" 14 #include "cc/output/software_output_device.h"
15 #include "cc/quads/checkerboard_draw_quad.h" 15 #include "cc/quads/checkerboard_draw_quad.h"
16 #include "cc/quads/debug_border_draw_quad.h" 16 #include "cc/quads/debug_border_draw_quad.h"
17 #include "cc/quads/picture_draw_quad.h" 17 #include "cc/quads/picture_draw_quad.h"
18 #include "cc/quads/render_pass_draw_quad.h" 18 #include "cc/quads/render_pass_draw_quad.h"
19 #include "cc/quads/solid_color_draw_quad.h" 19 #include "cc/quads/solid_color_draw_quad.h"
20 #include "cc/quads/texture_draw_quad.h" 20 #include "cc/quads/texture_draw_quad.h"
21 #include "cc/quads/tile_draw_quad.h" 21 #include "cc/quads/tile_draw_quad.h"
22 #include "third_party/skia/include/core/SkBitmapDevice.h" 22 #include "skia/ext/opacity_draw_filter.h"
23 #include "third_party/skia/include/core/SkCanvas.h" 23 #include "third_party/skia/include/core/SkCanvas.h"
24 #include "third_party/skia/include/core/SkColor.h" 24 #include "third_party/skia/include/core/SkColor.h"
25 #include "third_party/skia/include/core/SkMatrix.h" 25 #include "third_party/skia/include/core/SkMatrix.h"
26 #include "third_party/skia/include/core/SkShader.h" 26 #include "third_party/skia/include/core/SkShader.h"
27 #include "third_party/skia/include/effects/SkLayerRasterizer.h" 27 #include "third_party/skia/include/effects/SkLayerRasterizer.h"
28 #include "ui/gfx/rect_conversions.h" 28 #include "ui/gfx/rect_conversions.h"
29 #include "ui/gfx/skia_util.h" 29 #include "ui/gfx/skia_util.h"
30 #include "ui/gfx/transform.h" 30 #include "ui/gfx/transform.h"
31 31
32 namespace cc { 32 namespace cc {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame, 307 void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame,
308 const PictureDrawQuad* quad) { 308 const PictureDrawQuad* quad) {
309 SkMatrix content_matrix; 309 SkMatrix content_matrix;
310 content_matrix.setRectToRect( 310 content_matrix.setRectToRect(
311 gfx::RectFToSkRect(quad->tex_coord_rect), 311 gfx::RectFToSkRect(quad->tex_coord_rect),
312 gfx::RectFToSkRect(QuadVertexRect()), 312 gfx::RectFToSkRect(QuadVertexRect()),
313 SkMatrix::kFill_ScaleToFit); 313 SkMatrix::kFill_ScaleToFit);
314 current_canvas_->concat(content_matrix); 314 current_canvas_->concat(content_matrix);
315 315
316 if (quad->ShouldDrawWithBlending()) { 316 // TODO(aelias): This isn't correct in all cases. We should detect these
317 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad with blending"); 317 // cases and fall back to a persistent bitmap backing
318 SkBitmap temp_bitmap; 318 // (http://crbug.com/280374).
319 temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 319 DCHECK(!current_canvas_->getDrawFilter());
320 quad->texture_size.width(), 320 current_canvas_->setDrawFilter(new skia::OpacityDrawFilter(quad->opacity(),
321 quad->texture_size.height()); 321 true));
322 temp_bitmap.allocPixels();
323 SkBitmapDevice temp_device(temp_bitmap);
324 SkCanvas temp_canvas(&temp_device);
325 322
326 quad->picture_pile->RasterToBitmap( 323 TRACE_EVENT0("cc",
327 &temp_canvas, quad->content_rect, quad->contents_scale, NULL); 324 "SoftwareRenderer::DrawPictureQuad");
325 quad->picture_pile->RasterDirect(
326 current_canvas_, quad->content_rect, quad->contents_scale, NULL);
328 327
329 current_paint_.setFilterBitmap(true); 328 current_canvas_->setDrawFilter(NULL);
330 current_canvas_->drawBitmap(temp_bitmap, 0, 0, &current_paint_);
331 } else {
332 TRACE_EVENT0("cc",
333 "SoftwareRenderer::DrawPictureQuad direct from PicturePile");
334 quad->picture_pile->RasterDirect(
335 current_canvas_, quad->content_rect, quad->contents_scale, NULL);
336 }
337 } 329 }
338 330
339 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame, 331 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
340 const SolidColorDrawQuad* quad) { 332 const SolidColorDrawQuad* quad) {
341 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional( 333 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional(
342 QuadVertexRect(), quad->rect, quad->visible_rect); 334 QuadVertexRect(), quad->rect, quad->visible_rect);
343 current_paint_.setColor(quad->color); 335 current_paint_.setColor(quad->color);
344 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color)); 336 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color));
345 current_canvas_->drawRect(gfx::RectFToSkRect(visible_quad_vertex_rect), 337 current_canvas_->drawRect(gfx::RectFToSkRect(visible_quad_vertex_rect),
346 current_paint_); 338 current_paint_);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 EnsureBackbuffer(); 545 EnsureBackbuffer();
554 else 546 else
555 DiscardBackbuffer(); 547 DiscardBackbuffer();
556 } 548 }
557 549
558 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { 550 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) {
559 // The software renderer always discards the backbuffer when not visible. 551 // The software renderer always discards the backbuffer when not visible.
560 } 552 }
561 553
562 } // namespace cc 554 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | skia/ext/opacity_draw_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698