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" |
| 13 | |
| 14 | #include "SkTArray.h" |
| 15 | |
| 16 | class GrAuditTrail; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 17 | class GrGpu; |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 18 | class GrOp; |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 19 | class GrTextureProxy; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 20 | struct SkIPoint; |
| 21 | struct SkIRect; |
| 22 | |
| 23 | class GrTextureOpList final : public GrOpList { |
| 24 | public: |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 25 | GrTextureOpList(GrTextureProxy*, GrGpu*, GrAuditTrail*); |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 26 | |
| 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 | */ |
| 32 | void reset() override; |
| 33 | |
| 34 | void abandonGpuResources() override {} |
| 35 | void freeGpuResources() override {} |
| 36 | |
| 37 | /** |
Brian Salomon | 69868af | 2016-12-22 15:42:51 -0500 | [diff] [blame] | 38 | * Together these two functions flush all queued ops to GrGpuCommandBuffer. The return value |
| 39 | * of executeOps() indicates whether any commands were actually issued to the GPU. |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 40 | */ |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 41 | void prepareOps(GrOpFlushState* flushState) override; |
| 42 | bool executeOps(GrOpFlushState* flushState) override; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Copies a pixel rectangle from one surface to another. This call may finalize |
| 46 | * reserved vertex/index data (as though a draw call was made). The src pixels |
| 47 | * copied are specified by srcRect. They are copied to a rect of the same |
| 48 | * size in dst with top left at dstPoint. If the src rect is clipped by the |
| 49 | * src bounds then pixel values in the dst rect corresponding to area clipped |
| 50 | * by the src rect are not overwritten. This method is not guaranteed to succeed |
| 51 | * depending on the type of surface, configs, etc, and the backend-specific |
| 52 | * limitations. |
| 53 | */ |
| 54 | bool copySurface(GrSurface* dst, |
| 55 | GrSurface* src, |
| 56 | const SkIRect& srcRect, |
| 57 | const SkIPoint& dstPoint); |
| 58 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 59 | GrTextureOpList* asTextureOpList() override { return this; } |
| 60 | |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 61 | SkDEBUGCODE(void dump() const override;) |
| 62 | |
| 63 | private: |
Brian Salomon | 69868af | 2016-12-22 15:42:51 -0500 | [diff] [blame] | 64 | // The unique ID is only needed for the audit trail. This should be removed with MDB. |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 65 | void recordOp(std::unique_ptr<GrOp>, GrGpuResource::UniqueID renderTargetID); |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 66 | |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 67 | SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps; |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 68 | GrGpu* fGpu; |
Brian Osman | 62e7b5f | 2016-10-26 12:02:18 -0400 | [diff] [blame] | 69 | |
| 70 | typedef GrOpList INHERITED; |
| 71 | }; |
| 72 | |
| 73 | #endif |