| 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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 | 969 |
| 985 void TileManager::FreeResourcesForTile(Tile* tile) { | 970 void TileManager::FreeResourcesForTile(Tile* tile) { |
| 986 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 971 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
| 987 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); | 972 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); |
| 988 } | 973 } |
| 989 } | 974 } |
| 990 | 975 |
| 991 void TileManager::FreeUnusedResourcesForTile(Tile* tile) { | 976 void TileManager::FreeUnusedResourcesForTile(Tile* tile) { |
| 992 DCHECK(tile->IsReadyToDraw()); | 977 DCHECK(tile->IsReadyToDraw()); |
| 993 ManagedTileState& mts = tile->managed_state(); | 978 ManagedTileState& mts = tile->managed_state(); |
| 994 RasterMode used_mode = HIGH_QUALITY_NO_LCD_RASTER_MODE; | 979 RasterMode used_mode = LOW_QUALITY_RASTER_MODE; |
| 995 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 980 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
| 996 if (mts.tile_versions[mode].IsReadyToDraw()) { | 981 if (mts.tile_versions[mode].IsReadyToDraw()) { |
| 997 used_mode = static_cast<RasterMode>(mode); | 982 used_mode = static_cast<RasterMode>(mode); |
| 998 break; | 983 break; |
| 999 } | 984 } |
| 1000 } | 985 } |
| 1001 | 986 |
| 1002 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 987 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
| 1003 if (mode != used_mode) | 988 if (mode != used_mode) |
| 1004 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); | 989 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1638 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 1654 | 1639 |
| 1655 rasterizer_->CheckForCompletedTasks(); | 1640 rasterizer_->CheckForCompletedTasks(); |
| 1656 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1641 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1657 | 1642 |
| 1658 if (IsReadyToActivate()) | 1643 if (IsReadyToActivate()) |
| 1659 client_->NotifyReadyToActivate(); | 1644 client_->NotifyReadyToActivate(); |
| 1660 } | 1645 } |
| 1661 | 1646 |
| 1662 } // namespace cc | 1647 } // namespace cc |
| OLD | NEW |