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

Unified Diff: cc/playback/picture_pile_impl_perftest.cc

Issue 1234133003: cc: Add drawing for testing raster perf tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/playback/picture_pile_impl_perftest.cc
diff --git a/cc/playback/picture_pile_impl_perftest.cc b/cc/playback/picture_pile_impl_perftest.cc
index e1560400f22cea8e93023cce74d7ea2176262e33..31e6a56593cba0ff5185d963b695a166e908b40a 100644
--- a/cc/playback/picture_pile_impl_perftest.cc
+++ b/cc/playback/picture_pile_impl_perftest.cc
@@ -6,6 +6,7 @@
#include "cc/debug/lap_timer.h"
#include "cc/test/fake_picture_pile_impl.h"
+#include "cc/test/skia_common.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"
@@ -43,14 +44,24 @@ class PicturePileImplPerfTest : public testing::Test {
"analyze", "", test_name, timer_.LapsPerSecond(), "runs/s", true);
}
- void RunRasterTest(const std::string& test_name, float contents_scale) {
- scoped_refptr<PicturePileImpl> pile = FakePicturePileImpl::CreateFilledPile(
- gfx::Size(kTileSize, kTileSize), gfx::Size(kLayerSize, kLayerSize));
- // Content rect that will align with top-left tile at scale 1.0.
- gfx::Rect content_rect(0, 0, kTileSize, kTileSize);
+ void RunRasterTest(const std::string& test_name,
+ float contents_scale,
+ const gfx::Size& tile_size,
+ const gfx::Size& layer_bounds,
+ const gfx::Size& drawing_size,
+ int drawing_iterations) {
+ scoped_ptr<FakePicturePile> drawing =
+ FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
+ // Content rect that will align with given layer at scale 1.0.
+ gfx::Rect content_rect(0, 0, layer_bounds.width(), layer_bounds.height());
+
+ AddDrawing(drawing.get(), drawing_size, drawing_iterations);
+
+ scoped_refptr<PicturePileImpl> pile =
+ FakePicturePileImpl::CreateFromPile(drawing.get(), nullptr);
SkBitmap bitmap;
- bitmap.allocN32Pixels(1, 1);
+ bitmap.allocN32Pixels(layer_bounds.width(), layer_bounds.height());
SkCanvas canvas(bitmap);
timer_.Reset();
@@ -64,6 +75,51 @@ class PicturePileImplPerfTest : public testing::Test {
"raster", "", test_name, timer_.LapsPerSecond(), "runs/s", true);
}
+ void AddDrawing(FakePicturePile* drawing,
+ const gfx::Size& drawing_size,
+ int drawing_iterations) {
+ if ((drawing_iterations <= 0) || drawing_size.IsEmpty())
+ return;
+
+ int x_pos = 0;
+ int y_pos = 0;
+ int width = drawing_size.width();
+ int height = drawing_size.height();
+ int color = 0;
+
+ // Create full drawing size bitmap so that it will cover the all tiles
+ // needed for given drawing size.
+ SkBitmap bitmap;
+ CreateBitmap(gfx::Size(width, height), "bitmap", &bitmap);
+ // TODO(prashant.n): Initialize bitmpa pixels, so that every test run gets
+ // same bitmap data.
+
+ SkPaint paint;
+
+ for (int i = 0; i < drawing_iterations; ++i) {
+ // Delimit location in drawing size area so that something gets drawn on
+ // the layer.
+ x_pos = ++x_pos % drawing_size.width();
+ y_pos = ++y_pos % drawing_size.height();
+ width = (--width) ? width : drawing_size.width();
+ height = (--height) ? height : drawing_size.height();
+ color = ++color % 255;
+ paint.setColor(SkColorSetARGB(color, color, color, color));
+ gfx::Rect rect(x_pos, y_pos, width, height);
+ drawing->add_draw_rect_with_paint(rect, paint);
+ drawing->add_draw_bitmap_with_paint(bitmap, gfx::Point(x_pos, y_pos),
+ paint);
+ }
+
+ // Record again.
+ for (int x = 0; x < drawing->tiling().num_tiles_x(); ++x) {
+ for (int y = 0; y < drawing->tiling().num_tiles_y(); ++y) {
+ drawing->RemoveRecordingAt(x, y);
+ drawing->AddRecordingAt(x, y);
+ }
+ }
+ }
+
private:
LapTimer timer_;
};
@@ -75,9 +131,20 @@ TEST_F(PicturePileImplPerfTest, Analyze) {
}
TEST_F(PicturePileImplPerfTest, Raster) {
- RunRasterTest("1", 1.0f);
- RunRasterTest("4", 0.5f);
- RunRasterTest("100", 0.1f);
+ gfx::Size tile_size(kTileSize, kTileSize);
+ gfx::Size layer_bounds(kLayerSize, kLayerSize);
+
+ RunRasterTest("1", 1.0f, tile_size, layer_bounds, layer_bounds, 0);
+ RunRasterTest("4", 0.5f, tile_size, layer_bounds, layer_bounds, 0);
+ RunRasterTest("100", 0.1f, tile_size, layer_bounds, layer_bounds, 0);
+
+ RunRasterTest("1_1", 1.0f, tile_size, layer_bounds, layer_bounds, 1);
+ RunRasterTest("4_1", 0.5f, tile_size, layer_bounds, layer_bounds, 1);
+ RunRasterTest("100_1", 0.1f, tile_size, layer_bounds, layer_bounds, 1);
+
+ RunRasterTest("1_64", 1.0f, tile_size, layer_bounds, layer_bounds, 64);
+ RunRasterTest("4_64", 0.5f, tile_size, layer_bounds, layer_bounds, 64);
+ RunRasterTest("100_64", 0.1f, tile_size, layer_bounds, layer_bounds, 64);
}
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698