2016-11-23 14:37:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GrTextureContext.h"
|
2017-03-30 12:02:11 +00:00
|
|
|
|
|
|
|
#include "GrContextPriv.h"
|
2016-11-23 14:37:01 +00:00
|
|
|
#include "GrDrawingManager.h"
|
|
|
|
#include "GrTextureOpList.h"
|
|
|
|
|
|
|
|
#include "../private/GrAuditTrail.h"
|
|
|
|
|
|
|
|
#define ASSERT_SINGLE_OWNER \
|
2017-04-10 12:19:26 +00:00
|
|
|
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
|
2017-01-25 22:31:35 +00:00
|
|
|
#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
|
2016-11-23 14:37:01 +00:00
|
|
|
|
|
|
|
GrTextureContext::GrTextureContext(GrContext* context,
|
|
|
|
GrDrawingManager* drawingMgr,
|
|
|
|
sk_sp<GrTextureProxy> textureProxy,
|
2017-01-18 15:08:39 +00:00
|
|
|
sk_sp<SkColorSpace> colorSpace,
|
2016-11-23 14:37:01 +00:00
|
|
|
GrAuditTrail* auditTrail,
|
|
|
|
GrSingleOwner* singleOwner)
|
2017-10-24 16:52:33 +00:00
|
|
|
: GrSurfaceContext(context, drawingMgr, textureProxy->config(), std::move(colorSpace),
|
|
|
|
auditTrail, singleOwner)
|
|
|
|
, fTextureProxy(std::move(textureProxy))
|
|
|
|
, fOpList(sk_ref_sp(fTextureProxy->getLastTextureOpList())) {
|
2016-11-23 14:37:01 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
void GrTextureContext::validate() const {
|
|
|
|
SkASSERT(fTextureProxy);
|
|
|
|
fTextureProxy->validate(fContext);
|
|
|
|
|
|
|
|
if (fOpList && !fOpList->isClosed()) {
|
2017-04-13 16:23:54 +00:00
|
|
|
SkASSERT(fTextureProxy->getLastOpList() == fOpList.get());
|
2016-11-23 14:37:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GrTextureContext::~GrTextureContext() {
|
|
|
|
ASSERT_SINGLE_OWNER
|
|
|
|
}
|
|
|
|
|
2017-01-30 18:27:37 +00:00
|
|
|
GrRenderTargetProxy* GrTextureContext::asRenderTargetProxy() {
|
|
|
|
// If the proxy can return an RTProxy it should've been wrapped in a RTContext
|
|
|
|
SkASSERT(!fTextureProxy->asRenderTargetProxy());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
sk_sp<GrRenderTargetProxy> GrTextureContext::asRenderTargetProxyRef() {
|
2016-12-14 13:46:47 +00:00
|
|
|
// If the proxy can return an RTProxy it should've been wrapped in a RTContext
|
|
|
|
SkASSERT(!fTextureProxy->asRenderTargetProxy());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-06-28 14:33:41 +00:00
|
|
|
GrOpList* GrTextureContext::getOpList() {
|
2016-11-23 14:37:01 +00:00
|
|
|
ASSERT_SINGLE_OWNER
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
|
|
|
|
if (!fOpList || fOpList->isClosed()) {
|
2017-05-11 18:14:30 +00:00
|
|
|
fOpList = this->drawingManager()->newTextureOpList(fTextureProxy.get());
|
2016-11-23 14:37:01 +00:00
|
|
|
}
|
|
|
|
|
2017-04-13 16:23:54 +00:00
|
|
|
return fOpList.get();
|
2016-11-23 14:37:01 +00:00
|
|
|
}
|