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/content_layer_client.h" | 6 #include "cc/content_layer_client.h" |
7 #include "cc/picture.h" | 7 #include "cc/picture.h" |
8 #include "cc/rendering_stats.h" | 8 #include "cc/rendering_stats.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 55 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
56 SkFloatToScalar(-layer_rect_.y())); | 56 SkFloatToScalar(-layer_rect_.y())); |
57 | 57 |
58 SkPaint paint; | 58 SkPaint paint; |
59 paint.setAntiAlias(false); | 59 paint.setAntiAlias(false); |
60 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 60 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
61 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), | 61 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), |
62 layer_rect_.y(), | 62 layer_rect_.y(), |
63 layer_rect_.width(), | 63 layer_rect_.width(), |
64 layer_rect_.height()); | 64 layer_rect_.height()); |
| 65 canvas->clipRect(layer_skrect); |
65 canvas->drawRect(layer_skrect, paint); | 66 canvas->drawRect(layer_skrect, paint); |
66 canvas->clipRect(layer_skrect); | |
67 | 67 |
68 gfx::RectF opaque_layer_rect; | 68 gfx::RectF opaque_layer_rect; |
69 base::TimeTicks beginPaintTime = base::TimeTicks::Now(); | 69 base::TimeTicks beginPaintTime = base::TimeTicks::Now(); |
70 painter->paintContents(canvas, layer_rect_, opaque_layer_rect); | 70 painter->paintContents(canvas, layer_rect_, opaque_layer_rect); |
71 double delta = (base::TimeTicks::Now() - beginPaintTime).InSecondsF(); | 71 double delta = (base::TimeTicks::Now() - beginPaintTime).InSecondsF(); |
72 stats.totalPaintTimeInSeconds += delta; | 72 stats.totalPaintTimeInSeconds += delta; |
73 stats.totalPixelsPainted += layer_rect_.width() * | 73 stats.totalPixelsPainted += layer_rect_.width() * |
74 layer_rect_.height(); | 74 layer_rect_.height(); |
75 | 75 |
76 canvas->restore(); | 76 canvas->restore(); |
77 picture_->endRecording(); | 77 picture_->endRecording(); |
78 | 78 |
79 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 79 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
80 } | 80 } |
81 | 81 |
82 void Picture::Raster(SkCanvas* canvas) { | 82 void Picture::Raster(SkCanvas* canvas) { |
83 TRACE_EVENT0("cc", "Picture::Raster"); | 83 TRACE_EVENT0("cc", "Picture::Raster"); |
84 DCHECK(picture_); | 84 DCHECK(picture_); |
85 canvas->save(); | 85 canvas->save(); |
86 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 86 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
87 canvas->drawPicture(*picture_); | 87 canvas->drawPicture(*picture_); |
88 canvas->restore(); | 88 canvas->restore(); |
89 } | 89 } |
90 | 90 |
91 } // namespace cc | 91 } // namespace cc |
OLD | NEW |