• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
asSurfaceProxy()30     GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
asSurfaceProxy()31     const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
asSurfaceProxyRef()32     sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }
33 
asTextureProxy()34     GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
asTextureProxy()35     const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
asTextureProxyRef()36     sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
37 
38     GrRenderTargetProxy* asRenderTargetProxy() override;
39     sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
40 
41 protected:
42     GrTextureContext(GrRecordingContext*, sk_sp<GrTextureProxy>, sk_sp<SkColorSpace>);
43 
44     SkDEBUGCODE(void validate() const override;)
45 
46 private:
47     friend class GrDrawingManager; // for ctor
48 
49     GrOpList* getOpList() override;
50 
51     sk_sp<GrTextureProxy>  fTextureProxy;
52 
53     // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
54     // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
55     sk_sp<GrTextureOpList> fOpList;
56 
57     typedef GrSurfaceContext INHERITED;
58 };
59 
60 #endif
61