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/utils/SkPictureUtils.h" | 11 #include "third_party/skia/include/utils/SkPictureUtils.h" |
12 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
| 13 #include "ui/gfx/skia_util.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 // URI label for a lazily decoded SkPixelRef. | 16 // URI label for a lazily decoded SkPixelRef. |
16 const char labelLazyDecoded[] = "lazy"; | 17 const char labelLazyDecoded[] = "lazy"; |
17 } | 18 } |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
21 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { | 22 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
22 return make_scoped_refptr(new Picture(layer_rect)); | 23 return make_scoped_refptr(new Picture(layer_rect)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 stats.totalPaintTimeInSeconds += delta; | 82 stats.totalPaintTimeInSeconds += delta; |
82 stats.totalPixelsPainted += layer_rect_.width() * | 83 stats.totalPixelsPainted += layer_rect_.width() * |
83 layer_rect_.height(); | 84 layer_rect_.height(); |
84 | 85 |
85 canvas->restore(); | 86 canvas->restore(); |
86 picture_->endRecording(); | 87 picture_->endRecording(); |
87 | 88 |
88 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 89 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
89 } | 90 } |
90 | 91 |
91 void Picture::Raster(SkCanvas* canvas) { | 92 void Picture::Raster( |
| 93 SkCanvas* canvas, |
| 94 gfx::Rect content_rect, |
| 95 float contents_scale) { |
92 TRACE_EVENT0("cc", "Picture::Raster"); | 96 TRACE_EVENT0("cc", "Picture::Raster"); |
93 DCHECK(picture_); | 97 DCHECK(picture_); |
| 98 |
94 canvas->save(); | 99 canvas->save(); |
| 100 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
| 101 canvas->scale(contents_scale, contents_scale); |
95 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 102 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
96 canvas->drawPicture(*picture_); | 103 canvas->drawPicture(*picture_); |
97 canvas->restore(); | 104 canvas->restore(); |
98 } | 105 } |
99 | 106 |
100 void Picture::GatherPixelRefs(const gfx::Rect& rect, | 107 void Picture::GatherPixelRefs(const gfx::Rect& rect, |
101 std::list<skia::LazyPixelRef*>& result) { | 108 std::list<skia::LazyPixelRef*>& result) { |
102 DCHECK(picture_); | 109 DCHECK(picture_); |
103 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( | 110 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
104 picture_.get(), SkRect::MakeXYWH(rect.x(), | 111 picture_.get(), SkRect::MakeXYWH(rect.x(), |
(...skipping 14 matching lines...) Expand all Loading... |
119 if (*refs && (*refs)->getURI() && !strncmp( | 126 if (*refs && (*refs)->getURI() && !strncmp( |
120 (*refs)->getURI(), labelLazyDecoded, 4)) { | 127 (*refs)->getURI(), labelLazyDecoded, 4)) { |
121 result.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 128 result.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
122 } | 129 } |
123 refs++; | 130 refs++; |
124 } | 131 } |
125 pixel_refs->unref(); | 132 pixel_refs->unref(); |
126 } | 133 } |
127 | 134 |
128 } // namespace cc | 135 } // namespace cc |
OLD | NEW |