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

Side by Side Diff: cc/resources/raster_source_helper.cc

Issue 1139063002: cc: Partial tile update for one-copy raster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: monocle: spaces_sorted Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/resources/raster_source_helper.h" 5 #include "cc/resources/raster_source_helper.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "cc/debug/debug_colors.h" 8 #include "cc/debug/debug_colors.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/geometry/rect_conversions.h" 10 #include "ui/gfx/geometry/rect_conversions.h"
11 #include "ui/gfx/skia_util.h" 11 #include "ui/gfx/skia_util.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 void RasterSourceHelper::PrepareForPlaybackToCanvas( 15 void RasterSourceHelper::PrepareForPlaybackToCanvas(
16 SkCanvas* canvas, 16 SkCanvas* canvas,
17 const gfx::Rect& canvas_rect, 17 const gfx::Rect& canvas_rect,
18 const gfx::Rect& source_rect, 18 const gfx::Rect& source_rect,
19 float contents_scale, 19 float contents_scale,
20 SkColor background_color, 20 SkColor background_color,
21 bool clear_canvas_with_debug_color, 21 bool clear_canvas_with_debug_color,
22 bool requires_clear) { 22 bool requires_clear,
23 canvas->discard(); 23 bool partial_update) {
24 if (!partial_update)
25 canvas->discard();
24 if (clear_canvas_with_debug_color) { 26 if (clear_canvas_with_debug_color) {
25 // Any non-painted areas in the content bounds will be left in this color. 27 // Any non-painted areas in the content bounds will be left in this color.
26 canvas->clear(DebugColors::NonPaintedFillColor()); 28 if (!partial_update) {
29 canvas->clear(DebugColors::NonPaintedFillColor());
30 } else {
31 canvas->save();
32 canvas->clipRect(gfx::RectToSkRect(gfx::Rect(canvas_rect.size())));
33 canvas->drawColor(DebugColors::NonPaintedFillColor());
34 canvas->restore();
35 }
27 } 36 }
28 37
29 // If this raster source has opaque contents, it is guaranteeing that it will 38 // If this raster source has opaque contents, it is guaranteeing that it will
30 // draw an opaque rect the size of the layer. If it is not, then we must 39 // draw an opaque rect the size of the layer. If it is not, then we must
31 // clear this canvas ourselves. 40 // clear this canvas ourselves.
32 if (requires_clear) { 41 if (requires_clear) {
33 TRACE_EVENT_INSTANT0("cc", "SkCanvas::clear", TRACE_EVENT_SCOPE_THREAD); 42 TRACE_EVENT_INSTANT0("cc", "SkCanvas::clear", TRACE_EVENT_SCOPE_THREAD);
34 // Clearing is about ~4x faster than drawing a rect even if the content 43 // Clearing is about ~4x faster than drawing a rect even if the content
35 // isn't covering a majority of the canvas. 44 // isn't covering a majority of the canvas.
36 canvas->clear(SK_ColorTRANSPARENT); 45 if (!partial_update) {
46 canvas->clear(SK_ColorTRANSPARENT);
47 } else {
48 canvas->save();
49 canvas->clipRect(gfx::RectToSkRect(gfx::Rect(canvas_rect.size())));
50 canvas->drawColor(SK_ColorTRANSPARENT);
51 canvas->restore();
52 }
37 } else { 53 } else {
38 // Even if completely covered, for rasterizations that touch the edge of the 54 // Even if completely covered, for rasterizations that touch the edge of the
39 // layer, we also need to raster the background color underneath the last 55 // layer, we also need to raster the background color underneath the last
40 // texel (since the recording won't cover it) and outside the last texel 56 // texel (since the recording won't cover it) and outside the last texel
41 // (due to linear filtering when using this texture). 57 // (due to linear filtering when using this texture).
42 gfx::Rect content_rect = 58 gfx::Rect content_rect =
43 gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, contents_scale)); 59 gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, contents_scale));
44 60
45 // The final texel of content may only be partially covered by a 61 // The final texel of content may only be partially covered by a
46 // rasterization; this rect represents the content rect that is fully 62 // rasterization; this rect represents the content rect that is fully
(...skipping 25 matching lines...) Expand all
72 SkRegion::kReplace_Op); 88 SkRegion::kReplace_Op);
73 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), 89 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
74 SkRegion::kDifference_Op); 90 SkRegion::kDifference_Op);
75 canvas->drawColor(background_color, SkXfermode::kSrc_Mode); 91 canvas->drawColor(background_color, SkXfermode::kSrc_Mode);
76 canvas->restore(); 92 canvas->restore();
77 } 93 }
78 } 94 }
79 } 95 }
80 96
81 } // namespace cc 97 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698