From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- gfx/2d/unittest/TestBugs.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 gfx/2d/unittest/TestBugs.cpp (limited to 'gfx/2d/unittest/TestBugs.cpp') diff --git a/gfx/2d/unittest/TestBugs.cpp b/gfx/2d/unittest/TestBugs.cpp new file mode 100644 index 000000000..f127eed8b --- /dev/null +++ b/gfx/2d/unittest/TestBugs.cpp @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "TestBugs.h" +#include "2D.h" +#include + +using namespace mozilla; +using namespace mozilla::gfx; + +TestBugs::TestBugs() +{ + REGISTER_TEST(TestBugs, CairoClip918671); + REGISTER_TEST(TestBugs, PushPopClip950550); +} + +void +TestBugs::CairoClip918671() +{ + RefPtr dt = Factory::CreateDrawTarget(BackendType::CAIRO, + IntSize(100, 100), + SurfaceFormat::B8G8R8A8); + RefPtr ref = Factory::CreateDrawTarget(BackendType::CAIRO, + IntSize(100, 100), + SurfaceFormat::B8G8R8A8); + // Create a path that extends around the center rect but doesn't intersect it. + RefPtr pb1 = dt->CreatePathBuilder(); + pb1->MoveTo(Point(10, 10)); + pb1->LineTo(Point(90, 10)); + pb1->LineTo(Point(90, 20)); + pb1->LineTo(Point(10, 20)); + pb1->Close(); + pb1->MoveTo(Point(90, 90)); + pb1->LineTo(Point(91, 90)); + pb1->LineTo(Point(91, 91)); + pb1->LineTo(Point(91, 90)); + pb1->Close(); + + RefPtr path1 = pb1->Finish(); + dt->PushClip(path1); + + // This center rect must NOT be rectilinear! + RefPtr pb2 = dt->CreatePathBuilder(); + pb2->MoveTo(Point(50, 50)); + pb2->LineTo(Point(55, 51)); + pb2->LineTo(Point(54, 55)); + pb2->LineTo(Point(50, 56)); + pb2->Close(); + + RefPtr path2 = pb2->Finish(); + dt->PushClip(path2); + + dt->FillRect(Rect(0, 0, 100, 100), ColorPattern(Color(1,0,0))); + + RefPtr surf1 = dt->Snapshot(); + RefPtr surf2 = ref->Snapshot(); + + RefPtr dataSurf1 = surf1->GetDataSurface(); + RefPtr dataSurf2 = surf2->GetDataSurface(); + + for (int y = 0; y < dt->GetSize().height; y++) { + VERIFY(memcmp(dataSurf1->GetData() + y * dataSurf1->Stride(), + dataSurf2->GetData() + y * dataSurf2->Stride(), + dataSurf1->GetSize().width * 4) == 0); + } + +} + +void +TestBugs::PushPopClip950550() +{ + RefPtr dt = Factory::CreateDrawTarget(BackendType::CAIRO, + IntSize(500, 500), + SurfaceFormat::B8G8R8A8); + dt->PushClipRect(Rect(0, 0, 100, 100)); + Matrix m(1, 0, 0, 1, 45, -100); + dt->SetTransform(m); + dt->PopClip(); + + // We fail the test if we assert in this call because our draw target's + // transforms are out of sync. + dt->FillRect(Rect(50, 50, 50, 50), ColorPattern(Color(0.5f, 0, 0, 1.0f))); +} + -- cgit v1.2.3