LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu - GrPipeline.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 75 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 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 "GrPipeline.h"
       9             : 
      10             : #include "GrAppliedClip.h"
      11             : #include "GrCaps.h"
      12             : #include "GrGpu.h"
      13             : #include "GrPipelineBuilder.h"
      14             : #include "GrRenderTargetContext.h"
      15             : #include "GrRenderTargetOpList.h"
      16             : #include "GrRenderTargetPriv.h"
      17             : #include "GrXferProcessor.h"
      18             : 
      19             : #include "ops/GrOp.h"
      20             : 
      21           0 : void GrPipeline::init(const InitArgs& args) {
      22           0 :     SkASSERT(args.fRenderTarget);
      23           0 :     SkASSERT(args.fProcessors);
      24           0 :     SkASSERT(args.fProcessors->isFinalized());
      25             : 
      26           0 :     fRenderTarget.reset(args.fRenderTarget);
      27             : 
      28           0 :     fFlags = args.fFlags;
      29           0 :     if (args.fAppliedClip) {
      30           0 :         fScissorState = args.fAppliedClip->scissorState();
      31           0 :         if (args.fAppliedClip->hasStencilClip()) {
      32           0 :             fFlags |= kHasStencilClip_Flag;
      33             :         }
      34           0 :         fWindowRectsState = args.fAppliedClip->windowRectsState();
      35             :     }
      36           0 :     if (args.fProcessors->usesDistanceVectorField()) {
      37           0 :         fFlags |= kUsesDistanceVectorField_Flag;
      38             :     }
      39           0 :     if (args.fProcessors->disableOutputConversionToSRGB()) {
      40           0 :         fFlags |= kDisableOutputConversionToSRGB_Flag;
      41             :     }
      42           0 :     if (args.fProcessors->allowSRGBInputs()) {
      43           0 :         fFlags |= kAllowSRGBInputs_Flag;
      44             :     }
      45           0 :     if (!args.fUserStencil->isDisabled(fFlags & kHasStencilClip_Flag)) {
      46           0 :         fFlags |= kStencilEnabled_Flag;
      47             :     }
      48             : 
      49           0 :     fUserStencilSettings = args.fUserStencil;
      50             : 
      51           0 :     fDrawFace = static_cast<int16_t>(args.fDrawFace);
      52             : 
      53           0 :     fXferProcessor = args.fProcessors->refXferProcessor();
      54             : 
      55           0 :     if (args.fDstTexture.texture()) {
      56           0 :         fDstTexture.reset(args.fDstTexture.texture());
      57           0 :         fDstTextureOffset = args.fDstTexture.offset();
      58             :     }
      59             : 
      60             :     // Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline, possibly removing some of the
      61             :     // color fragment processors.
      62           0 :     fNumColorProcessors = args.fProcessors->numColorFragmentProcessors();
      63             :     int numTotalProcessors =
      64           0 :             fNumColorProcessors + args.fProcessors->numCoverageFragmentProcessors();
      65           0 :     if (args.fAppliedClip && args.fAppliedClip->clipCoverageFragmentProcessor()) {
      66           0 :         ++numTotalProcessors;
      67             :     }
      68           0 :     fFragmentProcessors.reset(numTotalProcessors);
      69           0 :     int currFPIdx = 0;
      70           0 :     for (int i = 0; i < args.fProcessors->numColorFragmentProcessors(); ++i, ++currFPIdx) {
      71           0 :         const GrFragmentProcessor* fp = args.fProcessors->colorFragmentProcessor(i);
      72           0 :         fFragmentProcessors[currFPIdx].reset(fp);
      73             :     }
      74             : 
      75           0 :     for (int i = 0; i < args.fProcessors->numCoverageFragmentProcessors(); ++i, ++currFPIdx) {
      76           0 :         const GrFragmentProcessor* fp = args.fProcessors->coverageFragmentProcessor(i);
      77           0 :         fFragmentProcessors[currFPIdx].reset(fp);
      78             :     }
      79           0 :     if (args.fAppliedClip) {
      80           0 :         if (const GrFragmentProcessor* fp = args.fAppliedClip->clipCoverageFragmentProcessor()) {
      81           0 :             fFragmentProcessors[currFPIdx].reset(fp);
      82             :         }
      83             :     }
      84           0 : }
      85             : 
      86           0 : static void add_dependencies_for_processor(const GrFragmentProcessor* proc, GrRenderTarget* rt) {
      87           0 :     GrFragmentProcessor::TextureAccessIter iter(proc);
      88           0 :     while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) {
      89           0 :         SkASSERT(rt->getLastOpList());
      90           0 :         rt->getLastOpList()->addDependency(sampler->texture());
      91           0 :     }
      92           0 : }
      93             : 
      94           0 : void GrPipeline::addDependenciesTo(GrRenderTarget* rt) const {
      95           0 :     for (int i = 0; i < fFragmentProcessors.count(); ++i) {
      96           0 :         add_dependencies_for_processor(fFragmentProcessors[i].get(), rt);
      97             :     }
      98             : 
      99           0 :     if (fDstTexture) {
     100           0 :         SkASSERT(rt->getLastOpList());
     101           0 :         rt->getLastOpList()->addDependency(fDstTexture.get());
     102             :     }
     103           0 : }
     104             : 
     105           0 : GrPipeline::GrPipeline(GrRenderTarget* rt, SkBlendMode blendmode)
     106             :         : fRenderTarget(rt)
     107             :         , fScissorState()
     108             :         , fWindowRectsState()
     109             :         , fUserStencilSettings(&GrUserStencilSettings::kUnused)
     110             :         , fDrawFace(static_cast<uint16_t>(GrDrawFace::kBoth))
     111             :         , fFlags()
     112             :         , fXferProcessor(GrPorterDuffXPFactory::MakeNoCoverageXP(blendmode))
     113             :         , fFragmentProcessors()
     114           0 :         , fNumColorProcessors(0) {}
     115             : 
     116             : ////////////////////////////////////////////////////////////////////////////////
     117             : 
     118           0 : bool GrPipeline::AreEqual(const GrPipeline& a, const GrPipeline& b) {
     119           0 :     SkASSERT(&a != &b);
     120             : 
     121           0 :     if (a.getRenderTarget() != b.getRenderTarget() ||
     122           0 :         a.fFragmentProcessors.count() != b.fFragmentProcessors.count() ||
     123           0 :         a.fNumColorProcessors != b.fNumColorProcessors ||
     124           0 :         a.fScissorState != b.fScissorState ||
     125           0 :         a.fWindowRectsState != b.fWindowRectsState ||
     126           0 :         a.fFlags != b.fFlags ||
     127           0 :         a.fUserStencilSettings != b.fUserStencilSettings ||
     128           0 :         a.fDrawFace != b.fDrawFace) {
     129           0 :         return false;
     130             :     }
     131             : 
     132             :     // Most of the time both are nullptr
     133           0 :     if (a.fXferProcessor.get() || b.fXferProcessor.get()) {
     134           0 :         if (!a.getXferProcessor().isEqual(b.getXferProcessor())) {
     135           0 :             return false;
     136             :         }
     137             :     }
     138             : 
     139           0 :     for (int i = 0; i < a.numFragmentProcessors(); i++) {
     140           0 :         if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i))) {
     141           0 :             return false;
     142             :         }
     143             :     }
     144           0 :     return true;
     145             : }

Generated by: LCOV version 1.13