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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2016 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 GrSurfaceContext_DEFINED
       9             : #define GrSurfaceContext_DEFINED
      10             : 
      11             : #include "../private/GrSurfaceProxy.h"
      12             : 
      13             : #include "SkRefCnt.h"
      14             : 
      15             : class GrAuditTrail;
      16             : class GrContext;
      17             : class GrDrawingManager;
      18             : class GrRenderTargetContext;
      19             : class GrRenderTargetProxy;
      20             : class GrSingleOwner;
      21             : class GrSurface;
      22             : class GrSurfaceContextPriv;
      23             : class GrSurfaceProxy;
      24             : class GrTextureProxy;
      25             : struct SkIPoint;
      26             : struct SkIRect;
      27             : 
      28             : /**
      29             :  * A helper object to orchestrate commands for a particular surface
      30             :  */
      31             : class SK_API GrSurfaceContext : public SkRefCnt {
      32             : public:
      33           0 :     ~GrSurfaceContext() override {}
      34             : 
      35           0 :     SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
      36           0 :     sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
      37           0 :     bool isGammaCorrect() const { return fColorSpace; }
      38             : 
      39             :     // TODO: these two calls would be way cooler if this object had a GrSurfaceProxy pointer
      40             :     int width() const { return this->asSurfaceProxy()->width(); }
      41             :     int height() const { return this->asSurfaceProxy()->height(); }
      42             : 
      43             :     /*
      44             :      * Copy 'src' into the proxy backing this context
      45             :      * @param src       src of pixels
      46             :      * @param srcRect   the subset of 'src' to copy
      47             :      * @param dstPoint  the origin of the 'srcRect' in the destination coordinate space
      48             :      * @return          true if the copy succeeded; false otherwise
      49             :      *
      50             :      * Note: Notionally, 'srcRect' is clipped to 'src's extent with 'dstPoint' being adjusted.
      51             :      *       Then the 'srcRect' offset by 'dstPoint' is clipped against the dst's extent.
      52             :      *       The end result is only valid src pixels and dst pixels will be touched but the copied
      53             :      *       regions will not be shifted.
      54             :      */
      55           0 :     bool copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
      56           0 :         return this->onCopy(src, srcRect, dstPoint);
      57             :     }
      58             : 
      59           0 :     bool copy(GrSurfaceProxy* src) {
      60             :         return this->onCopy(src,
      61           0 :                             SkIRect::MakeWH(src->width(), src->height()),
      62           0 :                             SkIPoint::Make(0, 0));
      63             :     }
      64             : 
      65             :     /**
      66             :      * Reads a rectangle of pixels from the render target context.
      67             :      * @param dstInfo       image info for the destination
      68             :      * @param dstBuffer     destination pixels for the read
      69             :      * @param dstRowBytes   bytes in a row of 'dstBuffer'
      70             :      * @param x             x offset w/in the render target context from which to read
      71             :      * @param y             y offset w/in the render target context from which to read
      72             :      *
      73             :      * @return true if the read succeeded, false if not. The read can fail because of an
      74             :      *              unsupported pixel config.
      75             :      */
      76             :     bool readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes,
      77             :                     int x, int y, uint32_t flags = 0);
      78             : 
      79             :     /**
      80             :      * Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
      81             :      * renderTargetContext at the specified position.
      82             :      * @param srcInfo       image info for the source pixels
      83             :      * @param srcBuffer     source for the write
      84             :      * @param srcRowBytes   bytes in a row of 'srcBuffer'
      85             :      * @param x             x offset w/in the render target context at which to write
      86             :      * @param y             y offset w/in the render target context at which to write
      87             :      *
      88             :      * @return true if the write succeeded, false if not. The write can fail because of an
      89             :      *              unsupported pixel config.
      90             :      */
      91             :     bool writePixels(const SkImageInfo& srcInfo, const void* srcBuffer, size_t srcRowBytes,
      92             :                      int x, int y, uint32_t flags = 0);
      93             : 
      94             :     // TODO: this is virtual b.c. this object doesn't have a pointer to the wrapped GrSurfaceProxy?
      95             :     virtual GrSurfaceProxy* asSurfaceProxy() = 0;
      96             :     virtual const GrSurfaceProxy* asSurfaceProxy() const = 0;
      97             :     virtual sk_sp<GrSurfaceProxy> asSurfaceProxyRef() = 0;
      98             : 
      99             :     virtual GrTextureProxy* asTextureProxy() = 0;
     100             :     virtual sk_sp<GrTextureProxy> asTextureProxyRef() = 0;
     101             : 
     102             :     virtual GrRenderTargetProxy* asRenderTargetProxy() = 0;
     103             :     virtual sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() = 0;
     104             : 
     105           0 :     virtual GrRenderTargetContext* asRenderTargetContext() { return nullptr; }
     106             : 
     107           0 :     GrAuditTrail* auditTrail() { return fAuditTrail; }
     108             : 
     109             :     // Provides access to functions that aren't part of the public API.
     110             :     GrSurfaceContextPriv surfPriv();
     111             :     const GrSurfaceContextPriv surfPriv() const;
     112             : 
     113             : protected:
     114             :     friend class GrSurfaceContextPriv;
     115             : 
     116             :     GrSurfaceContext(GrContext*, GrDrawingManager*,
     117             :                      sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
     118             : 
     119           0 :     GrDrawingManager* drawingManager() { return fDrawingManager; }
     120           0 :     const GrDrawingManager* drawingManager() const { return fDrawingManager; }
     121             : 
     122           0 :     SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; })
     123             : 
     124             :     GrContext*            fContext;
     125             :     sk_sp<SkColorSpace>   fColorSpace;
     126             :     GrAuditTrail*         fAuditTrail;
     127             : 
     128             : private:
     129             :     virtual bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) = 0;
     130             : 
     131             :     GrDrawingManager*     fDrawingManager;
     132             : 
     133             :     // In debug builds we guard against improper thread handling
     134             :     SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
     135             : 
     136             :     typedef SkRefCnt INHERITED;
     137             : };
     138             : 
     139             : #endif

Generated by: LCOV version 1.13