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 "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" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 DCHECK(picture_); | 123 DCHECK(picture_); |
124 | 124 |
125 canvas->save(); | 125 canvas->save(); |
126 canvas->clipRect(gfx::RectToSkRect(content_rect)); | 126 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
127 canvas->scale(contents_scale, contents_scale); | 127 canvas->scale(contents_scale, contents_scale); |
128 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 128 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
129 canvas->drawPicture(*picture_); | 129 canvas->drawPicture(*picture_); |
130 canvas->restore(); | 130 canvas->restore(); |
131 } | 131 } |
132 | 132 |
133 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) const { | 133 void Picture::AnalyzeInRect(skia::AnalysisCanvas* canvas, |
134 TRACE_EVENT0("cc", "Picture::IsCheapInRect"); | 134 const gfx::Rect& content_rect, |
135 | 135 float contents_scale) { |
136 SkBitmap emptyBitmap; | 136 canvas->save(); |
137 emptyBitmap.setConfig(SkBitmap::kNo_Config, layer_rect.width(), | 137 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
138 layer_rect.height()); | 138 canvas->scale(contents_scale, contents_scale); |
139 skia::AnalysisDevice device(emptyBitmap); | 139 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
140 skia::AnalysisCanvas canvas(&device); | 140 canvas->drawPicture(*picture_); |
141 | 141 canvas->restore(); |
142 canvas.drawPicture(*picture_); | |
143 return canvas.isCheap(); | |
144 } | 142 } |
145 | 143 |
146 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, | 144 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, |
147 std::list<skia::LazyPixelRef*>& pixel_ref_list) { | 145 std::list<skia::LazyPixelRef*>& pixel_ref_list) { |
148 DCHECK(picture_); | 146 DCHECK(picture_); |
149 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( | 147 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
150 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), | 148 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), |
151 layer_rect.y(), | 149 layer_rect.y(), |
152 layer_rect.width(), | 150 layer_rect.width(), |
153 layer_rect.height())); | 151 layer_rect.height())); |
(...skipping 11 matching lines...) Expand all Loading... |
165 if (*refs && (*refs)->getURI() && !strncmp( | 163 if (*refs && (*refs)->getURI() && !strncmp( |
166 (*refs)->getURI(), labelLazyDecoded, 4)) { | 164 (*refs)->getURI(), labelLazyDecoded, 4)) { |
167 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 165 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
168 } | 166 } |
169 refs++; | 167 refs++; |
170 } | 168 } |
171 pixel_refs->unref(); | 169 pixel_refs->unref(); |
172 } | 170 } |
173 | 171 |
174 } // namespace cc | 172 } // namespace cc |
OLD | NEW |