Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions

The only really interesting parts are:
  src/gpu/SurfaceFillContext.*
  src/gpu/v1/SurfaceFillContext.*

Everything else is mostly mechanical.

Bug: skia:11837
Change-Id: If2945f30dadd6ad0cccf6ff2b53e4a92b1dc6cbc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436099
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Robert Phillips 2021-08-04 09:50:17 -04:00 committed by SkCQ
parent f0ffd41897
commit af844c79d5
44 changed files with 366 additions and 269 deletions

View File

@ -10,8 +10,9 @@
#include "include/core/SkRect.h"
#include "include/private/SkColorData.h"
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSwizzle.h"
#include "src/gpu/SurfaceFillContext.h"
namespace skiagm {

View File

@ -8,7 +8,7 @@
#include "gm/gm.h"
#include "include/effects/SkRuntimeEffect.h"
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"

View File

@ -21,8 +21,8 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrRRectEffect.h"
#include "src/gpu/effects/GrSkSLFP.h"
#include "src/gpu/effects/GrTextureEffect.h"

View File

@ -13,8 +13,8 @@
#include "include/core/SkTypes.h"
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "tools/Resources.h"

View File

@ -215,8 +215,6 @@ skia_gpu_sources = [
"$_src/gpu/GrSurface.h",
"$_src/gpu/GrSurfaceContext.cpp",
"$_src/gpu/GrSurfaceContext.h",
"$_src/gpu/GrSurfaceFillContext.cpp",
"$_src/gpu/GrSurfaceFillContext.h",
"$_src/gpu/GrSurfaceProxy.cpp",
"$_src/gpu/GrSurfaceProxy.h",
"$_src/gpu/GrSurfaceProxyPriv.h",
@ -474,6 +472,8 @@ skia_gpu_sources = [
"$_src/gpu/BaseDevice.h",
"$_src/gpu/SkGr.cpp",
"$_src/gpu/SkGr.h",
"$_src/gpu/SurfaceFillContext.cpp",
"$_src/gpu/SurfaceFillContext.h",
"$_src/image/SkImage_Gpu.cpp",
"$_src/image/SkImage_Gpu.h",
"$_src/image/SkImage_GpuBase.cpp",
@ -599,6 +599,8 @@ skia_skgpu_v1_sources = [
"$_src/gpu/v1/Device_v1.h",
"$_src/gpu/v1/SurfaceDrawContext.cpp",
"$_src/gpu/v1/SurfaceDrawContext_v1.h",
"$_src/gpu/v1/SurfaceFillContext.cpp",
"$_src/gpu/v1/SurfaceFillContext_v1.h",
]
skia_gpu_sources += skia_skgpu_v1_sources

View File

@ -133,7 +133,7 @@ skgpu::v1::SurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanva
}
#endif // SK_GPU_V1
GrSurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
skgpu::SurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
return gpuDevice->surfaceFillContext();
}
@ -149,7 +149,7 @@ skgpu::v1::SurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanva
}
#endif // SK_GPU_V1
GrSurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
skgpu::SurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas) {
return nullptr;
}

View File

@ -15,8 +15,12 @@ class SkReadBuffer;
class SkWriteBuffer;
#if GR_TEST_UTILS
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
class GrSurfaceFillContext;
namespace skgpu {
class SurfaceFillContext;
#if SK_GPU_V1
namespace v1 { class SurfaceDrawContext; }
#endif // SK_GPU_V1
}
#endif // GR_TEST_UTILS
// This declaration must match the one in SkDeferredDisplayList.h
@ -63,7 +67,7 @@ public:
#if SK_GPU_V1
static skgpu::v1::SurfaceDrawContext* TopDeviceSurfaceDrawContext(SkCanvas*);
#endif
static GrSurfaceFillContext* TopDeviceSurfaceFillContext(SkCanvas*);
static skgpu::SurfaceFillContext* TopDeviceSurfaceFillContext(SkCanvas*);
#endif // GR_TEST_UTILS
static GrRenderTargetProxy* TopDeviceTargetProxy(SkCanvas*);

View File

@ -65,7 +65,7 @@ static void fill_in_2D_gaussian_kernel(float* kernel, int width, int height,
* Draws 'dstRect' into 'surfaceFillContext' evaluating a 1D Gaussian over 'srcView'. The src rect
* is 'dstRect' offset by 'dstToSrcOffset'. 'mode' and 'bounds' are applied to the src coords.
*/
static void convolve_gaussian_1d(GrSurfaceFillContext* sfc,
static void convolve_gaussian_1d(skgpu::SurfaceFillContext* sfc,
GrSurfaceProxyView srcView,
const SkIRect srcSubset,
SkIVector dstToSrcOffset,
@ -112,7 +112,7 @@ static std::unique_ptr<skgpu::v1::SurfaceDrawContext> convolve_gaussian_2d(
SkASSERT(!SkGpuBlurUtils::IsEffectivelyZeroSigma(sigmaX) &&
!SkGpuBlurUtils::IsEffectivelyZeroSigma(sigmaY));
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
// SurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
auto sdc = skgpu::v1::SurfaceDrawContext::Make(
rContext, srcColorType, std::move(finalCS), dstFit, dstBounds.size(), SkSurfaceProps(),
1, GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
@ -167,7 +167,7 @@ static std::unique_ptr<skgpu::v1::SurfaceDrawContext> convolve_gaussian(
// at {0, 0} in the new RTC.
//
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
// SurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
auto dstSDC = skgpu::v1::SurfaceDrawContext::Make(
rContext, srcColorType, std::move(finalCS), fit, dstBounds.size(), SkSurfaceProps(), 1,
GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
@ -318,7 +318,7 @@ static std::unique_ptr<skgpu::v1::SurfaceDrawContext> reexpand(
src.reset(); // no longer needed
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
// SurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
auto dstSDC = skgpu::v1::SurfaceDrawContext::Make(
rContext, srcColorType, std::move(colorSpace), fit, dstSize, SkSurfaceProps(), 1,
GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
@ -520,7 +520,7 @@ std::unique_ptr<skgpu::v1::SurfaceDrawContext> GaussianBlur(GrRecordingContext*
// a draw that applies the tile mode.
if (!radiusX && !radiusY) {
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
// SurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
auto result = skgpu::v1::SurfaceDrawContext::Make(rContext,
srcColorType,
std::move(colorSpace),
@ -606,7 +606,7 @@ std::unique_ptr<skgpu::v1::SurfaceDrawContext> GaussianBlur(GrRecordingContext*
int padY = mode == SkTileMode::kClamp ||
(mode == SkTileMode::kDecal && sigmaY > kMaxSigma) ? 1 : 0;
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
// SurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
auto rescaledSDC = skgpu::v1::SurfaceDrawContext::Make(
srcCtx->recordingContext(),
colorInfo.colorType(),

View File

@ -25,9 +25,9 @@
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#endif
#include <atomic>

View File

@ -36,7 +36,8 @@
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrFPArgs.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrMatrixEffect.h"
#include "src/gpu/effects/GrSkSLFP.h"
#include "src/image/SkImage_Gpu.h"

View File

@ -20,9 +20,9 @@
#include "src/core/SkRuntimeEffectPriv.h"
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrSkSLFP.h"
#include "src/gpu/effects/GrTextureEffect.h"
#endif

View File

@ -22,9 +22,9 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#endif

View File

@ -19,10 +19,10 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"

View File

@ -22,10 +22,10 @@
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrPaint.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
@ -438,7 +438,7 @@ protected:
private:
#if SK_SUPPORT_GPU
void drawRect(GrSurfaceFillContext*,
void drawRect(skgpu::SurfaceFillContext*,
GrSurfaceProxyView srcView,
const SkMatrix& matrix,
const SkIRect& dstRect,
@ -454,7 +454,7 @@ private:
};
#if SK_SUPPORT_GPU
void SkLightingImageFilterInternal::drawRect(GrSurfaceFillContext* sfc,
void SkLightingImageFilterInternal::drawRect(skgpu::SurfaceFillContext* sfc,
GrSurfaceProxyView srcView,
const SkMatrix& matrix,
const SkIRect& dstRect,

View File

@ -19,10 +19,10 @@
#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
@ -357,7 +357,7 @@ std::unique_ptr<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorT
}
#endif
static void apply_morphology_rect(GrSurfaceFillContext* sfc,
static void apply_morphology_rect(skgpu::SurfaceFillContext* sfc,
GrSurfaceProxyView view,
SkAlphaType srcAlphaType,
const SkIRect& srcRect,
@ -376,7 +376,7 @@ static void apply_morphology_rect(GrSurfaceFillContext* sfc,
sfc->fillRectToRectWithFP(srcRect, dstRect, std::move(fp));
}
static void apply_morphology_rect_no_bounds(GrSurfaceFillContext* sfc,
static void apply_morphology_rect_no_bounds(skgpu::SurfaceFillContext* sfc,
GrSurfaceProxyView view,
SkAlphaType srcAlphaType,
const SkIRect& srcRect,
@ -389,7 +389,7 @@ static void apply_morphology_rect_no_bounds(GrSurfaceFillContext* sfc,
sfc->fillRectToRectWithFP(srcRect, dstRect, std::move(fp));
}
static void apply_morphology_pass(GrSurfaceFillContext* sfc,
static void apply_morphology_pass(skgpu::SurfaceFillContext* sfc,
GrSurfaceProxyView view,
SkAlphaType srcAlphaType,
const SkIRect& srcRect,

View File

@ -12,8 +12,12 @@
#include "include/private/GrTypesPriv.h"
class GrRenderTargetProxy;
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
class GrSurfaceFillContext;
namespace skgpu {
class SurfaceFillContext;
#if SK_GPU_V1
namespace v1 { class SurfaceDrawContext; }
#endif // SK_GPU_V1
}
class GrSurfaceProxyView;
// NOTE: when not defined, SkGpuDevice extends SkBaseDevice directly and manages its clip stack
@ -53,7 +57,7 @@ public:
virtual skgpu::v1::SurfaceDrawContext* surfaceDrawContext() { return nullptr; }
#endif
virtual GrSurfaceFillContext* surfaceFillContext() = 0;
virtual skgpu::SurfaceFillContext* surfaceFillContext() = 0;
GrRenderTargetProxy* targetProxy();
GrRecordingContext* recordingContext() const { return fContext.get(); }

View File

@ -16,10 +16,10 @@
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrThreadSafePipelineBuilder.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrSkSLFP.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/text/GrAtlasManager.h"

View File

@ -18,7 +18,7 @@
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#endif
#if SK_GPU_V2
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/v2/Device_v2.h"
#endif
@ -133,10 +133,10 @@ std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeSC(GrSurfaceProxyV
info.refColorSpace(),
SkSurfaceProps());
} else {
sc = std::make_unique<GrSurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
info);
sc = std::make_unique<skgpu::v1::SurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
info);
}
} else {
sc = std::make_unique<GrSurfaceContext>(this->context(), std::move(readView), info);
@ -149,13 +149,13 @@ std::unique_ptr<GrSurfaceContext> GrRecordingContextPriv::makeSC(GrSurfaceProxyV
return nullptr;
}
std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFC(GrImageInfo info,
SkBackingFit fit,
int sampleCount,
GrMipmapped mipmapped,
GrProtected isProtected,
GrSurfaceOrigin origin,
SkBudgeted budgeted) {
std::unique_ptr<skgpu::SurfaceFillContext> GrRecordingContextPriv::makeSFC(GrImageInfo info,
SkBackingFit fit,
int sampleCount,
GrMipmapped mipmapped,
GrProtected isProtected,
GrSurfaceOrigin origin,
SkBudgeted budgeted) {
#if GR_TEST_UTILS
if (this->options().fUseSkGpuV2 == GrContextOptions::Enable::kYes) {
@ -197,30 +197,32 @@ std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFC(GrImageInf
GrSurfaceProxyView readView( proxy, origin, readSwizzle);
GrSurfaceProxyView writeView(std::move(proxy), origin, writeSwizzle);
auto fillContext = std::make_unique<GrSurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
info.colorInfo());
fillContext->discard();
return fillContext;
std::unique_ptr<skgpu::SurfaceFillContext> sfc;
sfc = std::make_unique<skgpu::v1::SurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
info.colorInfo());
sfc->discard();
return sfc;
#endif
}
return nullptr;
}
std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFC(SkAlphaType alphaType,
sk_sp<SkColorSpace> cs,
SkISize dimensions,
SkBackingFit fit,
const GrBackendFormat& format,
int sampleCount,
GrMipmapped mipmapped,
GrProtected isProtected,
GrSwizzle readSwizzle,
GrSwizzle writeSwizzle,
GrSurfaceOrigin origin,
SkBudgeted budgeted) {
std::unique_ptr<skgpu::SurfaceFillContext> GrRecordingContextPriv::makeSFC(
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
SkISize dimensions,
SkBackingFit fit,
const GrBackendFormat& format,
int sampleCount,
GrMipmapped mipmapped,
GrProtected isProtected,
GrSwizzle readSwizzle,
GrSwizzle writeSwizzle,
GrSurfaceOrigin origin,
SkBudgeted budgeted) {
#if GR_TEST_UTILS
if (this->context()->options().fUseSkGpuV2 == GrContextOptions::Enable::kYes) {
@ -236,7 +238,7 @@ std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFC(SkAlphaTyp
SkASSERT(format.isValid() && format.backend() == fContext->backend());
if (alphaType == kPremul_SkAlphaType || alphaType == kOpaque_SkAlphaType) {
return skgpu::v1::SurfaceDrawContext::Make(this->context(),
std::move(cs),
std::move(colorSpace),
fit,
dimensions,
format,
@ -261,22 +263,23 @@ std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFC(SkAlphaTyp
if (!proxy) {
return nullptr;
}
GrImageInfo info(GrColorType::kUnknown, alphaType, std::move(cs), dimensions);
GrImageInfo info(GrColorType::kUnknown, alphaType, std::move(colorSpace), dimensions);
GrSurfaceProxyView readView( proxy, origin, readSwizzle);
GrSurfaceProxyView writeView(std::move(proxy), origin, writeSwizzle);
auto fillContext = std::make_unique<GrSurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
info.colorInfo());
fillContext->discard();
return fillContext;
std::unique_ptr<skgpu::SurfaceFillContext> sfc;
sfc = std::make_unique<skgpu::v1::SurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
info.colorInfo());
sfc->discard();
return sfc;
#endif
}
return nullptr;
}
std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFCWithFallback(
std::unique_ptr<skgpu::SurfaceFillContext> GrRecordingContextPriv::makeSFCWithFallback(
GrImageInfo info,
SkBackingFit fit,
int sampleCount,
@ -327,7 +330,7 @@ std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFCWithFallbac
return nullptr;
}
std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFCFromBackendTexture(
std::unique_ptr<skgpu::SurfaceFillContext> GrRecordingContextPriv::makeSFCFromBackendTexture(
GrColorInfo info,
const GrBackendTexture& tex,
int sampleCount,
@ -375,10 +378,10 @@ std::unique_ptr<GrSurfaceFillContext> GrRecordingContextPriv::makeSFCFromBackend
GrSurfaceProxyView readView( proxy, origin, readSwizzle);
GrSurfaceProxyView writeView(std::move(proxy), origin, writeSwizzle);
return std::make_unique<GrSurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
std::move(info));
return std::make_unique<skgpu::v1::SurfaceFillContext>(this->context(),
std::move(readView),
std::move(writeView),
std::move(info));
#endif
}

View File

@ -17,6 +17,7 @@
class GrImageInfo;
class GrSwizzle;
class SkDeferredDisplayList;
namespace skgpu { class SurfaceFillContext; }
/** Class that exposes methods on GrRecordingContext that are only intended for use internal to
Skia. This class is purely a privileged window into GrRecordingContext. It should never have
@ -133,37 +134,38 @@ public:
* Uses GrImageInfo's color type to pick the default texture format. Will return a
* SurfaceDrawContext if possible.
*/
std::unique_ptr<GrSurfaceFillContext> makeSFC(GrImageInfo,
SkBackingFit = SkBackingFit::kExact,
int sampleCount = 1,
GrMipmapped = GrMipmapped::kNo,
GrProtected = GrProtected::kNo,
GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
SkBudgeted = SkBudgeted::kYes);
std::unique_ptr<skgpu::SurfaceFillContext> makeSFC(
GrImageInfo,
SkBackingFit = SkBackingFit::kExact,
int sampleCount = 1,
GrMipmapped = GrMipmapped::kNo,
GrProtected = GrProtected::kNo,
GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
SkBudgeted = SkBudgeted::kYes);
/**
* Makes a custom configured GrSurfaceFillContext where the caller specifies the specific
* Makes a custom configured SurfaceFillContext where the caller specifies the specific
* texture format and swizzles. The color type will be kUnknown. Returns a SurfaceDrawContext
* if possible.
*/
std::unique_ptr<GrSurfaceFillContext> makeSFC(SkAlphaType,
sk_sp<SkColorSpace>,
SkISize dimensions,
SkBackingFit,
const GrBackendFormat&,
int sampleCount,
GrMipmapped,
GrProtected,
GrSwizzle readSwizzle,
GrSwizzle writeSwizzle,
GrSurfaceOrigin,
SkBudgeted);
std::unique_ptr<skgpu::SurfaceFillContext> makeSFC(SkAlphaType,
sk_sp<SkColorSpace>,
SkISize dimensions,
SkBackingFit,
const GrBackendFormat&,
int sampleCount,
GrMipmapped,
GrProtected,
GrSwizzle readSwizzle,
GrSwizzle writeSwizzle,
GrSurfaceOrigin,
SkBudgeted);
/**
* Like the above but uses GetFallbackColorTypeAndFormat to find a fallback color type (and
* compatible format) if the passed GrImageInfo's color type is not renderable.
*/
std::unique_ptr<GrSurfaceFillContext> makeSFCWithFallback(
std::unique_ptr<skgpu::SurfaceFillContext> makeSFCWithFallback(
GrImageInfo,
SkBackingFit = SkBackingFit::kExact,
int sampleCount = 1,
@ -173,11 +175,11 @@ public:
SkBudgeted = SkBudgeted::kYes);
/**
* Creates a GrSurfaceFillContext from an existing GrBackendTexture. The GrColorInfo's color
* Creates a SurfaceFillContext from an existing GrBackendTexture. The GrColorInfo's color
* type must be compatible with backend texture's format or this will fail. All formats are
* considered compatible with kUnknown. Returns a SurfaceDrawContext if possible.
*/
std::unique_ptr<GrSurfaceFillContext> makeSFCFromBackendTexture(
std::unique_ptr<skgpu::SurfaceFillContext> makeSFCFromBackendTexture(
GrColorInfo,
const GrBackendTexture&,
int sampleCount,

View File

@ -19,9 +19,9 @@
class GrResourceProvider;
// GrArenas matches the lifetime of a single frame. It is created and held on the
// GrSurfaceFillContext's RenderTargetProxy with the first call to get an arena. Each GrOpsTask
// SurfaceFillContext's RenderTargetProxy with the first call to get an arena. Each GrOpsTask
// takes a ref on it to keep the arenas alive. When the first GrOpsTask's onExecute() is
// completed, the arena ref on the GrSurfaceFillContext's RenderTargetProxy is nulled out so that
// completed, the arena ref on the SurfaceFillContext's RenderTargetProxy is nulled out so that
// any new GrOpsTasks will create and ref a new set of arenas.
class GrArenas : public SkNVRefCnt<GrArenas> {
public:

View File

@ -24,8 +24,8 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrBicubicEffect.h"
#include "src/gpu/effects/GrTextureEffect.h"
@ -640,7 +640,7 @@ void GrSurfaceContext::asyncRescaleAndReadPixels(GrDirectContext* dContext,
return;
}
std::unique_ptr<GrSurfaceFillContext> tempFC;
std::unique_ptr<skgpu::SurfaceFillContext> tempFC;
int x = srcRect.fLeft;
int y = srcRect.fTop;
if (needsRescale) {
@ -1106,11 +1106,11 @@ sk_sp<GrRenderTask> GrSurfaceContext::copy(sk_sp<GrSurfaceProxy> src,
this->origin());
}
std::unique_ptr<GrSurfaceFillContext> GrSurfaceContext::rescale(const GrImageInfo& info,
GrSurfaceOrigin origin,
SkIRect srcRect,
RescaleGamma rescaleGamma,
RescaleMode rescaleMode) {
std::unique_ptr<skgpu::SurfaceFillContext> GrSurfaceContext::rescale(const GrImageInfo& info,
GrSurfaceOrigin origin,
SkIRect srcRect,
RescaleGamma rescaleGamma,
RescaleMode rescaleMode) {
auto sfc = fContext->priv().makeSFCWithFallback(info,
SkBackingFit::kExact,
1,
@ -1127,7 +1127,7 @@ std::unique_ptr<GrSurfaceFillContext> GrSurfaceContext::rescale(const GrImageInf
return sfc;
}
bool GrSurfaceContext::rescaleInto(GrSurfaceFillContext* dst,
bool GrSurfaceContext::rescaleInto(skgpu::SurfaceFillContext* dst,
SkIRect dstRect,
SkIRect srcRect,
RescaleGamma rescaleGamma,
@ -1167,8 +1167,8 @@ bool GrSurfaceContext::rescaleInto(GrSurfaceFillContext* dst,
// Within a rescaling pass A is the input (if not null) and B is the output. At the end of the
// pass B is moved to A. If 'this' is the input on the first pass then tempA is null.
std::unique_ptr<GrSurfaceFillContext> tempA;
std::unique_ptr<GrSurfaceFillContext> tempB;
std::unique_ptr<skgpu::SurfaceFillContext> tempA;
std::unique_ptr<skgpu::SurfaceFillContext> tempB;
// Assume we should ignore the rescale linear request if the surface has no color space since
// it's unclear how we'd linearize from an unknown color space.
@ -1220,7 +1220,7 @@ bool GrSurfaceContext::rescaleInto(GrSurfaceFillContext* dst,
}
auto input = tempA ? tempA.get() : this;
sk_sp<GrColorSpaceXform> xform;
GrSurfaceFillContext* stepDst;
skgpu::SurfaceFillContext* stepDst;
SkIRect stepDstRect;
if (nextDims == finalSize) {
stepDst = dst;

View File

@ -26,8 +26,7 @@ class GrRecordingContext;
class GrRenderTargetProxy;
class GrSingleOwner;
class GrSurface;
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
class GrSurfaceFillContext;
namespace skgpu { class SurfaceFillContext; }
class GrSurfaceProxy;
class GrTextureProxy;
struct SkIPoint;
@ -158,7 +157,7 @@ public:
return fReadView.asRenderTargetProxyRef();
}
virtual GrSurfaceFillContext* asFillContext() { return nullptr; }
virtual skgpu::SurfaceFillContext* asFillContext() { return nullptr; }
/**
* Rescales the contents of srcRect. The gamma in which the rescaling occurs is controlled by
@ -167,17 +166,17 @@ public:
* different size than srcRect. Though, it could be relaxed to allow non-scaling color
* conversions.
*/
std::unique_ptr<GrSurfaceFillContext> rescale(const GrImageInfo& info,
GrSurfaceOrigin,
SkIRect srcRect,
SkImage::RescaleGamma,
SkImage::RescaleMode);
std::unique_ptr<skgpu::SurfaceFillContext> rescale(const GrImageInfo& info,
GrSurfaceOrigin,
SkIRect srcRect,
SkImage::RescaleGamma,
SkImage::RescaleMode);
/**
* Like the above but allows the caller ot specify a destination fill context and
* rect within that context. The dst rect must be contained by the dst or this will fail.
*/
bool rescaleInto(GrSurfaceFillContext* dst,
bool rescaleInto(skgpu::SurfaceFillContext* dst,
SkIRect dstRect,
SkIRect srcRect,
SkImage::RescaleGamma,

View File

@ -17,9 +17,9 @@
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurface.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureRenderTargetProxy.h"
#include "src/gpu/SurfaceFillContext.h"
#ifdef SK_DEBUG
#include "include/gpu/GrDirectContext.h"
@ -310,7 +310,7 @@ sk_sp<GrSurfaceProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
GrSurfaceProxyView view(std::move(src), origin, GrSwizzle::RGBA());
if (dstContext && dstContext->blitTexture(std::move(view), srcRect, dstPoint)) {
if (outTask) {
*outTask = sk_ref_sp(dstContext->getOpsTask());
*outTask = dstContext->refRenderTask();
}
return dstContext->asSurfaceProxyRef();
}

View File

@ -0,0 +1,21 @@
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrMatrixEffect.h"
namespace skgpu {
void SurfaceFillContext::fillRectWithFP(const SkIRect& dstRect,
const SkMatrix& localMatrix,
std::unique_ptr<GrFragmentProcessor> fp) {
fp = GrMatrixEffect::Make(localMatrix, std::move(fp));
this->fillRectWithFP(dstRect, std::move(fp));
}
} // namespace skgpu

View File

@ -1,47 +1,27 @@
/*
* Copyright 2020 Google LLC
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrSurfaceFillContext_DEFINED
#define GrSurfaceFillContext_DEFINED
#ifndef SurfaceFillContext_DEFINED
#define SurfaceFillContext_DEFINED
#include "include/core/SkSize.h"
#include "include/private/GrTypesPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrSwizzle.h"
#include "src/gpu/effects/GrMatrixEffect.h"
#include <array>
#include <tuple>
namespace skgpu {
class GrFragmentProcessor;
class GrImageContext;
class GrOp;
class GrBackendFormat;
class GrRecordingContext;
class GrSurfaceProxyView;
class SkColorSpace;
class GrSurfaceFillContext : public GrSurfaceContext {
class SurfaceFillContext : public GrSurfaceContext {
public:
GrSurfaceFillContext(GrRecordingContext*,
GrSurfaceProxyView readView,
GrSurfaceProxyView writeView,
const GrColorInfo&,
bool flushTimeOpsTask = false);
GrSurfaceFillContext* asFillContext() override { return this; }
SurfaceFillContext* asFillContext() override { return this; }
/**
* Provides a performance hint that the render target's contents are allowed
* to become undefined.
*/
void discard();
virtual void discard() = 0;
/**
* Clear the rect of the render target to the given color.
@ -70,7 +50,7 @@ public:
}
/** Fills 'dstRect' with 'fp' */
void fillRectWithFP(const SkIRect& dstRect, std::unique_ptr<GrFragmentProcessor> fp);
virtual void fillRectWithFP(const SkIRect& dstRect, std::unique_ptr<GrFragmentProcessor>) = 0;
/**
* A convenience version of fillRectWithFP that applies a coordinate transformation via
@ -78,10 +58,7 @@ public:
*/
void fillRectWithFP(const SkIRect& dstRect,
const SkMatrix& localMatrix,
std::unique_ptr<GrFragmentProcessor> fp) {
fp = GrMatrixEffect::Make(localMatrix, std::move(fp));
this->fillRectWithFP(dstRect, std::move(fp));
}
std::unique_ptr<GrFragmentProcessor>);
/** Fills 'dstRect' with 'fp' using a local matrix that maps 'srcRect' to 'dstRect' */
void fillRectToRectWithFP(const SkRect& srcRect,
@ -108,8 +85,9 @@ public:
* GrMatrixEffect and fills the entire render target.
*/
void fillWithFP(const SkMatrix& localMatrix, std::unique_ptr<GrFragmentProcessor> fp) {
this->fillRectWithFP(
SkIRect::MakeSize(fWriteView.proxy()->dimensions()), localMatrix, std::move(fp));
this->fillRectWithFP(SkIRect::MakeSize(fWriteView.proxy()->dimensions()),
localMatrix,
std::move(fp));
}
/**
@ -117,34 +95,22 @@ public:
* of the srcRect. The srcRect and dstRect are clipped to the bounds of the src and dst surfaces
* respectively.
*/
bool blitTexture(GrSurfaceProxyView view, const SkIRect& srcRect, const SkIPoint& dstPoint);
virtual bool blitTexture(GrSurfaceProxyView,
const SkIRect& srcRect,
const SkIPoint& dstPoint) = 0;
GrOpsTask* getOpsTask();
int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
SkArenaAlloc* arenaAlloc() { return this->arenas()->arenaAlloc(); }
GrSubRunAllocator* subRunAlloc() { return this->arenas()->subRunAlloc(); }
#if GR_TEST_UTILS
GrOpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); }
#endif
const GrSurfaceProxyView& writeSurfaceView() const { return fWriteView; }
virtual sk_sp<GrRenderTask> refRenderTask() = 0;
protected:
/**
* Creates a constant color paint for a clear, using src-over if possible to improve batching.
*/
static void ClearToGrPaint(std::array<float, 4> color, GrPaint* paint);
void addOp(GrOp::Owner);
GrOpsTask* replaceOpsTask();
private:
sk_sp<GrArenas> arenas() { return fWriteView.proxy()->asRenderTargetProxy()->arenas(); }
SurfaceFillContext(GrRecordingContext* rContext,
GrSurfaceProxyView readView,
GrSurfaceProxyView writeView,
const GrColorInfo& colorInfo)
: GrSurfaceContext(rContext, std::move(readView), colorInfo)
, fWriteView(std::move(writeView)) {
SkASSERT(this->asSurfaceProxy() == fWriteView.proxy());
SkASSERT(this->origin() == fWriteView.origin());
}
template <SkAlphaType AlphaType>
static std::array<float, 4> ConvertColor(SkRGBA4f<AlphaType> color);
@ -152,50 +118,30 @@ private:
template <SkAlphaType AlphaType>
std::array<float, 4> adjustColorAlphaType(SkRGBA4f<AlphaType> color) const;
/** Override to be notified in subclass before the current ops task is replaced. */
virtual void willReplaceOpsTask(GrOpsTask* prevTask, GrOpsTask* nextTask) {}
/**
* Override to be called to participate in the decision to discard all previous ops if a
* fullscreen clear occurs.
*/
virtual GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const {
return GrOpsTask::CanDiscardPreviousOps::kYes;
}
void internalClear(const SkIRect* scissor,
std::array<float, 4> color,
bool upgradePartialToFull = false);
void addDrawOp(GrOp::Owner);
SkDEBUGCODE(void onValidate() const override;)
GrSurfaceProxyView fWriteView;
// The GrOpsTask can be closed by some other surface context that has picked it up. For this
// reason, the GrOpsTask should only ever be accessed via 'getOpsTask'.
sk_sp<GrOpsTask> fOpsTask;
bool fFlushTimeOpsTask;
private:
virtual void internalClear(const SkIRect* scissor,
std::array<float, 4> color,
bool upgradePartialToFull = false) = 0;
using INHERITED = GrSurfaceContext;
};
template<>
inline std::array<float, 4> GrSurfaceFillContext::ConvertColor<kPremul_SkAlphaType>(
inline std::array<float, 4> SurfaceFillContext::ConvertColor<kPremul_SkAlphaType>(
SkPMColor4f color) {
return color.unpremul().array();
}
template<>
inline std::array<float, 4> GrSurfaceFillContext::ConvertColor<kUnpremul_SkAlphaType>(
inline std::array<float, 4> SurfaceFillContext::ConvertColor<kUnpremul_SkAlphaType>(
SkColor4f color) {
return color.premul().array();
}
template <SkAlphaType AlphaType>
std::array<float, 4> GrSurfaceFillContext::adjustColorAlphaType(SkRGBA4f<AlphaType> color) const {
std::array<float, 4> SurfaceFillContext::adjustColorAlphaType(SkRGBA4f<AlphaType> color) const {
if (AlphaType == kUnknown_SkAlphaType ||
this->colorInfo().alphaType() == kUnknown_SkAlphaType) {
return color.array();
@ -203,4 +149,6 @@ std::array<float, 4> GrSurfaceFillContext::adjustColorAlphaType(SkRGBA4f<AlphaTy
return (AlphaType == this->colorInfo().alphaType()) ? color.array() : ConvertColor(color);
}
#endif
} // namespace skgpu
#endif // SurfaceFillContext_DEFINED

View File

@ -291,7 +291,7 @@ const SurfaceDrawContext* Device::surfaceDrawContext() const {
return fSurfaceDrawContext.get();
}
GrSurfaceFillContext* Device::surfaceFillContext() {
skgpu::SurfaceFillContext* Device::surfaceFillContext() {
ASSERT_SINGLE_OWNER
return fSurfaceDrawContext.get();
}

View File

@ -106,7 +106,7 @@ public:
SurfaceDrawContext* surfaceDrawContext() override;
const SurfaceDrawContext* surfaceDrawContext() const;
GrSurfaceFillContext* surfaceFillContext() override;
skgpu::SurfaceFillContext* surfaceFillContext() override;
// set all pixels to 0
void clearAll();

View File

@ -294,11 +294,11 @@ SurfaceDrawContext::SurfaceDrawContext(GrRecordingContext* rContext,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps& surfaceProps,
bool flushTimeOpsTask)
: GrSurfaceFillContext(rContext,
std::move(readView),
std::move(writeView),
{colorType, kPremul_SkAlphaType, std::move(colorSpace)},
flushTimeOpsTask)
: SurfaceFillContext(rContext,
std::move(readView),
std::move(writeView),
{colorType, kPremul_SkAlphaType, std::move(colorSpace)},
flushTimeOpsTask)
, fSurfaceProps(surfaceProps)
, fCanUseDynamicMSAA(
(fSurfaceProps.flags() & SkSurfaceProps::kDynamicMSAA_Flag) &&

View File

@ -18,10 +18,10 @@
#include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrPaint.h"
#include "src/gpu/GrRenderTargetProxy.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrSurfaceProxyView.h"
#include "src/gpu/GrXferProcessor.h"
#include "src/gpu/geometry/GrQuad.h"
#include "src/gpu/v1/SurfaceFillContext_v1.h"
class GrBackendSemaphore;
class GrClip;
@ -60,7 +60,7 @@ namespace skgpu::v1 {
/**
* A helper object to orchestrate commands (draws, etc...) for GrSurfaces that are GrRenderTargets.
*/
class SurfaceDrawContext : public GrSurfaceFillContext {
class SurfaceDrawContext : public SurfaceFillContext {
public:
static std::unique_ptr<SurfaceDrawContext> Make(GrRecordingContext*,
GrColorType,
@ -707,7 +707,7 @@ private:
bool fPreserveOpsOnFullClear_TestingOnly = false;
#endif
SkGlyphRunListPainter fGlyphPainter;
using INHERITED = GrSurfaceFillContext;
using INHERITED = SurfaceFillContext;
};
} // namespace skgpu::v1

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/v1/SurfaceFillContext_v1.h"
#include "include/private/GrImageContext.h"
#include "src/gpu/GrDstProxyView.h"
@ -15,6 +15,7 @@
#include "src/gpu/geometry/GrRect.h"
#include "src/gpu/ops/GrClearOp.h"
#include "src/gpu/ops/GrFillRectOp.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(this->singleOwner())
#define RETURN_IF_ABANDONED if (fContext->abandoned()) { return; }
@ -30,31 +31,33 @@ private:
GrDrawingManager* fDrawingManager;
};
namespace skgpu::v1 {
// In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress
// GrOpsTask to be picked up and added to by GrSurfaceFillContext lower in the call
// GrOpsTask to be picked up and added to by SurfaceFillContext lower in the call
// stack. When this occurs with a closed GrOpsTask, a new one will be allocated
// when the GrSurfaceFillContext attempts to use it (via getOpsTask).
GrSurfaceFillContext::GrSurfaceFillContext(GrRecordingContext* context,
GrSurfaceProxyView readView,
GrSurfaceProxyView writeView,
const GrColorInfo& colorInfo,
bool flushTimeOpsTask)
: GrSurfaceContext(context, std::move(readView), std::move(colorInfo))
, fWriteView(std::move(writeView))
// when the SurfaceFillContext attempts to use it (via getOpsTask).
SurfaceFillContext::SurfaceFillContext(GrRecordingContext* rContext,
GrSurfaceProxyView readView,
GrSurfaceProxyView writeView,
const GrColorInfo& colorInfo,
bool flushTimeOpsTask)
: skgpu::SurfaceFillContext(rContext,
std::move(readView),
std::move(writeView),
std::move(colorInfo))
, fFlushTimeOpsTask(flushTimeOpsTask) {
fOpsTask = sk_ref_sp(context->priv().drawingManager()->getLastOpsTask(this->asSurfaceProxy()));
SkASSERT(this->asSurfaceProxy() == fWriteView.proxy());
SkASSERT(this->origin() == fWriteView.origin());
fOpsTask = sk_ref_sp(rContext->priv().drawingManager()->getLastOpsTask(this->asSurfaceProxy()));
SkDEBUGCODE(this->validate();)
}
void GrSurfaceFillContext::fillRectWithFP(const SkIRect& dstRect,
std::unique_ptr<GrFragmentProcessor> fp) {
void SurfaceFillContext::fillRectWithFP(const SkIRect& dstRect,
std::unique_ptr<GrFragmentProcessor> fp) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceFillContext", "fillRectWithFP", fContext);
GR_CREATE_TRACE_MARKER_CONTEXT("v1::SurfaceFillContext", "fillRectWithFP", fContext);
AutoCheckFlush acf(this->drawingManager());
@ -66,7 +69,7 @@ void GrSurfaceFillContext::fillRectWithFP(const SkIRect& dstRect,
this->addDrawOp(std::move(op));
}
void GrSurfaceFillContext::addDrawOp(GrOp::Owner owner) {
void SurfaceFillContext::addDrawOp(GrOp::Owner owner) {
GrDrawOp* op = static_cast<GrDrawOp*>(owner.get());
GrClampType clampType = GrColorTypeClampType(this->colorInfo().colorType());
auto clip = GrAppliedClip::Disabled();
@ -94,7 +97,7 @@ void GrSurfaceFillContext::addDrawOp(GrOp::Owner owner) {
caps);
}
void GrSurfaceFillContext::ClearToGrPaint(std::array<float, 4> color, GrPaint* paint) {
void SurfaceFillContext::ClearToGrPaint(std::array<float, 4> color, GrPaint* paint) {
paint->setColor4f({color[0], color[1], color[2], color[3]});
if (color[3] == 1.f) {
// Can just rely on the src-over blend mode to do the right thing.
@ -107,7 +110,7 @@ void GrSurfaceFillContext::ClearToGrPaint(std::array<float, 4> color, GrPaint* p
}
}
void GrSurfaceFillContext::addOp(GrOp::Owner op) {
void SurfaceFillContext::addOp(GrOp::Owner op) {
GrDrawingManager* drawingMgr = this->drawingManager();
this->getOpsTask()->addOp(drawingMgr,
std::move(op),
@ -115,7 +118,7 @@ void GrSurfaceFillContext::addOp(GrOp::Owner op) {
*this->caps());
}
GrOpsTask* GrSurfaceFillContext::getOpsTask() {
GrOpsTask* SurfaceFillContext::getOpsTask() {
ASSERT_SINGLE_OWNER
SkDEBUGCODE(this->validate();)
@ -126,7 +129,11 @@ GrOpsTask* GrSurfaceFillContext::getOpsTask() {
return fOpsTask.get();
}
GrOpsTask* GrSurfaceFillContext::replaceOpsTask() {
sk_sp<GrRenderTask> SurfaceFillContext::refRenderTask() {
return sk_ref_sp(this->getOpsTask());
}
GrOpsTask* SurfaceFillContext::replaceOpsTask() {
sk_sp<GrOpsTask> newOpsTask = this->drawingManager()->newOpsTask(
this->writeSurfaceView(), this->arenas(), fFlushTimeOpsTask);
this->willReplaceOpsTask(fOpsTask.get(), newOpsTask.get());
@ -135,31 +142,31 @@ GrOpsTask* GrSurfaceFillContext::replaceOpsTask() {
}
#ifdef SK_DEBUG
void GrSurfaceFillContext::onValidate() const {
void SurfaceFillContext::onValidate() const {
if (fOpsTask && !fOpsTask->isClosed()) {
SkASSERT(this->drawingManager()->getLastRenderTask(fWriteView.proxy()) == fOpsTask.get());
}
}
#endif
void GrSurfaceFillContext::discard() {
void SurfaceFillContext::discard() {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceFillContext", "discard", fContext);
GR_CREATE_TRACE_MARKER_CONTEXT("v1::SurfaceFillContext", "discard", fContext);
AutoCheckFlush acf(this->drawingManager());
this->getOpsTask()->discard();
}
void GrSurfaceFillContext::internalClear(const SkIRect* scissor,
std::array<float, 4> color,
bool upgradePartialToFull) {
void SurfaceFillContext::internalClear(const SkIRect* scissor,
std::array<float, 4> color,
bool upgradePartialToFull) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceFillContext", "clear", fContext);
GR_CREATE_TRACE_MARKER_CONTEXT("v1::SurfaceFillContext", "clear", fContext);
// There are three ways clears are handled: load ops, native clears, and draws. Load ops are
// only for fullscreen clears; native clears can be fullscreen or with scissors if the backend
@ -220,9 +227,9 @@ void GrSurfaceFillContext::internalClear(const SkIRect* scissor,
}
}
bool GrSurfaceFillContext::blitTexture(GrSurfaceProxyView view,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
bool SurfaceFillContext::blitTexture(GrSurfaceProxyView view,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
SkASSERT(view.asTextureProxy());
SkIRect clippedSrcRect;
SkIPoint clippedDstPoint;
@ -241,3 +248,5 @@ bool GrSurfaceFillContext::blitTexture(GrSurfaceProxyView view,
this->fillRectToRectWithFP(srcRectF, dstRect, std::move(fp));
return true;
}
} // namespace skgpu::v1

View File

@ -0,0 +1,106 @@
/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SurfaceFillContext_v1_DEFINED
#define SurfaceFillContext_v1_DEFINED
#include "include/core/SkSize.h"
#include "include/private/GrTypesPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrSwizzle.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrMatrixEffect.h"
#include <array>
#include <tuple>
class GrFragmentProcessor;
class GrImageContext;
class GrOp;
class GrBackendFormat;
class GrRecordingContext;
class GrSurfaceProxyView;
class SkColorSpace;
namespace skgpu::v1 {
class SurfaceFillContext : public skgpu::SurfaceFillContext {
public:
SurfaceFillContext(GrRecordingContext*,
GrSurfaceProxyView readView,
GrSurfaceProxyView writeView,
const GrColorInfo&,
bool flushTimeOpsTask = false);
void discard() override;
void fillRectWithFP(const SkIRect& dstRect, std::unique_ptr<GrFragmentProcessor> fp) override;
bool blitTexture(GrSurfaceProxyView view,
const SkIRect& srcRect,
const SkIPoint& dstPoint) override;
GrOpsTask* getOpsTask();
sk_sp<GrRenderTask> refRenderTask() override;
int numSamples() const { return this->asRenderTargetProxy()->numSamples(); }
bool wrapsVkSecondaryCB() const { return this->asRenderTargetProxy()->wrapsVkSecondaryCB(); }
SkArenaAlloc* arenaAlloc() { return this->arenas()->arenaAlloc(); }
GrSubRunAllocator* subRunAlloc() { return this->arenas()->subRunAlloc(); }
#if GR_TEST_UTILS
GrOpsTask* testingOnly_PeekLastOpsTask() { return fOpsTask.get(); }
#endif
const GrSurfaceProxyView& writeSurfaceView() const { return fWriteView; }
protected:
/**
* Creates a constant color paint for a clear, using src-over if possible to improve batching.
*/
static void ClearToGrPaint(std::array<float, 4> color, GrPaint* paint);
void addOp(GrOp::Owner);
GrOpsTask* replaceOpsTask();
private:
sk_sp<GrArenas> arenas() { return fWriteView.proxy()->asRenderTargetProxy()->arenas(); }
/** Override to be notified in subclass before the current ops task is replaced. */
virtual void willReplaceOpsTask(GrOpsTask* prevTask, GrOpsTask* nextTask) {}
/**
* Override to be called to participate in the decision to discard all previous ops if a
* fullscreen clear occurs.
*/
virtual GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const {
return GrOpsTask::CanDiscardPreviousOps::kYes;
}
void internalClear(const SkIRect* scissor,
std::array<float, 4> color,
bool upgradePartialToFull = false) override;
void addDrawOp(GrOp::Owner);
SkDEBUGCODE(void onValidate() const override;)
// The GrOpsTask can be closed by some other surface context that has picked it up. For this
// reason, the GrOpsTask should only ever be accessed via 'getOpsTask'.
sk_sp<GrOpsTask> fOpsTask;
bool fFlushTimeOpsTask;
using INHERITED = skgpu::SurfaceFillContext;
};
} // namespace skgpu::v1
#endif // SurfaceFillContext_v1_DEFINED

View File

@ -26,7 +26,7 @@ Device::~Device() {}
GrSurfaceProxyView Device::readSurfaceView() { return {}; }
GrSurfaceFillContext* Device::surfaceFillContext() {
skgpu::SurfaceFillContext* Device::surfaceFillContext() {
return nullptr;
}

View File

@ -44,7 +44,7 @@ public:
GrSurfaceProxyView readSurfaceView() override;
GrSurfaceFillContext* surfaceFillContext() override;
skgpu::SurfaceFillContext* surfaceFillContext() override;
bool wait(int numSemaphores,
const GrBackendSemaphore* waitSemaphores,

View File

@ -33,11 +33,11 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSemaphore.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/GrTextureProxyPriv.h"
#include "src/gpu/GrYUVATextureProxies.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/gl/GrGLTexture.h"

View File

@ -17,7 +17,6 @@
class GrColorSpaceXform;
class GrDirectContext;
class GrImageContext;
class GrSurfaceFillContext;
class SkColorSpace;
class SkImage_GpuBase : public SkImage_Base {

View File

@ -22,8 +22,8 @@
#include "src/gpu/GrImageContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrBicubicEffect.h"
#include "src/gpu/effects/GrYUVtoRGBEffect.h"
#include "src/image/SkImage_Gpu.h"

View File

@ -28,9 +28,9 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSamplerState.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrYUVATextureProxies.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrYUVtoRGBEffect.h"
#endif

View File

@ -12,7 +12,7 @@
#include "src/core/SkAutoPixmapStorage.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/image/SkImage_Base.h"
@ -297,7 +297,7 @@ static void check_base_readbacks(GrDirectContext* dContext,
#endif
} else {
auto name = SkStringPrintf("%s::readPixels",
(renderableCtx == GrRenderable::kYes ? "GrSurfaceFillContext"
(renderableCtx == GrRenderable::kYes ? "SurfaceFillContext"
: "GrSurfaceContext"));
check_solid_pixmap(reporter, expectedColor, actual, colorType, label, name.c_str());
}

View File

@ -18,10 +18,10 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
#include "tools/gpu/ProxyUtils.h"

View File

@ -9,9 +9,9 @@
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrShaderCaps.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxyPriv.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/gl/GrGLUtil.h"
#include "tests/Test.h"

View File

@ -15,7 +15,7 @@
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"

View File

@ -11,9 +11,9 @@
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
#ifdef SK_GL
#include "src/gpu/gl/GrGLGpu.h"
@ -40,7 +40,7 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrDirectContext
static void test_clear(skiatest::Reporter* reporter, GrDirectContext* dContext,
GrSurfaceContext* rectContext) {
if (GrSurfaceFillContext* sfc = rectContext->asFillContext()) {
if (auto sfc = rectContext->asFillContext()) {
// Clear the whole thing.
GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD);
sfc->clear(SkPMColor4f::FromBytes_RGBA(color0));

View File

@ -25,7 +25,7 @@
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/SurfaceFillContext.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkImage_Gpu.h"
#include "src/image/SkSurface_Gpu.h"

View File

@ -13,8 +13,8 @@
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/SurfaceFillContext.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/gpu/BackendSurfaceFactory.h"
@ -22,8 +22,6 @@
#if SK_GPU_V1
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#else
#include "src/gpu/GrSurfaceFillContext.h"
#endif
DEF_GPUTEST_FOR_ALL_CONTEXTS(WrappedSurfaceCopyOnWrite, reporter, ctxInfo) {