| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "cc/debug/debug_colors.h" | |
| 15 #include "cc/debug/devtools_instrumentation.h" | 14 #include "cc/debug/devtools_instrumentation.h" |
| 16 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
| 17 #include "cc/resources/raster_worker_pool.h" | 16 #include "cc/resources/raster_worker_pool.h" |
| 18 #include "cc/resources/resource_pool.h" | 17 #include "cc/resources/resource_pool.h" |
| 19 #include "cc/resources/tile.h" | 18 #include "cc/resources/tile.h" |
| 20 #include "third_party/skia/include/core/SkDevice.h" | 19 #include "third_party/skia/include/core/SkDevice.h" |
| 21 | 20 |
| 22 namespace cc { | 21 namespace cc { |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", | 847 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", |
| 849 analysis->is_solid_color); | 848 analysis->is_solid_color); |
| 850 stats_instrumentation->AddTileAnalysisResult(analysis->is_solid_color); | 849 stats_instrumentation->AddTileAnalysisResult(analysis->is_solid_color); |
| 851 | 850 |
| 852 // Clear the flag if we're not using the estimator. | 851 // Clear the flag if we're not using the estimator. |
| 853 analysis->is_solid_color &= use_color_estimator; | 852 analysis->is_solid_color &= use_color_estimator; |
| 854 | 853 |
| 855 if (metadata.prediction_benchmarking) { | 854 if (metadata.prediction_benchmarking) { |
| 856 SkDevice device(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 855 SkDevice device(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
| 857 SkCanvas canvas(&device); | 856 SkCanvas canvas(&device); |
| 858 picture_pile->Raster(&canvas, rect, contents_scale, NULL); | 857 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); |
| 859 | 858 |
| 860 const SkBitmap bitmap = device.accessBitmap(false); | 859 const SkBitmap bitmap = device.accessBitmap(false); |
| 861 DCHECK_EQ(bitmap.rowBytes(), | 860 DCHECK_EQ(bitmap.rowBytes(), |
| 862 static_cast<size_t>(bitmap.width() * bitmap.bytesPerPixel())); | 861 static_cast<size_t>(bitmap.width() * bitmap.bytesPerPixel())); |
| 863 | 862 |
| 864 RecordSolidColorPredictorResults( | 863 RecordSolidColorPredictorResults( |
| 865 reinterpret_cast<SkPMColor*>(bitmap.getPixels()), | 864 reinterpret_cast<SkPMColor*>(bitmap.getPixels()), |
| 866 bitmap.getSize() / bitmap.bytesPerPixel(), | 865 bitmap.getSize() / bitmap.bytesPerPixel(), |
| 867 analysis->is_solid_color, | 866 analysis->is_solid_color, |
| 868 SkPreMultiplyColor(analysis->solid_color)); | 867 SkPreMultiplyColor(analysis->solid_color)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 | 900 |
| 902 if (analysis->is_solid_color) | 901 if (analysis->is_solid_color) |
| 903 return; | 902 return; |
| 904 | 903 |
| 905 SkBitmap bitmap; | 904 SkBitmap bitmap; |
| 906 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 905 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
| 907 bitmap.setPixels(buffer); | 906 bitmap.setPixels(buffer); |
| 908 SkDevice device(bitmap); | 907 SkDevice device(bitmap); |
| 909 SkCanvas canvas(&device); | 908 SkCanvas canvas(&device); |
| 910 | 909 |
| 911 #ifndef NDEBUG | |
| 912 // Any non-painted areas will be left in this color. | |
| 913 canvas.clear(DebugColors::NonPaintedFillColor()); | |
| 914 #endif // NDEBUG | |
| 915 | |
| 916 if (stats_instrumentation->record_rendering_stats()) { | 910 if (stats_instrumentation->record_rendering_stats()) { |
| 917 PicturePileImpl::RasterStats raster_stats; | 911 PicturePileImpl::RasterStats raster_stats; |
| 918 picture_pile->Raster(&canvas, rect, contents_scale, &raster_stats); | 912 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, &raster_stats); |
| 919 stats_instrumentation->AddRaster( | 913 stats_instrumentation->AddRaster( |
| 920 raster_stats.total_rasterize_time, | 914 raster_stats.total_rasterize_time, |
| 921 raster_stats.best_rasterize_time, | 915 raster_stats.best_rasterize_time, |
| 922 raster_stats.total_pixels_rasterized, | 916 raster_stats.total_pixels_rasterized, |
| 923 metadata.is_tile_in_pending_tree_now_bin); | 917 metadata.is_tile_in_pending_tree_now_bin); |
| 924 | 918 |
| 925 HISTOGRAM_CUSTOM_COUNTS( | 919 HISTOGRAM_CUSTOM_COUNTS( |
| 926 "Renderer4.PictureRasterTimeUS", | 920 "Renderer4.PictureRasterTimeUS", |
| 927 raster_stats.total_rasterize_time.InMicroseconds(), | 921 raster_stats.total_rasterize_time.InMicroseconds(), |
| 928 0, | 922 0, |
| 929 100000, | 923 100000, |
| 930 100); | 924 100); |
| 931 } else { | 925 } else { |
| 932 picture_pile->Raster(&canvas, rect, contents_scale, NULL); | 926 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); |
| 933 } | 927 } |
| 934 } | 928 } |
| 935 | 929 |
| 936 // static | 930 // static |
| 937 void TileManager::RunImageDecodeTask( | 931 void TileManager::RunImageDecodeTask( |
| 938 skia::LazyPixelRef* pixel_ref, | 932 skia::LazyPixelRef* pixel_ref, |
| 939 RenderingStatsInstrumentation* stats_instrumentation) { | 933 RenderingStatsInstrumentation* stats_instrumentation) { |
| 940 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); | 934 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); |
| 941 base::TimeTicks start_time = stats_instrumentation->StartRecording(); | 935 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
| 942 pixel_ref->Decode(); | 936 pixel_ref->Decode(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 972 is_predicted_solid && predicted_color != actual_color); | 966 is_predicted_solid && predicted_color != actual_color); |
| 973 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", | 967 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", |
| 974 is_predicted_solid == is_actually_solid && | 968 is_predicted_solid == is_actually_solid && |
| 975 (!is_predicted_solid || predicted_color == actual_color)); | 969 (!is_predicted_solid || predicted_color == actual_color)); |
| 976 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid", | 970 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid", |
| 977 is_predicted_solid == is_actually_solid && | 971 is_predicted_solid == is_actually_solid && |
| 978 (is_predicted_solid && predicted_color == actual_color)); | 972 (is_predicted_solid && predicted_color == actual_color)); |
| 979 } | 973 } |
| 980 | 974 |
| 981 } // namespace cc | 975 } // namespace cc |
| OLD | NEW |