Add factories to GrSurfaceContext and clean up creation flow.
This CL updates all callers that ending up in GrDrawingManager::makeSurfaceContext to use the new factory or directly call ctors. A follow on change will get the rest of the calls which go to GrDrawingManager::makeRenderTargetContext Change-Id: I662da654a1ec8b8972c50fe9ce45a9185d4c3dc1 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260901 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
2702dc77e0
commit
bfa19c4e76
@ -86,25 +86,6 @@ protected:
|
||||
*/
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
/** Create a new surface context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrSurfaceContext> makeDeferredSurfaceContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
GrMipMapped = GrMipMapped::kNo,
|
||||
GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
|
||||
SkBudgeted = SkBudgeted::kYes,
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
/*
|
||||
* Create a new render target context backed by a deferred-style
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
|
@ -185,13 +185,17 @@ bool SkDeferredDisplayListRecorder::init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto c = fContext->priv().makeWrappedSurfaceContext(std::move(proxy),
|
||||
grColorType,
|
||||
kPremul_SkAlphaType,
|
||||
fCharacterization.refColorSpace(),
|
||||
&fCharacterization.surfaceProps());
|
||||
SkASSERT(c->asRenderTargetContext());
|
||||
std::unique_ptr<GrRenderTargetContext> rtc(c.release()->asRenderTargetContext());
|
||||
const GrSwizzle& readSwizzle = caps->getReadSwizzle(fCharacterization.backendFormat(),
|
||||
grColorType);
|
||||
const GrSwizzle& outputSwizzle = caps->getOutputSwizzle(fCharacterization.backendFormat(),
|
||||
grColorType);
|
||||
SkASSERT(readSwizzle == proxy->textureSwizzle());
|
||||
|
||||
auto rtc = std::make_unique<GrRenderTargetContext>(fContext.get(), std::move(proxy),
|
||||
grColorType, fCharacterization.origin(),
|
||||
readSwizzle, outputSwizzle,
|
||||
fCharacterization.refColorSpace(),
|
||||
&fCharacterization.surfaceProps());
|
||||
fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(), std::move(rtc));
|
||||
return SkToBool(fSurface.get());
|
||||
}
|
||||
|
@ -451,8 +451,8 @@ public:
|
||||
if (!rec) {
|
||||
return false;
|
||||
}
|
||||
auto sContext = fContext->priv().makeWrappedSurfaceContext(fTextureProxy, fColorType,
|
||||
this->alphaType(), fColorSpace);
|
||||
auto sContext = GrSurfaceContext::Make(fContext, fTextureProxy, fColorType,
|
||||
this->alphaType(), fColorSpace);
|
||||
if (!sContext) {
|
||||
return false;
|
||||
}
|
||||
|
@ -40,32 +40,6 @@ void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBO
|
||||
fContext->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
return fContext->makeDeferredSurfaceContext(fit, width, height, colorType, alphaType,
|
||||
std::move(colorSpace), mipMapped, origin, budgeted,
|
||||
isProtected);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
@ -93,24 +67,6 @@ std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetCo
|
||||
surfaceProps, budgeted, isProtected);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrContextPriv::makeBackendTextureContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(
|
||||
tex, colorType, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this->drawingManager()->makeSurfaceContext(std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
|
@ -67,25 +67,6 @@ public:
|
||||
*/
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
/** Create a new texture context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrSurfaceContext> makeDeferredSurfaceContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
GrMipMapped = GrMipMapped::kNo,
|
||||
GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
|
||||
SkBudgeted = SkBudgeted::kYes,
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
/*
|
||||
* Create a new render target context backed by a deferred-style
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
@ -130,12 +111,6 @@ public:
|
||||
*/
|
||||
static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&);
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> makeBackendTextureContext(const GrBackendTexture&,
|
||||
GrSurfaceOrigin,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
||||
// These match the definitions in SkSurface & GrSurface.h, for whence they came
|
||||
typedef void* ReleaseContext;
|
||||
typedef void (*ReleaseProc)(ReleaseContext);
|
||||
|
@ -941,22 +941,3 @@ std::unique_ptr<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext
|
||||
managedOpsTask));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrDrawingManager::makeSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> sProxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
if (this->wasAbandoned() || !sProxy->asTextureProxy()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// GrTextureRenderTargets should always be using a GrRenderTargetContext
|
||||
SkASSERT(!sProxy->asRenderTargetProxy());
|
||||
|
||||
GrSurfaceOrigin origin = sProxy->origin();
|
||||
GrSwizzle readSwizzle = sProxy->textureSwizzle();
|
||||
|
||||
return std::unique_ptr<GrSurfaceContext>(new GrSurfaceContext(
|
||||
fContext, std::move(sProxy), colorType, alphaType, std::move(colorSpace), origin,
|
||||
readSwizzle));
|
||||
}
|
||||
|
@ -42,10 +42,6 @@ public:
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps*,
|
||||
bool managedOpsTask = true);
|
||||
std::unique_ptr<GrSurfaceContext> makeSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
||||
// A managed opsTask is controlled by the drawing manager (i.e., sorted & flushed with the
|
||||
// others). An unmanaged one is created and used by the onFlushCallback.
|
||||
|
@ -159,65 +159,6 @@ void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlu
|
||||
this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
|
||||
SkASSERT(proxy);
|
||||
|
||||
if (proxy->asRenderTargetProxy()) {
|
||||
SkASSERT(kPremul_SkAlphaType == alphaType || kOpaque_SkAlphaType == alphaType);
|
||||
return this->drawingManager()->makeRenderTargetContext(std::move(proxy), colorType,
|
||||
std::move(colorSpace), props);
|
||||
} else {
|
||||
SkASSERT(proxy->asTextureProxy());
|
||||
SkASSERT(!props);
|
||||
return this->drawingManager()->makeSurfaceContext(std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContext::makeDeferredSurfaceContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
auto format = this->caps()->getDefaultBackendFormat(colorType, GrRenderable::kNo);
|
||||
if (!format.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto config = this->caps()->getConfigFromBackendFormat(format, colorType);
|
||||
if (config == kUnknown_GrPixelConfig) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fWidth = width;
|
||||
desc.fHeight = height;
|
||||
desc.fConfig = config;
|
||||
|
||||
sk_sp<GrTextureProxy> texture = this->proxyProvider()->createProxy(
|
||||
format, desc, GrRenderable::kNo, 1, origin, mipMapped, fit, budgeted, isProtected);
|
||||
if (!texture) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto drawingManager = this->drawingManager();
|
||||
|
||||
return drawingManager->makeSurfaceContext(std::move(texture), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
@ -330,32 +271,6 @@ void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* o
|
||||
fContext->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeDeferredSurfaceContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
return fContext->makeDeferredSurfaceContext(fit, width, height, colorType, alphaType,
|
||||
std::move(colorSpace), mipMapped, origin, budgeted,
|
||||
isProtected);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
|
@ -66,25 +66,6 @@ public:
|
||||
*/
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
/** Create a new texture context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrSurfaceContext> makeDeferredSurfaceContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
GrMipMapped = GrMipMapped::kNo,
|
||||
GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
|
||||
SkBudgeted = SkBudgeted::kYes,
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
/*
|
||||
* Create a new render target context backed by a deferred-style
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
|
@ -145,13 +145,13 @@ GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
|
||||
sk_sp<GrRenderTargetProxy> rtp,
|
||||
GrColorType colorType,
|
||||
GrSurfaceOrigin origin,
|
||||
GrSwizzle texSwizzle,
|
||||
GrSwizzle readSwizzle,
|
||||
GrSwizzle outSwizzle,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
bool managedOpsTask)
|
||||
: GrSurfaceContext(context, std::move(rtp), colorType, kPremul_SkAlphaType,
|
||||
std::move(colorSpace), origin, texSwizzle)
|
||||
std::move(colorSpace), origin, readSwizzle)
|
||||
, fOutputSwizzle(outSwizzle)
|
||||
, fOpsTask(sk_ref_sp(fSurfaceProxy->getLastOpsTask()))
|
||||
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
|
||||
|
@ -27,7 +27,6 @@ class GrBackendSemaphore;
|
||||
class GrClip;
|
||||
class GrColorSpaceXform;
|
||||
class GrCoverageCountingPathRenderer;
|
||||
class GrDrawingManager;
|
||||
class GrDrawOp;
|
||||
class GrFixedClip;
|
||||
class GrOp;
|
||||
@ -58,6 +57,10 @@ class SkVertices;
|
||||
*/
|
||||
class GrRenderTargetContext : public GrSurfaceContext {
|
||||
public:
|
||||
GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>, GrColorType,
|
||||
GrSurfaceOrigin, GrSwizzle readSwizzle, GrSwizzle outSwizzle,
|
||||
sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true);
|
||||
|
||||
~GrRenderTargetContext() override;
|
||||
|
||||
virtual void drawGlyphRunList(const GrClip&, const SkMatrix& viewMatrix, const SkGlyphRunList&);
|
||||
@ -523,7 +526,6 @@ private:
|
||||
friend class GrClipStackClip; // for access to getOpsTask
|
||||
friend class GrOnFlushResourceProvider; // for access to getOpsTask (http://skbug.com/9357)
|
||||
|
||||
friend class GrDrawingManager; // for ctor
|
||||
friend class GrRenderTargetContextPriv;
|
||||
|
||||
// All the path renderers currently make their own ops
|
||||
@ -541,10 +543,6 @@ private:
|
||||
friend class GrFillRectOp; // for access to addDrawOp
|
||||
friend class GrTextureOp; // for access to addDrawOp
|
||||
|
||||
GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>, GrColorType,
|
||||
GrSurfaceOrigin, GrSwizzle texSwizzle, GrSwizzle outSwizzle,
|
||||
sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true);
|
||||
|
||||
SkDEBUGCODE(void onValidate() const override;)
|
||||
|
||||
|
||||
|
@ -27,6 +27,61 @@
|
||||
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
|
||||
#define RETURN_FALSE_IF_ABANDONED if (this->fContext->priv().abandoned()) { return false; }
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
SkASSERT(proxy && proxy->asTextureProxy());
|
||||
|
||||
// TODO: These should be passed in directly or as GrSurfaceProxyView
|
||||
GrSurfaceOrigin origin = proxy->origin();
|
||||
GrSwizzle readSwizzle = proxy->textureSwizzle();
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> surfaceContext;
|
||||
if (GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy()) {
|
||||
SkASSERT(kPremul_SkAlphaType == alphaType || kOpaque_SkAlphaType == alphaType);
|
||||
// Will we ever want a swizzle that is not the default output swizzle for the format and
|
||||
// colorType here? If so we will need to manually pass that in.
|
||||
GrSwizzle outSwizzle = context->priv().caps()->getOutputSwizzle(proxy->backendFormat(),
|
||||
colorType);
|
||||
surfaceContext.reset(new GrRenderTargetContext(context, sk_ref_sp(rtProxy), colorType,
|
||||
origin, readSwizzle, outSwizzle,
|
||||
std::move(colorSpace), nullptr));
|
||||
} else {
|
||||
surfaceContext.reset(new GrSurfaceContext(context, std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace), origin, readSwizzle));
|
||||
}
|
||||
return surfaceContext;
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(
|
||||
GrRecordingContext* context, const SkISize& dimensions, const GrBackendFormat& format,
|
||||
GrRenderable renderable, int renderTargetSampleCnt, GrMipMapped mipMapped,
|
||||
GrProtected isProtected, GrSurfaceOrigin origin, GrColorType colorType,
|
||||
SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace, SkBackingFit fit,
|
||||
SkBudgeted budgeted) {
|
||||
auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType);
|
||||
if (config == kUnknown_GrPixelConfig) {
|
||||
return nullptr;
|
||||
}
|
||||
GrSurfaceDesc desc;
|
||||
desc.fWidth = dimensions.width();
|
||||
desc.fHeight = dimensions.height();
|
||||
desc.fConfig = config;
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(
|
||||
format, desc, renderable, renderTargetSampleCnt, origin, mipMapped, fit, budgeted,
|
||||
isProtected);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrSurfaceContext::Make(context, std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
|
||||
// In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress
|
||||
// GrOpsTasks to be picked up and added to by renderTargetContexts lower in the call
|
||||
// stack. When this occurs with a closed GrOpsTask, a new one will be allocated
|
||||
@ -291,6 +346,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
|
||||
|
||||
GrBackendFormat format;
|
||||
SkAlphaType alphaType;
|
||||
GrSwizzle tempReadSwizzle;
|
||||
if (canvas2DFastPath) {
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
colorType = GrColorType::kRGBA_8888;
|
||||
@ -304,6 +360,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
|
||||
return false;
|
||||
}
|
||||
alphaType = this->colorInfo().alphaType();
|
||||
tempReadSwizzle = this->readSwizzle();
|
||||
}
|
||||
|
||||
// It is more efficient for us to write pixels into a top left origin so we prefer that.
|
||||
@ -316,15 +373,12 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
|
||||
auto tempProxy = direct->priv().proxyProvider()->createProxy(
|
||||
format, desc, GrRenderable::kNo, 1, tempOrigin, GrMipMapped::kNo,
|
||||
SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
|
||||
|
||||
if (!tempProxy) {
|
||||
return false;
|
||||
}
|
||||
auto tempCtx = direct->priv().drawingManager()->makeSurfaceContext(
|
||||
tempProxy, colorType, alphaType, this->colorInfo().refColorSpace());
|
||||
if (!tempCtx) {
|
||||
return false;
|
||||
}
|
||||
SkASSERT(tempProxy->textureSwizzle() == tempReadSwizzle);
|
||||
GrSurfaceContext tempCtx(direct, tempProxy, colorType, alphaType,
|
||||
this->colorInfo().refColorSpace(), tempOrigin, tempReadSwizzle);
|
||||
|
||||
// In the fast path we always write the srcData to the temp context as though it were RGBA.
|
||||
// When the data is really BGRA the write will cause the R and B channels to be swapped in
|
||||
@ -333,7 +387,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
|
||||
if (canvas2DFastPath) {
|
||||
srcInfo = srcInfo.makeColorType(GrColorType::kRGBA_8888);
|
||||
}
|
||||
if (!tempCtx->writePixels(srcInfo, src, rowBytes, {0, 0}, direct)) {
|
||||
if (!tempCtx.writePixels(srcInfo, src, rowBytes, {0, 0}, direct)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,23 @@ struct SkIRect;
|
||||
*/
|
||||
class GrSurfaceContext {
|
||||
public:
|
||||
// If the passed in GrSurfaceProxy is renderable this will return a GrRenderTargetContext,
|
||||
// otherwise it will return a GrSurfaceContext.
|
||||
static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, sk_sp<GrSurfaceProxy>,
|
||||
GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
|
||||
|
||||
static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, const SkISize& dimensions,
|
||||
const GrBackendFormat&, GrRenderable,
|
||||
int renderTargetSampleCnt, GrMipMapped,
|
||||
GrProtected, GrSurfaceOrigin, GrColorType,
|
||||
SkAlphaType, sk_sp<SkColorSpace>, SkBackingFit,
|
||||
SkBudgeted);
|
||||
|
||||
// If it is known that the GrSurfaceProxy is not renderable, you can directly call the the ctor
|
||||
// here to make a GrSurfaceContext on the stack.
|
||||
GrSurfaceContext(GrRecordingContext*, sk_sp<GrSurfaceProxy>, GrColorType, SkAlphaType,
|
||||
sk_sp<SkColorSpace>, GrSurfaceOrigin, GrSwizzle readSwizzle);
|
||||
|
||||
virtual ~GrSurfaceContext() = default;
|
||||
|
||||
const GrColorInfo& colorInfo() const { return fColorInfo; }
|
||||
@ -113,10 +130,6 @@ public:
|
||||
|
||||
protected:
|
||||
friend class GrSurfaceContextPriv;
|
||||
friend class GrDrawingManager; // For ctor
|
||||
|
||||
GrSurfaceContext(GrRecordingContext*, sk_sp<GrSurfaceProxy>, GrColorType, SkAlphaType,
|
||||
sk_sp<SkColorSpace>, GrSurfaceOrigin, GrSwizzle readSwizzle);
|
||||
|
||||
GrDrawingManager* drawingManager();
|
||||
const GrDrawingManager* drawingManager() const;
|
||||
|
@ -308,14 +308,24 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
auto colorType = GrPixelConfigToColorType(src->config());
|
||||
auto format = src->backendFormat().makeTexture2D();
|
||||
SkASSERT(format.isValid());
|
||||
auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType);
|
||||
if (config == kUnknown_GrPixelConfig) {
|
||||
return nullptr;
|
||||
}
|
||||
GrSurfaceDesc desc;
|
||||
desc.fWidth = width;
|
||||
desc.fHeight = height;
|
||||
desc.fConfig = config;
|
||||
|
||||
GrSurfaceOrigin origin = src->origin();
|
||||
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
|
||||
auto dstContext = context->priv().makeDeferredSurfaceContext(
|
||||
fit, width, height, colorType, kUnknown_SkAlphaType, nullptr, mipMapped,
|
||||
src->origin(), budgeted, isProtected);
|
||||
if (!dstContext) {
|
||||
return nullptr;
|
||||
}
|
||||
if (dstContext->copy(src, srcRect, dstPoint)) {
|
||||
auto dstContext = GrSurfaceContext::Make(context, {width, height}, format,
|
||||
GrRenderable::kNo, 1, mipMapped, isProtected,
|
||||
origin, colorType, kUnknown_SkAlphaType, nullptr,
|
||||
fit, budgeted);
|
||||
if (dstContext && dstContext->copy(src, srcRect, dstPoint)) {
|
||||
return dstContext->asTextureProxyRef();
|
||||
}
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, GrColorType
|
||||
return false;
|
||||
}
|
||||
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(sk_ref_sp(sProxy), colorType,
|
||||
kUnknown_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, sk_ref_sp(sProxy), colorType,
|
||||
kUnknown_SkAlphaType, nullptr);
|
||||
if (!sContext || !sContext->asTextureProxy()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -637,20 +637,17 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto surfaceContext =
|
||||
drawingManager->makeSurfaceContext(proxy, SkColorTypeToGrColorType(pixmap.colorType()),
|
||||
pixmap.alphaType(), cs);
|
||||
if (!surfaceContext) {
|
||||
return nullptr;
|
||||
}
|
||||
GrSurfaceContext surfaceContext(context, std::move(proxy),
|
||||
SkColorTypeToGrColorType(pixmap.colorType()),
|
||||
pixmap.alphaType(), cs, surfaceOrigin, swizzle);
|
||||
|
||||
SkImageInfo srcInfo = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, at,
|
||||
std::move(cs));
|
||||
surfaceContext->writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
|
||||
surfaceContext.writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
|
||||
|
||||
GrFlushInfo info;
|
||||
info.fFlags = kSyncCpu_GrFlushFlag;
|
||||
GrSurfaceProxy* p[1] = {proxy.get()};
|
||||
GrSurfaceProxy* p[1] = {surfaceContext.asSurfaceProxy()};
|
||||
drawingManager->flush(p, 1, SkSurface::BackendSurfaceAccess::kNoAccess, info,
|
||||
GrPrepareForExternalIORequests());
|
||||
|
||||
|
@ -119,8 +119,8 @@ bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
|
||||
this->colorType(),
|
||||
texProxy->backendFormat());
|
||||
|
||||
auto sContext = direct->priv().makeWrappedSurfaceContext(
|
||||
std::move(texProxy), grColorType, this->alphaType(), this->refColorSpace());
|
||||
auto sContext = GrSurfaceContext::Make(direct, std::move(texProxy), grColorType,
|
||||
this->alphaType(), this->refColorSpace());
|
||||
if (!sContext) {
|
||||
return false;
|
||||
}
|
||||
@ -180,8 +180,8 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels,
|
||||
this->colorType(),
|
||||
texProxy->backendFormat());
|
||||
|
||||
auto sContext = direct->priv().makeWrappedSurfaceContext(
|
||||
std::move(texProxy), grColorType, this->alphaType(), this->refColorSpace());
|
||||
auto sContext = GrSurfaceContext::Make(direct, std::move(texProxy), grColorType,
|
||||
this->alphaType(), this->refColorSpace());
|
||||
if (!sContext) {
|
||||
return false;
|
||||
}
|
||||
|
@ -97,13 +97,15 @@ sk_sp<SkSurface> SkSurface::MakeFromCAMetalLayer(GrContext* context,
|
||||
false,
|
||||
GrSurfaceProxy::UseAllocator::kYes);
|
||||
|
||||
auto c = context->priv().makeWrappedSurfaceContext(std::move(proxy),
|
||||
grColorType,
|
||||
kPremul_SkAlphaType,
|
||||
colorSpace,
|
||||
surfaceProps);
|
||||
SkASSERT(c->asRenderTargetContext());
|
||||
std::unique_ptr<GrRenderTargetContext> rtc(c.release()->asRenderTargetContext());
|
||||
const GrSwizzle& readSwizzle = caps->getReadSwizzle(backendFormat, grColorType);
|
||||
const GrSwizzle& outputSwizzle = caps->getOutputSwizzle(backendFormat, grColorType);
|
||||
|
||||
SkASSERT(readSwizzle == proxy->textureSwizzle());
|
||||
|
||||
auto rtc = std::make_unique<GrRenderTargetContext>(context, std::move(proxy),
|
||||
grColorType, origin,
|
||||
readSwizzle, outputSwizzle,
|
||||
colorSpace, surfaceProps);
|
||||
|
||||
sk_sp<SkSurface> surface = SkSurface_Gpu::MakeWrappedRenderTarget(context, std::move(rtc));
|
||||
return surface;
|
||||
|
@ -105,10 +105,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType());
|
||||
auto dstContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(dst),
|
||||
grColorType,
|
||||
ii.alphaType());
|
||||
auto dstContext = GrSurfaceContext::Make(context, std::move(dst),
|
||||
grColorType,
|
||||
ii.alphaType(), nullptr);
|
||||
|
||||
bool result = false;
|
||||
if (sOrigin == dOrigin) {
|
||||
|
@ -155,11 +155,21 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
// Wrap this texture ID in a GrTexture
|
||||
GrBackendTexture backendTex(kSize, kSize, GrMipMapped::kNo, externalTexture);
|
||||
|
||||
GrColorType colorType = GrColorType::kRGBA_8888;
|
||||
SkAlphaType alphaType = kPremul_SkAlphaType;
|
||||
// TODO: If I make this TopLeft origin to match resolve_origin calls for kDefault, this test
|
||||
// fails on the Nexus5. Why?
|
||||
auto surfaceContext = context0->priv().makeBackendTextureContext(
|
||||
backendTex, kBottomLeft_GrSurfaceOrigin, GrColorType::kRGBA_8888, kPremul_SkAlphaType,
|
||||
nullptr);
|
||||
GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin;
|
||||
sk_sp<GrSurfaceProxy> texProxy = context0->priv().proxyProvider()->wrapBackendTexture(
|
||||
backendTex, colorType, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRW_GrIOType);
|
||||
if (!texProxy) {
|
||||
ERRORF(reporter, "Error wrapping external texture in GrTextureProxy.");
|
||||
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
|
||||
return;
|
||||
}
|
||||
auto surfaceContext = GrSurfaceContext::Make(context0, std::move(texProxy), colorType,
|
||||
alphaType, nullptr);
|
||||
|
||||
if (!surfaceContext) {
|
||||
ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext.");
|
||||
@ -180,7 +190,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
// Should not be able to wrap as a RT
|
||||
{
|
||||
auto temp = context0->priv().makeBackendTextureRenderTargetContext(
|
||||
backendTex, kBottomLeft_GrSurfaceOrigin, 1, GrColorType::kRGBA_8888, nullptr);
|
||||
backendTex, origin, 1, colorType, nullptr);
|
||||
if (temp) {
|
||||
ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT.");
|
||||
}
|
||||
@ -194,7 +204,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
// Only test RT-config
|
||||
// TODO: why do we always need to draw to copy from an external texture?
|
||||
TestCopyFromSurface(reporter, context0, surfaceContext->asSurfaceProxy(),
|
||||
GrColorType::kRGBA_8888, pixels.get(), "EGLImageTest-copy");
|
||||
colorType, pixels.get(), "EGLImageTest-copy");
|
||||
|
||||
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context, T min, T max, T
|
||||
continue;
|
||||
}
|
||||
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(std::move(fpProxy), colorType,
|
||||
kPremul_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, std::move(fpProxy), colorType,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
REPORTER_ASSERT(reporter, sContext);
|
||||
|
||||
bool result = sContext->readPixels({colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
|
||||
|
@ -303,8 +303,9 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
{kSize, kSize}, combo.fColorType, combo.fFormat, renderable, 1,
|
||||
kTopLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes, GrProtected::kNo);
|
||||
if (proxy) {
|
||||
auto texCtx = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), combo.fColorType, kPremul_SkAlphaType);
|
||||
auto texCtx = GrSurfaceContext::Make(context, std::move(proxy),
|
||||
combo.fColorType,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
|
||||
readback.erase(kClearColor);
|
||||
if (texCtx->readPixels(readback.info(), readback.writable_addr(),
|
||||
@ -328,10 +329,11 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
fit, desc.fWidth, desc.fHeight, combo.fColorType, nullptr,
|
||||
1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr);
|
||||
} else {
|
||||
surfCtx = context->priv().makeDeferredSurfaceContext(
|
||||
fit, desc.fWidth, desc.fHeight, combo.fColorType,
|
||||
kUnknown_SkAlphaType, nullptr, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
surfCtx = GrSurfaceContext::Make(
|
||||
context, {desc.fWidth, desc.fHeight}, combo.fFormat,
|
||||
GrRenderable::kNo, 1, GrMipMapped::kNo, GrProtected::kNo,
|
||||
kTopLeft_GrSurfaceOrigin, combo.fColorType,
|
||||
kUnknown_SkAlphaType, nullptr, fit, SkBudgeted::kYes);
|
||||
}
|
||||
if (!surfCtx) {
|
||||
continue;
|
||||
@ -398,8 +400,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo, ioType);
|
||||
auto surfContext = context->priv().makeWrappedSurfaceContext(proxy, GrColorType::kRGBA_8888,
|
||||
kPremul_SkAlphaType);
|
||||
auto surfContext = GrSurfaceContext::Make(context, proxy, GrColorType::kRGBA_8888,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
|
||||
// Read pixels should work with a read-only texture.
|
||||
{
|
||||
|
@ -72,8 +72,8 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
|
||||
}
|
||||
REPORTER_ASSERT(reporter, wrappedProxy);
|
||||
|
||||
auto surfaceContext = context->priv().makeWrappedSurfaceContext(std::move(wrappedProxy), grCT,
|
||||
kPremul_SkAlphaType);
|
||||
auto surfaceContext = GrSurfaceContext::Make(context, std::move(wrappedProxy), grCT,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
REPORTER_ASSERT(reporter, surfaceContext);
|
||||
|
||||
bool result = surfaceContext->readPixels({grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight},
|
||||
|
@ -35,8 +35,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
|
||||
{grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (proxy) {
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
proxy, SkColorTypeToGrColorType(ct), kPremul_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, proxy, SkColorTypeToGrColorType(ct),
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
|
||||
|
||||
@ -62,8 +62,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
|
||||
{grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (proxy) {
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
proxy, SkColorTypeToGrColorType(ct), kPremul_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, proxy, SkColorTypeToGrColorType(ct),
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
|
||||
|
||||
|
@ -120,10 +120,13 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context, int array
|
||||
controlPixelData.begin(), 0);
|
||||
SkASSERT(proxy);
|
||||
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(std::move(proxy), grColorType,
|
||||
kPremul_SkAlphaType);
|
||||
GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
|
||||
grColorType);
|
||||
|
||||
if (!sContext->readPixels(dstInfo, readBuffer.begin(), 0, {0, 0})) {
|
||||
GrSurfaceContext sContext(context, std::move(proxy), grColorType, kPremul_SkAlphaType,
|
||||
nullptr, origin, readSwizzle);
|
||||
|
||||
if (!sContext.readPixels(dstInfo, readBuffer.begin(), 0, {0, 0})) {
|
||||
// We only require this to succeed if the format is renderable.
|
||||
REPORTER_ASSERT(reporter, !context->colorTypeSupportedAsSurface(colorType));
|
||||
return;
|
||||
|
@ -338,8 +338,8 @@ bool log_pixels(GrColor* pixels, int widthHeight, SkString* dst) {
|
||||
}
|
||||
|
||||
bool log_texture_proxy(GrContext* context, sk_sp<GrTextureProxy> src, SkString* dst) {
|
||||
auto sContext =
|
||||
context->priv().makeWrappedSurfaceContext(src, GrColorType::kRGBA_8888, kLogAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, src, GrColorType::kRGBA_8888, kLogAlphaType,
|
||||
nullptr);
|
||||
SkImageInfo ii = SkImageInfo::Make(src->dimensions(), kRGBA_8888_SkColorType, kLogAlphaType);
|
||||
SkBitmap bm;
|
||||
SkAssertResult(bm.tryAllocPixels(ii));
|
||||
|
@ -426,9 +426,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
|
||||
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
|
||||
sk_sp<GrTextureProxy> proxy = sk_gpu_test::MakeTextureProxyFromData(
|
||||
context, renderable, origin, bmp.info(), bmp.getPixels(), bmp.rowBytes());
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), SkColorTypeToGrColorType(bmp.colorType()),
|
||||
kPremul_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, std::move(proxy),
|
||||
SkColorTypeToGrColorType(bmp.colorType()), kPremul_SkAlphaType, nullptr);
|
||||
auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType);
|
||||
test_readpixels_texture(reporter, std::move(sContext), info);
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
ERRORF(reporter, "Could not create alpha texture.");
|
||||
return;
|
||||
}
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), GrColorType::kAlpha_8, kPremul_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, std::move(proxy), GrColorType::kAlpha_8,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
|
||||
sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
|
||||
|
||||
@ -193,8 +193,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), info.fColorType, kPremul_SkAlphaType);
|
||||
auto sContext = GrSurfaceContext::Make(context, std::move(proxy), info.fColorType,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
|
||||
for (auto rowBytes : kRowBytes) {
|
||||
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
|
||||
|
@ -192,8 +192,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
||||
TestCopyFromSurface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888, refPixels,
|
||||
"RectangleTexture-copy-from");
|
||||
|
||||
auto rectContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(rectProxy), GrColorType::kRGBA_8888, kPremul_SkAlphaType);
|
||||
auto rectContext = GrSurfaceContext::Make(context, std::move(rectProxy),
|
||||
GrColorType::kRGBA_8888, kPremul_SkAlphaType,
|
||||
nullptr);
|
||||
SkASSERT(rectContext);
|
||||
|
||||
TestReadPixels(reporter, rectContext.get(), refPixels, "RectangleTexture-read");
|
||||
|
@ -783,9 +783,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
|
||||
sk_sp<SkImage> i(surface->makeImageSnapshot());
|
||||
SkImage_Gpu* gpuImage = (SkImage_Gpu*)as_IB(i);
|
||||
sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(context);
|
||||
return context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
|
||||
gpuImage->refColorSpace());
|
||||
return GrSurfaceContext::Make(context, std::move(proxy),
|
||||
SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
|
||||
gpuImage->refColorSpace());
|
||||
};
|
||||
|
||||
// Test that non-wrapped RTs are created clear.
|
||||
|
@ -84,8 +84,8 @@ void TestCopyFromSurface(skiatest::Reporter* reporter,
|
||||
SkBackingFit::kExact, SkBudgeted::kYes);
|
||||
SkASSERT(dstProxy);
|
||||
|
||||
auto dstContext = context->priv().makeWrappedSurfaceContext(std::move(dstProxy), colorType,
|
||||
kPremul_SkAlphaType);
|
||||
auto dstContext = GrSurfaceContext::Make(context, std::move(dstProxy), colorType,
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
SkASSERT(dstContext);
|
||||
|
||||
TestReadPixels(reporter, dstContext.get(), expectedPixelValues, testName);
|
||||
|
@ -46,9 +46,8 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context,
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(proxy, imageInfo.colorType(),
|
||||
imageInfo.alphaType(),
|
||||
imageInfo.refColorSpace(), nullptr);
|
||||
auto sContext = GrSurfaceContext::Make(context, proxy, imageInfo.colorType(),
|
||||
imageInfo.alphaType(), imageInfo.refColorSpace());
|
||||
if (!sContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user