LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu/ops - GrDrawOp.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 39 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 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             : #ifndef GrDrawOp_DEFINED
       9             : #define GrDrawOp_DEFINED
      10             : 
      11             : #include <functional>
      12             : #include "GrOp.h"
      13             : #include "GrPipeline.h"
      14             : 
      15             : class GrAppliedClip;
      16             : 
      17             : /**
      18             :  * GrDrawOps are flushed in two phases (preDraw, and draw). In preDraw uploads to GrGpuResources
      19             :  * and draws are determined and scheduled. They are issued in the draw phase. GrDrawOpUploadToken is
      20             :  * used to sequence the uploads relative to each other and to draws.
      21             :  **/
      22             : 
      23             : class GrDrawOpUploadToken {
      24             : public:
      25           0 :     static GrDrawOpUploadToken AlreadyFlushedToken() { return GrDrawOpUploadToken(0); }
      26             : 
      27           0 :     GrDrawOpUploadToken(const GrDrawOpUploadToken& that) : fSequenceNumber(that.fSequenceNumber) {}
      28           0 :     GrDrawOpUploadToken& operator =(const GrDrawOpUploadToken& that) {
      29           0 :         fSequenceNumber = that.fSequenceNumber;
      30           0 :         return *this;
      31             :     }
      32           0 :     bool operator==(const GrDrawOpUploadToken& that) const {
      33           0 :         return fSequenceNumber == that.fSequenceNumber;
      34             :     }
      35           0 :     bool operator!=(const GrDrawOpUploadToken& that) const { return !(*this == that); }
      36             : 
      37             : private:
      38             :     GrDrawOpUploadToken();
      39           0 :     explicit GrDrawOpUploadToken(uint64_t sequenceNumber) : fSequenceNumber(sequenceNumber) {}
      40             :     friend class GrOpFlushState;
      41             :     uint64_t fSequenceNumber;
      42             : };
      43             : 
      44             : /**
      45             :  * Base class for GrOps that draw. These ops have a GrPipeline installed by GrOpList.
      46             :  */
      47           0 : class GrDrawOp : public GrOp {
      48             : public:
      49             :     /** Method that performs an upload on behalf of a DeferredUploadFn. */
      50             :     using WritePixelsFn = std::function<bool(GrSurface* texture,
      51             :                                              int left, int top, int width, int height,
      52             :                                              GrPixelConfig config, const void* buffer,
      53             :                                              size_t rowBytes)>;
      54             :     /** See comments before GrDrawOp::Target definition on how deferred uploaders work. */
      55             :     using DeferredUploadFn = std::function<void(WritePixelsFn&)>;
      56             : 
      57             :     class Target;
      58             : 
      59           0 :     GrDrawOp(uint32_t classID) : INHERITED(classID) {}
      60             : 
      61             :     /**
      62             :      * This information is required to determine how to compute a GrAppliedClip from a GrClip for
      63             :      * this op.
      64             :      */
      65             :     enum class FixedFunctionFlags : uint32_t {
      66             :         kNone = 0x0,
      67             :         /** Indices that the op will enable MSAA or mixed samples rendering. */
      68             :         kUsesHWAA = 0x1,
      69             :         /** Indices that the op reads and/or writes the stencil buffer */
      70             :         kUsesStencil = 0x2,
      71             :     };
      72             :     GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(FixedFunctionFlags);
      73             :     virtual FixedFunctionFlags fixedFunctionFlags() const = 0;
      74             : 
      75             :     /**
      76             :      * This is called after the GrAppliedClip has been computed and just prior to recording the op
      77             :      * or combining it with a previously recorded op. It is used to determine whether a copy of the
      78             :      * destination (or destination texture itself) needs to be provided to the xp when this op
      79             :      * executes. This is guaranteed to be called before an op is recorded. However, this is also
      80             :      * called on ops that are not recorded because they combine with a previously recorded op.
      81             :      */
      82             :     virtual bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) = 0;
      83             : 
      84             : protected:
      85           0 :     static SkString DumpPipelineInfo(const GrPipeline& pipeline) {
      86           0 :         SkString string;
      87           0 :         string.appendf("RT: %d\n", pipeline.getRenderTarget()->uniqueID().asUInt());
      88           0 :         string.append("ColorStages:\n");
      89           0 :         for (int i = 0; i < pipeline.numColorFragmentProcessors(); i++) {
      90           0 :             string.appendf("\t\t%s\n\t\t%s\n",
      91           0 :                            pipeline.getColorFragmentProcessor(i).name(),
      92           0 :                            pipeline.getColorFragmentProcessor(i).dumpInfo().c_str());
      93             :         }
      94           0 :         string.append("CoverageStages:\n");
      95           0 :         for (int i = 0; i < pipeline.numCoverageFragmentProcessors(); i++) {
      96           0 :             string.appendf("\t\t%s\n\t\t%s\n",
      97           0 :                            pipeline.getCoverageFragmentProcessor(i).name(),
      98           0 :                            pipeline.getCoverageFragmentProcessor(i).dumpInfo().c_str());
      99             :         }
     100           0 :         string.appendf("XP: %s\n", pipeline.getXferProcessor().name());
     101             : 
     102           0 :         bool scissorEnabled = pipeline.getScissorState().enabled();
     103           0 :         string.appendf("Scissor: ");
     104           0 :         if (scissorEnabled) {
     105             :             string.appendf("[L: %d, T: %d, R: %d, B: %d]\n",
     106           0 :                            pipeline.getScissorState().rect().fLeft,
     107           0 :                            pipeline.getScissorState().rect().fTop,
     108           0 :                            pipeline.getScissorState().rect().fRight,
     109           0 :                            pipeline.getScissorState().rect().fBottom);
     110             :         } else {
     111           0 :             string.appendf("<disabled>\n");
     112             :         }
     113           0 :         return string;
     114             :     }
     115             : 
     116           0 :     struct QueuedUpload {
     117           0 :         QueuedUpload(DeferredUploadFn&& upload, GrDrawOpUploadToken token)
     118           0 :             : fUpload(std::move(upload))
     119           0 :             , fUploadBeforeToken(token) {}
     120             :         DeferredUploadFn fUpload;
     121             :         GrDrawOpUploadToken fUploadBeforeToken;
     122             :     };
     123             : 
     124             :     SkTArray<QueuedUpload> fInlineUploads;
     125             : 
     126             : private:
     127             :     typedef GrOp INHERITED;
     128             : };
     129             : 
     130           0 : GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags);
     131             : 
     132             : #endif

Generated by: LCOV version 1.13