Home | History | Annotate | Download | only in gpu
      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 GrTextureContext_DEFINED
      9 #define GrTextureContext_DEFINED
     10 
     11 #include "GrSurfaceContext.h"
     12 #include "../private/GrTextureProxy.h"
     13 
     14 class GrContext;
     15 class GrDrawingManager;
     16 class GrSurface;
     17 class GrTextureOpList;
     18 class GrTextureProxy;
     19 struct SkIPoint;
     20 struct SkIRect;
     21 
     22 /**
     23  * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
     24  * GrTextures and not GrRenderTargets.
     25  */
     26 class SK_API GrTextureContext : public GrSurfaceContext {
     27 public:
     28     ~GrTextureContext() override;
     29 
     30     GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
     31     const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
     32     sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }
     33 
     34     GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
     35     const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
     36     sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
     37 
     38     GrRenderTargetProxy* asRenderTargetProxy() override;
     39     sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
     40 
     41 protected:
     42     GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
     43                      sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
     44 
     45     SkDEBUGCODE(void validate() const override;)
     46 
     47 private:
     48     friend class GrDrawingManager; // for ctor
     49 
     50     GrOpList* getOpList() override;
     51 
     52     sk_sp<GrTextureProxy>        fTextureProxy;
     53 
     54     // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
     55     // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
     56     sk_sp<GrTextureOpList>       fOpList;
     57 
     58     typedef GrSurfaceContext INHERITED;
     59 };
     60 
     61 #endif
     62