blob: f59ab1a2cfca67499a23a6d08783296792be73dd [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
11#include "GrSurfaceContext.h"
12#include "../private/GrTextureProxy.h"
13
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(); }
35 sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
36
37 GrRenderTargetProxy* asRenderTargetProxy() override;
38 sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
Robert Phillips27341362016-12-14 08:46:47 -050039
Brian Osman45580d32016-11-23 09:37:01 -050040protected:
Robert Phillips2c862492017-01-18 10:08:39 -050041 GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
42 sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
Brian Osman45580d32016-11-23 09:37:01 -050043
Robert Phillips2de8cfa2017-06-28 10:33:41 -040044 SkDEBUGCODE(void validate() const override;)
Brian Osman45580d32016-11-23 09:37:01 -050045
46private:
47 friend class GrDrawingManager; // for ctor
48
Robert Phillips2de8cfa2017-06-28 10:33:41 -040049 GrOpList* getOpList() override;
Brian Osman45580d32016-11-23 09:37:01 -050050
Brian Osman45580d32016-11-23 09:37:01 -050051 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'.
Robert Phillipsdc83b892017-04-13 12:23:54 -040055 sk_sp<GrTextureOpList> fOpList;
Robert Phillipse2f7d182016-12-15 09:23:05 -050056
57 typedef GrSurfaceContext INHERITED;
Brian Osman45580d32016-11-23 09:37:01 -050058};
59
60#endif