2 * Copyright 2016 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "GrTextureOpList.h"
10 #include "GrAuditTrail.h"
12 #include "GrTextureProxy.h"
13 #include "SkStringUtils.h"
14 #include "ops/GrCopySurfaceOp.h"
16 ////////////////////////////////////////////////////////////////////////////////
18 GrTextureOpList::GrTextureOpList(GrTextureProxy* proxy, GrAuditTrail* auditTrail)
19 : INHERITED(proxy, auditTrail) {
22 GrTextureOpList::~GrTextureOpList() {
25 ////////////////////////////////////////////////////////////////////////////////
28 void GrTextureOpList::dump() const {
31 SkDebugf("ops (%d):\n", fRecordedOps.count());
32 for (int i = 0; i < fRecordedOps.count(); ++i) {
33 SkDebugf("*******************************\n");
34 SkDebugf("%d: %s\n", i, fRecordedOps[i]->name());
35 SkString str = fRecordedOps[i]->dumpInfo();
36 SkDebugf("%s\n", str.c_str());
37 const SkRect& clippedBounds = fRecordedOps[i]->bounds();
38 SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
39 clippedBounds.fLeft, clippedBounds.fTop, clippedBounds.fRight,
40 clippedBounds.fBottom);
44 void GrTextureOpList::validateTargetsSingleRenderTarget() const {
45 SkASSERT(1 == fRecordedOps.count() || 0 == fRecordedOps.count());
50 void GrTextureOpList::prepareOps(GrOpFlushState* flushState) {
51 SkASSERT(this->isClosed());
53 // Loop over the ops that haven't yet generated their geometry
54 for (int i = 0; i < fRecordedOps.count(); ++i) {
55 if (fRecordedOps[i]) {
56 // We do not call flushState->setDrawOpArgs as this op list does not support GrDrawOps.
57 fRecordedOps[i]->prepare(flushState);
62 bool GrTextureOpList::executeOps(GrOpFlushState* flushState) {
63 if (0 == fRecordedOps.count()) {
67 for (int i = 0; i < fRecordedOps.count(); ++i) {
68 // We do not call flushState->setDrawOpArgs as this op list does not support GrDrawOps.
69 fRecordedOps[i]->execute(flushState);
75 void GrTextureOpList::reset() {
80 ////////////////////////////////////////////////////////////////////////////////
82 // MDB TODO: fuse with GrRenderTargetOpList::copySurface
83 bool GrTextureOpList::copySurface(GrResourceProvider* resourceProvider,
86 const SkIRect& srcRect,
87 const SkIPoint& dstPoint) {
88 std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(resourceProvider, dst, src, srcRect, dstPoint);
93 this->addDependency(src);
96 // See the comment in GrRenderTargetOpList about why we pass the invalid ID here.
97 this->recordOp(std::move(op),
98 GrGpuResource::UniqueID::InvalidID(),
99 GrSurfaceProxy::UniqueID::InvalidID());
103 void GrTextureOpList::recordOp(std::unique_ptr<GrOp> op,
104 GrGpuResource::UniqueID resourceUniqueID,
105 GrSurfaceProxy::UniqueID proxyUniqueID) {
106 // A closed GrOpList should never receive new/more ops
107 SkASSERT(!this->isClosed());
109 GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), resourceUniqueID, proxyUniqueID);
110 GrOP_INFO("Re-Recording (%s, opID: %u)\n"
111 "\tBounds LRTB (%f, %f, %f, %f)\n",
114 op->bounds().fLeft, op->bounds().fRight,
115 op->bounds().fTop, op->bounds().fBottom);
116 GrOP_INFO(SkTabString(op->dumpInfo(), 1).c_str());
117 GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op.get());
119 fRecordedOps.emplace_back(std::move(op));