blob: b16246038f9e6bbca8e22374b89420576b0098fa [file] [log] [blame]
Brian Osman62e7b5f2016-10-26 12:02:18 -04001/*
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 GrTexureOpList_DEFINED
9#define GrTexureOpList_DEFINED
10
Brian Salomon69868af2016-12-22 15:42:51 -050011#include "GrGpuResource.h"
Brian Osman62e7b5f2016-10-26 12:02:18 -040012#include "GrOpList.h"
Robert Phillipsf7a72612017-03-31 10:03:45 -040013#include "GrSurfaceProxy.h"
Brian Osman62e7b5f2016-10-26 12:02:18 -040014
15#include "SkTArray.h"
16
17class GrAuditTrail;
Brian Osman62e7b5f2016-10-26 12:02:18 -040018class GrGpu;
Brian Salomon25a88092016-12-01 09:36:50 -050019class GrOp;
Robert Phillipsc7635fa2016-10-28 13:25:24 -040020class GrTextureProxy;
Brian Osman62e7b5f2016-10-26 12:02:18 -040021struct SkIPoint;
22struct SkIRect;
23
24class GrTextureOpList final : public GrOpList {
25public:
Robert Phillips831a2932019-04-12 17:18:39 -040026 GrTextureOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>,
27 sk_sp<GrTextureProxy>, GrAuditTrail*);
Brian Osman62e7b5f2016-10-26 12:02:18 -040028 ~GrTextureOpList() override;
29
30 /**
Brian Salomon69868af2016-12-22 15:42:51 -050031 * Empties the draw buffer of any queued ops.
Brian Osman62e7b5f2016-10-26 12:02:18 -040032 */
Chris Daltona84cacf2017-10-04 10:30:29 -060033 void endFlush() override;
Brian Osman62e7b5f2016-10-26 12:02:18 -040034
Brian Osman62e7b5f2016-10-26 12:02:18 -040035 /**
Brian Salomon69868af2016-12-22 15:42:51 -050036 * Together these two functions flush all queued ops to GrGpuCommandBuffer. The return value
37 * of executeOps() indicates whether any commands were actually issued to the GPU.
Brian Osman62e7b5f2016-10-26 12:02:18 -040038 */
Brian Osman407b3422017-08-22 15:01:32 -040039 void onPrepare(GrOpFlushState* flushState) override;
40 bool onExecute(GrOpFlushState* flushState) override;
Brian Osman62e7b5f2016-10-26 12:02:18 -040041
42 /**
43 * Copies a pixel rectangle from one surface to another. This call may finalize
44 * reserved vertex/index data (as though a draw call was made). The src pixels
45 * copied are specified by srcRect. They are copied to a rect of the same
46 * size in dst with top left at dstPoint. If the src rect is clipped by the
47 * src bounds then pixel values in the dst rect corresponding to area clipped
48 * by the src rect are not overwritten. This method is not guaranteed to succeed
49 * depending on the type of surface, configs, etc, and the backend-specific
50 * limitations.
51 */
Robert Phillipsbe9aff22019-02-15 11:33:22 -050052 bool copySurface(GrRecordingContext*,
Robert Phillipsbf25d432017-04-07 10:08:53 -040053 GrSurfaceProxy* dst,
54 GrSurfaceProxy* src,
Brian Osman62e7b5f2016-10-26 12:02:18 -040055 const SkIRect& srcRect,
Robert Phillips2de8cfa2017-06-28 10:33:41 -040056 const SkIPoint& dstPoint) override;
Brian Osman62e7b5f2016-10-26 12:02:18 -040057
Brian Osman45580d32016-11-23 09:37:01 -050058 GrTextureOpList* asTextureOpList() override { return this; }
59
Robert Phillips27483912018-04-20 12:43:18 -040060 SkDEBUGCODE(void dump(bool printDependencies) const override;)
Brian Osman62e7b5f2016-10-26 12:02:18 -040061
62private:
Robert Phillips9313aa72019-04-09 18:41:27 -040063 bool onIsUsed(GrSurfaceProxy*) const override;
64
Robert Phillipsc994a932018-06-19 13:09:54 -040065 void deleteOp(int index);
66 void deleteOps();
67
Greg Danielaa3dfbe2018-01-29 10:34:25 -050068 void purgeOpsWithUninstantiatedProxies() override;
69
Robert Phillipsd375dbf2017-09-14 12:45:25 -040070 void gatherProxyIntervals(GrResourceAllocator*) const override;
71
Robert Phillips318c4192017-05-17 09:36:38 -040072 void recordOp(std::unique_ptr<GrOp>);
Brian Osman62e7b5f2016-10-26 12:02:18 -040073
Brian Salomon588cec72018-11-14 13:56:37 -050074 // The memory for the ops in 'fOpChains' is actually stored in 'fOpMemoryPool'
Brian Salomonf8334782017-01-03 09:42:58 -050075 SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps;
Brian Osman62e7b5f2016-10-26 12:02:18 -040076
77 typedef GrOpList INHERITED;
78};
79
80#endif