aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureContext.h
blob: 995ebf53d248ba3b866e4eab39409e44a8bf9a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrTextureContext_DEFINED
#define GrTextureContext_DEFINED

#include "GrSurfaceContext.h"
#include "../private/GrTextureProxy.h"

class GrContext;
class GrDrawingManager;
class GrSurface;
class GrTextureOpList;
class GrTextureProxy;
struct SkIPoint;
struct SkIRect;

/**
 * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
 * GrTextures and not GrRenderTargets.
 */
class SK_API GrTextureContext : public GrSurfaceContext {
public:
    ~GrTextureContext() override;

    GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
    const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
    sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }

    GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
    sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }

    GrRenderTargetProxy* asRenderTargetProxy() override;
    sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;

protected:
    GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
                     sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);

    SkDEBUGCODE(void validate() const;)

private:
    friend class GrDrawingManager; // for ctor

    bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;

    GrTextureOpList* getOpList();

    sk_sp<GrTextureProxy>        fTextureProxy;

    // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
    // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
    GrTextureOpList*             fOpList;

    typedef GrSurfaceContext INHERITED;
};

#endif