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/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "third_party/skia/include/core/SkPixelRef.h" | 25 #include "third_party/skia/include/core/SkPixelRef.h" |
26 #include "ui/gfx/rect_conversions.h" | 26 #include "ui/gfx/rect_conversions.h" |
27 | 27 |
28 namespace cc { | 28 namespace cc { |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Flag to indicate whether we should try and detect that | 31 // Flag to indicate whether we should try and detect that |
32 // a tile is of solid color. | 32 // a tile is of solid color. |
33 const bool kUseColorEstimator = true; | 33 const bool kUseColorEstimator = true; |
34 | 34 |
| 35 // Minimum width/height of a pile that would require analysis for tiles. |
| 36 const int kMinDimensionsForAnalysis = 256; |
| 37 |
35 class DisableLCDTextFilter : public SkDrawFilter { | 38 class DisableLCDTextFilter : public SkDrawFilter { |
36 public: | 39 public: |
37 // SkDrawFilter interface. | 40 // SkDrawFilter interface. |
38 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { | 41 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { |
39 if (type != SkDrawFilter::kText_Type) | 42 if (type != SkDrawFilter::kText_Type) |
40 return true; | 43 return true; |
41 | 44 |
42 paint->setLCDRenderText(false); | 45 paint->setLCDRenderText(false); |
43 return true; | 46 return true; |
44 } | 47 } |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 CreateImageDecodeTask(tile, pixel_ref); | 1159 CreateImageDecodeTask(tile, pixel_ref); |
1157 decode_tasks.push_back(decode_task); | 1160 decode_tasks.push_back(decode_task); |
1158 existing_pixel_refs[id] = decode_task; | 1161 existing_pixel_refs[id] = decode_task; |
1159 } | 1162 } |
1160 | 1163 |
1161 // We analyze picture before rasterization to detect solid-color tiles. | 1164 // We analyze picture before rasterization to detect solid-color tiles. |
1162 // If the tile is detected as such there is no need to raster or upload. | 1165 // If the tile is detected as such there is no need to raster or upload. |
1163 // It is drawn directly as a solid-color quad saving raster and upload cost. | 1166 // It is drawn directly as a solid-color quad saving raster and upload cost. |
1164 // The analysis step is however expensive and is not justified when doing | 1167 // The analysis step is however expensive and is not justified when doing |
1165 // gpu rasterization where there is no upload. | 1168 // gpu rasterization where there is no upload. |
1166 bool analyze_picture = !tile->use_gpu_rasterization(); | 1169 // |
| 1170 // Additionally, we do not want to do the analysis if the layer that produced |
| 1171 // this tile is narrow, since more likely than not the tile would not be |
| 1172 // solid. We use the picture pile size as a proxy for layer size, since it |
| 1173 // represents the recorded (and thus rasterizable) content. |
| 1174 // Note that this last optimization is a heuristic that ensures that we don't |
| 1175 // spend too much time analyzing tiles on a multitude of small layers, as it |
| 1176 // is likely that these layers have some non-solid content. |
| 1177 gfx::Size pile_size = tile->picture_pile()->size(); |
| 1178 bool analyze_picture = !tile->use_gpu_rasterization() && |
| 1179 std::min(pile_size.width(), pile_size.height()) >= |
| 1180 kMinDimensionsForAnalysis; |
1167 | 1181 |
1168 return make_scoped_refptr(new RasterWorkerPoolTaskImpl( | 1182 return make_scoped_refptr(new RasterWorkerPoolTaskImpl( |
1169 const_resource, | 1183 const_resource, |
1170 tile->picture_pile(), | 1184 tile->picture_pile(), |
1171 tile->content_rect(), | 1185 tile->content_rect(), |
1172 tile->contents_scale(), | 1186 tile->contents_scale(), |
1173 mts.raster_mode, | 1187 mts.raster_mode, |
1174 mts.resolution, | 1188 mts.resolution, |
1175 tile->layer_id(), | 1189 tile->layer_id(), |
1176 static_cast<const void*>(tile), | 1190 static_cast<const void*>(tile), |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 b_tile->priority(b_pair.second), | 1540 b_tile->priority(b_pair.second), |
1527 false /* prioritize low res */); | 1541 false /* prioritize low res */); |
1528 } | 1542 } |
1529 | 1543 |
1530 NOTREACHED(); | 1544 NOTREACHED(); |
1531 // Keep the compiler happy. | 1545 // Keep the compiler happy. |
1532 return false; | 1546 return false; |
1533 } | 1547 } |
1534 | 1548 |
1535 } // namespace cc | 1549 } // namespace cc |
OLD | NEW |