GrSurfaceContext not ref counted.
Also don't specify redundant width/height to SkGpuDevice. Change-Id: I389df5c4b073c2c05632ba6b7c95b02a22dfaf98 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235824 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
147b6642ac
commit
bf6b9795f6
@ -270,8 +270,8 @@ public:
|
||||
const int kDrawsPerLoop = 32;
|
||||
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 100, 100, GrColorType::kRGBA_8888, p3));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 100, 100, GrColorType::kRGBA_8888, p3);
|
||||
SkASSERT(rtc);
|
||||
|
||||
for (int j = 0; j < kDrawsPerLoop; ++j) {
|
||||
|
@ -228,7 +228,7 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
|
||||
const GrReducedClip& reducedClip, GrPaint&& paint) {
|
||||
const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2;
|
||||
const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2;
|
||||
sk_sp<GrRenderTargetContext> maskRTC(ctx->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
auto maskRTC(ctx->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, kCoverRect.width() + padRight, kCoverRect.height() + padBottom,
|
||||
GrColorType::kAlpha_8, nullptr));
|
||||
if (!maskRTC) {
|
||||
|
@ -61,14 +61,14 @@ protected:
|
||||
*/
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
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. */
|
||||
sk_sp<GrTextureContext> makeDeferredTextureContext(
|
||||
std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
@ -85,7 +85,7 @@ protected:
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
* renderTargetContexts created via this entry point.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -104,7 +104,7 @@ protected:
|
||||
* converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
|
||||
* SRGB-ness will be preserved.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
|
||||
std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -184,9 +184,9 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) {
|
||||
|
||||
GrOpMemoryPool* pool = ctx->priv().opMemoryPool();
|
||||
|
||||
sk_sp<GrRenderTargetContext> ccbuff = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, this->width(), this->height(), GrColorType::kAlpha_F16,
|
||||
nullptr);
|
||||
auto ccbuff = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
this->width(), this->height(),
|
||||
GrColorType::kAlpha_F16, nullptr);
|
||||
SkASSERT(ccbuff);
|
||||
ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT,
|
||||
GrRenderTargetContext::CanClearFullscreen::kYes);
|
||||
|
@ -878,17 +878,16 @@ sk_sp<GrTextureProxy> SkBlurMaskFilterImpl::filterMaskGPU(GrRecordingContext* co
|
||||
// If we're doing a normal blur, we can clobber the pathTexture in the
|
||||
// gaussianBlur. Otherwise, we need to save it for later compositing.
|
||||
bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
SkGpuBlurUtils::GaussianBlur(context,
|
||||
srcProxy,
|
||||
SkIPoint::Make(0, 0),
|
||||
nullptr,
|
||||
clipRect,
|
||||
SkIRect::EmptyIRect(),
|
||||
xformedSigma,
|
||||
xformedSigma,
|
||||
GrTextureDomain::kIgnore_Mode,
|
||||
kPremul_SkAlphaType));
|
||||
auto renderTargetContext = SkGpuBlurUtils::GaussianBlur(context,
|
||||
srcProxy,
|
||||
SkIPoint::Make(0, 0),
|
||||
nullptr,
|
||||
clipRect,
|
||||
SkIRect::EmptyIRect(),
|
||||
xformedSigma,
|
||||
xformedSigma,
|
||||
GrTextureDomain::kIgnore_Mode,
|
||||
kPremul_SkAlphaType);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -185,14 +185,14 @@ bool SkDeferredDisplayListRecorder::init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> c = fContext->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy),
|
||||
grColorType,
|
||||
kPremul_SkAlphaType,
|
||||
fCharacterization.refColorSpace(),
|
||||
&fCharacterization.surfaceProps());
|
||||
fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(),
|
||||
sk_ref_sp(c->asRenderTargetContext()));
|
||||
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());
|
||||
fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(), std::move(rtc));
|
||||
return SkToBool(fSurface.get());
|
||||
}
|
||||
|
||||
|
@ -105,24 +105,23 @@ static GrColorType get_blur_color_type(GrTextureProxy* proxy) {
|
||||
return GrPixelConfigToColorType(config);
|
||||
}
|
||||
|
||||
static sk_sp<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const SkIRect& srcBounds,
|
||||
const SkIPoint& srcOffset,
|
||||
int radiusX,
|
||||
int radiusY,
|
||||
SkScalar sigmaX,
|
||||
SkScalar sigmaY,
|
||||
GrTextureDomain::Mode mode,
|
||||
int finalW,
|
||||
int finalH,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit dstFit) {
|
||||
static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const SkIRect& srcBounds,
|
||||
const SkIPoint& srcOffset,
|
||||
int radiusX,
|
||||
int radiusY,
|
||||
SkScalar sigmaX,
|
||||
SkScalar sigmaY,
|
||||
GrTextureDomain::Mode mode,
|
||||
int finalW,
|
||||
int finalH,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit dstFit) {
|
||||
// TODO: Once GrPixelConfig is gone, we need will need the source's color type.
|
||||
GrColorType colorType = get_blur_color_type(proxy.get());
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext;
|
||||
renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
dstFit,
|
||||
finalW,
|
||||
finalH,
|
||||
@ -162,27 +161,26 @@ static sk_sp<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingContext* con
|
||||
// (which do impact destination decisions). Both functions incorporate the proxy offset into the
|
||||
// geometry they submit or before calling convolve_gaussian_1d.
|
||||
|
||||
static sk_sp<GrRenderTargetContext> convolve_gaussian(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const SkIPoint& proxyOffset,
|
||||
const SkIRect& srcRect,
|
||||
const SkIPoint& srcOffset,
|
||||
Direction direction,
|
||||
int radius,
|
||||
float sigma,
|
||||
SkIRect* contentRect,
|
||||
GrTextureDomain::Mode mode,
|
||||
int finalW,
|
||||
int finalH,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit fit) {
|
||||
static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> proxy,
|
||||
const SkIPoint& proxyOffset,
|
||||
const SkIRect& srcRect,
|
||||
const SkIPoint& srcOffset,
|
||||
Direction direction,
|
||||
int radius,
|
||||
float sigma,
|
||||
SkIRect* contentRect,
|
||||
GrTextureDomain::Mode mode,
|
||||
int finalW,
|
||||
int finalH,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit fit) {
|
||||
SkASSERT(srcRect.width() <= finalW && srcRect.height() <= finalH);
|
||||
|
||||
// TODO: Once GrPixelConfig is gone we'll need the source's color type here.
|
||||
GrColorType colorType = get_blur_color_type(proxy.get());
|
||||
|
||||
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
|
||||
dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
fit,
|
||||
srcRect.width(),
|
||||
srcRect.height(),
|
||||
@ -308,7 +306,7 @@ static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
|
||||
|
||||
SkIRect dstRect(srcRect);
|
||||
|
||||
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
|
||||
std::unique_ptr<GrRenderTargetContext> dstRenderTargetContext;
|
||||
|
||||
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
|
||||
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
|
||||
@ -404,15 +402,16 @@ static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
|
||||
// Expand the contents of 'srcRenderTargetContext' to fit in 'dstII'. At this point, we are
|
||||
// expanding an intermediate image, so there's no need to account for a proxy offset from the
|
||||
// original input.
|
||||
static sk_sp<GrRenderTargetContext> reexpand(GrRecordingContext* context,
|
||||
sk_sp<GrRenderTargetContext> srcRenderTargetContext,
|
||||
const SkIRect& localSrcBounds,
|
||||
int scaleFactorX, int scaleFactorY,
|
||||
GrTextureDomain::Mode mode,
|
||||
int finalW,
|
||||
int finalH,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit fit) {
|
||||
static std::unique_ptr<GrRenderTargetContext> reexpand(
|
||||
GrRecordingContext* context,
|
||||
std::unique_ptr<GrRenderTargetContext> srcRenderTargetContext,
|
||||
const SkIRect& localSrcBounds,
|
||||
int scaleFactorX, int scaleFactorY,
|
||||
GrTextureDomain::Mode mode,
|
||||
int finalW,
|
||||
int finalH,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit fit) {
|
||||
const SkIRect srcRect = SkIRect::MakeWH(srcRenderTargetContext->width(),
|
||||
srcRenderTargetContext->height());
|
||||
|
||||
@ -434,10 +433,9 @@ static sk_sp<GrRenderTargetContext> reexpand(GrRecordingContext* context,
|
||||
// TODO: Once GrPixelConfig is gone we'll need the source's color type here.
|
||||
GrColorType colorType = get_blur_color_type(srcProxy.get());
|
||||
|
||||
sk_sp<GrRenderTargetContext> dstRenderTargetContext =
|
||||
context->priv().makeDeferredRenderTargetContext(fit, finalW, finalH, colorType,
|
||||
std::move(finalCS), 1, GrMipMapped::kNo,
|
||||
srcProxy->origin());
|
||||
auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
fit, finalW, finalH, colorType, std::move(finalCS), 1, GrMipMapped::kNo,
|
||||
srcProxy->origin());
|
||||
if (!dstRenderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -476,17 +474,17 @@ static sk_sp<GrRenderTargetContext> reexpand(GrRecordingContext* context,
|
||||
|
||||
namespace SkGpuBlurUtils {
|
||||
|
||||
sk_sp<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> srcProxy,
|
||||
const SkIPoint& proxyOffset,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkIRect& dstBounds,
|
||||
const SkIRect& srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
GrTextureDomain::Mode mode,
|
||||
SkAlphaType at,
|
||||
SkBackingFit fit) {
|
||||
std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> srcProxy,
|
||||
const SkIPoint& proxyOffset,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkIRect& dstBounds,
|
||||
const SkIRect& srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
GrTextureDomain::Mode mode,
|
||||
SkAlphaType at,
|
||||
SkBackingFit fit) {
|
||||
SkASSERT(context);
|
||||
|
||||
TRACE_EVENT2("skia.gpu", "GaussianBlur", "sigmaX", sigmaX, "sigmaY", sigmaY);
|
||||
@ -537,7 +535,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
|
||||
std::unique_ptr<GrRenderTargetContext> dstRenderTargetContext;
|
||||
|
||||
auto srcRect = SkIRect::MakeWH(finalW, finalH);
|
||||
scale_irect_roundout(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
|
||||
@ -598,7 +596,6 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
|
||||
SkASSERT(!dstRenderTargetContext || dstRenderTargetContext->origin() == srcProxy->origin());
|
||||
return dstRenderTargetContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -42,18 +42,17 @@ namespace SkGpuBlurUtils {
|
||||
* @param fit backing fit for the returned render target context
|
||||
* @return The renderTargetContext containing the blurred result.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> GaussianBlur(
|
||||
GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> src,
|
||||
const SkIPoint& proxyOffset,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkIRect& dstBounds,
|
||||
const SkIRect& srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
GrTextureDomain::Mode mode,
|
||||
SkAlphaType at,
|
||||
SkBackingFit fit = SkBackingFit::kApprox);
|
||||
std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> src,
|
||||
const SkIPoint& proxyOffset,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkIRect& dstBounds,
|
||||
const SkIRect& srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
GrTextureDomain::Mode mode,
|
||||
SkAlphaType at,
|
||||
SkBackingFit fit = SkBackingFit::kApprox);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -413,19 +413,18 @@ sk_sp<SkSpecialImage> SkImageFilter_Base::DrawWithFP(GrRecordingContext* context
|
||||
paint.addColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox,
|
||||
bounds.width(),
|
||||
bounds.height(),
|
||||
SkColorTypeToGrColorType(colorType),
|
||||
sk_ref_sp(colorSpace),
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected));
|
||||
auto renderTargetContext =
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
bounds.width(),
|
||||
bounds.height(),
|
||||
SkColorTypeToGrColorType(colorType),
|
||||
sk_ref_sp(colorSpace),
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ public:
|
||||
if (!rec) {
|
||||
return false;
|
||||
}
|
||||
sk_sp<GrSurfaceContext> sContext = fContext->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = fContext->priv().makeWrappedSurfaceContext(
|
||||
fTextureProxy, GrPixelConfigToColorType(fTextureProxy->config()), this->alphaType(),
|
||||
fColorSpace);
|
||||
if (!sContext) {
|
||||
|
@ -117,54 +117,46 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/private/GrRecordingContext.h"
|
||||
#include "src/core/SkMakeUnique.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/SkGpuDevice.h"
|
||||
|
||||
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
|
||||
public:
|
||||
SkSpecialSurface_Gpu(GrRecordingContext* context,
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext,
|
||||
std::unique_ptr<GrRenderTargetContext> renderTargetContext,
|
||||
int width, int height, const SkIRect& subset)
|
||||
: INHERITED(subset, &renderTargetContext->surfaceProps())
|
||||
, fRenderTargetContext(std::move(renderTargetContext)) {
|
||||
|
||||
: INHERITED(subset, &renderTargetContext->surfaceProps())
|
||||
, fProxy(renderTargetContext->asTextureProxyRef()) {
|
||||
// CONTEXT TODO: remove this use of 'backdoor' to create an SkGpuDevice
|
||||
sk_sp<SkBaseDevice> device(SkGpuDevice::Make(context->priv().backdoor(),
|
||||
fRenderTargetContext, width, height,
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
auto device = SkGpuDevice::Make(context->priv().backdoor(), std::move(renderTargetContext),
|
||||
SkGpuDevice::kUninit_InitContents);
|
||||
if (!device) {
|
||||
return;
|
||||
}
|
||||
|
||||
fCanvas.reset(new SkCanvas(device));
|
||||
fCanvas.reset(new SkCanvas(std::move(device)));
|
||||
fCanvas->clipRect(SkRect::Make(subset));
|
||||
#ifdef SK_IS_BOT
|
||||
fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness
|
||||
#endif
|
||||
}
|
||||
|
||||
~SkSpecialSurface_Gpu() override { }
|
||||
|
||||
sk_sp<SkSpecialImage> onMakeImageSnapshot() override {
|
||||
if (!fRenderTargetContext->asTextureProxy()) {
|
||||
if (!fProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeDeferredFromGpu(
|
||||
fCanvas->getGrContext(),
|
||||
this->subset(),
|
||||
kNeedNewImageUniqueID_SpecialImage,
|
||||
fRenderTargetContext->asTextureProxyRef(),
|
||||
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
|
||||
&this->props()));
|
||||
fRenderTargetContext = nullptr;
|
||||
return tmp;
|
||||
return SkSpecialImage::MakeDeferredFromGpu(fCanvas->getGrContext(),
|
||||
this->subset(),
|
||||
kNeedNewImageUniqueID_SpecialImage,
|
||||
std::move(fProxy),
|
||||
fCanvas->imageInfo().refColorSpace(),
|
||||
&this->props());
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<GrRenderTargetContext> fRenderTargetContext;
|
||||
|
||||
sk_sp<GrTextureProxy> fProxy;
|
||||
typedef SkSpecialSurface_Base INHERITED;
|
||||
};
|
||||
|
||||
@ -176,10 +168,9 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrRecordingContext* c
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, width, height, colorType, std::move(colorSpace), 1,
|
||||
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, width, height, colorType, std::move(colorSpace), 1,
|
||||
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -103,10 +103,8 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context,
|
||||
const SkMatrix& inMatrix,
|
||||
const SkIRect& bounds) const {
|
||||
sk_sp<GrRenderTargetContext> rtContext(
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8,
|
||||
nullptr));
|
||||
auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8, nullptr);
|
||||
if (!rtContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -401,19 +401,18 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
|
||||
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox,
|
||||
bounds.width(),
|
||||
bounds.height(),
|
||||
ctx.grColorType(),
|
||||
ctx.refColorSpace(),
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected));
|
||||
auto renderTargetContext =
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
bounds.width(),
|
||||
bounds.height(),
|
||||
ctx.grColorType(),
|
||||
ctx.refColorSpace(),
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -649,17 +649,17 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
|
||||
}
|
||||
|
||||
// TODO (michaelludwig) - The color space choice is odd, should it just be ctx.refColorSpace()?
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(SkGpuBlurUtils::GaussianBlur(
|
||||
context,
|
||||
std::move(inputTexture),
|
||||
input->subset().topLeft(),
|
||||
ctx.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,
|
||||
dstBounds,
|
||||
inputBounds,
|
||||
sigma.x(),
|
||||
sigma.y(),
|
||||
to_texture_domain_mode(fTileMode),
|
||||
input->alphaType()));
|
||||
auto renderTargetContext = SkGpuBlurUtils::GaussianBlur(
|
||||
context,
|
||||
std::move(inputTexture),
|
||||
input->subset().topLeft(),
|
||||
ctx.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,
|
||||
dstBounds,
|
||||
inputBounds,
|
||||
sigma.x(),
|
||||
sigma.y(),
|
||||
to_texture_domain_mode(fTileMode),
|
||||
input->alphaType());
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
|
||||
SkMatrix matrix;
|
||||
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
auto renderTargetContext =
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
bounds.width(),
|
||||
bounds.height(),
|
||||
@ -374,7 +374,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected));
|
||||
isProtected);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -480,19 +480,18 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
|
||||
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
|
||||
SkASSERT(inputProxy);
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox,
|
||||
offsetBounds.width(),
|
||||
offsetBounds.height(),
|
||||
ctx.grColorType(),
|
||||
ctx.refColorSpace(),
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
inputProxy->isProtected() ? GrProtected::kYes : GrProtected::kNo));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox,
|
||||
offsetBounds.width(),
|
||||
offsetBounds.height(),
|
||||
ctx.grColorType(),
|
||||
ctx.refColorSpace(),
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
inputProxy->isProtected() ? GrProtected::kYes : GrProtected::kNo);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
|
||||
SkASSERT(radius.width() > 0 || radius.height() > 0);
|
||||
|
||||
if (radius.fWidth > 0) {
|
||||
sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
|
||||
auto dstRTContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox,
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
@ -570,7 +570,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo));
|
||||
srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo);
|
||||
if (!dstRTContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -587,7 +587,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
|
||||
srcRect = dstRect;
|
||||
}
|
||||
if (radius.fHeight > 0) {
|
||||
sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
|
||||
auto dstRTContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox,
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
@ -598,7 +598,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
|
||||
kBottomLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo));
|
||||
srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo);
|
||||
if (!dstRTContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -305,10 +305,9 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
|
||||
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(),
|
||||
ctx.refColorSpace()));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(),
|
||||
ctx.refColorSpace());
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -174,11 +174,9 @@ static sk_sp<GrTextureProxy> create_mask_GPU(GrRecordingContext* context,
|
||||
const SkMatrix& origViewMatrix,
|
||||
const GrShape& shape,
|
||||
int sampleCnt) {
|
||||
sk_sp<GrRenderTargetContext> rtContext(
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kApprox, maskRect.width(), maskRect.height(),
|
||||
GrColorType::kAlpha_8, nullptr, sampleCnt, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin));
|
||||
auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kApprox, maskRect.width(), maskRect.height(), GrColorType::kAlpha_8,
|
||||
nullptr, sampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
|
||||
if (!rtContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -356,18 +356,17 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrRecordingContext* c
|
||||
}
|
||||
|
||||
auto isProtected = proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo;
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
|
||||
reducedClip.width(),
|
||||
reducedClip.height(),
|
||||
GrColorType::kAlpha_8,
|
||||
nullptr,
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
|
||||
reducedClip.width(),
|
||||
reducedClip.height(),
|
||||
GrColorType::kAlpha_8,
|
||||
nullptr,
|
||||
1,
|
||||
GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
nullptr,
|
||||
SkBudgeted::kYes,
|
||||
isProtected);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -48,31 +48,33 @@ void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBO
|
||||
fContext->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
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);
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> GrContextPriv::makeDeferredTextureContext(SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
std::unique_ptr<GrTextureContext> GrContextPriv::makeDeferredTextureContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
return fContext->makeDeferredTextureContext(fit, width, height, colorType, alphaType,
|
||||
std::move(colorSpace), mipMapped, origin, budgeted,
|
||||
isProtected);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -89,7 +91,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
|
||||
origin, surfaceProps, budgeted, isProtected);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit fit, int width, int height, GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted) {
|
||||
@ -98,11 +100,12 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithF
|
||||
surfaceProps, budgeted);
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
std::unique_ptr<GrTextureContext> 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(
|
||||
@ -115,7 +118,7 @@ sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackend
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
int sampleCnt,
|
||||
@ -138,7 +141,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetContext(
|
||||
const GrBackendRenderTarget& backendRT,
|
||||
GrSurfaceOrigin origin,
|
||||
GrColorType colorType,
|
||||
@ -158,13 +161,13 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC
|
||||
std::move(colorSpace), surfaceProps);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRenderTargetContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
int sampleCnt,
|
||||
GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
std::unique_ptr<GrRenderTargetContext>
|
||||
GrContextPriv::makeBackendTextureAsRenderTargetRenderTargetContext(const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
int sampleCnt,
|
||||
GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
SkASSERT(sampleCnt > 0);
|
||||
sk_sp<GrSurfaceProxy> proxy(
|
||||
@ -178,7 +181,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetContext(
|
||||
const SkImageInfo& imageInfo, const GrVkDrawableInfo& vkInfo, const SkSurfaceProps* props) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
sk_sp<GrSurfaceProxy> proxy(
|
||||
|
@ -73,14 +73,14 @@ public:
|
||||
*/
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
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. */
|
||||
sk_sp<GrTextureContext> makeDeferredTextureContext(
|
||||
std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
@ -97,7 +97,7 @@ public:
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
* renderTargetContexts created via this entry point.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -116,7 +116,7 @@ public:
|
||||
* converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
|
||||
* SRGB-ness will be preserved.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
|
||||
std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -135,17 +135,17 @@ public:
|
||||
*/
|
||||
static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&);
|
||||
|
||||
sk_sp<GrTextureContext> makeBackendTextureContext(const GrBackendTexture&,
|
||||
GrSurfaceOrigin,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>);
|
||||
std::unique_ptr<GrTextureContext> 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);
|
||||
|
||||
sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
int sampleCnt,
|
||||
@ -155,7 +155,7 @@ public:
|
||||
ReleaseProc = nullptr,
|
||||
ReleaseContext = nullptr);
|
||||
|
||||
sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
|
||||
const GrBackendRenderTarget&,
|
||||
GrSurfaceOrigin origin,
|
||||
GrColorType,
|
||||
@ -164,7 +164,7 @@ public:
|
||||
ReleaseProc = nullptr,
|
||||
ReleaseContext = nullptr);
|
||||
|
||||
sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
int sampleCnt,
|
||||
@ -172,7 +172,7 @@ public:
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext(
|
||||
const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr);
|
||||
|
||||
/**
|
||||
|
@ -281,11 +281,11 @@ GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxies[], int num
|
||||
if (!fOnFlushCBObjects.empty()) {
|
||||
fDAG.gatherIDs(&fFlushingRenderTaskIDs);
|
||||
|
||||
SkSTArray<4, sk_sp<GrRenderTargetContext>> renderTargetContexts;
|
||||
SkSTArray<4, std::unique_ptr<GrRenderTargetContext>> renderTargetContexts;
|
||||
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
|
||||
onFlushCBObject->preFlush(&onFlushProvider, fFlushingRenderTaskIDs.begin(),
|
||||
fFlushingRenderTaskIDs.count(), &renderTargetContexts);
|
||||
for (const sk_sp<GrRenderTargetContext>& rtc : renderTargetContexts) {
|
||||
for (const auto& rtc : renderTargetContexts) {
|
||||
sk_sp<GrRenderTargetOpList> onFlushOpList = sk_ref_sp(rtc->getRTOpList());
|
||||
if (!onFlushOpList) {
|
||||
continue; // Odd - but not a big deal
|
||||
@ -794,7 +794,7 @@ void GrDrawingManager::flushIfNecessary() {
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
|
||||
sk_sp<GrSurfaceProxy> sProxy,
|
||||
GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
@ -813,18 +813,20 @@ sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
|
||||
|
||||
sk_sp<GrRenderTargetProxy> renderTargetProxy(sk_ref_sp(sProxy->asRenderTargetProxy()));
|
||||
|
||||
return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext,
|
||||
std::move(renderTargetProxy),
|
||||
colorType,
|
||||
std::move(colorSpace),
|
||||
surfaceProps,
|
||||
managedOpList));
|
||||
return std::unique_ptr<GrRenderTargetContext>(
|
||||
new GrRenderTargetContext(fContext,
|
||||
std::move(renderTargetProxy),
|
||||
colorType,
|
||||
std::move(colorSpace),
|
||||
surfaceProps,
|
||||
managedOpList));
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
std::unique_ptr<GrTextureContext> GrDrawingManager::makeTextureContext(
|
||||
sk_sp<GrSurfaceProxy> sProxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
if (this->wasAbandoned() || !sProxy->asTextureProxy()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -841,9 +843,6 @@ sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProx
|
||||
|
||||
sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
|
||||
|
||||
return sk_sp<GrTextureContext>(new GrTextureContext(fContext,
|
||||
std::move(textureProxy),
|
||||
colorType,
|
||||
alphaType,
|
||||
std::move(colorSpace)));
|
||||
return std::unique_ptr<GrTextureContext>(new GrTextureContext(
|
||||
fContext, std::move(textureProxy), colorType, alphaType, std::move(colorSpace)));
|
||||
}
|
||||
|
@ -37,15 +37,15 @@ public:
|
||||
|
||||
void freeGpuResources();
|
||||
|
||||
sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
|
||||
std::unique_ptr<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps*,
|
||||
bool managedOpList = true);
|
||||
std::unique_ptr<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps*,
|
||||
bool managedOpList = true);
|
||||
sk_sp<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>);
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
||||
// A managed opList is controlled by the drawing manager (i.e., sorted & flushed with the
|
||||
// others). An unmanaged one is created and used by the onFlushCallback.
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
@ -27,8 +27,8 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(fDrawingMgr->makeRenderTargetContext(
|
||||
std::move(proxy), colorType, std::move(colorSpace), props, false));
|
||||
auto renderTargetContext = fDrawingMgr->makeRenderTargetContext(
|
||||
std::move(proxy), colorType, std::move(colorSpace), props, false);
|
||||
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
|
@ -37,9 +37,8 @@ public:
|
||||
* callback. The callback should return the render target contexts used to render the atlases
|
||||
* in 'results'.
|
||||
*/
|
||||
virtual void preFlush(GrOnFlushResourceProvider*,
|
||||
const uint32_t* opListIDs, int numOpListIDs,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>* results) = 0;
|
||||
virtual void preFlush(GrOnFlushResourceProvider*, const uint32_t* opListIDs, int numOpListIDs,
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* results) = 0;
|
||||
|
||||
/**
|
||||
* Called once flushing is complete and all ops indicated by preFlush have been executed and
|
||||
@ -66,10 +65,10 @@ class GrOnFlushResourceProvider {
|
||||
public:
|
||||
explicit GrOnFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
|
||||
|
||||
sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps*);
|
||||
std::unique_ptr<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps*);
|
||||
|
||||
// Proxy unique key management. See GrProxyProvider.h.
|
||||
bool assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
|
||||
|
@ -143,7 +143,7 @@ void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlu
|
||||
this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
@ -165,7 +165,7 @@ sk_sp<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
|
||||
std::unique_ptr<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -208,7 +208,7 @@ sk_sp<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -253,7 +253,7 @@ sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext
|
||||
|
||||
auto drawingManager = this->drawingManager();
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext = drawingManager->makeRenderTargetContext(
|
||||
auto renderTargetContext = drawingManager->makeRenderTargetContext(
|
||||
std::move(rtp), colorType, std::move(colorSpace), surfaceProps);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
@ -285,20 +285,20 @@ static inline GrColorType color_type_fallback(GrColorType ct) {
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
int sampleCnt,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
std::unique_ptr<GrRenderTargetContext>
|
||||
GrRecordingContext::makeDeferredRenderTargetContextWithFallback(SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
GrColorType colorType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
int sampleCnt,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
SkASSERT(sampleCnt > 0);
|
||||
sk_sp<GrRenderTargetContext> rtc;
|
||||
std::unique_ptr<GrRenderTargetContext> rtc;
|
||||
do {
|
||||
rtc = this->makeDeferredRenderTargetContext(fit, width, height, colorType, colorSpace,
|
||||
sampleCnt, mipMapped, origin, surfaceProps,
|
||||
@ -325,7 +325,7 @@ void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* o
|
||||
fContext->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
@ -335,7 +335,7 @@ sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
|
||||
std::unique_ptr<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -351,7 +351,7 @@ sk_sp<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
|
||||
isProtected);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -368,7 +368,8 @@ sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetCon
|
||||
origin, surfaceProps, budgeted, isProtected);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback(
|
||||
std::unique_ptr<GrRenderTargetContext>
|
||||
GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -57,14 +57,14 @@ public:
|
||||
*/
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
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. */
|
||||
sk_sp<GrTextureContext> makeDeferredTextureContext(
|
||||
std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
@ -81,7 +81,7 @@ public:
|
||||
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
|
||||
* renderTargetContexts created via this entry point.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -100,7 +100,7 @@ public:
|
||||
* converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
|
||||
* SRGB-ness will be preserved.
|
||||
*/
|
||||
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
|
||||
std::unique_ptr<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -1602,17 +1602,17 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc;
|
||||
std::unique_ptr<GrRenderTargetContext> tempRTC;
|
||||
int x = srcRect.fLeft;
|
||||
int y = srcRect.fTop;
|
||||
if (needsRescale) {
|
||||
rtc = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
|
||||
if (!rtc) {
|
||||
tempRTC = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
|
||||
if (!tempRTC) {
|
||||
callback(context, nullptr, 0);
|
||||
return;
|
||||
}
|
||||
SkASSERT(SkColorSpace::Equals(rtc->colorSpaceInfo().colorSpace(), info.colorSpace()));
|
||||
SkASSERT(rtc->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
SkASSERT(SkColorSpace::Equals(tempRTC->colorSpaceInfo().colorSpace(), info.colorSpace()));
|
||||
SkASSERT(tempRTC->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
x = y = 0;
|
||||
} else {
|
||||
sk_sp<GrColorSpaceXform> xform =
|
||||
@ -1640,24 +1640,23 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
|
||||
}
|
||||
srcRectToDraw = SkRect::MakeWH(srcRect.width(), srcRect.height());
|
||||
}
|
||||
rtc = direct->priv().makeDeferredRenderTargetContext(
|
||||
tempRTC = direct->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, srcRect.width(), srcRect.height(),
|
||||
this->colorSpaceInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
if (!rtc) {
|
||||
if (!tempRTC) {
|
||||
callback(context, nullptr, 0);
|
||||
return;
|
||||
}
|
||||
rtc->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
|
||||
SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
|
||||
SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
|
||||
GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
|
||||
std::move(xform));
|
||||
tempRTC->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
|
||||
SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
|
||||
SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
|
||||
GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
|
||||
SkMatrix::I(), std::move(xform));
|
||||
x = y = 0;
|
||||
} else {
|
||||
rtc = sk_ref_sp(this);
|
||||
}
|
||||
}
|
||||
auto rtc = tempRTC ? tempRTC.get() : this;
|
||||
return rtc->asyncReadPixels(SkIRect::MakeXYWH(x, y, info.width(), info.height()),
|
||||
info.colorType(), callback, context);
|
||||
}
|
||||
@ -1740,20 +1739,20 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(
|
||||
}
|
||||
int x = srcRect.fLeft;
|
||||
int y = srcRect.fTop;
|
||||
auto rtc = sk_ref_sp(this);
|
||||
std::unique_ptr<GrRenderTargetContext> tempRTC;
|
||||
bool needsRescale = srcRect.width() != dstW || srcRect.height() != dstH;
|
||||
if (needsRescale) {
|
||||
// We assume the caller wants kPremul. There is no way to indicate a preference.
|
||||
auto info = SkImageInfo::Make(dstW, dstH, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
|
||||
dstColorSpace);
|
||||
// TODO: Incorporate the YUV conversion into last pass of rescaling.
|
||||
rtc = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
|
||||
if (!rtc) {
|
||||
tempRTC = this->rescale(info, srcRect, rescaleGamma, rescaleQuality);
|
||||
if (!tempRTC) {
|
||||
callback(context, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
SkASSERT(SkColorSpace::Equals(rtc->colorSpaceInfo().colorSpace(), info.colorSpace()));
|
||||
SkASSERT(rtc->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
SkASSERT(SkColorSpace::Equals(tempRTC->colorSpaceInfo().colorSpace(), info.colorSpace()));
|
||||
SkASSERT(tempRTC->origin() == kTopLeft_GrSurfaceOrigin);
|
||||
x = y = 0;
|
||||
} else {
|
||||
// We assume the caller wants kPremul. There is no way to indicate a preference.
|
||||
@ -1768,22 +1767,22 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(
|
||||
return;
|
||||
}
|
||||
SkRect srcRectToDraw = SkRect::Make(srcRect);
|
||||
rtc = direct->priv().makeDeferredRenderTargetContext(
|
||||
tempRTC = direct->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, dstW, dstH, this->colorSpaceInfo().colorType(),
|
||||
dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
|
||||
if (!rtc) {
|
||||
if (!tempRTC) {
|
||||
callback(context, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
rtc->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
|
||||
SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
|
||||
SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
|
||||
GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
|
||||
std::move(xform));
|
||||
tempRTC->drawTexture(GrNoClip(), std::move(texProxy), GrSamplerState::Filter::kNearest,
|
||||
SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
|
||||
SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
|
||||
GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
|
||||
SkMatrix::I(), std::move(xform));
|
||||
x = y = 0;
|
||||
}
|
||||
}
|
||||
auto srcProxy = rtc->asTextureProxyRef();
|
||||
auto srcProxy = tempRTC ? tempRTC->asTextureProxyRef() : this->asTextureProxyRef();
|
||||
// TODO: Do something if the input is not a texture already.
|
||||
if (!srcProxy) {
|
||||
callback(context, nullptr, nullptr);
|
||||
|
@ -194,7 +194,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
|
||||
// care about is that it is not converted. So we use the same alpha type for the data
|
||||
// and the surface context.
|
||||
static constexpr auto kAlphaType = kUnpremul_SkAlphaType;
|
||||
sk_sp<GrSurfaceContext> sContext =
|
||||
auto sContext =
|
||||
context->priv().makeWrappedSurfaceContext(std::move(proxy), srcColorType, kAlphaType);
|
||||
if (!sContext) {
|
||||
return nullptr;
|
||||
|
@ -136,7 +136,7 @@ bool GrSurfaceContext::readPixels(const GrPixelInfo& origDstInfo, void* dst, siz
|
||||
sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr
|
||||
: this->colorSpaceInfo().refColorSpace();
|
||||
|
||||
sk_sp<GrRenderTargetContext> tempCtx = direct->priv().makeDeferredRenderTargetContext(
|
||||
auto tempCtx = direct->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), colorType, std::move(cs),
|
||||
1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes);
|
||||
if (!tempCtx) {
|
||||
@ -428,10 +428,11 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S
|
||||
return this->getOpList()->copySurface(fContext, src, srcRect, dstPoint);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrSurfaceContext::rescale(const SkImageInfo& info,
|
||||
const SkIRect& srcRect,
|
||||
SkSurface::RescaleGamma rescaleGamma,
|
||||
SkFilterQuality rescaleQuality) {
|
||||
std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
|
||||
const SkImageInfo& info,
|
||||
const SkIRect& srcRect,
|
||||
SkSurface::RescaleGamma rescaleGamma,
|
||||
SkFilterQuality rescaleQuality) {
|
||||
auto direct = fContext->priv().asDirectContext();
|
||||
if (!direct) {
|
||||
return nullptr;
|
||||
@ -477,7 +478,11 @@ sk_sp<GrRenderTargetContext> GrSurfaceContext::rescale(const SkImageInfo& info,
|
||||
stepsY = sy != 1.f;
|
||||
}
|
||||
SkASSERT(stepsX || stepsY);
|
||||
auto currCtx = sk_ref_sp(this);
|
||||
// Within a rescaling pass A is the input (if not null) and B is the output. At the end of the
|
||||
// pass B is moved to A. If 'this' is the input on the first pass then tempA is null.
|
||||
std::unique_ptr<GrRenderTargetContext> tempA;
|
||||
std::unique_ptr<GrRenderTargetContext> tempB;
|
||||
|
||||
// Assume we should ignore the rescale linear request if the surface has no color space since
|
||||
// it's unclear how we'd linearize from an unknown color space.
|
||||
if (rescaleGamma == SkSurface::kLinear && this->colorSpaceInfo().colorSpace() &&
|
||||
@ -498,7 +503,7 @@ sk_sp<GrRenderTargetContext> GrSurfaceContext::rescale(const SkImageInfo& info,
|
||||
SkRect::MakeWH(srcW, srcH), GrAA::kNo, GrQuadAAFlags::kNone,
|
||||
constraint, SkMatrix::I(), std::move(xform));
|
||||
texProxy = linearRTC->asTextureProxyRef();
|
||||
currCtx = std::move(linearRTC);
|
||||
tempA = std::move(linearRTC);
|
||||
srcX = 0;
|
||||
srcY = 0;
|
||||
constraint = SkCanvas::kFast_SrcRectConstraint;
|
||||
@ -524,23 +529,23 @@ sk_sp<GrRenderTargetContext> GrSurfaceContext::rescale(const SkImageInfo& info,
|
||||
}
|
||||
--stepsY;
|
||||
}
|
||||
GrColorType colorType = currCtx->colorSpaceInfo().colorType();
|
||||
auto cs = currCtx->colorSpaceInfo().refColorSpace();
|
||||
auto input = tempA ? tempA.get() : this;
|
||||
GrColorType colorType = input->colorSpaceInfo().colorType();
|
||||
auto cs = input->colorSpaceInfo().refColorSpace();
|
||||
sk_sp<GrColorSpaceXform> xform;
|
||||
auto prevAlphaType = currCtx->colorSpaceInfo().alphaType();
|
||||
auto prevAlphaType = input->colorSpaceInfo().alphaType();
|
||||
if (!stepsX && !stepsY) {
|
||||
// Might as well fold conversion to final info in the last step.
|
||||
cs = info.refColorSpace();
|
||||
colorType = SkColorTypeToGrColorType(info.colorType());
|
||||
xform = GrColorSpaceXform::Make(currCtx->colorSpaceInfo().colorSpace(),
|
||||
currCtx->colorSpaceInfo().alphaType(), cs.get(),
|
||||
xform = GrColorSpaceXform::Make(input->colorSpaceInfo().colorSpace(),
|
||||
input->colorSpaceInfo().alphaType(), cs.get(),
|
||||
info.alphaType());
|
||||
}
|
||||
auto currRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
tempB = fContext->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, nextW, nextH, colorType, std::move(cs), 1, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
currCtx = currRTC;
|
||||
if (!currCtx) {
|
||||
if (!tempB) {
|
||||
return nullptr;
|
||||
}
|
||||
auto dstRect = SkRect::MakeWH(nextW, nextH);
|
||||
@ -567,24 +572,25 @@ sk_sp<GrRenderTargetContext> GrSurfaceContext::rescale(const SkImageInfo& info,
|
||||
GrPaint paint;
|
||||
paint.addColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
currRTC->fillRectToRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), dstRect,
|
||||
tempB->fillRectToRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), dstRect,
|
||||
dstRect);
|
||||
} else {
|
||||
auto filter = rescaleQuality == kNone_SkFilterQuality ? GrSamplerState::Filter::kNearest
|
||||
: GrSamplerState::Filter::kBilerp;
|
||||
auto srcSubset = SkRect::MakeXYWH(srcX, srcY, srcW, srcH);
|
||||
currRTC->drawTexture(GrNoClip(), texProxy, filter, SkBlendMode::kSrc, SK_PMColor4fWHITE,
|
||||
tempB->drawTexture(GrNoClip(), texProxy, filter, SkBlendMode::kSrc, SK_PMColor4fWHITE,
|
||||
srcSubset, dstRect, GrAA::kNo, GrQuadAAFlags::kNone, constraint,
|
||||
SkMatrix::I(), std::move(xform));
|
||||
}
|
||||
texProxy = currCtx->asTextureProxyRef();
|
||||
texProxy = tempB->asTextureProxyRef();
|
||||
tempA = std::move(tempB);
|
||||
srcX = srcY = 0;
|
||||
srcW = nextW;
|
||||
srcH = nextH;
|
||||
constraint = SkCanvas::kFast_SrcRectConstraint;
|
||||
}
|
||||
SkASSERT(currCtx);
|
||||
return sk_ref_sp(currCtx->asRenderTargetContext());
|
||||
SkASSERT(tempA);
|
||||
return tempA;
|
||||
}
|
||||
|
||||
GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorType dstCT,
|
||||
|
@ -34,9 +34,9 @@ struct SkIRect;
|
||||
/**
|
||||
* A helper object to orchestrate commands for a particular surface
|
||||
*/
|
||||
class SK_API GrSurfaceContext : public SkRefCnt {
|
||||
class SK_API GrSurfaceContext {
|
||||
public:
|
||||
~GrSurfaceContext() override {}
|
||||
virtual ~GrSurfaceContext() = default;
|
||||
|
||||
const GrColorSpaceInfo& colorSpaceInfo() const { return fColorSpaceInfo; }
|
||||
|
||||
@ -118,9 +118,9 @@ protected:
|
||||
GrRecordingContext* fContext;
|
||||
|
||||
// The rescaling step of asyncRescaleAndReadPixels[YUV420]().
|
||||
sk_sp<GrRenderTargetContext> rescale(const SkImageInfo& info, const SkIRect& srcRect,
|
||||
SkSurface::RescaleGamma rescaleGamma,
|
||||
SkFilterQuality rescaleQuality);
|
||||
std::unique_ptr<GrRenderTargetContext> rescale(const SkImageInfo& info, const SkIRect& srcRect,
|
||||
SkSurface::RescaleGamma rescaleGamma,
|
||||
SkFilterQuality rescaleQuality);
|
||||
|
||||
// Inserts a transfer, part of the implementation of asyncReadPixels and
|
||||
// asyncRescaleAndReadPixelsYUV420().
|
||||
|
@ -370,9 +370,9 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
|
||||
}
|
||||
auto colorType = GrPixelConfigToColorType(src->config());
|
||||
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
|
||||
sk_sp<GrTextureContext> dstContext(context->priv().makeDeferredTextureContext(
|
||||
auto dstContext = context->priv().makeDeferredTextureContext(
|
||||
fit, width, height, colorType, kUnknown_SkAlphaType, nullptr, mipMapped,
|
||||
src->origin(), budgeted, isProtected));
|
||||
src->origin(), budgeted, isProtected);
|
||||
if (!dstContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -381,7 +381,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
|
||||
}
|
||||
}
|
||||
if (src->asTextureProxy()) {
|
||||
sk_sp<GrRenderTargetContext> dstContext = context->priv().makeDeferredRenderTargetContext(
|
||||
auto dstContext = context->priv().makeDeferredRenderTargetContext(
|
||||
fit, width, height, colorType, nullptr, 1, mipMapped, src->origin(), nullptr,
|
||||
budgeted);
|
||||
|
||||
|
@ -48,10 +48,9 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrRecordingContext* context,
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> copyRTC =
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1,
|
||||
mipMapped, inputProxy->origin());
|
||||
auto copyRTC = context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1,
|
||||
mipMapped, inputProxy->origin());
|
||||
if (!copyRTC) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -158,9 +158,9 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrRecordingContext* ctx,
|
||||
}
|
||||
|
||||
// TODO: investigate preallocating mip maps here
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(ctx->priv().makeDeferredRenderTargetContext(
|
||||
auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, desc.fWidth, desc.fHeight, colorType, nullptr, 1,
|
||||
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
|
||||
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -81,8 +81,7 @@ bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
|
||||
}
|
||||
|
||||
sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context,
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext,
|
||||
int width, int height,
|
||||
std::unique_ptr<GrRenderTargetContext> renderTargetContext,
|
||||
InitContents init) {
|
||||
if (!renderTargetContext || context->priv().abandoned()) {
|
||||
return nullptr;
|
||||
@ -91,8 +90,7 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context,
|
||||
if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext),
|
||||
width, height, flags));
|
||||
return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext), flags));
|
||||
}
|
||||
|
||||
sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
|
||||
@ -104,51 +102,42 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(MakeRenderTargetContext(context, budgeted,
|
||||
info, sampleCount,
|
||||
origin, props,
|
||||
mipMapped));
|
||||
auto renderTargetContext =
|
||||
MakeRenderTargetContext(context, budgeted, info, sampleCount, origin, props, mipMapped);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext),
|
||||
info.width(), info.height(), flags));
|
||||
return sk_sp<SkGpuDevice>(new SkGpuDevice(context, std::move(renderTargetContext), flags));
|
||||
}
|
||||
|
||||
static SkImageInfo make_info(GrRenderTargetContext* context, int w, int h, bool opaque) {
|
||||
static SkImageInfo make_info(GrRenderTargetContext* context, bool opaque) {
|
||||
SkColorType colorType = GrColorTypeToSkColorType(context->colorSpaceInfo().colorType());
|
||||
return SkImageInfo::Make(w, h, colorType, opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
|
||||
return SkImageInfo::Make(context->width(), context->height(), colorType,
|
||||
opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
|
||||
context->colorSpaceInfo().refColorSpace());
|
||||
}
|
||||
|
||||
SkGpuDevice::SkGpuDevice(GrContext* context, sk_sp<GrRenderTargetContext> renderTargetContext,
|
||||
int width, int height, unsigned flags)
|
||||
: INHERITED(make_info(renderTargetContext.get(), width, height,
|
||||
SkToBool(flags & kIsOpaque_Flag)), renderTargetContext->surfaceProps())
|
||||
, fContext(SkRef(context))
|
||||
, fRenderTargetContext(std::move(renderTargetContext))
|
||||
{
|
||||
fSize.set(width, height);
|
||||
|
||||
SkGpuDevice::SkGpuDevice(GrContext* context,
|
||||
std::unique_ptr<GrRenderTargetContext> renderTargetContext,
|
||||
unsigned flags)
|
||||
: INHERITED(make_info(renderTargetContext.get(), SkToBool(flags & kIsOpaque_Flag)),
|
||||
renderTargetContext->surfaceProps())
|
||||
, fContext(SkRef(context))
|
||||
, fRenderTargetContext(std::move(renderTargetContext)) {
|
||||
if (flags & kNeedClear_Flag) {
|
||||
this->clearAll();
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
|
||||
GrContext* context,
|
||||
SkBudgeted budgeted,
|
||||
const SkImageInfo& origInfo,
|
||||
int sampleCount,
|
||||
GrSurfaceOrigin origin,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
GrMipMapped mipMapped) {
|
||||
if (kUnknown_SkColorType == origInfo.colorType() ||
|
||||
origInfo.width() < 0 || origInfo.height() < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
|
||||
GrContext* context,
|
||||
SkBudgeted budgeted,
|
||||
const SkImageInfo& origInfo,
|
||||
int sampleCount,
|
||||
GrSurfaceOrigin origin,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
GrMipMapped mipMapped) {
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -224,7 +213,7 @@ void SkGpuDevice::clearAll() {
|
||||
GrRenderTargetContext::CanClearFullscreen::kYes);
|
||||
}
|
||||
|
||||
void SkGpuDevice::replaceRenderTargetContext(sk_sp<GrRenderTargetContext> rtc,
|
||||
void SkGpuDevice::replaceRenderTargetContext(std::unique_ptr<GrRenderTargetContext> rtc,
|
||||
bool shouldRetainContent) {
|
||||
SkASSERT(rtc->width() == this->width());
|
||||
SkASSERT(rtc->height() == this->height());
|
||||
@ -251,14 +240,13 @@ void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) {
|
||||
|
||||
// This entry point is used by SkSurface_Gpu::onCopyOnWrite so it must create a
|
||||
// kExact-backed render target context.
|
||||
sk_sp<GrRenderTargetContext> newRTC(MakeRenderTargetContext(
|
||||
this->context(),
|
||||
budgeted,
|
||||
this->imageInfo(),
|
||||
fRenderTargetContext->numSamples(),
|
||||
fRenderTargetContext->origin(),
|
||||
&this->surfaceProps(),
|
||||
fRenderTargetContext->mipMapped()));
|
||||
auto newRTC = MakeRenderTargetContext(this->context(),
|
||||
budgeted,
|
||||
this->imageInfo(),
|
||||
fRenderTargetContext->numSamples(),
|
||||
fRenderTargetContext->origin(),
|
||||
&this->surfaceProps(),
|
||||
fRenderTargetContext->mipMapped());
|
||||
if (!newRTC) {
|
||||
return;
|
||||
}
|
||||
@ -1661,7 +1649,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
|
||||
colorType = GrColorType::kRGBA_8888;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(fContext->priv().makeDeferredRenderTargetContext(
|
||||
auto rtc = fContext->priv().makeDeferredRenderTargetContext(
|
||||
fit,
|
||||
cinfo.fInfo.width(),
|
||||
cinfo.fInfo.height(),
|
||||
@ -1673,7 +1661,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
|
||||
&props,
|
||||
SkBudgeted::kYes,
|
||||
fRenderTargetContext->asSurfaceProxy()->isProtected() ? GrProtected::kYes
|
||||
: GrProtected::kNo));
|
||||
: GrProtected::kNo);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1681,8 +1669,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
|
||||
// Skia's convention is to only clear a device if it is non-opaque.
|
||||
InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_InitContents;
|
||||
|
||||
return SkGpuDevice::Make(fContext.get(), std::move(rtc),
|
||||
cinfo.fInfo.width(), cinfo.fInfo.height(), init).release();
|
||||
return SkGpuDevice::Make(fContext.get(), std::move(rtc), init).release();
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
* Creates an SkGpuDevice from a GrRenderTargetContext whose backing width/height is
|
||||
* different than its actual width/height (e.g., approx-match scratch texture).
|
||||
*/
|
||||
static sk_sp<SkGpuDevice> Make(GrContext*, sk_sp<GrRenderTargetContext> renderTargetContext,
|
||||
int width, int height, InitContents);
|
||||
static sk_sp<SkGpuDevice> Make(
|
||||
GrContext*, std::unique_ptr<GrRenderTargetContext>, InitContents);
|
||||
|
||||
/**
|
||||
* New device that will create an offscreen renderTarget based on the ImageInfo and
|
||||
@ -65,7 +65,8 @@ public:
|
||||
void clearAll();
|
||||
|
||||
void replaceRenderTargetContext(bool shouldRetainContent);
|
||||
void replaceRenderTargetContext(sk_sp<GrRenderTargetContext>, bool shouldRetainContent);
|
||||
void replaceRenderTargetContext(std::unique_ptr<GrRenderTargetContext>,
|
||||
bool shouldRetainContent);
|
||||
|
||||
GrRenderTargetContext* accessRenderTargetContext() override;
|
||||
|
||||
@ -132,10 +133,8 @@ protected:
|
||||
|
||||
private:
|
||||
// We want these unreffed in RenderTargetContext, GrContext order.
|
||||
sk_sp<GrContext> fContext;
|
||||
sk_sp<GrRenderTargetContext> fRenderTargetContext;
|
||||
|
||||
SkISize fSize;
|
||||
sk_sp<GrContext> fContext;
|
||||
std::unique_ptr<GrRenderTargetContext> fRenderTargetContext;
|
||||
|
||||
enum Flags {
|
||||
kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear
|
||||
@ -145,7 +144,7 @@ private:
|
||||
static bool CheckAlphaTypeAndGetFlags(const SkImageInfo* info, InitContents init,
|
||||
unsigned* flags);
|
||||
|
||||
SkGpuDevice(GrContext*, sk_sp<GrRenderTargetContext>, int width, int height, unsigned flags);
|
||||
SkGpuDevice(GrContext*, std::unique_ptr<GrRenderTargetContext>, unsigned flags);
|
||||
|
||||
SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
|
||||
|
||||
@ -233,13 +232,13 @@ private:
|
||||
const SkVertices::Bone bones[], int boneCount, SkBlendMode,
|
||||
const uint16_t indices[], int indexCount, const SkPaint&);
|
||||
|
||||
static sk_sp<GrRenderTargetContext> MakeRenderTargetContext(GrContext*,
|
||||
SkBudgeted,
|
||||
const SkImageInfo&,
|
||||
int sampleCount,
|
||||
GrSurfaceOrigin,
|
||||
const SkSurfaceProps*,
|
||||
GrMipMapped);
|
||||
static std::unique_ptr<GrRenderTargetContext> MakeRenderTargetContext(GrContext*,
|
||||
SkBudgeted,
|
||||
const SkImageInfo&,
|
||||
int sampleCount,
|
||||
GrSurfaceOrigin,
|
||||
const SkSurfaceProps*,
|
||||
GrMipMapped);
|
||||
|
||||
friend class GrAtlasTextContext;
|
||||
friend class SkSurface_Gpu; // for access to surfaceProps
|
||||
|
@ -216,7 +216,7 @@ sk_sp<GrCCCachedAtlas> GrCCAtlas::refOrMakeCachedAtlas(GrOnFlushResourceProvider
|
||||
return fCachedAtlas;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrCCAtlas::makeRenderTargetContext(
|
||||
std::unique_ptr<GrRenderTargetContext> GrCCAtlas::makeRenderTargetContext(
|
||||
GrOnFlushResourceProvider* onFlushRP, sk_sp<GrTexture> backingTexture) {
|
||||
SkASSERT(!fTextureProxy->isInstantiated()); // This method should only be called once.
|
||||
// Caller should have cropped any paths to the destination render target instead of asking for
|
||||
@ -241,8 +241,7 @@ sk_sp<GrRenderTargetContext> GrCCAtlas::makeRenderTargetContext(
|
||||
}
|
||||
auto colorType = (CoverageType::kFP16_CoverageCount == fCoverageType)
|
||||
? GrColorType::kAlpha_F16 : GrColorType::kAlpha_8;
|
||||
sk_sp<GrRenderTargetContext> rtc =
|
||||
onFlushRP->makeRenderTargetContext(fTextureProxy, colorType, nullptr, nullptr);
|
||||
auto rtc = onFlushRP->makeRenderTargetContext(fTextureProxy, colorType, nullptr, nullptr);
|
||||
if (!rtc) {
|
||||
SkDebugf("WARNING: failed to allocate a %ix%i atlas. Some paths will not be drawn.\n",
|
||||
fWidth, fHeight);
|
||||
|
@ -100,8 +100,8 @@ public:
|
||||
// 'backingTexture', if provided, is a renderable texture with which to instantiate our proxy.
|
||||
// If null then we will create a texture using the resource provider. The purpose of this param
|
||||
// is to provide a guaranteed way to recycle a stashed atlas texture from a previous flush.
|
||||
sk_sp<GrRenderTargetContext> makeRenderTargetContext(GrOnFlushResourceProvider*,
|
||||
sk_sp<GrTexture> backingTexture = nullptr);
|
||||
std::unique_ptr<GrRenderTargetContext> makeRenderTargetContext(
|
||||
GrOnFlushResourceProvider*, sk_sp<GrTexture> backingTexture = nullptr);
|
||||
|
||||
private:
|
||||
class Node;
|
||||
|
@ -500,7 +500,7 @@ void GrCCPerFlushResources::recordStencilResolveInstance(
|
||||
}
|
||||
|
||||
bool GrCCPerFlushResources::finalize(GrOnFlushResourceProvider* onFlushRP,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>* out) {
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) {
|
||||
SkASSERT(this->isMapped());
|
||||
SkASSERT(fNextPathInstanceIdx == fEndPathInstance);
|
||||
SkASSERT(fNextCopyInstanceIdx == fEndCopyInstance);
|
||||
@ -541,7 +541,7 @@ bool GrCCPerFlushResources::finalize(GrOnFlushResourceProvider* onFlushRP,
|
||||
int endCopyRange = atlas->getFillBatchID();
|
||||
SkASSERT(endCopyRange > copyRangeIdx);
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc = atlas->makeRenderTargetContext(onFlushRP);
|
||||
auto rtc = atlas->makeRenderTargetContext(onFlushRP);
|
||||
for (; copyRangeIdx < endCopyRange; ++copyRangeIdx) {
|
||||
const CopyPathRange& copyRange = fCopyPathRanges[copyRangeIdx];
|
||||
int endCopyInstance = baseCopyInstance + copyRange.fCount;
|
||||
|
@ -107,7 +107,8 @@ public:
|
||||
}
|
||||
|
||||
// Finishes off the GPU buffers and renders the atlas(es).
|
||||
bool finalize(GrOnFlushResourceProvider*, SkTArray<sk_sp<GrRenderTargetContext>>* out);
|
||||
bool finalize(GrOnFlushResourceProvider*,
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* out);
|
||||
|
||||
// Accessors used by draw calls, once the resources have been finalized.
|
||||
const GrCCFiller& filler() const { SkASSERT(!this->isMapped()); return fFiller; }
|
||||
|
@ -226,9 +226,11 @@ std::unique_ptr<GrFragmentProcessor> GrCoverageCountingPathRenderer::makeClipPro
|
||||
return skstd::make_unique<GrCCClipProcessor>(&clipPath, isCoverageCount, mustCheckBounds);
|
||||
}
|
||||
|
||||
void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlushRP,
|
||||
const uint32_t* opListIDs, int numOpListIDs,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>* out) {
|
||||
void GrCoverageCountingPathRenderer::preFlush(
|
||||
GrOnFlushResourceProvider* onFlushRP,
|
||||
const uint32_t* opListIDs,
|
||||
int numOpListIDs,
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) {
|
||||
using DoCopiesToA8Coverage = GrCCDrawPathsOp::DoCopiesToA8Coverage;
|
||||
SkASSERT(!fFlushing);
|
||||
SkASSERT(fFlushingPaths.empty());
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
|
||||
// GrOnFlushCallbackObject overrides.
|
||||
void preFlush(GrOnFlushResourceProvider*, const uint32_t* opListIDs, int numOpListIDs,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>* out) override;
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) override;
|
||||
void postFlush(GrDeferredUploadToken, const uint32_t* opListIDs, int numOpListIDs) override;
|
||||
|
||||
void purgeCacheEntriesOlderThan(GrProxyProvider*, const GrStdSteadyClock::time_point&);
|
||||
|
@ -40,14 +40,14 @@
|
||||
const SkImageInfo ii = SkImageInfo::Make(kSize, kSize,
|
||||
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
|
||||
sk_sp<GrRenderTargetContext> readRTC(
|
||||
auto readRTC =
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
|
||||
kSize, kSize,
|
||||
kColorType, nullptr));
|
||||
sk_sp<GrRenderTargetContext> tempRTC(
|
||||
kColorType, nullptr);
|
||||
auto tempRTC =
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
|
||||
kSize, kSize,
|
||||
kColorType, nullptr));
|
||||
kColorType, nullptr);
|
||||
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
|
||||
return false;
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ uniform half blurRadius;
|
||||
key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin));
|
||||
if (!mask) {
|
||||
// TODO: this could be approx but the texture coords will need to be updated
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
auto rtc =
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, size.fWidth,
|
||||
size.fHeight, GrColorType::kAlpha_8, nullptr));
|
||||
size.fHeight, GrColorType::kAlpha_8, nullptr);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -73,7 +73,7 @@ uniform half blurRadius;
|
||||
if (!srcProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<GrRenderTargetContext> rtc2(
|
||||
auto rtc2 =
|
||||
SkGpuBlurUtils::GaussianBlur(context,
|
||||
std::move(srcProxy),
|
||||
SkIPoint::Make(0, 0),
|
||||
@ -84,7 +84,7 @@ uniform half blurRadius;
|
||||
xformedSigma,
|
||||
GrTextureDomain::kIgnore_Mode,
|
||||
kPremul_SkAlphaType,
|
||||
SkBackingFit::kExact));
|
||||
SkBackingFit::kExact);
|
||||
if (!rtc2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ public:
|
||||
const SkImageInfo ii =
|
||||
SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
|
||||
sk_sp<GrRenderTargetContext> readRTC(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kSize, kSize, kColorType, nullptr));
|
||||
sk_sp<GrRenderTargetContext> tempRTC(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kSize, kSize, kColorType, nullptr));
|
||||
auto readRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize,
|
||||
kSize, kColorType, nullptr);
|
||||
auto tempRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize,
|
||||
kSize, kColorType, nullptr);
|
||||
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
|
||||
return false;
|
||||
}
|
||||
|
@ -55,10 +55,9 @@ public:
|
||||
key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin));
|
||||
if (!mask) {
|
||||
// TODO: this could be approx but the texture coords will need to be updated
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, size.fWidth, size.fHeight, GrColorType::kAlpha_8,
|
||||
nullptr));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, size.fWidth, size.fHeight, GrColorType::kAlpha_8,
|
||||
nullptr);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -74,18 +73,17 @@ public:
|
||||
if (!srcProxy) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<GrRenderTargetContext> rtc2(
|
||||
SkGpuBlurUtils::GaussianBlur(context,
|
||||
std::move(srcProxy),
|
||||
SkIPoint::Make(0, 0),
|
||||
nullptr,
|
||||
SkIRect::MakeWH(size.fWidth, size.fHeight),
|
||||
SkIRect::EmptyIRect(),
|
||||
xformedSigma,
|
||||
xformedSigma,
|
||||
GrTextureDomain::kIgnore_Mode,
|
||||
kPremul_SkAlphaType,
|
||||
SkBackingFit::kExact));
|
||||
auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
|
||||
std::move(srcProxy),
|
||||
SkIPoint::Make(0, 0),
|
||||
nullptr,
|
||||
SkIRect::MakeWH(size.fWidth, size.fHeight),
|
||||
SkIRect::EmptyIRect(),
|
||||
xformedSigma,
|
||||
xformedSigma,
|
||||
GrTextureDomain::kIgnore_Mode,
|
||||
kPremul_SkAlphaType,
|
||||
SkBackingFit::kExact);
|
||||
if (!rtc2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
// default retainOnFreeGpuResources implementation).
|
||||
|
||||
void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>*) override {
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>*) override {
|
||||
if (fAtlas) {
|
||||
fAtlas->instantiate(onFlushResourceProvider);
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, GrColorType
|
||||
return false;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(
|
||||
sk_ref_sp(sProxy), colorType, kUnknown_SkAlphaType));
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(sk_ref_sp(sProxy), colorType,
|
||||
kUnknown_SkAlphaType);
|
||||
if (!sContext || !sContext->asTextureProxy()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
// GrOnFlushCallbackObject overrides
|
||||
|
||||
void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>*) override {
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>*) override {
|
||||
for (int i = 0; i < kMaskFormatCount; ++i) {
|
||||
if (fAtlases[i]) {
|
||||
fAtlases[i]->instantiate(onFlushResourceProvider);
|
||||
|
@ -235,8 +235,8 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) {
|
||||
}
|
||||
|
||||
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 1024, 1024, GrColorType::kRGBA_8888, nullptr));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1024, 1024,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
||||
|
||||
|
@ -30,15 +30,11 @@ sk_sp<GrVkSecondaryCBDrawContext> GrVkSecondaryCBDrawContext::Make(GrContext* ct
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
ctx->priv().makeVulkanSecondaryCBRenderTargetContext(imageInfo, vkInfo, props));
|
||||
auto rtc = ctx->priv().makeVulkanSecondaryCBRenderTargetContext(imageInfo, vkInfo, props);
|
||||
SkASSERT(rtc->asSurfaceProxy()->isInstantiated());
|
||||
|
||||
int width = rtc->width();
|
||||
int height = rtc->height();
|
||||
|
||||
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(ctx, std::move(rtc), width, height,
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
sk_sp<SkGpuDevice> device(
|
||||
SkGpuDevice::Make(ctx, std::move(rtc), SkGpuDevice::kUninit_InitContents));
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -86,10 +86,9 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(context);
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, this->width(), this->height(),
|
||||
SkColorTypeToGrColorType(targetCT), nullptr));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContextWithFallback(
|
||||
SkBackingFit::kExact, this->width(), this->height(), SkColorTypeToGrColorType(targetCT),
|
||||
nullptr);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -245,9 +244,9 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* ctx,
|
||||
const int height = imageSize.height();
|
||||
|
||||
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(ctx->priv().makeDeferredRenderTargetContext(
|
||||
auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, width, height, GrColorType::kRGBA_8888,
|
||||
std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
|
||||
std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -283,11 +282,9 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
|
||||
|
||||
// Needs to create a render target with external texture
|
||||
// in order to draw to it for the yuv->rgb conversion.
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
ctx->priv().makeBackendTextureRenderTargetContext(backendTexture, imageOrigin, 1,
|
||||
grColorType,
|
||||
std::move(imageColorSpace), nullptr,
|
||||
textureReleaseProc, releaseContext));
|
||||
auto renderTargetContext = ctx->priv().makeBackendTextureRenderTargetContext(
|
||||
backendTexture, imageOrigin, 1, grColorType, std::move(imageColorSpace), nullptr,
|
||||
textureReleaseProc, releaseContext);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -601,7 +598,7 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrTextureContext> texContext =
|
||||
auto texContext =
|
||||
drawingManager->makeTextureContext(proxy, SkColorTypeToGrColorType(pixmap.colorType()),
|
||||
pixmap.alphaType(), cs);
|
||||
if (!texContext) {
|
||||
|
@ -92,11 +92,8 @@ bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
|
||||
this->colorType(),
|
||||
texProxy->backendFormat());
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext =
|
||||
direct->priv().makeWrappedSurfaceContext(std::move(texProxy),
|
||||
grColorType,
|
||||
this->alphaType(),
|
||||
this->refColorSpace());
|
||||
auto sContext = direct->priv().makeWrappedSurfaceContext(
|
||||
std::move(texProxy), grColorType, this->alphaType(), this->refColorSpace());
|
||||
if (!sContext) {
|
||||
return false;
|
||||
}
|
||||
@ -150,7 +147,7 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels,
|
||||
this->colorType(),
|
||||
texProxy->backendFormat());
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext = direct->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = direct->priv().makeWrappedSurfaceContext(
|
||||
std::move(texProxy), grColorType, this->alphaType(), this->refColorSpace());
|
||||
if (!sContext) {
|
||||
return false;
|
||||
|
@ -141,10 +141,9 @@ sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef(GrRecordingContext* con
|
||||
}
|
||||
|
||||
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888,
|
||||
this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888,
|
||||
this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin);
|
||||
if (!renderTargetContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -364,25 +364,23 @@ sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* context,
|
||||
|
||||
GrColorType grColorType = SkColorTypeToGrColorType(c.colorType());
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact,
|
||||
c.width(),
|
||||
c.height(),
|
||||
grColorType,
|
||||
c.refColorSpace(),
|
||||
c.sampleCount(),
|
||||
GrMipMapped(c.isMipMapped()),
|
||||
c.origin(),
|
||||
&c.surfaceProps(),
|
||||
budgeted,
|
||||
c.isProtected()));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
|
||||
c.width(),
|
||||
c.height(),
|
||||
grColorType,
|
||||
c.refColorSpace(),
|
||||
c.sampleCount(),
|
||||
GrMipMapped(c.isMipMapped()),
|
||||
c.origin(),
|
||||
&c.surfaceProps(),
|
||||
budgeted,
|
||||
c.isProtected());
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// CONTEXT TODO: remove this use of 'backdoor' to create an SkGpuDevice
|
||||
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context->priv().backdoor(), std::move(rtc),
|
||||
c.width(), c.height(),
|
||||
SkGpuDevice::kClear_InitContents));
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
@ -458,16 +456,14 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
|
||||
backendTexture, c.origin(), c.sampleCount(), grCT,
|
||||
c.refColorSpace(), &c.surfaceProps(), textureReleaseProc, releaseContext));
|
||||
auto rtc = context->priv().makeBackendTextureRenderTargetContext(
|
||||
backendTexture, c.origin(), c.sampleCount(), grCT, c.refColorSpace(), &c.surfaceProps(),
|
||||
textureReleaseProc, releaseContext);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc),
|
||||
backendTexture.width(), backendTexture.height(),
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -505,16 +501,13 @@ sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted
|
||||
return sk_make_sp<SkSurface_Gpu>(std::move(device));
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(GrContext* context,
|
||||
sk_sp<GrRenderTargetContext> rtc) {
|
||||
sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(
|
||||
GrContext* context, std::unique_ptr<GrRenderTargetContext> rtc) {
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int w = rtc->width();
|
||||
int h = rtc->height();
|
||||
sk_sp<SkGpuDevice> device(
|
||||
SkGpuDevice::Make(context, std::move(rtc), w, h, SkGpuDevice::kUninit_InitContents));
|
||||
auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -544,15 +537,14 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrB
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
|
||||
tex, origin, sampleCnt, grColorType, std::move(colorSpace), props,
|
||||
textureReleaseProc, releaseContext));
|
||||
auto rtc = context->priv().makeBackendTextureRenderTargetContext(
|
||||
tex, origin, sampleCnt, grColorType, std::move(colorSpace), props, textureReleaseProc,
|
||||
releaseContext);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), tex.width(), tex.height(),
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -598,7 +590,7 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
|
||||
sampleCnt, grColorType, true)) {
|
||||
return false;
|
||||
}
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
|
||||
auto rtc = context->priv().makeBackendTextureRenderTargetContext(
|
||||
backendTexture,
|
||||
origin,
|
||||
sampleCnt,
|
||||
@ -606,7 +598,7 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
|
||||
std::move(colorSpace),
|
||||
&this->props(),
|
||||
releaseProc,
|
||||
releaseContext));
|
||||
releaseContext);
|
||||
if (!rtc) {
|
||||
return false;
|
||||
}
|
||||
@ -652,14 +644,13 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendRenderTargetRenderTargetContext(
|
||||
rt, origin, grColorType, std::move(colorSpace), props, relProc, releaseContext));
|
||||
auto rtc = context->priv().makeBackendRenderTargetRenderTargetContext(
|
||||
rt, origin, grColorType, std::move(colorSpace), props, relProc, releaseContext);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), rt.width(), rt.height(),
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -688,20 +679,13 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
context->priv().makeBackendTextureAsRenderTargetRenderTargetContext(
|
||||
tex,
|
||||
origin,
|
||||
sampleCnt,
|
||||
grColorType,
|
||||
std::move(colorSpace),
|
||||
props));
|
||||
auto rtc = context->priv().makeBackendTextureAsRenderTargetRenderTargetContext(
|
||||
tex, origin, sampleCnt, grColorType, std::move(colorSpace), props);
|
||||
if (!rtc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), tex.width(), tex.height(),
|
||||
SkGpuDevice::kUninit_InitContents));
|
||||
auto device = SkGpuDevice::Make(context, std::move(rtc), SkGpuDevice::kUninit_InitContents);
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ public:
|
||||
~SkSurface_Gpu() override;
|
||||
|
||||
// This is an internal-only factory
|
||||
static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
|
||||
static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*,
|
||||
std::unique_ptr<GrRenderTargetContext>);
|
||||
|
||||
GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
|
||||
GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;
|
||||
|
@ -62,7 +62,7 @@ static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
|
||||
std::unique_ptr<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
|
||||
return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
}
|
||||
@ -72,7 +72,7 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static const int kH = 10;
|
||||
|
||||
SkIRect fullRect = SkIRect::MakeWH(kW, kH);
|
||||
sk_sp<GrRenderTargetContext> rtContext;
|
||||
std::unique_ptr<GrRenderTargetContext> rtContext;
|
||||
|
||||
// A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround
|
||||
// it.
|
||||
|
@ -103,11 +103,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> dstContext =
|
||||
context->priv().makeWrappedSurfaceContext(
|
||||
std::move(dst),
|
||||
SkColorTypeToGrColorType(ii.colorType()),
|
||||
ii.alphaType());
|
||||
auto dstContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(dst),
|
||||
SkColorTypeToGrColorType(ii.colorType()),
|
||||
ii.alphaType());
|
||||
|
||||
bool result = false;
|
||||
if (sOrigin == dOrigin) {
|
||||
|
@ -156,7 +156,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
|
||||
// TODO: If I make this TopLeft origin to match resolve_origin calls for kDefault, this test
|
||||
// fails on the Nexus5. Why?
|
||||
sk_sp<GrTextureContext> surfaceContext = context0->priv().makeBackendTextureContext(
|
||||
auto surfaceContext = context0->priv().makeBackendTextureContext(
|
||||
backendTex, kBottomLeft_GrSurfaceOrigin, GrColorType::kRGBA_8888, kPremul_SkAlphaType,
|
||||
nullptr);
|
||||
|
||||
@ -178,7 +178,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
|
||||
// Should not be able to wrap as a RT
|
||||
{
|
||||
sk_sp<GrRenderTargetContext> temp = context0->priv().makeBackendTextureRenderTargetContext(
|
||||
auto temp = context0->priv().makeBackendTextureRenderTargetContext(
|
||||
backendTex, kBottomLeft_GrSurfaceOrigin, 1, GrColorType::kRGBA_8888, nullptr);
|
||||
if (temp) {
|
||||
ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT.");
|
||||
|
@ -54,8 +54,8 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context, T min, T max, T
|
||||
continue;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(fpProxy), colorType, kPremul_SkAlphaType);
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(std::move(fpProxy), colorType,
|
||||
kPremul_SkAlphaType);
|
||||
REPORTER_ASSERT(reporter, sContext);
|
||||
|
||||
bool result = sContext->readPixels({colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
|
||||
|
@ -142,9 +142,9 @@ private:
|
||||
static const int kRenderTargetHeight = 1;
|
||||
static const int kRenderTargetWidth = 1;
|
||||
|
||||
static sk_sp<GrRenderTargetContext> random_render_target_context(GrContext* context,
|
||||
SkRandom* random,
|
||||
const GrCaps* caps) {
|
||||
static std::unique_ptr<GrRenderTargetContext> random_render_target_context(GrContext* context,
|
||||
SkRandom* random,
|
||||
const GrCaps* caps) {
|
||||
GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin
|
||||
: kBottomLeft_GrSurfaceOrigin;
|
||||
|
||||
@ -155,16 +155,14 @@ static sk_sp<GrRenderTargetContext> random_render_target_context(GrContext* cont
|
||||
// Above could be 0 if msaa isn't supported.
|
||||
sampleCnt = SkTMax(1, sampleCnt);
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
|
||||
kRenderTargetWidth,
|
||||
kRenderTargetHeight,
|
||||
GrColorType::kRGBA_8888,
|
||||
nullptr,
|
||||
sampleCnt,
|
||||
GrMipMapped::kNo,
|
||||
origin));
|
||||
return renderTargetContext;
|
||||
return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
|
||||
kRenderTargetWidth,
|
||||
kRenderTargetHeight,
|
||||
GrColorType::kRGBA_8888,
|
||||
nullptr,
|
||||
sampleCnt,
|
||||
GrMipMapped::kNo,
|
||||
origin);
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
@ -305,8 +303,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
||||
static const int NUM_TESTS = 1024;
|
||||
for (int t = 0; t < NUM_TESTS; t++) {
|
||||
// setup random render target(can fail)
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
random_render_target_context(context, &random, context->priv().caps()));
|
||||
auto renderTargetContext =
|
||||
random_render_target_context(context, &random, context->priv().caps());
|
||||
if (!renderTargetContext) {
|
||||
SkDebugf("Could not allocate renderTargetContext");
|
||||
return false;
|
||||
@ -323,12 +321,12 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
||||
GrPrepareForExternalIORequests());
|
||||
|
||||
// Validate that GrFPs work correctly without an input.
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
auto renderTargetContext =
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
|
||||
kRenderTargetWidth,
|
||||
kRenderTargetHeight,
|
||||
GrColorType::kRGBA_8888,
|
||||
nullptr));
|
||||
nullptr);
|
||||
if (!renderTargetContext) {
|
||||
SkDebugf("Could not allocate a renderTargetContext");
|
||||
return false;
|
||||
|
@ -83,7 +83,6 @@ public:
|
||||
void clear() const { fRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
|
||||
GrRenderTargetContext::CanClearFullscreen::kYes); }
|
||||
void destroyGrContext() {
|
||||
SkASSERT(fRTC->unique());
|
||||
SkASSERT(fCtx->unique());
|
||||
fRTC.reset();
|
||||
fCCPR = nullptr;
|
||||
@ -134,7 +133,7 @@ public:
|
||||
private:
|
||||
sk_sp<GrContext> fCtx;
|
||||
GrCoverageCountingPathRenderer* fCCPR;
|
||||
sk_sp<GrRenderTargetContext> fRTC;
|
||||
std::unique_ptr<GrRenderTargetContext> fRTC;
|
||||
const bool fDoStroke;
|
||||
};
|
||||
|
||||
@ -323,7 +322,7 @@ protected:
|
||||
int lastRenderedAtlasID() const { return fLastRenderedAtlasID; }
|
||||
|
||||
void preFlush(GrOnFlushResourceProvider*, const uint32_t* opListIDs, int numOpListIDs,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>* out) override {
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* out) override {
|
||||
fLastRenderedAtlasID = fLastCopyAtlasID = 0;
|
||||
|
||||
const GrCCPerFlushResources* resources = fCCPR->testingOnly_getCurrentFlushResources();
|
||||
|
@ -77,14 +77,14 @@ struct Box {
|
||||
*/
|
||||
|
||||
static void run_test(GrContext* context, const char* testName, skiatest::Reporter*,
|
||||
const sk_sp<GrRenderTargetContext>&, const SkBitmap& gold,
|
||||
const std::unique_ptr<GrRenderTargetContext>&, const SkBitmap& gold,
|
||||
std::function<void(DrawMeshHelper*)> testFn);
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kImageWidth, kImageHeight, GrColorType::kRGBA_8888, nullptr));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kImageWidth, kImageHeight, GrColorType::kRGBA_8888, nullptr);
|
||||
if (!rtc) {
|
||||
ERRORF(reporter, "could not create render target context.");
|
||||
return;
|
||||
@ -387,7 +387,7 @@ void DrawMeshHelper::drawMesh(const GrMesh& mesh) {
|
||||
}
|
||||
|
||||
static void run_test(GrContext* context, const char* testName, skiatest::Reporter* reporter,
|
||||
const sk_sp<GrRenderTargetContext>& rtc, const SkBitmap& gold,
|
||||
const std::unique_ptr<GrRenderTargetContext>& rtc, const SkBitmap& gold,
|
||||
std::function<void(DrawMeshHelper*)> testFn) {
|
||||
const int w = gold.width(), h = gold.height(), rowBytes = gold.rowBytes();
|
||||
const uint32_t* goldPx = reinterpret_cast<const uint32_t*>(gold.getPixels());
|
||||
|
@ -338,7 +338,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(Gr1x1TextureMipMappedTest, reporter, ctxInfo)
|
||||
}
|
||||
|
||||
// Create a new render target and draw 'mipmapProxy' into it using the provided 'filter'.
|
||||
static sk_sp<GrRenderTargetContext> draw_mipmap_into_new_render_target(
|
||||
static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target(
|
||||
GrDrawingManager* drawingManager, GrProxyProvider* proxyProvider, GrColorType colorType,
|
||||
sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) {
|
||||
GrSurfaceDesc desc;
|
||||
@ -348,7 +348,7 @@ static sk_sp<GrRenderTargetContext> draw_mipmap_into_new_render_target(
|
||||
sk_sp<GrSurfaceProxy> renderTarget = proxyProvider->createProxy(
|
||||
mipmapProxy->backendFormat(), desc, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin,
|
||||
SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
|
||||
sk_sp<GrRenderTargetContext> rtc = drawingManager->makeRenderTargetContext(
|
||||
auto rtc = drawingManager->makeRenderTargetContext(
|
||||
std::move(renderTarget), colorType, nullptr, nullptr, true);
|
||||
rtc->drawTexture(GrNoClip(), mipmapProxy, filter, SkBlendMode::kSrcOver, {1,1,1,1},
|
||||
SkRect::MakeWH(4, 4), SkRect::MakeWH(1,1), GrAA::kYes, GrQuadAAFlags::kAll,
|
||||
@ -381,8 +381,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrManyDependentsMipMappedTest, reporter, ctxInfo) {
|
||||
GrProtected::kNo);
|
||||
|
||||
// Render something to dirty the mips.
|
||||
sk_sp<GrRenderTargetContext> mipmapRTC = drawingManager->makeRenderTargetContext(
|
||||
mipmapProxy, colorType, nullptr, nullptr, true);
|
||||
auto mipmapRTC =
|
||||
drawingManager->makeRenderTargetContext(mipmapProxy, colorType, nullptr, nullptr, true);
|
||||
mipmapRTC->clear(nullptr, {.1f,.2f,.3f,.4f}, GrRenderTargetContext::CanClearFullscreen::kYes);
|
||||
REPORTER_ASSERT(reporter, mipmapProxy->mipMapsAreDirty());
|
||||
REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask());
|
||||
@ -391,8 +391,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrManyDependentsMipMappedTest, reporter, ctxInfo) {
|
||||
reporter, mipmapRTC->testingOnly_PeekLastOpList() == mipmapProxy->getLastRenderTask());
|
||||
|
||||
// Draw the dirty mipmap texture into a render target.
|
||||
sk_sp<GrRenderTargetContext> rtc1 = draw_mipmap_into_new_render_target(
|
||||
drawingManager, proxyProvider, colorType, mipmapProxy, GrSamplerState::Filter::kMipMap);
|
||||
auto rtc1 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
|
||||
mipmapProxy, GrSamplerState::Filter::kMipMap);
|
||||
|
||||
// Make sure the texture's mipmaps are now clean, and its last render task has switched from the
|
||||
// opList that drew to it, to the task that resolved its mips.
|
||||
@ -405,8 +405,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrManyDependentsMipMappedTest, reporter, ctxInfo) {
|
||||
SkASSERT(!mipmapProxy->mipMapsAreDirty());
|
||||
|
||||
// Draw the now-clean mipmap texture into a second target.
|
||||
sk_sp<GrRenderTargetContext> rtc2 = draw_mipmap_into_new_render_target(
|
||||
drawingManager, proxyProvider, colorType, mipmapProxy, GrSamplerState::Filter::kMipMap);
|
||||
auto rtc2 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
|
||||
mipmapProxy, GrSamplerState::Filter::kMipMap);
|
||||
|
||||
// Make sure the mipmap texture still has the same regen task.
|
||||
REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask() == initialMipmapRegenTask);
|
||||
|
@ -164,8 +164,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
GrResourceProvider* rp = context->priv().resourceProvider();
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kScreenSize, kScreenSize, GrColorType::kRGBA_8888, nullptr));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kScreenSize, kScreenSize, GrColorType::kRGBA_8888, nullptr);
|
||||
if (!rtc) {
|
||||
ERRORF(reporter, "could not create render target context.");
|
||||
return;
|
||||
|
@ -309,7 +309,7 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
|
||||
// Try creating the texture as a deferred proxy.
|
||||
{
|
||||
sk_sp<GrSurfaceContext> surfCtx;
|
||||
std::unique_ptr<GrSurfaceContext> surfCtx;
|
||||
if (renderable == GrRenderable::kYes) {
|
||||
surfCtx = context->priv().makeDeferredRenderTargetContext(
|
||||
fit, desc.fWidth, desc.fHeight, combo.fColorType, nullptr,
|
||||
|
@ -33,7 +33,7 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
|
||||
kTopLeft_GrSurfaceOrigin, srcBuffer, 0);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (proxy) {
|
||||
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
proxy, SkColorTypeToGrColorType(ct), kPremul_SkAlphaType);
|
||||
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
|
||||
@ -65,7 +65,7 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
|
||||
srcBuffer, 0);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (proxy) {
|
||||
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
proxy, SkColorTypeToGrColorType(ct), kPremul_SkAlphaType);
|
||||
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
void preFlush(GrOnFlushResourceProvider*, const uint32_t*, int,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>*) override {
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>*) override {
|
||||
REPORTER_ASSERT(fReporter, !fHasOpTexture);
|
||||
REPORTER_ASSERT(fReporter, !fHasClipTexture);
|
||||
}
|
||||
@ -209,10 +209,10 @@ DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
|
||||
for (bool nullTexture : {false, true}) {
|
||||
LazyProxyTest test(reporter);
|
||||
ctx->priv().addOnFlushCallbackObject(&test);
|
||||
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, 100, 100, GrColorType::kRGBA_8888, nullptr);
|
||||
auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
REPORTER_ASSERT(reporter, rtc);
|
||||
sk_sp<GrRenderTargetContext> mockAtlas = ctx->priv().makeDeferredRenderTargetContext(
|
||||
auto mockAtlas = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, 10, 10, GrColorType::kAlpha_F16, nullptr);
|
||||
REPORTER_ASSERT(reporter, mockAtlas);
|
||||
rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()),
|
||||
@ -375,8 +375,8 @@ DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) {
|
||||
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
|
||||
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
|
||||
for (bool failInstantiation : {false, true}) {
|
||||
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, 100, 100, GrColorType::kRGBA_8888, nullptr);
|
||||
auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
REPORTER_ASSERT(reporter, rtc);
|
||||
|
||||
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
|
||||
@ -446,8 +446,8 @@ DEF_GPUTEST(LazyProxyDeinstantiateTest, reporter, /* options */) {
|
||||
|
||||
using LazyType = GrSurfaceProxy::LazyInstantiationType;
|
||||
for (auto lazyType : {LazyType::kSingleUse, LazyType::kMultipleUse, LazyType::kDeinstantiate}) {
|
||||
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, 100, 100, GrColorType::kRGBA_8888, nullptr);
|
||||
auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
REPORTER_ASSERT(reporter, rtc);
|
||||
|
||||
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
|
||||
|
@ -334,8 +334,9 @@ public:
|
||||
* This callback creates the atlas and updates the AtlasedRectOps to read from it
|
||||
*/
|
||||
void preFlush(GrOnFlushResourceProvider* resourceProvider,
|
||||
const uint32_t* opListIDs, int numOpListIDs,
|
||||
SkTArray<sk_sp<GrRenderTargetContext>>* results) override {
|
||||
const uint32_t* opListIDs,
|
||||
int numOpListIDs,
|
||||
SkTArray<std::unique_ptr<GrRenderTargetContext>>* results) override {
|
||||
SkASSERT(!results->count());
|
||||
|
||||
// Until MDB is landed we will most-likely only have one opList.
|
||||
@ -360,8 +361,8 @@ public:
|
||||
SkASSERT(10 == fAtlasProxy->priv().getProxyRefCnt());
|
||||
// The backing GrSurface should have only 1 though bc there is only one proxy
|
||||
SkASSERT(1 == fAtlasProxy->testingOnly_getBackingRefCnt());
|
||||
sk_sp<GrRenderTargetContext> rtc = resourceProvider->makeRenderTargetContext(
|
||||
fAtlasProxy, GrColorType::kRGBA_8888, nullptr, nullptr);
|
||||
auto rtc = resourceProvider->makeRenderTargetContext(fAtlasProxy, GrColorType::kRGBA_8888,
|
||||
nullptr, nullptr);
|
||||
|
||||
// clear the atlas
|
||||
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
|
||||
@ -435,12 +436,11 @@ private:
|
||||
// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
|
||||
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
|
||||
sk_sp<GrTextureProxy> atlasProxy) {
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
3*kDrawnTileSize,
|
||||
kDrawnTileSize,
|
||||
GrColorType::kRGBA_8888,
|
||||
nullptr));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
3* kDrawnTileSize,
|
||||
kDrawnTileSize,
|
||||
GrColorType::kRGBA_8888,
|
||||
nullptr);
|
||||
|
||||
rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
|
||||
|
||||
@ -553,12 +553,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
|
||||
static const int kFinalWidth = 6*kDrawnTileSize;
|
||||
static const int kFinalHeight = kDrawnTileSize;
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
|
||||
kFinalWidth,
|
||||
kFinalHeight,
|
||||
GrColorType::kRGBA_8888,
|
||||
nullptr));
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, kFinalWidth, kFinalHeight, GrColorType::kRGBA_8888, nullptr);
|
||||
|
||||
rtc->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes);
|
||||
|
||||
|
@ -117,7 +117,7 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context, int array
|
||||
controlPixelData.begin(), 0);
|
||||
SkASSERT(proxy);
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), SkColorTypeToGrColorType(colorType), kPremul_SkAlphaType);
|
||||
|
||||
if (!sContext->readPixels(dstInfo, readBuffer.begin(), 0, {0, 0})) {
|
||||
|
@ -79,9 +79,9 @@ static void test_path(skiatest::Reporter* reporter,
|
||||
ctx->setResourceCacheLimits(100, 8000000);
|
||||
GrResourceCache* cache = ctx->priv().getResourceCache();
|
||||
|
||||
sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext(
|
||||
auto rtc = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin));
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
if (!rtc) {
|
||||
return;
|
||||
}
|
||||
|
@ -132,9 +132,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
|
||||
GrGpu* gpu = context->priv().getGpu();
|
||||
#endif
|
||||
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1, 1,
|
||||
GrColorType::kRGBA_8888, nullptr));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr);
|
||||
if (!renderTargetContext) {
|
||||
ERRORF(reporter, "Could not create render target context.");
|
||||
return;
|
||||
|
@ -172,9 +172,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
|
||||
|
||||
for (bool makeClone : {false, true}) {
|
||||
for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
|
||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||
context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr));
|
||||
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr);
|
||||
{
|
||||
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
|
||||
format, desc, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
|
||||
@ -346,8 +345,8 @@ bool log_pixels(GrColor* pixels, int widthHeight, SkString* dst) {
|
||||
}
|
||||
|
||||
bool log_texture_proxy(GrContext* context, sk_sp<GrTextureProxy> src, SkString* dst) {
|
||||
sk_sp<GrSurfaceContext> sContext(
|
||||
context->priv().makeWrappedSurfaceContext(src, GrColorType::kRGBA_8888, kLogAlphaType));
|
||||
auto sContext =
|
||||
context->priv().makeWrappedSurfaceContext(src, GrColorType::kRGBA_8888, kLogAlphaType);
|
||||
SkImageInfo ii =
|
||||
SkImageInfo::Make(src->width(), src->height(), kRGBA_8888_SkColorType, kLogAlphaType);
|
||||
SkBitmap bm;
|
||||
@ -439,7 +438,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
||||
|
||||
// Make the destination context for the test.
|
||||
static constexpr int kRenderSize = 256;
|
||||
sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
|
||||
|
||||
sk_sp<GrTextureProxy> proxies[2];
|
||||
@ -673,7 +672,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
|
||||
|
||||
// Make the destination context for the test.
|
||||
static constexpr int kRenderSize = 1024;
|
||||
sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
|
||||
|
||||
sk_sp<GrTextureProxy> proxies[2];
|
||||
|
@ -429,7 +429,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
static void test_readpixels_texture(skiatest::Reporter* reporter,
|
||||
sk_sp<GrSurfaceContext> sContext,
|
||||
std::unique_ptr<GrSurfaceContext> sContext,
|
||||
const SkImageInfo& surfaceInfo) {
|
||||
for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
|
||||
const SkIRect& srcRect = gReadPixelsTestRects[rect];
|
||||
@ -473,7 +473,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
|
||||
sk_sp<GrTextureProxy> proxy = sk_gpu_test::MakeTextureProxyFromData(
|
||||
context, renderable, DEV_W, DEV_H, bmp.colorType(), bmp.alphaType(), origin,
|
||||
bmp.getPixels(), bmp.rowBytes());
|
||||
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), SkColorTypeToGrColorType(bmp.colorType()),
|
||||
kPremul_SkAlphaType);
|
||||
auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType);
|
||||
|
@ -75,8 +75,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
ERRORF(reporter, "Could not create alpha texture.");
|
||||
return;
|
||||
}
|
||||
sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), GrColorType::kAlpha_8, kPremul_SkAlphaType));
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), GrColorType::kAlpha_8, kPremul_SkAlphaType);
|
||||
|
||||
sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
|
||||
|
||||
@ -194,7 +194,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
|
||||
auto sContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(proxy), info.fColorType, kPremul_SkAlphaType);
|
||||
|
||||
for (auto rowBytes : kRowBytes) {
|
||||
|
@ -26,8 +26,8 @@
|
||||
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
|
||||
sk_sp<GrTextureProxy> rectProxy, GrColorType colorType,
|
||||
uint32_t expectedPixelValues[]) {
|
||||
sk_sp<GrRenderTargetContext> rtContext(context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, rectProxy->width(), rectProxy->height(), colorType, nullptr));
|
||||
auto rtContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, rectProxy->width(), rectProxy->height(), colorType, nullptr);
|
||||
for (auto filter : {GrSamplerState::Filter::kNearest,
|
||||
GrSamplerState::Filter::kBilerp,
|
||||
GrSamplerState::Filter::kMipMap}) {
|
||||
@ -184,7 +184,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
||||
test_copy_from_surface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888,
|
||||
refPixels, "RectangleTexture-copy-from");
|
||||
|
||||
sk_sp<GrSurfaceContext> rectContext = context->priv().makeWrappedSurfaceContext(
|
||||
auto rectContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(rectProxy), GrColorType::kRGBA_8888, kPremul_SkAlphaType);
|
||||
SkASSERT(rectContext);
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
static const int kSize = 64;
|
||||
|
||||
static sk_sp<GrRenderTargetContext> get_rtc(GrContext* ctx) {
|
||||
static std::unique_ptr<GrRenderTargetContext> get_rtc(GrContext* ctx) {
|
||||
return ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, kSize,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
}
|
||||
@ -37,7 +37,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RenderTargetContextTest, reporter, ctxInfo) {
|
||||
// Calling instantiate on a GrRenderTargetContext's textureProxy also instantiates the
|
||||
// GrRenderTargetContext
|
||||
{
|
||||
sk_sp<GrRenderTargetContext> rtCtx(get_rtc(ctx));
|
||||
auto rtCtx = get_rtc(ctx);
|
||||
|
||||
check_instantiation_status(reporter, rtCtx.get(), false);
|
||||
|
||||
@ -51,7 +51,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RenderTargetContextTest, reporter, ctxInfo) {
|
||||
|
||||
// readPixels switches a deferred rtCtx to wrapped
|
||||
{
|
||||
sk_sp<GrRenderTargetContext> rtCtx(get_rtc(ctx));
|
||||
auto rtCtx = get_rtc(ctx);
|
||||
|
||||
check_instantiation_status(reporter, rtCtx.get(), false);
|
||||
|
||||
|
@ -186,8 +186,9 @@ static std::unique_ptr<uint32_t[]> make_data() {
|
||||
return data;
|
||||
}
|
||||
|
||||
static sk_sp<GrSurfaceContext> make_surface_context(Encoding contextEncoding, GrContext* context,
|
||||
skiatest::Reporter* reporter) {
|
||||
static std::unique_ptr<GrSurfaceContext> make_surface_context(Encoding contextEncoding,
|
||||
GrContext* context,
|
||||
skiatest::Reporter* reporter) {
|
||||
auto surfaceContext = context->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kExact, kW, kH, GrColorType::kRGBA_8888,
|
||||
encoding_as_color_space(contextEncoding), 1, GrMipMapped::kNo,
|
||||
|
@ -729,31 +729,19 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
|
||||
return surface;
|
||||
}
|
||||
|
||||
static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> surface,
|
||||
std::function<sk_sp<GrSurfaceContext>(SkSurface*)> grSurfaceGetter,
|
||||
uint32_t expectedValue) {
|
||||
if (!surface) {
|
||||
ERRORF(reporter, "Could not create GPU SkSurface.");
|
||||
return;
|
||||
}
|
||||
int w = surface->width();
|
||||
int h = surface->height();
|
||||
static void test_surface_context_clear(skiatest::Reporter* reporter,
|
||||
GrSurfaceContext* surfaceContext, uint32_t expectedValue) {
|
||||
int w = surfaceContext->width();
|
||||
int h = surfaceContext->height();
|
||||
|
||||
SkImageInfo ii = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
|
||||
SkAutoPixmapStorage readback;
|
||||
readback.alloc(ii);
|
||||
|
||||
sk_sp<GrSurfaceContext> grSurfaceContext(grSurfaceGetter(surface.get()));
|
||||
if (!grSurfaceContext) {
|
||||
ERRORF(reporter, "Could access render target of GPU SkSurface.");
|
||||
return;
|
||||
}
|
||||
surface.reset();
|
||||
|
||||
readback.erase(~expectedValue);
|
||||
grSurfaceContext->readPixels(readback.info(), readback.writable_addr(), readback.rowBytes(),
|
||||
{0, 0});
|
||||
surfaceContext->readPixels(readback.info(), readback.writable_addr(), readback.rowBytes(),
|
||||
{0, 0});
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
uint32_t pixel = readback.addr32()[y * w + x];
|
||||
@ -775,37 +763,52 @@ static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> su
|
||||
|
||||
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
|
||||
std::function<sk_sp<GrSurfaceContext>(SkSurface*)> grSurfaceContextGetters[] = {
|
||||
[] (SkSurface* s){
|
||||
return sk_ref_sp(s->getCanvas()->internal_private_accessTopLayerRenderTargetContext());
|
||||
},
|
||||
[context] (SkSurface* s){
|
||||
sk_sp<SkImage> i(s->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());
|
||||
}
|
||||
// Snaps an image from a surface and then makes a GrSurfaceContext from the image's texture.
|
||||
auto makeImageSurfaceContext = [context](SkSurface* surface) {
|
||||
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());
|
||||
};
|
||||
|
||||
for (auto grSurfaceGetter : grSurfaceContextGetters) {
|
||||
// Test that non-wrapped RTs are created clear.
|
||||
for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) {
|
||||
auto surface = surface_func(context, kPremul_SkAlphaType, nullptr);
|
||||
test_surface_clear(reporter, surface, grSurfaceGetter, 0x0);
|
||||
// Test that non-wrapped RTs are created clear.
|
||||
for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) {
|
||||
auto surface = surface_func(context, kPremul_SkAlphaType, nullptr);
|
||||
if (!surface) {
|
||||
ERRORF(reporter, "Could not create GPU SkSurface.");
|
||||
return;
|
||||
}
|
||||
// Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
|
||||
const SkColor4f kOrigColor { .67f, .67f, .67f, 1 };
|
||||
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
|
||||
&create_gpu_surface_backend_texture_as_render_target}) {
|
||||
GrBackendTexture backendTex;
|
||||
auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex);
|
||||
test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor.toSkColor());
|
||||
surface.reset();
|
||||
context->deleteBackendTexture(backendTex);
|
||||
auto rtc = surface->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
|
||||
if (!rtc) {
|
||||
ERRORF(reporter, "Could access surface context of GPU SkSurface.");
|
||||
return;
|
||||
}
|
||||
test_surface_context_clear(reporter, rtc, 0x0);
|
||||
auto imageSurfaceCtx = makeImageSurfaceContext(surface.get());
|
||||
test_surface_context_clear(reporter, imageSurfaceCtx.get(), 0x0);
|
||||
}
|
||||
|
||||
// Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
|
||||
const SkColor4f kOrigColor{.67f, .67f, .67f, 1};
|
||||
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
|
||||
&create_gpu_surface_backend_texture_as_render_target}) {
|
||||
GrBackendTexture backendTex;
|
||||
auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex);
|
||||
if (!surface) {
|
||||
ERRORF(reporter, "Could not create GPU SkSurface.");
|
||||
return;
|
||||
}
|
||||
auto rtc = surface->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
|
||||
if (!rtc) {
|
||||
ERRORF(reporter, "Could access surface context of GPU SkSurface.");
|
||||
return;
|
||||
}
|
||||
test_surface_context_clear(reporter, rtc, kOrigColor.toSkColor());
|
||||
auto imageSurfaceCtx = makeImageSurfaceContext(surface.get());
|
||||
test_surface_context_clear(reporter, imageSurfaceCtx.get(), kOrigColor.toSkColor());
|
||||
context->deleteBackendTexture(backendTex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -733,9 +733,9 @@ static void test_path(GrContext* ctx,
|
||||
|
||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
|
||||
GrContext* ctx = ctxInfo.grContext();
|
||||
sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext(
|
||||
auto rtc = ctx->priv().makeDeferredRenderTargetContext(
|
||||
SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin));
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
if (!rtc) {
|
||||
return;
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ void test_copy_from_surface(skiatest::Reporter* reporter, GrContext* context, Gr
|
||||
SkBackingFit::kExact, SkBudgeted::kYes);
|
||||
SkASSERT(dstProxy);
|
||||
|
||||
sk_sp<GrSurfaceContext> dstContext = context->priv().makeWrappedSurfaceContext(
|
||||
std::move(dstProxy), colorType, kPremul_SkAlphaType);
|
||||
SkASSERT(dstContext.get());
|
||||
auto dstContext = context->priv().makeWrappedSurfaceContext(std::move(dstProxy), colorType,
|
||||
kPremul_SkAlphaType);
|
||||
SkASSERT(dstContext);
|
||||
|
||||
test_read_pixels(reporter, dstContext.get(), expectedPixelValues, testName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user