| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 // This is a GR test | 9 // This is a GR test |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| 11 #include "GrClipStackClip.h" | 11 #include "GrClipStackClip.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 | 13 |
| 14 // Ensure that the 'getConservativeBounds' calls are returning bounds clamped | 14 // Ensure that the 'getConservativeBounds' calls are returning bounds clamped |
| 15 // to the render target | 15 // to the render target |
| 16 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) { | 16 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrClipBounds, reporter, ctxInfo) { |
| 17 static const int kXSize = 100; | 17 static const int kXSize = 100; |
| 18 static const int kYSize = 100; | 18 static const int kYSize = 100; |
| 19 | 19 |
| 20 const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); | 20 const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); |
| 21 const SkRect screen = SkRect::Make(intScreen); | 21 const SkRect screen = SkRect::Make(intScreen); |
| 22 | 22 |
| 23 SkRect clipRect(screen); | 23 SkRect clipRect(screen); |
| 24 clipRect.outset(10, 10); | 24 clipRect.outset(10, 10); |
| 25 | 25 |
| 26 // create a clip stack that will (trivially) reduce to a single rect that | 26 // create a clip stack that will (trivially) reduce to a single rect that |
| 27 // is larger than the screen | 27 // is larger than the screen |
| 28 SkClipStack stack; | 28 SkClipStack stack; |
| 29 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false); | 29 stack.clipDevRect(clipRect, SkCanvas::kReplace_Op, false); |
| 30 | 30 |
| 31 bool isIntersectionOfRects = true; | 31 bool isIntersectionOfRects = true; |
| 32 SkRect devStackBounds; | 32 SkRect devStackBounds; |
| 33 | 33 |
| 34 stack.getConservativeBounds(0, 0, kXSize, kYSize, | 34 stack.getConservativeBounds(0, 0, kXSize, kYSize, |
| 35 &devStackBounds, | 35 &devStackBounds, |
| 36 &isIntersectionOfRects); | 36 &isIntersectionOfRects); |
| 37 | 37 |
| 38 // make sure that the SkClipStack is behaving itself | 38 // make sure that the SkClipStack is behaving itself |
| 39 REPORTER_ASSERT(reporter, screen == devStackBounds); | 39 REPORTER_ASSERT(reporter, screen == devStackBounds); |
| 40 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 40 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
| 41 | 41 |
| 42 // wrap the SkClipStack in a GrClip | 42 // wrap the SkClipStack in a GrClip |
| 43 GrClipStackClip clipData(&stack); | 43 GrClipStackClip clipData(&stack); |
| 44 | 44 |
| 45 SkIRect devGrClipBound; | 45 SkIRect devGrClipBound; |
| 46 clipData.getConservativeBounds(kXSize, kYSize, | 46 clipData.getConservativeBounds(kXSize, kYSize, |
| 47 &devGrClipBound, | 47 &devGrClipBound, |
| 48 &isIntersectionOfRects); | 48 &isIntersectionOfRects); |
| 49 | 49 |
| 50 // make sure that GrClip is behaving itself | 50 // make sure that GrClip is behaving itself |
| 51 REPORTER_ASSERT(reporter, intScreen == devGrClipBound); | 51 REPORTER_ASSERT(reporter, intScreen == devGrClipBound); |
| 52 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 52 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
| 53 } | 53 } |
| 54 | 54 |
| 55 #endif | 55 #endif |
| OLD | NEW |