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