Commit 8eae448d authored by tomhudson's avatar tomhudson Committed by Commit bot

Start enabling platform_canvas_unittests on Linux

These unittests have been disabled for years, limiting our coverage;
by implementing a Cairo version of DrawNativeRect() we can turn on at
least a few of them.

R=fmalita@chromium.org
BUG=154358

Review-Url: https://codereview.chromium.org/2332293003
Cr-Commit-Position: refs/heads/master@{#418545}
parent 604a9c1f
......@@ -662,7 +662,7 @@ test("skia_unittests") {
"ext/skia_utils_mac_unittest.mm",
]
if (!is_win && !is_mac) {
if (!is_win && !is_mac && !use_cairo) {
sources -= [ "ext/platform_canvas_unittest.cc" ]
}
......@@ -684,6 +684,12 @@ test("skia_unittests") {
"//skia/public/interfaces:test_interfaces",
]
}
if (is_linux) {
if (use_pango) {
configs += [ "//build/config/linux/pangocairo" ]
}
}
}
if (!is_ios) {
......
......@@ -26,6 +26,14 @@
#include <unistd.h>
#endif
#if defined(USE_CAIRO)
#if defined(OS_OPENBSD)
#include <cairo.h>
#else
#include <cairo/cairo.h>
#endif // OS_OPENBSD
#endif // USE_CAIRO
namespace skia {
namespace {
......@@ -116,12 +124,10 @@ bool VerifyBlackRect(const SkCanvas& canvas, int x, int y, int w, int h) {
return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h);
}
#if !defined(USE_AURA) // http://crbug.com/154358
// Check that every pixel in the canvas is a single color.
bool VerifyCanvasColor(const SkCanvas& canvas, uint32_t canvas_color) {
return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0);
}
#endif // !defined(USE_AURA)
#if defined(OS_WIN)
void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
......@@ -147,6 +153,15 @@ void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
CGColorRelease(black);
CGContextFillRect(context, inner_rc);
}
#elif defined(USE_CAIRO)
void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
cairo_t* context = scoped_platform_paint.GetPlatformSurface();
cairo_rectangle(context, x, y, w, h);
cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
cairo_fill(context);
}
#else
void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
NOTIMPLEMENTED();
......@@ -225,7 +240,6 @@ TEST(PlatformCanvas, SkLayer) {
EXPECT_TRUE(VerifyBlackRect(*canvas, kLayerX, kLayerY, kLayerW, kLayerH));
}
#if !defined(USE_AURA) // http://crbug.com/154358
// Test native clipping.
TEST(PlatformCanvas, ClipRegion) {
// Initialize a white canvas
......@@ -250,7 +264,6 @@ TEST(PlatformCanvas, ClipRegion) {
}
EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE));
}
#endif // !defined(USE_AURA)
// Test the layers get filled properly by native rendering.
TEST(PlatformCanvas, FillLayer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment