Reduce dependence on GrSurface's origin field
Unfortunately, GrGPU and its ilk are still using the GrSurface's origin a lot. I will clean that up in a second CL. Change-Id: Iba729440ce8ea8d24bb7f4e5de55ed576a0f176d Reviewed-on: https://skia-review.googlesource.com/24700 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
594838a44d
commit
467022b186
@ -152,7 +152,8 @@ public:
|
||||
: SkImageGenerator(info)
|
||||
, fCtx(SkRef(ctx)) {
|
||||
|
||||
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
|
||||
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
|
||||
kTopLeft_GrSurfaceOrigin, nullptr));
|
||||
if (surface) {
|
||||
surface->getCanvas()->clear(0);
|
||||
surface->getCanvas()->translate(-100, -100);
|
||||
|
@ -86,6 +86,7 @@ protected:
|
||||
}
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fWidth = fBmp.width();
|
||||
desc.fHeight = fBmp.height();
|
||||
desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps());
|
||||
|
@ -66,7 +66,7 @@ protected:
|
||||
SkBackingFit, SkBudgeted, uint32_t flags);
|
||||
|
||||
// Wrapped version
|
||||
GrRenderTargetProxy(sk_sp<GrSurface>);
|
||||
GrRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
|
||||
|
||||
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
|
||||
|
||||
|
@ -173,8 +173,8 @@ private:
|
||||
|
||||
class GrSurfaceProxy : public GrIORefProxy {
|
||||
public:
|
||||
static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>);
|
||||
static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>);
|
||||
static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>, GrSurfaceOrigin);
|
||||
static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>, GrSurfaceOrigin);
|
||||
|
||||
static sk_sp<GrTextureProxy> MakeDeferred(GrResourceProvider*,
|
||||
const GrSurfaceDesc&, SkBackingFit,
|
||||
@ -353,7 +353,7 @@ protected:
|
||||
}
|
||||
|
||||
// Wrapped version
|
||||
GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit);
|
||||
GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit);
|
||||
|
||||
virtual ~GrSurfaceProxy();
|
||||
|
||||
|
@ -45,7 +45,7 @@ protected:
|
||||
GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
|
||||
const void* srcData, size_t srcRowBytes, uint32_t flags);
|
||||
// Wrapped version
|
||||
GrTextureProxy(sk_sp<GrSurface>);
|
||||
GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
|
||||
|
||||
SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; }
|
||||
|
||||
|
@ -86,7 +86,8 @@ sk_sp<GrTextureProxy> SkColorSpaceXformImageGenerator::onGenerateTexture(
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext = ctx->makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, fSrc.width(), fSrc.height(), kRGBA_8888_GrPixelConfig, nullptr);
|
||||
SkBackingFit::kExact, fSrc.width(), fSrc.height(), kRGBA_8888_GrPixelConfig, nullptr,
|
||||
0, kTopLeft_GrSurfaceOrigin);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -110,7 +110,8 @@ sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture(
|
||||
// TODO: respect the usage, by possibly creating a different (pow2) surface
|
||||
//
|
||||
SkImageInfo surfaceInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info;
|
||||
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo));
|
||||
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo,
|
||||
0, kTopLeft_GrSurfaceOrigin, nullptr));
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -174,10 +174,12 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource
|
||||
builder[0] = sigmaToCircleRRatioFixed;
|
||||
builder.finish();
|
||||
|
||||
sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey(key);
|
||||
sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey(
|
||||
key, kTopLeft_GrSurfaceOrigin);
|
||||
if (!blurProfile) {
|
||||
static constexpr int kProfileTextureWidth = 512;
|
||||
GrSurfaceDesc texDesc;
|
||||
texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
texDesc.fWidth = kProfileTextureWidth;
|
||||
texDesc.fHeight = 1;
|
||||
texDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
@ -197,6 +199,7 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
|
||||
}
|
||||
|
||||
|
@ -942,23 +942,24 @@ void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
|
||||
GrResourceProvider* resourceProvider,
|
||||
float sigma) {
|
||||
GrSurfaceDesc texDesc;
|
||||
|
||||
unsigned int profileSize = SkScalarCeilToInt(6*sigma);
|
||||
|
||||
texDesc.fWidth = profileSize;
|
||||
texDesc.fHeight = 1;
|
||||
texDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
texDesc.fIsMipMapped = false;
|
||||
|
||||
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
|
||||
GrUniqueKey key;
|
||||
GrUniqueKey::Builder builder(&key, kDomain, 1);
|
||||
builder[0] = profileSize;
|
||||
builder.finish();
|
||||
|
||||
sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(key));
|
||||
sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(
|
||||
key, kTopLeft_GrSurfaceOrigin));
|
||||
if (!blurProfile) {
|
||||
GrSurfaceDesc texDesc;
|
||||
texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
texDesc.fWidth = profileSize;
|
||||
texDesc.fHeight = 1;
|
||||
texDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
texDesc.fIsMipMapped = false;
|
||||
|
||||
std::unique_ptr<uint8_t[]> profile(SkBlurMask::ComputeBlurProfile(sigma));
|
||||
|
||||
blurProfile = GrSurfaceProxy::MakeDeferred(resourceProvider,
|
||||
@ -967,6 +968,7 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkASSERT(blurProfile->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
|
||||
}
|
||||
|
||||
@ -1117,7 +1119,8 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context,
|
||||
}
|
||||
builder.finish();
|
||||
|
||||
sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey(key));
|
||||
sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey(
|
||||
key, kBottomLeft_GrSurfaceOrigin));
|
||||
if (!mask) {
|
||||
// TODO: this could be approx but the texture coords will need to be updated
|
||||
sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
|
||||
@ -1154,6 +1157,7 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context,
|
||||
if (!mask) {
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT(mask->origin() == kBottomLeft_GrSurfaceOrigin);
|
||||
context->resourceProvider()->assignUniqueKeyToProxy(key, mask.get());
|
||||
}
|
||||
|
||||
|
@ -597,14 +597,15 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
|
||||
void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
|
||||
GrTexture* colorTex = displacementMap.textureSampler(1).peekTexture();
|
||||
GrSurfaceProxy* proxy = displacementMap.textureSampler(1).proxy();
|
||||
GrTexture* colorTex = proxy->priv().peekTexture();
|
||||
|
||||
SkScalar scaleX = displacementMap.scale().fX / colorTex->width();
|
||||
SkScalar scaleY = displacementMap.scale().fY / colorTex->height();
|
||||
pdman.set2f(fScaleUni, SkScalarToFloat(scaleX),
|
||||
colorTex->origin() == kTopLeft_GrSurfaceOrigin ?
|
||||
proxy->origin() == kTopLeft_GrSurfaceOrigin ?
|
||||
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
|
||||
fGLDomain.setData(pdman, displacementMap.domain(), colorTex);
|
||||
fGLDomain.setData(pdman, displacementMap.domain(), proxy);
|
||||
if (SkToBool(displacementMap.colorSpaceXform())) {
|
||||
fColorSpaceHelper.setData(pdman, displacementMap.colorSpaceXform());
|
||||
}
|
||||
|
@ -1899,14 +1899,15 @@ void GrGLLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
fLight = lighting.light()->createGLLight();
|
||||
}
|
||||
|
||||
GrTexture* texture = lighting.textureSampler(0).peekTexture();
|
||||
GrTextureProxy* proxy = lighting.textureSampler(0).proxy();
|
||||
GrTexture* texture = proxy->priv().peekTexture();
|
||||
|
||||
float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
|
||||
float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
|
||||
pdman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
|
||||
pdman.set1f(fSurfaceScaleUni, lighting.surfaceScale());
|
||||
sk_sp<SkImageFilterLight> transformedLight(
|
||||
lighting.light()->transform(lighting.filterMatrix()));
|
||||
fDomain.setData(pdman, lighting.domain(), texture);
|
||||
fDomain.setData(pdman, lighting.domain(), proxy);
|
||||
fLight->setData(pdman, transformedLight.get());
|
||||
}
|
||||
|
||||
|
@ -202,14 +202,15 @@ void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& effect) {
|
||||
const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>();
|
||||
|
||||
GrTexture* tex = zoom.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = zoom.textureSampler(0).proxy();
|
||||
GrTexture* tex = proxy->priv().peekTexture();
|
||||
|
||||
SkScalar invW = 1.0f / tex->width();
|
||||
SkScalar invH = 1.0f / tex->height();
|
||||
|
||||
{
|
||||
SkScalar y = zoom.srcRect().y() * invH;
|
||||
if (tex->origin() != kTopLeft_GrSurfaceOrigin) {
|
||||
if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
|
||||
y = 1.0f - (zoom.srcRect().height() / zoom.bounds().height()) - y;
|
||||
}
|
||||
|
||||
@ -221,7 +222,7 @@ void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
|
||||
{
|
||||
SkScalar y = zoom.bounds().y() * invH;
|
||||
if (tex->origin() != kTopLeft_GrSurfaceOrigin) {
|
||||
if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
|
||||
y = 1.0f - zoom.bounds().height() * invH;
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,8 @@ void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
|
||||
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& proc) {
|
||||
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
|
||||
GrTexture& texture = *m.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = m.textureSampler(0).proxy();
|
||||
GrTexture& texture = *proxy->priv().peekTexture();
|
||||
|
||||
float pixelSize = 0.0f;
|
||||
switch (m.direction()) {
|
||||
@ -311,7 +312,7 @@ void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
if (m.useRange()) {
|
||||
const float* range = m.range();
|
||||
if (Gr1DKernelEffect::kY_Direction == m.direction() &&
|
||||
texture.origin() == kBottomLeft_GrSurfaceOrigin) {
|
||||
proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
|
||||
pdman.set2f(fRangeUni, 1.0f - (range[1]*pixelSize), 1.0f - (range[0]*pixelSize));
|
||||
} else {
|
||||
pdman.set2f(fRangeUni, range[0] * pixelSize, range[1] * pixelSize);
|
||||
|
@ -165,7 +165,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
|
||||
SkASSERT(fRefHelper->fBorrowingContextID == context->uniqueID());
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), fSurfaceOrigin);
|
||||
|
||||
if (0 == origin.fX && 0 == origin.fY &&
|
||||
info.width() == fBackendTexture.width() && info.height() == fBackendTexture.height()) {
|
||||
|
@ -37,7 +37,8 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
|
||||
if (fOriginalKey.isValid()) {
|
||||
proxy = this->context()->resourceProvider()->findProxyByUniqueKey(fOriginalKey);
|
||||
proxy = this->context()->resourceProvider()->findProxyByUniqueKey(
|
||||
fOriginalKey, kTopLeft_GrSurfaceOrigin);
|
||||
if (proxy) {
|
||||
return proxy;
|
||||
}
|
||||
@ -50,6 +51,7 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM
|
||||
dstColorSpace);
|
||||
}
|
||||
if (proxy && fOriginalKey.isValid()) {
|
||||
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
this->context()->resourceProvider()->assignUniqueKeyToProxy(fOriginalKey, proxy.get());
|
||||
// MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching
|
||||
GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef());
|
||||
|
@ -394,7 +394,8 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context,
|
||||
GrUniqueKey key;
|
||||
create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy(resourceProvider->findProxyByUniqueKey(key));
|
||||
sk_sp<GrTextureProxy> proxy(resourceProvider->findProxyByUniqueKey(
|
||||
key, kBottomLeft_GrSurfaceOrigin));
|
||||
if (proxy) {
|
||||
return proxy;
|
||||
}
|
||||
@ -418,6 +419,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkASSERT(result->origin() == kBottomLeft_GrSurfaceOrigin);
|
||||
resourceProvider->assignUniqueKeyToProxy(key, result.get());
|
||||
// MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching
|
||||
add_invalidate_on_pop_message(*fStack, reducedClip.elementsGenID(), key);
|
||||
@ -431,7 +433,8 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask(
|
||||
GrUniqueKey key;
|
||||
create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy(context->resourceProvider()->findProxyByUniqueKey(key));
|
||||
sk_sp<GrTextureProxy> proxy(context->resourceProvider()->findProxyByUniqueKey(
|
||||
key, kTopLeft_GrSurfaceOrigin));
|
||||
if (proxy) {
|
||||
return proxy;
|
||||
}
|
||||
@ -489,6 +492,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask(
|
||||
|
||||
sk_sp<GrTextureProxy> result(helper.toTextureProxy(context, SkBackingFit::kApprox));
|
||||
|
||||
SkASSERT(result->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
context->resourceProvider()->assignUniqueKeyToProxy(key, result.get());
|
||||
// MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching
|
||||
add_invalidate_on_pop_message(*fStack, reducedClip.elementsGenID(), key);
|
||||
|
@ -676,7 +676,7 @@ sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackend
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface)));
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin));
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -698,7 +698,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface)));
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin));
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -720,7 +720,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(rt)));
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(rt), origin));
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -746,7 +746,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface)));
|
||||
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin));
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrContext* ctx, GrPixelConfig
|
||||
// should receive special attention.
|
||||
// Note: When switching over to the deferred proxy, use the kExact flag to create
|
||||
// the atlas and assert that the width & height are powers of 2.
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(texture));
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(texture),
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc
|
||||
}
|
||||
|
||||
// Wrapped version
|
||||
GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrSurface> surf)
|
||||
: INHERITED(std::move(surf), SkBackingFit::kExact)
|
||||
GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin)
|
||||
: INHERITED(std::move(surf), origin, SkBackingFit::kExact)
|
||||
, fSampleCnt(fTarget->asRenderTarget()->numStencilSamples())
|
||||
, fRenderTargetFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) {
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc
|
||||
|
||||
if (make_info(desc.fWidth, desc.fHeight, desc.fConfig, &srcInfo)) {
|
||||
sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, 0);
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
if (proxy) {
|
||||
sk_sp<GrSurfaceContext> sContext =
|
||||
context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), nullptr);
|
||||
@ -153,7 +153,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> tex(fGpu->createTexture(desc, budgeted, &mipLevel, 1));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
||||
@ -312,7 +312,8 @@ void GrResourceProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextur
|
||||
}
|
||||
|
||||
// MDB TODO (caching): this side-steps the issue of texture proxies with unique IDs
|
||||
sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey& key) {
|
||||
sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey& key,
|
||||
GrSurfaceOrigin origin) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
sk_sp<GrTexture> texture(this->findAndRefTextureByUniqueKey(key));
|
||||
@ -320,7 +321,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(texture));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(texture), origin);
|
||||
}
|
||||
|
||||
const GrBuffer* GrResourceProvider::createPatternedIndexBuffer(const uint16_t* pattern,
|
||||
|
@ -53,7 +53,9 @@ public:
|
||||
void assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy*);
|
||||
|
||||
/** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */
|
||||
sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey& key);
|
||||
// MDB TODO (caching): If this were actually caching proxies (rather than shallowly
|
||||
// wrapping GrSurface caching) we would not need the origin parameter.
|
||||
sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey& key, GrSurfaceOrigin);
|
||||
|
||||
/**
|
||||
* Finds a texture that approximately matches the descriptor. Will be at least as large in width
|
||||
|
@ -205,7 +205,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
if (useCache) {
|
||||
proxy = fResourceProvider->findProxyByUniqueKey(maskKey);
|
||||
proxy = fResourceProvider->findProxyByUniqueKey(maskKey, kTopLeft_GrSurfaceOrigin);
|
||||
}
|
||||
if (!proxy) {
|
||||
SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox;
|
||||
@ -217,6 +217,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
return false;
|
||||
}
|
||||
if (useCache) {
|
||||
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
fResourceProvider->assignUniqueKeyToProxy(maskKey, proxy.get());
|
||||
}
|
||||
}
|
||||
|
@ -20,19 +20,22 @@
|
||||
|
||||
#include "SkMathPriv.h"
|
||||
|
||||
GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit)
|
||||
GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit)
|
||||
: INHERITED(std::move(surface))
|
||||
, fConfig(fTarget->config())
|
||||
, fWidth(fTarget->width())
|
||||
, fHeight(fTarget->height())
|
||||
, fOrigin(fTarget->origin())
|
||||
, fOrigin(origin)
|
||||
, fFit(fit)
|
||||
, fBudgeted(fTarget->resourcePriv().isBudgeted())
|
||||
, fFlags(0)
|
||||
, fUniqueID(fTarget->uniqueID()) // Note: converting from unique resource ID to a proxy ID!
|
||||
, fNeedsClear(false)
|
||||
, fGpuMemorySize(kInvalidGpuMemorySize)
|
||||
, fLastOpList(nullptr) {}
|
||||
, fLastOpList(nullptr) {
|
||||
SkASSERT(kDefault_GrSurfaceOrigin != fOrigin);
|
||||
SkASSERT(fTarget->origin() == fOrigin);
|
||||
}
|
||||
|
||||
GrSurfaceProxy::~GrSurfaceProxy() {
|
||||
// For this to be deleted the opList that held a ref on it (if there was one) must have been
|
||||
@ -117,34 +120,34 @@ GrTextureOpList* GrSurfaceProxy::getLastTextureOpList() {
|
||||
return fLastOpList ? fLastOpList->asTextureOpList() : nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf) {
|
||||
sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) {
|
||||
if (!surf) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (surf->asTexture()) {
|
||||
if (surf->asRenderTarget()) {
|
||||
return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf)));
|
||||
return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf), origin));
|
||||
} else {
|
||||
return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf)));
|
||||
return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf), origin));
|
||||
}
|
||||
} else {
|
||||
SkASSERT(surf->asRenderTarget());
|
||||
|
||||
// Not texturable
|
||||
return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf)));
|
||||
return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf), origin));
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex) {
|
||||
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) {
|
||||
if (!tex) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (tex->asRenderTarget()) {
|
||||
return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex)));
|
||||
return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin));
|
||||
} else {
|
||||
return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex)));
|
||||
return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin));
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,14 +245,14 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferredMipMap(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context,
|
||||
GrBackendTexture& backendTex,
|
||||
GrSurfaceOrigin origin) {
|
||||
sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(backendTex, origin));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex), origin);
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
|
@ -46,7 +46,8 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
|
||||
GrUniqueKey key;
|
||||
this->makeCopyKey(copyParams, &key, nullptr);
|
||||
if (key.isValid()) {
|
||||
sk_sp<GrTextureProxy> cachedCopy = fContext->resourceProvider()->findProxyByUniqueKey(key);
|
||||
sk_sp<GrTextureProxy> cachedCopy = fContext->resourceProvider()->findProxyByUniqueKey(
|
||||
key, this->originalProxy()->origin());
|
||||
if (cachedCopy) {
|
||||
return cachedCopy;
|
||||
}
|
||||
@ -58,6 +59,7 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
|
||||
sk_sp<GrTextureProxy> copy = CopyOnGpu(fContext, std::move(proxy), contentArea, copyParams);
|
||||
if (copy) {
|
||||
if (key.isValid()) {
|
||||
SkASSERT(copy->origin() == this->originalProxy()->origin());
|
||||
fContext->resourceProvider()->assignUniqueKeyToProxy(key, copy.get());
|
||||
this->didCacheCopy(key);
|
||||
}
|
||||
|
@ -41,10 +41,12 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerPa
|
||||
}
|
||||
}
|
||||
|
||||
GrSurfaceOrigin origOrigin = original->origin();
|
||||
GrUniqueKey copyKey;
|
||||
this->makeCopyKey(copyParams, ©Key, dstColorSpace);
|
||||
if (copyKey.isValid()) {
|
||||
sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findProxyByUniqueKey(copyKey));
|
||||
sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findProxyByUniqueKey(
|
||||
copyKey, origOrigin));
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@ -62,6 +64,7 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerPa
|
||||
}
|
||||
|
||||
if (copyKey.isValid()) {
|
||||
SkASSERT(result->origin() == origOrigin);
|
||||
fContext->resourceProvider()->assignUniqueKeyToProxy(copyKey, result.get());
|
||||
this->didCacheCopy(copyKey);
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
|
||||
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
|
||||
|
||||
sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr);
|
||||
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr,
|
||||
0, inputProxy->origin());
|
||||
if (!copyRTC) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, S
|
||||
SkASSERT(!srcData); // currently handled in Make()
|
||||
}
|
||||
|
||||
GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf)
|
||||
: INHERITED(std::move(surf), SkBackingFit::kExact)
|
||||
GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin)
|
||||
: INHERITED(std::move(surf), origin, SkBackingFit::kExact)
|
||||
, fIsMipMapped(fTarget->asTexture()->texturePriv().hasMipMaps())
|
||||
, fMipColorMode(fTarget->asTexture()->texturePriv().mipColorMode()) {
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
|
||||
// Wrapped version
|
||||
// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
|
||||
// GrRenderTargetProxy) so its constructor must be explicitly called.
|
||||
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf)
|
||||
: GrSurfaceProxy(surf, SkBackingFit::kExact)
|
||||
, GrTextureProxy(surf)
|
||||
, GrRenderTargetProxy(surf) {
|
||||
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf,
|
||||
GrSurfaceOrigin origin)
|
||||
: GrSurfaceProxy(surf, origin, SkBackingFit::kExact)
|
||||
, GrTextureProxy(surf, origin)
|
||||
, GrRenderTargetProxy(surf, origin) {
|
||||
SkASSERT(surf->asTexture());
|
||||
SkASSERT(surf->asRenderTarget());
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ private:
|
||||
SkBackingFit, SkBudgeted, uint32_t flags);
|
||||
|
||||
// Wrapped version
|
||||
GrTextureRenderTargetProxy(sk_sp<GrSurface>);
|
||||
GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
|
||||
|
||||
bool instantiate(GrResourceProvider*) override;
|
||||
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
|
||||
|
@ -124,10 +124,11 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
|
||||
|
||||
// We never want to perform color-space conversion during the decode
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact,
|
||||
desc.fWidth, desc.fHeight,
|
||||
desc.fConfig, nullptr,
|
||||
desc.fSampleCnt));
|
||||
SkBackingFit::kExact,
|
||||
desc.fWidth, desc.fHeight,
|
||||
desc.fConfig, nullptr,
|
||||
desc.fSampleCnt,
|
||||
kTopLeft_GrSurfaceOrigin));
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info, const GrCaps& caps) {
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fWidth = info.width();
|
||||
desc.fHeight = info.height();
|
||||
desc.fConfig = SkImageInfo2GrPixelConfig(info, caps);
|
||||
@ -245,7 +246,7 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider* resourceProvid
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
|
||||
if (originalKey.isValid()) {
|
||||
proxy = resourceProvider->findProxyByUniqueKey(originalKey);
|
||||
proxy = resourceProvider->findProxyByUniqueKey(originalKey, kTopLeft_GrSurfaceOrigin);
|
||||
}
|
||||
if (!proxy) {
|
||||
// Pass nullptr for |dstColorSpace|. This is lenient - we allow a wider range of
|
||||
@ -253,6 +254,7 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider* resourceProvid
|
||||
// we can't necessarily know the |dstColorSpace| at this time.
|
||||
proxy = GrUploadBitmapToTextureProxy(resourceProvider, bitmap, nullptr);
|
||||
if (proxy && originalKey.isValid()) {
|
||||
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
resourceProvider->assignUniqueKeyToProxy(originalKey, proxy.get());
|
||||
// MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching
|
||||
GrInstallBitmapUniqueKeyInvalidator(originalKey, bitmap.pixelRef());
|
||||
|
@ -86,7 +86,7 @@ GrCCPRPathProcessor::GrCCPRPathProcessor(GrResourceProvider* rp, sk_sp<GrTexture
|
||||
}
|
||||
|
||||
void GrCCPRPathProcessor::getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const {
|
||||
b->add32((fFillType << 16) | this->atlas()->origin());
|
||||
b->add32((fFillType << 16) | this->proxy()->origin());
|
||||
}
|
||||
|
||||
class GLSLPathProcessor : public GrGLSLGeometryProcessor {
|
||||
@ -161,10 +161,10 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
// Convert to atlas coordinates in order to do our texture lookup.
|
||||
v->codeAppendf("highp vec2 atlascoord = octocoord + vec2(%s);",
|
||||
proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
|
||||
if (kTopLeft_GrSurfaceOrigin == proc.atlas()->origin()) {
|
||||
if (kTopLeft_GrSurfaceOrigin == proc.proxy()->origin()) {
|
||||
v->codeAppendf("%s = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
|
||||
} else {
|
||||
SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlas()->origin());
|
||||
SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.proxy()->origin());
|
||||
v->codeAppendf("%s = vec2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
|
||||
texcoord.vsOut(), atlasAdjust, atlasAdjust);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
const GrShaderCaps&);
|
||||
|
||||
const char* name() const override { return "GrCCPRPathProcessor"; }
|
||||
const GrSurfaceProxy* proxy() const { return fAtlasAccess.proxy(); }
|
||||
const GrTexture* atlas() const { return fAtlasAccess.peekTexture(); }
|
||||
SkPath::FillType fillType() const { return fFillType; }
|
||||
const Attribute& getInstanceAttrib(InstanceAttribs attribID) const {
|
||||
|
@ -120,13 +120,14 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
|
||||
GrTexture* texture = processor.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = processor.textureSampler(0).proxy();
|
||||
GrTexture* texture = proxy->priv().peekTexture();
|
||||
|
||||
float imageIncrement[2];
|
||||
imageIncrement[0] = 1.0f / texture->width();
|
||||
imageIncrement[1] = 1.0f / texture->height();
|
||||
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||
fDomain.setData(pdman, bicubicEffect.domain(), texture);
|
||||
fDomain.setData(pdman, bicubicEffect.domain(), proxy);
|
||||
if (SkToBool(bicubicEffect.colorSpaceXform())) {
|
||||
fColorSpaceHelper.setData(pdman, bicubicEffect.colorSpaceXform());
|
||||
}
|
||||
|
@ -133,6 +133,7 @@ bool GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
return false;
|
||||
}
|
||||
GrSurfaceDesc desc;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fWidth = kSize;
|
||||
desc.fHeight = kSize;
|
||||
desc.fConfig = kConfig;
|
||||
|
@ -121,10 +121,11 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrGaussianConvolutionFragmentProcessor& conv =
|
||||
processor.cast<GrGaussianConvolutionFragmentProcessor>();
|
||||
GrTexture& texture = *conv.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
|
||||
GrTexture& texture = *proxy->priv().peekTexture();
|
||||
|
||||
float imageIncrement[2] = {0};
|
||||
float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
|
||||
float ySign = proxy->origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
|
||||
switch (conv.direction()) {
|
||||
case Gr1DKernelEffect::kX_Direction:
|
||||
imageIncrement[0] = 1.0f / texture.width();
|
||||
@ -149,7 +150,7 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
pdman.set2f(fBoundsUni, inv * bounds[0], inv * bounds[1]);
|
||||
} else {
|
||||
SkScalar inv = SkScalarInvert(SkIntToScalar(texture.height()));
|
||||
if (texture.origin() != kTopLeft_GrSurfaceOrigin) {
|
||||
if (proxy->origin() != kTopLeft_GrSurfaceOrigin) {
|
||||
pdman.set2f(fBoundsUni, 1.0f - (inv * bounds[1]), 1.0f - (inv * bounds[0]));
|
||||
} else {
|
||||
pdman.set2f(fBoundsUni, inv * bounds[1], inv * bounds[0]);
|
||||
|
@ -131,10 +131,11 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
|
||||
void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) {
|
||||
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
|
||||
GrTexture* texture = conv.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
|
||||
GrTexture* texture = proxy->priv().peekTexture();
|
||||
|
||||
float imageIncrement[2];
|
||||
float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
|
||||
float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
|
||||
imageIncrement[0] = 1.0f / texture->width();
|
||||
imageIncrement[1] = ySign / texture->height();
|
||||
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||
@ -145,7 +146,7 @@ void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdma
|
||||
pdman.set4fv(fKernelUni, arrayCount, conv.kernel());
|
||||
pdman.set1f(fGainUni, conv.gain());
|
||||
pdman.set1f(fBiasUni, conv.bias());
|
||||
fDomain.setData(pdman, conv.domain(), texture);
|
||||
fDomain.setData(pdman, conv.domain(), proxy);
|
||||
}
|
||||
|
||||
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy,
|
||||
|
@ -161,7 +161,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
|
||||
void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrTextureDomain& textureDomain,
|
||||
GrTexture* tex) {
|
||||
GrSurfaceProxy* proxy) {
|
||||
GrTexture* tex = proxy->priv().peekTexture();
|
||||
SkASSERT(textureDomain.mode() == fMode);
|
||||
if (kIgnore_Mode != textureDomain.mode()) {
|
||||
SkScalar wInv = SK_Scalar1 / tex->width();
|
||||
@ -180,7 +181,7 @@ void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
|
||||
SkASSERT(values[3] >= 0.0f && values[3] <= 1.0f);
|
||||
|
||||
// vertical flip if necessary
|
||||
if (kBottomLeft_GrSurfaceOrigin == tex->origin()) {
|
||||
if (kBottomLeft_GrSurfaceOrigin == proxy->origin()) {
|
||||
values[1] = 1.0f - values[1];
|
||||
values[3] = 1.0f - values[3];
|
||||
// The top and bottom were just flipped, so correct the ordering
|
||||
@ -270,9 +271,9 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
|
||||
const GrFragmentProcessor& fp) override {
|
||||
const GrTextureDomainEffect& tde = fp.cast<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = tde.fTextureDomain;
|
||||
GrTexture* texture = tde.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = tde.textureSampler(0).proxy();
|
||||
|
||||
fGLDomain.setData(pdman, domain, texture);
|
||||
fGLDomain.setData(pdman, domain, proxy);
|
||||
if (SkToBool(tde.colorSpaceXform())) {
|
||||
fColorSpaceHelper.setData(pdman, tde.colorSpaceXform());
|
||||
}
|
||||
@ -372,16 +373,17 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
|
||||
const GrFragmentProcessor& fp) override {
|
||||
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
|
||||
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
|
||||
GrTexture* texture = dstdfp.textureSampler(0).peekTexture();
|
||||
GrSurfaceProxy* proxy = dstdfp.textureSampler(0).proxy();
|
||||
GrTexture* texture = proxy->priv().peekTexture();
|
||||
|
||||
fGLDomain.setData(pdman, dstdfp.fTextureDomain, texture);
|
||||
fGLDomain.setData(pdman, dstdfp.fTextureDomain, proxy);
|
||||
float iw = 1.f / texture->width();
|
||||
float ih = 1.f / texture->height();
|
||||
float scaleAndTransData[4] = {
|
||||
iw, ih,
|
||||
-dstdfp.fDeviceSpaceOffset.fX * iw, -dstdfp.fDeviceSpaceOffset.fY * ih
|
||||
};
|
||||
if (texture->origin() == kBottomLeft_GrSurfaceOrigin) {
|
||||
if (proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
|
||||
scaleAndTransData[1] = -scaleAndTransData[1];
|
||||
scaleAndTransData[3] = 1 - scaleAndTransData[3];
|
||||
}
|
||||
|
@ -115,8 +115,7 @@ public:
|
||||
* texture domain. The rectangle is automatically adjusted to account for the texture's
|
||||
* origin.
|
||||
*/
|
||||
void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
|
||||
GrTexture* texure);
|
||||
void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, GrSurfaceProxy*);
|
||||
|
||||
enum {
|
||||
kDomainKeyBits = 2, // See DomainKey().
|
||||
|
@ -193,11 +193,6 @@ GrTextureStripAtlas::AtlasRow* GrTextureStripAtlas::getLRU() {
|
||||
}
|
||||
|
||||
void GrTextureStripAtlas::lockTexture() {
|
||||
GrSurfaceDesc texDesc;
|
||||
texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
texDesc.fWidth = fDesc.fWidth;
|
||||
texDesc.fHeight = fDesc.fHeight;
|
||||
texDesc.fConfig = fDesc.fConfig;
|
||||
|
||||
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
|
||||
GrUniqueKey key;
|
||||
@ -205,8 +200,15 @@ void GrTextureStripAtlas::lockTexture() {
|
||||
builder[0] = static_cast<uint32_t>(fCacheKey);
|
||||
builder.finish();
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(key);
|
||||
sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(
|
||||
key, kTopLeft_GrSurfaceOrigin);
|
||||
if (!proxy) {
|
||||
GrSurfaceDesc texDesc;
|
||||
texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
texDesc.fWidth = fDesc.fWidth;
|
||||
texDesc.fHeight = fDesc.fHeight;
|
||||
texDesc.fConfig = fDesc.fConfig;
|
||||
|
||||
proxy = GrSurfaceProxy::MakeDeferred(fDesc.fContext->resourceProvider(),
|
||||
texDesc, SkBackingFit::kExact,
|
||||
SkBudgeted::kYes,
|
||||
@ -215,6 +217,7 @@ void GrTextureStripAtlas::lockTexture() {
|
||||
return;
|
||||
}
|
||||
|
||||
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
fDesc.fContext->resourceProvider()->assignUniqueKeyToProxy(key, proxy.get());
|
||||
// This is a new texture, so all of our cache info is now invalid
|
||||
this->initLRU();
|
||||
|
@ -277,7 +277,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
||||
}
|
||||
|
||||
const SkBudgeted budgeted = SkBudgeted::kNo;
|
||||
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex)));
|
||||
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex), origin));
|
||||
return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID,
|
||||
at, std::move(proxy), std::move(colorSpace), budgeted);
|
||||
}
|
||||
|
@ -697,6 +697,7 @@ public:
|
||||
static void set_key_on_proxy(GrResourceProvider* resourceProvider,
|
||||
GrTextureProxy* proxy, const GrUniqueKey& key) {
|
||||
if (key.isValid()) {
|
||||
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
resourceProvider->assignUniqueKeyToProxy(key, proxy);
|
||||
}
|
||||
}
|
||||
@ -747,7 +748,8 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
|
||||
|
||||
// 1. Check the cache for a pre-existing one
|
||||
if (key.isValid()) {
|
||||
if (sk_sp<GrTextureProxy> proxy = ctx->resourceProvider()->findProxyByUniqueKey(key)) {
|
||||
if (sk_sp<GrTextureProxy> proxy = ctx->resourceProvider()->findProxyByUniqueKey(
|
||||
key, kTopLeft_GrSurfaceOrigin)) {
|
||||
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath,
|
||||
kLockTexturePathCount);
|
||||
return proxy;
|
||||
|
@ -184,7 +184,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
|
||||
if (!tex) {
|
||||
continue;
|
||||
}
|
||||
auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
auto texCtx = context->contextPriv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), nullptr);
|
||||
SkImageInfo info = SkImageInfo::Make(
|
||||
|
@ -190,8 +190,9 @@ static sk_sp<GrTextureProxy> create_proxy(GrResourceProvider* resourceProvider)
|
||||
SkBitmap srcBM = create_bm();
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
desc.fWidth = kFullSize;
|
||||
desc.fHeight = kFullSize;
|
||||
|
||||
|
@ -302,9 +302,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
||||
sk_sp<GrRenderTargetContext> rtc = context->makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, 256, 256, kRGBA_8888_GrPixelConfig, nullptr);
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
desc.fWidth = 256;
|
||||
desc.fHeight = 256;
|
||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
|
||||
sk_sp<GrTextureProxy> proxies[2];
|
||||
|
@ -29,7 +29,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrResourceProvider* provider,
|
||||
sk_sp<GrRenderTarget> defaultFBO(provider->wrapBackendRenderTarget(backendRT, desc.fOrigin));
|
||||
SkASSERT(!defaultFBO->asTexture());
|
||||
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO), desc.fOrigin);
|
||||
}
|
||||
|
||||
static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrResourceProvider* provider,
|
||||
@ -40,7 +40,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrResourceProvider* provi
|
||||
|
||||
sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted));
|
||||
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
}
|
||||
|
||||
static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrResourceProvider* provider,
|
||||
@ -48,7 +48,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrResourceProvider* provider,
|
||||
SkBudgeted budgeted) {
|
||||
sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted));
|
||||
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
}
|
||||
|
||||
// Test converting between RenderTargetProxies and TextureProxies for wrapped
|
||||
|
@ -80,13 +80,14 @@ static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
|
||||
static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
desc.fWidth = kWidthHeight;
|
||||
desc.fHeight = kWidthHeight;
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
|
||||
sk_sp<GrTexture> tex(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo));
|
||||
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||
return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
|
||||
|
@ -236,7 +236,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
sk_sp<GrRenderTarget> defaultFBO(
|
||||
provider->wrapBackendRenderTarget(backendRT, origin));
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO));
|
||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO,
|
||||
origin));
|
||||
check_surface(reporter, sProxy.get(), origin,
|
||||
kWidthHeight, kWidthHeight, config,
|
||||
defaultFBO->uniqueID(), SkBudgeted::kNo);
|
||||
@ -252,7 +253,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
tex = provider->createTexture(desc, budgeted);
|
||||
sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget()));
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt));
|
||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt, origin));
|
||||
check_surface(reporter, sProxy.get(), origin,
|
||||
kWidthHeight, kWidthHeight, config,
|
||||
rt->uniqueID(), budgeted);
|
||||
@ -267,7 +268,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
tex = provider->createTexture(desc, budgeted);
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex));
|
||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex, origin));
|
||||
check_surface(reporter, sProxy.get(), origin,
|
||||
kWidthHeight, kWidthHeight, config, tex->uniqueID(), budgeted);
|
||||
check_texture(reporter, provider, sProxy->asTextureProxy(),
|
||||
|
@ -50,6 +50,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
{
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = kAlpha_8_GrPixelConfig; // it is a single channel texture
|
||||
desc.fWidth = X_SIZE;
|
||||
desc.fHeight = Y_SIZE;
|
||||
@ -153,6 +154,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
for (int rt = 0; rt < 2; ++rt) {
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = rt ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = config;
|
||||
desc.fWidth = X_SIZE;
|
||||
desc.fHeight = Y_SIZE;
|
||||
|
@ -1673,6 +1673,8 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrResourceProvider* provider,
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = flags;
|
||||
desc.fOrigin = (flags & kRenderTarget_GrSurfaceFlag) ? kBottomLeft_GrSurfaceOrigin
|
||||
: kTopLeft_GrSurfaceOrigin;
|
||||
desc.fWidth = width;
|
||||
desc.fHeight = height;
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
|
@ -124,6 +124,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
|
||||
// Create our test texture
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = kSRGBA_8888_GrPixelConfig;
|
||||
desc.fWidth = texS;
|
||||
desc.fHeight = texS;
|
||||
|
@ -301,8 +301,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo)
|
||||
SkBitmap bm = create_bm();
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fWidth = kFullSize;
|
||||
desc.fHeight = kFullSize;
|
||||
|
||||
|
@ -599,7 +599,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture(
|
||||
backendHandle);
|
||||
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, backendTex,
|
||||
kDefault_GrSurfaceOrigin, sampleCnt,
|
||||
kTopLeft_GrSurfaceOrigin, sampleCnt,
|
||||
nullptr, nullptr);
|
||||
if (!surface) {
|
||||
context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
|
||||
@ -625,7 +625,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
|
||||
kRGBA_8888_GrPixelConfig,
|
||||
backendHandle);
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
|
||||
context, backendTex, kDefault_GrSurfaceOrigin, sampleCnt, nullptr, nullptr);
|
||||
context, backendTex, kTopLeft_GrSurfaceOrigin, sampleCnt, nullptr, nullptr);
|
||||
|
||||
if (!surface) {
|
||||
context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
|
||||
@ -907,7 +907,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
|
||||
backendHandle);
|
||||
|
||||
return SkSurface::MakeFromBackendTexture(context, backendTex,
|
||||
kDefault_GrSurfaceOrigin, 0,
|
||||
kTopLeft_GrSurfaceOrigin, 0,
|
||||
sk_ref_sp(info.colorSpace()), nullptr);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user