Skip to content

Commit

Permalink
Have GrTextureOp use GrSurfaceProxyViews instead of just proxys.
Browse files Browse the repository at this point in the history
Additionally updated some calls upstack to pass in the views.

Bug: skia:9556
Change-Id: I2b6274cb1811b102713433d51a9b18d47778174a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251759
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
  • Loading branch information
egdaniel authored and Skia Commit-Bot committed Oct 30, 2019
1 parent e785c44 commit 549325c
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 64 deletions.
12 changes: 6 additions & 6 deletions src/gpu/GrRenderTargetContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ void GrRenderTargetContext::drawFilledQuad(const GrClip& clip,
}

void GrRenderTargetContext::drawTexturedQuad(const GrClip& clip,
sk_sp<GrTextureProxy> proxy,
GrSurfaceProxyView proxyView,
GrColorType srcColorType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
Expand All @@ -624,7 +624,7 @@ void GrRenderTargetContext::drawTexturedQuad(const GrClip& clip,
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
SkASSERT(proxy);
SkASSERT(proxyView.asTextureProxy());
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "drawTexturedQuad", fContext);

AutoCheckFlush acf(this->drawingManager());
Expand All @@ -648,7 +648,7 @@ void GrRenderTargetContext::drawTexturedQuad(const GrClip& clip,
// Use the provided domain, although hypothetically we could detect that the cropped local
// quad is sufficiently inside the domain and the constraint could be dropped.
this->addDrawOp(finalClip,
GrTextureOp::Make(fContext, std::move(proxy), srcColorType,
GrTextureOp::Make(fContext, std::move(proxyView), srcColorType,
std::move(textureXform), filter, color, saturate,
blendMode, aaType, edgeFlags, croppedDeviceQuad,
croppedLocalQuad, domain));
Expand Down Expand Up @@ -898,9 +898,9 @@ void GrRenderTargetContext::drawTextureSet(const GrClip& clip, const TextureSetE

const SkRect* domain = constraint == SkCanvas::kStrict_SrcRectConstraint
? &set[i].fSrcRect : nullptr;
this->drawTexturedQuad(clip, set[i].fProxy, set[i].fSrcColorType, texXform, filter,
{alpha, alpha, alpha, alpha}, mode, aa, set[i].fAAFlags,
quad, srcQuad, domain);
this->drawTexturedQuad(clip, set[i].fProxyView, set[i].fSrcColorType, texXform, filter,
{alpha, alpha, alpha, alpha}, mode, aa, set[i].fAAFlags, quad,
srcQuad, domain);
}
} else {
// Can use a single op, avoiding GrPaint creation, and can batch across proxies
Expand Down
21 changes: 14 additions & 7 deletions src/gpu/GrRenderTargetContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ class GrRenderTargetContext : public GrSurfaceContext {
sk_sp<GrColorSpaceXform> texXform) {
const SkRect* domain = constraint == SkCanvas::kStrict_SrcRectConstraint ?
&srcRect : nullptr;
this->drawTexturedQuad(clip, std::move(proxy), srcColorType, std::move(texXform), filter,
color, mode, aa, edgeAA, GrQuad::MakeFromRect(dstRect, viewMatrix),
GrQuad(srcRect), domain);
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
GrSurfaceProxyView proxyView(std::move(proxy), origin, swizzle);
this->drawTexturedQuad(clip, std::move(proxyView), srcColorType, std::move(texXform),
filter, color, mode, aa, edgeAA,
GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), domain);
}

/**
Expand All @@ -218,14 +221,18 @@ class GrRenderTargetContext : public GrSurfaceContext {
const SkPoint srcQuad[4], const SkPoint dstQuad[4], GrAA aa,
GrQuadAAFlags edgeAA, const SkRect* domain, const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> texXform) {
this->drawTexturedQuad(clip, std::move(proxy), srcColorType, std::move(texXform), filter,
color, mode, aa, edgeAA, GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
GrSurfaceProxyView proxyView(std::move(proxy), origin, swizzle);
this->drawTexturedQuad(clip, std::move(proxyView), srcColorType, std::move(texXform),
filter, color, mode, aa, edgeAA,
GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), domain);
}

/** Used with drawTextureSet */
struct TextureSetEntry {
sk_sp<GrTextureProxy> fProxy;
GrSurfaceProxyView fProxyView;
GrColorType fSrcColorType;
SkRect fSrcRect;
SkRect fDstRect;
Expand Down Expand Up @@ -601,7 +608,7 @@ class GrRenderTargetContext : public GrSurfaceContext {

// Like drawFilledQuad but does not require using a GrPaint or FP for texturing
void drawTexturedQuad(const GrClip& clip,
sk_sp<GrTextureProxy> proxy,
GrSurfaceProxyView proxyView,
GrColorType srcColorType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
Expand Down
10 changes: 5 additions & 5 deletions src/gpu/GrSurfaceProxyView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ class GrSurfaceProxyView {
: fProxy(proxy), fOrigin(kTopLeft_GrSurfaceOrigin) {}

GrSurfaceProxyView(GrSurfaceProxyView&& view) = default;
GrSurfaceProxyView(const GrSurfaceProxyView&) = delete;
GrSurfaceProxyView(const GrSurfaceProxyView&) = default;

GrSurfaceProxyView& operator=(const GrSurfaceProxyView& that) = default;
GrSurfaceProxyView& operator=(const GrSurfaceProxyView&) = default;

bool operator==(const GrSurfaceProxyView& view) {
return fProxy.get() == view.fProxy.get() &&
bool operator==(const GrSurfaceProxyView& view) const {
return fProxy->uniqueID() == view.fProxy->uniqueID() &&
fOrigin == view.fOrigin &&
fSwizzle == view.fSwizzle;
}
bool operator!=(const GrSurfaceProxyView& other) { return !(*this == other); }
bool operator!=(const GrSurfaceProxyView& other) const { return !(*this == other); }

GrSurfaceProxy* proxy() const { return fProxy.get(); }
GrTextureProxy* asTextureProxy() const { return fProxy->asTextureProxy(); }
Expand Down
10 changes: 7 additions & 3 deletions src/gpu/SkGpuDevice_drawTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,10 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
continue;
}

textures[i].fProxy = std::move(proxy);
// TODO: have refPinnedTextureProxy and asTextureProxyRef return GrSurfaceProxyViews.
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
textures[i].fProxyView = {std::move(proxy), origin, swizzle};
textures[i].fSrcColorType = SkColorTypeToGrColorType(image->colorType());
textures[i].fSrcRect = set[i].fSrcRect;
textures[i].fDstRect = set[i].fDstRect;
Expand All @@ -562,8 +565,9 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
textures[i].fAAFlags = SkToGrQuadAAFlags(set[i].fAAFlags);

if (n > 0 &&
(!GrTextureProxy::ProxiesAreCompatibleAsDynamicState(textures[i].fProxy.get(),
textures[base].fProxy.get()) ||
(!GrTextureProxy::ProxiesAreCompatibleAsDynamicState(
textures[i].fProxyView.asTextureProxy(),
textures[base].fProxyView.asTextureProxy()) ||
set[i].fImage->alphaType() != set[base].fImage->alphaType() ||
!SkColorSpace::Equals(set[i].fImage->colorSpace(), set[base].fImage->colorSpace()))) {
draw();
Expand Down
Loading

0 comments on commit 549325c

Please sign in to comment.