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 #include "effects/GrCoverageSetOpXP.h" | 8 #include "effects/GrCoverageSetOpXP.h" |
9 #include "GrCaps.h" | 9 #include "GrCaps.h" |
10 #include "GrColor.h" | 10 #include "GrColor.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 /////////////////////////////////////////////////////////////////////////////// | 238 /////////////////////////////////////////////////////////////////////////////// |
239 // | 239 // |
240 GrCoverageSetOpXPFactory::GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool i
nvertCoverage) | 240 GrCoverageSetOpXPFactory::GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool i
nvertCoverage) |
241 : fRegionOp(regionOp) | 241 : fRegionOp(regionOp) |
242 , fInvertCoverage(invertCoverage) { | 242 , fInvertCoverage(invertCoverage) { |
243 this->initClassID<GrCoverageSetOpXPFactory>(); | 243 this->initClassID<GrCoverageSetOpXPFactory>(); |
244 } | 244 } |
245 | 245 |
246 GrXPFactory* GrCoverageSetOpXPFactory::Create(SkRegion::Op regionOp, bool invert
Coverage) { | 246 sk_sp<GrXPFactory> GrCoverageSetOpXPFactory::Make(SkRegion::Op regionOp, bool in
vertCoverage) { |
247 switch (regionOp) { | 247 switch (regionOp) { |
248 case SkRegion::kReplace_Op: { | 248 case SkRegion::kReplace_Op: { |
249 if (invertCoverage) { | 249 if (invertCoverage) { |
250 static GrCoverageSetOpXPFactory gReplaceCDXPFI(regionOp, invertC
overage); | 250 static GrCoverageSetOpXPFactory gReplaceCDXPFI(regionOp, invertC
overage); |
251 return SkRef(&gReplaceCDXPFI); | 251 return sk_sp<GrXPFactory>(SkRef(&gReplaceCDXPFI)); |
252 } else { | 252 } else { |
253 static GrCoverageSetOpXPFactory gReplaceCDXPF(regionOp, invertCo
verage); | 253 static GrCoverageSetOpXPFactory gReplaceCDXPF(regionOp, invertCo
verage); |
254 return SkRef(&gReplaceCDXPF); | 254 return sk_sp<GrXPFactory>(SkRef(&gReplaceCDXPF)); |
255 } | 255 } |
256 break; | 256 break; |
257 } | 257 } |
258 case SkRegion::kIntersect_Op: { | 258 case SkRegion::kIntersect_Op: { |
259 if (invertCoverage) { | 259 if (invertCoverage) { |
260 static GrCoverageSetOpXPFactory gIntersectCDXPFI(regionOp, inver
tCoverage); | 260 static GrCoverageSetOpXPFactory gIntersectCDXPFI(regionOp, inver
tCoverage); |
261 return SkRef(&gIntersectCDXPFI); | 261 return sk_sp<GrXPFactory>(SkRef(&gIntersectCDXPFI)); |
262 } else { | 262 } else { |
263 static GrCoverageSetOpXPFactory gIntersectCDXPF(regionOp, invert
Coverage); | 263 static GrCoverageSetOpXPFactory gIntersectCDXPF(regionOp, invert
Coverage); |
264 return SkRef(&gIntersectCDXPF); | 264 return sk_sp<GrXPFactory>(SkRef(&gIntersectCDXPF)); |
265 } | 265 } |
266 break; | 266 break; |
267 } | 267 } |
268 case SkRegion::kUnion_Op: { | 268 case SkRegion::kUnion_Op: { |
269 if (invertCoverage) { | 269 if (invertCoverage) { |
270 static GrCoverageSetOpXPFactory gUnionCDXPFI(regionOp, invertCov
erage); | 270 static GrCoverageSetOpXPFactory gUnionCDXPFI(regionOp, invertCov
erage); |
271 return SkRef(&gUnionCDXPFI); | 271 return sk_sp<GrXPFactory>(SkRef(&gUnionCDXPFI)); |
272 } else { | 272 } else { |
273 static GrCoverageSetOpXPFactory gUnionCDXPF(regionOp, invertCove
rage); | 273 static GrCoverageSetOpXPFactory gUnionCDXPF(regionOp, invertCove
rage); |
274 return SkRef(&gUnionCDXPF); | 274 return sk_sp<GrXPFactory>(SkRef(&gUnionCDXPF)); |
275 } | 275 } |
276 break; | 276 break; |
277 } | 277 } |
278 case SkRegion::kXOR_Op: { | 278 case SkRegion::kXOR_Op: { |
279 if (invertCoverage) { | 279 if (invertCoverage) { |
280 static GrCoverageSetOpXPFactory gXORCDXPFI(regionOp, invertCover
age); | 280 static GrCoverageSetOpXPFactory gXORCDXPFI(regionOp, invertCover
age); |
281 return SkRef(&gXORCDXPFI); | 281 return sk_sp<GrXPFactory>(SkRef(&gXORCDXPFI)); |
282 } else { | 282 } else { |
283 static GrCoverageSetOpXPFactory gXORCDXPF(regionOp, invertCovera
ge); | 283 static GrCoverageSetOpXPFactory gXORCDXPF(regionOp, invertCovera
ge); |
284 return SkRef(&gXORCDXPF); | 284 return sk_sp<GrXPFactory>(SkRef(&gXORCDXPF)); |
285 } | 285 } |
286 break; | 286 break; |
287 } | 287 } |
288 case SkRegion::kDifference_Op: { | 288 case SkRegion::kDifference_Op: { |
289 if (invertCoverage) { | 289 if (invertCoverage) { |
290 static GrCoverageSetOpXPFactory gDifferenceCDXPFI(regionOp, inve
rtCoverage); | 290 static GrCoverageSetOpXPFactory gDifferenceCDXPFI(regionOp, inve
rtCoverage); |
291 return SkRef(&gDifferenceCDXPFI); | 291 return sk_sp<GrXPFactory>(SkRef(&gDifferenceCDXPFI)); |
292 } else { | 292 } else { |
293 static GrCoverageSetOpXPFactory gDifferenceCDXPF(regionOp, inver
tCoverage); | 293 static GrCoverageSetOpXPFactory gDifferenceCDXPF(regionOp, inver
tCoverage); |
294 return SkRef(&gDifferenceCDXPF); | 294 return sk_sp<GrXPFactory>(SkRef(&gDifferenceCDXPF)); |
295 } | 295 } |
296 break; | 296 break; |
297 } | 297 } |
298 case SkRegion::kReverseDifference_Op: { | 298 case SkRegion::kReverseDifference_Op: { |
299 if (invertCoverage) { | 299 if (invertCoverage) { |
300 static GrCoverageSetOpXPFactory gRevDiffCDXPFI(regionOp, invertC
overage); | 300 static GrCoverageSetOpXPFactory gRevDiffCDXPFI(regionOp, invertC
overage); |
301 return SkRef(&gRevDiffCDXPFI); | 301 return sk_sp<GrXPFactory>(SkRef(&gRevDiffCDXPFI)); |
302 } else { | 302 } else { |
303 static GrCoverageSetOpXPFactory gRevDiffCDXPF(regionOp, invertCo
verage); | 303 static GrCoverageSetOpXPFactory gRevDiffCDXPF(regionOp, invertCo
verage); |
304 return SkRef(&gRevDiffCDXPF); | 304 return sk_sp<GrXPFactory>(SkRef(&gRevDiffCDXPF)); |
305 } | 305 } |
306 break; | 306 break; |
307 } | 307 } |
308 default: | 308 default: |
309 return nullptr; | 309 return nullptr; |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 GrXferProcessor* | 313 GrXferProcessor* |
314 GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps, | 314 GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps, |
(...skipping 15 matching lines...) Expand all Loading... |
330 } | 330 } |
331 | 331 |
332 void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
orPOI, | 332 void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
orPOI, |
333 InvariantBlendedColor* b
lendedColor) const { | 333 InvariantBlendedColor* b
lendedColor) const { |
334 blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; | 334 blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; |
335 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 335 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
336 } | 336 } |
337 | 337 |
338 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); | 338 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); |
339 | 339 |
340 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ | 340 sk_sp<GrXPFactory> GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ |
341 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); | 341 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); |
342 bool invertCoverage = !d->fDrawContext->hasMixedSamples() && d->fRandom->nex
tBool(); | 342 bool invertCoverage = !d->fDrawContext->hasMixedSamples() && d->fRandom->nex
tBool(); |
343 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); | 343 return GrCoverageSetOpXPFactory::Make(regionOp, invertCoverage); |
344 } | 344 } |
OLD | NEW |