OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/content_layer.h" | 5 #include "cc/layers/content_layer.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create( | 22 scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create( |
23 ContentLayerClient* client) { | 23 ContentLayerClient* client) { |
24 return make_scoped_ptr(new ContentLayerPainter(client)); | 24 return make_scoped_ptr(new ContentLayerPainter(client)); |
25 } | 25 } |
26 | 26 |
27 void ContentLayerPainter::Paint(SkCanvas* canvas, | 27 void ContentLayerPainter::Paint(SkCanvas* canvas, |
28 const gfx::Rect& content_rect, | 28 const gfx::Rect& content_rect, |
29 gfx::RectF* opaque) { | 29 gfx::RectF* opaque) { |
30 base::TimeTicks paint_start = base::TimeTicks::HighResNow(); | 30 base::TimeTicks paint_start = base::TimeTicks::HighResNow(); |
31 client_->PaintContents(canvas, content_rect, opaque); | 31 client_->PaintContents(canvas, |
| 32 content_rect, |
| 33 opaque, |
| 34 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
32 base::TimeTicks paint_end = base::TimeTicks::HighResNow(); | 35 base::TimeTicks paint_end = base::TimeTicks::HighResNow(); |
33 // The start and end times might be the same if the paint was very fast or if | 36 // The start and end times might be the same if the paint was very fast or if |
34 // our timer granularity is poor. Treat this as a very short time duration | 37 // our timer granularity is poor. Treat this as a very short time duration |
35 // instead of none to avoid dividing by zero. | 38 // instead of none to avoid dividing by zero. |
36 if (paint_end == paint_start) | 39 if (paint_end == paint_start) |
37 paint_end += base::TimeDelta::FromMicroseconds(1); | 40 paint_end += base::TimeDelta::FromMicroseconds(1); |
38 | 41 |
39 double pixels_per_sec = (content_rect.width() * content_rect.height()) / | 42 double pixels_per_sec = (content_rect.width() * content_rect.height()) / |
40 (paint_end - paint_start).InSecondsF(); | 43 (paint_end - paint_start).InSecondsF(); |
41 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", | 44 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { | 159 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { |
157 if (!DrawsContent()) | 160 if (!DrawsContent()) |
158 return skia::RefPtr<SkPicture>(); | 161 return skia::RefPtr<SkPicture>(); |
159 | 162 |
160 int width = bounds().width(); | 163 int width = bounds().width(); |
161 int height = bounds().height(); | 164 int height = bounds().height(); |
162 gfx::RectF opaque; | 165 gfx::RectF opaque; |
163 | 166 |
164 SkPictureRecorder recorder; | 167 SkPictureRecorder recorder; |
165 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); | 168 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); |
166 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); | 169 client_->PaintContents(canvas, |
| 170 gfx::Rect(width, height), |
| 171 &opaque, |
| 172 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
167 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 173 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
168 return picture; | 174 return picture; |
169 } | 175 } |
170 | 176 |
171 void ContentLayer::OnOutputSurfaceCreated() { | 177 void ContentLayer::OnOutputSurfaceCreated() { |
172 SetTextureFormat( | 178 SetTextureFormat( |
173 layer_tree_host()->GetRendererCapabilities().best_texture_format); | 179 layer_tree_host()->GetRendererCapabilities().best_texture_format); |
174 TiledLayer::OnOutputSurfaceCreated(); | 180 TiledLayer::OnOutputSurfaceCreated(); |
175 } | 181 } |
176 | 182 |
177 } // namespace cc | 183 } // namespace cc |
OLD | NEW |