| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 #ifdef SK_DEBUG | 94 #ifdef SK_DEBUG |
| 95 SkASSERT(kMaxTileBound.contains(fRRects[curRRect].getBounds())); | 95 SkASSERT(kMaxTileBound.contains(fRRects[curRRect].getBounds())); |
| 96 SkRect imageSpaceBounds = fRRects[curRRect].getBounds(); | 96 SkRect imageSpaceBounds = fRRects[curRRect].getBounds(); |
| 97 imageSpaceBounds.offset(SkIntToScalar(x), SkIntToScalar(y)); | 97 imageSpaceBounds.offset(SkIntToScalar(x), SkIntToScalar(y)); |
| 98 SkASSERT(kMaxImageBound.contains(imageSpaceBounds)); | 98 SkASSERT(kMaxImageBound.contains(imageSpaceBounds)); |
| 99 #endif | 99 #endif |
| 100 canvas->save(); | 100 canvas->save(); |
| 101 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 101 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
| 102 if (kEffect_Type == fType) { | 102 if (kEffect_Type == fType) { |
| 103 #if SK_SUPPORT_GPU | 103 #if SK_SUPPORT_GPU |
| 104 GrPipelineBuilder pipelineBuilder; | 104 GrPaint grPaint; |
| 105 pipelineBuilder.setXPFactory( | 105 grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXferm
ode::kSrc_Mode)); |
| 106 GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); | |
| 107 | 106 |
| 108 SkRRect rrect = fRRects[curRRect]; | 107 SkRRect rrect = fRRects[curRRect]; |
| 109 rrect.offset(SkIntToScalar(x), SkIntToScalar(y)); | 108 rrect.offset(SkIntToScalar(x), SkIntToScalar(y)); |
| 110 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; | 109 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; |
| 111 sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeTy
pe, rrect)); | 110 sk_sp<GrFragmentProcessor> fp(GrRRectEffect::Make(edgeTy
pe, rrect)); |
| 112 if (fp) { | 111 if (fp) { |
| 113 pipelineBuilder.addCoverageFragmentProcessor(std::mo
ve(fp)); | 112 grPaint.addCoverageFragmentProcessor(std::move(fp)); |
| 114 | 113 |
| 115 SkRect bounds = rrect.getBounds(); | 114 SkRect bounds = rrect.getBounds(); |
| 116 bounds.outset(2.f, 2.f); | 115 bounds.outset(2.f, 2.f); |
| 117 | 116 |
| 118 SkAutoTUnref<GrDrawBatch> batch( | 117 SkAutoTUnref<GrDrawBatch> batch( |
| 119 GrRectBatchFactory::CreateNonAAFill(0xff0000
00, SkMatrix::I(), | 118 GrRectBatchFactory::CreateNonAAFill(0xff0000
00, SkMatrix::I(), |
| 120 bounds,
nullptr, nullptr)); | 119 bounds,
nullptr, nullptr)); |
| 121 drawContext->drawContextPriv().testingOnly_drawBatch
(pipelineBuilder, | 120 drawContext->drawContextPriv().testingOnly_drawBatch
(grPaint, batch); |
| 122
batch); | |
| 123 } else { | 121 } else { |
| 124 drew = false; | 122 drew = false; |
| 125 } | 123 } |
| 126 #endif | 124 #endif |
| 127 } else if (kBW_Clip_Type == fType || kAA_Clip_Type == fType)
{ | 125 } else if (kBW_Clip_Type == fType || kAA_Clip_Type == fType)
{ |
| 128 bool aaClip = (kAA_Clip_Type == fType); | 126 bool aaClip = (kAA_Clip_Type == fType); |
| 129 canvas->clipRRect(fRRects[curRRect], SkRegion::kReplace_
Op, aaClip); | 127 canvas->clipRRect(fRRects[curRRect], SkRegion::kReplace_
Op, aaClip); |
| 130 canvas->drawRect(kMaxTileBound, paint); | 128 canvas->drawRect(kMaxTileBound, paint); |
| 131 } else { | 129 } else { |
| 132 canvas->drawRRect(fRRects[curRRect], paint); | 130 canvas->drawRRect(fRRects[curRRect], paint); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 251 |
| 254 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) | 252 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) |
| 255 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) | 253 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) |
| 256 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) | 254 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) |
| 257 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) | 255 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) |
| 258 #if SK_SUPPORT_GPU | 256 #if SK_SUPPORT_GPU |
| 259 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) | 257 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) |
| 260 #endif | 258 #endif |
| 261 | 259 |
| 262 } | 260 } |
| OLD | NEW |