| 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 "cc/layers/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
| 9 #include "cc/layers/picture_layer_impl.h" | 9 #include "cc/layers/picture_layer_impl.h" |
| 10 #include "cc/resources/display_list_recording_source.h" | 10 #include "cc/resources/display_list_recording_source.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 | 142 |
| 143 // UpdateAndExpandInvalidation will give us an invalidation that covers | 143 // UpdateAndExpandInvalidation will give us an invalidation that covers |
| 144 // anything not explicitly recorded in this frame. We give this region | 144 // anything not explicitly recorded in this frame. We give this region |
| 145 // to the impl side so that it drops tiles that may not have a recording | 145 // to the impl side so that it drops tiles that may not have a recording |
| 146 // for them. | 146 // for them. |
| 147 DCHECK(client_); | 147 DCHECK(client_); |
| 148 updated |= recording_source_->UpdateAndExpandInvalidation( | 148 updated |= recording_source_->UpdateAndExpandInvalidation( |
| 149 client_, &recording_invalidation_, can_use_lcd_text_for_update_, | 149 client_, &recording_invalidation_, can_use_lcd_text_for_update_, |
| 150 layer_size, visible_layer_rect, update_source_frame_number_, | 150 layer_size, visible_layer_rect, update_source_frame_number_, |
| 151 Picture::RECORD_NORMALLY); | 151 RecordingSource::RECORD_NORMALLY); |
| 152 last_updated_visible_content_rect_ = visible_content_rect(); | 152 last_updated_visible_content_rect_ = visible_content_rect(); |
| 153 | 153 |
| 154 if (updated) { | 154 if (updated) { |
| 155 SetNeedsPushProperties(); | 155 SetNeedsPushProperties(); |
| 156 } else { | 156 } else { |
| 157 // If this invalidation did not affect the recording source, then it can be | 157 // If this invalidation did not affect the recording source, then it can be |
| 158 // cleared as an optimization. | 158 // cleared as an optimization. |
| 159 recording_invalidation_.Clear(); | 159 recording_invalidation_.Clear(); |
| 160 } | 160 } |
| 161 | 161 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 185 // or paint a fresh one depending on what we intend to do with the | 185 // or paint a fresh one depending on what we intend to do with the |
| 186 // picture. For now we just paint a fresh one to get consistent results. | 186 // picture. For now we just paint a fresh one to get consistent results. |
| 187 if (!DrawsContent()) | 187 if (!DrawsContent()) |
| 188 return skia::RefPtr<SkPicture>(); | 188 return skia::RefPtr<SkPicture>(); |
| 189 | 189 |
| 190 int width = bounds().width(); | 190 int width = bounds().width(); |
| 191 int height = bounds().height(); | 191 int height = bounds().height(); |
| 192 | 192 |
| 193 SkPictureRecorder recorder; | 193 SkPictureRecorder recorder; |
| 194 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); | 194 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); |
| 195 client_->PaintContents(canvas, | 195 client_->PaintContents(canvas, gfx::Rect(width, height), |
| 196 gfx::Rect(width, height), | 196 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 197 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | |
| 198 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 197 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
| 199 return picture; | 198 return picture; |
| 200 } | 199 } |
| 201 | 200 |
| 202 bool PictureLayer::IsSuitableForGpuRasterization() const { | 201 bool PictureLayer::IsSuitableForGpuRasterization() const { |
| 203 return recording_source_->IsSuitableForGpuRasterization(); | 202 return recording_source_->IsSuitableForGpuRasterization(); |
| 204 } | 203 } |
| 205 | 204 |
| 206 void PictureLayer::ClearClient() { | 205 void PictureLayer::ClearClient() { |
| 207 client_ = nullptr; | 206 client_ = nullptr; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 218 | 217 |
| 219 bool PictureLayer::HasDrawableContent() const { | 218 bool PictureLayer::HasDrawableContent() const { |
| 220 return client_ && Layer::HasDrawableContent(); | 219 return client_ && Layer::HasDrawableContent(); |
| 221 } | 220 } |
| 222 | 221 |
| 223 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 222 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 224 benchmark->RunOnLayer(this); | 223 benchmark->RunOnLayer(this); |
| 225 } | 224 } |
| 226 | 225 |
| 227 } // namespace cc | 226 } // namespace cc |
| OLD | NEW |