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" | |
11 #include "third_party/skia/include/utils/SkPictureUtils.h" | |
10 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
11 | 13 |
14 namespace { | |
15 // URI label for a lazily decoded SkPixelRef. | |
16 const char labelLazyDecoded[] = "lazy"; | |
17 } | |
18 | |
12 namespace cc { | 19 namespace cc { |
13 | 20 |
14 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { | 21 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
15 return make_scoped_refptr(new Picture(layer_rect)); | 22 return make_scoped_refptr(new Picture(layer_rect)); |
16 } | 23 } |
17 | 24 |
18 Picture::Picture(gfx::Rect layer_rect) | 25 Picture::Picture(gfx::Rect layer_rect) |
19 : layer_rect_(layer_rect) { | 26 : layer_rect_(layer_rect) { |
20 } | 27 } |
21 | 28 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 88 |
82 void Picture::Raster(SkCanvas* canvas) { | 89 void Picture::Raster(SkCanvas* canvas) { |
83 TRACE_EVENT0("cc", "Picture::Raster"); | 90 TRACE_EVENT0("cc", "Picture::Raster"); |
84 DCHECK(picture_); | 91 DCHECK(picture_); |
85 canvas->save(); | 92 canvas->save(); |
86 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 93 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
87 canvas->drawPicture(*picture_); | 94 canvas->drawPicture(*picture_); |
88 canvas->restore(); | 95 canvas->restore(); |
89 } | 96 } |
90 | 97 |
98 void Picture::GatherPixelRefs(const gfx::Rect& rect, | |
99 std::vector<SkPixelRef*>& result) { | |
100 DCHECK(picture_); | |
101 SkAutoDataUnref pixel_refs(SkPictureUtils::GatherPixelRefs( | |
102 picture_.get(), SkRect::MakeXYWH(rect.x(), | |
103 rect.y(), | |
104 rect.width(), | |
105 rect.height()))); | |
106 void* data = const_cast<void*>(pixel_refs->data()); | |
107 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); | |
108 for (int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { | |
109 if (memcmp((*refs)->getURI(), labelLazyDecoded, | |
reveman
2012/12/07 21:14:54
should this be strcmp? memcmp is allowed to read p
qinmin
2012/12/07 23:41:55
ok, using strncmp instead
On 2012/12/07 21:14:54,
| |
110 sizeof(labelLazyDecoded))) { | |
111 result.push_back(*refs); | |
112 } | |
113 refs++; | |
114 } | |
115 } | |
116 | |
91 } // namespace cc | 117 } // namespace cc |
OLD | NEW |