blob: 8f1a7f2bf99c68f0d637cc990a002d579c552ab4 [file] [log] [blame]
Brian Osman45580d32016-11-23 09:37:01 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrSurfaceContext.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040012#include "src/gpu/GrTextureProxy.h"
Brian Osman45580d32016-11-23 09:37:01 -050013
14class GrContext;
15class GrDrawingManager;
16class GrSurface;
17class GrTextureOpList;
18class GrTextureProxy;
19struct SkIPoint;
20struct SkIRect;
21
22/**
23 * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
24 * GrTextures and not GrRenderTargets.
25 */
26class SK_API GrTextureContext : public GrSurfaceContext {
27public:
28 ~GrTextureContext() override;
29
Robert Phillipsf200a902017-01-30 13:27:37 -050030 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(); }
Greg Daniele252f082017-10-23 16:05:23 -040035 const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
Robert Phillipsf200a902017-01-30 13:27:37 -050036 sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
37
38 GrRenderTargetProxy* asRenderTargetProxy() override;
39 sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
Robert Phillips27341362016-12-14 08:46:47 -050040
Brian Osman45580d32016-11-23 09:37:01 -050041protected:
Brian Salomond6287472019-06-24 15:50:07 -040042 GrTextureContext(GrRecordingContext*,
43 sk_sp<GrTextureProxy>,
44 GrColorType,
45 SkAlphaType,
46 sk_sp<SkColorSpace>);
Brian Osman45580d32016-11-23 09:37:01 -050047
Robert Phillips2de8cfa2017-06-28 10:33:41 -040048 SkDEBUGCODE(void validate() const override;)
Brian Osman45580d32016-11-23 09:37:01 -050049
50private:
51 friend class GrDrawingManager; // for ctor
52
Robert Phillips2de8cfa2017-06-28 10:33:41 -040053 GrOpList* getOpList() override;
Brian Osman45580d32016-11-23 09:37:01 -050054
Robert Phillips0d075de2019-03-04 11:08:13 -050055 sk_sp<GrTextureProxy> fTextureProxy;
Brian Osman45580d32016-11-23 09:37:01 -050056
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'.
Robert Phillips0d075de2019-03-04 11:08:13 -050059 sk_sp<GrTextureOpList> fOpList;
Robert Phillipse2f7d182016-12-15 09:23:05 -050060
61 typedef GrSurfaceContext INHERITED;
Brian Osman45580d32016-11-23 09:37:01 -050062};
63
64#endif