blob: 626c2d345189f0d3eef64f1235236ecf26e96e1f [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;
Brian Osman45580d32016-11-23 09:37:01 -050017class GrTextureProxy;
18struct SkIPoint;
19struct SkIRect;
20
21/**
22 * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
23 * GrTextures and not GrRenderTargets.
24 */
Brian Salomon57f211b2019-08-21 15:21:09 -040025class GrTextureContext : public GrSurfaceContext {
Brian Osman45580d32016-11-23 09:37:01 -050026public:
27 ~GrTextureContext() override;
28
Robert Phillipsf200a902017-01-30 13:27:37 -050029 GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
30 const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
31 sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }
32
33 GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
Greg Daniele252f082017-10-23 16:05:23 -040034 const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
Robert Phillipsf200a902017-01-30 13:27:37 -050035 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:
Brian Salomond6287472019-06-24 15:50:07 -040041 GrTextureContext(GrRecordingContext*,
42 sk_sp<GrTextureProxy>,
43 GrColorType,
44 SkAlphaType,
45 sk_sp<SkColorSpace>);
Brian Osman45580d32016-11-23 09:37:01 -050046
Robert Phillips2de8cfa2017-06-28 10:33:41 -040047 SkDEBUGCODE(void validate() const override;)
Brian Osman45580d32016-11-23 09:37:01 -050048
49private:
50 friend class GrDrawingManager; // for ctor
51
Robert Phillips0d075de2019-03-04 11:08:13 -050052 sk_sp<GrTextureProxy> fTextureProxy;
Brian Osman45580d32016-11-23 09:37:01 -050053
Robert Phillipse2f7d182016-12-15 09:23:05 -050054 typedef GrSurfaceContext INHERITED;
Brian Osman45580d32016-11-23 09:37:01 -050055};
56
57#endif