blob: b49b27255a1929d0876eedd955addd2175850b46 [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 Phillips27341362016-12-14 08:46:47 -050030 GrSurfaceProxy* asDeferredSurface() override { return fTextureProxy.get(); }
31 GrTextureProxy* asDeferredTexture() override { return fTextureProxy.get(); }
32 GrRenderTargetProxy* asDeferredRenderTarget() override;
33
Brian Osman45580d32016-11-23 09:37:01 -050034protected:
Robert Phillips2c862492017-01-18 10:08:39 -050035 GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
36 sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
Brian Osman45580d32016-11-23 09:37:01 -050037
38 GrDrawingManager* drawingManager() { return fDrawingManager; }
39
40 SkDEBUGCODE(void validate() const;)
41
42private:
43 friend class GrDrawingManager; // for ctor
44
Robert Phillipse2f7d182016-12-15 09:23:05 -050045 bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
Robert Phillips2c862492017-01-18 10:08:39 -050046 bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
47 size_t dstRowBytes, int x, int y) override;
48 bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
49 size_t srcRowBytes, int x, int y) override;
Robert Phillipse2f7d182016-12-15 09:23:05 -050050
Brian Osman45580d32016-11-23 09:37:01 -050051 GrTextureOpList* getOpList();
52
53 GrDrawingManager* fDrawingManager;
54 sk_sp<GrTextureProxy> fTextureProxy;
55
56 // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
57 // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
58 GrTextureOpList* fOpList;
Robert Phillipse2f7d182016-12-15 09:23:05 -050059
60 typedef GrSurfaceContext INHERITED;
Brian Osman45580d32016-11-23 09:37:01 -050061};
62
63#endif