Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2009)

Unified Diff: cc/tile_manager.cc

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bugfix Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/tile_manager.cc
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index 580759f7b10521a578edd93fa7cc495a42da1f60..8e51ce542007f7283970c1ccb39dbc2f99edaf55 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -17,6 +17,7 @@
#include "cc/resource_pool.h"
#include "cc/tile.h"
#include "third_party/skia/include/core/SkDevice.h"
+#include "ui/gfx/rect_conversions.h"
namespace cc {
@@ -176,7 +177,8 @@ TileManager::TileManager(
TileManagerClient* client,
ResourceProvider* resource_provider,
size_t num_raster_threads,
- bool use_cheapness_estimator)
+ bool use_cheapness_estimator,
+ bool solid_color_benchmarking)
: client_(client),
resource_pool_(ResourcePool::Create(resource_provider)),
raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)),
@@ -188,7 +190,8 @@ TileManager::TileManager(
record_rendering_stats_(false),
use_cheapness_estimator_(use_cheapness_estimator),
allow_cheap_tasks_(true),
- did_schedule_cheap_tasks_(false) {
+ did_schedule_cheap_tasks_(false),
+ solid_color_benchmarking_(solid_color_benchmarking) {
for (int i = 0; i < NUM_STATES; ++i) {
for (int j = 0; j < NUM_TREES; ++j) {
for (int k = 0; k < NUM_BINS; ++k)
@@ -817,6 +820,7 @@ TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata(
RasterTaskMetadata metadata;
const ManagedTileState& mts = tile.managed_state();
metadata.use_cheapness_estimator = use_cheapness_estimator_;
+ metadata.solid_color_benchmarking = solid_color_benchmarking_;
metadata.is_tile_in_pending_tree_now_bin =
mts.tree_bin[PENDING_TREE] == NOW_BIN;
metadata.tile_resolution = mts.resolution;
@@ -939,7 +943,6 @@ void TileManager::RunRasterTask(uint8* buffer,
int64 total_pixels_rasterized = 0;
picture_pile->Raster(&canvas, rect, contents_scale,
&total_pixels_rasterized);
-
if (stats) {
stats->totalPixelsRasterized += total_pixels_rasterized;
@@ -957,11 +960,25 @@ void TileManager::RunRasterTask(uint8* buffer,
if (metadata.use_cheapness_estimator) {
bool is_predicted_cheap =
- picture_pile->IsCheapInRect(rect, contents_scale);
+ picture_pile->IsCheapInRect(rect, contents_scale);
bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f;
RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap);
}
}
+
+ if (metadata.solid_color_benchmarking) {
+ SkColor solid_color;
+ bool is_predicted_solid =
+ picture_pile->GetColorIfSolidInRect(rect, contents_scale, &solid_color);
+ bool is_predicted_transparent =
+ picture_pile->IsTransparentInRect(rect, contents_scale);
+
+ RecordSolidColorPredictorResults(buffer,
+ rect.width() * rect.height(),
+ is_predicted_solid,
+ solid_color,
+ is_predicted_transparent);
+ }
}
// static
@@ -976,6 +993,56 @@ void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap,
is_predicted_cheap == is_actually_cheap);
}
+//static
+void TileManager::RecordSolidColorPredictorResults(const uint8* actual_bytes,
+ size_t pixel_count,
+ bool is_predicted_solid,
+ SkColor predicted_color,
+ bool is_predicted_transparent) {
+ CHECK(pixel_count > 0);
+
+ bool is_actually_solid = true;
+ bool is_transparent = true;
+ SkColor actual_color = SkColorSetARGB(actual_bytes[3],
+ actual_bytes[2],
+ actual_bytes[1],
+ actual_bytes[0]);
+ for (int i = (pixel_count-1)*4; i >= 0; i -= 4) {
+ SkColor current_color = SkColorSetARGB(actual_bytes[i+3],
+ actual_bytes[i+2],
+ actual_bytes[i+1],
+ actual_bytes[i]);
+ if (current_color != actual_color ||
+ SkColorGetA(current_color) != 255)
+ is_actually_solid = false;
+
+ if (SkColorGetA(current_color) != 0)
+ is_transparent = false;
+ }
+
+ if (is_predicted_solid && !is_actually_solid)
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongActualNotSolid", true);
+ else if (is_predicted_solid &&
+ is_actually_solid &&
+ predicted_color != actual_color)
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongColor", true);
+ else if(!is_predicted_solid && is_actually_solid)
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongActualSolid", true);
+
+ bool correct_guess = (is_predicted_solid && is_actually_solid &&
+ predicted_color == actual_color) ||
+ (!is_predicted_solid && !is_actually_solid);
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", correct_guess);
+
+ if (correct_guess)
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid",
+ is_predicted_solid);
+
+ if (is_predicted_transparent)
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.PredictedTransparentIsActually", is_transparent);
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsActuallyTransparent", is_transparent);
+}
+
// static
void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref,
RenderingStats* stats) {

Powered by Google App Engine
This is Rietveld 408576698