OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/playback/display_item_list.h" | 5 #include "cc/playback/display_item_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // rects. For now we just clear them out since we won't ever need | 177 // rects. For now we just clear them out since we won't ever need |
178 // them to stick around post-Finalize. http://crbug.com/527245 | 178 // them to stick around post-Finalize. http://crbug.com/527245 |
179 // This clears both the vector and the vector's capacity, since visual_rects_ | 179 // This clears both the vector and the vector's capacity, since visual_rects_ |
180 // won't be used anymore. | 180 // won't be used anymore. |
181 std::vector<gfx::Rect>().swap(visual_rects_); | 181 std::vector<gfx::Rect>().swap(visual_rects_); |
182 | 182 |
183 if (settings_.use_cached_picture) { | 183 if (settings_.use_cached_picture) { |
184 // Convert to an SkPicture for faster rasterization. | 184 // Convert to an SkPicture for faster rasterization. |
185 DCHECK(settings_.use_cached_picture); | 185 DCHECK(settings_.use_cached_picture); |
186 DCHECK(!picture_); | 186 DCHECK(!picture_); |
187 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); | 187 picture_ = recorder_->finishRecordingAsPicture(); |
188 DCHECK(picture_); | 188 DCHECK(picture_); |
189 picture_memory_usage_ = | 189 picture_memory_usage_ = |
190 SkPictureUtils::ApproximateBytesUsed(picture_.get()); | 190 SkPictureUtils::ApproximateBytesUsed(picture_.get()); |
191 recorder_.reset(); | 191 recorder_.reset(); |
192 canvas_.clear(); | 192 canvas_.clear(); |
193 is_suitable_for_gpu_rasterization_ = | 193 is_suitable_for_gpu_rasterization_ = |
194 picture_->suitableForGpuRasterization(nullptr); | 194 picture_->suitableForGpuRasterization(nullptr); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 state->SetValue("layer_rect", MathUtil::AsValue(layer_rect_)); | 258 state->SetValue("layer_rect", MathUtil::AsValue(layer_rect_)); |
259 state->EndDictionary(); // "params". | 259 state->EndDictionary(); // "params". |
260 | 260 |
261 if (!layer_rect_.IsEmpty()) { | 261 if (!layer_rect_.IsEmpty()) { |
262 SkPictureRecorder recorder; | 262 SkPictureRecorder recorder; |
263 SkCanvas* canvas = | 263 SkCanvas* canvas = |
264 recorder.beginRecording(layer_rect_.width(), layer_rect_.height()); | 264 recorder.beginRecording(layer_rect_.width(), layer_rect_.height()); |
265 canvas->translate(-layer_rect_.x(), -layer_rect_.y()); | 265 canvas->translate(-layer_rect_.x(), -layer_rect_.y()); |
266 canvas->clipRect(gfx::RectToSkRect(layer_rect_)); | 266 canvas->clipRect(gfx::RectToSkRect(layer_rect_)); |
267 Raster(canvas, NULL, gfx::Rect(), 1.f); | 267 Raster(canvas, NULL, gfx::Rect(), 1.f); |
268 skia::RefPtr<SkPicture> picture = | 268 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
269 skia::AdoptRef(recorder.endRecordingAsPicture()); | |
270 | 269 |
271 std::string b64_picture; | 270 std::string b64_picture; |
272 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); | 271 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); |
273 state->SetString("skp64", b64_picture); | 272 state->SetString("skp64", b64_picture); |
274 } | 273 } |
275 | 274 |
276 return std::move(state); | 275 return std::move(state); |
277 } | 276 } |
278 | 277 |
279 void DisplayItemList::EmitTraceSnapshot() const { | 278 void DisplayItemList::EmitTraceSnapshot() const { |
(...skipping 27 matching lines...) Expand all Loading... |
307 float raster_scale, | 306 float raster_scale, |
308 std::vector<DrawImage>* images) { | 307 std::vector<DrawImage>* images) { |
309 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 308 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
310 } | 309 } |
311 | 310 |
312 bool DisplayItemList::MayHaveDiscardableImages() const { | 311 bool DisplayItemList::MayHaveDiscardableImages() const { |
313 return !image_map_.empty(); | 312 return !image_map_.empty(); |
314 } | 313 } |
315 | 314 |
316 } // namespace cc | 315 } // namespace cc |
OLD | NEW |