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 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
22 | 21 |
23 namespace cc { | 22 namespace cc { |
24 | 23 |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // Clear the flag if we're not using the estimator. | 852 // Clear the flag if we're not using the estimator. |
854 analysis->is_solid_color &= use_color_estimator; | 853 analysis->is_solid_color &= use_color_estimator; |
855 | 854 |
856 if (metadata.prediction_benchmarking) { | 855 if (metadata.prediction_benchmarking) { |
857 gfx::Rect layer_rect = gfx::ToEnclosingRect( | 856 gfx::Rect layer_rect = gfx::ToEnclosingRect( |
858 gfx::ScaleRect(rect, 1.0f / contents_scale)); | 857 gfx::ScaleRect(rect, 1.0f / contents_scale)); |
859 | 858 |
860 SkDevice device( | 859 SkDevice device( |
861 SkBitmap::kARGB_8888_Config, layer_rect.width(), layer_rect.height()); | 860 SkBitmap::kARGB_8888_Config, layer_rect.width(), layer_rect.height()); |
862 SkCanvas canvas(&device); | 861 SkCanvas canvas(&device); |
863 picture_pile->Raster(&canvas, layer_rect, 1.0f, NULL); | 862 picture_pile->RasterToBitmap(&canvas, layer_rect, 1.0f, NULL); |
864 | 863 |
865 const SkBitmap bitmap = device.accessBitmap(false); | 864 const SkBitmap bitmap = device.accessBitmap(false); |
866 DCHECK_EQ(bitmap.rowBytes(), | 865 DCHECK_EQ(bitmap.rowBytes(), |
867 static_cast<size_t>(bitmap.width() * bitmap.bytesPerPixel())); | 866 static_cast<size_t>(bitmap.width() * bitmap.bytesPerPixel())); |
868 | 867 |
869 RecordSolidColorPredictorResults( | 868 RecordSolidColorPredictorResults( |
870 reinterpret_cast<SkPMColor*>(bitmap.getPixels()), | 869 reinterpret_cast<SkPMColor*>(bitmap.getPixels()), |
871 bitmap.getSize() / bitmap.bytesPerPixel(), | 870 bitmap.getSize() / bitmap.bytesPerPixel(), |
872 analysis->is_solid_color, | 871 analysis->is_solid_color, |
873 SkPreMultiplyColor(analysis->solid_color)); | 872 SkPreMultiplyColor(analysis->solid_color)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 | 905 |
907 if (analysis->is_solid_color) | 906 if (analysis->is_solid_color) |
908 return; | 907 return; |
909 | 908 |
910 SkBitmap bitmap; | 909 SkBitmap bitmap; |
911 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 910 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
912 bitmap.setPixels(buffer); | 911 bitmap.setPixels(buffer); |
913 SkDevice device(bitmap); | 912 SkDevice device(bitmap); |
914 SkCanvas canvas(&device); | 913 SkCanvas canvas(&device); |
915 | 914 |
916 #ifndef NDEBUG | |
917 // Any non-painted areas will be left in this color. | |
918 canvas.clear(DebugColors::NonPaintedFillColor()); | |
919 #endif // NDEBUG | |
920 | |
921 if (stats_instrumentation->record_rendering_stats()) { | 915 if (stats_instrumentation->record_rendering_stats()) { |
922 PicturePileImpl::RasterStats raster_stats; | 916 PicturePileImpl::RasterStats raster_stats; |
923 picture_pile->Raster(&canvas, rect, contents_scale, &raster_stats); | 917 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, &raster_stats); |
924 stats_instrumentation->AddRaster( | 918 stats_instrumentation->AddRaster( |
925 raster_stats.total_rasterize_time, | 919 raster_stats.total_rasterize_time, |
926 raster_stats.best_rasterize_time, | 920 raster_stats.best_rasterize_time, |
927 raster_stats.total_pixels_rasterized, | 921 raster_stats.total_pixels_rasterized, |
928 metadata.is_tile_in_pending_tree_now_bin); | 922 metadata.is_tile_in_pending_tree_now_bin); |
929 | 923 |
930 HISTOGRAM_CUSTOM_COUNTS( | 924 HISTOGRAM_CUSTOM_COUNTS( |
931 "Renderer4.PictureRasterTimeUS", | 925 "Renderer4.PictureRasterTimeUS", |
932 raster_stats.total_rasterize_time.InMicroseconds(), | 926 raster_stats.total_rasterize_time.InMicroseconds(), |
933 0, | 927 0, |
934 100000, | 928 100000, |
935 100); | 929 100); |
936 } else { | 930 } else { |
937 picture_pile->Raster(&canvas, rect, contents_scale, NULL); | 931 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); |
938 } | 932 } |
939 } | 933 } |
940 | 934 |
941 // static | 935 // static |
942 void TileManager::RunImageDecodeTask( | 936 void TileManager::RunImageDecodeTask( |
943 skia::LazyPixelRef* pixel_ref, | 937 skia::LazyPixelRef* pixel_ref, |
944 RenderingStatsInstrumentation* stats_instrumentation) { | 938 RenderingStatsInstrumentation* stats_instrumentation) { |
945 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); | 939 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); |
946 base::TimeTicks start_time = stats_instrumentation->StartRecording(); | 940 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
947 pixel_ref->Decode(); | 941 pixel_ref->Decode(); |
(...skipping 29 matching lines...) Expand all Loading... |
977 is_predicted_solid && predicted_color != actual_color); | 971 is_predicted_solid && predicted_color != actual_color); |
978 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", | 972 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", |
979 is_predicted_solid == is_actually_solid && | 973 is_predicted_solid == is_actually_solid && |
980 (!is_predicted_solid || predicted_color == actual_color)); | 974 (!is_predicted_solid || predicted_color == actual_color)); |
981 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid", | 975 HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid", |
982 is_predicted_solid == is_actually_solid && | 976 is_predicted_solid == is_actually_solid && |
983 (is_predicted_solid && predicted_color == actual_color)); | 977 (is_predicted_solid && predicted_color == actual_color)); |
984 } | 978 } |
985 | 979 |
986 } // namespace cc | 980 } // namespace cc |
OLD | NEW |