| 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 #ifndef GrPorterDuffXferProcessor_DEFINED | 8 #ifndef GrPorterDuffXferProcessor_DEFINED |
| 9 #define GrPorterDuffXferProcessor_DEFINED | 9 #define GrPorterDuffXferProcessor_DEFINED |
| 10 | 10 |
| 11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "GrXferProcessor.h" | 12 #include "GrXferProcessor.h" |
| 13 #include "SkXfermode.h" | 13 #include "SkXfermode.h" |
| 14 | 14 |
| 15 class GrProcOptInfo; | 15 class GrProcOptInfo; |
| 16 | 16 |
| 17 class GrPorterDuffXPFactory : public GrXPFactory { | 17 class GrPorterDuffXPFactory : public GrXPFactory { |
| 18 public: | 18 public: |
| 19 static GrXPFactory* Create(SkXfermode::Mode mode); | 19 static GrXPFactory* Create(SkXfermode::Mode mode); |
| 20 | 20 |
| 21 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 21 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 22 GrXPFactory::InvariantBlendedColor*) const ove
rride; | 22 GrXPFactory::InvariantBlendedColor*) const ove
rride; |
| 23 | 23 |
| 24 |
| 25 /** Because src-over is so common we special case it for performance reasons
. If this returns |
| 26 null then the SimpleSrcOverXP() below should be used. */ |
| 24 static GrXferProcessor* CreateSrcOverXferProcessor(const GrCaps& caps, | 27 static GrXferProcessor* CreateSrcOverXferProcessor(const GrCaps& caps, |
| 25 const GrPipelineOptimizat
ions& optimizations, | 28 const GrPipelineOptimizat
ions& optimizations, |
| 26 bool hasMixedSamples, | 29 bool hasMixedSamples, |
| 27 const GrXferProcessor::Ds
tTexture*); | 30 const GrXferProcessor::Ds
tTexture*); |
| 31 /** This XP implements non-LCD src-over using hw blend with no optimizations
. It is returned |
| 32 by reference because it is global and its ref-cnting methods are not thr
ead safe. */ |
| 33 static const GrXferProcessor& SimpleSrcOverXP(); |
| 28 | 34 |
| 29 static inline void SrcOverInvariantBlendedColor( | 35 static inline void SrcOverInvariantBlendedColor( |
| 30 GrColor inputColor, | 36 GrColor inputColor, |
| 31 GrColorComponentFlags validColor
Flags, | 37 GrColorComponentFlags validColor
Flags, |
| 32 bool isOpaque, | 38 bool isOpaque, |
| 33 GrXPFactory::InvariantBlendedCol
or* blendedColor) { | 39 GrXPFactory::InvariantBlendedCol
or* blendedColor) { |
| 34 if (!isOpaque) { | 40 if (!isOpaque) { |
| 35 blendedColor->fWillBlendWithDst = true; | 41 blendedColor->fWillBlendWithDst = true; |
| 36 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 42 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 37 return; | 43 return; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 66 GR_DECLARE_XP_FACTORY_TEST; | 72 GR_DECLARE_XP_FACTORY_TEST; |
| 67 static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, in
t* outSecondary); | 73 static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, in
t* outSecondary); |
| 68 | 74 |
| 69 SkXfermode::Mode fXfermode; | 75 SkXfermode::Mode fXfermode; |
| 70 | 76 |
| 71 friend class GrPorterDuffTest; // for TestGetXPOutputTypes() | 77 friend class GrPorterDuffTest; // for TestGetXPOutputTypes() |
| 72 typedef GrXPFactory INHERITED; | 78 typedef GrXPFactory INHERITED; |
| 73 }; | 79 }; |
| 74 | 80 |
| 75 #endif | 81 #endif |
| OLD | NEW |