| 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 // 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" |
| 11 | 11 |
| 12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
| 13 | 13 |
| 14 #include "GrContext.h" | 14 #include "GrContext.h" |
| 15 #include "GrDrawContextPriv.h" | 15 #include "GrDrawContextPriv.h" |
| 16 #include "GrPipelineBuilder.h" | |
| 17 #include "SkGrPriv.h" | 16 #include "SkGrPriv.h" |
| 18 #include "SkGradientShader.h" | 17 #include "SkGradientShader.h" |
| 19 #include "batches/GrDrawBatch.h" | 18 #include "batches/GrDrawBatch.h" |
| 20 #include "batches/GrRectBatchFactory.h" | 19 #include "batches/GrRectBatchFactory.h" |
| 21 #include "effects/GrConstColorProcessor.h" | 20 #include "effects/GrConstColorProcessor.h" |
| 22 | 21 |
| 23 namespace skiagm { | 22 namespace skiagm { |
| 24 /** | 23 /** |
| 25 * This GM directly exercises GrConstColorProcessor. | 24 * This GM directly exercises GrConstColorProcessor. |
| 26 */ | 25 */ |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } else { | 99 } else { |
| 101 skPaint.setColor(kPaintColors[paintType]); | 100 skPaint.setColor(kPaintColors[paintType]); |
| 102 } | 101 } |
| 103 // SRGBTODO: No sRGB inputs allowed here? | 102 // SRGBTODO: No sRGB inputs allowed here? |
| 104 SkAssertResult(SkPaintToGrPaint(context, skPaint, viewMatrix
, false, &grPaint)); | 103 SkAssertResult(SkPaintToGrPaint(context, skPaint, viewMatrix
, false, &grPaint)); |
| 105 | 104 |
| 106 GrConstColorProcessor::InputMode mode = (GrConstColorProcess
or::InputMode) m; | 105 GrConstColorProcessor::InputMode mode = (GrConstColorProcess
or::InputMode) m; |
| 107 GrColor color = kColors[procColor]; | 106 GrColor color = kColors[procColor]; |
| 108 sk_sp<GrFragmentProcessor> fp(GrConstColorProcessor::Make(co
lor, mode)); | 107 sk_sp<GrFragmentProcessor> fp(GrConstColorProcessor::Make(co
lor, mode)); |
| 109 | 108 |
| 110 GrPipelineBuilder pipelineBuilder(grPaint, drawContext->must
UseHWAA(grPaint)); | 109 grPaint.addColorFragmentProcessor(std::move(fp)); |
| 111 pipelineBuilder.addColorFragmentProcessor(std::move(fp)); | |
| 112 | 110 |
| 113 SkAutoTUnref<GrDrawBatch> batch( | 111 SkAutoTUnref<GrDrawBatch> batch( |
| 114 GrRectBatchFactory::CreateNonAAFill(grPaint.getColor
(), viewMatrix, | 112 GrRectBatchFactory::CreateNonAAFill(grPaint.getColor
(), viewMatrix, |
| 115 renderRect, null
ptr, nullptr)); | 113 renderRect, null
ptr, nullptr)); |
| 116 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin
eBuilder, batch); | 114 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint
, batch); |
| 117 | 115 |
| 118 // Draw labels for the input to the processor and the proces
sor to the right of | 116 // Draw labels for the input to the processor and the proces
sor to the right of |
| 119 // the test rect. The input label appears above the processo
r label. | 117 // the test rect. The input label appears above the processo
r label. |
| 120 SkPaint labelPaint; | 118 SkPaint labelPaint; |
| 121 sk_tool_utils::set_portable_typeface(&labelPaint); | 119 sk_tool_utils::set_portable_typeface(&labelPaint); |
| 122 labelPaint.setAntiAlias(true); | 120 labelPaint.setAntiAlias(true); |
| 123 labelPaint.setTextSize(10.f); | 121 labelPaint.setTextSize(10.f); |
| 124 SkString inputLabel; | 122 SkString inputLabel; |
| 125 inputLabel.set("Input: "); | 123 inputLabel.set("Input: "); |
| 126 if (paintType >= SK_ARRAY_COUNT(kPaintColors)) { | 124 if (paintType >= SK_ARRAY_COUNT(kPaintColors)) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 typedef GM INHERITED; | 182 typedef GM INHERITED; |
| 185 }; | 183 }; |
| 186 | 184 |
| 187 const SkScalar ConstColorProcessor::kPad = 10.f; | 185 const SkScalar ConstColorProcessor::kPad = 10.f; |
| 188 const SkScalar ConstColorProcessor::kRectSize = 20.f; | 186 const SkScalar ConstColorProcessor::kRectSize = 20.f; |
| 189 | 187 |
| 190 DEF_GM(return new ConstColorProcessor;) | 188 DEF_GM(return new ConstColorProcessor;) |
| 191 } | 189 } |
| 192 | 190 |
| 193 #endif | 191 #endif |
| OLD | NEW |