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

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: Remove default arguments 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
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 "skia/ext/alpha_proxy_canvas.h"
22 #include "third_party/skia/include/core/SkCanvas.h" 23 #include "third_party/skia/include/core/SkCanvas.h"
23 #include "third_party/skia/include/core/SkColor.h" 24 #include "third_party/skia/include/core/SkColor.h"
24 #include "third_party/skia/include/core/SkDevice.h" 25 #include "third_party/skia/include/core/SkDevice.h"
25 #include "third_party/skia/include/core/SkMatrix.h" 26 #include "third_party/skia/include/core/SkMatrix.h"
26 #include "third_party/skia/include/core/SkShader.h" 27 #include "third_party/skia/include/core/SkShader.h"
27 #include "third_party/skia/include/effects/SkLayerRasterizer.h" 28 #include "third_party/skia/include/effects/SkLayerRasterizer.h"
28 #include "ui/gfx/rect_conversions.h" 29 #include "ui/gfx/rect_conversions.h"
29 #include "ui/gfx/skia_util.h" 30 #include "ui/gfx/skia_util.h"
30 #include "ui/gfx/transform.h" 31 #include "ui/gfx/transform.h"
31 32
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 SkPoint transformed_vertices[4]; 291 SkPoint transformed_vertices[4];
291 current_canvas_->getTotalMatrix().mapPoints(transformed_vertices, 292 current_canvas_->getTotalMatrix().mapPoints(transformed_vertices,
292 vertices, 293 vertices,
293 4); 294 4);
294 current_canvas_->resetMatrix(); 295 current_canvas_->resetMatrix();
295 296
296 current_paint_.setColor(quad->color); 297 current_paint_.setColor(quad->color);
297 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color)); 298 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color));
298 current_paint_.setStyle(SkPaint::kStroke_Style); 299 current_paint_.setStyle(SkPaint::kStroke_Style);
299 current_paint_.setStrokeWidth(quad->width); 300 current_paint_.setStrokeWidth(quad->width);
300 current_canvas_->drawPoints(SkCanvas::kPolygon_PointMode, 301 current_canvas_->drawPoints(
301 4, transformed_vertices, current_paint_); 302 SkCanvas::kPolygon_PointMode, 4, transformed_vertices, current_paint_);
302 } 303 }
303 304
304 void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame, 305 void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame,
305 const PictureDrawQuad* quad) { 306 const PictureDrawQuad* quad) {
306 SkMatrix content_matrix; 307 SkMatrix content_matrix;
307 content_matrix.setRectToRect( 308 content_matrix.setRectToRect(
308 gfx::RectFToSkRect(quad->tex_coord_rect), 309 gfx::RectFToSkRect(quad->tex_coord_rect),
309 gfx::RectFToSkRect(QuadVertexRect()), 310 gfx::RectFToSkRect(QuadVertexRect()),
310 SkMatrix::kFill_ScaleToFit); 311 SkMatrix::kFill_ScaleToFit);
311 current_canvas_->concat(content_matrix); 312 current_canvas_->concat(content_matrix);
312 313
313 if (quad->ShouldDrawWithBlending()) { 314 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad");
314 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad with blending"); 315 skia::AlphaProxyCanvas proxy_canvas(current_canvas_, quad->opacity(), false);
315 SkBitmap temp_bitmap; 316 quad->picture_pile->RasterDirect(
316 temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 317 &proxy_canvas, quad->content_rect, quad->contents_scale, NULL);
317 quad->texture_size.width(),
318 quad->texture_size.height());
319 temp_bitmap.allocPixels();
320 SkDevice temp_device(temp_bitmap);
321 SkCanvas temp_canvas(&temp_device);
322
323 quad->picture_pile->RasterToBitmap(
324 &temp_canvas, quad->content_rect, quad->contents_scale, NULL);
325
326 current_paint_.setFilterBitmap(true);
327 current_canvas_->drawBitmap(temp_bitmap, 0, 0, &current_paint_);
328 } else {
329 TRACE_EVENT0("cc",
330 "SoftwareRenderer::DrawPictureQuad direct from PicturePile");
331 quad->picture_pile->RasterDirect(
332 current_canvas_, quad->content_rect, quad->contents_scale, NULL);
333 }
334 } 318 }
335 319
336 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame, 320 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
337 const SolidColorDrawQuad* quad) { 321 const SolidColorDrawQuad* quad) {
338 current_paint_.setColor(quad->color); 322 current_paint_.setColor(quad->color);
339 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color)); 323 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color));
340 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()), 324 current_canvas_->drawRect(gfx::RectFToSkRect(QuadVertexRect()),
341 current_paint_); 325 current_paint_);
342 } 326 }
343 327
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 visible_ = visible; 497 visible_ = visible;
514 } 498 }
515 499
516 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { 500 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) {
517 // TODO(piman, skaslev): Can we release the backbuffer? We don't currently 501 // TODO(piman, skaslev): Can we release the backbuffer? We don't currently
518 // receive memory policy yet anyway. 502 // receive memory policy yet anyway.
519 NOTIMPLEMENTED(); 503 NOTIMPLEMENTED();
520 } 504 }
521 505
522 } // namespace cc 506 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698