diff options
author | dtrainor <dtrainor@chromium.org> | 2015-12-11 08:20:15 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-11 16:20:59 +0000 |
commit | fb0a1628cb77cc79d2e565b5219aca1a26c3dbbf (patch) | |
tree | c262560a13896e3bab181b159b94c738a530315d /cc/test | |
parent | 6f0958f7d8e4700226b67399bcfaddc464dd737b (diff) | |
download | chromium_src-fb0a1628cb77cc79d2e565b5219aca1a26c3dbbf.zip chromium_src-fb0a1628cb77cc79d2e565b5219aca1a26c3dbbf.tar.gz chromium_src-fb0a1628cb77cc79d2e565b5219aca1a26c3dbbf.tar.bz2 |
Serialize DisplayListRecordingSource to protos.
Add protobuf serialization to DisplayListRecordingSource. Also refactor
the unittests to run all tests in both serialization and
non-serialization mode.
BUG=541321
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1512823002
Cr-Commit-Position: refs/heads/master@{#364712}
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/fake_content_layer_client.cc | 8 | ||||
-rw-r--r-- | cc/test/fake_content_layer_client.h | 5 | ||||
-rw-r--r-- | cc/test/fake_display_list_recording_source.cc | 19 | ||||
-rw-r--r-- | cc/test/fake_display_list_recording_source.h | 9 | ||||
-rw-r--r-- | cc/test/skia_common.cc | 15 | ||||
-rw-r--r-- | cc/test/skia_common.h | 4 |
6 files changed, 57 insertions, 3 deletions
diff --git a/cc/test/fake_content_layer_client.cc b/cc/test/fake_content_layer_client.cc index ac8d282..6ffa8fe 100644 --- a/cc/test/fake_content_layer_client.cc +++ b/cc/test/fake_content_layer_client.cc @@ -28,10 +28,12 @@ FakeContentLayerClient::ImageData::ImageData(const SkImage* img, FakeContentLayerClient::ImageData::~ImageData() {} FakeContentLayerClient::FakeContentLayerClient() - : fill_with_nonsolid_color_(false), + : display_list_use_cached_picture_(true), + fill_with_nonsolid_color_(false), last_canvas_(nullptr), last_painting_control_(PAINTING_BEHAVIOR_NORMAL), - reported_memory_usage_(0) {} + reported_memory_usage_(0), + bounds_set_(false) {} FakeContentLayerClient::~FakeContentLayerClient() { } @@ -47,7 +49,7 @@ FakeContentLayerClient::PaintContentsToDisplayList( // Cached picture is used because unit tests expect to be able to // use GatherPixelRefs. DisplayItemListSettings settings; - settings.use_cached_picture = true; + settings.use_cached_picture = display_list_use_cached_picture_; scoped_refptr<DisplayItemList> display_list = DisplayItemList::Create(PaintableRegion(), settings); SkPictureRecorder recorder; diff --git a/cc/test/fake_content_layer_client.h b/cc/test/fake_content_layer_client.h index 00d562d..c63f5d2 100644 --- a/cc/test/fake_content_layer_client.h +++ b/cc/test/fake_content_layer_client.h @@ -44,6 +44,10 @@ class FakeContentLayerClient : public ContentLayerClient { bool FillsBoundsCompletely() const override; size_t GetApproximateUnsharedMemoryUsage() const override; + void set_display_list_use_cached_picture(bool use_cached_picture) { + display_list_use_cached_picture_ = use_cached_picture; + } + void set_fill_with_nonsolid_color(bool nonsolid) { fill_with_nonsolid_color_ = nonsolid; } @@ -89,6 +93,7 @@ class FakeContentLayerClient : public ContentLayerClient { typedef std::vector<std::pair<gfx::RectF, SkPaint>> RectPaintVector; typedef std::vector<ImageData> ImageVector; + bool display_list_use_cached_picture_; bool fill_with_nonsolid_color_; RectPaintVector draw_rects_; ImageVector draw_images_; diff --git a/cc/test/fake_display_list_recording_source.cc b/cc/test/fake_display_list_recording_source.cc index c48859e..fe0a127 100644 --- a/cc/test/fake_display_list_recording_source.cc +++ b/cc/test/fake_display_list_recording_source.cc @@ -5,6 +5,7 @@ #include "cc/test/fake_display_list_recording_source.h" #include "cc/test/fake_display_list_raster_source.h" +#include "cc/test/skia_common.h" namespace cc { @@ -24,4 +25,22 @@ FakeDisplayListRecordingSource::CreateRasterSource(bool can_use_lcd) const { this, can_use_lcd, playback_allowed_event_); } +bool FakeDisplayListRecordingSource::EqualsTo( + const FakeDisplayListRecordingSource& other) { + return recorded_viewport_ == other.recorded_viewport_ && + size_ == other.size_ && + slow_down_raster_scale_factor_for_debug_ == + other.slow_down_raster_scale_factor_for_debug_ && + generate_discardable_images_metadata_ == + other.generate_discardable_images_metadata_ && + requires_clear_ == other.requires_clear_ && + is_solid_color_ == other.is_solid_color_ && + clear_canvas_with_debug_color_ == + other.clear_canvas_with_debug_color_ && + solid_color_ == other.solid_color_ && + background_color_ == other.background_color_ && + AreDisplayListDrawingResultsSame(recorded_viewport_, display_list_, + other.display_list_); +} + } // namespace cc diff --git a/cc/test/fake_display_list_recording_source.h b/cc/test/fake_display_list_recording_source.h index f8e3cc1..cb526ad 100644 --- a/cc/test/fake_display_list_recording_source.h +++ b/cc/test/fake_display_list_recording_source.h @@ -48,6 +48,10 @@ class FakeDisplayListRecordingSource : public DisplayListRecordingSource { bool can_use_lcd) const override; bool IsSuitableForGpuRasterization() const override; + void SetDisplayListUsesCachedPicture(bool use_cached_picture) { + client_.set_display_list_use_cached_picture(use_cached_picture); + } + void SetRecordedViewport(const gfx::Rect& recorded_viewport) { recorded_viewport_ = recorded_viewport; } @@ -119,6 +123,11 @@ class FakeDisplayListRecordingSource : public DisplayListRecordingSource { DisplayItemList* display_list() const { return display_list_.get(); } + // Checks that the basic properties of the |other| match |this|. For the + // DisplayItemList, it checks that the painted result matches the painted + // result of |other|. + bool EqualsTo(const FakeDisplayListRecordingSource& other); + private: FakeContentLayerClient client_; SkPaint default_paint_; diff --git a/cc/test/skia_common.cc b/cc/test/skia_common.cc index 22d546c..aed4025 100644 --- a/cc/test/skia_common.cc +++ b/cc/test/skia_common.cc @@ -35,6 +35,21 @@ void DrawDisplayList(unsigned char* buffer, list->Raster(&canvas, NULL, gfx::Rect(), 1.0f); } +bool AreDisplayListDrawingResultsSame(const gfx::Rect& layer_rect, + scoped_refptr<DisplayItemList> list_a, + scoped_refptr<DisplayItemList> list_b) { + const size_t pixel_size = 4 * layer_rect.size().GetArea(); + + scoped_ptr<unsigned char[]> pixels_a(new unsigned char[pixel_size]); + scoped_ptr<unsigned char[]> pixels_b(new unsigned char[pixel_size]); + memset(pixels_a.get(), 0, pixel_size); + memset(pixels_b.get(), 0, pixel_size); + DrawDisplayList(pixels_a.get(), layer_rect, list_a); + DrawDisplayList(pixels_b.get(), layer_rect, list_b); + + return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size); +} + skia::RefPtr<SkImage> CreateDiscardableImage(const gfx::Size& size) { const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); diff --git a/cc/test/skia_common.h b/cc/test/skia_common.h index 2351e27..ba5d969 100644 --- a/cc/test/skia_common.h +++ b/cc/test/skia_common.h @@ -23,6 +23,10 @@ void DrawDisplayList(unsigned char* buffer, const gfx::Rect& layer_rect, scoped_refptr<DisplayItemList> list); +bool AreDisplayListDrawingResultsSame(const gfx::Rect& layer_rect, + scoped_refptr<DisplayItemList> list_a, + scoped_refptr<DisplayItemList> list_b); + skia::RefPtr<SkImage> CreateDiscardableImage(const gfx::Size& size); } // namespace cc |