OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/resources/gpu_raster_worker_pool.h" | 5 #include "cc/resources/gpu_raster_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 SkMultiPictureDraw* multi_picture_draw) | 29 SkMultiPictureDraw* multi_picture_draw) |
30 : lock_(resource_provider, resource->id()), | 30 : lock_(resource_provider, resource->id()), |
31 resource_(resource), | 31 resource_(resource), |
32 multi_picture_draw_(multi_picture_draw) {} | 32 multi_picture_draw_(multi_picture_draw) {} |
33 | 33 |
34 // Overridden from RasterBuffer: | 34 // Overridden from RasterBuffer: |
35 virtual void Playback(const PicturePileImpl* picture_pile, | 35 virtual void Playback(const PicturePileImpl* picture_pile, |
36 const gfx::Rect& rect, | 36 const gfx::Rect& rect, |
37 float scale, | 37 float scale, |
38 RenderingStatsInstrumentation* stats) override { | 38 RenderingStatsInstrumentation* stats) override { |
39 if (!lock_.sk_surface()) | 39 // Turn on distance fields for layers that have ever animated. |
40 bool use_distance_field_text = | |
41 picture_pile->will_be_used_for_transform_animation(); | |
reveman
2014/10/20 18:38:29
This line should also take LayerTreeSettings::use_
| |
42 SkSurface* sk_surface = lock_.GetSkSurface(use_distance_field_text); | |
43 | |
44 if (!sk_surface) | |
40 return; | 45 return; |
41 | 46 |
42 SkPictureRecorder recorder; | 47 SkPictureRecorder recorder; |
43 gfx::Size size = resource_->size(); | 48 gfx::Size size = resource_->size(); |
44 skia::RefPtr<SkCanvas> canvas = | 49 skia::RefPtr<SkCanvas> canvas = |
45 skia::SharePtr(recorder.beginRecording(size.width(), size.height())); | 50 skia::SharePtr(recorder.beginRecording(size.width(), size.height())); |
46 | 51 |
47 canvas->save(); | 52 canvas->save(); |
48 picture_pile->RasterToBitmap(canvas.get(), rect, scale, stats); | 53 picture_pile->RasterToBitmap(canvas.get(), rect, scale, stats); |
49 canvas->restore(); | 54 canvas->restore(); |
50 | 55 |
51 // Add the canvas and recorded picture to |multi_picture_draw_|. | 56 // Add the canvas and recorded picture to |multi_picture_draw_|. |
52 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 57 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
53 multi_picture_draw_->add(lock_.sk_surface()->getCanvas(), picture.get()); | 58 multi_picture_draw_->add(sk_surface->getCanvas(), picture.get()); |
54 } | 59 } |
55 | 60 |
56 private: | 61 private: |
57 ResourceProvider::ScopedWriteLockGr lock_; | 62 ResourceProvider::ScopedWriteLockGr lock_; |
58 const Resource* resource_; | 63 const Resource* resource_; |
59 SkMultiPictureDraw* multi_picture_draw_; | 64 SkMultiPictureDraw* multi_picture_draw_; |
60 | 65 |
61 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | 66 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); |
62 }; | 67 }; |
63 | 68 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 | 231 |
227 ScopedGpuRaster gpu_raster(context_provider_); | 232 ScopedGpuRaster gpu_raster(context_provider_); |
228 task_graph_runner_->RunUntilIdle(); | 233 task_graph_runner_->RunUntilIdle(); |
229 | 234 |
230 // Draw each all of the pictures that were collected. This will also clear | 235 // Draw each all of the pictures that were collected. This will also clear |
231 // the pictures and canvases added to |multi_picture_draw_| | 236 // the pictures and canvases added to |multi_picture_draw_| |
232 multi_picture_draw_.draw(); | 237 multi_picture_draw_.draw(); |
233 } | 238 } |
234 | 239 |
235 } // namespace cc | 240 } // namespace cc |
OLD | NEW |