OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_rasterizer.h" | 5 #include "cc/resources/gpu_rasterizer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void GpuRasterizer::RasterizeTiles( | 59 void GpuRasterizer::RasterizeTiles( |
60 const TileVector& tiles, | 60 const TileVector& tiles, |
61 ResourcePool* resource_pool, | 61 ResourcePool* resource_pool, |
62 ResourceFormat resource_format, | 62 ResourceFormat resource_format, |
63 const UpdateTileDrawInfoCallback& update_tile_draw_info) { | 63 const UpdateTileDrawInfoCallback& update_tile_draw_info) { |
64 ScopedGpuRaster gpu_raster(context_provider_); | 64 ScopedGpuRaster gpu_raster(context_provider_); |
65 | 65 |
66 ScopedResourceWriteLocks locks; | 66 ScopedResourceWriteLocks locks; |
67 | 67 |
68 for (Tile* tile : tiles) { | 68 for (Tile* tile : tiles) { |
69 // TODO(hendrikw): Don't create resources for solid color tiles. | |
70 // See crbug.com/445919 | |
71 scoped_ptr<ScopedResource> resource = | |
72 resource_pool->AcquireResource(tile->desired_texture_size(), | |
73 resource_format); | |
74 const ScopedResource* const_resource = resource.get(); | |
75 | |
76 RasterSource::SolidColorAnalysis analysis; | 69 RasterSource::SolidColorAnalysis analysis; |
77 | 70 |
78 if (tile->use_picture_analysis()) | 71 if (tile->use_picture_analysis()) |
79 PerformSolidColorAnalysis(tile, &analysis); | 72 PerformSolidColorAnalysis(tile, &analysis); |
80 | 73 |
81 if (!analysis.is_solid_color) | 74 scoped_ptr<ScopedResource> resource; |
82 AddToMultiPictureDraw(tile, const_resource, &locks); | 75 if (!analysis.is_solid_color) { |
83 | 76 resource = resource_pool->AcquireResource(tile->desired_texture_size(), |
| 77 resource_format); |
| 78 AddToMultiPictureDraw(tile, resource.get(), &locks); |
| 79 } |
84 update_tile_draw_info.Run(tile, resource.Pass(), analysis); | 80 update_tile_draw_info.Run(tile, resource.Pass(), analysis); |
85 } | 81 } |
86 | 82 |
87 multi_picture_draw_.draw(); | 83 multi_picture_draw_.draw(); |
88 } | 84 } |
89 | 85 |
90 void GpuRasterizer::PerformSolidColorAnalysis( | 86 void GpuRasterizer::PerformSolidColorAnalysis( |
91 const Tile* tile, | 87 const Tile* tile, |
92 RasterSource::SolidColorAnalysis* analysis) { | 88 RasterSource::SolidColorAnalysis* analysis) { |
93 const void* tile_id = static_cast<const void*>(tile); | 89 const void* tile_id = static_cast<const void*>(tile); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 tile->raster_source()->PlaybackToCanvas(canvas.get(), tile->content_rect(), | 137 tile->raster_source()->PlaybackToCanvas(canvas.get(), tile->content_rect(), |
142 tile->contents_scale()); | 138 tile->contents_scale()); |
143 canvas->restore(); | 139 canvas->restore(); |
144 | 140 |
145 // Add the canvas and recorded picture to |multi_picture_draw_|. | 141 // Add the canvas and recorded picture to |multi_picture_draw_|. |
146 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 142 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
147 multi_picture_draw_.add(sk_surface->getCanvas(), picture.get()); | 143 multi_picture_draw_.add(sk_surface->getCanvas(), picture.get()); |
148 } | 144 } |
149 | 145 |
150 } // namespace cc | 146 } // namespace cc |
OLD | NEW |