Add method to GrProgramResource to record that pending a execution was completed.

BUG=skia:2889
R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/543833002
This commit is contained in:
bsalomon 2014-09-04 14:13:44 -07:00 committed by Commit bot
parent 29dfaa80f5
commit ac8d6193ea
5 changed files with 51 additions and 12 deletions

View File

@ -109,8 +109,7 @@ private:
mutable int32_t fPendingReads;
mutable int32_t fPendingWrites;
// These functions need access to the pending read/write member functions.
friend class GrRODrawState;
// This class is used to manage conversion of refs to pending reads/writes.
friend class GrProgramResource;
};

View File

@ -71,13 +71,7 @@ protected:
private:
void convertRefToPendingExecution() const;
void completedExecution() const {
this->validate();
--fPendingExecutions;
if (0 == fRefCnt && 0 == fPendingExecutions) {
SkDELETE(this);
}
}
void completedExecution() const;
mutable int32_t fRefCnt;
// Count of deferred executions not yet issued to the 3D API.

View File

@ -59,7 +59,13 @@ private:
writes to the resource using the program element or draw state. */
void removeRef() const;
friend class GrDrawState;
/** Called to indicate that the previous pending IO is complete. Useful when the owning object
still has refs, so it is not about to destroy this GrProgramResource, but its previously
pending executions have been complete.
*/
void pendingIOComplete() const;
friend class GrRODrawState;
friend class GrProgramElement;
GrGpuResource* fResource;

View File

@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
#include "GrProgramElement.h"
#include "GrProgramResource.h"
@ -28,3 +27,20 @@ void GrProgramElement::convertRefToPendingExecution() const {
}
}
}
void GrProgramElement::completedExecution() const {
this->validate();
--fPendingExecutions;
if (0 == fPendingExecutions) {
if (0 == fRefCnt) {
SkDELETE(this);
} else {
// Now our pending executions have ocurred and we still have refs. Convert
// ownership of our resources back to regular refs.
for (int i = 0; i < fProgramResources.count(); ++i) {
fProgramResources[i]->pendingIOComplete();
}
}
}
}

View File

@ -74,7 +74,7 @@ void GrProgramResource::setResource(GrGpuResource* resource, IOType ioType) {
}
void GrProgramResource::markPendingIO() const {
// This should only be called once, when the owning GrProgramElement gets its first
// This should only be called when the owning GrProgramElement gets its first
// pendingExecution ref.
SkASSERT(!fPendingIO);
SkASSERT(NULL != fResource);
@ -97,6 +97,30 @@ void GrProgramResource::markPendingIO() const {
}
}
void GrProgramResource::pendingIOComplete() const {
// This should only be called when the owner's pending executions have ocurred but it is still
// reffed.
SkASSERT(fOwnRef);
SkASSERT(fPendingIO);
switch (fIOType) {
case kNone_IOType:
SkFAIL("GrProgramResource with neither reads nor writes?");
break;
case kRead_IOType:
fResource->completedRead();
break;
case kWrite_IOType:
fResource->completedWrite();
break;
case kRW_IOType:
fResource->completedRead();
fResource->completedWrite();
break;
}
fPendingIO = false;
}
void GrProgramResource::removeRef() const {
// This should only be called once, when the owners last ref goes away and
// there is a pending execution.