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

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

Issue 315393002: Record SkPicture with correct LCD text setting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better unittest Created 6 years, 6 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/content_layer_updater.h" 5 #include "cc/resources/content_layer_updater.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "cc/debug/rendering_stats_instrumentation.h" 9 #include "cc/debug/rendering_stats_instrumentation.h"
10 #include "cc/resources/layer_painter.h" 10 #include "cc/resources/content_layer_painter.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "third_party/skia/include/core/SkPaint.h" 12 #include "third_party/skia/include/core/SkPaint.h"
13 #include "third_party/skia/include/core/SkRect.h" 13 #include "third_party/skia/include/core/SkRect.h"
14 #include "third_party/skia/include/core/SkScalar.h" 14 #include "third_party/skia/include/core/SkScalar.h"
15 #include "ui/gfx/rect_conversions.h" 15 #include "ui/gfx/rect_conversions.h"
16 #include "ui/gfx/rect_f.h" 16 #include "ui/gfx/rect_f.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 ContentLayerUpdater::ContentLayerUpdater( 20 ContentLayerUpdater::ContentLayerUpdater(
21 scoped_ptr<LayerPainter> painter, 21 scoped_ptr<ContentLayerPainter> painter,
22 RenderingStatsInstrumentation* stats_instrumentation, 22 RenderingStatsInstrumentation* stats_instrumentation,
23 int layer_id) 23 int layer_id)
24 : rendering_stats_instrumentation_(stats_instrumentation), 24 : rendering_stats_instrumentation_(stats_instrumentation),
25 layer_id_(layer_id), 25 layer_id_(layer_id),
26 layer_is_opaque_(false), 26 layer_is_opaque_(false),
27 layer_fills_bounds_completely_(false), 27 layer_fills_bounds_completely_(false),
28 painter_(painter.Pass()) {} 28 painter_(painter.Pass()),
29 can_use_lcd_text_(false) {
30 }
29 31
30 ContentLayerUpdater::~ContentLayerUpdater() {} 32 ContentLayerUpdater::~ContentLayerUpdater() {}
31 33
32 void ContentLayerUpdater::set_rendering_stats_instrumentation( 34 void ContentLayerUpdater::set_rendering_stats_instrumentation(
33 RenderingStatsInstrumentation* rsi) { 35 RenderingStatsInstrumentation* rsi) {
34 rendering_stats_instrumentation_ = rsi; 36 rendering_stats_instrumentation_ = rsi;
35 } 37 }
36 38
37 void ContentLayerUpdater::PaintContents(SkCanvas* canvas, 39 void ContentLayerUpdater::PaintContents(SkCanvas* canvas,
38 const gfx::Rect& content_rect, 40 const gfx::Rect& content_rect,
(...skipping 26 matching lines...) Expand all
65 canvas->clipRect(layer_sk_rect); 67 canvas->clipRect(layer_sk_rect);
66 68
67 // If the layer has opaque contents or will fill the bounds completely there 69 // If the layer has opaque contents or will fill the bounds completely there
68 // is no need to clear the canvas before painting. 70 // is no need to clear the canvas before painting.
69 if (!layer_is_opaque_ && !layer_fills_bounds_completely_) { 71 if (!layer_is_opaque_ && !layer_fills_bounds_completely_) {
70 TRACE_EVENT0("cc", "Clear"); 72 TRACE_EVENT0("cc", "Clear");
71 canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode); 73 canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode);
72 } 74 }
73 75
74 gfx::RectF opaque_layer_rect; 76 gfx::RectF opaque_layer_rect;
75 painter_->Paint(canvas, layer_rect, &opaque_layer_rect); 77 painter_->Paint(canvas, layer_rect, can_use_lcd_text_, &opaque_layer_rect);
76 canvas->restore(); 78 canvas->restore();
77 79
78 gfx::Rect opaque_content_rect = gfx::ToEnclosedRect(gfx::ScaleRect( 80 gfx::Rect opaque_content_rect = gfx::ToEnclosedRect(gfx::ScaleRect(
79 opaque_layer_rect, contents_width_scale, contents_height_scale)); 81 opaque_layer_rect, contents_width_scale, contents_height_scale));
80 *resulting_opaque_rect = opaque_content_rect; 82 *resulting_opaque_rect = opaque_content_rect;
81 83
82 content_rect_ = content_rect; 84 content_rect_ = content_rect;
83 } 85 }
84 86
85 void ContentLayerUpdater::SetOpaque(bool opaque) { 87 void ContentLayerUpdater::SetOpaque(bool opaque) {
86 layer_is_opaque_ = opaque; 88 layer_is_opaque_ = opaque;
87 } 89 }
88 90
89 void ContentLayerUpdater::SetFillsBoundsCompletely(bool fills_bounds) { 91 void ContentLayerUpdater::SetFillsBoundsCompletely(bool fills_bounds) {
90 layer_fills_bounds_completely_ = fills_bounds; 92 layer_fills_bounds_completely_ = fills_bounds;
91 } 93 }
92 94
93 } // namespace cc 95 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698