Remove GrSurfaceContext::flush calls ...
... replacing them w/ calls to GrDirectContextPriv::flushSurface. Since recording contexts can also possess surface- and renderTarget- Contexts it is misleading for them to have a flush method. Change-Id: I10f4fad12d4d5efdd999ba212fda9ce5cdd83130 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334068 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
c90084a9a3
commit
80bfda87c8
@ -113,7 +113,7 @@ private:
|
||||
canvas->drawPath(star7_evenOdd, paint);
|
||||
canvas->drawPath(star5_winding, paint);
|
||||
canvas->drawPath(star5_evenOdd, paint);
|
||||
rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(), nullptr);
|
||||
dContext->priv().flushSurface(rtc->asSurfaceProxy());
|
||||
|
||||
// Ensure the path cache is behaving in such a way that we are actually testing what we
|
||||
// think we are.
|
||||
|
@ -365,13 +365,8 @@ GrSemaphoresSubmitted GrDirectContext::flush(const GrFlushInfo& info) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
bool flushed = this->drawingManager()->flush(
|
||||
{}, SkSurface::BackendSurfaceAccess::kNoAccess, info, nullptr);
|
||||
|
||||
if (!flushed || (!this->priv().caps()->semaphoreSupport() && info.fNumSemaphores)) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
return GrSemaphoresSubmitted::kYes;
|
||||
return this->drawingManager()->flushSurfaces({}, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
info, nullptr);
|
||||
}
|
||||
|
||||
bool GrDirectContext::submit(bool syncCpu) {
|
||||
|
@ -39,24 +39,31 @@ void GrDirectContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFl
|
||||
fContext->addOnFlushCallbackObject(onFlushCBObject);
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted GrDirectContextPriv::flushSurfaces(SkSpan<GrSurfaceProxy*> proxies,
|
||||
const GrFlushInfo& info) {
|
||||
GrSemaphoresSubmitted GrDirectContextPriv::flushSurfaces(
|
||||
SkSpan<GrSurfaceProxy*> proxies,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info,
|
||||
const GrBackendSurfaceMutableState* newState) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_VALUE_IF_ABANDONED(GrSemaphoresSubmitted::kNo)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrDirectContextPriv", "flushSurfaces", fContext);
|
||||
|
||||
if (fContext->abandoned()) {
|
||||
if (info.fSubmittedProc) {
|
||||
info.fSubmittedProc(info.fSubmittedContext, false);
|
||||
}
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
for (GrSurfaceProxy* proxy : proxies) {
|
||||
SkASSERT(proxy);
|
||||
ASSERT_OWNED_PROXY(proxy);
|
||||
}
|
||||
#endif
|
||||
return fContext->drawingManager()->flushSurfaces(
|
||||
proxies, SkSurface::BackendSurfaceAccess::kNoAccess, info, nullptr);
|
||||
}
|
||||
|
||||
void GrDirectContextPriv::flushSurface(GrSurfaceProxy* proxy) {
|
||||
size_t size = proxy ? 1 : 0;
|
||||
this->flushSurfaces({&proxy, size}, {});
|
||||
return fContext->drawingManager()->flushSurfaces(proxies, access, info, newState);
|
||||
}
|
||||
|
||||
void GrDirectContextPriv::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList> ddl,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef GrDirectContextPriv_DEFINED
|
||||
#define GrDirectContextPriv_DEFINED
|
||||
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/core/SkSpan.h"
|
||||
|
||||
@ -81,11 +82,21 @@ public:
|
||||
* GrContext will detect when it must perform a resolve before reading pixels back from the
|
||||
* surface or using it as a texture.
|
||||
*/
|
||||
GrSemaphoresSubmitted flushSurfaces(SkSpan<GrSurfaceProxy*>, const GrFlushInfo&);
|
||||
GrSemaphoresSubmitted flushSurfaces(
|
||||
SkSpan<GrSurfaceProxy*>,
|
||||
SkSurface::BackendSurfaceAccess = SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
const GrFlushInfo& = {},
|
||||
const GrBackendSurfaceMutableState* newState = nullptr);
|
||||
|
||||
/** Version of above that flushes for a single proxy and uses a default GrFlushInfo. Null is
|
||||
* allowed. */
|
||||
void flushSurface(GrSurfaceProxy*);
|
||||
/** Version of above that flushes for a single proxy. Null is allowed. */
|
||||
GrSemaphoresSubmitted flushSurface(
|
||||
GrSurfaceProxy* proxy,
|
||||
SkSurface::BackendSurfaceAccess access = SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
const GrFlushInfo& info = {},
|
||||
const GrBackendSurfaceMutableState* newState = nullptr) {
|
||||
size_t size = proxy ? 1 : 0;
|
||||
return this->flushSurfaces({&proxy, size}, access, info, newState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if createPMToUPMEffect and createUPMToPMEffect will succeed. In other words,
|
||||
|
@ -757,7 +757,10 @@ void GrSurfaceContext::asyncReadPixels(GrDirectContext* dContext,
|
||||
GrFlushInfo flushInfo;
|
||||
flushInfo.fFinishedContext = finishContext;
|
||||
flushInfo.fFinishedProc = finishCallback;
|
||||
this->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo, nullptr);
|
||||
|
||||
dContext->priv().flushSurface(this->asSurfaceProxy(),
|
||||
SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
flushInfo);
|
||||
}
|
||||
|
||||
void GrSurfaceContext::asyncRescaleAndReadPixelsYUV420(GrDirectContext* dContext,
|
||||
@ -1025,7 +1028,9 @@ void GrSurfaceContext::asyncRescaleAndReadPixelsYUV420(GrDirectContext* dContext
|
||||
GrFlushInfo flushInfo;
|
||||
flushInfo.fFinishedContext = finishContext;
|
||||
flushInfo.fFinishedProc = finishCallback;
|
||||
this->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo, nullptr);
|
||||
dContext->priv().flushSurface(this->asSurfaceProxy(),
|
||||
SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
flushInfo);
|
||||
}
|
||||
|
||||
bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
|
||||
@ -1213,26 +1218,6 @@ std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(const GrImageIn
|
||||
return tempA;
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted GrSurfaceContext::flush(SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info,
|
||||
const GrBackendSurfaceMutableState* newState) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
if (fContext->abandoned()) {
|
||||
if (info.fSubmittedProc) {
|
||||
info.fSubmittedProc(info.fSubmittedContext, false);
|
||||
}
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "flush", fContext);
|
||||
|
||||
GrSurfaceProxy* proxies[1] = {this->asSurfaceProxy()};
|
||||
return this->drawingManager()->flushSurfaces(proxies, access, info, newState);
|
||||
}
|
||||
|
||||
GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorType dstCT,
|
||||
const SkIRect& rect) {
|
||||
SkASSERT(rect.fLeft >= 0 && rect.fRight <= this->width());
|
||||
|
@ -158,14 +158,6 @@ public:
|
||||
SkImage::RescaleGamma,
|
||||
SkFilterQuality);
|
||||
|
||||
/**
|
||||
* After this returns any pending surface IO will be issued to the backend 3D API and
|
||||
* if the surface has MSAA it will be resolved.
|
||||
*/
|
||||
GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&,
|
||||
const GrBackendSurfaceMutableState*);
|
||||
|
||||
GrAuditTrail* auditTrail();
|
||||
|
||||
// Provides access to functions that aren't part of the public API.
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "src/core/SkVerticesPriv.h"
|
||||
#include "src/gpu/GrBitmapTextureMaker.h"
|
||||
#include "src/gpu/GrBlurUtils.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrImageTextureMaker.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
@ -1033,18 +1034,10 @@ void SkGpuDevice::flush() {
|
||||
return;
|
||||
}
|
||||
|
||||
this->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(), nullptr);
|
||||
direct->priv().flushSurface(fRenderTargetContext->asSurfaceProxy());
|
||||
direct->submit();
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted SkGpuDevice::flush(SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info,
|
||||
const GrBackendSurfaceMutableState* newState) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
return fRenderTargetContext->flush(access, info, newState);
|
||||
}
|
||||
|
||||
bool SkGpuDevice::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
|
||||
bool deleteSemaphoresAfterWait) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
@ -131,8 +131,6 @@ public:
|
||||
sk_sp<SkSpecialImage> snapSpecial(const SkIRect&, bool = false) override;
|
||||
|
||||
void flush() override;
|
||||
GrSemaphoresSubmitted flush(SkSurface::BackendSurfaceAccess access, const GrFlushInfo&,
|
||||
const GrBackendSurfaceMutableState*);
|
||||
bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
|
||||
bool deleteSemaphoresAfterWait);
|
||||
|
||||
|
@ -77,8 +77,8 @@ GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrDirectContext* dContext, const GrFl
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
GrSurfaceProxy* p[1] = {fView.proxy()};
|
||||
return dContext->priv().flushSurfaces(p, info);
|
||||
return dContext->priv().flushSurface(fView.proxy(), SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
info);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT,
|
||||
|
@ -142,7 +142,9 @@ GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrDirectContext* dContext, const
|
||||
proxies[0] = fRGBView.proxy();
|
||||
numProxies = 1;
|
||||
}
|
||||
return dContext->priv().flushSurfaces({proxies, numProxies}, info);
|
||||
return dContext->priv().flushSurfaces({proxies, numProxies},
|
||||
SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
info);
|
||||
}
|
||||
|
||||
GrTextureProxy* SkImage_GpuYUVA::peekProxy() const { return fRGBView.asTextureProxy(); }
|
||||
|
@ -44,6 +44,11 @@ GrRecordingContext* SkSurface_Gpu::onGetRecordingContext() {
|
||||
|
||||
static GrRenderTarget* prepare_rt_for_external_access(SkSurface_Gpu* surface,
|
||||
SkSurface::BackendHandleAccess access) {
|
||||
auto dContext = surface->recordingContext()->asDirectContext();
|
||||
if (!dContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (access) {
|
||||
case SkSurface::kFlushRead_BackendHandleAccess:
|
||||
break;
|
||||
@ -54,9 +59,11 @@ static GrRenderTarget* prepare_rt_for_external_access(SkSurface_Gpu* surface,
|
||||
break;
|
||||
}
|
||||
|
||||
// Grab the render target *after* firing notifications, as it may get switched if CoW kicks in.
|
||||
surface->getDevice()->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(), nullptr);
|
||||
GrRenderTargetContext* rtc = surface->getDevice()->accessRenderTargetContext();
|
||||
dContext->priv().flushSurface(rtc->asSurfaceProxy());
|
||||
|
||||
// Grab the render target *after* firing notifications, as it may get switched if CoW kicks in.
|
||||
rtc = surface->getDevice()->accessRenderTargetContext();
|
||||
return rtc->accessRenderTarget();
|
||||
}
|
||||
|
||||
@ -201,7 +208,15 @@ void SkSurface_Gpu::onDiscard() {
|
||||
|
||||
GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access, const GrFlushInfo& info,
|
||||
const GrBackendSurfaceMutableState* newState) {
|
||||
return fDevice->flush(access, info, newState);
|
||||
|
||||
auto dContext = fDevice->recordingContext()->asDirectContext();
|
||||
if (!dContext) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext();
|
||||
|
||||
return dContext->priv().flushSurface(rtc->asSurfaceProxy(), access, info, newState);
|
||||
}
|
||||
|
||||
bool SkSurface_Gpu::onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
|
||||
|
@ -96,10 +96,9 @@ static void run_test(GrDirectContext* dContext, skiatest::Reporter* reporter) {
|
||||
auto fp = GrConstColorProcessor::Make(color);
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
|
||||
rtc->drawPath(nullptr, std::move(paint), GrAA::kNo,
|
||||
SkMatrix::I(), invPath, style);
|
||||
rtc->drawPath(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(), invPath, style);
|
||||
|
||||
rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(), nullptr);
|
||||
dContext->priv().flushSurface(rtc->asSurfaceProxy());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -598,7 +598,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
|
||||
rtc->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(), r);
|
||||
}
|
||||
|
||||
rtc->flush(SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(), nullptr);
|
||||
dContext->priv().flushSurface(rtc->asSurfaceProxy());
|
||||
|
||||
SkBitmap readBack;
|
||||
readBack.allocN32Pixels(kFinalWidth, kFinalHeight);
|
||||
|
Loading…
Reference in New Issue
Block a user