Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: gm/constcolorprocessor.cpp

Issue 1930623003: Clean up test drawContext usage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix typo Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/bigrrectaaeffect.cpp ('k') | gm/convexpolyeffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 void onOnceBeforeDraw() override { 42 void onOnceBeforeDraw() override {
43 SkColor colors[] = { 0xFFFF0000, 0x2000FF00, 0xFF0000FF}; 43 SkColor colors[] = { 0xFFFF0000, 0x2000FF00, 0xFF0000FF};
44 SkPoint pts[] = { SkPoint::Make(0, 0), SkPoint::Make(kRectSize, kRectSiz e) }; 44 SkPoint pts[] = { SkPoint::Make(0, 0), SkPoint::Make(kRectSize, kRectSiz e) };
45 fShader = SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_CO UNT(colors), 45 fShader = SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_CO UNT(colors),
46 SkShader::kClamp_TileMode); 46 SkShader::kClamp_TileMode);
47 } 47 }
48 48
49 void onDraw(SkCanvas* canvas) override { 49 void onDraw(SkCanvas* canvas) override {
50 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget (); 50 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw Context();
51 if (nullptr == rt) { 51 if (!drawContext) {
52 return;
53 }
54 GrContext* context = rt->getContext();
55 if (nullptr == context) {
56 skiagm::GM::DrawGpuOnlyMessage(canvas); 52 skiagm::GM::DrawGpuOnlyMessage(canvas);
57 return; 53 return;
58 } 54 }
59 55
60 sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(rt))); 56 GrContext* context = canvas->getGrContext();
61 if (!drawContext) { 57 if (!context) {
62 return; 58 return;
63 } 59 }
64 60
65 static const GrColor kColors[] = { 61 static const GrColor kColors[] = {
66 0xFFFFFFFF, 62 0xFFFFFFFF,
67 0xFFFF00FF, 63 0xFFFF00FF,
68 0x80000000, 64 0x80000000,
69 0x00000000, 65 0x00000000,
70 }; 66 };
71 67
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 skPaint.setColor(kPaintColors[paintType]); 101 skPaint.setColor(kPaintColors[paintType]);
106 } 102 }
107 // SRGBTODO: No sRGB inputs allowed here? 103 // SRGBTODO: No sRGB inputs allowed here?
108 SkAssertResult(SkPaintToGrPaint(context, skPaint, viewMatrix , false, &grPaint)); 104 SkAssertResult(SkPaintToGrPaint(context, skPaint, viewMatrix , false, &grPaint));
109 105
110 GrConstColorProcessor::InputMode mode = (GrConstColorProcess or::InputMode) m; 106 GrConstColorProcessor::InputMode mode = (GrConstColorProcess or::InputMode) m;
111 GrColor color = kColors[procColor]; 107 GrColor color = kColors[procColor];
112 SkAutoTUnref<GrFragmentProcessor> fp(GrConstColorProcessor:: Create(color, mode)); 108 SkAutoTUnref<GrFragmentProcessor> fp(GrConstColorProcessor:: Create(color, mode));
113 109
114 GrClip clip; 110 GrClip clip;
115 GrPipelineBuilder pipelineBuilder(grPaint, rt, clip); 111 GrPipelineBuilder pipelineBuilder(grPaint,
112 drawContext->accessRenderT arget(),
113 clip);
116 pipelineBuilder.addColorFragmentProcessor(fp); 114 pipelineBuilder.addColorFragmentProcessor(fp);
117 115
118 SkAutoTUnref<GrDrawBatch> batch( 116 SkAutoTUnref<GrDrawBatch> batch(
119 GrRectBatchFactory::CreateNonAAFill(grPaint.getColor (), viewMatrix, 117 GrRectBatchFactory::CreateNonAAFill(grPaint.getColor (), viewMatrix,
120 renderRect, null ptr, nullptr)); 118 renderRect, null ptr, nullptr));
121 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin eBuilder, batch); 119 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin eBuilder, batch);
122 120
123 // Draw labels for the input to the processor and the proces sor to the right of 121 // Draw labels for the input to the processor and the proces sor to the right of
124 // the test rect. The input label appears above the processo r label. 122 // the test rect. The input label appears above the processo r label.
125 SkPaint labelPaint; 123 SkPaint labelPaint;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 typedef GM INHERITED; 187 typedef GM INHERITED;
190 }; 188 };
191 189
192 const SkScalar ConstColorProcessor::kPad = 10.f; 190 const SkScalar ConstColorProcessor::kPad = 10.f;
193 const SkScalar ConstColorProcessor::kRectSize = 20.f; 191 const SkScalar ConstColorProcessor::kRectSize = 20.f;
194 192
195 DEF_GM(return new ConstColorProcessor;) 193 DEF_GM(return new ConstColorProcessor;)
196 } 194 }
197 195
198 #endif 196 #endif
OLDNEW
« no previous file with comments | « gm/bigrrectaaeffect.cpp ('k') | gm/convexpolyeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698