| OLD | NEW |
| 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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
| 6 #include "cc/debug/rendering_stats.h" | 6 #include "cc/debug/rendering_stats_instrumentation.h" |
| 7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
| 8 #include "cc/resources/picture.h" | 8 #include "cc/resources/picture.h" |
| 9 #include "skia/ext/analysis_canvas.h" | 9 #include "skia/ext/analysis_canvas.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #include "third_party/skia/include/core/SkData.h" | 11 #include "third_party/skia/include/core/SkData.h" |
| 12 #include "third_party/skia/include/core/SkDrawFilter.h" | 12 #include "third_party/skia/include/core/SkDrawFilter.h" |
| 13 #include "third_party/skia/include/core/SkPaint.h" | 13 #include "third_party/skia/include/core/SkPaint.h" |
| 14 #include "third_party/skia/include/utils/SkPictureUtils.h" | 14 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 15 #include "ui/gfx/rect_conversions.h" | 15 #include "ui/gfx/rect_conversions.h" |
| 16 #include "ui/gfx/skia_util.h" | 16 #include "ui/gfx/skia_util.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 for (int i = 0; i < num_threads; i++) { | 73 for (int i = 0; i < num_threads; i++) { |
| 74 scoped_refptr<Picture> clone = make_scoped_refptr( | 74 scoped_refptr<Picture> clone = make_scoped_refptr( |
| 75 new Picture(skia::AdoptRef(new SkPicture(clones[i])), | 75 new Picture(skia::AdoptRef(new SkPicture(clones[i])), |
| 76 layer_rect_, | 76 layer_rect_, |
| 77 opaque_rect_)); | 77 opaque_rect_)); |
| 78 clones_.push_back(clone); | 78 clones_.push_back(clone); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void Picture::Record(ContentLayerClient* painter, | 82 void Picture::Record(ContentLayerClient* painter, |
| 83 RenderingStats* stats, | 83 RenderingStatsInstrumentation* stats_instrumentation, |
| 84 const SkTileGridPicture::TileGridInfo& tile_grid_info) { | 84 const SkTileGridPicture::TileGridInfo& tile_grid_info) { |
| 85 TRACE_EVENT2("cc", "Picture::Record", | 85 TRACE_EVENT2("cc", "Picture::Record", |
| 86 "width", layer_rect_.width(), "height", layer_rect_.height()); | 86 "width", layer_rect_.width(), "height", layer_rect_.height()); |
| 87 | 87 |
| 88 // Record() should only be called once. | 88 // Record() should only be called once. |
| 89 DCHECK(!picture_); | 89 DCHECK(!picture_); |
| 90 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); | 90 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); |
| 91 picture_ = skia::AdoptRef(new SkTileGridPicture( | 91 picture_ = skia::AdoptRef(new SkTileGridPicture( |
| 92 layer_rect_.width(), layer_rect_.height(), tile_grid_info)); | 92 layer_rect_.width(), layer_rect_.height(), tile_grid_info)); |
| 93 | 93 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 105 paint.setAntiAlias(false); | 105 paint.setAntiAlias(false); |
| 106 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 106 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
| 107 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), | 107 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), |
| 108 layer_rect_.y(), | 108 layer_rect_.y(), |
| 109 layer_rect_.width(), | 109 layer_rect_.width(), |
| 110 layer_rect_.height()); | 110 layer_rect_.height()); |
| 111 canvas->clipRect(layer_skrect); | 111 canvas->clipRect(layer_skrect); |
| 112 canvas->drawRect(layer_skrect, paint); | 112 canvas->drawRect(layer_skrect, paint); |
| 113 | 113 |
| 114 gfx::RectF opaque_layer_rect; | 114 gfx::RectF opaque_layer_rect; |
| 115 base::TimeTicks begin_paint_time; | 115 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
| 116 if (stats) | 116 |
| 117 begin_paint_time = base::TimeTicks::Now(); | |
| 118 painter->PaintContents(canvas, layer_rect_, &opaque_layer_rect); | 117 painter->PaintContents(canvas, layer_rect_, &opaque_layer_rect); |
| 119 if (stats) { | 118 |
| 120 stats->total_paint_time += base::TimeTicks::Now() - begin_paint_time; | 119 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); |
| 121 stats->total_pixels_painted += | 120 stats_instrumentation->AddPaint(duration, |
| 122 layer_rect_.width() * layer_rect_.height(); | 121 layer_rect_.width() * layer_rect_.height()); |
| 123 } | |
| 124 | 122 |
| 125 canvas->restore(); | 123 canvas->restore(); |
| 126 picture_->endRecording(); | 124 picture_->endRecording(); |
| 127 | 125 |
| 128 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 126 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
| 129 } | 127 } |
| 130 | 128 |
| 131 void Picture::Raster( | 129 void Picture::Raster( |
| 132 SkCanvas* canvas, | 130 SkCanvas* canvas, |
| 133 gfx::Rect content_rect, | 131 gfx::Rect content_rect, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (*refs && (*refs)->getURI() && !strncmp( | 171 if (*refs && (*refs)->getURI() && !strncmp( |
| 174 (*refs)->getURI(), kLabelLazyDecoded, 4)) { | 172 (*refs)->getURI(), kLabelLazyDecoded, 4)) { |
| 175 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 173 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
| 176 } | 174 } |
| 177 refs++; | 175 refs++; |
| 178 } | 176 } |
| 179 pixel_refs->unref(); | 177 pixel_refs->unref(); |
| 180 } | 178 } |
| 181 | 179 |
| 182 } // namespace cc | 180 } // namespace cc |
| OLD | NEW |