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

Side by Side Diff: gm/rrects.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/rectangletexture.cpp ('k') | gm/texdata.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 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 case kEffect_Type: 55 case kEffect_Type:
56 name.append("_effect"); 56 name.append("_effect");
57 break; 57 break;
58 } 58 }
59 return name; 59 return name;
60 } 60 }
61 61
62 SkISize onISize() override { return SkISize::Make(kImageWidth, kImageHeight) ; } 62 SkISize onISize() override { return SkISize::Make(kImageWidth, kImageHeight) ; }
63 63
64 void onDraw(SkCanvas* canvas) override { 64 void onDraw(SkCanvas* canvas) override {
65 GrContext* context = nullptr; 65 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw Context();
66 #if SK_SUPPORT_GPU 66 if (kEffect_Type == fType && !drawContext) {
67 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget ();
68 context = rt ? rt->getContext() : nullptr;
69 sk_sp<GrDrawContext> drawContext;
70 if (kEffect_Type == fType) {
71 if (!context) {
72 skiagm::GM::DrawGpuOnlyMessage(canvas);
73 return;
74 }
75
76 drawContext = context->drawContext(sk_ref_sp(rt));
77 if (!drawContext) {
78 return;
79 }
80 }
81 #endif
82 if (kEffect_Type == fType && nullptr == context) {
83 skiagm::GM::DrawGpuOnlyMessage(canvas); 67 skiagm::GM::DrawGpuOnlyMessage(canvas);
84 return; 68 return;
85 } 69 }
86 70
87 SkPaint paint; 71 SkPaint paint;
88 if (kAA_Draw_Type == fType) { 72 if (kAA_Draw_Type == fType) {
89 paint.setAntiAlias(true); 73 paint.setAntiAlias(true);
90 } 74 }
91 75
92 static const SkRect kMaxTileBound = SkRect::MakeWH(SkIntToScalar(kTileX) , 76 static const SkRect kMaxTileBound = SkRect::MakeWH(SkIntToScalar(kTileX) ,
(...skipping 28 matching lines...) Expand all
121 pipelineBuilder.setXPFactory( 105 pipelineBuilder.setXPFactory(
122 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode) )->unref(); 106 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode) )->unref();
123 107
124 SkRRect rrect = fRRects[curRRect]; 108 SkRRect rrect = fRRects[curRRect];
125 rrect.offset(SkIntToScalar(x), SkIntToScalar(y)); 109 rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
126 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 110 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
127 SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Crea te(edgeType, 111 SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Crea te(edgeType,
128 rrect)); 112 rrect));
129 if (fp) { 113 if (fp) {
130 pipelineBuilder.addCoverageFragmentProcessor(fp); 114 pipelineBuilder.addCoverageFragmentProcessor(fp);
131 pipelineBuilder.setRenderTarget(rt); 115 pipelineBuilder.setRenderTarget(drawContext->accessR enderTarget());
132 116
133 SkRect bounds = rrect.getBounds(); 117 SkRect bounds = rrect.getBounds();
134 bounds.outset(2.f, 2.f); 118 bounds.outset(2.f, 2.f);
135 119
136 SkAutoTUnref<GrDrawBatch> batch( 120 SkAutoTUnref<GrDrawBatch> batch(
137 GrRectBatchFactory::CreateNonAAFill(0xff0000 00, SkMatrix::I(), 121 GrRectBatchFactory::CreateNonAAFill(0xff0000 00, SkMatrix::I(),
138 bounds, nullptr, nullptr)); 122 bounds, nullptr, nullptr));
139 drawContext->drawContextPriv().testingOnly_drawBatch (pipelineBuilder, 123 drawContext->drawContextPriv().testingOnly_drawBatch (pipelineBuilder,
140 batch); 124 batch);
141 } else { 125 } else {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 255
272 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) 256 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); )
273 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) 257 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); )
274 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) 258 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); )
275 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) 259 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); )
276 #if SK_SUPPORT_GPU 260 #if SK_SUPPORT_GPU
277 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) 261 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); )
278 #endif 262 #endif
279 263
280 } 264 }
OLDNEW
« no previous file with comments | « gm/rectangletexture.cpp ('k') | gm/texdata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698