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" |
11 #include "third_party/skia/include/core/SkData.h" | 11 #include "third_party/skia/include/core/SkData.h" |
12 #include "third_party/skia/include/core/SkTileGridPicture.h" | |
13 #include "third_party/skia/include/utils/SkPictureUtils.h" | 12 #include "third_party/skia/include/utils/SkPictureUtils.h" |
14 #include "ui/gfx/rect_conversions.h" | 13 #include "ui/gfx/rect_conversions.h" |
15 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
16 | 15 |
17 namespace { | 16 namespace { |
18 // URI label for a lazily decoded SkPixelRef. | 17 // URI label for a lazily decoded SkPixelRef. |
19 const char labelLazyDecoded[] = "lazy"; | 18 const char labelLazyDecoded[] = "lazy"; |
20 // Tile size in recording coordinates used by SkTileGridPicture | |
21 const int tileGridSize = 256; | |
22 } | 19 } |
23 | 20 |
24 namespace cc { | 21 namespace cc { |
25 | 22 |
26 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { | 23 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
27 return make_scoped_refptr(new Picture(layer_rect)); | 24 return make_scoped_refptr(new Picture(layer_rect)); |
28 } | 25 } |
29 | 26 |
30 Picture::Picture(gfx::Rect layer_rect) | 27 Picture::Picture(gfx::Rect layer_rect) |
31 : layer_rect_(layer_rect) { | 28 : layer_rect_(layer_rect) { |
(...skipping 12 matching lines...) Expand all Loading... |
44 | 41 |
45 scoped_refptr<Picture> Picture::Clone() const { | 42 scoped_refptr<Picture> Picture::Clone() const { |
46 // SkPicture is not thread-safe to rasterize with, so return a thread-safe | 43 // SkPicture is not thread-safe to rasterize with, so return a thread-safe |
47 // clone of it. | 44 // clone of it. |
48 DCHECK(picture_); | 45 DCHECK(picture_); |
49 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone()); | 46 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone()); |
50 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); | 47 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); |
51 } | 48 } |
52 | 49 |
53 void Picture::Record(ContentLayerClient* painter, | 50 void Picture::Record(ContentLayerClient* painter, |
54 RenderingStats* stats) { | 51 RenderingStats* stats, |
| 52 const SkTileGridPicture::TileGridInfo& tileGridInfo) { |
55 TRACE_EVENT2("cc", "Picture::Record", | 53 TRACE_EVENT2("cc", "Picture::Record", |
56 "width", layer_rect_.width(), "height", layer_rect_.height()); | 54 "width", layer_rect_.width(), "height", layer_rect_.height()); |
57 | 55 |
58 // Record() should only be called once. | 56 // Record() should only be called once. |
59 DCHECK(!picture_); | 57 DCHECK(!picture_); |
60 picture_ = skia::AdoptRef(new SkTileGridPicture( | 58 picture_ = skia::AdoptRef(new SkTileGridPicture( |
61 tileGridSize, tileGridSize, layer_rect_.width(), layer_rect_.height())); | 59 layer_rect_.width(), layer_rect_.height(), tileGridInfo)); |
62 | 60 |
63 SkCanvas* canvas = picture_->beginRecording( | 61 SkCanvas* canvas = picture_->beginRecording( |
64 layer_rect_.width(), | 62 layer_rect_.width(), |
65 layer_rect_.height(), | 63 layer_rect_.height(), |
66 SkPicture::kUsePathBoundsForClip_RecordingFlag | | 64 SkPicture::kUsePathBoundsForClip_RecordingFlag | |
67 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); | 65 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); |
68 | 66 |
69 canvas->save(); | 67 canvas->save(); |
70 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 68 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
71 SkFloatToScalar(-layer_rect_.y())); | 69 SkFloatToScalar(-layer_rect_.y())); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 if (*refs && (*refs)->getURI() && !strncmp( | 147 if (*refs && (*refs)->getURI() && !strncmp( |
150 (*refs)->getURI(), labelLazyDecoded, 4)) { | 148 (*refs)->getURI(), labelLazyDecoded, 4)) { |
151 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 149 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
152 } | 150 } |
153 refs++; | 151 refs++; |
154 } | 152 } |
155 pixel_refs->unref(); | 153 pixel_refs->unref(); |
156 } | 154 } |
157 | 155 |
158 } // namespace cc | 156 } // namespace cc |
OLD | NEW |