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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 stats.totalPaintTime += base::TimeTicks::Now() - beginPaintTime; | 85 stats.totalPaintTime += base::TimeTicks::Now() - beginPaintTime; |
86 stats.totalPixelsPainted += layer_rect_.width() * | 86 stats.totalPixelsPainted += layer_rect_.width() * |
87 layer_rect_.height(); | 87 layer_rect_.height(); |
88 | 88 |
89 canvas->restore(); | 89 canvas->restore(); |
90 picture_->endRecording(); | 90 picture_->endRecording(); |
91 | 91 |
92 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 92 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
93 } | 93 } |
94 | 94 |
95 void Picture::IsCheapInRect(gfx::Rect contents, float contents_scale) { | |
enne (OOO)
2013/01/31 21:34:37
Did you mean to add this too?
| |
96 return false; | |
97 } | |
98 | |
95 void Picture::Raster( | 99 void Picture::Raster( |
96 SkCanvas* canvas, | 100 SkCanvas* canvas, |
97 gfx::Rect content_rect, | 101 gfx::Rect content_rect, |
98 float contents_scale) { | 102 float contents_scale) { |
99 TRACE_EVENT2("cc", "Picture::Raster", | 103 TRACE_EVENT2("cc", "Picture::Raster", |
100 "width", layer_rect_.width(), "height", layer_rect_.height()); | 104 "width", layer_rect_.width(), "height", layer_rect_.height()); |
101 DCHECK(picture_); | 105 DCHECK(picture_); |
102 | 106 |
103 canvas->save(); | 107 canvas->save(); |
104 canvas->clipRect(gfx::RectToSkRect(content_rect)); | 108 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
105 canvas->scale(contents_scale, contents_scale); | 109 canvas->scale(contents_scale, contents_scale); |
106 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 110 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
107 canvas->drawPicture(*picture_); | 111 canvas->drawPicture(*picture_); |
108 canvas->restore(); | 112 canvas->restore(); |
109 } | 113 } |
110 | 114 |
115 void Picture::WillRasterTakeLessThanOneMillisecond(const gfx::Rect& layer_rect) { | |
enne (OOO)
2013/01/31 21:34:37
This is an awfully specific name. Is EstimatedRas
| |
116 return false; | |
117 } | |
118 | |
111 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, | 119 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, |
112 std::list<skia::LazyPixelRef*>& pixel_ref_list) { | 120 std::list<skia::LazyPixelRef*>& pixel_ref_list) { |
113 DCHECK(picture_); | 121 DCHECK(picture_); |
114 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( | 122 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
115 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), | 123 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), |
116 layer_rect.y(), | 124 layer_rect.y(), |
117 layer_rect.width(), | 125 layer_rect.width(), |
118 layer_rect.height())); | 126 layer_rect.height())); |
119 if (!pixel_refs) | 127 if (!pixel_refs) |
120 return; | 128 return; |
121 | 129 |
122 void* data = const_cast<void*>(pixel_refs->data()); | 130 void* data = const_cast<void*>(pixel_refs->data()); |
123 if (!data) { | 131 if (!data) { |
124 pixel_refs->unref(); | 132 pixel_refs->unref(); |
125 return; | 133 return; |
126 } | 134 } |
127 | 135 |
128 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); | 136 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); |
129 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { | 137 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { |
130 if (*refs && (*refs)->getURI() && !strncmp( | 138 if (*refs && (*refs)->getURI() && !strncmp( |
131 (*refs)->getURI(), labelLazyDecoded, 4)) { | 139 (*refs)->getURI(), labelLazyDecoded, 4)) { |
132 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 140 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
133 } | 141 } |
134 refs++; | 142 refs++; |
135 } | 143 } |
136 pixel_refs->unref(); | 144 pixel_refs->unref(); |
137 } | 145 } |
138 | 146 |
139 } // namespace cc | 147 } // namespace cc |
OLD | NEW |