| 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 "gm.h" | 8 #include "gm.h" |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 #include "GrDrawContextPriv.h" | 11 #include "GrDrawContextPriv.h" |
| 12 #include "GrPipelineBuilder.h" | |
| 13 #include "SkRRect.h" | 12 #include "SkRRect.h" |
| 14 #include "batches/GrDrawBatch.h" | 13 #include "batches/GrDrawBatch.h" |
| 15 #include "batches/GrRectBatchFactory.h" | 14 #include "batches/GrRectBatchFactory.h" |
| 16 #include "effects/GrRRectEffect.h" | 15 #include "effects/GrRRectEffect.h" |
| 17 | 16 |
| 18 namespace skiagm { | 17 namespace skiagm { |
| 19 | 18 |
| 20 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
| 21 | 20 |
| 22 class BigRRectAAEffectGM : public GM { | 21 class BigRRectAAEffectGM : public GM { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 for (size_t et = 0; et < SK_ARRAY_COUNT(kEdgeTypes); ++et) { | 66 for (size_t et = 0; et < SK_ARRAY_COUNT(kEdgeTypes); ++et) { |
| 68 GrPrimitiveEdgeType edgeType = kEdgeTypes[et]; | 67 GrPrimitiveEdgeType edgeType = kEdgeTypes[et]; |
| 69 canvas->save(); | 68 canvas->save(); |
| 70 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 69 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
| 71 | 70 |
| 72 // Draw a background for the test case | 71 // Draw a background for the test case |
| 73 SkPaint paint; | 72 SkPaint paint; |
| 74 paint.setColor(SK_ColorWHITE); | 73 paint.setColor(SK_ColorWHITE); |
| 75 canvas->drawRect(testBounds, paint); | 74 canvas->drawRect(testBounds, paint); |
| 76 | 75 |
| 77 GrPipelineBuilder pipelineBuilder; | 76 GrPaint grPaint; |
| 78 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXferm
ode::kSrc_Mode)); | 77 grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSr
c_Mode)); |
| 79 | 78 |
| 80 SkRRect rrect = fRRect; | 79 SkRRect rrect = fRRect; |
| 81 rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap)); | 80 rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap)); |
| 82 sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrec
t)); | 81 sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeType, rrec
t)); |
| 83 SkASSERT(fp); | 82 SkASSERT(fp); |
| 84 if (fp) { | 83 if (fp) { |
| 85 pipelineBuilder.addCoverageFragmentProcessor(std::move(fp)); | 84 grPaint.addCoverageFragmentProcessor(std::move(fp)); |
| 86 | 85 |
| 87 SkRect bounds = testBounds; | 86 SkRect bounds = testBounds; |
| 88 bounds.offset(SkIntToScalar(x), SkIntToScalar(y)); | 87 bounds.offset(SkIntToScalar(x), SkIntToScalar(y)); |
| 89 | 88 |
| 90 SkAutoTUnref<GrDrawBatch> batch( | 89 SkAutoTUnref<GrDrawBatch> batch( |
| 91 GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMa
trix::I(), bounds, | 90 GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMa
trix::I(), bounds, |
| 92 nullptr, nullptr
)); | 91 nullptr, nullptr
)); |
| 93 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin
eBuilder, batch); | 92 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint
, batch); |
| 94 } | 93 } |
| 95 canvas->restore(); | 94 canvas->restore(); |
| 96 x = x + fTestOffsetX; | 95 x = x + fTestOffsetX; |
| 97 } | 96 } |
| 98 } | 97 } |
| 99 | 98 |
| 100 private: | 99 private: |
| 101 // pad between test cases | 100 // pad between test cases |
| 102 static const int kPad = 7; | 101 static const int kPad = 7; |
| 103 // gap between rect for each case that is rendered and exterior of rrect | 102 // gap between rect for each case that is rendered and exterior of rrect |
| (...skipping 17 matching lines...) Expand all Loading... |
| 121 | 120 |
| 122 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRect(SkRect::MakeIWH(kSize,
kSize)), "rect"); ) | 121 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRect(SkRect::MakeIWH(kSize,
kSize)), "rect"); ) |
| 123 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize,
kSize)), "circle"); ) | 122 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize,
kSize)), "circle"); ) |
| 124 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize -
1, kSize - 10)), "ellipse"); ) | 123 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeOval(SkRect::MakeIWH(kSize -
1, kSize - 10)), "ellipse"); ) |
| 125 // The next two have small linear segments between the corners | 124 // The next two have small linear segments between the corners |
| 126 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 10.f), "circular_corner"); ) | 125 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 10.f), "circular_corner"); ) |
| 127 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 15.f), "elliptical_corner"); ) | 126 DEF_GM( return new BigRRectAAEffectGM (SkRRect::MakeRectXY(SkRect::MakeIWH(kSize
- 1, kSize - 10), kSize/2.f - 10.f, kSize/2.f - 15.f), "elliptical_corner"); ) |
| 128 | 127 |
| 129 } | 128 } |
| 130 #endif | 129 #endif |
| OLD | NEW |