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