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

Unified Diff: cc/output/software_renderer_unittest.cc

Issue 2867913002: Avoid using SkClipOp::kReplace_deprecated in software renderer (Closed)
Patch Set: feedback Created 3 years, 7 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/software_renderer.cc ('k') | no next file » | 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 b6867fe7247dc44248096634386730e562482218..19a68ca63402e4ca6756a8c9f301ddfe3b2ff98c 100644
--- a/cc/output/software_renderer_unittest.cc
+++ b/cc/output/software_renderer_unittest.cc
@@ -27,6 +27,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/utils/SkNWayCanvas.h"
#include "ui/gfx/skia_util.h"
namespace cc {
@@ -378,26 +379,45 @@ TEST_F(SoftwareRendererTest, RenderPassVisibleRect) {
interior_visible_rect.bottom() - 1));
}
+class ClipTrackingCanvas : public SkNWayCanvas {
+ public:
+ ClipTrackingCanvas(int width, int height) : SkNWayCanvas(width, height) {}
+ void onClipRect(const SkRect& rect,
+ SkClipOp op,
+ ClipEdgeStyle style) override {
+ last_clip_rect_ = rect;
+ SkNWayCanvas::onClipRect(rect, op, style);
+ }
+
+ SkRect last_clip_rect() const { return last_clip_rect_; }
+
+ private:
+ SkRect last_clip_rect_;
+};
+
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_;
+ canvas_.reset(new ClipTrackingCanvas(viewport_pixel_size_.width(),
+ viewport_pixel_size_.height()));
+ canvas_->addCanvas(SoftwareOutputDevice::BeginPaint(damage_rect));
+ return canvas_.get();
}
+
void EndPaint() override {
- clip_rect_at_end_ = gfx::SkIRectToRect(canvas_->getDeviceClipBounds());
+ clip_rect_at_end_ = gfx::SkRectToRectF(canvas_->last_clip_rect());
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_; }
+ gfx::RectF clip_rect_at_end() const { return clip_rect_at_end_; }
private:
- SkCanvas* canvas_ = nullptr;
+ std::unique_ptr<ClipTrackingCanvas> canvas_;
gfx::Rect damage_rect_at_start_;
- gfx::Rect clip_rect_at_end_;
+ gfx::RectF clip_rect_at_end_;
};
TEST_F(SoftwareRendererTest, PartialSwap) {
@@ -428,7 +448,7 @@ TEST_F(SoftwareRendererTest, PartialSwap) {
// 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());
+ EXPECT_EQ(gfx::RectF(2, 2, 3, 3), device->clip_rect_at_end());
}
} // namespace
« no previous file with comments | « cc/output/software_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698