Rename GrContext's newDrawContext & drawContext to makeDrawContext
These both return sk_sp. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2186073002 Review-Url: https://codereview.chromium.org/2186073002
This commit is contained in:
parent
81ce4a9c55
commit
6738c70242
@ -189,22 +189,22 @@ public:
|
|||||||
*
|
*
|
||||||
* @return a draw context
|
* @return a draw context
|
||||||
*/
|
*/
|
||||||
sk_sp<GrDrawContext> drawContext(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpace> colorSpace,
|
sk_sp<GrDrawContext> makeDrawContext(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpace> colorSpace,
|
||||||
const SkSurfaceProps* = nullptr);
|
const SkSurfaceProps* = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create both a GrRenderTarget and a matching GrDrawContext to wrap it.
|
* Create both a GrRenderTarget and a matching GrDrawContext to wrap it.
|
||||||
* We guarantee that "asTexture" will succeed for drawContexts created
|
* We guarantee that "asTexture" will succeed for drawContexts created
|
||||||
* via this entry point.
|
* via this entry point.
|
||||||
*/
|
*/
|
||||||
sk_sp<GrDrawContext> newDrawContext(SkBackingFit fit,
|
sk_sp<GrDrawContext> makeDrawContext(SkBackingFit fit,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GrPixelConfig config,
|
GrPixelConfig config,
|
||||||
sk_sp<SkColorSpace> colorSpace,
|
sk_sp<SkColorSpace> colorSpace,
|
||||||
int sampleCnt = 0,
|
int sampleCnt = 0,
|
||||||
GrSurfaceOrigin origin = kDefault_GrSurfaceOrigin,
|
GrSurfaceOrigin origin = kDefault_GrSurfaceOrigin,
|
||||||
const SkSurfaceProps* surfaceProps = nullptr,
|
const SkSurfaceProps* surfaceProps = nullptr,
|
||||||
SkBudgeted = SkBudgeted::kYes);
|
SkBudgeted = SkBudgeted::kYes);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Misc.
|
// Misc.
|
||||||
|
@ -281,10 +281,10 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
|
|||||||
paint.addColorFragmentProcessor(std::move(fp));
|
paint.addColorFragmentProcessor(std::move(fp));
|
||||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
bounds.width(), bounds.height(),
|
bounds.width(), bounds.height(),
|
||||||
kRGBA_8888_GrPixelConfig,
|
kRGBA_8888_GrPixelConfig,
|
||||||
std::move(colorSpace)));
|
std::move(colorSpace)));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,9 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
width, height, config,
|
width, height, config,
|
||||||
std::move(colorSpace)));
|
std::move(colorSpace)));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -102,9 +102,9 @@ sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* contex
|
|||||||
config = kRGBA_8888_GrPixelConfig;
|
config = kRGBA_8888_GrPixelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
bounds.width(), bounds.height(),
|
bounds.width(), bounds.height(),
|
||||||
config, nullptr));
|
config, nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
|
|||||||
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
|
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(
|
sk_sp<GrDrawContext> drawContext(
|
||||||
context->newDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.height(),
|
context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.height(),
|
||||||
kSkia8888_GrPixelConfig, sk_ref_sp(source->getColorSpace())));
|
kSkia8888_GrPixelConfig, sk_ref_sp(source->getColorSpace())));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -226,9 +226,9 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
|
|||||||
const int height = dstBounds.height();
|
const int height = dstBounds.height();
|
||||||
const GrPixelConfig config = srcTexture->config();
|
const GrPixelConfig config = srcTexture->config();
|
||||||
|
|
||||||
sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> dstDrawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
width, height, config, colorSpace,
|
width, height, config, colorSpace,
|
||||||
0, kDefault_GrSurfaceOrigin));
|
0, kDefault_GrSurfaceOrigin));
|
||||||
if (!dstDrawContext) {
|
if (!dstDrawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -246,9 +246,9 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
|
|||||||
return dstDrawContext;
|
return dstDrawContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> tmpDrawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> tmpDrawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
width, height, config, colorSpace,
|
width, height, config, colorSpace,
|
||||||
0, kDefault_GrSurfaceOrigin));
|
0, kDefault_GrSurfaceOrigin));
|
||||||
if (!tmpDrawContext) {
|
if (!tmpDrawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -408,11 +408,11 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(SkSpecialIma
|
|||||||
sk_sp<GrTexture> inputTexture(input->asTextureRef(context));
|
sk_sp<GrTexture> inputTexture(input->asTextureRef(context));
|
||||||
SkASSERT(inputTexture);
|
SkASSERT(inputTexture);
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
offsetBounds.width(),
|
offsetBounds.width(),
|
||||||
offsetBounds.height(),
|
offsetBounds.height(),
|
||||||
kRGBA_8888_GrPixelConfig,
|
kRGBA_8888_GrPixelConfig,
|
||||||
sk_ref_sp(source->getColorSpace())));
|
sk_ref_sp(source->getColorSpace())));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -485,10 +485,10 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
|
|||||||
SkASSERT(radius.width() > 0 || radius.height() > 0);
|
SkASSERT(radius.width() > 0 || radius.height() > 0);
|
||||||
|
|
||||||
if (radius.fWidth > 0) {
|
if (radius.fWidth > 0) {
|
||||||
sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> dstDrawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
rect.width(), rect.height(),
|
rect.width(), rect.height(),
|
||||||
kSkia8888_GrPixelConfig,
|
kSkia8888_GrPixelConfig,
|
||||||
colorSpace));
|
colorSpace));
|
||||||
if (!dstDrawContext) {
|
if (!dstDrawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -507,10 +507,10 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
|
|||||||
srcRect = dstRect;
|
srcRect = dstRect;
|
||||||
}
|
}
|
||||||
if (radius.fHeight > 0) {
|
if (radius.fHeight > 0) {
|
||||||
sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> dstDrawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
rect.width(), rect.height(),
|
rect.width(), rect.height(),
|
||||||
kSkia8888_GrPixelConfig,
|
kSkia8888_GrPixelConfig,
|
||||||
colorSpace));
|
colorSpace));
|
||||||
if (!dstDrawContext) {
|
if (!dstDrawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -241,10 +241,10 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
|
|||||||
|
|
||||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
bounds.width(), bounds.height(),
|
bounds.width(), bounds.height(),
|
||||||
kSkia8888_GrPixelConfig,
|
kSkia8888_GrPixelConfig,
|
||||||
sk_ref_sp(source->getColorSpace())));
|
sk_ref_sp(source->getColorSpace())));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -109,12 +109,12 @@ static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
|
|||||||
config = kAlpha_8_GrPixelConfig;
|
config = kAlpha_8_GrPixelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
maskRect.width(),
|
maskRect.width(),
|
||||||
maskRect.height(),
|
maskRect.height(),
|
||||||
config,
|
config,
|
||||||
nullptr,
|
nullptr,
|
||||||
sampleCnt));
|
sampleCnt));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -462,10 +462,10 @@ sk_sp<GrTexture> GrClipMaskManager::CreateAlphaClipMask(GrContext* context,
|
|||||||
config = kAlpha_8_GrPixelConfig;
|
config = kAlpha_8_GrPixelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> dc(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> dc(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
clipSpaceIBounds.width(),
|
clipSpaceIBounds.width(),
|
||||||
clipSpaceIBounds.height(),
|
clipSpaceIBounds.height(),
|
||||||
config, nullptr));
|
config, nullptr));
|
||||||
if (!dc) {
|
if (!dc) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
|||||||
// TODO: Need to decide the semantics of this function for color spaces. Do we support
|
// TODO: Need to decide the semantics of this function for color spaces. Do we support
|
||||||
// conversion from a passed-in color space? For now, specifying nullptr means that this
|
// conversion from a passed-in color space? For now, specifying nullptr means that this
|
||||||
// path will do no conversion, so it will match the behavior of the non-draw path.
|
// path will do no conversion, so it will match the behavior of the non-draw path.
|
||||||
sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(renderTarget), nullptr));
|
sk_sp<GrDrawContext> drawContext(this->makeDrawContext(sk_ref_sp(renderTarget), nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ bool GrContext::readSurfacePixels(GrSurface* src,
|
|||||||
// TODO: Need to decide the semantics of this function for color spaces. Do we support
|
// TODO: Need to decide the semantics of this function for color spaces. Do we support
|
||||||
// conversion to a passed-in color space? For now, specifying nullptr means that this
|
// conversion to a passed-in color space? For now, specifying nullptr means that this
|
||||||
// path will do no conversion, so it will match the behavior of the non-draw path.
|
// path will do no conversion, so it will match the behavior of the non-draw path.
|
||||||
sk_sp<GrDrawContext> tempDC = this->newDrawContext(tempDrawInfo.fTempSurfaceFit,
|
sk_sp<GrDrawContext> tempDC = this->makeDrawContext(tempDrawInfo.fTempSurfaceFit,
|
||||||
tempDrawInfo.fTempSurfaceDesc.fWidth,
|
tempDrawInfo.fTempSurfaceDesc.fWidth,
|
||||||
tempDrawInfo.fTempSurfaceDesc.fHeight,
|
tempDrawInfo.fTempSurfaceDesc.fHeight,
|
||||||
tempDrawInfo.fTempSurfaceDesc.fConfig,
|
tempDrawInfo.fTempSurfaceDesc.fConfig,
|
||||||
@ -540,7 +540,7 @@ bool GrContext::applyGamma(GrRenderTarget* dst, GrTexture* src, SkScalar gamma){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Supply color space?
|
// TODO: Supply color space?
|
||||||
sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst), nullptr));
|
sk_sp<GrDrawContext> drawContext(this->makeDrawContext(sk_ref_sp(dst), nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -602,7 +602,7 @@ bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe
|
|||||||
src->flushWrites();
|
src->flushWrites();
|
||||||
return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint);
|
return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint);
|
||||||
}
|
}
|
||||||
sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst->asRenderTarget()), nullptr));
|
sk_sp<GrDrawContext> drawContext(this->makeDrawContext(sk_ref_sp(dst->asRenderTarget()), nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -641,21 +641,21 @@ int GrContext::getRecommendedSampleCount(GrPixelConfig config,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sk_sp<GrDrawContext> GrContext::drawContext(sk_sp<GrRenderTarget> rt,
|
sk_sp<GrDrawContext> GrContext::makeDrawContext(sk_sp<GrRenderTarget> rt,
|
||||||
sk_sp<SkColorSpace> colorSpace,
|
sk_sp<SkColorSpace> colorSpace,
|
||||||
const SkSurfaceProps* surfaceProps) {
|
const SkSurfaceProps* surfaceProps) {
|
||||||
ASSERT_SINGLE_OWNER
|
ASSERT_SINGLE_OWNER
|
||||||
return fDrawingManager->drawContext(std::move(rt), std::move(colorSpace), surfaceProps);
|
return fDrawingManager->drawContext(std::move(rt), std::move(colorSpace), surfaceProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> GrContext::newDrawContext(SkBackingFit fit,
|
sk_sp<GrDrawContext> GrContext::makeDrawContext(SkBackingFit fit,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GrPixelConfig config,
|
GrPixelConfig config,
|
||||||
sk_sp<SkColorSpace> colorSpace,
|
sk_sp<SkColorSpace> colorSpace,
|
||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
GrSurfaceOrigin origin,
|
GrSurfaceOrigin origin,
|
||||||
const SkSurfaceProps* surfaceProps,
|
const SkSurfaceProps* surfaceProps,
|
||||||
SkBudgeted budgeted) {
|
SkBudgeted budgeted) {
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
desc.fOrigin = origin;
|
desc.fOrigin = origin;
|
||||||
@ -674,8 +674,8 @@ sk_sp<GrDrawContext> GrContext::newDrawContext(SkBackingFit fit,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(tex->asRenderTarget()),
|
sk_sp<GrDrawContext> drawContext(this->makeDrawContext(sk_ref_sp(tex->asRenderTarget()),
|
||||||
std::move(colorSpace), surfaceProps));
|
std::move(colorSpace), surfaceProps));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ void GrRenderTarget::discard() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(this), nullptr));
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(sk_ref_sp(this), nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> copyDC = context->newDrawContext(SkBackingFit::kExact, copyParams.fWidth,
|
sk_sp<GrDrawContext> copyDC = context->makeDrawContext(SkBackingFit::kExact, copyParams.fWidth,
|
||||||
copyParams.fHeight, config, nullptr);
|
copyParams.fHeight, config, nullptr);
|
||||||
if (!copyDC) {
|
if (!copyDC) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -69,34 +69,34 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
|
|||||||
// sizes however we optimize for two other cases - all planes are the same (1 draw to YUV),
|
// sizes however we optimize for two other cases - all planes are the same (1 draw to YUV),
|
||||||
// and U and V are the same but Y differs (2 draws, one for Y, one for UV).
|
// and U and V are the same but Y differs (2 draws, one for Y, one for UV).
|
||||||
if (sizes[0] == sizes[1] && sizes[1] == sizes[2]) {
|
if (sizes[0] == sizes[1] && sizes[1] == sizes[2]) {
|
||||||
yuvDrawContext = context->newDrawContext(SkBackingFit::kApprox,
|
yuvDrawContext = context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
sizes[0].fWidth, sizes[0].fHeight,
|
sizes[0].fWidth, sizes[0].fHeight,
|
||||||
kRGBA_8888_GrPixelConfig, nullptr);
|
kRGBA_8888_GrPixelConfig, nullptr);
|
||||||
if (!yuvDrawContext) {
|
if (!yuvDrawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
yDrawContext = context->newDrawContext(SkBackingFit::kApprox,
|
yDrawContext = context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
sizes[0].fWidth, sizes[0].fHeight,
|
sizes[0].fWidth, sizes[0].fHeight,
|
||||||
singleChannelPixelConfig, nullptr);
|
singleChannelPixelConfig, nullptr);
|
||||||
if (!yDrawContext) {
|
if (!yDrawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sizes[1] == sizes[2]) {
|
if (sizes[1] == sizes[2]) {
|
||||||
// TODO: Add support for GL_RG when available.
|
// TODO: Add support for GL_RG when available.
|
||||||
uvDrawContext = context->newDrawContext(SkBackingFit::kApprox,
|
uvDrawContext = context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
sizes[1].fWidth, sizes[1].fHeight,
|
sizes[1].fWidth, sizes[1].fHeight,
|
||||||
kRGBA_8888_GrPixelConfig, nullptr);
|
kRGBA_8888_GrPixelConfig, nullptr);
|
||||||
if (!uvDrawContext) {
|
if (!uvDrawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uDrawContext = context->newDrawContext(SkBackingFit::kApprox,
|
uDrawContext = context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
sizes[1].fWidth, sizes[1].fHeight,
|
sizes[1].fWidth, sizes[1].fHeight,
|
||||||
singleChannelPixelConfig, nullptr);
|
singleChannelPixelConfig, nullptr);
|
||||||
vDrawContext = context->newDrawContext(SkBackingFit::kApprox,
|
vDrawContext = context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
sizes[2].fWidth, sizes[2].fHeight,
|
sizes[2].fWidth, sizes[2].fHeight,
|
||||||
singleChannelPixelConfig, nullptr);
|
singleChannelPixelConfig, nullptr);
|
||||||
if (!uDrawContext || !vDrawContext) {
|
if (!uDrawContext || !vDrawContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -114,10 +114,10 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We never want to perform color-space conversion during the decode
|
// We never want to perform color-space conversion during the decode
|
||||||
sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact,
|
sk_sp<GrDrawContext> drawContext(ctx->makeDrawContext(SkBackingFit::kExact,
|
||||||
desc.fWidth, desc.fHeight,
|
desc.fWidth, desc.fHeight,
|
||||||
desc.fConfig, nullptr,
|
desc.fConfig, nullptr,
|
||||||
desc.fSampleCnt));
|
desc.fSampleCnt));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpac
|
|||||||
|
|
||||||
GrContext* context = rt->getContext();
|
GrContext* context = rt->getContext();
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), std::move(colorSpace),
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(std::move(rt), std::move(colorSpace),
|
||||||
props));
|
props));
|
||||||
return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags));
|
return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,10 +187,10 @@ sk_sp<GrDrawContext> SkGpuDevice::MakeDrawContext(GrContext* context,
|
|||||||
|
|
||||||
GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps());
|
GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps());
|
||||||
|
|
||||||
return context->newDrawContext(SkBackingFit::kExact, // Why exact?
|
return context->makeDrawContext(SkBackingFit::kExact, // Why exact?
|
||||||
origInfo.width(), origInfo.height(),
|
origInfo.width(), origInfo.height(),
|
||||||
config, sk_ref_sp(cs), sampleCount,
|
config, sk_ref_sp(cs), sampleCount,
|
||||||
origin, surfaceProps, budgeted);
|
origin, surfaceProps, budgeted);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw,
|
sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw,
|
||||||
@ -1745,13 +1745,13 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
|
|||||||
SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApprox
|
SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApprox
|
||||||
: SkBackingFit::kExact;
|
: SkBackingFit::kExact;
|
||||||
|
|
||||||
sk_sp<GrDrawContext> dc(fContext->newDrawContext(fit,
|
sk_sp<GrDrawContext> dc(fContext->makeDrawContext(fit,
|
||||||
cinfo.fInfo.width(), cinfo.fInfo.height(),
|
cinfo.fInfo.width(), cinfo.fInfo.height(),
|
||||||
fDrawContext->config(),
|
fDrawContext->config(),
|
||||||
sk_ref_sp(fDrawContext->getColorSpace()),
|
sk_ref_sp(fDrawContext->getColorSpace()),
|
||||||
fDrawContext->desc().fSampleCnt,
|
fDrawContext->desc().fSampleCnt,
|
||||||
kDefault_GrSurfaceOrigin,
|
kDefault_GrSurfaceOrigin,
|
||||||
&props));
|
&props));
|
||||||
if (!dc) {
|
if (!dc) {
|
||||||
SkErrorInternals::SetError( kInternalError_SkError,
|
SkErrorInternals::SetError( kInternalError_SkError,
|
||||||
"---- failed to create gpu device texture [%d %d]\n",
|
"---- failed to create gpu device texture [%d %d]\n",
|
||||||
|
@ -173,10 +173,10 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrDrawContext> readDC(context->newDrawContext(SkBackingFit::kExact, kSize, kSize,
|
sk_sp<GrDrawContext> readDC(context->makeDrawContext(SkBackingFit::kExact, kSize, kSize,
|
||||||
kConfig, nullptr));
|
kConfig, nullptr));
|
||||||
sk_sp<GrDrawContext> tempDC(context->newDrawContext(SkBackingFit::kExact, kSize, kSize,
|
sk_sp<GrDrawContext> tempDC(context->makeDrawContext(SkBackingFit::kExact, kSize, kSize,
|
||||||
kConfig, nullptr));
|
kConfig, nullptr));
|
||||||
if (!readDC || !tempDC) {
|
if (!readDC || !tempDC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -389,8 +389,8 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup dummy SkPaint / GrPaint / GrDrawContext
|
// Setup dummy SkPaint / GrPaint / GrDrawContext
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox, 1024, 1024,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox, 1024, 1024,
|
||||||
kSkia8888_GrPixelConfig, nullptr));
|
kSkia8888_GrPixelConfig, nullptr));
|
||||||
|
|
||||||
GrColor color = GrRandomColor(random);
|
GrColor color = GrRandomColor(random);
|
||||||
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
||||||
|
@ -250,12 +250,12 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
|
|||||||
const int height = yuvSizes[0].fHeight;
|
const int height = yuvSizes[0].fHeight;
|
||||||
|
|
||||||
// Needs to be a render target in order to draw to it for the yuv->rgb conversion.
|
// Needs to be a render target in order to draw to it for the yuv->rgb conversion.
|
||||||
sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact,
|
sk_sp<GrDrawContext> drawContext(ctx->makeDrawContext(SkBackingFit::kExact,
|
||||||
width, height,
|
width, height,
|
||||||
kRGBA_8888_GrPixelConfig,
|
kRGBA_8888_GrPixelConfig,
|
||||||
std::move(imageColorSpace),
|
std::move(imageColorSpace),
|
||||||
0,
|
0,
|
||||||
origin));
|
origin));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ static bool reset_dc(sk_sp<GrDrawContext>* dc, GrContext* context, int w, int h)
|
|||||||
}
|
}
|
||||||
context->freeGpuResources();
|
context->freeGpuResources();
|
||||||
|
|
||||||
*dc = context->newDrawContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, nullptr);
|
*dc = context->makeDrawContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, nullptr);
|
||||||
|
|
||||||
SkASSERT((*dc)->accessRenderTarget()->getUniqueID() != oldID);
|
SkASSERT((*dc)->accessRenderTarget()->getUniqueID() != oldID);
|
||||||
|
|
||||||
|
@ -63,22 +63,22 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(AADistanceFieldPathRenderer, reporter, ctxInfo)
|
|||||||
if (!ctxInfo.grContext()->caps()->shaderCaps()->shaderDerivativeSupport()) {
|
if (!ctxInfo.grContext()->caps()->shaderCaps()->shaderDerivativeSupport()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> dc(ctxInfo.grContext()->makeDrawContext(SkBackingFit::kApprox,
|
||||||
800, 800,
|
800, 800,
|
||||||
kSkia8888_GrPixelConfig,
|
kSkia8888_GrPixelConfig,
|
||||||
nullptr,
|
nullptr,
|
||||||
0,
|
0,
|
||||||
kTopLeft_GrSurfaceOrigin));
|
kTopLeft_GrSurfaceOrigin));
|
||||||
if (!drawContext) {
|
if (!dc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrAADistanceFieldPathRenderer dfpr;
|
GrAADistanceFieldPathRenderer dfpr;
|
||||||
GrTestTarget tt;
|
GrTestTarget tt;
|
||||||
ctxInfo.grContext()->getTestTarget(&tt, drawContext);
|
ctxInfo.grContext()->getTestTarget(&tt, dc);
|
||||||
GrResourceProvider* rp = tt.resourceProvider();
|
GrResourceProvider* rp = tt.resourceProvider();
|
||||||
|
|
||||||
test_far_from_origin(drawContext.get(), &dfpr, rp);
|
test_far_from_origin(dc.get(), &dfpr, rp);
|
||||||
ctxInfo.grContext()->flush();
|
ctxInfo.grContext()->flush();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -154,13 +154,13 @@ static sk_sp<GrDrawContext> random_draw_context(GrContext* context,
|
|||||||
: kBottomLeft_GrSurfaceOrigin;
|
: kBottomLeft_GrSurfaceOrigin;
|
||||||
int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0;
|
int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0;
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExact,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kExact,
|
||||||
kRenderTargetWidth,
|
kRenderTargetWidth,
|
||||||
kRenderTargetHeight,
|
kRenderTargetHeight,
|
||||||
kRGBA_8888_GrPixelConfig,
|
kRGBA_8888_GrPixelConfig,
|
||||||
nullptr,
|
nullptr,
|
||||||
sampleCnt,
|
sampleCnt,
|
||||||
origin));
|
origin));
|
||||||
return drawContext;
|
return drawContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,11 +343,11 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
|||||||
drawingManager->flush();
|
drawingManager->flush();
|
||||||
|
|
||||||
// Validate that GrFPs work correctly without an input.
|
// Validate that GrFPs work correctly without an input.
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExact,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kExact,
|
||||||
kRenderTargetWidth,
|
kRenderTargetWidth,
|
||||||
kRenderTargetHeight,
|
kRenderTargetHeight,
|
||||||
kRGBA_8888_GrPixelConfig,
|
kRGBA_8888_GrPixelConfig,
|
||||||
nullptr));
|
nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
SkDebugf("Could not allocate a drawContext");
|
SkDebugf("Could not allocate a drawContext");
|
||||||
return false;
|
return false;
|
||||||
|
@ -104,9 +104,9 @@ private:
|
|||||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
|
||||||
GrContext* context = ctxInfo.grContext();
|
GrContext* context = ctxInfo.grContext();
|
||||||
|
|
||||||
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApprox,
|
||||||
1, 1, kRGBA_8888_GrPixelConfig,
|
1, 1, kRGBA_8888_GrPixelConfig,
|
||||||
nullptr));
|
nullptr));
|
||||||
if (!drawContext) {
|
if (!drawContext) {
|
||||||
ERRORF(reporter, "Could not create draw context.");
|
ERRORF(reporter, "Could not create draw context.");
|
||||||
return;
|
return;
|
||||||
|
@ -90,8 +90,8 @@ static void test_clear(skiatest::Reporter* reporter, GrContext* context,
|
|||||||
GrTexture* rectangleTexture) {
|
GrTexture* rectangleTexture) {
|
||||||
if (rectangleTexture->asRenderTarget()) {
|
if (rectangleTexture->asRenderTarget()) {
|
||||||
sk_sp<GrDrawContext> dc(
|
sk_sp<GrDrawContext> dc(
|
||||||
context->drawContext(sk_ref_sp(rectangleTexture->asRenderTarget()),
|
context->makeDrawContext(sk_ref_sp(rectangleTexture->asRenderTarget()),
|
||||||
nullptr));
|
nullptr));
|
||||||
if (!dc) {
|
if (!dc) {
|
||||||
ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.");
|
ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.");
|
||||||
return;
|
return;
|
||||||
|
@ -121,12 +121,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
|
|||||||
|
|
||||||
// Create two draw contexts (L32 and S32)
|
// Create two draw contexts (L32 and S32)
|
||||||
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
|
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
|
||||||
sk_sp<GrDrawContext> l32DrawContext = context->newDrawContext(SkBackingFit::kExact, rtS, rtS,
|
sk_sp<GrDrawContext> l32DrawContext = context->makeDrawContext(SkBackingFit::kExact, rtS, rtS,
|
||||||
kSkia8888_GrPixelConfig,
|
kSkia8888_GrPixelConfig,
|
||||||
nullptr);
|
nullptr);
|
||||||
sk_sp<GrDrawContext> s32DrawContext = context->newDrawContext(SkBackingFit::kExact, rtS, rtS,
|
sk_sp<GrDrawContext> s32DrawContext = context->makeDrawContext(SkBackingFit::kExact, rtS, rtS,
|
||||||
kSkiaGamma8888_GrPixelConfig,
|
kSkiaGamma8888_GrPixelConfig,
|
||||||
std::move(srgbColorSpace));
|
std::move(srgbColorSpace));
|
||||||
|
|
||||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS));
|
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS));
|
||||||
GrNoClip noClip;
|
GrNoClip noClip;
|
||||||
|
@ -254,35 +254,35 @@ static void test_path(GrDrawContext* drawContext, GrResourceProvider* rp, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
|
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
|
||||||
sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
|
sk_sp<GrDrawContext> dc(ctxInfo.grContext()->makeDrawContext(SkBackingFit::kApprox,
|
||||||
800, 800,
|
800, 800,
|
||||||
kSkia8888_GrPixelConfig,
|
kSkia8888_GrPixelConfig,
|
||||||
nullptr,
|
nullptr,
|
||||||
0,
|
0,
|
||||||
kTopLeft_GrSurfaceOrigin));
|
kTopLeft_GrSurfaceOrigin));
|
||||||
if (!drawContext) {
|
if (!dc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrTestTarget tt;
|
GrTestTarget tt;
|
||||||
ctxInfo.grContext()->getTestTarget(&tt, drawContext);
|
ctxInfo.grContext()->getTestTarget(&tt, dc);
|
||||||
GrResourceProvider* rp = tt.resourceProvider();
|
GrResourceProvider* rp = tt.resourceProvider();
|
||||||
|
|
||||||
test_path(drawContext.get(), rp, create_path_0());
|
test_path(dc.get(), rp, create_path_0());
|
||||||
test_path(drawContext.get(), rp, create_path_1());
|
test_path(dc.get(), rp, create_path_1());
|
||||||
test_path(drawContext.get(), rp, create_path_2());
|
test_path(dc.get(), rp, create_path_2());
|
||||||
test_path(drawContext.get(), rp, create_path_3());
|
test_path(dc.get(), rp, create_path_3());
|
||||||
test_path(drawContext.get(), rp, create_path_4());
|
test_path(dc.get(), rp, create_path_4());
|
||||||
test_path(drawContext.get(), rp, create_path_5());
|
test_path(dc.get(), rp, create_path_5());
|
||||||
test_path(drawContext.get(), rp, create_path_6());
|
test_path(dc.get(), rp, create_path_6());
|
||||||
test_path(drawContext.get(), rp, create_path_7());
|
test_path(dc.get(), rp, create_path_7());
|
||||||
test_path(drawContext.get(), rp, create_path_8());
|
test_path(dc.get(), rp, create_path_8());
|
||||||
test_path(drawContext.get(), rp, create_path_9());
|
test_path(dc.get(), rp, create_path_9());
|
||||||
test_path(drawContext.get(), rp, create_path_10());
|
test_path(dc.get(), rp, create_path_10());
|
||||||
test_path(drawContext.get(), rp, create_path_11());
|
test_path(dc.get(), rp, create_path_11());
|
||||||
test_path(drawContext.get(), rp, create_path_12());
|
test_path(dc.get(), rp, create_path_12());
|
||||||
test_path(drawContext.get(), rp, create_path_13());
|
test_path(dc.get(), rp, create_path_13());
|
||||||
test_path(drawContext.get(), rp, create_path_14());
|
test_path(dc.get(), rp, create_path_14());
|
||||||
test_path(drawContext.get(), rp, create_path_15());
|
test_path(dc.get(), rp, create_path_15());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user