blob: 5660afdc27aa2cdb00b422509230113d3cbb1792 [file] [log] [blame]
bsalomon473addf2015-10-02 07:49:05 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Test.h"
9// This is a GR test
10#if SK_SUPPORT_GPU
11#include "GrClipMaskManager.h"
kkinnunen15302832015-12-01 04:35:26 -080012#include "GrContext.h"
bsalomon473addf2015-10-02 07:49:05 -070013
14// Ensure that the 'getConservativeBounds' calls are returning bounds clamped
15// to the render target
bsalomon68d91342016-04-12 09:59:58 -070016DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) {
bsalomon473addf2015-10-02 07:49:05 -070017 static const int kXSize = 100;
18 static const int kYSize = 100;
19
robertphillipsd4c741e2016-04-28 09:55:15 -070020 const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize);
21 const SkRect screen = SkRect::Make(intScreen);
bsalomon473addf2015-10-02 07:49:05 -070022
23 SkRect clipRect(screen);
24 clipRect.outset(10, 10);
25
26 // create a clip stack that will (trivially) reduce to a single rect that
27 // is larger than the screen
28 SkClipStack stack;
29 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false);
30
31 bool isIntersectionOfRects = true;
32 SkRect devStackBounds;
33
34 stack.getConservativeBounds(0, 0, kXSize, kYSize,
35 &devStackBounds,
36 &isIntersectionOfRects);
37
38 // make sure that the SkClipStack is behaving itself
39 REPORTER_ASSERT(reporter, screen == devStackBounds);
40 REPORTER_ASSERT(reporter, isIntersectionOfRects);
41
42 // wrap the SkClipStack in a GrClip
43 GrClip clipData;
44 clipData.setClipStack(&stack);
45
46 SkIRect devGrClipBound;
robertphillipsd4c741e2016-04-28 09:55:15 -070047 clipData.getConservativeBounds(kXSize, kYSize,
bsalomon473addf2015-10-02 07:49:05 -070048 &devGrClipBound,
49 &isIntersectionOfRects);
50
51 // make sure that GrClip is behaving itself
52 REPORTER_ASSERT(reporter, intScreen == devGrClipBound);
53 REPORTER_ASSERT(reporter, isIntersectionOfRects);
54}
55
bsalomon473addf2015-10-02 07:49:05 -070056#endif