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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2010 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 GrRenderTargetOpList_DEFINED
       9             : #define GrRenderTargetOpList_DEFINED
      10             : 
      11             : #include "GrAppliedClip.h"
      12             : #include "GrOpList.h"
      13             : #include "GrPathRendering.h"
      14             : #include "GrPrimitiveProcessor.h"
      15             : #include "SkArenaAlloc.h"
      16             : #include "SkClipStack.h"
      17             : #include "SkMatrix.h"
      18             : #include "SkStringUtils.h"
      19             : #include "SkStrokeRec.h"
      20             : #include "SkTArray.h"
      21             : #include "SkTLazy.h"
      22             : #include "SkTypes.h"
      23             : 
      24             : class GrAuditTrail;
      25             : class GrClearOp;
      26             : class GrCaps;
      27             : class GrOp;
      28             : class GrPipelineBuilder;
      29             : class GrRenderTargetProxy;
      30             : 
      31             : class GrRenderTargetOpList final : public GrOpList {
      32             : private:
      33             :     using DstTexture = GrXferProcessor::DstTexture;
      34             : 
      35             : public:
      36             :     /** Options for GrRenderTargetOpList behavior. */
      37             :     struct Options {
      38             :         int fMaxOpCombineLookback = -1;
      39             :         int fMaxOpCombineLookahead = -1;
      40             :     };
      41             : 
      42             :     GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrResourceProvider*,
      43             :                          GrAuditTrail*, const Options&);
      44             : 
      45             :     ~GrRenderTargetOpList() override;
      46             : 
      47           0 :     void makeClosed() override {
      48           0 :         INHERITED::makeClosed();
      49             : 
      50           0 :         fLastFullClearOp = nullptr;
      51           0 :         this->forwardCombine();
      52           0 :     }
      53             : 
      54             :     /**
      55             :      * Empties the draw buffer of any queued up draws.
      56             :      */
      57             :     void reset() override;
      58             : 
      59             :     void abandonGpuResources() override;
      60             :     void freeGpuResources() override;
      61             : 
      62             :     /**
      63             :      * Together these two functions flush all queued up draws to GrCommandBuffer. The return value
      64             :      * of executeOps() indicates whether any commands were actually issued to the GPU.
      65             :      */
      66             :     void prepareOps(GrOpFlushState* flushState) override;
      67             :     bool executeOps(GrOpFlushState* flushState) override;
      68             : 
      69             :     /**
      70             :      * Gets the capabilities of the draw target.
      71             :      */
      72           0 :     const GrCaps* caps() const { return fGpu->caps(); }
      73             : 
      74           0 :     uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) {
      75           0 :         this->recordOp(std::move(op), renderTargetContext, nullptr, nullptr);
      76           0 :         return this->uniqueID();
      77             :     }
      78           0 :     uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext,
      79             :                    GrAppliedClip&& clip, const DstTexture& dstTexture) {
      80           0 :         this->recordOp(std::move(op), renderTargetContext, clip.doesClip() ? &clip : nullptr,
      81           0 :                        &dstTexture);
      82           0 :         return this->uniqueID();
      83             :     }
      84             : 
      85             :     /** Clears the entire render target */
      86             :     void fullClear(GrRenderTargetContext*, GrColor color);
      87             : 
      88             :     /** Discards the contents render target. */
      89             :     void discard(GrRenderTargetContext*);
      90             : 
      91             :     /**
      92             :      * Copies a pixel rectangle from one surface to another. This call may finalize
      93             :      * reserved vertex/index data (as though a draw call was made). The src pixels
      94             :      * copied are specified by srcRect. They are copied to a rect of the same
      95             :      * size in dst with top left at dstPoint. If the src rect is clipped by the
      96             :      * src bounds then  pixel values in the dst rect corresponding to area clipped
      97             :      * by the src rect are not overwritten. This method is not guaranteed to succeed
      98             :      * depending on the type of surface, configs, etc, and the backend-specific
      99             :      * limitations.
     100             :      */
     101             :     bool copySurface(GrResourceProvider* resourceProvider,
     102             :                      GrSurfaceProxy* dst,
     103             :                      GrSurfaceProxy* src,
     104             :                      const SkIRect& srcRect,
     105             :                      const SkIPoint& dstPoint);
     106             : 
     107           0 :     gr_instanced::InstancedRendering* instancedRendering() const {
     108           0 :         SkASSERT(fInstancedRendering);
     109           0 :         return fInstancedRendering.get();
     110             :     }
     111             : 
     112           0 :     GrRenderTargetOpList* asRenderTargetOpList() override { return this; }
     113             : 
     114             :     SkDEBUGCODE(void dump() const override;)
     115             : 
     116             :     SkDEBUGCODE(void validateTargetsSingleRenderTarget() const;)
     117             : 
     118             : private:
     119             :     friend class GrRenderTargetContextPriv; // for stencil clip state. TODO: this is invasive
     120             : 
     121           0 :     struct RecordedOp {
     122           0 :         RecordedOp(std::unique_ptr<GrOp> op,
     123             :                    GrRenderTarget* rt,
     124             :                    const GrAppliedClip* appliedClip,
     125             :                    const DstTexture* dstTexture)
     126           0 :                 : fOp(std::move(op))
     127             :                 , fRenderTarget(rt)
     128           0 :                 , fAppliedClip(appliedClip) {
     129           0 :             if (dstTexture) {
     130           0 :                 fDstTexture = *dstTexture;
     131             :             }
     132           0 :         }
     133             :         std::unique_ptr<GrOp> fOp;
     134             :         // TODO: These ops will all to target the same render target and this won't be needed.
     135             :         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
     136             :         DstTexture fDstTexture;
     137             :         const GrAppliedClip* fAppliedClip;
     138             :     };
     139             : 
     140             :     // If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
     141             :     // returns the input op.
     142             :     GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, GrAppliedClip* = nullptr,
     143             :                    const DstTexture* = nullptr);
     144             : 
     145             :     void forwardCombine();
     146             : 
     147             :     // If this returns true then b has been merged into a's op.
     148             :     bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip,
     149             :                            const DstTexture* bDstTexture);
     150             : 
     151             :     GrClearOp* fLastFullClearOp = nullptr;
     152             :     GrGpuResource::UniqueID fLastFullClearResourceID = GrGpuResource::UniqueID::InvalidID();
     153             :     GrSurfaceProxy::UniqueID fLastFullClearProxyID = GrSurfaceProxy::UniqueID::InvalidID();
     154             : 
     155             :     GrGpu* fGpu;
     156             :     GrResourceProvider* fResourceProvider;
     157             : 
     158             :     int fMaxOpLookback;
     159             :     int fMaxOpLookahead;
     160             : 
     161             :     std::unique_ptr<gr_instanced::InstancedRendering> fInstancedRendering;
     162             : 
     163             :     int32_t fLastClipStackGenID;
     164             :     SkIRect fLastDevClipBounds;
     165             : 
     166             :     SkSTArray<256, RecordedOp, true> fRecordedOps;
     167             : 
     168             :     char fClipAllocatorStorage[4096];
     169             :     SkArenaAlloc fClipAllocator;
     170             : 
     171             :     typedef GrOpList INHERITED;
     172             : };
     173             : 
     174             : #endif

Generated by: LCOV version 1.13