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" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 DCHECK(picture_); | 107 DCHECK(picture_); |
108 | 108 |
109 canvas->save(); | 109 canvas->save(); |
110 canvas->clipRect(gfx::RectToSkRect(content_rect)); | 110 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
111 canvas->scale(contents_scale, contents_scale); | 111 canvas->scale(contents_scale, contents_scale); |
112 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 112 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
113 canvas->drawPicture(*picture_); | 113 canvas->drawPicture(*picture_); |
114 canvas->restore(); | 114 canvas->restore(); |
115 } | 115 } |
116 | 116 |
117 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) const { | 117 void Picture::AnalyzeInRect(skia::AnalysisCanvas* canvas, |
118 TRACE_EVENT0("cc", "Picture::IsCheapInRect"); | 118 const gfx::Rect& content_rect, |
| 119 float contents_scale, |
| 120 bool* is_solid, |
| 121 SkColor* solid_color, |
| 122 bool* is_transparent, |
| 123 bool* is_cheap) { |
| 124 // Verify outputs are valid. |
| 125 DCHECK(is_solid && solid_color && is_transparent && is_cheap); |
119 | 126 |
120 SkBitmap emptyBitmap; | 127 canvas->save(); |
121 emptyBitmap.setConfig(SkBitmap::kNo_Config, layer_rect.width(), | 128 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
122 layer_rect.height()); | 129 canvas->scale(contents_scale, contents_scale); |
123 skia::AnalysisDevice device(emptyBitmap); | 130 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
124 skia::AnalysisCanvas canvas(&device); | 131 canvas->drawPicture(*picture_); |
| 132 canvas->restore(); |
125 | 133 |
126 canvas.drawPicture(*picture_); | 134 *is_solid = canvas->getColorIfSolid(solid_color); |
127 return canvas.isCheap(); | 135 *is_transparent = canvas->isTransparent(); |
| 136 *is_cheap = canvas->isCheap(); |
128 } | 137 } |
129 | 138 |
130 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, | 139 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, |
131 std::list<skia::LazyPixelRef*>& pixel_ref_list) { | 140 std::list<skia::LazyPixelRef*>& pixel_ref_list) { |
132 DCHECK(picture_); | 141 DCHECK(picture_); |
133 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( | 142 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
134 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), | 143 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), |
135 layer_rect.y(), | 144 layer_rect.y(), |
136 layer_rect.width(), | 145 layer_rect.width(), |
137 layer_rect.height())); | 146 layer_rect.height())); |
(...skipping 11 matching lines...) Expand all Loading... |
149 if (*refs && (*refs)->getURI() && !strncmp( | 158 if (*refs && (*refs)->getURI() && !strncmp( |
150 (*refs)->getURI(), labelLazyDecoded, 4)) { | 159 (*refs)->getURI(), labelLazyDecoded, 4)) { |
151 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 160 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
152 } | 161 } |
153 refs++; | 162 refs++; |
154 } | 163 } |
155 pixel_refs->unref(); | 164 pixel_refs->unref(); |
156 } | 165 } |
157 | 166 |
158 } // namespace cc | 167 } // namespace cc |
OLD | NEW |