Remove GrTextureContext.
This change mostly just removes GrTextureContext and switches users to directly creating GrSurfaceContexts. Outside of updating types, the factory functions for creating Gr*Contexts have not been updated in this but will be done in a followup. Change-Id: I55257568d4c096c5fb48c5e38bfa2c01b824e7b5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260289 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
48257d74cd
commit
46e366ae21
@ -328,7 +328,7 @@ DrawResult SampleLocationsGM::onDraw(
|
||||
return DrawResult::kFail;
|
||||
}
|
||||
if (offscreenRTC->numSamples() <= 1 &&
|
||||
!offscreenRTC->proxy()->canUseMixedSamples(*ctx->priv().caps())) {
|
||||
!offscreenRTC->asRenderTargetProxy()->canUseMixedSamples(*ctx->priv().caps())) {
|
||||
*errorMsg = "MSAA and mixed samples only.";
|
||||
return DrawResult::kSkip;
|
||||
}
|
||||
|
@ -216,8 +216,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrTexture.cpp",
|
||||
"$_src/gpu/GrTextureAdjuster.cpp",
|
||||
"$_src/gpu/GrTextureAdjuster.h",
|
||||
"$_src/gpu/GrTextureContext.cpp",
|
||||
"$_src/gpu/GrTextureContext.h",
|
||||
"$_src/gpu/GrTextureMaker.cpp",
|
||||
"$_src/gpu/GrTextureMaker.h",
|
||||
"$_src/gpu/GrTexturePriv.h",
|
||||
|
@ -22,7 +22,6 @@ class GrStrikeCache;
|
||||
class GrSurfaceContext;
|
||||
class GrSurfaceProxy;
|
||||
class GrTextBlobCache;
|
||||
class GrTextureContext;
|
||||
class SkArenaAlloc;
|
||||
|
||||
class GrRecordingContext : public GrImageContext {
|
||||
@ -93,8 +92,8 @@ protected:
|
||||
sk_sp<SkColorSpace> = nullptr,
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
/** Create a new texture context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
|
||||
/** Create a new surface context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrSurfaceContext> makeDeferredSurfaceContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -124,7 +124,7 @@ bool GrClipStackClip::PathNeedsSWRenderer(GrRecordingContext* context,
|
||||
GrShape shape(path, GrStyle::SimpleFill());
|
||||
GrPathRenderer::CanDrawPathArgs canDrawArgs;
|
||||
canDrawArgs.fCaps = context->priv().caps();
|
||||
canDrawArgs.fProxy = renderTargetContext->proxy();
|
||||
canDrawArgs.fProxy = renderTargetContext->asRenderTargetProxy();
|
||||
canDrawArgs.fClipConservativeBounds = &scissorRect;
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrMemoryPool.h"
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
#include "src/gpu/GrSurfaceContext.h"
|
||||
#include "src/gpu/GrSurfaceContextPriv.h"
|
||||
#include "src/gpu/GrSurfacePriv.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/effects/generated/GrConfigConversionEffect.h"
|
||||
@ -50,7 +50,7 @@ std::unique_ptr<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrTextureContext> GrContextPriv::makeDeferredTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -61,7 +61,7 @@ std::unique_ptr<GrTextureContext> GrContextPriv::makeDeferredTextureContext(
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
return fContext->makeDeferredTextureContext(fit, width, height, colorType, alphaType,
|
||||
return fContext->makeDeferredSurfaceContext(fit, width, height, colorType, alphaType,
|
||||
std::move(colorSpace), mipMapped, origin, budgeted,
|
||||
isProtected);
|
||||
}
|
||||
@ -93,7 +93,7 @@ std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetCo
|
||||
surfaceProps, budgeted, isProtected);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrTextureContext> GrContextPriv::makeBackendTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrContextPriv::makeBackendTextureContext(
|
||||
const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
GrColorType colorType,
|
||||
@ -107,7 +107,7 @@ std::unique_ptr<GrTextureContext> GrContextPriv::makeBackendTextureContext(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this->drawingManager()->makeTextureContext(std::move(proxy), colorType, alphaType,
|
||||
return this->drawingManager()->makeSurfaceContext(std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ class GrOpMemoryPool;
|
||||
class GrOnFlushCallbackObject;
|
||||
class GrSemaphore;
|
||||
class GrSurfaceProxy;
|
||||
class GrTextureContext;
|
||||
|
||||
class SkDeferredDisplayList;
|
||||
class SkTaskGroup;
|
||||
@ -75,7 +74,7 @@ public:
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
/** Create a new texture context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> makeDeferredSurfaceContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
@ -131,7 +130,7 @@ public:
|
||||
*/
|
||||
static sk_sp<GrContext> MakeDDL(const sk_sp<GrContextThreadSafeProxy>&);
|
||||
|
||||
std::unique_ptr<GrTextureContext> makeBackendTextureContext(const GrBackendTexture&,
|
||||
std::unique_ptr<GrSurfaceContext> makeBackendTextureContext(const GrBackendTexture&,
|
||||
GrSurfaceOrigin,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "src/gpu/GrResourceAllocator.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrSoftwarePathRenderer.h"
|
||||
#include "src/gpu/GrSurfaceContext.h"
|
||||
#include "src/gpu/GrSurfaceProxyPriv.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/GrTexturePriv.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/GrTextureProxyPriv.h"
|
||||
@ -941,7 +941,7 @@ std::unique_ptr<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext
|
||||
managedOpsTask));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrTextureContext> GrDrawingManager::makeTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrDrawingManager::makeSurfaceContext(
|
||||
sk_sp<GrSurfaceProxy> sProxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
@ -953,12 +953,10 @@ std::unique_ptr<GrTextureContext> GrDrawingManager::makeTextureContext(
|
||||
// GrTextureRenderTargets should always be using a GrRenderTargetContext
|
||||
SkASSERT(!sProxy->asRenderTargetProxy());
|
||||
|
||||
sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
|
||||
GrSurfaceOrigin origin = sProxy->origin();
|
||||
GrSwizzle readSwizzle = sProxy->textureSwizzle();
|
||||
|
||||
GrSurfaceOrigin origin = textureProxy->origin();
|
||||
GrSwizzle texSwizzle = textureProxy->textureSwizzle();
|
||||
|
||||
return std::unique_ptr<GrTextureContext>(new GrTextureContext(
|
||||
fContext, std::move(textureProxy), colorType, alphaType, std::move(colorSpace), origin,
|
||||
texSwizzle));
|
||||
return std::unique_ptr<GrSurfaceContext>(new GrSurfaceContext(
|
||||
fContext, std::move(sProxy), colorType, alphaType, std::move(colorSpace), origin,
|
||||
readSwizzle));
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ class GrRecordingContext;
|
||||
class GrRenderTargetContext;
|
||||
class GrRenderTargetProxy;
|
||||
class GrSoftwarePathRenderer;
|
||||
class GrSurfaceContext;
|
||||
class GrSurfaceProxyView;
|
||||
class GrTextureContext;
|
||||
class GrTextureResolveRenderTask;
|
||||
class SkDeferredDisplayList;
|
||||
|
||||
@ -42,7 +42,7 @@ public:
|
||||
sk_sp<SkColorSpace>,
|
||||
const SkSurfaceProps*,
|
||||
bool managedOpsTask = true);
|
||||
std::unique_ptr<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>,
|
||||
std::unique_ptr<GrSurfaceContext> makeSurfaceContext(sk_sp<GrSurfaceProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
@ -45,7 +45,7 @@ bool GrPathRenderer::drawPath(const DrawPathArgs& args) {
|
||||
args.validate();
|
||||
CanDrawPathArgs canArgs;
|
||||
canArgs.fCaps = args.fContext->priv().caps();
|
||||
canArgs.fProxy = args.fRenderTargetContext->proxy();
|
||||
canArgs.fProxy = args.fRenderTargetContext->asRenderTargetProxy();
|
||||
canArgs.fClipConservativeBounds = args.fClipConservativeBounds;
|
||||
canArgs.fViewMatrix = args.fViewMatrix;
|
||||
canArgs.fShape = args.fShape;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/GrSurfaceContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/text/GrTextBlobCache.h"
|
||||
@ -176,12 +176,12 @@ std::unique_ptr<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
|
||||
} else {
|
||||
SkASSERT(proxy->asTextureProxy());
|
||||
SkASSERT(!props);
|
||||
return this->drawingManager()->makeTextureContext(std::move(proxy), colorType, alphaType,
|
||||
return this->drawingManager()->makeSurfaceContext(std::move(proxy), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GrTextureContext> GrRecordingContext::makeDeferredTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContext::makeDeferredSurfaceContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -214,7 +214,7 @@ std::unique_ptr<GrTextureContext> GrRecordingContext::makeDeferredTextureContext
|
||||
|
||||
auto drawingManager = this->drawingManager();
|
||||
|
||||
return drawingManager->makeTextureContext(std::move(texture), colorType, alphaType,
|
||||
return drawingManager->makeSurfaceContext(std::move(texture), colorType, alphaType,
|
||||
std::move(colorSpace));
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceCont
|
||||
std::move(colorSpace), props);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeDeferredSurfaceContext(
|
||||
SkBackingFit fit,
|
||||
int width,
|
||||
int height,
|
||||
@ -351,7 +351,7 @@ std::unique_ptr<GrTextureContext> GrRecordingContextPriv::makeDeferredTextureCon
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted,
|
||||
GrProtected isProtected) {
|
||||
return fContext->makeDeferredTextureContext(fit, width, height, colorType, alphaType,
|
||||
return fContext->makeDeferredSurfaceContext(fit, width, height, colorType, alphaType,
|
||||
std::move(colorSpace), mipMapped, origin, budgeted,
|
||||
isProtected);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
const SkSurfaceProps* = nullptr);
|
||||
|
||||
/** Create a new texture context backed by a deferred-style GrTextureProxy. */
|
||||
std::unique_ptr<GrTextureContext> makeDeferredTextureContext(
|
||||
std::unique_ptr<GrSurfaceContext> makeDeferredSurfaceContext(
|
||||
SkBackingFit,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -864,7 +864,7 @@ bool GrReducedClip::drawStencilClipMask(GrRecordingContext* context,
|
||||
GrShape shape(clipPath, GrStyle::SimpleFill());
|
||||
GrPathRenderer::CanDrawPathArgs canDrawArgs;
|
||||
canDrawArgs.fCaps = context->priv().caps();
|
||||
canDrawArgs.fProxy = renderTargetContext->proxy();
|
||||
canDrawArgs.fProxy = renderTargetContext->asRenderTargetProxy();
|
||||
canDrawArgs.fClipConservativeBounds = &stencilClip.fixedClip().scissorRect();
|
||||
canDrawArgs.fViewMatrix = &SkMatrix::I();
|
||||
canDrawArgs.fShape = &shape;
|
||||
|
@ -150,11 +150,10 @@ GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
bool managedOpsTask)
|
||||
: GrSurfaceContext(context, colorType, kPremul_SkAlphaType, std::move(colorSpace), origin,
|
||||
texSwizzle)
|
||||
, fRenderTargetProxy(std::move(rtp))
|
||||
: GrSurfaceContext(context, std::move(rtp), colorType, kPremul_SkAlphaType,
|
||||
std::move(colorSpace), origin, texSwizzle)
|
||||
, fOutputSwizzle(outSwizzle)
|
||||
, fOpsTask(sk_ref_sp(fRenderTargetProxy->getLastOpsTask()))
|
||||
, fOpsTask(sk_ref_sp(fSurfaceProxy->getLastOpsTask()))
|
||||
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
|
||||
, fManagedOpsTask(managedOpsTask) {
|
||||
fTextTarget.reset(new TextTarget(this));
|
||||
@ -162,15 +161,9 @@ GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void GrRenderTargetContext::validate() const {
|
||||
SkASSERT(fRenderTargetProxy);
|
||||
fRenderTargetProxy->validate(fContext);
|
||||
|
||||
SkASSERT(fContext->priv().caps()->areColorTypeAndFormatCompatible(
|
||||
this->colorInfo().colorType(), fRenderTargetProxy->backendFormat()));
|
||||
|
||||
void GrRenderTargetContext::onValidate() const {
|
||||
if (fOpsTask && !fOpsTask->isClosed()) {
|
||||
SkASSERT(fRenderTargetProxy->getLastRenderTask() == fOpsTask.get());
|
||||
SkASSERT(fSurfaceProxy->getLastRenderTask() == fOpsTask.get());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -191,18 +184,6 @@ inline GrAAType GrRenderTargetContext::chooseAAType(GrAA aa) {
|
||||
return (this->numSamples() > 1) ? GrAAType::kMSAA : GrAAType::kCoverage;
|
||||
}
|
||||
|
||||
GrTextureProxy* GrRenderTargetContext::asTextureProxy() {
|
||||
return fRenderTargetProxy->asTextureProxy();
|
||||
}
|
||||
|
||||
const GrTextureProxy* GrRenderTargetContext::asTextureProxy() const {
|
||||
return fRenderTargetProxy->asTextureProxy();
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrRenderTargetContext::asTextureProxyRef() {
|
||||
return sk_ref_sp(fRenderTargetProxy->asTextureProxy());
|
||||
}
|
||||
|
||||
GrMipMapped GrRenderTargetContext::mipMapped() const {
|
||||
if (const GrTextureProxy* proxy = this->asTextureProxy()) {
|
||||
return proxy->mipMapped();
|
||||
@ -367,7 +348,7 @@ void GrRenderTargetContext::drawPaint(const GrClip& clip,
|
||||
const SkMatrix& viewMatrix) {
|
||||
// Start with the render target, since that is the maximum content we could possibly fill.
|
||||
// drawFilledQuad() will automatically restrict it to clip bounds for us if possible.
|
||||
SkRect r = fRenderTargetProxy->getBoundsRect();
|
||||
SkRect r = fSurfaceProxy->getBoundsRect();
|
||||
if (!paint.numTotalFragmentProcessors()) {
|
||||
// The paint is trivial so we won't need to use local coordinates, so skip calculating the
|
||||
// inverse view matrix.
|
||||
@ -431,7 +412,7 @@ GrRenderTargetContext::QuadOptimization GrRenderTargetContext::attemptQuadOptimi
|
||||
if (stencilSettings) {
|
||||
// Must use size at which the rendertarget will ultimately be allocated so that stencil
|
||||
// buffer updates on approximately sized render targets don't get corrupted.
|
||||
rtRect = fRenderTargetProxy->backingStoreBoundsRect();
|
||||
rtRect = fSurfaceProxy->backingStoreBoundsRect();
|
||||
} else {
|
||||
// Use the logical size of the render target, which allows for "fullscreen" clears even if
|
||||
// the render target has an approximate backing fit
|
||||
@ -737,7 +718,7 @@ void GrRenderTargetContext::drawQuadSet(const GrClip& clip, GrPaint&& paint, GrA
|
||||
}
|
||||
|
||||
int GrRenderTargetContextPriv::maxWindowRectangles() const {
|
||||
return fRenderTargetContext->fRenderTargetProxy->maxWindowRectangles(
|
||||
return fRenderTargetContext->asRenderTargetProxy()->maxWindowRectangles(
|
||||
*fRenderTargetContext->caps());
|
||||
}
|
||||
|
||||
@ -764,7 +745,7 @@ void GrRenderTargetContext::setNeedsStencil(bool useMixedSamplesIfNotMSAA) {
|
||||
|
||||
int numRequiredSamples = this->numSamples();
|
||||
if (useMixedSamplesIfNotMSAA && 1 == numRequiredSamples) {
|
||||
SkASSERT(fRenderTargetProxy->canUseMixedSamples(*this->caps()));
|
||||
SkASSERT(this->asRenderTargetProxy()->canUseMixedSamples(*this->caps()));
|
||||
numRequiredSamples = this->caps()->internalMultisampleCount(
|
||||
this->asSurfaceProxy()->backendFormat());
|
||||
}
|
||||
@ -772,7 +753,7 @@ void GrRenderTargetContext::setNeedsStencil(bool useMixedSamplesIfNotMSAA) {
|
||||
|
||||
if (numRequiredSamples > fNumStencilSamples) {
|
||||
fNumStencilSamples = numRequiredSamples;
|
||||
fRenderTargetProxy->setNeedsStencil(fNumStencilSamples);
|
||||
this->asRenderTargetProxy()->setNeedsStencil(fNumStencilSamples);
|
||||
}
|
||||
|
||||
if (!hasInitializedStencil) {
|
||||
@ -813,7 +794,7 @@ void GrRenderTargetContext::internalStencilClear(const GrFixedClip& clip, bool i
|
||||
rtRect, ss));
|
||||
} else {
|
||||
std::unique_ptr<GrOp> op(GrClearStencilClipOp::Make(fContext, clip, insideStencilMask,
|
||||
fRenderTargetProxy.get()));
|
||||
this->asRenderTargetProxy()));
|
||||
if (!op) {
|
||||
return;
|
||||
}
|
||||
@ -1493,7 +1474,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
|
||||
callback(context, nullptr);
|
||||
return;
|
||||
}
|
||||
if (fRenderTargetProxy->wrapsVkSecondaryCB()) {
|
||||
if (this->asRenderTargetProxy()->wrapsVkSecondaryCB()) {
|
||||
callback(context, nullptr);
|
||||
return;
|
||||
}
|
||||
@ -1504,7 +1485,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
|
||||
}
|
||||
bool needsRescale = srcRect.width() != info.width() || srcRect.height() != info.height();
|
||||
auto colorTypeOfFinalContext = this->colorInfo().colorType();
|
||||
auto backendFormatOfFinalContext = fRenderTargetProxy->backendFormat();
|
||||
auto backendFormatOfFinalContext = fSurfaceProxy->backendFormat();
|
||||
if (needsRescale) {
|
||||
colorTypeOfFinalContext = dstCT;
|
||||
backendFormatOfFinalContext = this->caps()->getDefaultBackendFormat(dstCT,
|
||||
@ -1552,11 +1533,11 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
|
||||
callback(context, nullptr);
|
||||
return;
|
||||
}
|
||||
sk_sp<GrTextureProxy> texProxy = sk_ref_sp(fRenderTargetProxy->asTextureProxy());
|
||||
sk_sp<GrTextureProxy> texProxy = sk_ref_sp(fSurfaceProxy->asTextureProxy());
|
||||
SkRect srcRectToDraw = SkRect::Make(srcRect);
|
||||
// If the src is not texturable first try to make a copy to a texture.
|
||||
if (!texProxy) {
|
||||
texProxy = GrSurfaceProxy::Copy(fContext, fRenderTargetProxy.get(),
|
||||
texProxy = GrSurfaceProxy::Copy(fContext, fSurfaceProxy.get(),
|
||||
GrMipMapped::kNo, srcRect, SkBackingFit::kApprox,
|
||||
SkBudgeted::kNo);
|
||||
if (!texProxy) {
|
||||
@ -1738,7 +1719,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
|
||||
callback(context, nullptr);
|
||||
return;
|
||||
}
|
||||
if (fRenderTargetProxy->wrapsVkSecondaryCB()) {
|
||||
if (this->asRenderTargetProxy()->wrapsVkSecondaryCB()) {
|
||||
callback(context, nullptr);
|
||||
return;
|
||||
}
|
||||
@ -1942,7 +1923,7 @@ GrSemaphoresSubmitted GrRenderTargetContext::flush(SkSurface::BackendSurfaceAcce
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "flush", fContext);
|
||||
|
||||
return this->drawingManager()->flushSurface(fRenderTargetProxy.get(), access, info);
|
||||
return this->drawingManager()->flushSurface(fSurfaceProxy.get(), access, info);
|
||||
}
|
||||
|
||||
bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores,
|
||||
@ -2087,7 +2068,7 @@ bool GrRenderTargetContextPriv::drawAndStencilPath(const GrHardClip& clip,
|
||||
GrShape shape(path, GrStyle::SimpleFill());
|
||||
GrPathRenderer::CanDrawPathArgs canDrawArgs;
|
||||
canDrawArgs.fCaps = fRenderTargetContext->caps();
|
||||
canDrawArgs.fProxy = fRenderTargetContext->proxy();
|
||||
canDrawArgs.fProxy = fRenderTargetContext->asRenderTargetProxy();
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
canDrawArgs.fClipConservativeBounds = &clipConservativeBounds;
|
||||
@ -2129,7 +2110,7 @@ SkBudgeted GrRenderTargetContextPriv::isBudgeted() const {
|
||||
|
||||
SkDEBUGCODE(fRenderTargetContext->validate();)
|
||||
|
||||
return fRenderTargetContext->fRenderTargetProxy->isBudgeted();
|
||||
return fRenderTargetContext->fSurfaceProxy->isBudgeted();
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawShapeUsingPathRenderer(const GrClip& clip,
|
||||
@ -2153,7 +2134,7 @@ void GrRenderTargetContext::drawShapeUsingPathRenderer(const GrClip& clip,
|
||||
|
||||
GrPathRenderer::CanDrawPathArgs canDrawArgs;
|
||||
canDrawArgs.fCaps = this->caps();
|
||||
canDrawArgs.fProxy = this->proxy();
|
||||
canDrawArgs.fProxy = this->asRenderTargetProxy();
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &originalShape;
|
||||
canDrawArgs.fClipConservativeBounds = &clipConservativeBounds;
|
||||
@ -2283,7 +2264,8 @@ void GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<GrDraw
|
||||
// that uses a stencil test when the stencil buffer is multisampled.)
|
||||
bool hasMixedSampledCoverage = (
|
||||
willUseStencil && fNumStencilSamples > this->numSamples());
|
||||
SkASSERT(!hasMixedSampledCoverage || fRenderTargetProxy->canUseMixedSamples(*this->caps()));
|
||||
SkASSERT(!hasMixedSampledCoverage ||
|
||||
this->asRenderTargetProxy()->canUseMixedSamples(*this->caps()));
|
||||
|
||||
GrClampType clampType = GrColorTypeClampType(this->colorInfo().colorType());
|
||||
GrProcessorSet::Analysis analysis = op->finalize(
|
||||
@ -2311,25 +2293,25 @@ bool GrRenderTargetContext::setupDstProxyView(const GrClip& clip, const GrOp& op
|
||||
// If we are wrapping a vulkan secondary command buffer, we can't make a dst copy because we
|
||||
// don't actually have a VkImage to make a copy of. Additionally we don't have the power to
|
||||
// start and stop the render pass in order to make the copy.
|
||||
if (fRenderTargetProxy->wrapsVkSecondaryCB()) {
|
||||
if (this->asRenderTargetProxy()->wrapsVkSecondaryCB()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->caps()->textureBarrierSupport() && !fRenderTargetProxy->requiresManualMSAAResolve()) {
|
||||
if (fRenderTargetProxy->asTextureProxy()) {
|
||||
if (this->caps()->textureBarrierSupport() && !fSurfaceProxy->requiresManualMSAAResolve()) {
|
||||
if (this->asTextureProxy()) {
|
||||
// The render target is a texture, so we can read from it directly in the shader. The XP
|
||||
// will be responsible to detect this situation and request a texture barrier.
|
||||
dstProxyView->setProxyView(this->textureSurfaceView());
|
||||
dstProxyView->setProxyView(this->readSurfaceView());
|
||||
dstProxyView->setOffset(0, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
SkIRect copyRect = SkIRect::MakeSize(fRenderTargetProxy->dimensions());
|
||||
SkIRect copyRect = SkIRect::MakeSize(fSurfaceProxy->dimensions());
|
||||
|
||||
SkIRect clippedRect;
|
||||
clip.getConservativeBounds(
|
||||
fRenderTargetProxy->width(), fRenderTargetProxy->height(), &clippedRect);
|
||||
this->width(), this->height(), &clippedRect);
|
||||
SkRect opBounds = op.bounds();
|
||||
// If the op has aa bloating or is a infinitely thin geometry (hairline) outset the bounds by
|
||||
// 0.5 pixels.
|
||||
@ -2339,7 +2321,7 @@ bool GrRenderTargetContext::setupDstProxyView(const GrClip& clip, const GrOp& op
|
||||
// performance we may ignore the clip when the draw is entirely inside the clip is float
|
||||
// space but will hit pixels just outside the clip when actually rasterizing.
|
||||
clippedRect.outset(1, 1);
|
||||
clippedRect.intersect(SkIRect::MakeSize(fRenderTargetProxy->dimensions()));
|
||||
clippedRect.intersect(SkIRect::MakeSize(fSurfaceProxy->dimensions()));
|
||||
}
|
||||
SkIRect opIBounds;
|
||||
opBounds.roundOut(&opIBounds);
|
||||
@ -2353,7 +2335,7 @@ bool GrRenderTargetContext::setupDstProxyView(const GrClip& clip, const GrOp& op
|
||||
// MSAA consideration: When there is support for reading MSAA samples in the shader we could
|
||||
// have per-sample dst values by making the copy multisampled.
|
||||
GrCaps::DstCopyRestrictions restrictions = this->caps()->getDstCopyRestrictions(
|
||||
fRenderTargetProxy.get(), this->colorInfo().colorType());
|
||||
this->asRenderTargetProxy(), this->colorInfo().colorType());
|
||||
|
||||
if (!restrictions.fMustCopyWholeSrc) {
|
||||
copyRect = clippedRect;
|
||||
@ -2369,11 +2351,11 @@ bool GrRenderTargetContext::setupDstProxyView(const GrClip& clip, const GrOp& op
|
||||
fit = SkBackingFit::kApprox;
|
||||
}
|
||||
sk_sp<GrTextureProxy> newProxy =
|
||||
GrSurfaceProxy::Copy(fContext, fRenderTargetProxy.get(), GrMipMapped::kNo, copyRect,
|
||||
GrSurfaceProxy::Copy(fContext, fSurfaceProxy.get(), GrMipMapped::kNo, copyRect,
|
||||
fit, SkBudgeted::kYes, restrictions.fRectsMustMatch);
|
||||
SkASSERT(newProxy);
|
||||
|
||||
dstProxyView->setProxyView({std::move(newProxy), this->origin(), this->textureSwizzle()});
|
||||
dstProxyView->setProxyView({std::move(newProxy), this->origin(), this->readSwizzle()});
|
||||
dstProxyView->setOffset(dstOffset);
|
||||
return true;
|
||||
}
|
||||
|
@ -486,32 +486,18 @@ public:
|
||||
*/
|
||||
bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[]);
|
||||
|
||||
const GrRenderTargetProxy* proxy() const { return fRenderTargetProxy.get(); }
|
||||
int width() const { return fRenderTargetProxy->width(); }
|
||||
int height() const { return fRenderTargetProxy->height(); }
|
||||
int numSamples() const { return fRenderTargetProxy->numSamples(); }
|
||||
int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
|
||||
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
|
||||
bool wrapsVkSecondaryCB() const { return fRenderTargetProxy->wrapsVkSecondaryCB(); }
|
||||
bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
|
||||
GrMipMapped mipMapped() const;
|
||||
|
||||
GrSurfaceProxyView outputSurfaceView() {
|
||||
return { fRenderTargetProxy, fOrigin, fOutputSwizzle };
|
||||
return { fSurfaceProxy, fOrigin, fOutputSwizzle };
|
||||
}
|
||||
|
||||
// This entry point should only be called if the backing GPU object is known to be
|
||||
// instantiated.
|
||||
GrRenderTarget* accessRenderTarget() { return fRenderTargetProxy->peekRenderTarget(); }
|
||||
|
||||
GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); }
|
||||
const GrSurfaceProxy* asSurfaceProxy() const override { return fRenderTargetProxy.get(); }
|
||||
sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fRenderTargetProxy; }
|
||||
|
||||
GrTextureProxy* asTextureProxy() override;
|
||||
const GrTextureProxy* asTextureProxy() const override;
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef() override;
|
||||
|
||||
GrRenderTargetProxy* asRenderTargetProxy() override { return fRenderTargetProxy.get(); }
|
||||
sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override { return fRenderTargetProxy; }
|
||||
GrRenderTarget* accessRenderTarget() { return fSurfaceProxy->peekRenderTarget(); }
|
||||
|
||||
GrRenderTargetContext* asRenderTargetContext() override { return this; }
|
||||
|
||||
@ -522,7 +508,7 @@ public:
|
||||
GrTextTarget* textTarget() { return fTextTarget.get(); }
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool testingOnly_IsInstantiated() const { return fRenderTargetProxy->isInstantiated(); }
|
||||
bool testingOnly_IsInstantiated() const { return fSurfaceProxy->isInstantiated(); }
|
||||
void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; }
|
||||
GrOpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); }
|
||||
#endif
|
||||
@ -559,7 +545,7 @@ private:
|
||||
GrSurfaceOrigin, GrSwizzle texSwizzle, GrSwizzle outSwizzle,
|
||||
sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true);
|
||||
|
||||
SkDEBUGCODE(void validate() const override;)
|
||||
SkDEBUGCODE(void onValidate() const override;)
|
||||
|
||||
|
||||
GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const;
|
||||
@ -649,7 +635,6 @@ private:
|
||||
|
||||
std::unique_ptr<GrTextTarget> fTextTarget;
|
||||
|
||||
sk_sp<GrRenderTargetProxy> fRenderTargetProxy;
|
||||
GrSwizzle fOutputSwizzle;
|
||||
|
||||
// In MDB-mode the GrOpsTask can be closed by some other renderTargetContext that has picked
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
* guaranteed to match the uniqueID of the underlying GrRenderTarget - beware!
|
||||
*/
|
||||
GrSurfaceProxy::UniqueID uniqueID() const {
|
||||
return fRenderTargetContext->fRenderTargetProxy->uniqueID();
|
||||
return fRenderTargetContext->fSurfaceProxy->uniqueID();
|
||||
}
|
||||
|
||||
uint32_t testingOnly_getOpsTaskID();
|
||||
@ -99,7 +99,7 @@ public:
|
||||
const std::function<WillAddOpFn>& = std::function<WillAddOpFn>());
|
||||
|
||||
bool refsWrappedObjects() const {
|
||||
return fRenderTargetContext->fRenderTargetProxy->refsWrappedObjects();
|
||||
return fRenderTargetContext->asRenderTargetProxy()->refsWrappedObjects();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
#include "src/gpu/GrSurfaceContextPriv.h"
|
||||
#include "src/gpu/GrSurfacePriv.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBicubicEffect.h"
|
||||
|
||||
@ -33,15 +32,17 @@
|
||||
// stack. When this occurs with a closed GrOpsTask, a new one will be allocated
|
||||
// when the renderTargetContext attempts to use it (via getOpsTask).
|
||||
GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
|
||||
sk_sp<GrSurfaceProxy> proxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrSurfaceOrigin origin,
|
||||
GrSwizzle texSwizzle)
|
||||
GrSwizzle readSwizzle)
|
||||
: fContext(context)
|
||||
, fSurfaceProxy(std::move(proxy))
|
||||
, fOrigin(origin)
|
||||
, fColorInfo(colorType, alphaType, std::move(colorSpace))
|
||||
, fTextureSwizzle(texSwizzle) {}
|
||||
, fReadSwizzle(readSwizzle) {}
|
||||
|
||||
const GrCaps* GrSurfaceContext::caps() const { return fContext->priv().caps(); }
|
||||
|
||||
@ -319,7 +320,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
|
||||
if (!tempProxy) {
|
||||
return false;
|
||||
}
|
||||
auto tempCtx = direct->priv().drawingManager()->makeTextureContext(
|
||||
auto tempCtx = direct->priv().drawingManager()->makeSurfaceContext(
|
||||
tempProxy, colorType, alphaType, this->colorInfo().refColorSpace());
|
||||
if (!tempCtx) {
|
||||
return false;
|
||||
@ -426,7 +427,7 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S
|
||||
// The swizzle doesn't matter for copies and it is not used.
|
||||
return this->drawingManager()->newCopyRenderTask(
|
||||
GrSurfaceProxyView(sk_ref_sp(src), src->origin(), GrSwizzle()), srcRect,
|
||||
this->textureSurfaceView(), dstPoint);
|
||||
this->readSurfaceView(), dstPoint);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
|
||||
@ -658,3 +659,15 @@ GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorTy
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void GrSurfaceContext::validate() const {
|
||||
SkASSERT(fSurfaceProxy);
|
||||
fSurfaceProxy->validate(fContext);
|
||||
SkASSERT(fContext->priv().caps()->areColorTypeAndFormatCompatible(
|
||||
this->colorInfo().colorType(), fSurfaceProxy->backendFormat()));
|
||||
|
||||
this->onValidate();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -40,14 +40,13 @@ public:
|
||||
|
||||
const GrColorInfo& colorInfo() const { return fColorInfo; }
|
||||
GrSurfaceOrigin origin() const { return fOrigin; }
|
||||
const GrSwizzle& textureSwizzle() const { return fTextureSwizzle; }
|
||||
GrSurfaceProxyView textureSurfaceView() {
|
||||
return { this->asSurfaceProxyRef(), fOrigin, fTextureSwizzle };
|
||||
const GrSwizzle& readSwizzle() const { return fReadSwizzle; }
|
||||
GrSurfaceProxyView readSurfaceView() {
|
||||
return { this->asSurfaceProxyRef(), fOrigin, fReadSwizzle };
|
||||
}
|
||||
|
||||
// TODO: these two calls would be way cooler if this object had a GrSurfaceProxy pointer
|
||||
int width() const { return this->asSurfaceProxy()->width(); }
|
||||
int height() const { return this->asSurfaceProxy()->height(); }
|
||||
int width() const { return fSurfaceProxy->width(); }
|
||||
int height() const { return fSurfaceProxy->height(); }
|
||||
|
||||
const GrCaps* caps() const;
|
||||
|
||||
@ -76,17 +75,23 @@ public:
|
||||
bool writePixels(const GrImageInfo& srcInfo, const void* src, size_t rowBytes, SkIPoint dstPt,
|
||||
GrContext* direct = nullptr);
|
||||
|
||||
// TODO: this is virtual b.c. this object doesn't have a pointer to the wrapped GrSurfaceProxy?
|
||||
virtual GrSurfaceProxy* asSurfaceProxy() = 0;
|
||||
virtual const GrSurfaceProxy* asSurfaceProxy() const = 0;
|
||||
virtual sk_sp<GrSurfaceProxy> asSurfaceProxyRef() = 0;
|
||||
GrSurfaceProxy* asSurfaceProxy() { return fSurfaceProxy.get(); }
|
||||
const GrSurfaceProxy* asSurfaceProxy() const { return fSurfaceProxy.get(); }
|
||||
sk_sp<GrSurfaceProxy> asSurfaceProxyRef() { return fSurfaceProxy; }
|
||||
|
||||
virtual GrTextureProxy* asTextureProxy() = 0;
|
||||
virtual const GrTextureProxy* asTextureProxy() const = 0;
|
||||
virtual sk_sp<GrTextureProxy> asTextureProxyRef() = 0;
|
||||
GrTextureProxy* asTextureProxy() { return fSurfaceProxy->asTextureProxy(); }
|
||||
const GrTextureProxy* asTextureProxy() const { return fSurfaceProxy->asTextureProxy(); }
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef() {
|
||||
return sk_ref_sp(fSurfaceProxy->asTextureProxy());
|
||||
}
|
||||
|
||||
virtual GrRenderTargetProxy* asRenderTargetProxy() = 0;
|
||||
virtual sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() = 0;
|
||||
GrRenderTargetProxy* asRenderTargetProxy() { return fSurfaceProxy->asRenderTargetProxy(); }
|
||||
const GrRenderTargetProxy* asRenderTargetProxy() const {
|
||||
return fSurfaceProxy->asRenderTargetProxy();
|
||||
}
|
||||
sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() {
|
||||
return sk_ref_sp(fSurfaceProxy->asRenderTargetProxy());
|
||||
}
|
||||
|
||||
virtual GrRenderTargetContext* asRenderTargetContext() { return nullptr; }
|
||||
|
||||
@ -108,19 +113,21 @@ public:
|
||||
|
||||
protected:
|
||||
friend class GrSurfaceContextPriv;
|
||||
friend class GrDrawingManager; // For ctor
|
||||
|
||||
GrSurfaceContext(GrRecordingContext*, GrColorType, SkAlphaType, sk_sp<SkColorSpace>,
|
||||
GrSurfaceOrigin, GrSwizzle texSwizzle);
|
||||
GrSurfaceContext(GrRecordingContext*, sk_sp<GrSurfaceProxy>, GrColorType, SkAlphaType,
|
||||
sk_sp<SkColorSpace>, GrSurfaceOrigin, GrSwizzle readSwizzle);
|
||||
|
||||
GrDrawingManager* drawingManager();
|
||||
const GrDrawingManager* drawingManager() const;
|
||||
|
||||
SkDEBUGCODE(virtual void validate() const = 0;)
|
||||
SkDEBUGCODE(void validate() const;)
|
||||
|
||||
SkDEBUGCODE(GrSingleOwner* singleOwner();)
|
||||
|
||||
GrRecordingContext* fContext;
|
||||
|
||||
sk_sp<GrSurfaceProxy> fSurfaceProxy;
|
||||
GrSurfaceOrigin fOrigin;
|
||||
|
||||
// The rescaling step of asyncRescaleAndReadPixels[YUV420]().
|
||||
@ -145,6 +152,8 @@ protected:
|
||||
private:
|
||||
friend class GrSurfaceProxy; // for copy
|
||||
|
||||
SkDEBUGCODE(virtual void onValidate() const {})
|
||||
|
||||
/**
|
||||
* Copy 'src' into the proxy backing this context. This call will not do any draw fallback.
|
||||
* Currently only writePixels and replaceRenderTarget call this directly. All other copies
|
||||
@ -167,7 +176,7 @@ private:
|
||||
}
|
||||
|
||||
GrColorInfo fColorInfo;
|
||||
GrSwizzle fTextureSwizzle;
|
||||
GrSwizzle fReadSwizzle;
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrStencilAttachment.h"
|
||||
#include "src/gpu/GrSurfacePriv.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/GrTexturePriv.h"
|
||||
#include "src/gpu/GrTextureRenderTargetProxy.h"
|
||||
|
||||
@ -310,7 +309,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
|
||||
}
|
||||
auto colorType = GrPixelConfigToColorType(src->config());
|
||||
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
|
||||
auto dstContext = context->priv().makeDeferredTextureContext(
|
||||
auto dstContext = context->priv().makeDeferredSurfaceContext(
|
||||
fit, width, height, colorType, kUnknown_SkAlphaType, nullptr, mipMapped,
|
||||
src->origin(), budgeted, isProtected);
|
||||
if (!dstContext) {
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
|
||||
#include "src/gpu/GrAuditTrail.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/GrDrawingManager.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
|
||||
#define ASSERT_SINGLE_OWNER \
|
||||
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
|
||||
#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
|
||||
|
||||
GrTextureContext::GrTextureContext(GrRecordingContext* context,
|
||||
sk_sp<GrTextureProxy> textureProxy,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrSurfaceOrigin origin,
|
||||
GrSwizzle texSwizzle)
|
||||
: GrSurfaceContext(context, colorType, alphaType, std::move(colorSpace), origin, texSwizzle)
|
||||
, fTextureProxy(std::move(textureProxy)) {
|
||||
SkDEBUGCODE(this->validate();)
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void GrTextureContext::validate() const {
|
||||
SkASSERT(fTextureProxy);
|
||||
fTextureProxy->validate(fContext);
|
||||
SkASSERT(fContext->priv().caps()->areColorTypeAndFormatCompatible(
|
||||
this->colorInfo().colorType(), fTextureProxy->backendFormat()));
|
||||
}
|
||||
#endif
|
||||
|
||||
GrTextureContext::~GrTextureContext() {
|
||||
ASSERT_SINGLE_OWNER
|
||||
}
|
||||
|
||||
GrRenderTargetProxy* GrTextureContext::asRenderTargetProxy() {
|
||||
// If the proxy can return an RTProxy it should've been wrapped in a RTContext
|
||||
SkASSERT(!fTextureProxy->asRenderTargetProxy());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTargetProxy> GrTextureContext::asRenderTargetProxyRef() {
|
||||
// If the proxy can return an RTProxy it should've been wrapped in a RTContext
|
||||
SkASSERT(!fTextureProxy->asRenderTargetProxy());
|
||||
return nullptr;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrTextureContext_DEFINED
|
||||
#define GrTextureContext_DEFINED
|
||||
|
||||
#include "src/gpu/GrSurfaceContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
|
||||
class GrContext;
|
||||
class GrDrawingManager;
|
||||
class GrSurface;
|
||||
class GrTextureProxy;
|
||||
struct SkIPoint;
|
||||
struct SkIRect;
|
||||
|
||||
/**
|
||||
* A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
|
||||
* GrTextures and not GrRenderTargets.
|
||||
*/
|
||||
class GrTextureContext : public GrSurfaceContext {
|
||||
public:
|
||||
~GrTextureContext() override;
|
||||
|
||||
GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
|
||||
const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
|
||||
sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }
|
||||
|
||||
GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
|
||||
const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
|
||||
|
||||
GrRenderTargetProxy* asRenderTargetProxy() override;
|
||||
sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
|
||||
|
||||
protected:
|
||||
GrTextureContext(GrRecordingContext*,
|
||||
sk_sp<GrTextureProxy>,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
GrSurfaceOrigin origin,
|
||||
GrSwizzle texSwizzle);
|
||||
|
||||
SkDEBUGCODE(void validate() const override;)
|
||||
|
||||
private:
|
||||
friend class GrDrawingManager; // for ctor
|
||||
|
||||
sk_sp<GrTextureProxy> fTextureProxy;
|
||||
|
||||
typedef GrSurfaceContext INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
@ -580,8 +580,8 @@ bool GrCCPerFlushResources::finalize(GrOnFlushResourceProvider* onFlushRP) {
|
||||
atlas->getStrokeBatchID(), atlas->drawBounds());
|
||||
}
|
||||
rtc->addDrawOp(GrNoClip(), std::move(op));
|
||||
if (rtc->proxy()->requiresManualMSAAResolve()) {
|
||||
onFlushRP->addTextureResolveTask(sk_ref_sp(rtc->proxy()->asTextureProxy()),
|
||||
if (rtc->asSurfaceProxy()->requiresManualMSAAResolve()) {
|
||||
onFlushRP->addTextureResolveTask(sk_ref_sp(rtc->asTextureProxy()),
|
||||
GrSurfaceProxy::ResolveFlags::kMSAA);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "src/gpu/GrSemaphore.h"
|
||||
#include "src/gpu/GrSurfacePriv.h"
|
||||
#include "src/gpu/GrTextureAdjuster.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/GrTexturePriv.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/GrTextureProxyPriv.h"
|
||||
@ -105,7 +104,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con
|
||||
|
||||
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
||||
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID, this->alphaType(),
|
||||
renderTargetContext->textureSurfaceView(), std::move(targetCS));
|
||||
renderTargetContext->readSurfaceView(), std::move(targetCS));
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage_Gpu::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const {
|
||||
@ -232,7 +231,7 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorS
|
||||
SkAlphaType at = GetAlphaTypeFromYUVAIndices(yuvaIndices);
|
||||
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, at,
|
||||
renderTargetContext->textureSurfaceView(),
|
||||
renderTargetContext->readSurfaceView(),
|
||||
renderTargetContext->colorInfo().refColorSpace());
|
||||
}
|
||||
|
||||
@ -608,16 +607,16 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto texContext =
|
||||
drawingManager->makeTextureContext(proxy, SkColorTypeToGrColorType(pixmap.colorType()),
|
||||
auto surfaceContext =
|
||||
drawingManager->makeSurfaceContext(proxy, SkColorTypeToGrColorType(pixmap.colorType()),
|
||||
pixmap.alphaType(), cs);
|
||||
if (!texContext) {
|
||||
if (!surfaceContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkImageInfo srcInfo = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, at,
|
||||
std::move(cs));
|
||||
texContext->writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
|
||||
surfaceContext->writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
|
||||
|
||||
GrFlushInfo info;
|
||||
info.fFlags = kSyncCpu_GrFlushFlag;
|
||||
|
@ -122,7 +122,7 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) {
|
||||
// The renderTargetContext coming out of SkGpuDevice should always be exact and the
|
||||
// above copy creates a kExact surfaceContext.
|
||||
SkASSERT(srcProxy->priv().isExact());
|
||||
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->textureSwizzle());
|
||||
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->readSwizzle());
|
||||
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, info.alphaType(),
|
||||
std::move(view), info.refColorSpace());
|
||||
}
|
||||
@ -256,7 +256,7 @@ void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPai
|
||||
// Possibly we could skip making an image here if SkGpuDevice exposed a lower level way
|
||||
// of drawing a texture proxy.
|
||||
const SkImageInfo info = fDevice->imageInfo();
|
||||
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->textureSwizzle());
|
||||
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->readSwizzle());
|
||||
sk_sp<SkImage> image;
|
||||
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, info.alphaType(),
|
||||
std::move(view), info.refColorSpace());
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrSurfacePriv.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/GrTexturePriv.h"
|
||||
#include "src/gpu/GrTextureProxyPriv.h"
|
||||
#include "src/gpu/gl/GrGLGpu.h"
|
||||
|
@ -209,7 +209,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
||||
|
||||
#include "src/gpu/GrDrawingManager.h"
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
|
||||
// For each context, set it to always clear the textures and then run through all the
|
||||
// supported formats checking that the textures are actually cleared
|
||||
@ -329,7 +328,7 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
|
||||
fit, desc.fWidth, desc.fHeight, combo.fColorType, nullptr,
|
||||
1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr);
|
||||
} else {
|
||||
surfCtx = context->priv().makeDeferredTextureContext(
|
||||
surfCtx = context->priv().makeDeferredSurfaceContext(
|
||||
fit, desc.fWidth, desc.fHeight, combo.fColorType,
|
||||
kUnknown_SkAlphaType, nullptr, GrMipMapped::kNo,
|
||||
kTopLeft_GrSurfaceOrigin);
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "src/gpu/GrImageInfo.h"
|
||||
#include "src/gpu/GrSurfaceContext.h"
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
#include "src/gpu/GrTextureContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user