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 #include "effects/GrCustomXfermode.h" | 8 #include "effects/GrCustomXfermode.h" |
9 | 9 |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
73 // Xfer Processor | 73 // Xfer Processor |
74 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
75 | 75 |
76 class CustomXP : public GrXferProcessor { | 76 class CustomXP : public GrXferProcessor { |
77 public: | 77 public: |
78 CustomXP(SkXfermode::Mode mode, GrBlendEquation hwBlendEquation) | 78 CustomXP(SkXfermode::Mode mode, GrBlendEquation hwBlendEquation, GrRenderTar
get* dst) |
79 : fMode(mode), | 79 : INHERITED(dst), fMode(mode), |
80 fHWBlendEquation(hwBlendEquation) { | 80 fHWBlendEquation(hwBlendEquation) { |
81 this->initClassID<CustomXP>(); | 81 this->initClassID<CustomXP>(); |
82 } | 82 } |
83 | 83 |
84 CustomXP(const DstTexture* dstTexture, bool hasMixedSamples, SkXfermode::Mod
e mode) | 84 CustomXP(const DstTexture* dstTexture, bool hasMixedSamples, SkXfermode::Mod
e mode, GrRenderTarget* dst) |
85 : INHERITED(dstTexture, true, hasMixedSamples), | 85 : INHERITED(dstTexture, true, hasMixedSamples, dst), |
86 fMode(mode), | 86 fMode(mode), |
87 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { | 87 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { |
88 this->initClassID<CustomXP>(); | 88 this->initClassID<CustomXP>(); |
89 } | 89 } |
90 | 90 |
91 const char* name() const override { return "Custom Xfermode"; } | 91 const char* name() const override { return "Custom Xfermode"; } |
92 | 92 |
93 GrGLXferProcessor* createGLInstance() const override; | 93 GrGLXferProcessor* createGLInstance() const override; |
94 | 94 |
95 SkXfermode::Mode mode() const { return fMode; } | 95 SkXfermode::Mode mode() const { return fMode; } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 325 } |
326 | 326 |
327 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 327 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
328 GrXPFactory::InvariantBlendedColor*) const ove
rride; | 328 GrXPFactory::InvariantBlendedColor*) const ove
rride; |
329 | 329 |
330 private: | 330 private: |
331 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, | 331 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, |
332 const GrProcOptInfo& colorPOI, | 332 const GrProcOptInfo& colorPOI, |
333 const GrProcOptInfo& coveragePOI, | 333 const GrProcOptInfo& coveragePOI, |
334 bool hasMixedSamples, | 334 bool hasMixedSamples, |
335 const DstTexture*) const override; | 335 const DstTexture*, |
| 336 GrRenderTarget* dst) const override; |
336 | 337 |
337 bool willReadDstColor(const GrCaps& caps, | 338 bool willReadDstColor(const GrCaps& caps, |
338 const GrProcOptInfo& colorPOI, | 339 const GrProcOptInfo& colorPOI, |
339 const GrProcOptInfo& coveragePOI, | 340 const GrProcOptInfo& coveragePOI, |
340 bool hasMixedSamples) const override; | 341 bool hasMixedSamples) const override; |
341 | 342 |
342 bool onIsEqual(const GrXPFactory& xpfBase) const override { | 343 bool onIsEqual(const GrXPFactory& xpfBase) const override { |
343 const CustomXPFactory& xpf = xpfBase.cast<CustomXPFactory>(); | 344 const CustomXPFactory& xpf = xpfBase.cast<CustomXPFactory>(); |
344 return fMode == xpf.fMode; | 345 return fMode == xpf.fMode; |
345 } | 346 } |
(...skipping 10 matching lines...) Expand all Loading... |
356 : fMode(mode), | 357 : fMode(mode), |
357 fHWBlendEquation(hw_blend_equation(mode)) { | 358 fHWBlendEquation(hw_blend_equation(mode)) { |
358 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); | 359 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); |
359 this->initClassID<CustomXPFactory>(); | 360 this->initClassID<CustomXPFactory>(); |
360 } | 361 } |
361 | 362 |
362 GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, | 363 GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, |
363 const GrProcOptInfo& col
orPOI, | 364 const GrProcOptInfo& col
orPOI, |
364 const GrProcOptInfo& cov
eragePOI, | 365 const GrProcOptInfo& cov
eragePOI, |
365 bool hasMixedSamples, | 366 bool hasMixedSamples, |
366 const DstTexture* dstTex
ture) const { | 367 const DstTexture* dstTex
ture, GrRenderTarget* dst) const { |
367 if (can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps)) { | 368 if (can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps)) { |
368 SkASSERT(!dstTexture || !dstTexture->texture()); | 369 SkASSERT(!dstTexture || !dstTexture->texture()); |
369 return new CustomXP(fMode, fHWBlendEquation); | 370 return new CustomXP(fMode, fHWBlendEquation, dst); |
370 } | 371 } |
371 return new CustomXP(dstTexture, hasMixedSamples, fMode); | 372 return new CustomXP(dstTexture, hasMixedSamples, fMode, dst); |
372 } | 373 } |
373 | 374 |
374 bool CustomXPFactory::willReadDstColor(const GrCaps& caps, | 375 bool CustomXPFactory::willReadDstColor(const GrCaps& caps, |
375 const GrProcOptInfo& colorPOI, | 376 const GrProcOptInfo& colorPOI, |
376 const GrProcOptInfo& coveragePOI, | 377 const GrProcOptInfo& coveragePOI, |
377 bool hasMixedSamples) const { | 378 bool hasMixedSamples) const { |
378 return !can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps); | 379 return !can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps); |
379 } | 380 } |
380 | 381 |
381 void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 382 void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
(...skipping 12 matching lines...) Expand all Loading... |
394 | 395 |
395 /////////////////////////////////////////////////////////////////////////////// | 396 /////////////////////////////////////////////////////////////////////////////// |
396 | 397 |
397 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 398 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
398 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 399 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
399 return nullptr; | 400 return nullptr; |
400 } else { | 401 } else { |
401 return new CustomXPFactory(mode); | 402 return new CustomXPFactory(mode); |
402 } | 403 } |
403 } | 404 } |
OLD | NEW |