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 12 matching lines...) Expand all Loading... |
23 #include "third_party/skia/include/core/SkPixelRef.h" | 23 #include "third_party/skia/include/core/SkPixelRef.h" |
24 #include "ui/gfx/rect_conversions.h" | 24 #include "ui/gfx/rect_conversions.h" |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Flag to indicate whether we should try and detect that | 29 // Flag to indicate whether we should try and detect that |
30 // a tile is of solid color. | 30 // a tile is of solid color. |
31 const bool kUseColorEstimator = true; | 31 const bool kUseColorEstimator = true; |
32 | 32 |
33 class DisableLCDTextFilter : public SkDrawFilter { | |
34 public: | |
35 // SkDrawFilter interface. | |
36 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { | |
37 if (type != SkDrawFilter::kText_Type) | |
38 return true; | |
39 | |
40 paint->setLCDRenderText(false); | |
41 return true; | |
42 } | |
43 }; | |
44 | |
45 class RasterTaskImpl : public RasterTask { | 33 class RasterTaskImpl : public RasterTask { |
46 public: | 34 public: |
47 RasterTaskImpl( | 35 RasterTaskImpl( |
48 const Resource* resource, | 36 const Resource* resource, |
49 PicturePileImpl* picture_pile, | 37 PicturePileImpl* picture_pile, |
50 const gfx::Rect& content_rect, | 38 const gfx::Rect& content_rect, |
51 float contents_scale, | 39 float contents_scale, |
52 RasterMode raster_mode, | 40 RasterMode raster_mode, |
53 TileResolution tile_resolution, | 41 TileResolution tile_resolution, |
54 int layer_id, | 42 int layer_id, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 layer_id_, | 127 layer_id_, |
140 raster_mode_); | 128 raster_mode_); |
141 devtools_instrumentation::ScopedLayerTask layer_task( | 129 devtools_instrumentation::ScopedLayerTask layer_task( |
142 devtools_instrumentation::kRasterTask, layer_id_); | 130 devtools_instrumentation::kRasterTask, layer_id_); |
143 | 131 |
144 skia::RefPtr<SkDrawFilter> draw_filter; | 132 skia::RefPtr<SkDrawFilter> draw_filter; |
145 switch (raster_mode_) { | 133 switch (raster_mode_) { |
146 case LOW_QUALITY_RASTER_MODE: | 134 case LOW_QUALITY_RASTER_MODE: |
147 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); | 135 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); |
148 break; | 136 break; |
149 case HIGH_QUALITY_NO_LCD_RASTER_MODE: | |
150 draw_filter = skia::AdoptRef(new DisableLCDTextFilter); | |
151 break; | |
152 case HIGH_QUALITY_RASTER_MODE: | 137 case HIGH_QUALITY_RASTER_MODE: |
153 break; | 138 break; |
154 case NUM_RASTER_MODES: | 139 case NUM_RASTER_MODES: |
155 default: | 140 default: |
156 NOTREACHED(); | 141 NOTREACHED(); |
157 } | 142 } |
158 canvas_->setDrawFilter(draw_filter.get()); | 143 canvas_->setDrawFilter(draw_filter.get()); |
159 | 144 |
160 base::TimeDelta prev_rasterize_time = | 145 base::TimeDelta prev_rasterize_time = |
161 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 146 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 947 |
963 void TileManager::FreeResourcesForTile(Tile* tile) { | 948 void TileManager::FreeResourcesForTile(Tile* tile) { |
964 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 949 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
965 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); | 950 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); |
966 } | 951 } |
967 } | 952 } |
968 | 953 |
969 void TileManager::FreeUnusedResourcesForTile(Tile* tile) { | 954 void TileManager::FreeUnusedResourcesForTile(Tile* tile) { |
970 DCHECK(tile->IsReadyToDraw()); | 955 DCHECK(tile->IsReadyToDraw()); |
971 ManagedTileState& mts = tile->managed_state(); | 956 ManagedTileState& mts = tile->managed_state(); |
972 RasterMode used_mode = HIGH_QUALITY_NO_LCD_RASTER_MODE; | 957 RasterMode used_mode = LOW_QUALITY_RASTER_MODE; |
973 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 958 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
974 if (mts.tile_versions[mode].IsReadyToDraw()) { | 959 if (mts.tile_versions[mode].IsReadyToDraw()) { |
975 used_mode = static_cast<RasterMode>(mode); | 960 used_mode = static_cast<RasterMode>(mode); |
976 break; | 961 break; |
977 } | 962 } |
978 } | 963 } |
979 | 964 |
980 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 965 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
981 if (mode != used_mode) | 966 if (mode != used_mode) |
982 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); | 967 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1610 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
1626 | 1611 |
1627 rasterizer_->CheckForCompletedTasks(); | 1612 rasterizer_->CheckForCompletedTasks(); |
1628 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1613 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
1629 | 1614 |
1630 if (IsReadyToActivate()) | 1615 if (IsReadyToActivate()) |
1631 client_->NotifyReadyToActivate(); | 1616 client_->NotifyReadyToActivate(); |
1632 } | 1617 } |
1633 | 1618 |
1634 } // namespace cc | 1619 } // namespace cc |
OLD | NEW |