| 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 GrSurfaceDesc desc; | 20 const SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); |
| 21 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 21 const SkRect screen = SkRect::Make(intScreen); |
| 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); | |
| 34 | 22 |
| 35 SkRect clipRect(screen); | 23 SkRect clipRect(screen); |
| 36 clipRect.outset(10, 10); | 24 clipRect.outset(10, 10); |
| 37 | 25 |
| 38 // 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 |
| 39 // is larger than the screen | 27 // is larger than the screen |
| 40 SkClipStack stack; | 28 SkClipStack stack; |
| 41 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false); | 29 stack.clipDevRect(clipRect, SkRegion::kReplace_Op, false); |
| 42 | 30 |
| 43 bool isIntersectionOfRects = true; | 31 bool isIntersectionOfRects = true; |
| 44 SkRect devStackBounds; | 32 SkRect devStackBounds; |
| 45 | 33 |
| 46 stack.getConservativeBounds(0, 0, kXSize, kYSize, | 34 stack.getConservativeBounds(0, 0, kXSize, kYSize, |
| 47 &devStackBounds, | 35 &devStackBounds, |
| 48 &isIntersectionOfRects); | 36 &isIntersectionOfRects); |
| 49 | 37 |
| 50 // make sure that the SkClipStack is behaving itself | 38 // make sure that the SkClipStack is behaving itself |
| 51 REPORTER_ASSERT(reporter, screen == devStackBounds); | 39 REPORTER_ASSERT(reporter, screen == devStackBounds); |
| 52 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 40 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
| 53 | 41 |
| 54 // wrap the SkClipStack in a GrClip | 42 // wrap the SkClipStack in a GrClip |
| 55 GrClip clipData; | 43 GrClip clipData; |
| 56 clipData.setClipStack(&stack); | 44 clipData.setClipStack(&stack); |
| 57 | 45 |
| 58 SkIRect devGrClipBound; | 46 SkIRect devGrClipBound; |
| 59 clipData.getConservativeBounds(texture->width(), texture->height(), | 47 clipData.getConservativeBounds(kXSize, kYSize, |
| 60 &devGrClipBound, | 48 &devGrClipBound, |
| 61 &isIntersectionOfRects); | 49 &isIntersectionOfRects); |
| 62 | 50 |
| 63 // make sure that GrClip is behaving itself | 51 // make sure that GrClip is behaving itself |
| 64 REPORTER_ASSERT(reporter, intScreen == devGrClipBound); | 52 REPORTER_ASSERT(reporter, intScreen == devGrClipBound); |
| 65 REPORTER_ASSERT(reporter, isIntersectionOfRects); | 53 REPORTER_ASSERT(reporter, isIntersectionOfRects); |
| 66 } | 54 } |
| 67 | 55 |
| 68 #endif | 56 #endif |
| OLD | NEW |