• 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 "src/gpu/GrSurfaceContext.h"
12 #include "src/gpu/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*,
43                      sk_sp<GrTextureProxy>,
44                      GrColorType,
45                      SkAlphaType,
46                      sk_sp<SkColorSpace>);
47 
48     SkDEBUGCODE(void validate() const override;)
49 
50 private:
51     friend class GrDrawingManager; // for ctor
52 
53     GrOpList* getOpList() override;
54 
55     sk_sp<GrTextureProxy>  fTextureProxy;
56 
57     // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
58     // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
59     sk_sp<GrTextureOpList> fOpList;
60 
61     typedef GrSurfaceContext INHERITED;
62 };
63 
64 #endif
65