LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu - GrXferProcessor.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 90 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2015 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #include "GrXferProcessor.h"
       9             : #include "GrPipeline.h"
      10             : #include "gl/GrGLCaps.h"
      11             : 
      12           0 : GrXferProcessor::GrXferProcessor() : fWillReadDstColor(false), fDstReadUsesMixedSamples(false) {}
      13             : 
      14           0 : GrXferProcessor::GrXferProcessor(bool willReadDstColor, bool hasMixedSamples)
      15             :         : fWillReadDstColor(willReadDstColor)
      16           0 :         , fDstReadUsesMixedSamples(willReadDstColor && hasMixedSamples) {}
      17             : 
      18           0 : bool GrXferProcessor::hasSecondaryOutput() const {
      19           0 :     if (!this->willReadDstColor()) {
      20           0 :         return this->onHasSecondaryOutput();
      21             :     }
      22           0 :     return this->dstReadUsesMixedSamples();
      23             : }
      24             : 
      25           0 : void GrXferProcessor::getBlendInfo(BlendInfo* blendInfo) const {
      26           0 :     blendInfo->reset();
      27           0 :     if (!this->willReadDstColor()) {
      28           0 :         this->onGetBlendInfo(blendInfo);
      29           0 :     } else if (this->dstReadUsesMixedSamples()) {
      30           0 :         blendInfo->fDstBlend = kIS2A_GrBlendCoeff;
      31             :     }
      32           0 : }
      33             : 
      34           0 : void GrXferProcessor::getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b,
      35             :                                           const GrSurfaceOrigin* originIfDstTexture) const {
      36           0 :     uint32_t key = this->willReadDstColor() ? 0x1 : 0x0;
      37           0 :     if (key) {
      38           0 :         if (originIfDstTexture) {
      39           0 :             key |= 0x2;
      40           0 :             if (kTopLeft_GrSurfaceOrigin == *originIfDstTexture) {
      41           0 :                 key |= 0x4;
      42             :             }
      43             :         }
      44           0 :         if (this->dstReadUsesMixedSamples()) {
      45           0 :             key |= 0x8;
      46             :         }
      47             :     }
      48           0 :     b->add32(key);
      49           0 :     this->onGetGLSLProcessorKey(caps, b);
      50           0 : }
      51             : 
      52             : #ifdef SK_DEBUG
      53           0 : static const char* equation_string(GrBlendEquation eq) {
      54           0 :     switch (eq) {
      55             :         case kAdd_GrBlendEquation:
      56           0 :             return "add";
      57             :         case kSubtract_GrBlendEquation:
      58           0 :             return "subtract";
      59             :         case kReverseSubtract_GrBlendEquation:
      60           0 :             return "reverse_subtract";
      61             :         case kScreen_GrBlendEquation:
      62           0 :             return "screen";
      63             :         case kOverlay_GrBlendEquation:
      64           0 :             return "overlay";
      65             :         case kDarken_GrBlendEquation:
      66           0 :             return "darken";
      67             :         case kLighten_GrBlendEquation:
      68           0 :             return "lighten";
      69             :         case kColorDodge_GrBlendEquation:
      70           0 :             return "color_dodge";
      71             :         case kColorBurn_GrBlendEquation:
      72           0 :             return "color_burn";
      73             :         case kHardLight_GrBlendEquation:
      74           0 :             return "hard_light";
      75             :         case kSoftLight_GrBlendEquation:
      76           0 :             return "soft_light";
      77             :         case kDifference_GrBlendEquation:
      78           0 :             return "difference";
      79             :         case kExclusion_GrBlendEquation:
      80           0 :             return "exclusion";
      81             :         case kMultiply_GrBlendEquation:
      82           0 :             return "multiply";
      83             :         case kHSLHue_GrBlendEquation:
      84           0 :             return "hsl_hue";
      85             :         case kHSLSaturation_GrBlendEquation:
      86           0 :             return "hsl_saturation";
      87             :         case kHSLColor_GrBlendEquation:
      88           0 :             return "hsl_color";
      89             :         case kHSLLuminosity_GrBlendEquation:
      90           0 :             return "hsl_luminosity";
      91             :     };
      92           0 :     return "";
      93             : }
      94             : 
      95           0 : static const char* coeff_string(GrBlendCoeff coeff) {
      96           0 :     switch (coeff) {
      97             :         case kZero_GrBlendCoeff:
      98           0 :             return "zero";
      99             :         case kOne_GrBlendCoeff:
     100           0 :             return "one";
     101             :         case kSC_GrBlendCoeff:
     102           0 :             return "src_color";
     103             :         case kISC_GrBlendCoeff:
     104           0 :             return "inv_src_color";
     105             :         case kDC_GrBlendCoeff:
     106           0 :             return "dst_color";
     107             :         case kIDC_GrBlendCoeff:
     108           0 :             return "inv_dst_color";
     109             :         case kSA_GrBlendCoeff:
     110           0 :             return "src_alpha";
     111             :         case kISA_GrBlendCoeff:
     112           0 :             return "inv_src_alpha";
     113             :         case kDA_GrBlendCoeff:
     114           0 :             return "dst_alpha";
     115             :         case kIDA_GrBlendCoeff:
     116           0 :             return "inv_dst_alpha";
     117             :         case kConstC_GrBlendCoeff:
     118           0 :             return "const_color";
     119             :         case kIConstC_GrBlendCoeff:
     120           0 :             return "inv_const_color";
     121             :         case kConstA_GrBlendCoeff:
     122           0 :             return "const_alpha";
     123             :         case kIConstA_GrBlendCoeff:
     124           0 :             return "inv_const_alpha";
     125             :         case kS2C_GrBlendCoeff:
     126           0 :             return "src2_color";
     127             :         case kIS2C_GrBlendCoeff:
     128           0 :             return "inv_src2_color";
     129             :         case kS2A_GrBlendCoeff:
     130           0 :             return "src2_alpha";
     131             :         case kIS2A_GrBlendCoeff:
     132           0 :             return "inv_src2_alpha";
     133             :     }
     134           0 :     return "";
     135             : }
     136             : 
     137           0 : SkString GrXferProcessor::BlendInfo::dump() const {
     138           0 :     SkString out;
     139           0 :     out.printf("write_color(%d) equation(%s) src_coeff(%s) dst_coeff:(%s) const(0x%08x)",
     140           0 :                fWriteColor, equation_string(fEquation), coeff_string(fSrcBlend),
     141           0 :                coeff_string(fDstBlend), fBlendConstant);
     142           0 :     return out;
     143             : }
     144             : #endif
     145             : 
     146             : ///////////////////////////////////////////////////////////////////////////////
     147             : 
     148           0 : GrXPFactory::AnalysisProperties GrXPFactory::GetAnalysisProperties(
     149             :         const GrXPFactory* factory,
     150             :         const GrProcessorAnalysisColor& color,
     151             :         const GrProcessorAnalysisCoverage& coverage,
     152             :         const GrCaps& caps) {
     153             :     AnalysisProperties result;
     154           0 :     if (factory) {
     155           0 :         result = factory->analysisProperties(color, coverage, caps);
     156             :     } else {
     157           0 :         result = GrPorterDuffXPFactory::SrcOverAnalysisProperties(color, coverage, caps);
     158             :     }
     159           0 :     SkASSERT(!(result & AnalysisProperties::kRequiresDstTexture));
     160           0 :     if ((result & AnalysisProperties::kReadsDstInShader) &&
     161           0 :         !caps.shaderCaps()->dstReadInShaderSupport()) {
     162           0 :         result |= AnalysisProperties::kRequiresDstTexture;
     163           0 :         if (caps.textureBarrierSupport()) {
     164           0 :             result |= AnalysisProperties::kRequiresBarrierBetweenOverlappingDraws;
     165             :         }
     166             :     }
     167           0 :     return result;
     168             : }
     169             : 
     170           0 : sk_sp<const GrXferProcessor> GrXPFactory::MakeXferProcessor(const GrXPFactory* factory,
     171             :                                                             const GrProcessorAnalysisColor& color,
     172             :                                                             GrProcessorAnalysisCoverage coverage,
     173             :                                                             bool hasMixedSamples,
     174             :                                                             const GrCaps& caps) {
     175           0 :     SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport());
     176           0 :     if (factory) {
     177           0 :         return factory->makeXferProcessor(color, coverage, hasMixedSamples, caps);
     178             :     } else {
     179             :         return GrPorterDuffXPFactory::MakeSrcOverXferProcessor(color, coverage, hasMixedSamples,
     180           0 :                                                                caps);
     181             :     }
     182             : }

Generated by: LCOV version 1.13