Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: cc/resources/gpu_raster_worker_pool.cc

Issue 648293006: cc: turn on distance field text on animated layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 bool use_distance_field_text =
40 picture_pile->will_be_used_for_transform_animation();
41 SkSurface* sk_surface = lock_.GetSkSurface(use_distance_field_text);
42 if (!sk_surface)
40 return; 43 return;
41 44
42 SkPictureRecorder recorder; 45 SkPictureRecorder recorder;
43 gfx::Size size = resource_->size(); 46 gfx::Size size = resource_->size();
44 skia::RefPtr<SkCanvas> canvas = 47 skia::RefPtr<SkCanvas> canvas =
45 skia::SharePtr(recorder.beginRecording(size.width(), size.height())); 48 skia::SharePtr(recorder.beginRecording(size.width(), size.height()));
46 49
47 canvas->save(); 50 canvas->save();
48 picture_pile->RasterToBitmap(canvas.get(), rect, scale, stats); 51 picture_pile->RasterToBitmap(canvas.get(), rect, scale, stats);
49 canvas->restore(); 52 canvas->restore();
50 53
51 // Add the canvas and recorded picture to |multi_picture_draw_|. 54 // Add the canvas and recorded picture to |multi_picture_draw_|.
52 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 55 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
53 multi_picture_draw_->add(lock_.sk_surface()->getCanvas(), picture.get()); 56 multi_picture_draw_->add(sk_surface->getCanvas(), picture.get());
54 } 57 }
55 58
56 private: 59 private:
57 ResourceProvider::ScopedWriteLockGr lock_; 60 ResourceProvider::ScopedWriteLockGr lock_;
58 const Resource* resource_; 61 const Resource* resource_;
59 SkMultiPictureDraw* multi_picture_draw_; 62 SkMultiPictureDraw* multi_picture_draw_;
60 63
61 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); 64 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
62 }; 65 };
63 66
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 229
227 ScopedGpuRaster gpu_raster(context_provider_); 230 ScopedGpuRaster gpu_raster(context_provider_);
228 task_graph_runner_->RunUntilIdle(); 231 task_graph_runner_->RunUntilIdle();
229 232
230 // Draw each all of the pictures that were collected. This will also clear 233 // Draw each all of the pictures that were collected. This will also clear
231 // the pictures and canvases added to |multi_picture_draw_| 234 // the pictures and canvases added to |multi_picture_draw_|
232 multi_picture_draw_.draw(); 235 multi_picture_draw_.draw();
233 } 236 }
234 237
235 } // namespace cc 238 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698