#include "SkString.h"
struct GrContextOptions;
-class GrRenderTargetProxy;
+class GrRenderTarget;
/**
* Represents the capabilities of a GrContext.
/**
* This is can be called before allocating a texture to be a dst for copySurface. This is only
- * used for doing dst copies needed in blends, thus the src is always a GrRenderTargetProxy. It
- * will populate the origin, config, and flags fields of the desc such that copySurface can
+ * used for doing dst copies needed in blends, thus the src is always a GrRenderTarget. It will
+ * populate the origin, config, and flags fields of the desc such that copySurface can
* efficiently succeed. rectsMustMatch will be set to true if the copy operation must ensure
* that the src and dest rects are identical. disallowSubrect will be set to true if copy rect
* must equal src's bounds.
*/
- virtual bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
+ virtual bool initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const = 0;
protected:
GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); }
// Create a renderTargetContext that wraps an existing renderTarget
- sk_sp<GrRenderTargetContext> makeWrappedRenderTargetContext(sk_sp<GrRenderTarget>,
- sk_sp<SkColorSpace>,
+ sk_sp<GrRenderTargetContext> makeWrappedRenderTargetContext(sk_sp<GrRenderTarget> rt,
+ sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* = nullptr);
// Create a surfaceContext that wraps an existing texture or renderTarget
- sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurface>);
+ sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurface> tex);
- sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>, sk_sp<SkColorSpace>);
+ sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy,
+ sk_sp<SkColorSpace>);
- sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc&,
- SkBackingFit,
- SkBudgeted);
+ sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
+ SkBackingFit dstFit,
+ SkBudgeted isDstBudgeted);
// TODO: Maybe add a 'surfaceProps' param (that is ignored for non-RTs) and remove
// makeBackendTextureRenderTargetContext & makeBackendTextureAsRenderTargetRenderTargetContext
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
- GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::onCopy");
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::copy");
- return this->getOpList()->copySurface(fContext->resourceProvider(),
- fRenderTargetProxy.get(), srcProxy, srcRect, dstPoint);
+ // TODO: defer instantiation until flush time
+ sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->resourceProvider())));
+ if (!src) {
+ return false;
+ }
+
+ // TODO: This needs to be fixed up since it ends the deferral of the GrRenderTarget.
+ sk_sp<GrRenderTarget> rt(
+ sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider())));
+ if (!rt) {
+ return false;
+ }
+
+ return this->getOpList()->copySurface(rt.get(), src.get(), srcRect, dstPoint);
}
// TODO: move this (and GrTextureContext::onReadPixels) to GrSurfaceContext?
GrXferProcessor::DstTexture dstTexture;
if (op->xpRequiresDstTexture(*this->caps(), &appliedClip)) {
- if (!this->setupDstTexture(fRenderTargetProxy.get(), clip, op->bounds(), &dstTexture)) {
+ this->setupDstTexture(rt, clip, op->bounds(), &dstTexture);
+ if (!dstTexture.texture()) {
return SK_InvalidUniqueID;
}
}
args.fXPInputCoverage = analysis.outputCoverage();
if (analysis.requiresDstTexture()) {
- if (!this->setupDstTexture(fRenderTargetProxy.get(), clip, bounds, &args.fDstTexture)) {
+ this->setupDstTexture(rt, clip, bounds, &args.fDstTexture);
+ if (!args.fDstTexture.texture()) {
return SK_InvalidUniqueID;
}
}
return this->getOpList()->addOp(std::move(op), this);
}
-bool GrRenderTargetContext::setupDstTexture(GrRenderTargetProxy* rtProxy, const GrClip& clip,
+void GrRenderTargetContext::setupDstTexture(GrRenderTarget* rt, const GrClip& clip,
const SkRect& opBounds,
GrXferProcessor::DstTexture* dstTexture) {
if (this->caps()->textureBarrierSupport()) {
- if (GrTextureProxy* texProxy = rtProxy->asTextureProxy()) {
- // MDB TODO: remove this instantiation. Blocked on making DstTexture be proxy-based
- sk_sp<GrTexture> tex(sk_ref_sp(texProxy->instantiate(fContext->resourceProvider())));
- if (!tex) {
- SkDebugf("setupDstTexture: instantiation of src texture failed.\n");
- return false; // We have bigger problems now
- }
-
+ if (GrTexture* rtTex = rt->asTexture()) {
// The render target is a texture, so we can read from it directly in the shader. The XP
// will be responsible to detect this situation and request a texture barrier.
- dstTexture->setTexture(std::move(tex));
+ dstTexture->setTexture(sk_ref_sp(rtTex));
dstTexture->setOffset(0, 0);
- return true;
+ return;
}
}
- SkIRect copyRect = SkIRect::MakeWH(rtProxy->width(), rtProxy->height());
+ SkIRect copyRect = SkIRect::MakeWH(rt->width(), rt->height());
SkIRect clippedRect;
- clip.getConservativeBounds(rtProxy->width(), rtProxy->height(), &clippedRect);
+ clip.getConservativeBounds(rt->width(), rt->height(), &clippedRect);
SkIRect drawIBounds;
opBounds.roundOut(&drawIBounds);
// Cover up for any precision issues by outsetting the op bounds a pixel in each direction.
drawIBounds.outset(1, 1);
if (!clippedRect.intersect(drawIBounds)) {
#ifdef SK_DEBUG
- GrCapsDebugf(this->caps(), "setupDstTexture: Missed an early reject bailing on draw.");
+ GrCapsDebugf(this->caps(), "Missed an early reject. "
+ "Bailing on draw from setupDstTexture.\n");
#endif
- return false;
+ return;
}
// MSAA consideration: When there is support for reading MSAA samples in the shader we could
GrSurfaceDesc desc;
bool rectsMustMatch = false;
bool disallowSubrect = false;
- if (!this->caps()->initDescForDstCopy(rtProxy, &desc, &rectsMustMatch, &disallowSubrect)) {
- desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+ if (!this->caps()->initDescForDstCopy(rt, &desc, &rectsMustMatch, &disallowSubrect)) {
+ desc.fOrigin = kDefault_GrSurfaceOrigin;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fConfig = rtProxy->config();
+ desc.fConfig = rt->config();
}
if (!disallowSubrect) {
copyRect = clippedRect;
}
- SkIPoint dstPoint, dstOffset;
- SkBackingFit fit;
+ SkIPoint dstPoint;
+ SkIPoint dstOffset;
+ static const uint32_t kFlags = 0;
+ sk_sp<GrTexture> copy;
if (rectsMustMatch) {
- SkASSERT(desc.fOrigin == rtProxy->origin());
- desc.fWidth = rtProxy->width();
- desc.fHeight = rtProxy->height();
+ SkASSERT(desc.fOrigin == rt->origin());
+ desc.fWidth = rt->width();
+ desc.fHeight = rt->height();
dstPoint = {copyRect.fLeft, copyRect.fTop};
dstOffset = {0, 0};
- fit = SkBackingFit::kExact;
+ copy = fContext->resourceProvider()->createTexture(desc, SkBudgeted::kYes, kFlags);
} else {
desc.fWidth = copyRect.width();
desc.fHeight = copyRect.height();
dstPoint = {0, 0};
dstOffset = {copyRect.fLeft, copyRect.fTop};
- fit = SkBackingFit::kApprox;
- }
-
- sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeDeferredSurfaceContext(
- desc,
- fit,
- SkBudgeted::kYes);
- if (!sContext) {
- SkDebugf("setupDstTexture: surfaceContext creation failed.\n");
- return false;
+ copy.reset(fContext->resourceProvider()->createApproxTexture(desc, kFlags));
}
- if (!sContext->copy(rtProxy, copyRect, dstPoint)) {
- SkDebugf("setupDstTexture: copy failed.\n");
- return false;
- }
-
- GrTextureProxy* copyProxy = sContext->asTextureProxy();
- // MDB TODO: remove this instantiation once DstTexture is proxy-backed
- sk_sp<GrTexture> copy(sk_ref_sp(copyProxy->instantiate(fContext->resourceProvider())));
if (!copy) {
- SkDebugf("setupDstTexture: instantiation of copied texture failed.\n");
- return false;
+ SkDebugf("Failed to create temporary copy of destination texture.\n");
+ return;
}
+ this->getOpList()->copySurface(copy.get(), rt, copyRect, dstPoint);
dstTexture->setTexture(std::move(copy));
dstTexture->setOffset(dstOffset);
- return true;
}
uint32_t addLegacyMeshDrawOp(GrPipelineBuilder&&, const GrClip&,
std::unique_ptr<GrLegacyMeshDrawOp>);
- // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
- // be used by GrXferProcessor to access the destination color in 'result'. If the return
- // value is false then a texture copy could not be made.
- bool SK_WARN_UNUSED_RESULT setupDstTexture(GrRenderTargetProxy*,
- const GrClip&,
- const SkRect& opBounds,
- GrXferProcessor::DstTexture* result);
+ // Makes a copy of the dst if it is necessary for the draw and returns the texture that should
+ // be used by GrXferProcessor to access the destination color. If the texture is nullptr then
+ // a texture copy could not be made.
+ void setupDstTexture(GrRenderTarget*, const GrClip&, const SkRect& opBounds,
+ GrXferProcessor::DstTexture*);
+
GrRenderTargetOpList* getOpList();
////////////////////////////////////////////////////////////////////////////////
-bool GrRenderTargetOpList::copySurface(GrResourceProvider* resourceProvider,
- GrSurfaceProxy* dst,
- GrSurfaceProxy* src,
+bool GrRenderTargetOpList::copySurface(GrSurface* dst,
+ GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
- std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(resourceProvider, dst, src, srcRect, dstPoint);
+ std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(dst, src, srcRect, dstPoint);
if (!op) {
return false;
}
* depending on the type of surface, configs, etc, and the backend-specific
* limitations.
*/
- bool copySurface(GrResourceProvider* resourceProvider,
- GrSurfaceProxy* dst,
- GrSurfaceProxy* src,
+ bool copySurface(GrSurface* dst,
+ GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint);
fContext->contextPriv().flushSurfaceWrites(srcProxy);
#endif
+ // TODO: defer instantiation until flush time
+ sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->resourceProvider())));
+ if (!src) {
+ return false;
+ }
+
+ // TODO: this needs to be fixed up since it ends the deferrable of the GrTexture
+ sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->resourceProvider())));
+ if (!tex) {
+ return false;
+ }
+
GrTextureOpList* opList = this->getOpList();
- bool result = opList->copySurface(fContext->resourceProvider(),
- fTextureProxy.get(), srcProxy, srcRect, dstPoint);
+ bool result = opList->copySurface(tex.get(), src.get(), srcRect, dstPoint);
#ifndef ENABLE_MDB
GrOpFlushState flushState(fContext->getGpu(), nullptr);
////////////////////////////////////////////////////////////////////////////////
-bool GrTextureOpList::copySurface(GrResourceProvider* resourceProvider,
- GrSurfaceProxy* dst,
- GrSurfaceProxy* src,
+bool GrTextureOpList::copySurface(GrSurface* dst,
+ GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
- std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(resourceProvider, dst, src, srcRect, dstPoint);
+ std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make(dst, src, srcRect, dstPoint);
if (!op) {
return false;
}
* depending on the type of surface, configs, etc, and the backend-specific
* limitations.
*/
- bool copySurface(GrResourceProvider* resourceProvider,
- GrSurfaceProxy* dst,
- GrSurfaceProxy* src,
+ bool copySurface(GrSurface* dst,
+ GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint);
#include "GrGLRenderTarget.h"
#include "GrGLTexture.h"
#include "GrShaderCaps.h"
-#include "GrSurfaceProxyPriv.h"
#include "SkTSearch.h"
#include "SkTSort.h"
#include "instanced/GLInstancedRendering.h"
#endif
}
-bool GrGLCaps::initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
+bool GrGLCaps::initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const {
// By default, we don't require rects to match.
*rectsMustMatch = false;
// If the src is a texture, we can implement the blit as a draw assuming the config is
// renderable.
- if (src->asTextureProxy() && this->isConfigRenderable(src->config(), false)) {
- desc->fOrigin = kBottomLeft_GrSurfaceOrigin;
+ if (src->asTexture() && this->isConfigRenderable(src->config(), false)) {
+ desc->fOrigin = kDefault_GrSurfaceOrigin;
desc->fFlags = kRenderTarget_GrSurfaceFlag;
desc->fConfig = src->config();
return true;
}
- {
- // The only way we could see a non-GR_GL_TEXTURE_2D texture would be if it were
- // wrapped. In that case the proxy would already be instantiated.
- const GrTexture* srcTexture = src->priv().peekTexture();
- const GrGLTexture* glSrcTexture = static_cast<const GrGLTexture*>(srcTexture);
- if (glSrcTexture && glSrcTexture->target() != GR_GL_TEXTURE_2D) {
- // Not supported for FBO blit or CopyTexSubImage
- return false;
- }
+ const GrGLTexture* srcTexture = static_cast<const GrGLTexture*>(src->asTexture());
+ if (srcTexture && srcTexture->target() != GR_GL_TEXTURE_2D) {
+ // Not supported for FBO blit or CopyTexSubImage
+ return false;
}
// We look for opportunities to use CopyTexSubImage, or fbo blit. If neither are
return false;
}
- {
- bool srcIsMSAARenderbuffer = src->desc().fSampleCnt > 0 && this->usesMSAARenderBuffers();
- if (srcIsMSAARenderbuffer) {
- // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO
- // blit or fail.
- if (this->canConfigBeFBOColorAttachment(src->config())) {
- desc->fOrigin = originForBlitFramebuffer;
- desc->fConfig = src->config();
- *rectsMustMatch = rectsMustMatchForBlitFramebuffer;
- *disallowSubrect = disallowSubrectForBlitFramebuffer;
- return true;
- }
- return false;
+ const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src);
+ if (srcRT->renderFBOID() != srcRT->textureFBOID()) {
+ // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO blit or
+ // fail.
+ if (this->canConfigBeFBOColorAttachment(src->config())) {
+ desc->fOrigin = originForBlitFramebuffer;
+ desc->fConfig = src->config();
+ *rectsMustMatch = rectsMustMatchForBlitFramebuffer;
+ *disallowSubrect = disallowSubrectForBlitFramebuffer;
+ return true;
}
+ return false;
}
// We'll do a CopyTexSubImage. Make the dst a plain old texture.
return fRGBAToBGRAReadbackConversionsAreSlow;
}
- bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
- bool* rectsMustMatch, bool* disallowSubrect) const override;
+ bool initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc, bool* rectsMustMatch,
+ bool* disallowSubrect) const override;
private:
enum ExternalFormatUsage {
#include "GrCopySurfaceOp.h"
// returns true if the read/written rect intersects the src/dst and false if not.
-static bool clip_src_rect_and_dst_point(const GrSurfaceProxy* dst,
- const GrSurfaceProxy* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint,
- SkIRect* clippedSrcRect,
- SkIPoint* clippedDstPoint) {
+bool GrCopySurfaceOp::ClipSrcRectAndDstPoint(const GrSurface* dst,
+ const GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint,
+ SkIRect* clippedSrcRect,
+ SkIPoint* clippedDstPoint) {
*clippedSrcRect = srcRect;
*clippedDstPoint = dstPoint;
return !clippedSrcRect->isEmpty();
}
-std::unique_ptr<GrOp> GrCopySurfaceOp::Make(GrResourceProvider* resourceProvider,
- GrSurfaceProxy* dstProxy, GrSurfaceProxy* srcProxy,
- const SkIRect& srcRect,
+std::unique_ptr<GrOp> GrCopySurfaceOp::Make(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
const SkIPoint& dstPoint) {
- SkASSERT(dstProxy);
- SkASSERT(srcProxy);
- if (GrPixelConfigIsSint(dstProxy->config()) != GrPixelConfigIsSint(srcProxy->config())) {
+ SkASSERT(dst);
+ SkASSERT(src);
+ if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) {
return nullptr;
}
- if (GrPixelConfigIsCompressed(dstProxy->config())) {
+ if (GrPixelConfigIsCompressed(dst->config())) {
return nullptr;
}
SkIRect clippedSrcRect;
SkIPoint clippedDstPoint;
- // If the rect is outside the srcProxy or dstProxy then we've already succeeded.
- if (!clip_src_rect_and_dst_point(dstProxy, srcProxy, srcRect, dstPoint,
- &clippedSrcRect, &clippedDstPoint)) {
+ // If the rect is outside the src or dst then we've already succeeded.
+ if (!ClipSrcRectAndDstPoint(dst, src, srcRect, dstPoint, &clippedSrcRect, &clippedDstPoint)) {
return nullptr;
}
-
- // MDB TODO: remove this instantiation
- GrSurface* dstTex = dstProxy->instantiate(resourceProvider);
- if (!dstTex) {
- return nullptr;
- }
- GrSurface* srcTex = srcProxy->instantiate(resourceProvider);
- if (!srcTex) {
- return nullptr;
- }
-
- return std::unique_ptr<GrOp>(new GrCopySurfaceOp(dstTex, srcTex,
- dstProxy->uniqueID(), srcProxy->uniqueID(),
- clippedSrcRect, clippedDstPoint));
+ return std::unique_ptr<GrOp>(new GrCopySurfaceOp(dst, src, clippedSrcRect, clippedDstPoint));
}
#ifndef GrCopySurfaceOp_DEFINED
#define GrCopySurfaceOp_DEFINED
+#include "GrGpu.h"
#include "GrOp.h"
#include "GrOpFlushState.h"
+#include "GrRenderTarget.h"
class GrCopySurfaceOp final : public GrOp {
public:
DEFINE_OP_CLASS_ID
- // MDB TODO: remove the resourceProvider parameter
- static std::unique_ptr<GrOp> Make(GrResourceProvider*,
- GrSurfaceProxy* dst, GrSurfaceProxy* src,
- const SkIRect& srcRect,
+ /** This should not really be exposed as Create() will apply this clipping, but there is
+ * currently a workaround in GrContext::copySurface() for non-render target dsts that relies
+ * on it. */
+ static bool ClipSrcRectAndDstPoint(const GrSurface* dst,
+ const GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint,
+ SkIRect* clippedSrcRect,
+ SkIPoint* clippedDstPoint);
+
+ static std::unique_ptr<GrOp> Make(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
const SkIPoint& dstPoint);
const char* name() const override { return "CopySurface"; }
SkString dumpInfo() const override {
SkString string;
- string.printf("src: (proxyID: %d, rtID: %d), dst: (proxyID: %d, rtID: %d), "
- "srcRect: [L: %d, T: %d, R: %d, B: %d], dstPt: [X: %d, Y: %d]",
- fSrcProxyID.asUInt(), fSrc.get()->uniqueID().asUInt(),
- fDstProxyID.asUInt(), fDst.get()->uniqueID().asUInt(),
- fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
- fDstPoint.fX, fDstPoint.fY);
+ string.printf(
+ "SRC: 0x%p, DST: 0x%p, SRECT: [L: %d, T: %d, R: %d, B: %d], "
+ "DPT:[X: %d, Y: %d]",
+ fDst.get(), fSrc.get(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight,
+ fSrcRect.fBottom, fDstPoint.fX, fDstPoint.fY);
string.append(INHERITED::dumpInfo());
return string;
}
private:
- GrCopySurfaceOp(GrSurface* dst, GrSurface* src,
- GrSurfaceProxy::UniqueID dstID, GrSurfaceProxy::UniqueID srcID,
- const SkIRect& srcRect, const SkIPoint& dstPoint)
- : INHERITED(ClassID())
- , fDstProxyID(dstID)
- , fSrcProxyID(srcID)
- , fDst(dst)
- , fSrc(src)
- , fSrcRect(srcRect)
- , fDstPoint(dstPoint) {
+ GrCopySurfaceOp(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
+ const SkIPoint& dstPoint)
+ : INHERITED(ClassID()), fDst(dst), fSrc(src), fSrcRect(srcRect), fDstPoint(dstPoint) {
SkRect bounds =
SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
}
}
- // MDB TODO: remove the proxy IDs once the GrSurfaceProxy carries the ref since they will
- // be redundant
- GrSurfaceProxy::UniqueID fDstProxyID;
- GrSurfaceProxy::UniqueID fSrcProxyID;
GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst;
- GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
- SkIRect fSrcRect;
- SkIPoint fDstPoint;
+ GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
+ SkIRect fSrcRect;
+ SkIPoint fDstPoint;
typedef GrOp INHERITED;
};
*/
#include "GrVkCaps.h"
-#include "GrRenderTargetProxy.h"
+#include "GrRenderTarget.h"
#include "GrShaderCaps.h"
#include "GrVkUtil.h"
#include "vk/GrVkBackendContext.h"
this->init(contextOptions, vkInterface, physDev, featureFlags, extensionFlags);
}
-bool GrVkCaps::initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
+bool GrVkCaps::initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const {
// Vk doesn't use rectsMustMatch or disallowSubrect. Always return false.
*rectsMustMatch = false;
// render target as well.
desc->fOrigin = src->origin();
desc->fConfig = src->config();
- if (src->numColorSamples() > 1 || (src->asTextureProxy() && this->supportsCopiesAsDraws())) {
+ if (src->numColorSamples() > 1 || (src->asTexture() && this->supportsCopiesAsDraws())) {
desc->fFlags = kRenderTarget_GrSurfaceFlag;
} else {
// Just going to use CopyImage here
return fPreferedStencilFormat;
}
- bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
- bool* rectsMustMatch, bool* disallowSubrect) const override;
+ bool initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc, bool* rectsMustMatch,
+ bool* disallowSubrect) const override;
private:
enum VkVendor {
namespace {
static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
GrContext* context, int sampleCnt, int width, int height, GrPixelConfig config,
- GrSurfaceOrigin origin,
sk_sp<GrTexture>* backingSurface) {
GrSurfaceDesc backingDesc;
- backingDesc.fFlags = kRenderTarget_GrSurfaceFlag;
- backingDesc.fOrigin = origin;
- backingDesc.fWidth = width;
backingDesc.fHeight = height;
+ backingDesc.fWidth = width;
backingDesc.fConfig = config;
- backingDesc.fSampleCnt = sampleCnt;
+ backingDesc.fOrigin = kDefault_GrSurfaceOrigin;
+ backingDesc.fFlags = kRenderTarget_GrSurfaceFlag;
*backingSurface = context->resourceProvider()->createTexture(backingDesc, SkBudgeted::kNo);
GrBackendTextureDesc desc;
- desc.fFlags = kRenderTarget_GrBackendTextureFlag;
- desc.fOrigin = origin;
+ desc.fConfig = config;
desc.fWidth = width;
desc.fHeight = height;
- desc.fConfig = config;
- desc.fSampleCnt = sampleCnt;
+ desc.fFlags = kRenderTarget_GrBackendTextureFlag;
desc.fTextureHandle = (*backingSurface)->getTextureHandle();
+ desc.fSampleCnt = sampleCnt;
sk_sp<SkSurface> surface =
SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc, nullptr);
return surface;
};
struct TestCase {
- RectAndSamplePoint fRectAndPoints;
- SkRect fClip;
- int fSampleCnt;
- GrSurfaceOrigin fOrigin;
+ RectAndSamplePoint rectAndPoints;
+ SkRect clip;
+ int sampleCnt;
};
std::vector<TestCase> testCases;
- for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
- for (int sampleCnt : {0, 4}) {
- for (auto rectAndPoints : allRectsAndPoints) {
- for (auto clip : {SkRect::MakeXYWH(0, 0, 10, 10), SkRect::MakeXYWH(1, 1, 8, 8)}) {
- testCases.push_back({rectAndPoints, clip, sampleCnt, origin});
- }
+ for (int sampleCnt : {0, 4}) {
+ for (auto rectAndPoints : allRectsAndPoints) {
+ for (auto clip : {SkRect::MakeXYWH(0, 0, 10, 10), SkRect::MakeXYWH(1, 1, 8, 8)}) {
+ testCases.push_back({rectAndPoints, clip, sampleCnt});
}
}
}
// Run each test case:
for (auto testCase : testCases) {
- int sampleCnt = testCase.fSampleCnt;
- SkRect paintRect = testCase.fRectAndPoints.rect;
- SkIPoint outPoint = testCase.fRectAndPoints.outPoint;
- SkIPoint inPoint = testCase.fRectAndPoints.inPoint;
- GrSurfaceOrigin origin = testCase.fOrigin;
+ int sampleCnt = testCase.sampleCnt;
+ SkRect paintRect = testCase.rectAndPoints.rect;
+ SkIPoint outPoint = testCase.rectAndPoints.outPoint;
+ SkIPoint inPoint = testCase.rectAndPoints.inPoint;
sk_sp<GrTexture> backingSurface;
// BGRA forces a framebuffer blit on ES2.
sk_sp<SkSurface> surface = create_gpu_surface_backend_texture_as_render_target(
- context, sampleCnt, kWidth, kHeight, kConfig, origin, &backingSurface);
+ context, sampleCnt, kWidth, kHeight, kConfig, &backingSurface);
if (!surface && sampleCnt > 0) {
// Some platforms don't support MSAA.
// Fill our canvas with 0xFFFF80
SkCanvas* canvas = surface->getCanvas();
- canvas->clipRect(testCase.fClip, false);
+ canvas->clipRect(testCase.clip, false);
SkPaint black_paint;
black_paint.setColor(SkColorSetRGB(0xFF, 0xFF, 0x80));
canvas->drawRect(SkRect::MakeXYWH(0, 0, kWidth, kHeight), black_paint);
bool isConfigTexturable(GrPixelConfig config) const override { return false; }
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return false; }
bool canConfigBeImageStorage(GrPixelConfig) const override { return false; }
- bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
- bool* rectsMustMatch, bool* disallowSubrect) const override {
+ bool initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc, bool* rectsMustMatch,
+ bool* disallowSubrect) const override {
return false;
}