Prefer fullscreen clears on Qualcomm/GL

Adds Qualcomm to the set of GL devices on which we prefer fullscreen
clears.

Renames fullscreenClearIsFree in GrCaps to preferFullscreenClears.

Replaces 'bool canIgnoreClip' on GrRenderTargetContext::clear with an
enum.

Bug: skia:
Change-Id: I5b30298c4d0b092c398b9fea6060f3e2bea91e46
Reviewed-on: https://skia-review.googlesource.com/83060
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2017-12-11 15:42:09 -07:00 committed by Skia Commit-Bot
parent 6e64f30891
commit 344e9037e1
22 changed files with 78 additions and 60 deletions

View File

@ -210,7 +210,7 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
// 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(maskRTC.get(), true); this->stencilCheckerboard(maskRTC.get(), true);
maskRTC->clear(nullptr, GrColorPackA4(0xff), true); maskRTC->clear(nullptr, GrColorPackA4(0xff), GrRenderTargetContext::CanClearFullscreen::kYes);
maskRTC->priv().drawAndStencilRect(make_stencil_only_clip(), &GrUserStencilSettings::kUnused, maskRTC->priv().drawAndStencilRect(make_stencil_only_clip(), &GrUserStencilSettings::kUnused,
SkRegion::kDifference_Op, false, GrAA::kNo, SkMatrix::I(), SkRegion::kDifference_Op, false, GrAA::kNo, SkMatrix::I(),
SkRect::MakeIWH(maskRTC->width(), maskRTC->height())); SkRect::MakeIWH(maskRTC->width(), maskRTC->height()));

View File

@ -55,6 +55,10 @@ public:
bool usesMixedSamples() const { return fUsesMixedSamples; } bool usesMixedSamples() const { return fUsesMixedSamples; }
bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; } bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; }
// On tilers, an initial fullscreen clear is an OPTIMIZATION. It allows the hardware to
// initialize each tile with a constant value rather than loading each pixel from memory.
bool preferFullscreenClears() const { return fPreferFullscreenClears; }
bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; } bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; }
bool blacklistCoverageCounting() const { return fBlacklistCoverageCounting; } bool blacklistCoverageCounting() const { return fBlacklistCoverageCounting; }
@ -144,8 +148,6 @@ public:
return fBufferMapThreshold; return fBufferMapThreshold;
} }
bool fullClearIsFree() const { return fFullClearIsFree; }
/** True in environments that will issue errors if memory uploaded to buffers /** True in environments that will issue errors if memory uploaded to buffers
is not initialized (even if not read by draw calls). */ is not initialized (even if not read by draw calls). */
bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; } bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; }
@ -192,7 +194,7 @@ protected:
bool fInstanceAttribSupport : 1; bool fInstanceAttribSupport : 1;
bool fUsesMixedSamples : 1; bool fUsesMixedSamples : 1;
bool fPreferClientSideDynamicBuffers : 1; bool fPreferClientSideDynamicBuffers : 1;
bool fFullClearIsFree : 1; bool fPreferFullscreenClears : 1;
bool fMustClearUploadedBufferData : 1; bool fMustClearUploadedBufferData : 1;
// Driver workaround // Driver workaround

View File

@ -162,11 +162,11 @@ static void convolve_gaussian(GrRenderTargetContext* renderTargetContext,
dstRect.fRight = midRect.right(); dstRect.fRight = midRect.right();
} }
if (!topRect.isEmpty()) { if (!topRect.isEmpty()) {
renderTargetContext->clear(&topRect, 0, false); renderTargetContext->clear(&topRect, 0, GrRenderTargetContext::CanClearFullscreen::kNo);
} }
if (!bottomRect.isEmpty()) { if (!bottomRect.isEmpty()) {
renderTargetContext->clear(&bottomRect, 0, false); renderTargetContext->clear(&bottomRect, 0, GrRenderTargetContext::CanClearFullscreen::kNo);
} }
if (midRect.isEmpty()) { if (midRect.isEmpty()) {

View File

@ -115,7 +115,7 @@ sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* c
GrPaint paint; GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkRegion::Iterator iter(fRegion); SkRegion::Iterator iter(fRegion);
rtContext->clear(nullptr, 0x0, true); rtContext->clear(nullptr, 0x0, GrRenderTargetContext::CanClearFullscreen::kYes);
GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height())); GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height()));
while (!iter.done()) { while (!iter.done()) {

View File

@ -882,7 +882,7 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context,
GrPaint paint; GrPaint paint;
rtc->clear(nullptr, 0x0, true); rtc->clear(nullptr, 0x0, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw, rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill()); GrStyle::SimpleFill());

View File

@ -509,7 +509,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
dstRect.width(), radius.fHeight); dstRect.width(), radius.fHeight);
GrColor clearColor = GrColor clearColor =
GrMorphologyEffect::Type::kErode == morphType ? SK_ColorWHITE : SK_ColorTRANSPARENT; GrMorphologyEffect::Type::kErode == morphType ? SK_ColorWHITE : SK_ColorTRANSPARENT;
dstRTContext->clear(&clearRect, clearColor, false); dstRTContext->clear(&clearRect, clearColor, GrRenderTargetContext::CanClearFullscreen::kNo);
srcTexture = dstRTContext->asTextureProxyRef(); srcTexture = dstRTContext->asTextureProxyRef();
srcRect = dstRect; srcRect = dstRect;

View File

@ -53,7 +53,7 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fInstanceAttribSupport = false; fInstanceAttribSupport = false;
fUsesMixedSamples = false; fUsesMixedSamples = false;
fPreferClientSideDynamicBuffers = false; fPreferClientSideDynamicBuffers = false;
fFullClearIsFree = false; fPreferFullscreenClears = false;
fMustClearUploadedBufferData = false; fMustClearUploadedBufferData = false;
fSampleShadingSupport = false; fSampleShadingSupport = false;
fFenceSyncSupport = false; fFenceSyncSupport = false;
@ -150,7 +150,7 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const {
writer->appendBool("Instance Attrib Support", fInstanceAttribSupport); writer->appendBool("Instance Attrib Support", fInstanceAttribSupport);
writer->appendBool("Uses Mixed Samples", fUsesMixedSamples); writer->appendBool("Uses Mixed Samples", fUsesMixedSamples);
writer->appendBool("Prefer client-side dynamic buffers", fPreferClientSideDynamicBuffers); writer->appendBool("Prefer client-side dynamic buffers", fPreferClientSideDynamicBuffers);
writer->appendBool("Full screen clear is free", fFullClearIsFree); writer->appendBool("Prefer fullscreen clears", fPreferFullscreenClears);
writer->appendBool("Must clear buffer memory", fMustClearUploadedBufferData); writer->appendBool("Must clear buffer memory", fMustClearUploadedBufferData);
writer->appendBool("Sample shading support", fSampleShadingSupport); writer->appendBool("Sample shading support", fSampleShadingSupport);
writer->appendBool("Fence sync support", fFenceSyncSupport); writer->appendBool("Fence sync support", fFenceSyncSupport);

View File

@ -746,7 +746,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->priv().clear(clip, initialCoverage, true); rtc->priv().clear(clip, initialCoverage, GrRenderTargetContext::CanClearFullscreen::kYes);
// 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;

View File

@ -272,14 +272,15 @@ void GrRenderTargetContext::discard() {
void GrRenderTargetContext::clear(const SkIRect* rect, void GrRenderTargetContext::clear(const SkIRect* rect,
const GrColor color, const GrColor color,
bool canIgnoreRect) { CanClearFullscreen canClearFullscreen) {
ASSERT_SINGLE_OWNER ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();) SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "clear", fContext); GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "clear", fContext);
AutoCheckFlush acf(this->drawingManager()); AutoCheckFlush acf(this->drawingManager());
this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), color, canIgnoreRect); this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), color,
canClearFullscreen);
} }
void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const GrColor color) { void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const GrColor color) {
@ -319,7 +320,7 @@ void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const GrColor
void GrRenderTargetContextPriv::clear(const GrFixedClip& clip, void GrRenderTargetContextPriv::clear(const GrFixedClip& clip,
const GrColor color, const GrColor color,
bool canIgnoreClip) { CanClearFullscreen canClearFullscreen) {
ASSERT_SINGLE_OWNER_PRIV ASSERT_SINGLE_OWNER_PRIV
RETURN_IF_ABANDONED_PRIV RETURN_IF_ABANDONED_PRIV
SkDEBUGCODE(fRenderTargetContext->validate();) SkDEBUGCODE(fRenderTargetContext->validate();)
@ -327,16 +328,17 @@ void GrRenderTargetContextPriv::clear(const GrFixedClip& clip,
fRenderTargetContext->fContext); fRenderTargetContext->fContext);
AutoCheckFlush acf(fRenderTargetContext->drawingManager()); AutoCheckFlush acf(fRenderTargetContext->drawingManager());
fRenderTargetContext->internalClear(clip, color, canIgnoreClip); fRenderTargetContext->internalClear(clip, color, canClearFullscreen);
} }
void GrRenderTargetContext::internalClear(const GrFixedClip& clip, void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
const GrColor color, const GrColor color,
bool canIgnoreClip) { CanClearFullscreen canClearFullscreen) {
bool isFull = false; bool isFull = false;
if (!clip.hasWindowRectangles()) { if (!clip.hasWindowRectangles()) {
isFull = !clip.scissorEnabled() || isFull = !clip.scissorEnabled() ||
(canIgnoreClip && fContext->caps()->fullClearIsFree()) || (CanClearFullscreen::kYes == canClearFullscreen &&
fContext->caps()->preferFullscreenClears()) ||
clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height())); clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height()));
} }
@ -519,7 +521,8 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
// Will it blend? // Will it blend?
GrColor clearColor; GrColor clearColor;
if (paint.isConstantBlendedColor(&clearColor)) { if (paint.isConstantBlendedColor(&clearColor)) {
this->clear(nullptr, clearColor, true); this->clear(nullptr, clearColor,
GrRenderTargetContext::CanClearFullscreen::kYes);
return; return;
} }
} }

View File

@ -79,14 +79,19 @@ public:
*/ */
void discard(); void discard();
enum class CanClearFullscreen : bool {
kNo = false,
kYes = true
};
/** /**
* Clear the entire or rect of the render target, ignoring any clips. * Clear the entire or rect of the render target, ignoring any clips.
* @param rect the rect to clear or the whole thing if rect is NULL. * @param rect the rect to clear or the whole thing if rect is NULL.
* @param color the color to clear to. * @param color the color to clear to.
* @param canIgnoreRect allows partial clears to be converted to whole * @param CanClearFullscreen allows partial clears to be converted to fullscreen clears on
* clears on platforms for which that is cheap * tiling platforms where that is an optimization.
*/ */
void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect); void clear(const SkIRect* rect, GrColor color, CanClearFullscreen);
/** /**
* Draw everywhere (respecting the clip) with the paint. * Draw everywhere (respecting the clip) with the paint.
@ -409,7 +414,7 @@ private:
friend void test_draw_op(GrRenderTargetContext*, std::unique_ptr<GrFragmentProcessor>, friend void test_draw_op(GrRenderTargetContext*, std::unique_ptr<GrFragmentProcessor>,
sk_sp<GrTextureProxy>); sk_sp<GrTextureProxy>);
void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip); void internalClear(const GrFixedClip&, const GrColor, CanClearFullscreen);
// Only consumes the GrPaint if successful. // Only consumes the GrPaint if successful.
bool drawFilledDRRect(const GrClip& clip, bool drawFilledDRRect(const GrClip& clip,

View File

@ -43,7 +43,9 @@ public:
opList->fLastClipNumAnalyticFPs != numClipAnalyticFPs; opList->fLastClipNumAnalyticFPs != numClipAnalyticFPs;
} }
void clear(const GrFixedClip&, const GrColor, bool canIgnoreClip); using CanClearFullscreen = GrRenderTargetContext::CanClearFullscreen;
void clear(const GrFixedClip&, const GrColor, CanClearFullscreen);
void clearStencilClip(const GrFixedClip&, bool insideStencilMask); void clearStencilClip(const GrFixedClip&, bool insideStencilMask);

View File

@ -232,7 +232,7 @@ void SkGpuDevice::clearAll() {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext.get()); GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext.get());
SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
fRenderTargetContext->clear(&rect, 0x0, true); fRenderTargetContext->clear(&rect, 0x0, GrRenderTargetContext::CanClearFullscreen::kYes);
} }
void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) { void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) {

View File

@ -116,7 +116,7 @@ sk_sp<GrRenderTargetContext> GrCCPRAtlas::finalize(GrOnFlushResourceProvider* on
} }
SkIRect clearRect = SkIRect::MakeSize(fDrawBounds); SkIRect clearRect = SkIRect::MakeSize(fDrawBounds);
rtc->clear(&clearRect, 0, true); rtc->clear(&clearRect, 0, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->addDrawOp(GrNoClip(), std::move(atlasOp)); rtc->addDrawOp(GrNoClip(), std::move(atlasOp));
fTextureProxy = sk_ref_sp(rtc->asTextureProxy()); fTextureProxy = sk_ref_sp(rtc->asTextureProxy());

View File

@ -152,8 +152,10 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fInvalidateFBType = kDiscard_InvalidateFBType; fInvalidateFBType = kDiscard_InvalidateFBType;
} }
if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) { if (kARM_GrGLVendor == ctxInfo.vendor() ||
fFullClearIsFree = true; kImagination_GrGLVendor == ctxInfo.vendor() ||
kQualcomm_GrGLVendor == ctxInfo.vendor() ) {
fPreferFullscreenClears = true;
} }
if (kGL_GrGLStandard == standard) { if (kGL_GrGLStandard == standard) {

View File

@ -79,7 +79,7 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Check a full clear // Check a full clear
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY); failX, failY);
@ -89,8 +89,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Check two full clears, same color // Check two full clears, same color
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY); failX, failY);
@ -100,8 +100,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Check two full clears, different colors // Check two full clears, different colors
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor2, false); rtContext->clear(&fullRect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
failX, failY); failX, failY);
@ -111,8 +111,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Test a full clear followed by a same color inset clear // Test a full clear followed by a same color inset clear
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor1, false); rtContext->clear(&mid1Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY); failX, failY);
@ -122,8 +122,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Test a inset clear followed by same color full clear // Test a inset clear followed by same color full clear
rtContext->clear(&mid1Rect, kColor1, false); rtContext->clear(&mid1Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY); failX, failY);
@ -133,8 +133,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Test a full clear followed by a different color inset clear // Test a full clear followed by a different color inset clear
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor2, false); rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
failX, failY); failX, failY);
@ -151,8 +151,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Test a inset clear followed by a different full clear // Test a inset clear followed by a different full clear
rtContext->clear(&mid1Rect, kColor2, false); rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY); failX, failY);
@ -163,9 +163,9 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
// Check three nested clears from largest to smallest where outermost and innermost are same // Check three nested clears from largest to smallest where outermost and innermost are same
// color. // color.
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor2, false); rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid2Rect, kColor1, false); rtContext->clear(&mid2Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY); failX, failY);
@ -189,9 +189,9 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext); SkASSERT(rtContext);
// Swap the order of the second two clears in the above test. // Swap the order of the second two clears in the above test.
rtContext->clear(&fullRect, kColor1, false); rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid2Rect, kColor1, false); rtContext->clear(&mid2Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor2, false); rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo);
if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
failX, failY); failX, failY);

View File

@ -71,7 +71,8 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
kBigSize/2+1, kBigSize/2+1, kBigSize/2+1, kBigSize/2+1,
kRGBA_8888_GrPixelConfig, nullptr); kRGBA_8888_GrPixelConfig, nullptr);
rtc->clear(nullptr, GrColorPackRGBA(0x0, 0x0, 0x0, 0xFF), true); rtc->clear(nullptr, GrColorPackRGBA(0x0, 0x0, 0x0, 0xFF),
GrRenderTargetContext::CanClearFullscreen::kYes);
GrPaint paint; GrPaint paint;
@ -89,7 +90,8 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
auto rtc = ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kBigSize, kBigSize, auto rtc = ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kBigSize, kBigSize,
kRGBA_8888_GrPixelConfig, nullptr); kRGBA_8888_GrPixelConfig, nullptr);
rtc->clear(nullptr, GrColorPackRGBA(0x0, 0x0, 0x0, 0xFF), true); rtc->clear(nullptr, GrColorPackRGBA(0x0, 0x0, 0x0, 0xFF),
GrRenderTargetContext::CanClearFullscreen::kYes);
GrPaint paint; GrPaint paint;

View File

@ -69,7 +69,7 @@ public:
} }
bool valid() const { return fCCPR && fRTC; } bool valid() const { return fCCPR && fRTC; }
void clear() const { fRTC->clear(nullptr, 0, true); } void clear() const { fRTC->clear(nullptr, 0, GrRenderTargetContext::CanClearFullscreen::kYes); }
void abandonGrContext() { fCtx = nullptr; fCCPR = nullptr; fRTC = nullptr; } void abandonGrContext() { fCtx = nullptr; fCCPR = nullptr; fRTC = nullptr; }
void drawPath(SkPath path, GrColor4f color = GrColor4f(0, 1, 0, 1)) const { void drawPath(SkPath path, GrColor4f color = GrColor4f(0, 1, 0, 1)) const {

View File

@ -389,7 +389,7 @@ static void run_test(const char* testName, skiatest::Reporter* reporter,
} }
SkAutoSTMalloc<kImageHeight * kImageWidth, uint32_t> resultPx(h * rowBytes); SkAutoSTMalloc<kImageHeight * kImageWidth, uint32_t> resultPx(h * rowBytes);
rtc->clear(nullptr, 0xbaaaaaad, true); rtc->clear(nullptr, 0xbaaaaaad, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->priv().testingOnly_addDrawOp(skstd::make_unique<GrMeshTestOp>(testFn)); rtc->priv().testingOnly_addDrawOp(skstd::make_unique<GrMeshTestOp>(testFn));
rtc->readPixels(gold.info(), resultPx, rowBytes, 0, 0, 0); rtc->readPixels(gold.info(), resultPx, rowBytes, 0, 0, 0);
for (int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {

View File

@ -192,7 +192,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
uint32_t resultPx[kScreenSize * kScreenSize]; uint32_t resultPx[kScreenSize * kScreenSize];
for (ScissorState scissorState : {ScissorState::kEnabled, ScissorState::kDisabled}) { for (ScissorState scissorState : {ScissorState::kEnabled, ScissorState::kDisabled}) {
rtc->clear(nullptr, 0xbaaaaaad, true); rtc->clear(nullptr, 0xbaaaaaad, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->priv().testingOnly_addDrawOp( rtc->priv().testingOnly_addDrawOp(
skstd::make_unique<GrPipelineDynamicStateTestOp>(scissorState, vbuff)); skstd::make_unique<GrPipelineDynamicStateTestOp>(scissorState, vbuff));
rtc->readPixels(SkImageInfo::Make(kScreenSize, kScreenSize, rtc->readPixels(SkImageInfo::Make(kScreenSize, kScreenSize,

View File

@ -262,7 +262,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
if (!fp) { if (!fp) {
return; return;
} }
rtContext->clear(nullptr, 0xDDAABBCC, true); rtContext->clear(nullptr, 0xDDAABBCC, GrRenderTargetContext::CanClearFullscreen::kYes);
GrPaint paint; GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));

View File

@ -329,7 +329,8 @@ public:
nullptr, nullptr); nullptr, nullptr);
#endif #endif
rtc->clear(nullptr, 0xFFFFFFFF, true); // clear the atlas // clear the atlas
rtc->clear(nullptr, 0xFFFFFFFF, GrRenderTargetContext::CanClearFullscreen::kYes);
int blocksInAtlas = 0; int blocksInAtlas = 0;
for (int i = 0; i < lists.count(); ++i) { for (int i = 0; i < lists.count(); ++i) {
@ -339,7 +340,7 @@ public:
// For now, we avoid the resource buffer issues and just use clears // For now, we avoid the resource buffer issues and just use clears
#if 1 #if 1
rtc->clear(&r, op->color(), false); rtc->clear(&r, op->color(), GrRenderTargetContext::CanClearFullscreen::kNo);
#else #else
GrPaint paint; GrPaint paint;
paint.setColor4f(GrColor4f::FromGrColor(op->color())); paint.setColor4f(GrColor4f::FromGrColor(op->color()));
@ -410,7 +411,8 @@ static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject
kRGBA_8888_GrPixelConfig, kRGBA_8888_GrPixelConfig,
nullptr)); nullptr));
rtc->clear(nullptr, GrColorPackRGBA(255, 0, 0, 255), true); rtc->clear(nullptr, GrColorPackRGBA(255, 0, 0, 255),
GrRenderTargetContext::CanClearFullscreen::kYes);
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize); SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize);
@ -539,7 +541,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
kRGBA_8888_GrPixelConfig, kRGBA_8888_GrPixelConfig,
nullptr)); nullptr));
rtc->clear(nullptr, 0xFFFFFFFF, true); rtc->clear(nullptr, 0xFFFFFFFF, GrRenderTargetContext::CanClearFullscreen::kYes);
// Note that this doesn't include the third texture proxy // Note that this doesn't include the third texture proxy
for (int i = 0; i < kNumProxies-1; ++i) { for (int i = 0; i < kNumProxies-1; ++i) {

View File

@ -28,7 +28,7 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* cont
for (auto filter : {GrSamplerState::Filter::kNearest, for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp, GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) { GrSamplerState::Filter::kMipMap}) {
rtContext->clear(nullptr, 0xDDCCBBAA, true); rtContext->clear(nullptr, 0xDDCCBBAA, GrRenderTargetContext::CanClearFullscreen::kYes);
auto fp = GrSimpleTextureEffect::Make(rectProxy, SkMatrix::I(), filter); auto fp = GrSimpleTextureEffect::Make(rectProxy, SkMatrix::I(), filter);
GrPaint paint; GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -43,7 +43,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
if (GrRenderTargetContext* rtc = rectContext->asRenderTargetContext()) { if (GrRenderTargetContext* rtc = rectContext->asRenderTargetContext()) {
// Clear the whole thing. // Clear the whole thing.
GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD);
rtc->clear(nullptr, color0, false); rtc->clear(nullptr, color0, GrRenderTargetContext::CanClearFullscreen::kNo);
int w = rtc->width(); int w = rtc->width();
int h = rtc->height(); int h = rtc->height();
@ -64,7 +64,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
// Clear the the top to a different color. // Clear the the top to a different color.
GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4); GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4);
SkIRect rect = SkIRect::MakeWH(w, h/2); SkIRect rect = SkIRect::MakeWH(w, h/2);
rtc->clear(&rect, color1, false); rtc->clear(&rect, color1, GrRenderTargetContext::CanClearFullscreen::kNo);
uint32_t expectedColor1 = 0; uint32_t expectedColor1 = 0;
uint8_t* expectedBytes1 = SkTCast<uint8_t*>(&expectedColor1); uint8_t* expectedBytes1 = SkTCast<uint8_t*>(&expectedColor1);