2013-11-13 01:47:40 +04:00
|
|
|
/* -*- 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"
|
2013-11-17 21:55:16 +04:00
|
|
|
#include <string.h>
|
2013-11-13 01:47:40 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
|
|
|
TestBugs::TestBugs()
|
|
|
|
{
|
|
|
|
REGISTER_TEST(TestBugs, CairoClip918671);
|
2014-01-07 02:27:07 +04:00
|
|
|
REGISTER_TEST(TestBugs, PushPopClip950550);
|
2013-11-13 01:47:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestBugs::CairoClip918671()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BackendType::CAIRO,
|
2013-11-13 01:47:40 +04:00
|
|
|
IntSize(100, 100),
|
2014-01-10 23:06:16 +04:00
|
|
|
SurfaceFormat::B8G8R8A8);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> ref = Factory::CreateDrawTarget(BackendType::CAIRO,
|
2013-11-13 01:47:40 +04:00
|
|
|
IntSize(100, 100),
|
2014-01-10 23:06:16 +04:00
|
|
|
SurfaceFormat::B8G8R8A8);
|
2013-11-13 01:47:40 +04:00
|
|
|
// Create a path that extends around the center rect but doesn't intersect it.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PathBuilder> pb1 = dt->CreatePathBuilder();
|
2013-11-13 01:47:40 +04:00
|
|
|
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();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> path1 = pb1->Finish();
|
2013-11-13 01:47:40 +04:00
|
|
|
dt->PushClip(path1);
|
|
|
|
|
|
|
|
// This center rect must NOT be rectilinear!
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PathBuilder> pb2 = dt->CreatePathBuilder();
|
2013-11-13 01:47:40 +04:00
|
|
|
pb2->MoveTo(Point(50, 50));
|
|
|
|
pb2->LineTo(Point(55, 51));
|
|
|
|
pb2->LineTo(Point(54, 55));
|
|
|
|
pb2->LineTo(Point(50, 56));
|
|
|
|
pb2->Close();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Path> path2 = pb2->Finish();
|
2013-11-13 01:47:40 +04:00
|
|
|
dt->PushClip(path2);
|
|
|
|
|
|
|
|
dt->FillRect(Rect(0, 0, 100, 100), ColorPattern(Color(1,0,0)));
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> surf1 = dt->Snapshot();
|
|
|
|
RefPtr<SourceSurface> surf2 = ref->Snapshot();
|
2013-11-13 01:47:40 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataSourceSurface> dataSurf1 = surf1->GetDataSurface();
|
|
|
|
RefPtr<DataSourceSurface> dataSurf2 = surf2->GetDataSurface();
|
2013-11-13 01:47:40 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-07 02:27:07 +04:00
|
|
|
void
|
|
|
|
TestBugs::PushPopClip950550()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BackendType::CAIRO,
|
2014-01-07 02:27:07 +04:00
|
|
|
IntSize(500, 500),
|
2014-01-10 23:06:16 +04:00
|
|
|
SurfaceFormat::B8G8R8A8);
|
2014-01-07 02:27:07 +04:00
|
|
|
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)));
|
|
|
|
}
|
|
|
|
|