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

Unified Diff: cc/output/software_renderer_unittest.cc

Issue 2161323002: cc: Make LayerTreeHostImpl unittests use a delegating output surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display-lthi-tests: . Created 4 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 | « cc/output/shader_unittest.cc ('k') | cc/test/fake_output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/software_renderer_unittest.cc
diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc
index be76d355d7b92a28fdd08ee76eff796b1e1b6bcc..db86db3319c1860f2ebdbffeb248babf1f1f3eef 100644
--- a/cc/output/software_renderer_unittest.cc
+++ b/cc/output/software_renderer_unittest.cc
@@ -26,6 +26,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "ui/gfx/skia_util.h"
namespace cc {
namespace {
@@ -395,5 +396,61 @@ TEST_F(SoftwareRendererTest, RenderPassVisibleRect) {
interior_visible_rect.bottom() - 1));
}
+class PartialSwapSoftwareOutputDevice : public SoftwareOutputDevice {
+ public:
+ // SoftwareOutputDevice overrides.
+ SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override {
+ damage_rect_at_start_ = damage_rect;
+ canvas_ = SoftwareOutputDevice::BeginPaint(damage_rect);
+ return canvas_;
+ }
+ void EndPaint() override {
+ SkIRect clip_device_bounds;
+ canvas_->getClipDeviceBounds(&clip_device_bounds);
+ clip_rect_at_end_ = gfx::SkIRectToRect(clip_device_bounds);
+ SoftwareOutputDevice::EndPaint();
+ }
+
+ gfx::Rect damage_rect_at_start() const { return damage_rect_at_start_; }
+ gfx::Rect clip_rect_at_end() const { return clip_rect_at_end_; }
+
+ private:
+ SkCanvas* canvas_ = nullptr;
+ gfx::Rect damage_rect_at_start_;
+ gfx::Rect clip_rect_at_end_;
+};
+
+TEST_F(SoftwareRendererTest, PartialSwap) {
+ float device_scale_factor = 1.f;
+ gfx::Rect device_viewport_rect(0, 0, 100, 100);
+
+ auto device_owned = base::MakeUnique<PartialSwapSoftwareOutputDevice>();
+ auto* device = device_owned.get();
+ InitializeRenderer(std::move(device_owned));
+
+ gfx::Rect viewport_rect(100, 100);
+ gfx::Rect clip_rect(100, 100);
+
+ RenderPassList list;
+
+ RenderPassId root_pass_id(1, 0);
+ RenderPass* root_pass =
+ AddRenderPass(&list, root_pass_id, viewport_rect, gfx::Transform());
+ AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
+
+ // Partial frame, we should pass this rect to the SoftwareOutputDevice.
+ // partial swap is enabled.
+ root_pass->damage_rect = gfx::Rect(2, 2, 3, 3);
+
+ renderer()->DecideRenderPassAllocationsForFrame(list);
+ renderer()->DrawFrame(&list, device_scale_factor, gfx::ColorSpace(),
+ viewport_rect, clip_rect);
+
+ // The damage rect should be reported to the SoftwareOutputDevice.
+ EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->damage_rect_at_start());
+ // The SkCanvas should be clipped to the damage rect.
+ EXPECT_EQ(gfx::Rect(2, 2, 3, 3), device->clip_rect_at_end());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/output/shader_unittest.cc ('k') | cc/test/fake_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698