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

Side by Side Diff: cc/content_layer_updater.cc

Issue 12095053: cc: Avoid expensive RenderingStats collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 10 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
« no previous file with comments | « cc/content_layer_updater.h ('k') | cc/contents_scaling_layer.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 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/content_layer_updater.h" 5 #include "cc/content_layer_updater.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "cc/layer_painter.h" 9 #include "cc/layer_painter.h"
10 #include "cc/rendering_stats.h" 10 #include "cc/rendering_stats.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(scoped_ptr<LayerPainter> painter) 20 ContentLayerUpdater::ContentLayerUpdater(scoped_ptr<LayerPainter> painter)
21 : m_painter(painter.Pass()) 21 : m_painter(painter.Pass())
22 { 22 {
23 } 23 }
24 24
25 ContentLayerUpdater::~ContentLayerUpdater() 25 ContentLayerUpdater::~ContentLayerUpdater()
26 { 26 {
27 } 27 }
28 28
29 void ContentLayerUpdater::paintContents(SkCanvas* canvas, const gfx::Rect& conte ntRect, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultin gOpaqueRect, RenderingStats& stats) 29 void ContentLayerUpdater::paintContents(SkCanvas* canvas, const gfx::Rect& conte ntRect, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultin gOpaqueRect, RenderingStats* stats)
30 { 30 {
31 TRACE_EVENT0("cc", "ContentLayerUpdater::paintContents"); 31 TRACE_EVENT0("cc", "ContentLayerUpdater::paintContents");
32 canvas->save(); 32 canvas->save();
33 canvas->translate(SkFloatToScalar(-contentRect.x()), SkFloatToScalar(-conten tRect.y())); 33 canvas->translate(SkFloatToScalar(-contentRect.x()), SkFloatToScalar(-conten tRect.y()));
34 34
35 gfx::Rect layerRect = contentRect; 35 gfx::Rect layerRect = contentRect;
36 36
37 if (contentsWidthScale != 1 || contentsHeightScale != 1) { 37 if (contentsWidthScale != 1 || contentsHeightScale != 1) {
38 canvas->scale(SkFloatToScalar(contentsWidthScale), SkFloatToScalar(conte ntsHeightScale)); 38 canvas->scale(SkFloatToScalar(contentsWidthScale), SkFloatToScalar(conte ntsHeightScale));
39 39
40 gfx::RectF rect = gfx::ScaleRect(contentRect, 1 / contentsWidthScale, 1 / contentsHeightScale); 40 gfx::RectF rect = gfx::ScaleRect(contentRect, 1 / contentsWidthScale, 1 / contentsHeightScale);
41 layerRect = gfx::ToEnclosingRect(rect); 41 layerRect = gfx::ToEnclosingRect(rect);
42 } 42 }
43 43
44 SkPaint paint; 44 SkPaint paint;
45 paint.setAntiAlias(false); 45 paint.setAntiAlias(false);
46 paint.setXfermodeMode(SkXfermode::kClear_Mode); 46 paint.setXfermodeMode(SkXfermode::kClear_Mode);
47 SkRect layerSkRect = SkRect::MakeXYWH(layerRect.x(), layerRect.y(), layerRec t.width(), layerRect.height()); 47 SkRect layerSkRect = SkRect::MakeXYWH(layerRect.x(), layerRect.y(), layerRec t.width(), layerRect.height());
48 canvas->drawRect(layerSkRect, paint); 48 canvas->drawRect(layerSkRect, paint);
49 canvas->clipRect(layerSkRect); 49 canvas->clipRect(layerSkRect);
50 50
51 gfx::RectF opaqueLayerRect; 51 gfx::RectF opaqueLayerRect;
52 base::TimeTicks paintBeginTime = base::TimeTicks::Now(); 52 base::TimeTicks paintBeginTime;
53 if (stats)
54 paintBeginTime = base::TimeTicks::Now();
53 m_painter->paint(canvas, layerRect, opaqueLayerRect); 55 m_painter->paint(canvas, layerRect, opaqueLayerRect);
54 stats.totalPaintTime += base::TimeTicks::Now() - paintBeginTime; 56 if (stats) {
57 stats->totalPaintTime += base::TimeTicks::Now() - paintBeginTime;
58 stats->totalPixelsPainted += contentRect.width() * contentRect.height();
59 }
55 canvas->restore(); 60 canvas->restore();
56 61
57 stats.totalPixelsPainted += contentRect.width() * contentRect.height();
58
59 gfx::RectF opaqueContentRect = gfx::ScaleRect(opaqueLayerRect, contentsWidth Scale, contentsHeightScale); 62 gfx::RectF opaqueContentRect = gfx::ScaleRect(opaqueLayerRect, contentsWidth Scale, contentsHeightScale);
60 resultingOpaqueRect = gfx::ToEnclosedRect(opaqueContentRect); 63 resultingOpaqueRect = gfx::ToEnclosedRect(opaqueContentRect);
61 64
62 m_contentRect = contentRect; 65 m_contentRect = contentRect;
63 } 66 }
64 67
65 } // namespace cc 68 } // namespace cc
OLDNEW
« no previous file with comments | « cc/content_layer_updater.h ('k') | cc/contents_scaling_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698