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

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: Add a test and bring back Ganesh support 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame, 305 void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame,
306 const PictureDrawQuad* quad) { 306 const PictureDrawQuad* quad) {
307 SkMatrix content_matrix; 307 SkMatrix content_matrix;
308 content_matrix.setRectToRect( 308 content_matrix.setRectToRect(
309 gfx::RectFToSkRect(quad->tex_coord_rect), 309 gfx::RectFToSkRect(quad->tex_coord_rect),
310 gfx::RectFToSkRect(QuadVertexRect()), 310 gfx::RectFToSkRect(QuadVertexRect()),
311 SkMatrix::kFill_ScaleToFit); 311 SkMatrix::kFill_ScaleToFit);
312 current_canvas_->concat(content_matrix); 312 current_canvas_->concat(content_matrix);
313 313
314 if (quad->ShouldDrawWithBlending()) { 314 // http://crbug.com/280374 - Applying opacity to each individual draw call is
joth 2013/08/28 03:29:12 Is this a TODO, or an explanation of what is alrea
315 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad with blending"); 315 // often incorrect. We should detect these cases and fall back to a persistent
316 SkBitmap temp_bitmap; 316 // bitmap backing.
317 temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 317 current_canvas_->setDrawFilter(new skia::OpacityDrawFilter(quad->opacity(),
318 quad->texture_size.width(), 318 true));
319 quad->texture_size.height());
320 temp_bitmap.allocPixels();
321 SkBitmapDevice temp_device(temp_bitmap);
322 SkCanvas temp_canvas(&temp_device);
323 319
324 quad->picture_pile->RasterToBitmap( 320 TRACE_EVENT0("cc",
325 &temp_canvas, quad->content_rect, quad->contents_scale, NULL); 321 "SoftwareRenderer::DrawPictureQuad");
322 quad->picture_pile->RasterDirect(
323 current_canvas_, quad->content_rect, quad->contents_scale, NULL);
326 324
327 current_paint_.setFilterBitmap(true); 325 current_canvas_->setDrawFilter(NULL);
328 current_canvas_->drawBitmap(temp_bitmap, 0, 0, &current_paint_);
329 } else {
330 TRACE_EVENT0("cc",
331 "SoftwareRenderer::DrawPictureQuad direct from PicturePile");
332 quad->picture_pile->RasterDirect(
333 current_canvas_, quad->content_rect, quad->contents_scale, NULL);
334 }
335 } 326 }
336 327
337 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame, 328 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
338 const SolidColorDrawQuad* quad) { 329 const SolidColorDrawQuad* quad) {
339 current_paint_.setColor(quad->color); 330 current_paint_.setColor(quad->color);
340 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color)); 331 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color));
341 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), 332 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()),
342 current_paint_); 333 current_paint_);
343 } 334 }
344 335
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 EnsureBackbuffer(); 528 EnsureBackbuffer();
538 else 529 else
539 DiscardBackbuffer(); 530 DiscardBackbuffer();
540 } 531 }
541 532
542 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { 533 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) {
543 // The software renderer always discards the backbuffer when not visible. 534 // The software renderer always discards the backbuffer when not visible.
544 } 535 }
545 536
546 } // namespace cc 537 } // 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