Rename renderTargetContextPriv to priv, and some more leftover DCs

API change is for non-public API.

TBR=bsalomon@google.com

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4060

Change-Id: I5011d753c3c6d1145ff242eab6baff2ae0647ba3
Reviewed-on: https://skia-review.googlesource.com/4060
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2016-10-27 15:13:22 -04:00 committed by Skia Commit-Bot
parent 130863ef51
commit 693a540272
19 changed files with 88 additions and 112 deletions

View File

@ -195,8 +195,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c])); new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c]));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
} }
++col; ++col;
if (numCols == col) { if (numCols == col) {
@ -328,8 +327,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f)); new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
} }
++col; ++col;
if (numCols == col) { if (numCols == col) {
@ -541,8 +539,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
new BezierQuadTestBatch(gp, bounds, color, DevToUV)); new BezierQuadTestBatch(gp, bounds, color, DevToUV));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
} }
++col; ++col;
if (numCols == col) { if (numCols == col) {

View File

@ -90,8 +90,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds, GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds,
nullptr, nullptr)); nullptr, nullptr));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
} }
canvas->restore(); canvas->restore();
x = x + fTestOffsetX; x = x + fTestOffsetX;

View File

@ -112,8 +112,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix, GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix,
renderRect, nullptr, nullptr)); renderRect, nullptr, nullptr));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
// Draw labels for the input to the processor and the processor to the right of // Draw labels for the input to the processor and the processor to the right of
// the test rect. The input label appears above the processor label. // the test rect. The input label appears above the processor label.

View File

@ -185,8 +185,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000)); SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
x += SkScalarCeilToScalar(path->getBounds().width() + kDX); x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
} }
@ -225,8 +224,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff000000)); SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff000000));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
x += SkScalarCeilToScalar(rect.width() + kDX); x += SkScalarCeilToScalar(rect.width() + kDX);
} }

View File

@ -118,8 +118,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(),
bounds, nullptr, nullptr)); bounds, nullptr, nullptr));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch( renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
grPaint, batch);
} else { } else {
drew = false; drew = false;
} }

View File

@ -130,8 +130,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix, GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
renderRect, nullptr, nullptr)); renderRect, nullptr, nullptr));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
x += renderRect.width() + kTestPad; x += renderRect.width() + kTestPad;
} }
y += renderRect.height() + kTestPad; y += renderRect.height() + kTestPad;

View File

@ -204,27 +204,24 @@ void WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack, SkCanvas
void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetContext* rtc, void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetContext* rtc,
const GrReducedClip& reducedClip, const GrReducedClip& reducedClip,
const GrPaint& paint) { const GrPaint& paint) {
sk_sp<GrRenderTargetContext> maskDC( sk_sp<GrRenderTargetContext> maskRTC(
ctx->makeRenderTargetContextWithFallback(SkBackingFit::kExact, kLayerRect.width(), ctx->makeRenderTargetContextWithFallback(SkBackingFit::kExact, kLayerRect.width(),
kLayerRect.height(), kAlpha_8_GrPixelConfig, kLayerRect.height(), kAlpha_8_GrPixelConfig,
nullptr)); nullptr));
if (!maskDC || if (!maskRTC ||
!ctx->resourceProvider()->attachStencilAttachment(maskDC->accessRenderTarget())) { !ctx->resourceProvider()->attachStencilAttachment(maskRTC->accessRenderTarget())) {
return; return;
} }
// Draw a checker pattern into the alpha mask so we can visualize the regions left untouched by // Draw a checker pattern into the alpha mask so we can visualize the regions left untouched by
// the clip mask generation. // the clip mask generation.
this->stencilCheckerboard(maskDC.get(), true); this->stencilCheckerboard(maskRTC.get(), true);
maskDC->clear(nullptr, GrColorPackA4(0xff), true); maskRTC->clear(nullptr, GrColorPackA4(0xff), true);
maskDC->renderTargetContextPriv().drawAndStencilRect(StencilOnlyClip(), maskRTC->priv().drawAndStencilRect(StencilOnlyClip(), &GrUserStencilSettings::kUnused,
&GrUserStencilSettings::kUnused, SkRegion::kDifference_Op, false, false, SkMatrix::I(),
SkRegion::kDifference_Op, false, false, SkRect::MakeIWH(maskRTC->width(), maskRTC->height()));
SkMatrix::I(), reducedClip.drawAlphaClipMask(maskRTC.get());
SkRect::MakeIWH(maskDC->width(), sk_sp<GrTexture> mask(maskRTC->asTexture());
maskDC->height()));
reducedClip.drawAlphaClipMask(maskDC.get());
sk_sp<GrTexture> mask(maskDC->asTexture());
int x = kCoverRect.x() - kLayerRect.x(), int x = kCoverRect.x() - kLayerRect.x(),
y = kCoverRect.y() - kLayerRect.y(); y = kCoverRect.y() - kLayerRect.y();
@ -266,13 +263,13 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, boo
0>() 0>()
); );
rtc->renderTargetContextPriv().clearStencilClip(GrFixedClip::Disabled(), false); rtc->priv().clearStencilClip(GrFixedClip::Disabled(), false);
for (int y = 0; y < kLayerRect.height(); y += kMaskCheckerSize) { for (int y = 0; y < kLayerRect.height(); y += kMaskCheckerSize) {
for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize; for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize;
x < kLayerRect.width(); x += 2 * kMaskCheckerSize) { x < kLayerRect.width(); x += 2 * kMaskCheckerSize) {
SkIRect checker = SkIRect::MakeXYWH(x, y, kMaskCheckerSize, kMaskCheckerSize); SkIRect checker = SkIRect::MakeXYWH(x, y, kMaskCheckerSize, kMaskCheckerSize);
rtc->renderTargetContextPriv().stencilRect(GrNoClip(), &kSetClip, false, SkMatrix::I(), rtc->priv().stencilRect(GrNoClip(), &kSetClip, false, SkMatrix::I(),
SkRect::Make(checker)); SkRect::Make(checker));
} }
} }

View File

@ -125,8 +125,7 @@ protected:
SkAutoTUnref<GrDrawBatch> batch( SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix, GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
renderRect, nullptr, nullptr)); renderRect, nullptr, nullptr));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
} }
x += renderRect.width() + kTestPad; x += renderRect.width() + kTestPad;
} }
@ -238,8 +237,7 @@ protected:
grPaint.addColorFragmentProcessor(fp); grPaint.addColorFragmentProcessor(fp);
SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill( SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(
GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
batch);
} }
} }
} }

View File

@ -346,8 +346,8 @@ public:
sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture()); } sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture()); }
// Provides access to functions that aren't part of the public API. // Provides access to functions that aren't part of the public API.
GrRenderTargetContextPriv renderTargetContextPriv(); GrRenderTargetContextPriv priv();
const GrRenderTargetContextPriv renderTargetContextPriv() const; const GrRenderTargetContextPriv priv() const;
GrAuditTrail* auditTrail() { return fAuditTrail; } GrAuditTrail* auditTrail() { return fAuditTrail; }

View File

@ -441,7 +441,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<GrRenderTargetContext> tempDC = this->makeRenderTargetContext( sk_sp<GrRenderTargetContext> tempRTC = this->makeRenderTargetContext(
tempDrawInfo.fTempSurfaceFit, tempDrawInfo.fTempSurfaceFit,
tempDrawInfo.fTempSurfaceDesc.fWidth, tempDrawInfo.fTempSurfaceDesc.fWidth,
tempDrawInfo.fTempSurfaceDesc.fHeight, tempDrawInfo.fTempSurfaceDesc.fHeight,
@ -449,7 +449,7 @@ bool GrContext::readSurfacePixels(GrSurface* src,
nullptr, nullptr,
tempDrawInfo.fTempSurfaceDesc.fSampleCnt, tempDrawInfo.fTempSurfaceDesc.fSampleCnt,
tempDrawInfo.fTempSurfaceDesc.fOrigin); tempDrawInfo.fTempSurfaceDesc.fOrigin);
if (tempDC) { if (tempRTC) {
SkMatrix textureMatrix; SkMatrix textureMatrix;
textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
textureMatrix.postIDiv(src->width(), src->height()); textureMatrix.postIDiv(src->width(), src->height());
@ -462,10 +462,10 @@ bool GrContext::readSurfacePixels(GrSurface* src,
} else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) { } else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
// We only wanted to do the draw in order to perform the unpremul so don't // We only wanted to do the draw in order to perform the unpremul so don't
// bother. // bother.
tempDC.reset(nullptr); tempRTC.reset(nullptr);
} }
} }
if (!fp && tempDC) { if (!fp && tempRTC) {
fp = GrConfigConversionEffect::Make(src->asTexture(), tempDrawInfo.fSwizzle, fp = GrConfigConversionEffect::Make(src->asTexture(), tempDrawInfo.fSwizzle,
GrConfigConversionEffect::kNone_PMConversion, GrConfigConversionEffect::kNone_PMConversion,
textureMatrix); textureMatrix);
@ -476,8 +476,8 @@ bool GrContext::readSurfacePixels(GrSurface* src,
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.setAllowSRGBInputs(true); paint.setAllowSRGBInputs(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
tempDC->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullptr); tempRTC->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullptr);
surfaceToRead.reset(tempDC->asTexture().release()); surfaceToRead.reset(tempRTC->asTexture().release());
left = 0; left = 0;
top = 0; top = 0;
didTempDraw = true; didTempDraw = true;

View File

@ -535,7 +535,7 @@ static bool stencil_element(GrRenderTargetContext* rtc,
SkDEBUGFAIL("Should never get here with an empty element."); SkDEBUGFAIL("Should never get here with an empty element.");
break; break;
case Element::kRect_Type: case Element::kRect_Type:
return rtc->renderTargetContextPriv().drawAndStencilRect(clip, ss, return rtc->priv().drawAndStencilRect(clip, ss,
(SkRegion::Op)element->getOp(), (SkRegion::Op)element->getOp(),
element->isInverseFilled(), element->isInverseFilled(),
element->isAA(), element->isAA(),
@ -549,7 +549,7 @@ static bool stencil_element(GrRenderTargetContext* rtc,
path.toggleInverseFillType(); path.toggleInverseFillType();
} }
return rtc->renderTargetContextPriv().drawAndStencilPath(clip, ss, return rtc->priv().drawAndStencilPath(clip, ss,
(SkRegion::Op)element->getOp(), (SkRegion::Op)element->getOp(),
element->isInverseFilled(), element->isInverseFilled(),
element->isAA(), viewMatrix, element->isAA(), viewMatrix,
@ -601,7 +601,7 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
// The scratch texture that we are drawing into can be substantially larger than the mask. Only // The scratch texture that we are drawing into can be substantially larger than the mask. Only
// clear the part that we care about. // clear the part that we care about.
GrColor initialCoverage = InitialState::kAllIn == this->initialState() ? -1 : 0; GrColor initialCoverage = InitialState::kAllIn == this->initialState() ? -1 : 0;
rtc->renderTargetContextPriv().clear(clip, initialCoverage, true); rtc->priv().clear(clip, initialCoverage, true);
// Set the matrix so that rendered clip elements are transformed to mask space from clip space. // Set the matrix so that rendered clip elements are transformed to mask space from clip space.
SkMatrix translate; SkMatrix translate;
@ -638,10 +638,8 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
GrUserStencilOp::kZero, GrUserStencilOp::kZero,
0xffff>() 0xffff>()
); );
if (!rtc->renderTargetContextPriv().drawAndStencilRect(clip, &kDrawOutsideElement, if (!rtc->priv().drawAndStencilRect(clip, &kDrawOutsideElement, op, !invert, false,
op, !invert, false, translate, SkRect::Make(fIBounds))) {
translate,
SkRect::Make(fIBounds))) {
return false; return false;
} }
} else { } else {
@ -706,8 +704,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
} }
bool initialState = InitialState::kAllIn == this->initialState(); bool initialState = InitialState::kAllIn == this->initialState();
renderTargetContext->renderTargetContextPriv().clearStencilClip(stencilClip.fixedClip(), renderTargetContext->priv().clearStencilClip(stencilClip.fixedClip(), initialState);
initialState);
// Set the matrix so that rendered clip elements are transformed from clip to stencil space. // Set the matrix so that rendered clip elements are transformed from clip to stencil space.
SkMatrix viewMatrix; SkMatrix viewMatrix;
@ -779,10 +776,8 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
0xffff>() 0xffff>()
); );
if (Element::kRect_Type == element->getType()) { if (Element::kRect_Type == element->getType()) {
renderTargetContext->renderTargetContextPriv().stencilRect(stencilClip.fixedClip(), renderTargetContext->priv().stencilRect(stencilClip.fixedClip(), &kDrawToStencil,
&kDrawToStencil, useHWAA, useHWAA, viewMatrix, element->getRect());
viewMatrix,
element->getRect());
} else { } else {
if (!clipPath.isEmpty()) { if (!clipPath.isEmpty()) {
GrShape shape(clipPath, GrStyle::SimpleFill()); GrShape shape(clipPath, GrStyle::SimpleFill());
@ -821,8 +816,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
for (GrUserStencilSettings const* const* pass = stencilPasses; *pass; ++pass) { for (GrUserStencilSettings const* const* pass = stencilPasses; *pass; ++pass) {
if (drawDirectToClip) { if (drawDirectToClip) {
if (Element::kRect_Type == element->getType()) { if (Element::kRect_Type == element->getType()) {
renderTargetContext->renderTargetContextPriv().stencilRect(stencilClip, *pass, renderTargetContext->priv().stencilRect(stencilClip, *pass, useHWAA, viewMatrix,
useHWAA, viewMatrix,
element->getRect()); element->getRect());
} else { } else {
GrShape shape(clipPath, GrStyle::SimpleFill()); GrShape shape(clipPath, GrStyle::SimpleFill());
@ -844,8 +838,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
} else { } else {
// The view matrix is setup to do clip space -> stencil space translation, so // The view matrix is setup to do clip space -> stencil space translation, so
// draw rect in clip space. // draw rect in clip space.
renderTargetContext->renderTargetContextPriv().stencilRect(stencilClip, *pass, renderTargetContext->priv().stencilRect(stencilClip, *pass, false, viewMatrix,
false, viewMatrix,
SkRect::Make(fIBounds)); SkRect::Make(fIBounds));
} }
} }

View File

@ -78,11 +78,11 @@ private:
friend class GrRenderTargetContext; // to construct/copy this type. friend class GrRenderTargetContext; // to construct/copy this type.
}; };
inline GrRenderTargetContextPriv GrRenderTargetContext::renderTargetContextPriv() { inline GrRenderTargetContextPriv GrRenderTargetContext::priv() {
return GrRenderTargetContextPriv(this); return GrRenderTargetContextPriv(this);
} }
inline const GrRenderTargetContextPriv GrRenderTargetContext::renderTargetContextPriv () const { inline const GrRenderTargetContextPriv GrRenderTargetContext::priv() const {
return GrRenderTargetContextPriv(const_cast<GrRenderTargetContext*>(this)); return GrRenderTargetContextPriv(const_cast<GrRenderTargetContext*>(this));
} }

View File

@ -147,7 +147,7 @@ private:
GrXferProcessor::DstTexture*, GrXferProcessor::DstTexture*,
const SkRect& batchBounds); const SkRect& batchBounds);
// Used only by renderTargetContextPriv. // Used only via GrRenderTargetContextPriv.
void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTarget*); void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTarget*);
struct RecordedBatch { struct RecordedBatch {

View File

@ -36,9 +36,9 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
GrPixelConfig config = GrMakePixelConfigUncompressed(inputTexture->config()); GrPixelConfig config = GrMakePixelConfigUncompressed(inputTexture->config());
sk_sp<GrRenderTargetContext> copyDC = context->makeRenderTargetContextWithFallback( sk_sp<GrRenderTargetContext> copyRTC = context->makeRenderTargetContextWithFallback(
SkBackingFit::kExact, copyParams.fWidth, copyParams.fHeight, config, nullptr); SkBackingFit::kExact, copyParams.fWidth, copyParams.fHeight, config, nullptr);
if (!copyDC) { if (!copyRTC) {
return nullptr; return nullptr;
} }
@ -84,8 +84,8 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
} }
SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight); SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
copyDC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect); copyRTC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect);
return copyDC->asTexture().release(); return copyRTC->asTexture().release();
} }
GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, SkAlphaType alphaType, GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, SkAlphaType alphaType,

View File

@ -243,16 +243,16 @@ void SkGpuDevice::clearAll() {
void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) { void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) {
ASSERT_SINGLE_OWNER ASSERT_SINGLE_OWNER
SkBudgeted budgeted = fRenderTargetContext->renderTargetContextPriv().isBudgeted(); SkBudgeted budgeted = fRenderTargetContext->priv().isBudgeted();
sk_sp<GrRenderTargetContext> newDC(MakeRenderTargetContext( sk_sp<GrRenderTargetContext> newRTC(MakeRenderTargetContext(
this->context(), this->context(),
budgeted, budgeted,
this->imageInfo(), this->imageInfo(),
fRenderTargetContext->numColorSamples(), fRenderTargetContext->numColorSamples(),
fRenderTargetContext->origin(), fRenderTargetContext->origin(),
&this->surfaceProps())); &this->surfaceProps()));
if (!newDC) { if (!newRTC) {
return; return;
} }
@ -260,12 +260,12 @@ void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) {
if (fRenderTargetContext->wasAbandoned()) { if (fRenderTargetContext->wasAbandoned()) {
return; return;
} }
newDC->copySurface(fRenderTargetContext->asTexture().get(), newRTC->copySurface(fRenderTargetContext->asTexture().get(),
SkIRect::MakeWH(this->width(), this->height()), SkIRect::MakeWH(this->width(), this->height()),
SkIPoint::Make(0, 0)); SkIPoint::Make(0, 0));
} }
fRenderTargetContext = newDC; fRenderTargetContext = newRTC;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -83,8 +83,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
SkASSERT(!args.fIsAA || args.fRenderTargetContext->isStencilBufferMultisampled()); SkASSERT(!args.fIsAA || args.fRenderTargetContext->isStencilBufferMultisampled());
SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape)); SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
args.fRenderTargetContext->renderTargetContextPriv().stencilPath(*args.fClip, args.fIsAA, args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fIsAA, *args.fViewMatrix, p);
*args.fViewMatrix, p);
} }
bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
@ -125,8 +124,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
nullptr, &invert)); nullptr, &invert));
// fake inverse with a stencil and cover // fake inverse with a stencil and cover
args.fRenderTargetContext->renderTargetContextPriv().stencilPath(*args.fClip, args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fPaint->isAntiAlias(),
args.fPaint->isAntiAlias(),
viewMatrix, path); viewMatrix, path);
{ {

View File

@ -184,13 +184,13 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
} }
} }
sk_sp<GrRenderTargetContext> readDC(context->makeRenderTargetContext(SkBackingFit::kExact, sk_sp<GrRenderTargetContext> readRTC(context->makeRenderTargetContext(SkBackingFit::kExact,
kSize, kSize, kSize, kSize,
kConfig, nullptr)); kConfig, nullptr));
sk_sp<GrRenderTargetContext> tempDC(context->makeRenderTargetContext(SkBackingFit::kExact, sk_sp<GrRenderTargetContext> tempRTC(context->makeRenderTargetContext(SkBackingFit::kExact,
kSize, kSize, kSize, kSize,
kConfig, nullptr)); kConfig, nullptr));
if (!readDC || !tempDC) { if (!readRTC || !tempRTC) {
return; return;
} }
GrSurfaceDesc desc; GrSurfaceDesc desc;
@ -226,28 +226,28 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
dataTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I())); dataTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
readDC->asTexture().get(), GrSwizzle::RGBA(), *upmToPMRule, SkMatrix::I())); readRTC->asTexture().get(), GrSwizzle::RGBA(), *upmToPMRule, SkMatrix::I()));
sk_sp<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( sk_sp<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
tempDC->asTexture().get(), GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I())); tempRTC->asTexture().get(), GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
paint1.addColorFragmentProcessor(std::move(pmToUPM1)); paint1.addColorFragmentProcessor(std::move(pmToUPM1));
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
readDC->fillRectToRect(GrNoClip(), paint1, SkMatrix::I(), kDstRect, kSrcRect); readRTC->fillRectToRect(GrNoClip(), paint1, SkMatrix::I(), kDstRect, kSrcRect);
readDC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, firstRead); readRTC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, firstRead);
paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
tempDC->fillRectToRect(GrNoClip(), paint2, SkMatrix::I(), kDstRect, kSrcRect); tempRTC->fillRectToRect(GrNoClip(), paint2, SkMatrix::I(), kDstRect, kSrcRect);
paint3.addColorFragmentProcessor(std::move(pmToUPM2)); paint3.addColorFragmentProcessor(std::move(pmToUPM2));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);
readDC->fillRectToRect(GrNoClip(), paint3, SkMatrix::I(), kDstRect, kSrcRect); readRTC->fillRectToRect(GrNoClip(), paint3, SkMatrix::I(), kDstRect, kSrcRect);
readDC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, secondRead); readRTC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, secondRead);
failed = false; failed = false;
for (int y = 0; y < kSize && !failed; ++y) { for (int y = 0; y < kSize && !failed; ++y) {

View File

@ -340,8 +340,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
bool snapToCenters = set_random_state(&grPaint, &random); bool snapToCenters = set_random_state(&grPaint, &random);
const GrUserStencilSettings* uss = get_random_stencil(&random); const GrUserStencilSettings* uss = get_random_stencil(&random);
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch, uss, renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch, uss, snapToCenters);
snapToCenters);
} }
// Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes) // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
drawingManager->flush(); drawingManager->flush();
@ -375,7 +374,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
BlockInputFragmentProcessor::Make(std::move(fp))); BlockInputFragmentProcessor::Make(std::move(fp)));
grPaint.addColorFragmentProcessor(std::move(blockFP)); grPaint.addColorFragmentProcessor(std::move(blockFP));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch); renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
drawingManager->flush(); drawingManager->flush();
} }
} }

View File

@ -127,7 +127,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
GrPaint grPaint; GrPaint grPaint;
// This one should succeed. // This one should succeed.
batch.reset(new Batch(attribCnt)); batch.reset(new Batch(attribCnt));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch); renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
context->flush(); context->flush();
#if GR_GPU_STATS #if GR_GPU_STATS
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1); REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1);
@ -136,7 +136,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
context->resetGpuStats(); context->resetGpuStats();
// This one should fail. // This one should fail.
batch.reset(new Batch(attribCnt+1)); batch.reset(new Batch(attribCnt+1));
renderTargetContext->renderTargetContextPriv().testingOnly_drawBatch(grPaint, batch); renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch);
context->flush(); context->flush();
#if GR_GPU_STATS #if GR_GPU_STATS
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);