Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 1 | /* |
| 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 Salomon | 69868af | 2016-12-22 15:42:51 -0500 | [diff] [blame] | 11 | #include "GrGpuResource.h" |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 12 | #include "GrOpList.h" |
Robert Phillips | f7a7261 | 2017-03-31 10:03:45 -0400 | [diff] [blame] | 13 | #include "GrSurfaceProxy.h" |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 14 | |
| 15 | #include "SkTArray.h" |
| 16 | |
| 17 | class GrAuditTrail; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 18 | class GrGpu; |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 19 | class GrOp; |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 20 | class GrTextureProxy; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 21 | struct SkIPoint; |
| 22 | struct SkIRect; |
| 23 | |
| 24 | class GrTextureOpList final : public GrOpList { |
| 25 | public: |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 26 | GrTextureOpList(GrResourceProvider*, sk_sp<GrOpMemoryPool>, GrTextureProxy*, GrAuditTrail*); |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 27 | ~GrTextureOpList() override; |
| 28 | |
| 29 | /** |
Brian Salomon | 69868af | 2016-12-22 15:42:51 -0500 | [diff] [blame] | 30 | * Empties the draw buffer of any queued ops. |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 31 | */ |
Chris Dalton | a84cacf | 2017-10-04 10:30:29 -0600 | [diff] [blame] | 32 | void endFlush() override; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 33 | |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 34 | /** |
Brian Salomon | 69868af | 2016-12-22 15:42:51 -0500 | [diff] [blame] | 35 | * Together these two functions flush all queued ops to GrGpuCommandBuffer. The return value |
| 36 | * of executeOps() indicates whether any commands were actually issued to the GPU. |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 37 | */ |
Brian Osman | 407b342 | 2017-08-22 15:01:32 -0400 | [diff] [blame] | 38 | void onPrepare(GrOpFlushState* flushState) override; |
| 39 | bool onExecute(GrOpFlushState* flushState) override; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Copies a pixel rectangle from one surface to another. This call may finalize |
| 43 | * reserved vertex/index data (as though a draw call was made). The src pixels |
| 44 | * copied are specified by srcRect. They are copied to a rect of the same |
| 45 | * size in dst with top left at dstPoint. If the src rect is clipped by the |
| 46 | * src bounds then pixel values in the dst rect corresponding to area clipped |
| 47 | * by the src rect are not overwritten. This method is not guaranteed to succeed |
| 48 | * depending on the type of surface, configs, etc, and the backend-specific |
| 49 | * limitations. |
| 50 | */ |
Robert Phillips | be9aff2 | 2019-02-15 11:33:22 -0500 | [diff] [blame] | 51 | bool copySurface(GrRecordingContext*, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 52 | GrSurfaceProxy* dst, |
| 53 | GrSurfaceProxy* src, |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 54 | const SkIRect& srcRect, |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 55 | const SkIPoint& dstPoint) override; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 56 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 57 | GrTextureOpList* asTextureOpList() override { return this; } |
| 58 | |
Robert Phillips | 2748391 | 2018-04-20 12:43:18 -0400 | [diff] [blame] | 59 | SkDEBUGCODE(void dump(bool printDependencies) const override;) |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 60 | |
| 61 | private: |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 62 | void deleteOp(int index); |
| 63 | void deleteOps(); |
| 64 | |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 65 | void purgeOpsWithUninstantiatedProxies() override; |
| 66 | |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 67 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
| 68 | |
Robert Phillips | 318c419 | 2017-05-17 09:36:38 -0400 | [diff] [blame] | 69 | void recordOp(std::unique_ptr<GrOp>); |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 70 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 71 | // The memory for the ops in 'fOpChains' is actually stored in 'fOpMemoryPool' |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 72 | SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 73 | |
| 74 | typedef GrOpList INHERITED; |
| 75 | }; |
| 76 | |
| 77 | #endif |