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 "third_party/skia/include/core/SkData.h" | 10 #include "third_party/skia/include/core/SkData.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 scoped_refptr<Picture> Picture::Clone() const { | 41 scoped_refptr<Picture> Picture::Clone() const { |
42 // SkPicture is not thread-safe to rasterize with, so return a thread-safe | 42 // SkPicture is not thread-safe to rasterize with, so return a thread-safe |
43 // clone of it. | 43 // clone of it. |
44 DCHECK(picture_); | 44 DCHECK(picture_); |
45 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone()); | 45 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone()); |
46 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); | 46 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); |
47 } | 47 } |
48 | 48 |
49 void Picture::Record(ContentLayerClient* painter, | 49 void Picture::Record(ContentLayerClient* painter, |
50 RenderingStats& stats) { | 50 RenderingStats& stats) { |
51 TRACE_EVENT0("cc", "Picture::Record"); | 51 TRACE_EVENT2("cc", "Picture::Record", |
| 52 "width", layer_rect_.width(), "height", layer_rect_.height()); |
52 | 53 |
53 // Record() should only be called once. | 54 // Record() should only be called once. |
54 DCHECK(!picture_); | 55 DCHECK(!picture_); |
55 picture_ = skia::AdoptRef(new SkPicture); | 56 picture_ = skia::AdoptRef(new SkPicture); |
56 | 57 |
57 // TODO(enne): Use SkPicture::kOptimizeForClippedPlayback_RecordingFlag | 58 // TODO(enne): Use SkPicture::kOptimizeForClippedPlayback_RecordingFlag |
58 // once http://code.google.com/p/skia/issues/detail?id=1014 is fixed. | 59 // once http://code.google.com/p/skia/issues/detail?id=1014 is fixed. |
59 SkCanvas* canvas = picture_->beginRecording( | 60 SkCanvas* canvas = picture_->beginRecording( |
60 layer_rect_.width(), | 61 layer_rect_.width(), |
61 layer_rect_.height(), | 62 layer_rect_.height(), |
(...skipping 24 matching lines...) Expand all Loading... |
86 canvas->restore(); | 87 canvas->restore(); |
87 picture_->endRecording(); | 88 picture_->endRecording(); |
88 | 89 |
89 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 90 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
90 } | 91 } |
91 | 92 |
92 void Picture::Raster( | 93 void Picture::Raster( |
93 SkCanvas* canvas, | 94 SkCanvas* canvas, |
94 gfx::Rect content_rect, | 95 gfx::Rect content_rect, |
95 float contents_scale) { | 96 float contents_scale) { |
96 TRACE_EVENT0("cc", "Picture::Raster"); | 97 TRACE_EVENT2("cc", "Picture::Raster", |
| 98 "width", layer_rect_.width(), "height", layer_rect_.height()); |
97 DCHECK(picture_); | 99 DCHECK(picture_); |
98 | 100 |
99 canvas->save(); | 101 canvas->save(); |
100 canvas->clipRect(gfx::RectToSkRect(content_rect)); | 102 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
101 canvas->scale(contents_scale, contents_scale); | 103 canvas->scale(contents_scale, contents_scale); |
102 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 104 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
103 canvas->drawPicture(*picture_); | 105 canvas->drawPicture(*picture_); |
104 canvas->restore(); | 106 canvas->restore(); |
105 } | 107 } |
106 | 108 |
(...skipping 19 matching lines...) Expand all Loading... |
126 if (*refs && (*refs)->getURI() && !strncmp( | 128 if (*refs && (*refs)->getURI() && !strncmp( |
127 (*refs)->getURI(), labelLazyDecoded, 4)) { | 129 (*refs)->getURI(), labelLazyDecoded, 4)) { |
128 result.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 130 result.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
129 } | 131 } |
130 refs++; | 132 refs++; |
131 } | 133 } |
132 pixel_refs->unref(); | 134 pixel_refs->unref(); |
133 } | 135 } |
134 | 136 |
135 } // namespace cc | 137 } // namespace cc |
OLD | NEW |