| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. |
| 9 | 9 |
| 10 #include "gm.h" | 10 #include "gm.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 SkRect renderRect = SkRect::Make(fBmp.bounds()); | 106 SkRect renderRect = SkRect::Make(fBmp.bounds()); |
| 107 renderRect.outset(kDrawPad, kDrawPad); | 107 renderRect.outset(kDrawPad, kDrawPad); |
| 108 | 108 |
| 109 SkScalar y = kDrawPad + kTestPad; | 109 SkScalar y = kDrawPad + kTestPad; |
| 110 for (int tm = 0; tm < textureMatrices.count(); ++tm) { | 110 for (int tm = 0; tm < textureMatrices.count(); ++tm) { |
| 111 for (size_t d = 0; d < SK_ARRAY_COUNT(texelDomains); ++d) { | 111 for (size_t d = 0; d < SK_ARRAY_COUNT(texelDomains); ++d) { |
| 112 SkScalar x = kDrawPad + kTestPad; | 112 SkScalar x = kDrawPad + kTestPad; |
| 113 for (int m = 0; m < GrTextureDomain::kModeCount; ++m) { | 113 for (int m = 0; m < GrTextureDomain::kModeCount; ++m) { |
| 114 GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m; | 114 GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m; |
| 115 GrPipelineBuilder pipelineBuilder; | 115 GrPaint grPaint; |
| 116 pipelineBuilder.setXPFactory( | 116 grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode:
:kSrc_Mode)); |
| 117 GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); | |
| 118 sk_sp<GrFragmentProcessor> fp( | 117 sk_sp<GrFragmentProcessor> fp( |
| 119 GrTextureDomainEffect::Make(texture, textureMatrices[tm]
, | 118 GrTextureDomainEffect::Make(texture, textureMatrices[tm]
, |
| 120 GrTextureDomain::MakeTexelDomain
(texture, | 119 GrTextureDomain::MakeTexelDomain
(texture, |
| 121
texelDomains[d]), | 120
texelDomains[d]), |
| 122 mode, GrTextureParams::kNone_Fil
terMode)); | 121 mode, GrTextureParams::kNone_Fil
terMode)); |
| 123 | 122 |
| 124 if (!fp) { | 123 if (!fp) { |
| 125 continue; | 124 continue; |
| 126 } | 125 } |
| 127 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); | 126 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); |
| 128 pipelineBuilder.addColorFragmentProcessor(std::move(fp)); | 127 grPaint.addColorFragmentProcessor(std::move(fp)); |
| 129 | 128 |
| 130 SkAutoTUnref<GrDrawBatch> batch( | 129 SkAutoTUnref<GrDrawBatch> batch( |
| 131 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, | 130 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, |
| 132 renderRect, null
ptr, nullptr)); | 131 renderRect, null
ptr, nullptr)); |
| 133 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin
eBuilder, batch); | 132 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint
, batch); |
| 134 x += renderRect.width() + kTestPad; | 133 x += renderRect.width() + kTestPad; |
| 135 } | 134 } |
| 136 y += renderRect.height() + kTestPad; | 135 y += renderRect.height() + kTestPad; |
| 137 } | 136 } |
| 138 } | 137 } |
| 139 } | 138 } |
| 140 | 139 |
| 141 private: | 140 private: |
| 142 static const SkScalar kDrawPad; | 141 static const SkScalar kDrawPad; |
| 143 static const SkScalar kTestPad; | 142 static const SkScalar kTestPad; |
| 144 static const int kTargetWidth = 100; | 143 static const int kTargetWidth = 100; |
| 145 static const int kTargetHeight = 100; | 144 static const int kTargetHeight = 100; |
| 146 SkBitmap fBmp; | 145 SkBitmap fBmp; |
| 147 | 146 |
| 148 typedef GM INHERITED; | 147 typedef GM INHERITED; |
| 149 }; | 148 }; |
| 150 | 149 |
| 151 // Windows builds did not like SkScalar initialization in class :( | 150 // Windows builds did not like SkScalar initialization in class :( |
| 152 const SkScalar TextureDomainEffect::kDrawPad = 10.f; | 151 const SkScalar TextureDomainEffect::kDrawPad = 10.f; |
| 153 const SkScalar TextureDomainEffect::kTestPad = 10.f; | 152 const SkScalar TextureDomainEffect::kTestPad = 10.f; |
| 154 | 153 |
| 155 DEF_GM(return new TextureDomainEffect;) | 154 DEF_GM(return new TextureDomainEffect;) |
| 156 } | 155 } |
| 157 | 156 |
| 158 #endif | 157 #endif |
| OLD | NEW |