| 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 "GrClipMaskManager.h" | 11 #include "GrClipMaskManager.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 GrSurfaceDesc desc; |
| 21 const SkRect screen = SkRect::Make(intScreen); | 21 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 22 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 23 desc.fWidth = kXSize; |
| 24 desc.fHeight = kYSize; |
| 25 |
| 26 SkAutoTUnref<GrTexture> texture( |
| 27 ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgeted::k
Yes, nullptr, 0)); |
| 28 if (!texture) { |
| 29 return; |
| 30 } |
| 31 |
| 32 SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); |
| 33 SkRect screen = SkRect::Make(intScreen); |
| 22 | 34 |
| 23 SkRect clipRect(screen); | 35 SkRect clipRect(screen); |
| 24 clipRect.outset(10, 10); | 36 clipRect.outset(10, 10); |
| 25 | 37 |
| 26 // create a clip stack that will (trivially) reduce to a single rect that | 38 // create a clip stack that will (trivially) reduce to a single rect that |
| 27 // is larger than the screen | 39 // is larger than the screen |
| 28 SkClipStack stack; | 40 SkClipStack stack; |
| 29 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false); | 41 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false); |
| 30 | 42 |
| 31 bool isIntersectionOfRects = true; | 43 bool isIntersectionOfRects = true; |
| 32 SkRect devStackBounds; | 44 SkRect devStackBounds; |
| 33 | 45 |
| 34 stack.getConservativeBounds(0, 0, kXSize, kYSize, | 46 stack.getConservativeBounds(0, 0, kXSize, kYSize, |
| 35 &devStackBounds, | 47 &devStackBounds, |
| 36 &isIntersectionOfRects); | 48 &isIntersectionOfRects); |
| 37 | 49 |
| 38 // make sure that the SkClipStack is behaving itself | 50 // make sure that the SkClipStack is behaving itself |
| 39 REPORTER_ASSERT(reporter, screen == devStackBounds); | 51 REPORTER_ASSERT(reporter, screen == devStackBounds); |
| 40 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 52 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
| 41 | 53 |
| 42 // wrap the SkClipStack in a GrClip | 54 // wrap the SkClipStack in a GrClip |
| 43 GrClip clipData; | 55 GrClip clipData; |
| 44 clipData.setClipStack(&stack); | 56 clipData.setClipStack(&stack); |
| 45 | 57 |
| 46 SkIRect devGrClipBound; | 58 SkIRect devGrClipBound; |
| 47 clipData.getConservativeBounds(kXSize, kYSize, | 59 clipData.getConservativeBounds(texture->width(), texture->height(), |
| 48 &devGrClipBound, | 60 &devGrClipBound, |
| 49 &isIntersectionOfRects); | 61 &isIntersectionOfRects); |
| 50 | 62 |
| 51 // make sure that GrClip is behaving itself | 63 // make sure that GrClip is behaving itself |
| 52 REPORTER_ASSERT(reporter, intScreen == devGrClipBound); | 64 REPORTER_ASSERT(reporter, intScreen == devGrClipBound); |
| 53 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 65 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
| 54 } | 66 } |
| 55 | 67 |
| 56 #endif | 68 #endif |
| OLD | NEW |