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 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 void Picture::Record(ContentLayerClient* painter, | 41 void Picture::Record(ContentLayerClient* painter, |
42 RenderingStats& stats) { | 42 RenderingStats& stats) { |
43 TRACE_EVENT0("cc", "Picture::Record"); | 43 TRACE_EVENT0("cc", "Picture::Record"); |
44 | 44 |
45 // Record() should only be called once. | 45 // Record() should only be called once. |
46 DCHECK(!picture_); | 46 DCHECK(!picture_); |
47 picture_ = skia::AdoptRef(new SkPicture); | 47 picture_ = skia::AdoptRef(new SkPicture); |
48 | 48 |
| 49 // TODO(enne): Use SkPicture::kOptimizeForClippedPlayback_RecordingFlag |
| 50 // once http://code.google.com/p/skia/issues/detail?id=1014 is fixed. |
49 SkCanvas* canvas = picture_->beginRecording( | 51 SkCanvas* canvas = picture_->beginRecording( |
50 layer_rect_.width(), | 52 layer_rect_.width(), |
51 layer_rect_.height(), | 53 layer_rect_.height()); |
52 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); | |
53 | 54 |
54 canvas->save(); | 55 canvas->save(); |
55 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 56 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
56 SkFloatToScalar(-layer_rect_.y())); | 57 SkFloatToScalar(-layer_rect_.y())); |
57 | 58 |
58 SkPaint paint; | 59 SkPaint paint; |
59 paint.setAntiAlias(false); | 60 paint.setAntiAlias(false); |
60 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 61 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
61 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), | 62 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), |
62 layer_rect_.y(), | 63 layer_rect_.y(), |
(...skipping 19 matching lines...) Expand all Loading... |
82 void Picture::Raster(SkCanvas* canvas) { | 83 void Picture::Raster(SkCanvas* canvas) { |
83 TRACE_EVENT0("cc", "Picture::Raster"); | 84 TRACE_EVENT0("cc", "Picture::Raster"); |
84 DCHECK(picture_); | 85 DCHECK(picture_); |
85 canvas->save(); | 86 canvas->save(); |
86 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 87 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
87 canvas->drawPicture(*picture_); | 88 canvas->drawPicture(*picture_); |
88 canvas->restore(); | 89 canvas->restore(); |
89 } | 90 } |
90 | 91 |
91 } // namespace cc | 92 } // namespace cc |
OLD | NEW |