Rename GrSurfaceDrawContext to skgpu::v1::SurfaceDrawContext
This CL is mostly mechanical. It: replaces "src/gpu/GrSurfaceDrawContext.h" #includes with "src/gpu/v1/SurfaceDrawContext_v1.h" and reorders replaces "class GrSurfaceDrawContext;" with "namespace skgpu { namespace v1 { class SurfaceDrawContext; }}" replaces "GrSurfaceDrawContext*" with "auto" where possible replaces "rtc" with "sdc" replaces "surfaceDrawContext" with "sdc" replaces GrSurfaceDrawContext with skgpu::v1::SurfaceDrawContext reflows parameters as needed This CL does not try to: make skgpu::v1::SurfaceDrawContext V1-only minimize the skgpu and/or skgpu::v1 prefixes Those two tasks will be accomplished in follow up CLs. This CL is just trying to get the bulk of the mechanical changes comprehensibly landed. Bug: skia:11837 Change-Id: I6fe59080249d585df8f5d27c6b67569cdc35842f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433156 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
f1f542cde8
commit
4dca83162b
@ -14,8 +14,8 @@
|
||||
#include "include/utils/SkRandom.h"
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/gpu/GrOpsTypes.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
// Benchmarks that exercise the bulk image and solid color quad APIs, under a variety of patterns:
|
||||
enum class ImageMode {
|
||||
@ -51,7 +51,7 @@ public:
|
||||
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
if (kDrawMode == DrawMode::kBatch && kImageMode == ImageMode::kNone) {
|
||||
// Currently the bulk color quad API is only available on GrSurfaceDrawContext
|
||||
// Currently the bulk color quad API is only available on skgpu::v1::SurfaceDrawContext
|
||||
return backend == kGPU_Backend;
|
||||
} else {
|
||||
return this->INHERITED::isSuitableFor(backend);
|
||||
@ -146,7 +146,7 @@ protected:
|
||||
paint.setColor(SK_ColorWHITE);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
GrSurfaceDrawContext* sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
SkMatrix view = canvas->getLocalToDeviceAs3x3();
|
||||
SkSimpleMatrixProvider matrixProvider(view);
|
||||
GrPaint grPaint;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
static sk_sp<SkShader> make_shader() {
|
||||
static const SkPoint kPts[] = {{0, 0}, {10, 10}};
|
||||
@ -62,9 +62,10 @@ protected:
|
||||
SkPaint interruptPaint;
|
||||
interruptPaint.setShader(make_shader());
|
||||
|
||||
GrSurfaceDrawContext* sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
if (sdc) {
|
||||
// Tell the GrSurfaceDrawContext to not reset its draw op list on a fullscreen clear.
|
||||
// Tell the skgpu::v1::SurfaceDrawContext to not reset its draw op list on a
|
||||
// fullscreen clear.
|
||||
// If we don't do this, fullscreen clear ops would be created and constantly discard the
|
||||
// previous iteration's op so execution would only invoke one actual clear on the GPU
|
||||
// (not what we want to measure).
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrMemoryPool.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
@ -24,6 +23,7 @@
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -309,10 +309,10 @@ public:
|
||||
const int kDrawsPerLoop = 32;
|
||||
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
auto rtc = GrSurfaceDrawContext::Make(context, GrColorType::kRGBA_8888, p3,
|
||||
SkBackingFit::kApprox, {100, 100},
|
||||
SkSurfaceProps());
|
||||
SkASSERT(rtc);
|
||||
auto sdc = skgpu::v1::SurfaceDrawContext::Make(context, GrColorType::kRGBA_8888, p3,
|
||||
SkBackingFit::kApprox, {100, 100},
|
||||
SkSurfaceProps());
|
||||
SkASSERT(sdc);
|
||||
|
||||
for (int j = 0; j < kDrawsPerLoop; ++j) {
|
||||
SkColor c = r.nextU();
|
||||
@ -332,7 +332,7 @@ public:
|
||||
op = GrOp::Make<Op>(rContext, c4f, fMode);
|
||||
}
|
||||
}
|
||||
rtc->addDrawOp(std::move(op));
|
||||
sdc->addDrawOp(std::move(op));
|
||||
}
|
||||
|
||||
context->flushAndSubmit();
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "src/core/SkTLList.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/gpu/TestOps.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "src/gpu/GrProcessorSet.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrUserStencilSettings.h"
|
||||
#include "src/gpu/effects/GrBezierEffect.h"
|
||||
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
|
||||
@ -47,6 +46,7 @@
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
|
||||
#include "src/gpu/effects/GrRRectEffect.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/ops/GrFillRectOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
// This test exercises Ganesh's drawing of tiled bitmaps. In particular, that the offsets and the
|
||||
// extents of the tiles don't causes gaps between tiles.
|
||||
static void draw_tile_bitmap_with_fractional_offset(GrRecordingContext* rContext,
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrShaderVar.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
@ -47,6 +46,7 @@
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/ops/GrOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/gpu/ProxyUtils.h"
|
||||
|
||||
#include <memory>
|
||||
@ -262,16 +262,16 @@ DrawResult ClockwiseGM::onDraw(GrRecordingContext* rContext, SkCanvas* canvas, S
|
||||
sdc->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
||||
|
||||
// Draw the test to an off-screen, top-down render target.
|
||||
GrColorType rtcColorType = sdc->colorInfo().colorType();
|
||||
if (auto topLeftRTC = GrSurfaceDrawContext::Make(
|
||||
rContext, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
|
||||
GrColorType sdcColorType = sdc->colorInfo().colorType();
|
||||
if (auto topLeftSDC = skgpu::v1::SurfaceDrawContext::Make(
|
||||
rContext, sdcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
|
||||
1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin,
|
||||
SkBudgeted::kYes)) {
|
||||
topLeftRTC->clear(SK_PMColor4fTRANSPARENT);
|
||||
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
||||
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
||||
topLeftSDC->clear(SK_PMColor4fTRANSPARENT);
|
||||
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
||||
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
||||
sdc->drawTexture(nullptr,
|
||||
topLeftRTC->readSurfaceView(),
|
||||
topLeftSDC->readSurfaceView(),
|
||||
sdc->colorInfo().alphaType(),
|
||||
GrSamplerState::Filter::kNearest,
|
||||
GrSamplerState::MipmapMode::kNone,
|
||||
@ -287,15 +287,15 @@ DrawResult ClockwiseGM::onDraw(GrRecordingContext* rContext, SkCanvas* canvas, S
|
||||
}
|
||||
|
||||
// Draw the test to an off-screen, bottom-up render target.
|
||||
if (auto topLeftRTC = GrSurfaceDrawContext::Make(
|
||||
rContext, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
|
||||
if (auto topLeftSDC = skgpu::v1::SurfaceDrawContext::Make(
|
||||
rContext, sdcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
|
||||
1, GrMipmapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin,
|
||||
SkBudgeted::kYes)) {
|
||||
topLeftRTC->clear(SK_PMColor4fTRANSPARENT);
|
||||
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
||||
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
||||
topLeftSDC->clear(SK_PMColor4fTRANSPARENT);
|
||||
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, false, 0));
|
||||
topLeftSDC->addDrawOp(ClockwiseTestOp::Make(rContext, true, 100));
|
||||
sdc->drawTexture(nullptr,
|
||||
topLeftRTC->readSurfaceView(),
|
||||
topLeftSDC->readSurfaceView(),
|
||||
sdc->colorInfo().alphaType(),
|
||||
GrSamplerState::Filter::kNearest,
|
||||
GrSamplerState::MipmapMode::kNone,
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "third_party/etc1/etc1.h"
|
||||
#include "tools/gpu/ProxyUtils.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
static SkPoint gen_pt(float angle, const SkVector& scale) {
|
||||
SkScalar s = SkScalarSin(angle);
|
||||
SkScalar c = SkScalarCos(angle);
|
||||
|
@ -33,9 +33,9 @@
|
||||
#include "src/gpu/GrColor.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/ops/GrOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
#include "tools/gpu/TestOps.h"
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "src/core/SkTLList.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrConvexPolyEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/gpu/TestOps.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -24,7 +24,7 @@ namespace skiagm {
|
||||
constexpr SkRect kSrcImageClip{75, 75, 275, 275};
|
||||
|
||||
/*
|
||||
* The purpose of this test is to exercise all three codepaths in GrSurfaceDrawContext
|
||||
* The purpose of this test is to exercise all three codepaths in skgpu::v1::SurfaceDrawContext
|
||||
* (drawFilledRect, fillRectToRect, fillRectWithLocalMatrix) that pre-crop filled rects based on the
|
||||
* clip.
|
||||
*
|
||||
@ -62,7 +62,7 @@ private:
|
||||
canvas->clear(SK_ColorWHITE);
|
||||
|
||||
{
|
||||
// GrSurfaceDrawContext::drawFilledRect.
|
||||
// skgpu::v1::SurfaceDrawContext::drawFilledRect.
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
SkPaint paint;
|
||||
paint.setShader(fSrcImageShader);
|
||||
@ -71,7 +71,7 @@ private:
|
||||
}
|
||||
|
||||
{
|
||||
// GrSurfaceDrawContext::fillRectToRect.
|
||||
// skgpu::v1::SurfaceDrawContext::fillRectToRect.
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
SkRect drawRect = SkRect::MakeXYWH(350, 100, 100, 300);
|
||||
canvas->clipRect(drawRect);
|
||||
@ -84,7 +84,7 @@ private:
|
||||
}
|
||||
|
||||
{
|
||||
// GrSurfaceDrawContext::fillRectWithLocalMatrix.
|
||||
// skgpu::v1::SurfaceDrawContext::fillRectWithLocalMatrix.
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
SkPath path = SkPath::Line(
|
||||
{kSrcImageClip.fLeft - kSrcImageClip.width(), kSrcImageClip.centerY()},
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "tools/Resources.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
DEF_SIMPLE_GPU_GM_CAN_FAIL(cross_context_image, rContext, canvas, errorMsg,
|
||||
3 * 256 + 40, 256 + 128 + 30) {
|
||||
sk_sp<SkData> encodedData = GetResourceAsData("images/mandrill_256.png");
|
||||
|
@ -16,10 +16,10 @@
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "include/utils/SkRandom.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
/*
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/core/SkMatrixProvider.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#include <utility>
|
||||
@ -49,7 +49,7 @@ static void draw_gradient_tiles(SkCanvas* canvas, bool alignGradients) {
|
||||
static constexpr SkPoint pts[] = { {0.f, 0.f}, {0.25f * kTileWidth, 0.25f * kTileHeight} };
|
||||
static constexpr SkColor colors[] = { SK_ColorBLUE, SK_ColorWHITE };
|
||||
|
||||
GrSurfaceDrawContext* sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
|
||||
auto rContext = canvas->recordingContext();
|
||||
|
||||
|
@ -37,8 +37,6 @@
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
static const int kNumMatrices = 6;
|
||||
static const int kImageSize = 128;
|
||||
static const int kLabelSize = 32;
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
|
||||
SkScalar y, const SkFont& font) {
|
||||
SkPaint paint;
|
||||
|
@ -36,8 +36,6 @@
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
static sk_sp<SkTextBlob> make_blob(const SkString& text, const SkFont& font) {
|
||||
size_t len = text.size();
|
||||
SkAutoTArray<SkScalar> pos(len);
|
||||
|
@ -11,10 +11,10 @@
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
namespace {
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrShaderVar.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
@ -42,6 +41,7 @@
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/ops/GrOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/gpu/ProxyUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
using namespace skiagm;
|
||||
|
||||
constexpr char GM::kErrorMsg_DrawSkippedGpuOnly[];
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include "src/core/SkGpuBlurUtils.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "src/image/SkImage_Base.h"
|
||||
|
||||
namespace {
|
||||
|
@ -39,8 +39,6 @@
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
const SkSamplingOptions gSamplings[] = {
|
||||
SkSamplingOptions(SkFilterMode::kNearest),
|
||||
SkSamplingOptions(SkFilterMode::kLinear),
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/gpu/YUVUtils.h"
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
namespace skiagm {
|
||||
class ImageFromYUVTextures : public GM {
|
||||
public:
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#include "tools/gpu/ProxyUtils.h"
|
||||
|
||||
@ -139,7 +139,7 @@ static SkBitmap create_bitmap(SkIRect contentRect, SkISize fullSize, GrSurfaceOr
|
||||
}
|
||||
|
||||
static void draw_texture(const GrCaps* caps,
|
||||
GrSurfaceDrawContext* sdc,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrSurfaceProxyView& src,
|
||||
const SkIRect& srcRect,
|
||||
const SkIRect& drawRect,
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrDrawingManager.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
namespace skiagm {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrDrawingManager.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
namespace skiagm {
|
||||
|
@ -39,8 +39,6 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
namespace skiagm {
|
||||
class RectangleTexture : public GM {
|
||||
public:
|
||||
|
@ -17,8 +17,8 @@
|
||||
#include "include/core/SkTileMode.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
|
||||
// Exercises code in GrSurfaceDrawContext that attempts to replace a rrect clip/draw paint with
|
||||
// draw rrect.
|
||||
// Exercises code in skgpu::V1::SurfaceDrawContext that attempts to replace a rrect clip/draw
|
||||
// paint with draw rrect.
|
||||
DEF_SIMPLE_GM(rrect_clip_draw_paint, canvas, 256, 256) {
|
||||
SkRRect rrect = SkRRect::MakeRectXY(SkRect::MakeXYWH(10.f, 10.f, 236.f, 236.f), 30.f, 40.f);
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
|
||||
#include "src/gpu/effects/GrRRectEffect.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/ops/GrFillRectOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
@ -19,12 +19,12 @@
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrShaderVar.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/gpu/TestOps.h"
|
||||
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
namespace skiagm {
|
||||
class TextBlobRandomFont : public GM {
|
||||
public:
|
||||
|
@ -20,8 +20,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
// This tests that we correctly regenerate textblobs after freeing all gpu resources crbug/491350
|
||||
namespace skiagm {
|
||||
class TextBlobUseAfterGpuFree : public GM {
|
||||
|
@ -55,8 +55,6 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
class GrSurfaceDrawContext;
|
||||
|
||||
static const int kTileWidthHeight = 128;
|
||||
static const int kLabelWidth = 64;
|
||||
static const int kLabelHeight = 32;
|
||||
|
@ -33,11 +33,11 @@
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/GrUserStencilSettings.h"
|
||||
#include "src/gpu/effects/GrDisableColorXP.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#include <utility>
|
||||
@ -157,11 +157,11 @@ private:
|
||||
constexpr static int kMaskCheckerSize = 5;
|
||||
SkString onShortName() final { return SkString("windowrectangles_mask"); }
|
||||
DrawResult onCoverClipStack(const SkClipStack&, SkCanvas*, SkString* errorMsg) final;
|
||||
void visualizeAlphaMask(GrRecordingContext*, GrSurfaceDrawContext*,
|
||||
void visualizeAlphaMask(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*,
|
||||
const GrReducedClip&, GrPaint&&);
|
||||
void visualizeStencilMask(GrRecordingContext*, GrSurfaceDrawContext*,
|
||||
void visualizeStencilMask(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*,
|
||||
const GrReducedClip&, GrPaint&&);
|
||||
void stencilCheckerboard(GrSurfaceDrawContext*, bool flip);
|
||||
void stencilCheckerboard(skgpu::v1::SurfaceDrawContext*, bool flip);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -175,15 +175,19 @@ private:
|
||||
SkIRect getConservativeBounds() const final {
|
||||
return SkIRect::MakeXYWH(fX, fY, fMask.width(), fMask.height());
|
||||
}
|
||||
Effect apply(GrRecordingContext* ctx, GrSurfaceDrawContext*, GrDrawOp*, GrAAType,
|
||||
GrAppliedClip* out, SkRect* bounds) const override {
|
||||
Effect apply(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
GrDrawOp*,
|
||||
GrAAType,
|
||||
GrAppliedClip* out,
|
||||
SkRect* bounds) const override {
|
||||
GrSamplerState samplerState(GrSamplerState::WrapMode::kClampToBorder,
|
||||
GrSamplerState::Filter::kNearest);
|
||||
auto m = SkMatrix::Translate(-fX, -fY);
|
||||
auto subset = SkRect::Make(fMask.dimensions());
|
||||
auto domain = bounds->makeOffset(-fX, -fY).makeInset(0.5, 0.5);
|
||||
auto fp = GrTextureEffect::MakeSubset(fMask, kPremul_SkAlphaType, m, samplerState, subset,
|
||||
domain, *ctx->priv().caps());
|
||||
domain, *rContext->priv().caps());
|
||||
fp = GrFragmentProcessor::DeviceSpace(std::move(fp));
|
||||
out->addCoverageFP(std::move(fp));
|
||||
return Effect::kClipped;
|
||||
@ -196,15 +200,15 @@ private:
|
||||
/**
|
||||
* Makes a clip object that enforces the stencil clip bit. Used to visualize the stencil mask.
|
||||
*/
|
||||
static GrStencilClip make_stencil_only_clip(GrSurfaceDrawContext* rtc) {
|
||||
return GrStencilClip(rtc->dimensions(), SkClipStack::kEmptyGenID);
|
||||
static GrStencilClip make_stencil_only_clip(skgpu::v1::SurfaceDrawContext* sdc) {
|
||||
return GrStencilClip(sdc->dimensions(), SkClipStack::kEmptyGenID);
|
||||
};
|
||||
|
||||
DrawResult WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack,
|
||||
SkCanvas* canvas,
|
||||
SkString* errorMsg) {
|
||||
auto rContext = canvas->recordingContext();
|
||||
GrSurfaceDrawContext* sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
|
||||
if (!rContext || !sdc) {
|
||||
*errorMsg = kErrorMsg_DrawSkippedGpuOnly;
|
||||
@ -229,27 +233,29 @@ DrawResult WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack,
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void WindowRectanglesMaskGM::visualizeAlphaMask(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc,
|
||||
const GrReducedClip& reducedClip, GrPaint&& paint) {
|
||||
void WindowRectanglesMaskGM::visualizeAlphaMask(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrReducedClip& reducedClip,
|
||||
GrPaint&& paint) {
|
||||
const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2;
|
||||
const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2;
|
||||
auto maskRTC = GrSurfaceDrawContext::MakeWithFallback(
|
||||
ctx, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact,
|
||||
auto maskSDC = skgpu::v1::SurfaceDrawContext::MakeWithFallback(
|
||||
rContext, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact,
|
||||
{kCoverRect.width() + padRight, kCoverRect.height() + padBottom}, SkSurfaceProps());
|
||||
if (!maskRTC) {
|
||||
if (!maskSDC) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw a checker pattern into the alpha mask so we can visualize the regions left untouched by
|
||||
// the clip mask generation.
|
||||
this->stencilCheckerboard(maskRTC.get(), true);
|
||||
maskRTC->clear(SK_PMColor4fWHITE);
|
||||
this->stencilCheckerboard(maskSDC.get(), true);
|
||||
maskSDC->clear(SK_PMColor4fWHITE);
|
||||
GrPaint stencilPaint;
|
||||
stencilPaint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op, false);
|
||||
GrStencilClip stencilClip = make_stencil_only_clip(maskRTC.get());
|
||||
maskRTC->stencilRect(&stencilClip, &GrUserStencilSettings::kUnused, std::move(stencilPaint),
|
||||
GrAA::kNo, SkMatrix::I(), SkRect::Make(maskRTC->dimensions()));
|
||||
reducedClip.drawAlphaClipMask(maskRTC.get());
|
||||
GrStencilClip stencilClip = make_stencil_only_clip(maskSDC.get());
|
||||
maskSDC->stencilRect(&stencilClip, &GrUserStencilSettings::kUnused, std::move(stencilPaint),
|
||||
GrAA::kNo, SkMatrix::I(), SkRect::Make(maskSDC->dimensions()));
|
||||
reducedClip.drawAlphaClipMask(maskSDC.get());
|
||||
|
||||
int x = kCoverRect.x() - kDeviceRect.x(),
|
||||
y = kCoverRect.y() - kDeviceRect.y();
|
||||
@ -257,16 +263,16 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrRecordingContext* ctx, GrSurfa
|
||||
// Now visualize the alpha mask by drawing a rect over the area where it is defined. The regions
|
||||
// inside window rectangles or outside the scissor should still have the initial checkerboard
|
||||
// intact. (This verifies we didn't spend any time modifying those pixels in the mask.)
|
||||
AlphaOnlyClip alphaClip(maskRTC->readSurfaceView().makeSwizzle(GrSwizzle("aaaa")), x, y);
|
||||
rtc->drawRect(&alphaClip, std::move(paint), GrAA::kYes, SkMatrix::I(),
|
||||
SkRect::Make(SkIRect::MakeXYWH(x, y, maskRTC->width(), maskRTC->height())));
|
||||
AlphaOnlyClip alphaClip(maskSDC->readSurfaceView().makeSwizzle(GrSwizzle("aaaa")), x, y);
|
||||
sdc->drawRect(&alphaClip, std::move(paint), GrAA::kYes, SkMatrix::I(),
|
||||
SkRect::Make(SkIRect::MakeXYWH(x, y, maskSDC->width(), maskSDC->height())));
|
||||
}
|
||||
|
||||
void WindowRectanglesMaskGM::visualizeStencilMask(GrRecordingContext* ctx,
|
||||
GrSurfaceDrawContext* rtc,
|
||||
void WindowRectanglesMaskGM::visualizeStencilMask(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrReducedClip& reducedClip,
|
||||
GrPaint&& paint) {
|
||||
if (ctx->abandoned()) {
|
||||
if (rContext->abandoned()) {
|
||||
// GrReducedClip assumes the context hasn't been abandoned, which is reasonable since it is
|
||||
// only ever used if a draw op is made. Since this GM calls it directly, it has to be taken
|
||||
// into account.
|
||||
@ -274,17 +280,17 @@ void WindowRectanglesMaskGM::visualizeStencilMask(GrRecordingContext* ctx,
|
||||
}
|
||||
// Draw a checker pattern into the stencil buffer so we can visualize the regions left untouched
|
||||
// by the clip mask generation.
|
||||
this->stencilCheckerboard(rtc, false);
|
||||
reducedClip.drawStencilClipMask(ctx, rtc);
|
||||
this->stencilCheckerboard(sdc, false);
|
||||
reducedClip.drawStencilClipMask(rContext, sdc);
|
||||
|
||||
// Now visualize the stencil mask by covering the entire render target. The regions inside
|
||||
// window rectangles or outside the scissor should still have the initial checkerboard intact.
|
||||
// (This verifies we didn't spend any time modifying those pixels in the mask.)
|
||||
GrStencilClip clip = make_stencil_only_clip(rtc);
|
||||
rtc->drawPaint(&clip, std::move(paint), SkMatrix::I());
|
||||
GrStencilClip clip = make_stencil_only_clip(sdc);
|
||||
sdc->drawPaint(&clip, std::move(paint), SkMatrix::I());
|
||||
}
|
||||
|
||||
void WindowRectanglesMaskGM::stencilCheckerboard(GrSurfaceDrawContext* rtc, bool flip) {
|
||||
void WindowRectanglesMaskGM::stencilCheckerboard(skgpu::v1::SurfaceDrawContext* sdc, bool flip) {
|
||||
constexpr static GrUserStencilSettings kSetClip(
|
||||
GrUserStencilSettings::StaticInit<
|
||||
0,
|
||||
@ -295,7 +301,7 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrSurfaceDrawContext* rtc, bool
|
||||
0>()
|
||||
);
|
||||
|
||||
rtc->clearStencilClip(SkIRect::MakeSize(rtc->dimensions()), false);
|
||||
sdc->clearStencilClip(SkIRect::MakeSize(sdc->dimensions()), false);
|
||||
|
||||
for (int y = 0; y < kDeviceRect.height(); y += kMaskCheckerSize) {
|
||||
for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize;
|
||||
@ -303,7 +309,7 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrSurfaceDrawContext* rtc, bool
|
||||
SkIRect checker = SkIRect::MakeXYWH(x, y, kMaskCheckerSize, kMaskCheckerSize);
|
||||
GrPaint paint;
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Get());
|
||||
rtc->stencilRect(nullptr, &kSetClip, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
sdc->stencilRect(nullptr, &kSetClip, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(checker));
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,11 @@
|
||||
#include "include/core/SkYUVAPixmaps.h"
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/GrYUVATextureProxies.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrYUVtoRGBEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
@ -215,8 +215,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrSurface.h",
|
||||
"$_src/gpu/GrSurfaceContext.cpp",
|
||||
"$_src/gpu/GrSurfaceContext.h",
|
||||
"$_src/gpu/GrSurfaceDrawContext.cpp",
|
||||
"$_src/gpu/GrSurfaceDrawContext.h",
|
||||
"$_src/gpu/GrSurfaceFillContext.cpp",
|
||||
"$_src/gpu/GrSurfaceFillContext.h",
|
||||
"$_src/gpu/GrSurfaceProxy.cpp",
|
||||
@ -484,6 +482,10 @@ skia_gpu_sources = [
|
||||
"$_src/image/SkImage_GpuYUVA.h",
|
||||
"$_src/image/SkSurface_Gpu.cpp",
|
||||
"$_src/image/SkSurface_Gpu.h",
|
||||
|
||||
# V1 files temporarily here
|
||||
"$_src/gpu/v1/SurfaceDrawContext.cpp",
|
||||
"$_src/gpu/v1/SurfaceDrawContext_v1.h",
|
||||
]
|
||||
|
||||
skia_gl_gpu_sources = [
|
||||
@ -595,7 +597,7 @@ skia_skgpu_v1_sources = [
|
||||
# tessellate
|
||||
"$_src/gpu/tessellate/GrTessellationPathRenderer.cpp",
|
||||
|
||||
# Sk files
|
||||
# v1
|
||||
"$_src/gpu/v1/Device.cpp",
|
||||
"$_src/gpu/v1/Device_drawTexture.cpp",
|
||||
"$_src/gpu/v1/Device_v1.h",
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/tessellate/GrPathCurveTessellator.h"
|
||||
#include "src/gpu/tessellate/GrPathWedgeTessellator.h"
|
||||
#include "src/gpu/tessellate/shaders/GrPathTessellationShader.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -174,7 +174,7 @@ void SamplePathTessellators::onDrawContent(SkCanvas* canvas) {
|
||||
canvas->clear(SK_ColorBLACK);
|
||||
|
||||
auto ctx = canvas->recordingContext();
|
||||
GrSurfaceDrawContext* sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
|
||||
|
||||
SkString error;
|
||||
if (!sdc || !ctx) {
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/GrThreadSafeCache.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
@ -40,6 +39,7 @@
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#endif
|
||||
|
||||
class SkBlurMaskFilterImpl : public SkMaskFilterBase {
|
||||
@ -58,11 +58,11 @@ public:
|
||||
const SkMatrix& ctm,
|
||||
SkIRect* maskRect) const override;
|
||||
bool directFilterMaskGPU(GrRecordingContext*,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&&,
|
||||
const GrClip*,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrStyledShape& shape) const override;
|
||||
const GrStyledShape&) const override;
|
||||
GrSurfaceProxyView filterMaskGPU(GrRecordingContext*,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
@ -1073,37 +1073,37 @@ static bool fillin_view_on_gpu(GrDirectContext* dContext,
|
||||
// regardless of the final dst surface.
|
||||
SkSurfaceProps defaultSurfaceProps;
|
||||
|
||||
std::unique_ptr<GrSurfaceDrawContext> rtc =
|
||||
GrSurfaceDrawContext::MakeWithFallback(dContext,
|
||||
GrColorType::kAlpha_8,
|
||||
nullptr,
|
||||
SkBackingFit::kExact,
|
||||
dimensions,
|
||||
defaultSurfaceProps,
|
||||
1,
|
||||
GrMipmapped::kNo,
|
||||
GrProtected::kNo,
|
||||
kBlurredRRectMaskOrigin);
|
||||
if (!rtc) {
|
||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> sdc =
|
||||
skgpu::v1::SurfaceDrawContext::MakeWithFallback(dContext,
|
||||
GrColorType::kAlpha_8,
|
||||
nullptr,
|
||||
SkBackingFit::kExact,
|
||||
dimensions,
|
||||
defaultSurfaceProps,
|
||||
1,
|
||||
GrMipmapped::kNo,
|
||||
GrProtected::kNo,
|
||||
kBlurredRRectMaskOrigin);
|
||||
if (!sdc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrPaint paint;
|
||||
|
||||
rtc->clear(SK_PMColor4fTRANSPARENT);
|
||||
rtc->drawRRect(nullptr,
|
||||
sdc->clear(SK_PMColor4fTRANSPARENT);
|
||||
sdc->drawRRect(nullptr,
|
||||
std::move(paint),
|
||||
GrAA::kYes,
|
||||
SkMatrix::I(),
|
||||
rrectToDraw,
|
||||
GrStyle::SimpleFill());
|
||||
|
||||
GrSurfaceProxyView srcView = rtc->readSurfaceView();
|
||||
GrSurfaceProxyView srcView = sdc->readSurfaceView();
|
||||
SkASSERT(srcView.asTextureProxy());
|
||||
auto rtc2 = SkGpuBlurUtils::GaussianBlur(dContext,
|
||||
std::move(srcView),
|
||||
rtc->colorInfo().colorType(),
|
||||
rtc->colorInfo().alphaType(),
|
||||
sdc->colorInfo().colorType(),
|
||||
sdc->colorInfo().alphaType(),
|
||||
nullptr,
|
||||
SkIRect::MakeSize(dimensions),
|
||||
SkIRect::MakeSize(dimensions),
|
||||
@ -1443,12 +1443,12 @@ static std::unique_ptr<GrFragmentProcessor> make_rrect_blur(GrRecordingContext*
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPaint&& paint,
|
||||
const GrClip* clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrStyledShape& shape) const {
|
||||
SkASSERT(surfaceDrawContext);
|
||||
SkASSERT(sdc);
|
||||
|
||||
if (fBlurStyle != kNormal_SkBlurStyle) {
|
||||
return false;
|
||||
@ -1461,8 +1461,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
|
||||
|
||||
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
|
||||
if (SkGpuBlurUtils::IsEffectivelyZeroSigma(xformedSigma)) {
|
||||
surfaceDrawContext->drawShape(clip, std::move(paint), GrAA::kYes, viewMatrix,
|
||||
GrStyledShape(shape));
|
||||
sdc->drawShape(clip, std::move(paint), GrAA::kYes, viewMatrix, GrStyledShape(shape));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1525,7 +1524,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
|
||||
}
|
||||
srcProxyRect.outset(outsetX, outsetY);
|
||||
|
||||
surfaceDrawContext->drawRect(clip, std::move(paint), GrAA::kNo, viewMatrix, srcProxyRect);
|
||||
sdc->drawRect(clip, std::move(paint), GrAA::kNo, viewMatrix, srcProxyRect);
|
||||
return true;
|
||||
}
|
||||
if (!viewMatrix.isScaleTranslate()) {
|
||||
@ -1544,7 +1543,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
|
||||
SkRect srcProxyRect = srcRRect.rect();
|
||||
srcProxyRect.outset(3.0f*fSigma, 3.0f*fSigma);
|
||||
paint.setCoverageFragmentProcessor(std::move(fp));
|
||||
surfaceDrawContext->drawRect(clip, std::move(paint), GrAA::kNo, viewMatrix, srcProxyRect);
|
||||
sdc->drawRect(clip, std::move(paint), GrAA::kNo, viewMatrix, srcProxyRect);
|
||||
} else {
|
||||
SkMatrix inverse;
|
||||
if (!viewMatrix.invert(&inverse)) {
|
||||
@ -1556,7 +1555,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
|
||||
devRRect.rect().makeOutset(extra, extra).roundOut(&proxyBounds);
|
||||
|
||||
paint.setCoverageFragmentProcessor(std::move(fp));
|
||||
surfaceDrawContext->fillPixelsWithLocalMatrix(clip, std::move(paint), proxyBounds, inverse);
|
||||
sdc->fillPixelsWithLocalMatrix(clip, std::move(paint), proxyBounds, inverse);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -58,7 +58,7 @@
|
||||
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
|
||||
# include "src/gpu/GrRenderTarget.h"
|
||||
# include "src/gpu/GrRenderTargetProxy.h"
|
||||
# include "src/gpu/GrSurfaceDrawContext.h"
|
||||
# include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1656,10 +1656,6 @@ SkM44 SkCanvas::getLocalToDevice() const {
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && SK_SUPPORT_GPU
|
||||
|
||||
#include "src/gpu/GrRenderTarget.h"
|
||||
#include "src/gpu/GrRenderTargetProxy.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
|
||||
SkIRect SkCanvas::topLayerBounds() const {
|
||||
return this->topDevice()->getGlobalBounds();
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ bool SkCanvasPriv::ValidateMarker(const char* name) {
|
||||
#include "src/gpu/BaseDevice.h"
|
||||
|
||||
#if SK_GPU_V1
|
||||
GrSurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
|
||||
skgpu::v1::SurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
|
||||
if (auto gpuDevice = canvas->topDevice()->asGpuDevice()) {
|
||||
return gpuDevice->surfaceDrawContext();
|
||||
}
|
||||
@ -144,7 +144,7 @@ GrSurfaceFillContext* SkCanvasPriv::TopDeviceSurfaceFillContext(SkCanvas* canvas
|
||||
#else // SK_SUPPORT_GPU
|
||||
|
||||
#if SK_GPU_V1
|
||||
GrSurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
|
||||
skgpu::v1::SurfaceDrawContext* SkCanvasPriv::TopDeviceSurfaceDrawContext(SkCanvas* canvas) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif // SK_GPU_V1
|
||||
|
@ -15,7 +15,7 @@ class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrSurfaceFillContext;
|
||||
#endif // GR_TEST_UTILS
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
#if SK_GPU_V1
|
||||
static GrSurfaceDrawContext* TopDeviceSurfaceDrawContext(SkCanvas*);
|
||||
static skgpu::v1::SurfaceDrawContext* TopDeviceSurfaceDrawContext(SkCanvas*);
|
||||
#endif
|
||||
static GrSurfaceFillContext* TopDeviceSurfaceFillContext(SkCanvas*);
|
||||
#endif // GR_TEST_UTILS
|
||||
|
@ -54,9 +54,9 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
|
||||
#include "include/gpu/GrYUVABackendTextures.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "src/image/SkImage_Gpu.h"
|
||||
#include "src/image/SkImage_GpuYUVA.h"
|
||||
#include "src/image/SkSurface_Gpu.h"
|
||||
|
@ -13,11 +13,11 @@
|
||||
#include "src/gpu/GrColorInfo.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/ops/GrAtlasTextOp.h"
|
||||
#include "src/gpu/text/GrSDFTControl.h"
|
||||
#include "src/gpu/text/GrTextBlobCache.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#endif
|
||||
|
||||
#include "include/core/SkColorFilter.h"
|
||||
@ -73,8 +73,8 @@ SkGlyphRunListPainter::SkGlyphRunListPainter(const SkSurfaceProps& props, const
|
||||
compute_scaler_context_flags(csi.colorSpace()),
|
||||
SkStrikeCache::GlobalStrikeCache()) {}
|
||||
|
||||
SkGlyphRunListPainter::SkGlyphRunListPainter(const GrSurfaceDrawContext& rtc)
|
||||
: SkGlyphRunListPainter{rtc.surfaceProps(), rtc.colorInfo()} {}
|
||||
SkGlyphRunListPainter::SkGlyphRunListPainter(const skgpu::v1::SurfaceDrawContext& sdc)
|
||||
: SkGlyphRunListPainter{sdc.surfaceProps(), sdc.colorInfo()} {}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/text/GrSDFTControl.h"
|
||||
class GrColorInfo;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
#endif
|
||||
|
||||
class SkGlyphRunPainterInterface;
|
||||
@ -62,7 +62,7 @@ public:
|
||||
// The following two ctors are used exclusively by the GPU, and will always use the global
|
||||
// strike cache.
|
||||
SkGlyphRunListPainter(const SkSurfaceProps&, const GrColorInfo&);
|
||||
explicit SkGlyphRunListPainter(const GrSurfaceDrawContext& surfaceDrawContext);
|
||||
explicit SkGlyphRunListPainter(const skgpu::v1::SurfaceDrawContext&);
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
class BitmapDevicePainter {
|
||||
|
@ -14,11 +14,11 @@
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrMatrixConvolutionEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#if SK_GPU_V1
|
||||
|
||||
@ -94,27 +94,28 @@ static void convolve_gaussian_1d(GrSurfaceFillContext* sfc,
|
||||
sfc->fillRectToRectWithFP(srcRect, dstRect, std::move(conv));
|
||||
}
|
||||
|
||||
static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian_2d(GrRecordingContext* context,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
const SkIRect& srcBounds,
|
||||
const SkIRect& dstBounds,
|
||||
int radiusX,
|
||||
int radiusY,
|
||||
SkScalar sigmaX,
|
||||
SkScalar sigmaY,
|
||||
SkTileMode mode,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit dstFit) {
|
||||
static std::unique_ptr<skgpu::v1::SurfaceDrawContext> convolve_gaussian_2d(
|
||||
GrRecordingContext* rContext,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
const SkIRect& srcBounds,
|
||||
const SkIRect& dstBounds,
|
||||
int radiusX,
|
||||
int radiusY,
|
||||
SkScalar sigmaX,
|
||||
SkScalar sigmaY,
|
||||
SkTileMode mode,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit dstFit) {
|
||||
SkASSERT(radiusX && radiusY);
|
||||
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.
|
||||
auto surfaceDrawContext = GrSurfaceDrawContext::Make(
|
||||
context, srcColorType, std::move(finalCS), dstFit, dstBounds.size(), SkSurfaceProps(),
|
||||
auto sdc = skgpu::v1::SurfaceDrawContext::Make(
|
||||
rContext, srcColorType, std::move(finalCS), dstFit, dstBounds.size(), SkSurfaceProps(),
|
||||
1, GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
|
||||
if (!surfaceDrawContext) {
|
||||
if (!sdc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -129,9 +130,9 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian_2d(GrRecordingCon
|
||||
SkASSERT(size.area() <= GrMatrixConvolutionEffect::kMaxUniformSize);
|
||||
float kernel[GrMatrixConvolutionEffect::kMaxUniformSize];
|
||||
fill_in_2D_gaussian_kernel(kernel, size.width(), size.height(), sigmaX, sigmaY);
|
||||
auto conv = GrMatrixConvolutionEffect::Make(context, std::move(srcView), srcBounds,
|
||||
auto conv = GrMatrixConvolutionEffect::Make(rContext, std::move(srcView), srcBounds,
|
||||
size, kernel, 1.0f, 0.0f, kernelOffset, wm, true,
|
||||
*surfaceDrawContext->caps());
|
||||
*sdc->caps());
|
||||
|
||||
paint.setColorFragmentProcessor(std::move(conv));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
@ -139,24 +140,25 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian_2d(GrRecordingCon
|
||||
// 'dstBounds' is actually in 'srcView' proxy space. It represents the blurred area from src
|
||||
// space that we want to capture in the new RTC at {0, 0}. Hence, we use its size as the rect to
|
||||
// draw and it directly as the local rect.
|
||||
surfaceDrawContext->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstBounds.size()), SkRect::Make(dstBounds));
|
||||
sdc->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstBounds.size()), SkRect::Make(dstBounds));
|
||||
|
||||
return surfaceDrawContext;
|
||||
return sdc;
|
||||
}
|
||||
|
||||
static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContext* context,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
SkIRect srcBounds,
|
||||
SkIRect dstBounds,
|
||||
Direction direction,
|
||||
int radius,
|
||||
float sigma,
|
||||
SkTileMode mode,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit fit) {
|
||||
static std::unique_ptr<skgpu::v1::SurfaceDrawContext> convolve_gaussian(
|
||||
GrRecordingContext* rContext,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
SkIRect srcBounds,
|
||||
SkIRect dstBounds,
|
||||
Direction direction,
|
||||
int radius,
|
||||
float sigma,
|
||||
SkTileMode mode,
|
||||
sk_sp<SkColorSpace> finalCS,
|
||||
SkBackingFit fit) {
|
||||
using namespace SkGpuBlurUtils;
|
||||
SkASSERT(radius > 0 && !SkGpuBlurUtils::IsEffectivelyZeroSigma(sigma));
|
||||
// Logically we're creating an infinite blur of 'srcBounds' of 'srcView' with 'mode' tiling
|
||||
@ -165,10 +167,10 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
//
|
||||
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
|
||||
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
|
||||
auto dstSurfaceDrawContext = GrSurfaceDrawContext::Make(
|
||||
context, srcColorType, std::move(finalCS), fit, dstBounds.size(), SkSurfaceProps(), 1,
|
||||
auto dstSDC = skgpu::v1::SurfaceDrawContext::Make(
|
||||
rContext, srcColorType, std::move(finalCS), fit, dstBounds.size(), SkSurfaceProps(), 1,
|
||||
GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
|
||||
if (!dstSurfaceDrawContext) {
|
||||
if (!dstSDC) {
|
||||
return nullptr;
|
||||
}
|
||||
// This represents the translation from 'dstSurfaceDrawContext' coords to 'srcView' coords.
|
||||
@ -181,13 +183,13 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
// ...but it's not worth doing the splitting if we'll get HW tiling instead of shader tiling.
|
||||
bool canHWTile =
|
||||
srcBounds.contains(srcBackingBounds) &&
|
||||
!context->priv().caps()->reducedShaderMode() && // this mode always uses shader tiling
|
||||
!(mode == SkTileMode::kDecal && !context->priv().caps()->clampToBorderSupport());
|
||||
!rContext->priv().caps()->reducedShaderMode() && // this mode always uses shader tiling
|
||||
!(mode == SkTileMode::kDecal && !rContext->priv().caps()->clampToBorderSupport());
|
||||
if (!canSplit || canHWTile) {
|
||||
auto dstRect = SkIRect::MakeSize(dstBounds.size());
|
||||
convolve_gaussian_1d(dstSurfaceDrawContext.get(), std::move(srcView), srcBounds,
|
||||
convolve_gaussian_1d(dstSDC.get(), std::move(srcView), srcBounds,
|
||||
rtcToSrcOffset, dstRect, srcAlphaType, direction, radius, sigma, mode);
|
||||
return dstSurfaceDrawContext;
|
||||
return dstSDC;
|
||||
}
|
||||
|
||||
// 'left' and 'right' are the sub rects of 'srcBounds' where 'mode' must be enforced.
|
||||
@ -239,13 +241,13 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
auto convolve = [&](SkIRect rect) {
|
||||
// Transform rect into the render target's coord system.
|
||||
rect.offset(-rtcToSrcOffset);
|
||||
convolve_gaussian_1d(dstSurfaceDrawContext.get(), srcView, srcBounds, rtcToSrcOffset, rect,
|
||||
convolve_gaussian_1d(dstSDC.get(), srcView, srcBounds, rtcToSrcOffset, rect,
|
||||
srcAlphaType, direction, radius, sigma, mode);
|
||||
};
|
||||
auto clear = [&](SkIRect rect) {
|
||||
// Transform rect into the render target's coord system.
|
||||
rect.offset(-rtcToSrcOffset);
|
||||
dstSurfaceDrawContext->clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
|
||||
dstSDC->clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
|
||||
};
|
||||
|
||||
// Doing mid separately will cause two draws to occur (left and right batch together). At
|
||||
@ -292,17 +294,18 @@ static std::unique_ptr<GrSurfaceDrawContext> convolve_gaussian(GrRecordingContex
|
||||
convolve(right);
|
||||
convolve(mid);
|
||||
}
|
||||
return dstSurfaceDrawContext;
|
||||
return dstSDC;
|
||||
}
|
||||
|
||||
// Expand the contents of 'src' to fit in 'dstSize'. At this point, we are expanding an intermediate
|
||||
// image, so there's no need to account for a proxy offset from the original input.
|
||||
static std::unique_ptr<GrSurfaceDrawContext> reexpand(GrRecordingContext* context,
|
||||
std::unique_ptr<GrSurfaceContext> src,
|
||||
const SkRect& srcBounds,
|
||||
SkISize dstSize,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkBackingFit fit) {
|
||||
static std::unique_ptr<skgpu::v1::SurfaceDrawContext> reexpand(
|
||||
GrRecordingContext* rContext,
|
||||
std::unique_ptr<GrSurfaceContext> src,
|
||||
const SkRect& srcBounds,
|
||||
SkISize dstSize,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkBackingFit fit) {
|
||||
GrSurfaceProxyView srcView = src->readSurfaceView();
|
||||
if (!srcView.asTextureProxy()) {
|
||||
return nullptr;
|
||||
@ -315,41 +318,42 @@ static std::unique_ptr<GrSurfaceDrawContext> reexpand(GrRecordingContext* contex
|
||||
|
||||
// Create the sdc with default SkSurfaceProps. Gaussian blurs will soon use a
|
||||
// GrSurfaceFillContext, at which point the SkSurfaceProps won't exist anymore.
|
||||
auto dstSurfaceDrawContext = GrSurfaceDrawContext::Make(
|
||||
context, srcColorType, std::move(colorSpace), fit, dstSize, SkSurfaceProps(), 1,
|
||||
auto dstSDC = skgpu::v1::SurfaceDrawContext::Make(
|
||||
rContext, srcColorType, std::move(colorSpace), fit, dstSize, SkSurfaceProps(), 1,
|
||||
GrMipmapped::kNo, srcView.proxy()->isProtected(), srcView.origin());
|
||||
if (!dstSurfaceDrawContext) {
|
||||
if (!dstSDC) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrPaint paint;
|
||||
auto fp = GrTextureEffect::MakeSubset(std::move(srcView), srcAlphaType, SkMatrix::I(),
|
||||
GrSamplerState::Filter::kLinear, srcBounds, srcBounds,
|
||||
*context->priv().caps());
|
||||
*rContext->priv().caps());
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
dstSurfaceDrawContext->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstSize), srcBounds);
|
||||
dstSDC->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstSize), srcBounds);
|
||||
|
||||
return dstSurfaceDrawContext;
|
||||
return dstSDC;
|
||||
}
|
||||
|
||||
static std::unique_ptr<GrSurfaceDrawContext> two_pass_gaussian(GrRecordingContext* context,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkIRect srcBounds,
|
||||
SkIRect dstBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
int radiusX,
|
||||
int radiusY,
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit) {
|
||||
static std::unique_ptr<skgpu::v1::SurfaceDrawContext> two_pass_gaussian(
|
||||
GrRecordingContext* rContext,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkIRect srcBounds,
|
||||
SkIRect dstBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
int radiusX,
|
||||
int radiusY,
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit) {
|
||||
SkASSERT(radiusX || radiusY);
|
||||
std::unique_ptr<GrSurfaceDrawContext> dstSurfaceDrawContext;
|
||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> dstSDC;
|
||||
if (radiusX > 0) {
|
||||
SkBackingFit xFit = radiusY > 0 ? SkBackingFit::kApprox : fit;
|
||||
// Expand the dstBounds vertically to produce necessary content for the y-pass. Then we will
|
||||
@ -422,23 +426,23 @@ static std::unique_ptr<GrSurfaceDrawContext> two_pass_gaussian(GrRecordingContex
|
||||
}
|
||||
}
|
||||
}
|
||||
dstSurfaceDrawContext = convolve_gaussian(
|
||||
context, std::move(srcView), srcColorType, srcAlphaType, srcBounds, xPassDstBounds,
|
||||
dstSDC = convolve_gaussian(
|
||||
rContext, std::move(srcView), srcColorType, srcAlphaType, srcBounds, xPassDstBounds,
|
||||
Direction::kX, radiusX, sigmaX, mode, colorSpace, xFit);
|
||||
if (!dstSurfaceDrawContext) {
|
||||
if (!dstSDC) {
|
||||
return nullptr;
|
||||
}
|
||||
srcView = dstSurfaceDrawContext->readSurfaceView();
|
||||
srcView = dstSDC->readSurfaceView();
|
||||
SkIVector newDstBoundsOffset = dstBounds.topLeft() - xPassDstBounds.topLeft();
|
||||
dstBounds = SkIRect::MakeSize(dstBounds.size()).makeOffset(newDstBoundsOffset);
|
||||
srcBounds = SkIRect::MakeSize(xPassDstBounds.size());
|
||||
}
|
||||
|
||||
if (!radiusY) {
|
||||
return dstSurfaceDrawContext;
|
||||
return dstSDC;
|
||||
}
|
||||
|
||||
return convolve_gaussian(context, std::move(srcView), srcColorType, srcAlphaType, srcBounds,
|
||||
return convolve_gaussian(rContext, std::move(srcView), srcColorType, srcAlphaType, srcBounds,
|
||||
dstBounds, Direction::kY, radiusY, sigmaY, mode, colorSpace, fit);
|
||||
}
|
||||
#endif // SK_GPU_V1
|
||||
@ -446,25 +450,25 @@ static std::unique_ptr<GrSurfaceDrawContext> two_pass_gaussian(GrRecordingContex
|
||||
namespace SkGpuBlurUtils {
|
||||
|
||||
#if SK_GPU_V1
|
||||
std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkIRect dstBounds,
|
||||
SkIRect srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit) {
|
||||
SkASSERT(context);
|
||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> GaussianBlur(GrRecordingContext* rContext,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkIRect dstBounds,
|
||||
SkIRect srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit) {
|
||||
SkASSERT(rContext);
|
||||
TRACE_EVENT2("skia.gpu", "GaussianBlur", "sigmaX", sigmaX, "sigmaY", sigmaY);
|
||||
|
||||
if (!srcView.asTextureProxy()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int maxRenderTargetSize = context->priv().caps()->maxRenderTargetSize();
|
||||
int maxRenderTargetSize = rContext->priv().caps()->maxRenderTargetSize();
|
||||
if (dstBounds.width() > maxRenderTargetSize || dstBounds.height() > maxRenderTargetSize) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -516,10 +520,16 @@ std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
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.
|
||||
auto result = GrSurfaceDrawContext::Make(context, srcColorType, std::move(colorSpace), fit,
|
||||
dstBounds.size(), SkSurfaceProps(), 1,
|
||||
GrMipmapped::kNo,
|
||||
srcView.proxy()->isProtected(), srcView.origin());
|
||||
auto result = skgpu::v1::SurfaceDrawContext::Make(rContext,
|
||||
srcColorType,
|
||||
std::move(colorSpace),
|
||||
fit,
|
||||
dstBounds.size(),
|
||||
SkSurfaceProps(),
|
||||
1,
|
||||
GrMipmapped::kNo,
|
||||
srcView.proxy()->isProtected(),
|
||||
srcView.origin());
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -530,7 +540,7 @@ std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
sampler,
|
||||
SkRect::Make(srcBounds),
|
||||
SkRect::Make(dstBounds),
|
||||
*context->priv().caps());
|
||||
*rContext->priv().caps());
|
||||
result->fillRectToRectWithFP(dstBounds, SkIRect::MakeSize(dstBounds.size()), std::move(fp));
|
||||
return result;
|
||||
}
|
||||
@ -543,21 +553,21 @@ std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
const int kernelSize = (2 * radiusX + 1) * (2 * radiusY + 1);
|
||||
if (radiusX > 0 && radiusY > 0 &&
|
||||
kernelSize <= GrMatrixConvolutionEffect::kMaxUniformSize &&
|
||||
!context->priv().caps()->reducedShaderMode()) {
|
||||
!rContext->priv().caps()->reducedShaderMode()) {
|
||||
// Apply the proxy offset to src bounds and offset directly
|
||||
return convolve_gaussian_2d(context, std::move(srcView), srcColorType, srcBounds,
|
||||
return convolve_gaussian_2d(rContext, std::move(srcView), srcColorType, srcBounds,
|
||||
dstBounds, radiusX, radiusY, sigmaX, sigmaY, mode,
|
||||
std::move(colorSpace), fit);
|
||||
}
|
||||
// This will automatically degenerate into a single pass of X or Y if only one of the
|
||||
// radii are non-zero.
|
||||
return two_pass_gaussian(context, std::move(srcView), srcColorType, srcAlphaType,
|
||||
return two_pass_gaussian(rContext, std::move(srcView), srcColorType, srcAlphaType,
|
||||
std::move(colorSpace), srcBounds, dstBounds, sigmaX, sigmaY,
|
||||
radiusX, radiusY, mode, fit);
|
||||
}
|
||||
|
||||
GrColorInfo colorInfo(srcColorType, srcAlphaType, colorSpace);
|
||||
auto srcCtx = GrSurfaceContext::Make(context, srcView, colorInfo);
|
||||
auto srcCtx = GrSurfaceContext::Make(rContext, srcView, colorInfo);
|
||||
SkASSERT(srcCtx);
|
||||
|
||||
float scaleX = sigmaX > kMaxSigma ? kMaxSigma/sigmaX : 1.f;
|
||||
@ -596,7 +606,7 @@ std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
(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.
|
||||
auto rescaledSDC = GrSurfaceDrawContext::Make(
|
||||
auto rescaledSDC = skgpu::v1::SurfaceDrawContext::Make(
|
||||
srcCtx->recordingContext(),
|
||||
colorInfo.colorType(),
|
||||
colorInfo.refColorSpace(),
|
||||
@ -695,7 +705,7 @@ std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
auto scaledDstBoundsI = scaledDstBounds.roundOut();
|
||||
|
||||
SkIRect scaledSrcBounds = SkIRect::MakeSize(srcView.dimensions());
|
||||
auto sdc = GaussianBlur(context,
|
||||
auto sdc = GaussianBlur(rContext,
|
||||
std::move(srcView),
|
||||
srcColorType,
|
||||
srcAlphaType,
|
||||
@ -712,7 +722,7 @@ std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext* context,
|
||||
// We rounded out the integer scaled dst bounds. Select the fractional dst bounds from the
|
||||
// integer dimension blurred result when we scale back up.
|
||||
scaledDstBounds.offset(-scaledDstBoundsI.left(), -scaledDstBoundsI.top());
|
||||
return reexpand(context, std::move(sdc), scaledDstBounds, dstBounds.size(),
|
||||
return reexpand(rContext, std::move(sdc), scaledDstBounds, dstBounds.size(),
|
||||
std::move(colorSpace), fit);
|
||||
}
|
||||
#endif // SK_GPU_V1
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrSurfaceProxyView;
|
||||
class GrTexture;
|
||||
|
||||
@ -48,17 +48,18 @@ static constexpr float kMaxSigma = 4.f;
|
||||
* @param fit backing fit for the returned render target context
|
||||
* @return The surfaceDrawContext containing the blurred result.
|
||||
*/
|
||||
std::unique_ptr<GrSurfaceDrawContext> GaussianBlur(GrRecordingContext*,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
sk_sp<SkColorSpace> srcColorSpace,
|
||||
SkIRect dstBounds,
|
||||
SkIRect srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit = SkBackingFit::kApprox);
|
||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> GaussianBlur(
|
||||
GrRecordingContext*,
|
||||
GrSurfaceProxyView srcView,
|
||||
GrColorType srcColorType,
|
||||
SkAlphaType srcAlphaType,
|
||||
sk_sp<SkColorSpace> srcColorSpace,
|
||||
SkIRect dstBounds,
|
||||
SkIRect srcBounds,
|
||||
float sigmaX,
|
||||
float sigmaY,
|
||||
SkTileMode mode,
|
||||
SkBackingFit fit = SkBackingFit::kApprox);
|
||||
#endif
|
||||
|
||||
static const int kBlurRRectMaxDivisions = 6;
|
||||
|
@ -336,7 +336,7 @@ bool SkMaskFilterBase::canFilterMaskGPU(const GrStyledShape& shape,
|
||||
}
|
||||
|
||||
bool SkMaskFilterBase::directFilterMaskGPU(GrRecordingContext*,
|
||||
GrSurfaceDrawContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&&,
|
||||
const GrClip*,
|
||||
const SkMatrix& viewMatrix,
|
||||
|
@ -26,7 +26,7 @@ class GrFragmentProcessor;
|
||||
class GrPaint;
|
||||
class GrRecordingContext;
|
||||
class GrRenderTarget;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrResourceProvider;
|
||||
class GrStyledShape;
|
||||
class GrSurfaceProxyView;
|
||||
@ -114,7 +114,7 @@ public:
|
||||
* successful. If false is returned then paint is unmodified.
|
||||
*/
|
||||
virtual bool directFilterMaskGPU(GrRecordingContext*,
|
||||
GrSurfaceDrawContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&& paint,
|
||||
const GrClip*,
|
||||
const SkMatrix& viewMatrix,
|
||||
|
@ -20,10 +20,10 @@
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrColorSpaceXform.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -100,17 +100,19 @@ void SkAlphaThresholdImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
GrSurfaceProxyView SkAlphaThresholdImageFilter::createMaskTexture(
|
||||
GrRecordingContext* context, const SkMatrix& inMatrix, const SkIRect& bounds,
|
||||
GrRecordingContext* rContext,
|
||||
const SkMatrix& inMatrix,
|
||||
const SkIRect& bounds,
|
||||
const SkSurfaceProps& surfaceProps) const {
|
||||
auto rtContext = GrSurfaceDrawContext::MakeWithFallback(
|
||||
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size(),
|
||||
auto sdc = skgpu::v1::SurfaceDrawContext::MakeWithFallback(
|
||||
rContext, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size(),
|
||||
surfaceProps);
|
||||
if (!rtContext) {
|
||||
if (!sdc) {
|
||||
return {};
|
||||
}
|
||||
|
||||
SkRegion::Iterator iter(fRegion);
|
||||
rtContext->clear(SK_PMColor4fTRANSPARENT);
|
||||
sdc->clear(SK_PMColor4fTRANSPARENT);
|
||||
|
||||
while (!iter.done()) {
|
||||
GrPaint paint;
|
||||
@ -118,12 +120,12 @@ GrSurfaceProxyView SkAlphaThresholdImageFilter::createMaskTexture(
|
||||
|
||||
SkRect rect = SkRect::Make(iter.rect());
|
||||
|
||||
rtContext->drawRect(nullptr, std::move(paint), GrAA::kNo, inMatrix, rect);
|
||||
sdc->drawRect(nullptr, std::move(paint), GrAA::kNo, inMatrix, rect);
|
||||
|
||||
iter.next();
|
||||
}
|
||||
|
||||
return rtContext->readSurfaceView();
|
||||
return sdc->readSurfaceView();
|
||||
}
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> make_alpha_threshold_fp(
|
||||
|
@ -24,9 +24,9 @@
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -625,7 +625,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::gpuFilter(
|
||||
// TODO (michaelludwig) - The color space choice is odd, should it just be ctx.refColorSpace()?
|
||||
dstBounds.offset(input->subset().topLeft());
|
||||
inputBounds.offset(input->subset().topLeft());
|
||||
auto surfaceDrawContext = SkGpuBlurUtils::GaussianBlur(
|
||||
auto sdc = SkGpuBlurUtils::GaussianBlur(
|
||||
context,
|
||||
std::move(inputView),
|
||||
SkColorTypeToGrColorType(input->colorType()),
|
||||
@ -636,15 +636,15 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::gpuFilter(
|
||||
sigma.x(),
|
||||
sigma.y(),
|
||||
fTileMode);
|
||||
if (!surfaceDrawContext) {
|
||||
if (!sdc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return SkSpecialImage::MakeDeferredFromGpu(context,
|
||||
SkIRect::MakeSize(dstBounds.size()),
|
||||
kNeedNewImageUniqueID_SpecialImage,
|
||||
surfaceDrawContext->readSurfaceView(),
|
||||
surfaceDrawContext->colorInfo().colorType(),
|
||||
sdc->readSurfaceView(),
|
||||
sdc->colorInfo().colorType(),
|
||||
sk_ref_sp(input->getColorSpace()),
|
||||
ctx.surfaceProps());
|
||||
#else // SK_GPU_V1
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
@ -27,6 +26,7 @@
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
|
||||
class GrRenderTargetProxy;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrSurfaceFillContext;
|
||||
class GrSurfaceProxyView;
|
||||
|
||||
@ -50,8 +50,7 @@ public:
|
||||
BaseDevice* asGpuDevice() override { return this; }
|
||||
|
||||
#if SK_GPU_V1
|
||||
// TODO: make this return a skgpu::v1:SurfaceDrawContext
|
||||
virtual GrSurfaceDrawContext* surfaceDrawContext() { return nullptr; }
|
||||
virtual skgpu::v1::SurfaceDrawContext* surfaceDrawContext() { return nullptr; }
|
||||
#endif
|
||||
|
||||
virtual GrSurfaceFillContext* surfaceFillContext() = 0;
|
||||
|
@ -17,11 +17,11 @@
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrResourceProviderPriv.h"
|
||||
#include "src/gpu/GrSemaphore.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrTextureProxyPriv.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/gl/GrGLTexture.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
GrBackendTextureImageGenerator::RefHelper::RefHelper(
|
||||
GrTexture* texture,
|
||||
|
@ -18,13 +18,13 @@
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/GrThreadSafeCache.h"
|
||||
#include "src/gpu/GrUtil.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "src/core/SkDraw.h"
|
||||
@ -42,7 +42,7 @@ static constexpr auto kMaskOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
// Draw a mask using the supplied paint. Since the coverage/geometry
|
||||
// is already burnt into the mask this boils down to a rect draw.
|
||||
// Return true if the mask was successfully drawn.
|
||||
static bool draw_mask(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
static bool draw_mask(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkIRect& maskBounds,
|
||||
@ -61,7 +61,7 @@ static bool draw_mask(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
paint.setCoverageFragmentProcessor(
|
||||
GrTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix));
|
||||
|
||||
surfaceDrawContext->fillPixelsWithLocalMatrix(clip, std::move(paint), maskBounds, inverse);
|
||||
sdc->fillPixelsWithLocalMatrix(clip, std::move(paint), maskBounds, inverse);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -185,11 +185,12 @@ static GrSurfaceProxyView sw_create_filtered_mask(GrRecordingContext* rContext,
|
||||
}
|
||||
|
||||
// Create a mask of 'shape' and return the resulting surfaceDrawContext
|
||||
static std::unique_ptr<GrSurfaceDrawContext> create_mask_GPU(GrRecordingContext* context,
|
||||
const SkIRect& maskRect,
|
||||
const SkMatrix& origViewMatrix,
|
||||
const GrStyledShape& shape,
|
||||
int sampleCnt) {
|
||||
static std::unique_ptr<skgpu::v1::SurfaceDrawContext> create_mask_GPU(
|
||||
GrRecordingContext* rContext,
|
||||
const SkIRect& maskRect,
|
||||
const SkMatrix& origViewMatrix,
|
||||
const GrStyledShape& shape,
|
||||
int sampleCnt) {
|
||||
// We cache blur masks. Use default surface props here so we can use the same cached mask
|
||||
// regardless of the final dst surface.
|
||||
SkSurfaceProps defaultSurfaceProps;
|
||||
@ -204,29 +205,34 @@ static std::unique_ptr<GrSurfaceDrawContext> create_mask_GPU(GrRecordingContext*
|
||||
// the same. We should offset our filter within the render target and expand the size as needed
|
||||
// to guarantee at least 1px of padding on all sides.
|
||||
auto approxSize = GrResourceProvider::MakeApprox(maskRect.size());
|
||||
auto rtContext = GrSurfaceDrawContext::MakeWithFallback(context, GrColorType::kAlpha_8, nullptr,
|
||||
SkBackingFit::kExact, approxSize,
|
||||
defaultSurfaceProps, sampleCnt,
|
||||
GrMipmapped::kNo, GrProtected::kNo,
|
||||
kMaskOrigin);
|
||||
if (!rtContext) {
|
||||
auto sdc = skgpu::v1::SurfaceDrawContext::MakeWithFallback(rContext,
|
||||
GrColorType::kAlpha_8,
|
||||
nullptr,
|
||||
SkBackingFit::kExact,
|
||||
approxSize,
|
||||
defaultSurfaceProps,
|
||||
sampleCnt,
|
||||
GrMipmapped::kNo,
|
||||
GrProtected::kNo,
|
||||
kMaskOrigin);
|
||||
if (!sdc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rtContext->clear(SK_PMColor4fTRANSPARENT);
|
||||
sdc->clear(SK_PMColor4fTRANSPARENT);
|
||||
|
||||
GrPaint maskPaint;
|
||||
maskPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
|
||||
|
||||
// setup new clip
|
||||
GrFixedClip clip(rtContext->dimensions(), SkIRect::MakeWH(maskRect.width(), maskRect.height()));
|
||||
GrFixedClip clip(sdc->dimensions(), SkIRect::MakeWH(maskRect.width(), maskRect.height()));
|
||||
|
||||
// Draw the mask into maskTexture with the path's integerized top-left at the origin using
|
||||
// maskPaint.
|
||||
SkMatrix viewMatrix = origViewMatrix;
|
||||
viewMatrix.postTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
|
||||
rtContext->drawShape(&clip, std::move(maskPaint), GrAA::kYes, viewMatrix, GrStyledShape(shape));
|
||||
return rtContext;
|
||||
sdc->drawShape(&clip, std::move(maskPaint), GrAA::kYes, viewMatrix, GrStyledShape(shape));
|
||||
return sdc;
|
||||
}
|
||||
|
||||
static bool get_unclipped_shape_dev_bounds(const GrStyledShape& shape, const SkMatrix& matrix,
|
||||
@ -256,7 +262,7 @@ static bool get_unclipped_shape_dev_bounds(const GrStyledShape& shape, const SkM
|
||||
|
||||
// Gets the shape bounds, the clip bounds, and the intersection (if any). Returns false if there
|
||||
// is no intersection.
|
||||
static bool get_shape_and_clip_bounds(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
static bool get_shape_and_clip_bounds(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
const GrStyledShape& shape,
|
||||
const SkMatrix& matrix,
|
||||
@ -264,8 +270,7 @@ static bool get_shape_and_clip_bounds(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
SkIRect* devClipBounds) {
|
||||
// compute bounds as intersection of rt size, clip, and path
|
||||
*devClipBounds = clip ? clip->getConservativeBounds()
|
||||
: SkIRect::MakeWH(surfaceDrawContext->width(),
|
||||
surfaceDrawContext->height());
|
||||
: SkIRect::MakeWH(sdc->width(), sdc->height());
|
||||
|
||||
if (!get_unclipped_shape_dev_bounds(shape, matrix, unclippedDevShapeBounds)) {
|
||||
*unclippedDevShapeBounds = SkIRect::MakeEmpty();
|
||||
@ -363,7 +368,7 @@ static bool compute_key_and_clip_bounds(GrUniqueKey* maskKey,
|
||||
}
|
||||
|
||||
static GrSurfaceProxyView hw_create_filtered_mask(GrDirectContext* dContext,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrStyledShape& shape,
|
||||
const SkMaskFilterBase* filter,
|
||||
@ -412,13 +417,12 @@ static GrSurfaceProxyView hw_create_filtered_mask(GrDirectContext* dContext,
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceDrawContext> maskRTC(create_mask_GPU(
|
||||
dContext,
|
||||
*maskRect,
|
||||
viewMatrix,
|
||||
shape,
|
||||
surfaceDrawContext->numSamples()));
|
||||
if (!maskRTC) {
|
||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> maskSDC(create_mask_GPU(dContext,
|
||||
*maskRect,
|
||||
viewMatrix,
|
||||
shape,
|
||||
sdc->numSamples()));
|
||||
if (!maskSDC) {
|
||||
if (key->isValid()) {
|
||||
// It is very unlikely that 'create_mask_GPU' will fail after 'CreateLazyView'
|
||||
// succeeded but, if it does, remove the lazy-view from the cache and fallback to
|
||||
@ -430,9 +434,9 @@ static GrSurfaceProxyView hw_create_filtered_mask(GrDirectContext* dContext,
|
||||
}
|
||||
|
||||
auto filteredMaskView = filter->filterMaskGPU(dContext,
|
||||
maskRTC->readSurfaceView(),
|
||||
maskRTC->colorInfo().colorType(),
|
||||
maskRTC->colorInfo().alphaType(),
|
||||
maskSDC->readSurfaceView(),
|
||||
maskSDC->colorInfo().colorType(),
|
||||
maskSDC->colorInfo().alphaType(),
|
||||
viewMatrix,
|
||||
*maskRect);
|
||||
if (!filteredMaskView) {
|
||||
@ -458,7 +462,7 @@ static GrSurfaceProxyView hw_create_filtered_mask(GrDirectContext* dContext,
|
||||
}
|
||||
|
||||
static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
GrPaint&& paint,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -483,7 +487,7 @@ static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
shape = tmpShape.get();
|
||||
}
|
||||
|
||||
if (maskFilter->directFilterMaskGPU(rContext, surfaceDrawContext, std::move(paint), clip,
|
||||
if (maskFilter->directFilterMaskGPU(rContext, sdc, std::move(paint), clip,
|
||||
viewMatrix, *shape)) {
|
||||
// the mask filter was able to draw itself directly, so there's nothing
|
||||
// left to do.
|
||||
@ -496,7 +500,7 @@ static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
!GrIsStrokeHairlineOrEquivalent(shape->style(), viewMatrix, nullptr);
|
||||
|
||||
SkIRect unclippedDevShapeBounds, devClipBounds;
|
||||
if (!get_shape_and_clip_bounds(surfaceDrawContext, clip, *shape, viewMatrix,
|
||||
if (!get_shape_and_clip_bounds(sdc, clip, *shape, viewMatrix,
|
||||
&unclippedDevShapeBounds, &devClipBounds)) {
|
||||
// TODO: just cons up an opaque mask here
|
||||
if (!inverseFilled) {
|
||||
@ -507,7 +511,7 @@ static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
GrUniqueKey maskKey;
|
||||
SkIRect boundsForClip;
|
||||
if (!compute_key_and_clip_bounds(&maskKey, &boundsForClip,
|
||||
surfaceDrawContext->caps(),
|
||||
sdc->caps(),
|
||||
viewMatrix, inverseFilled,
|
||||
maskFilter, *shape,
|
||||
unclippedDevShapeBounds,
|
||||
@ -519,12 +523,12 @@ static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
SkIRect maskRect;
|
||||
|
||||
if (auto dContext = rContext->asDirectContext()) {
|
||||
filteredMaskView = hw_create_filtered_mask(dContext, surfaceDrawContext,
|
||||
filteredMaskView = hw_create_filtered_mask(dContext, sdc,
|
||||
viewMatrix, *shape, maskFilter,
|
||||
unclippedDevShapeBounds, boundsForClip,
|
||||
&maskRect, &maskKey);
|
||||
if (filteredMaskView) {
|
||||
if (draw_mask(surfaceDrawContext, clip, viewMatrix, maskRect, std::move(paint),
|
||||
if (draw_mask(sdc, clip, viewMatrix, maskRect, std::move(paint),
|
||||
std::move(filteredMaskView))) {
|
||||
// This path is completely drawn
|
||||
return;
|
||||
@ -539,7 +543,7 @@ static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
unclippedDevShapeBounds, boundsForClip,
|
||||
&maskRect, &maskKey);
|
||||
if (filteredMaskView) {
|
||||
if (draw_mask(surfaceDrawContext, clip, viewMatrix, maskRect, std::move(paint),
|
||||
if (draw_mask(sdc, clip, viewMatrix, maskRect, std::move(paint),
|
||||
std::move(filteredMaskView))) {
|
||||
return;
|
||||
}
|
||||
@ -547,30 +551,29 @@ static void draw_shape_with_mask_filter(GrRecordingContext* rContext,
|
||||
}
|
||||
}
|
||||
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
const GrStyledShape& shape,
|
||||
GrPaint&& paint,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMaskFilter* mf) {
|
||||
draw_shape_with_mask_filter(context, surfaceDrawContext, clip, std::move(paint),
|
||||
draw_shape_with_mask_filter(rContext, sdc, clip, std::move(paint),
|
||||
viewMatrix, as_MFB(mf), shape);
|
||||
}
|
||||
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
const SkPaint& paint,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
const GrStyledShape& shape) {
|
||||
if (context->abandoned()) {
|
||||
if (rContext->abandoned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GrPaint grPaint;
|
||||
if (!SkPaintToGrPaint(context, surfaceDrawContext->colorInfo(), paint, matrixProvider,
|
||||
&grPaint)) {
|
||||
if (!SkPaintToGrPaint(rContext, sdc->colorInfo(), paint, matrixProvider, &grPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -578,31 +581,30 @@ void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* context,
|
||||
SkMaskFilterBase* mf = as_MFB(paint.getMaskFilter());
|
||||
if (mf && !mf->hasFragmentProcessor()) {
|
||||
// The MaskFilter wasn't already handled in SkPaintToGrPaint
|
||||
draw_shape_with_mask_filter(context, surfaceDrawContext, clip, std::move(grPaint),
|
||||
viewMatrix, mf, shape);
|
||||
draw_shape_with_mask_filter(rContext, sdc, clip, std::move(grPaint), viewMatrix, mf, shape);
|
||||
} else {
|
||||
surfaceDrawContext->drawShape(clip, std::move(grPaint), surfaceDrawContext->chooseAA(paint),
|
||||
viewMatrix, GrStyledShape(shape));
|
||||
sdc->drawShape(clip, std::move(grPaint), sdc->chooseAA(paint), viewMatrix,
|
||||
GrStyledShape(shape));
|
||||
}
|
||||
}
|
||||
|
||||
#else // SK_GPU_V1
|
||||
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
const GrClip* clip,
|
||||
const GrStyledShape& shape,
|
||||
GrPaint&& paint,
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
const GrClip*,
|
||||
const GrStyledShape&,
|
||||
GrPaint&&,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMaskFilter* mf) {
|
||||
const SkMaskFilter*) {
|
||||
}
|
||||
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
const GrClip* clip,
|
||||
const SkPaint& paint,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
const GrStyledShape& shape) {
|
||||
void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
const GrClip*,
|
||||
const SkPaint&,
|
||||
const SkMatrixProvider&,
|
||||
const GrStyledShape&) {
|
||||
}
|
||||
|
||||
#endif // SK_GPU_V1
|
||||
|
@ -14,7 +14,7 @@ class GrClip;
|
||||
class GrPaint;
|
||||
class GrRecordingContext;
|
||||
class GrRenderTarget;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrStyledShape;
|
||||
class GrStyle;
|
||||
struct SkIRect;
|
||||
@ -34,7 +34,7 @@ namespace GrBlurUtils {
|
||||
* Draw a shape handling the mask filter if present.
|
||||
*/
|
||||
void drawShapeWithMaskFilter(GrRecordingContext*,
|
||||
GrSurfaceDrawContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
const GrClip*,
|
||||
const SkPaint&,
|
||||
const SkMatrixProvider&,
|
||||
@ -45,7 +45,7 @@ namespace GrBlurUtils {
|
||||
* The GrPaint will be modified after return.
|
||||
*/
|
||||
void drawShapeWithMaskFilter(GrRecordingContext*,
|
||||
GrSurfaceDrawContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
const GrClip*,
|
||||
const GrStyledShape&,
|
||||
GrPaint&&,
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/GrAppliedClip.h"
|
||||
|
||||
class GrDrawOp;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
|
||||
/**
|
||||
* GrClip is an abstract base class for applying a clip. It constructs a clip mask if necessary, and
|
||||
@ -64,7 +64,7 @@ public:
|
||||
* clips). If kNoDraw is returned, 'bounds' and the applied clip are in an undetermined state
|
||||
* and should be ignored (and the draw should be skipped).
|
||||
*/
|
||||
virtual Effect apply(GrRecordingContext*, GrSurfaceDrawContext*, GrDrawOp*, GrAAType,
|
||||
virtual Effect apply(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*, GrDrawOp*, GrAAType,
|
||||
GrAppliedClip*, SkRect* bounds) const = 0;
|
||||
|
||||
/**
|
||||
@ -245,8 +245,12 @@ public:
|
||||
virtual Effect apply(GrAppliedHardClip* out, SkIRect* bounds) const = 0;
|
||||
|
||||
private:
|
||||
Effect apply(GrRecordingContext*, GrSurfaceDrawContext* rtc, GrDrawOp*, GrAAType aa,
|
||||
GrAppliedClip* out, SkRect* bounds) const final {
|
||||
Effect apply(GrRecordingContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
GrDrawOp*,
|
||||
GrAAType aa,
|
||||
GrAppliedClip* out,
|
||||
SkRect* bounds) const final {
|
||||
SkIRect pixelBounds = GetPixelIBounds(*bounds, GrAA(aa != GrAAType::kNone));
|
||||
Effect effect = this->apply(&out->hardClip(), &pixelBounds);
|
||||
bounds->intersect(SkRect::Make(pixelBounds));
|
||||
|
@ -21,13 +21,13 @@
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSWMaskHelper.h"
|
||||
#include "src/gpu/GrStencilMaskHelper.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrConvexPolyEffect.h"
|
||||
#include "src/gpu/effects/GrRRectEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/geometry/GrQuadUtils.h"
|
||||
#include "src/gpu/ops/GrAtlasPathRenderer.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -236,7 +236,7 @@ static GrFPResult analytic_clip_fp(const GrClipStack::Element& e,
|
||||
// TODO: Currently this only works with tessellation because the tessellation path renderer owns and
|
||||
// manages the atlas. The high-level concept could be generalized to support any path renderer going
|
||||
// into a shared atlas.
|
||||
static GrFPResult clip_atlas_fp(const GrSurfaceDrawContext* sdc,
|
||||
static GrFPResult clip_atlas_fp(const skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrOp* opBeingClipped,
|
||||
GrAtlasPathRenderer* atlasPathRenderer,
|
||||
const SkIRect& scissorBounds,
|
||||
@ -364,11 +364,14 @@ static GrSurfaceProxyView render_sw_mask(GrRecordingContext* context, const SkIR
|
||||
}
|
||||
}
|
||||
|
||||
static void render_stencil_mask(GrRecordingContext* context, GrSurfaceDrawContext* rtc,
|
||||
uint32_t genID, const SkIRect& bounds,
|
||||
const GrClipStack::Element** elements, int count,
|
||||
static void render_stencil_mask(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
uint32_t genID,
|
||||
const SkIRect& bounds,
|
||||
const GrClipStack::Element** elements,
|
||||
int count,
|
||||
GrAppliedClip* out) {
|
||||
GrStencilMaskHelper helper(context, rtc);
|
||||
GrStencilMaskHelper helper(rContext, sdc);
|
||||
if (helper.init(bounds, genID, out->windowRectsState().windows(), 0)) {
|
||||
// This follows the same logic as in draw_sw_mask
|
||||
bool startInside = elements[0]->fOp == SkClipOp::kDifference;
|
||||
@ -1244,15 +1247,18 @@ GrClip::PreClipResult GrClipStack::preApply(const SkRect& bounds, GrAA aa) const
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawContext* sdc,
|
||||
GrDrawOp* op, GrAAType aa, GrAppliedClip* out,
|
||||
GrClip::Effect GrClipStack::apply(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrDrawOp* op,
|
||||
GrAAType aa,
|
||||
GrAppliedClip* out,
|
||||
SkRect* bounds) const {
|
||||
// TODO: Once we no longer store SW masks, we don't need to sneak the provider in like this
|
||||
if (!fProxyProvider) {
|
||||
fProxyProvider = context->priv().proxyProvider();
|
||||
fProxyProvider = rContext->priv().proxyProvider();
|
||||
}
|
||||
SkASSERT(fProxyProvider == context->priv().proxyProvider());
|
||||
const GrCaps* caps = context->priv().caps();
|
||||
SkASSERT(fProxyProvider == rContext->priv().proxyProvider());
|
||||
const GrCaps* caps = rContext->priv().caps();
|
||||
|
||||
// Convert the bounds to a Draw and apply device bounds clipping, making our query as tight
|
||||
// as possible.
|
||||
@ -1276,7 +1282,7 @@ GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawCont
|
||||
if (cs.shader()) {
|
||||
static const GrColorInfo kCoverageColorInfo{GrColorType::kUnknown, kPremul_SkAlphaType,
|
||||
nullptr};
|
||||
GrFPArgs args(context, *fMatrixProvider, &kCoverageColorInfo);
|
||||
GrFPArgs args(rContext, *fMatrixProvider, &kCoverageColorInfo);
|
||||
clipFP = as_SB(cs.shader())->asFragmentProcessor(args);
|
||||
if (clipFP) {
|
||||
// The initial input is the coverage from the geometry processor, so this ensures it
|
||||
@ -1342,7 +1348,7 @@ GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawCont
|
||||
SkSTArray<kNumStackMasks, const Element*> elementsForMask;
|
||||
|
||||
bool maskRequiresAA = false;
|
||||
auto* atlasPathRenderer = context->priv().drawingManager()->getAtlasPathRenderer();
|
||||
auto* atlasPathRenderer = rContext->priv().drawingManager()->getAtlasPathRenderer();
|
||||
|
||||
int i = fElements.count();
|
||||
for (const RawElement& e : fElements.ritems()) {
|
||||
@ -1415,7 +1421,8 @@ GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawCont
|
||||
*caps->shaderCaps(),
|
||||
std::move(clipFP));
|
||||
if (!fullyApplied && atlasPathRenderer) {
|
||||
std::tie(fullyApplied, clipFP) = clip_atlas_fp(sdc, op, atlasPathRenderer,
|
||||
std::tie(fullyApplied, clipFP) = clip_atlas_fp(sdc, op,
|
||||
atlasPathRenderer,
|
||||
scissorBounds, e.asElement(),
|
||||
std::move(clipFP));
|
||||
}
|
||||
@ -1455,7 +1462,7 @@ GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawCont
|
||||
// flattened into a single mask.
|
||||
if (!elementsForMask.empty()) {
|
||||
bool stencilUnavailable =
|
||||
!sdc->asRenderTargetProxy()->canUseStencil(*context->priv().caps());
|
||||
!sdc->asRenderTargetProxy()->canUseStencil(*rContext->priv().caps());
|
||||
|
||||
bool hasSWMask = false;
|
||||
if ((sdc->numSamples() <= 1 && !sdc->canUseDynamicMSAA() && maskRequiresAA) ||
|
||||
@ -1463,8 +1470,8 @@ GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawCont
|
||||
// Must use a texture mask to represent the combined clip elements since the stencil
|
||||
// cannot be used, or cannot handle smooth clips.
|
||||
std::tie(hasSWMask, clipFP) = GetSWMaskFP(
|
||||
context, &fMasks, cs, scissorBounds, elementsForMask.begin(),
|
||||
elementsForMask.count(), std::move(clipFP));
|
||||
rContext, &fMasks, cs, scissorBounds, elementsForMask.begin(),
|
||||
elementsForMask.count(), std::move(clipFP));
|
||||
}
|
||||
|
||||
if (!hasSWMask) {
|
||||
@ -1474,7 +1481,7 @@ GrClip::Effect GrClipStack::apply(GrRecordingContext* context, GrSurfaceDrawCont
|
||||
return Effect::kClippedOut;
|
||||
} else {
|
||||
// Rasterize the remaining elements to the stencil buffer
|
||||
render_stencil_mask(context, sdc, cs.genID(), scissorBounds,
|
||||
render_stencil_mask(rContext, sdc, cs.genID(), scissorBounds,
|
||||
elementsForMask.begin(), elementsForMask.count(), out);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
class GrAppliedClip;
|
||||
class GrProxyProvider;
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrSWMaskHelper;
|
||||
class SkMatrixProvider;
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
void replaceClip(const SkIRect& rect);
|
||||
|
||||
// GrClip implementation
|
||||
GrClip::Effect apply(GrRecordingContext*, GrSurfaceDrawContext*, GrDrawOp*, GrAAType aa,
|
||||
GrClip::Effect apply(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*, GrDrawOp*, GrAAType,
|
||||
GrAppliedClip*, SkRect* bounds) const override;
|
||||
GrClip::PreClipResult preApply(const SkRect& drawBounds, GrAA aa) const override;
|
||||
SkIRect getConservativeBounds() const override;
|
||||
|
@ -22,12 +22,12 @@
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSWMaskHelper.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrRRectEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
typedef SkClipStack::Element Element;
|
||||
typedef GrReducedClip::InitialState InitialState;
|
||||
@ -92,9 +92,9 @@ static std::unique_ptr<GrFragmentProcessor> create_fp_for_mask(GrSurfaceProxyVie
|
||||
* will be used on any element. If so, it returns true to indicate that the
|
||||
* entire clip should be rendered in SW and then uploaded en masse to the gpu.
|
||||
*/
|
||||
bool GrClipStackClip::UseSWOnlyPath(GrRecordingContext* context,
|
||||
const GrSurfaceDrawContext* surfaceDrawContext,
|
||||
const GrReducedClip& reducedClip) {
|
||||
bool GrClipStackClip::UseSWOnlyPath(GrRecordingContext*,
|
||||
const skgpu::v1::SurfaceDrawContext*,
|
||||
const GrReducedClip& /* reducedClip */) {
|
||||
// TODO: right now it appears that GPU clip masks are strictly slower than software. We may
|
||||
// want to revisit this assumption once we can test with render target sorting.
|
||||
return true;
|
||||
@ -103,11 +103,14 @@ bool GrClipStackClip::UseSWOnlyPath(GrRecordingContext* context,
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// sort out what kind of clip mask needs to be created: alpha, stencil,
|
||||
// scissor, or entirely software
|
||||
GrClip::Effect GrClipStackClip::apply(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext, GrDrawOp*,
|
||||
GrAAType aa, GrAppliedClip* out, SkRect* bounds) const {
|
||||
SkASSERT(surfaceDrawContext->width() == fDeviceSize.fWidth &&
|
||||
surfaceDrawContext->height() == fDeviceSize.fHeight);
|
||||
GrClip::Effect GrClipStackClip::apply(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrDrawOp*,
|
||||
GrAAType aa,
|
||||
GrAppliedClip* out,
|
||||
SkRect* bounds) const {
|
||||
SkASSERT(sdc->width() == fDeviceSize.fWidth &&
|
||||
sdc->height() == fDeviceSize.fHeight);
|
||||
SkRect devBounds = SkRect::MakeIWH(fDeviceSize.fWidth, fDeviceSize.fHeight);
|
||||
if (!devBounds.intersect(*bounds)) {
|
||||
return Effect::kClippedOut;
|
||||
@ -125,16 +128,16 @@ GrClip::Effect GrClipStackClip::apply(GrRecordingContext* context,
|
||||
// when drawing rounded div borders.
|
||||
constexpr int kMaxAnalyticElements = 4;
|
||||
|
||||
int maxWindowRectangles = surfaceDrawContext->maxWindowRectangles();
|
||||
int maxWindowRectangles = sdc->maxWindowRectangles();
|
||||
int maxAnalyticElements = kMaxAnalyticElements;
|
||||
if (surfaceDrawContext->numSamples() > 1 || aa == GrAAType::kMSAA) {
|
||||
if (sdc->numSamples() > 1 || aa == GrAAType::kMSAA) {
|
||||
// Disable analytic clips when we have MSAA. In MSAA we never conflate coverage and opacity.
|
||||
maxAnalyticElements = 0;
|
||||
// We disable MSAA when stencil isn't supported.
|
||||
SkASSERT(surfaceDrawContext->asRenderTargetProxy()->canUseStencil(*context->priv().caps()));
|
||||
SkASSERT(sdc->asRenderTargetProxy()->canUseStencil(*rContext->priv().caps()));
|
||||
}
|
||||
|
||||
GrReducedClip reducedClip(*fStack, devBounds, context->priv().caps(), maxWindowRectangles,
|
||||
GrReducedClip reducedClip(*fStack, devBounds, rContext->priv().caps(), maxWindowRectangles,
|
||||
maxAnalyticElements);
|
||||
if (InitialState::kAllOut == reducedClip.initialState() &&
|
||||
reducedClip.maskElements().isEmpty()) {
|
||||
@ -154,7 +157,7 @@ GrClip::Effect GrClipStackClip::apply(GrRecordingContext* context,
|
||||
}
|
||||
|
||||
if (!reducedClip.maskElements().isEmpty()) {
|
||||
if (!this->applyClipMask(context, surfaceDrawContext, reducedClip, out)) {
|
||||
if (!this->applyClipMask(rContext, sdc, reducedClip, out)) {
|
||||
return Effect::kClippedOut;
|
||||
}
|
||||
effect = Effect::kClipped;
|
||||
@ -162,8 +165,9 @@ GrClip::Effect GrClipStackClip::apply(GrRecordingContext* context,
|
||||
|
||||
// The opsTask ID must not be looked up until AFTER producing the clip mask (if any). That step
|
||||
// can cause a flush or otherwise change which opstask our draw is going into.
|
||||
uint32_t opsTaskID = surfaceDrawContext->getOpsTask()->uniqueID();
|
||||
auto [success, clipFPs] = reducedClip.finishAndDetachAnalyticElements(context, *fMatrixProvider,
|
||||
uint32_t opsTaskID = sdc->getOpsTask()->uniqueID();
|
||||
auto [success, clipFPs] = reducedClip.finishAndDetachAnalyticElements(rContext,
|
||||
*fMatrixProvider,
|
||||
opsTaskID);
|
||||
if (success) {
|
||||
out->addCoverageFP(std::move(clipFPs));
|
||||
@ -175,46 +179,46 @@ GrClip::Effect GrClipStackClip::apply(GrRecordingContext* context,
|
||||
return effect;
|
||||
}
|
||||
|
||||
bool GrClipStackClip::applyClipMask(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
const GrReducedClip& reducedClip, GrAppliedClip* out) const {
|
||||
bool GrClipStackClip::applyClipMask(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrReducedClip& reducedClip,
|
||||
GrAppliedClip* out) const {
|
||||
#ifdef SK_DEBUG
|
||||
SkASSERT(reducedClip.hasScissor());
|
||||
SkIRect rtIBounds = SkIRect::MakeWH(surfaceDrawContext->width(),
|
||||
surfaceDrawContext->height());
|
||||
SkIRect rtIBounds = SkIRect::MakeWH(sdc->width(), sdc->height());
|
||||
const SkIRect& scissor = reducedClip.scissor();
|
||||
SkASSERT(rtIBounds.contains(scissor)); // Mask shouldn't be larger than the RT.
|
||||
#endif
|
||||
|
||||
if ((surfaceDrawContext->numSamples() <= 1 && reducedClip.maskRequiresAA()) ||
|
||||
!surfaceDrawContext->asRenderTargetProxy()->canUseStencil(*context->priv().caps())) {
|
||||
if ((sdc->numSamples() <= 1 && reducedClip.maskRequiresAA()) ||
|
||||
!sdc->asRenderTargetProxy()->canUseStencil(*rContext->priv().caps())) {
|
||||
GrSurfaceProxyView result;
|
||||
if (UseSWOnlyPath(context, surfaceDrawContext, reducedClip)) {
|
||||
if (UseSWOnlyPath(rContext, sdc, reducedClip)) {
|
||||
// The clip geometry is complex enough that it will be more efficient to create it
|
||||
// entirely in software
|
||||
result = this->createSoftwareClipMask(context, reducedClip, surfaceDrawContext);
|
||||
result = this->createSoftwareClipMask(rContext, reducedClip, sdc);
|
||||
} else {
|
||||
result = this->createAlphaClipMask(context, reducedClip);
|
||||
result = this->createAlphaClipMask(rContext, reducedClip);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// The mask's top left coord should be pinned to the rounded-out top left corner of
|
||||
// the clip's device space bounds.
|
||||
out->addCoverageFP(create_fp_for_mask(std::move(result), reducedClip.scissor(),
|
||||
*context->priv().caps()));
|
||||
*rContext->priv().caps()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// If alpha or software clip mask creation fails, fall through to the stencil code paths,
|
||||
// unless stencils are disallowed.
|
||||
if (!surfaceDrawContext->asRenderTargetProxy()->canUseStencil(*context->priv().caps())) {
|
||||
if (!sdc->asRenderTargetProxy()->canUseStencil(*rContext->priv().caps())) {
|
||||
SkDebugf("WARNING: Clip mask requires stencil, but stencil unavailable. "
|
||||
"Clip will be ignored.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
reducedClip.drawStencilClipMask(context, surfaceDrawContext);
|
||||
reducedClip.drawStencilClipMask(rContext, sdc);
|
||||
out->hardClip().addStencilClip(reducedClip.maskGenID());
|
||||
return true;
|
||||
}
|
||||
@ -256,37 +260,37 @@ static GrSurfaceProxyView find_mask(GrProxyProvider* provider, const GrUniqueKey
|
||||
1);
|
||||
}
|
||||
|
||||
GrSurfaceProxyView GrClipStackClip::createAlphaClipMask(GrRecordingContext* context,
|
||||
GrSurfaceProxyView GrClipStackClip::createAlphaClipMask(GrRecordingContext* rContext,
|
||||
const GrReducedClip& reducedClip) const {
|
||||
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
||||
GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
|
||||
GrUniqueKey key;
|
||||
create_clip_mask_key(reducedClip.maskGenID(), reducedClip.scissor(),
|
||||
reducedClip.numAnalyticElements(), &key);
|
||||
|
||||
if (auto cachedView = find_mask(context->priv().proxyProvider(), key)) {
|
||||
if (auto cachedView = find_mask(rContext->priv().proxyProvider(), key)) {
|
||||
return cachedView;
|
||||
}
|
||||
|
||||
auto rtc = GrSurfaceDrawContext::MakeWithFallback(
|
||||
context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox,
|
||||
auto sdc = skgpu::v1::SurfaceDrawContext::MakeWithFallback(
|
||||
rContext, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox,
|
||||
{reducedClip.width(), reducedClip.height()}, SkSurfaceProps(), 1, GrMipmapped::kNo,
|
||||
GrProtected::kNo, kMaskOrigin);
|
||||
if (!rtc) {
|
||||
if (!sdc) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!reducedClip.drawAlphaClipMask(rtc.get())) {
|
||||
if (!reducedClip.drawAlphaClipMask(sdc.get())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
GrSurfaceProxyView result = rtc->readSurfaceView();
|
||||
GrSurfaceProxyView result = sdc->readSurfaceView();
|
||||
if (!result || !result.asTextureProxy()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
SkASSERT(result.origin() == kMaskOrigin);
|
||||
proxyProvider->assignUniqueKeyToProxy(key, result.asTextureProxy());
|
||||
add_invalidate_on_pop_message(context, *fStack, reducedClip.maskGenID(), key);
|
||||
add_invalidate_on_pop_message(rContext, *fStack, reducedClip.maskGenID(), key);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -366,13 +370,14 @@ static void draw_clip_elements_to_mask_helper(GrSWMaskHelper& helper, const Elem
|
||||
}
|
||||
|
||||
GrSurfaceProxyView GrClipStackClip::createSoftwareClipMask(
|
||||
GrRecordingContext* context, const GrReducedClip& reducedClip,
|
||||
GrSurfaceDrawContext* surfaceDrawContext) const {
|
||||
GrRecordingContext* rContext,
|
||||
const GrReducedClip& reducedClip,
|
||||
skgpu::v1::SurfaceDrawContext* sdc) const {
|
||||
GrUniqueKey key;
|
||||
create_clip_mask_key(reducedClip.maskGenID(), reducedClip.scissor(),
|
||||
reducedClip.numAnalyticElements(), &key);
|
||||
|
||||
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
||||
GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
|
||||
|
||||
if (auto cachedView = find_mask(proxyProvider, key)) {
|
||||
return cachedView;
|
||||
@ -383,18 +388,18 @@ GrSurfaceProxyView GrClipStackClip::createSoftwareClipMask(
|
||||
SkIRect maskSpaceIBounds = SkIRect::MakeWH(reducedClip.width(), reducedClip.height());
|
||||
|
||||
SkTaskGroup* taskGroup = nullptr;
|
||||
if (auto direct = context->asDirectContext()) {
|
||||
if (auto direct = rContext->asDirectContext()) {
|
||||
taskGroup = direct->priv().getTaskGroup();
|
||||
}
|
||||
|
||||
GrSurfaceProxyView view;
|
||||
if (taskGroup && surfaceDrawContext) {
|
||||
const GrCaps* caps = context->priv().caps();
|
||||
if (taskGroup && sdc) {
|
||||
const GrCaps* caps = rContext->priv().caps();
|
||||
// Create our texture proxy
|
||||
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kAlpha_8,
|
||||
GrRenderable::kNo);
|
||||
|
||||
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kAlpha_8);
|
||||
GrSwizzle swizzle = rContext->priv().caps()->getReadSwizzle(format, GrColorType::kAlpha_8);
|
||||
|
||||
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt
|
||||
// to ops), so it can't have any pending IO.
|
||||
@ -435,12 +440,12 @@ GrSurfaceProxyView GrClipStackClip::createSoftwareClipMask(
|
||||
draw_clip_elements_to_mask_helper(helper, reducedClip.maskElements(), reducedClip.scissor(),
|
||||
reducedClip.initialState());
|
||||
|
||||
view = helper.toTextureView(context, SkBackingFit::kApprox);
|
||||
view = helper.toTextureView(rContext, SkBackingFit::kApprox);
|
||||
}
|
||||
|
||||
SkASSERT(view);
|
||||
SkASSERT(view.origin() == kMaskOrigin);
|
||||
proxyProvider->assignUniqueKeyToProxy(key, view.asTextureProxy());
|
||||
add_invalidate_on_pop_message(context, *fStack, reducedClip.maskGenID(), key);
|
||||
add_invalidate_on_pop_message(rContext, *fStack, reducedClip.maskGenID(), key);
|
||||
return view;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
, fMatrixProvider(matrixProvider) {}
|
||||
|
||||
SkIRect getConservativeBounds() const final;
|
||||
Effect apply(GrRecordingContext*, GrSurfaceDrawContext*, GrDrawOp*, GrAAType aaType,
|
||||
Effect apply(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*, GrDrawOp*, GrAAType aaType,
|
||||
GrAppliedClip* out, SkRect* bounds) const final;
|
||||
PreClipResult preApply(const SkRect& drawBounds, GrAA aa) const final;
|
||||
|
||||
@ -36,7 +36,9 @@ public:
|
||||
static const char kMaskTestTag[];
|
||||
|
||||
private:
|
||||
bool applyClipMask(GrRecordingContext*, GrSurfaceDrawContext*, const GrReducedClip&,
|
||||
bool applyClipMask(GrRecordingContext*,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
const GrReducedClip&,
|
||||
GrAppliedClip*) const;
|
||||
|
||||
// Creates an alpha mask of the clip. The mask is a rasterization of elements through the
|
||||
@ -45,10 +47,10 @@ private:
|
||||
|
||||
// Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture.
|
||||
GrSurfaceProxyView createSoftwareClipMask(GrRecordingContext*, const GrReducedClip&,
|
||||
GrSurfaceDrawContext*) const;
|
||||
skgpu::v1::SurfaceDrawContext*) const;
|
||||
|
||||
static bool UseSWOnlyPath(GrRecordingContext*,
|
||||
const GrSurfaceDrawContext*,
|
||||
const skgpu::v1::SurfaceDrawContext*,
|
||||
const GrReducedClip&);
|
||||
|
||||
// SkClipStack does not track device bounds explicitly, but it will refine these device bounds
|
||||
|
@ -17,21 +17,26 @@ class GrContext_Base;
|
||||
class GrDrawOp;
|
||||
class GrPaint;
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
struct GrUserStencilSettings;
|
||||
class SkRandom;
|
||||
|
||||
/** This function draws a randomly configured GrDrawOp for testing purposes. */
|
||||
void GrDrawRandomOp(SkRandom*, GrSurfaceDrawContext*, GrPaint&&);
|
||||
void GrDrawRandomOp(SkRandom*, skgpu::v1::SurfaceDrawContext*, GrPaint&&);
|
||||
|
||||
/** GrDrawOp subclasses should define test factory functions using this macro. */
|
||||
#define GR_DRAW_OP_TEST_DEFINE(Op) \
|
||||
GrOp::Owner Op##__Test(GrPaint&& paint, SkRandom* random, \
|
||||
GrRecordingContext* context, \
|
||||
GrSurfaceDrawContext* sdc, int numSamples)
|
||||
GrOp::Owner Op##__Test(GrPaint&& paint, \
|
||||
SkRandom* random, \
|
||||
GrRecordingContext* context, \
|
||||
skgpu::v1::SurfaceDrawContext* sdc, \
|
||||
int numSamples)
|
||||
#define GR_DRAW_OP_TEST_FRIEND(Op) \
|
||||
friend GrOp::OpOwner Op##__Test(GrPaint&&, SkRandom*, \
|
||||
GrRecordingContext*, GrSurfaceDrawContext*, int)
|
||||
friend GrOp::OpOwner Op##__Test(GrPaint&&, \
|
||||
SkRandom*, \
|
||||
GrRecordingContext*, \
|
||||
skgpu::v1::SurfaceDrawContext*, \
|
||||
int)
|
||||
|
||||
/** Helper for op test factories to pick a random stencil state. */
|
||||
const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext_Base*);
|
||||
|
@ -38,7 +38,6 @@ class GrResourceAllocator;
|
||||
class GrSemaphore;
|
||||
class GrSoftwarePathRenderer;
|
||||
class GrSurfaceContext;
|
||||
class GrSurfaceDrawContext;
|
||||
class GrSurfaceProxyView;
|
||||
class GrTessellationPathRenderer;
|
||||
class GrTextureResolveRenderTask;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
|
||||
class GrOnFlushResourceProvider;
|
||||
class GrSurfaceDrawContext;
|
||||
class GrResourceProvider;
|
||||
struct SkIPoint16;
|
||||
struct SkIRect;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "src/gpu/GrFixedClip.h"
|
||||
|
||||
#include "src/gpu/GrAppliedClip.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
SkIRect GrFixedClip::getConservativeBounds() const {
|
||||
return fScissorState.rect();
|
||||
|
@ -22,10 +22,10 @@
|
||||
#include "src/gpu/GrRenderTarget.h"
|
||||
#include "src/gpu/GrResourceAllocator.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/geometry/GrRect.h"
|
||||
#include "src/gpu/ops/GrClearOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -245,11 +245,11 @@ private:
|
||||
|
||||
friend class OpsTaskTestingAccess;
|
||||
|
||||
// The RTC and OpsTask have to work together to handle buffer clears. In most cases, buffer
|
||||
// The SDC and OpsTask have to work together to handle buffer clears. In most cases, buffer
|
||||
// clearing can be done natively, in which case the op list's load ops are sufficient. In other
|
||||
// cases, draw ops must be used, which makes the RTC the best place for those decisions. This,
|
||||
// however, requires that the RTC be able to coordinate with the op list to achieve similar ends
|
||||
friend class GrSurfaceDrawContext;
|
||||
// cases, draw ops must be used, which makes the SDC the best place for those decisions. This,
|
||||
// however, requires that the SDC be able to coordinate with the op list to achieve similar ends
|
||||
friend class skgpu::v1::SurfaceDrawContext;
|
||||
|
||||
GrAuditTrail* fAuditTrail;
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrPathRenderer.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrUserStencilSettings.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void GrPathRenderer::StencilPathArgs::validate() const {
|
||||
|
@ -17,7 +17,7 @@ class GrClip;
|
||||
class GrHardClip;
|
||||
class GrPaint;
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrRenderTargetProxy;
|
||||
class GrStyledShape;
|
||||
class GrStyle;
|
||||
@ -113,16 +113,16 @@ public:
|
||||
}
|
||||
|
||||
struct DrawPathArgs {
|
||||
GrRecordingContext* fContext;
|
||||
GrPaint&& fPaint;
|
||||
const GrUserStencilSettings* fUserStencilSettings;
|
||||
GrSurfaceDrawContext* fSurfaceDrawContext;
|
||||
const GrClip* fClip;
|
||||
const SkIRect* fClipConservativeBounds;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrStyledShape* fShape;
|
||||
GrAAType fAAType;
|
||||
bool fGammaCorrect;
|
||||
GrRecordingContext* fContext;
|
||||
GrPaint&& fPaint;
|
||||
const GrUserStencilSettings* fUserStencilSettings;
|
||||
skgpu::v1::SurfaceDrawContext* fSurfaceDrawContext;
|
||||
const GrClip* fClip;
|
||||
const SkIRect* fClipConservativeBounds;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrStyledShape* fShape;
|
||||
GrAAType fAAType;
|
||||
bool fGammaCorrect;
|
||||
#ifdef SK_DEBUG
|
||||
void validate() const {
|
||||
SkASSERT(fContext);
|
||||
@ -146,13 +146,13 @@ public:
|
||||
struct StencilPathArgs {
|
||||
SkDEBUGCODE(StencilPathArgs() { memset(this, 0, sizeof(*this)); }) // For validation.
|
||||
|
||||
GrRecordingContext* fContext;
|
||||
GrSurfaceDrawContext* fSurfaceDrawContext;
|
||||
const GrHardClip* fClip;
|
||||
const SkIRect* fClipConservativeBounds;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrStyledShape* fShape;
|
||||
GrAA fDoStencilMSAA;
|
||||
GrRecordingContext* fContext;
|
||||
skgpu::v1::SurfaceDrawContext* fSurfaceDrawContext;
|
||||
const GrHardClip* fClip;
|
||||
const SkIRect* fClipConservativeBounds;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrStyledShape* fShape;
|
||||
GrAA fDoStencilMSAA;
|
||||
|
||||
SkDEBUGCODE(void validate() const);
|
||||
};
|
||||
|
@ -24,7 +24,6 @@ class GrAppliedHardClip;
|
||||
struct GrGLSLBuiltinUniformHandles;
|
||||
class GrGLSLProgramDataManager;
|
||||
class GrOp;
|
||||
class GrSurfaceDrawContext;
|
||||
class GrTextureEffect;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,6 @@
|
||||
class SkMatrix;
|
||||
class GrCaps;
|
||||
class GrProxyProvider;
|
||||
class GrSurfaceDrawContext;
|
||||
class GrProcessorTestData;
|
||||
class GrTexture;
|
||||
class GrXPFactory;
|
||||
|
@ -60,10 +60,10 @@ public:
|
||||
UseAllocator = UseAllocator::kYes);
|
||||
|
||||
/**
|
||||
* A helper that uses findOrCreateProxyByUniqueKey() to find a proxy and if found creates a view
|
||||
* A helper that uses findOrCreateProxyByUniqueKey() to find a proxy and, if found, creates
|
||||
* a view for the found proxy using the passed in origin and color type. It is assumed that if
|
||||
* the proxy is renderable then it was created by GrSurfaceDrawContext::MakeWithFallback and
|
||||
* the fallback color type will be used to create the view.
|
||||
* the proxy is renderable then it was created via a fallback code path so the fallback
|
||||
* color type will be used to create the view.
|
||||
*/
|
||||
GrSurfaceProxyView findCachedProxyWithColorTypeFallback(const GrUniqueKey&,
|
||||
GrSurfaceOrigin,
|
||||
|
@ -18,12 +18,12 @@
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceContext.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/ops/GrAtlasTextOp.h"
|
||||
#include "src/gpu/text/GrTextBlob.h"
|
||||
#include "src/gpu/text/GrTextBlobCache.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
GrRecordingContext::ProgramData::ProgramData(std::unique_ptr<const GrProgramDesc> desc,
|
||||
const GrProgramInfo* info)
|
||||
|
@ -19,11 +19,11 @@
|
||||
#include "src/gpu/GrStencilMaskHelper.h"
|
||||
#include "src/gpu/GrStencilSettings.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrUserStencilSettings.h"
|
||||
#include "src/gpu/effects/GrConvexPolyEffect.h"
|
||||
#include "src/gpu/effects/GrRRectEffect.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
#include "src/shaders/SkShaderBase.h"
|
||||
|
||||
/**
|
||||
@ -708,7 +708,7 @@ void GrReducedClip::makeEmpty() {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Create a 8-bit clip mask in alpha
|
||||
|
||||
static bool stencil_element(GrSurfaceDrawContext* rtc,
|
||||
static bool stencil_element(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrFixedClip& clip,
|
||||
const GrUserStencilSettings* ss,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -722,7 +722,7 @@ static bool stencil_element(GrSurfaceDrawContext* rtc,
|
||||
GrPaint paint;
|
||||
paint.setCoverageSetOpXPFactory((SkRegion::Op)element->getOp(),
|
||||
element->isInverseFilled());
|
||||
rtc->stencilRect(&clip, ss, std::move(paint), aa, viewMatrix,
|
||||
sdc->stencilRect(&clip, ss, std::move(paint), aa, viewMatrix,
|
||||
element->getDeviceSpaceRect());
|
||||
return true;
|
||||
}
|
||||
@ -733,7 +733,7 @@ static bool stencil_element(GrSurfaceDrawContext* rtc,
|
||||
path.toggleInverseFillType();
|
||||
}
|
||||
|
||||
return rtc->drawAndStencilPath(&clip, ss, (SkRegion::Op)element->getOp(),
|
||||
return sdc->drawAndStencilPath(&clip, ss, (SkRegion::Op)element->getOp(),
|
||||
element->isInverseFilled(), aa, viewMatrix, path);
|
||||
}
|
||||
}
|
||||
@ -741,7 +741,7 @@ static bool stencil_element(GrSurfaceDrawContext* rtc,
|
||||
return false;
|
||||
}
|
||||
|
||||
static void draw_element(GrSurfaceDrawContext* rtc,
|
||||
static void draw_element(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip& clip, // TODO: can this just always be WideOpen?
|
||||
GrPaint&& paint,
|
||||
GrAA aa,
|
||||
@ -753,7 +753,7 @@ static void draw_element(GrSurfaceDrawContext* rtc,
|
||||
SkDEBUGFAIL("Should never get here with an empty element.");
|
||||
break;
|
||||
case SkClipStack::Element::DeviceSpaceType::kRect:
|
||||
rtc->drawRect(&clip, std::move(paint), aa, viewMatrix, element->getDeviceSpaceRect());
|
||||
sdc->drawRect(&clip, std::move(paint), aa, viewMatrix, element->getDeviceSpaceRect());
|
||||
break;
|
||||
default: {
|
||||
SkPath path;
|
||||
@ -762,16 +762,16 @@ static void draw_element(GrSurfaceDrawContext* rtc,
|
||||
path.toggleInverseFillType();
|
||||
}
|
||||
|
||||
rtc->drawPath(&clip, std::move(paint), aa, viewMatrix, path, GrStyle::SimpleFill());
|
||||
sdc->drawPath(&clip, std::move(paint), aa, viewMatrix, path, GrStyle::SimpleFill());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GrReducedClip::drawAlphaClipMask(GrSurfaceDrawContext* rtc) const {
|
||||
bool GrReducedClip::drawAlphaClipMask(skgpu::v1::SurfaceDrawContext* sdc) const {
|
||||
// The texture may be larger than necessary, this rect represents the part of the texture
|
||||
// we populate with a rasterization of the clip.
|
||||
GrFixedClip clip(rtc->dimensions(), SkIRect::MakeWH(fScissor.width(), fScissor.height()));
|
||||
GrFixedClip clip(sdc->dimensions(), SkIRect::MakeWH(fScissor.width(), fScissor.height()));
|
||||
|
||||
if (!fWindowRects.empty()) {
|
||||
clip.setWindowRectangles(fWindowRects.makeOffset(-fScissor.left(), -fScissor.top()),
|
||||
@ -786,10 +786,10 @@ bool GrReducedClip::drawAlphaClipMask(GrSurfaceDrawContext* rtc) const {
|
||||
GrPaint paint;
|
||||
paint.setColor4f(initialCoverage);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
rtc->drawRect(&clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
sdc->drawRect(&clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(clip.scissorRect()));
|
||||
} else {
|
||||
rtc->clearAtLeast(clip.scissorRect(), initialCoverage);
|
||||
sdc->clearAtLeast(clip.scissorRect(), initialCoverage);
|
||||
}
|
||||
|
||||
// Set the matrix so that rendered clip elements are transformed to mask space from clip space.
|
||||
@ -814,7 +814,7 @@ bool GrReducedClip::drawAlphaClipMask(GrSurfaceDrawContext* rtc) const {
|
||||
GrUserStencilOp::kReplace,
|
||||
0xffff>()
|
||||
);
|
||||
if (!stencil_element(rtc, clip, &kStencilInElement, translate, element)) {
|
||||
if (!stencil_element(sdc, clip, &kStencilInElement, translate, element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -831,14 +831,14 @@ bool GrReducedClip::drawAlphaClipMask(GrSurfaceDrawContext* rtc) const {
|
||||
|
||||
GrPaint paint;
|
||||
paint.setCoverageSetOpXPFactory(op, !invert);
|
||||
rtc->stencilRect(&clip, &kDrawOutsideElement, std::move(paint), GrAA::kNo, translate,
|
||||
sdc->stencilRect(&clip, &kDrawOutsideElement, std::move(paint), GrAA::kNo, translate,
|
||||
SkRect::Make(fScissor));
|
||||
} else {
|
||||
// all the remaining ops can just be directly draw into the accumulation buffer
|
||||
GrPaint paint;
|
||||
paint.setCoverageSetOpXPFactory(op, false);
|
||||
|
||||
draw_element(rtc, clip, std::move(paint), aa, translate, element);
|
||||
draw_element(sdc, clip, std::move(paint), aa, translate, element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -848,9 +848,9 @@ bool GrReducedClip::drawAlphaClipMask(GrSurfaceDrawContext* rtc) const {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Create a 1-bit clip mask in the stencil buffer.
|
||||
|
||||
bool GrReducedClip::drawStencilClipMask(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* surfaceDrawContext) const {
|
||||
GrStencilMaskHelper helper(context, surfaceDrawContext);
|
||||
bool GrReducedClip::drawStencilClipMask(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc) const {
|
||||
GrStencilMaskHelper helper(rContext, sdc);
|
||||
if (!helper.init(fScissor, this->maskGenID(), fWindowRects, this->numAnalyticElements())) {
|
||||
// The stencil mask doesn't need updating
|
||||
return true;
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "src/gpu/GrWindowRectangles.h"
|
||||
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class SkMatrixProvider;
|
||||
|
||||
/**
|
||||
@ -89,8 +89,8 @@ public:
|
||||
*/
|
||||
bool maskRequiresAA() const { SkASSERT(!fMaskElements.isEmpty()); return fMaskRequiresAA; }
|
||||
|
||||
bool drawAlphaClipMask(GrSurfaceDrawContext*) const;
|
||||
bool drawStencilClipMask(GrRecordingContext*, GrSurfaceDrawContext*) const;
|
||||
bool drawAlphaClipMask(skgpu::v1::SurfaceDrawContext*) const;
|
||||
bool drawStencilClipMask(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*) const;
|
||||
|
||||
int numAnalyticElements() const;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/GrBackendUtils.h"
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrStencilSettings.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
GrRenderTarget::GrRenderTarget(GrGpu* gpu,
|
||||
const SkISize& dimensions,
|
||||
|
@ -12,12 +12,12 @@
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
// Android Framework is relying on this header existing and the old name
|
||||
// of GrSurfaceDrawContext.
|
||||
// of skgpu::v1::SurfaceDrawContext.
|
||||
|
||||
using GrRenderTargetContext = GrSurfaceDrawContext;
|
||||
using GrRenderTargetContext = skgpu::v1::SurfaceDrawContext;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,12 +21,12 @@
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSWMaskHelper.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrUtil.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
GrPathRenderer::CanDrawPath
|
||||
@ -69,7 +69,7 @@ static bool get_unclipped_shape_dev_bounds(const GrStyledShape& shape, const SkM
|
||||
|
||||
// Gets the shape bounds, the clip bounds, and the intersection (if any). Returns false if there
|
||||
// is no intersection.
|
||||
bool GrSoftwarePathRenderer::GetShapeAndClipBounds(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
bool GrSoftwarePathRenderer::GetShapeAndClipBounds(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrClip* clip,
|
||||
const GrStyledShape& shape,
|
||||
const SkMatrix& matrix,
|
||||
@ -78,8 +78,7 @@ bool GrSoftwarePathRenderer::GetShapeAndClipBounds(GrSurfaceDrawContext* surface
|
||||
SkIRect* devClipBounds) {
|
||||
// compute bounds as intersection of rt size, clip, and path
|
||||
*devClipBounds = clip ? clip->getConservativeBounds()
|
||||
: SkIRect::MakeWH(surfaceDrawContext->width(),
|
||||
surfaceDrawContext->height());
|
||||
: SkIRect::MakeWH(sdc->width(), sdc->height());
|
||||
|
||||
if (!get_unclipped_shape_dev_bounds(shape, matrix, unclippedDevShapeBounds)) {
|
||||
*unclippedDevShapeBounds = SkIRect::MakeEmpty();
|
||||
@ -95,18 +94,18 @@ bool GrSoftwarePathRenderer::GetShapeAndClipBounds(GrSurfaceDrawContext* surface
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrSoftwarePathRenderer::DrawNonAARect(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
void GrSoftwarePathRenderer::DrawNonAARect(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPaint&& paint,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip* clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkMatrix& localMatrix) {
|
||||
surfaceDrawContext->stencilRect(clip, &userStencilSettings, std::move(paint), GrAA::kNo,
|
||||
viewMatrix, rect, &localMatrix);
|
||||
sdc->stencilRect(clip, &userStencilSettings, std::move(paint), GrAA::kNo,
|
||||
viewMatrix, rect, &localMatrix);
|
||||
}
|
||||
|
||||
void GrSoftwarePathRenderer::DrawAroundInvPath(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
void GrSoftwarePathRenderer::DrawAroundInvPath(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPaint&& paint,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip* clip,
|
||||
@ -122,32 +121,32 @@ void GrSoftwarePathRenderer::DrawAroundInvPath(GrSurfaceDrawContext* surfaceDraw
|
||||
if (devClipBounds.fTop < devPathBounds.fTop) {
|
||||
rect.setLTRB(SkIntToScalar(devClipBounds.fLeft), SkIntToScalar(devClipBounds.fTop),
|
||||
SkIntToScalar(devClipBounds.fRight), SkIntToScalar(devPathBounds.fTop));
|
||||
DrawNonAARect(surfaceDrawContext, GrPaint::Clone(paint), userStencilSettings, clip,
|
||||
DrawNonAARect(sdc, GrPaint::Clone(paint), userStencilSettings, clip,
|
||||
SkMatrix::I(), rect, invert);
|
||||
}
|
||||
if (devClipBounds.fLeft < devPathBounds.fLeft) {
|
||||
rect.setLTRB(SkIntToScalar(devClipBounds.fLeft), SkIntToScalar(devPathBounds.fTop),
|
||||
SkIntToScalar(devPathBounds.fLeft), SkIntToScalar(devPathBounds.fBottom));
|
||||
DrawNonAARect(surfaceDrawContext, GrPaint::Clone(paint), userStencilSettings, clip,
|
||||
DrawNonAARect(sdc, GrPaint::Clone(paint), userStencilSettings, clip,
|
||||
SkMatrix::I(), rect, invert);
|
||||
}
|
||||
if (devClipBounds.fRight > devPathBounds.fRight) {
|
||||
rect.setLTRB(SkIntToScalar(devPathBounds.fRight), SkIntToScalar(devPathBounds.fTop),
|
||||
SkIntToScalar(devClipBounds.fRight), SkIntToScalar(devPathBounds.fBottom));
|
||||
DrawNonAARect(surfaceDrawContext, GrPaint::Clone(paint), userStencilSettings, clip,
|
||||
DrawNonAARect(sdc, GrPaint::Clone(paint), userStencilSettings, clip,
|
||||
SkMatrix::I(), rect, invert);
|
||||
}
|
||||
if (devClipBounds.fBottom > devPathBounds.fBottom) {
|
||||
rect.setLTRB(SkIntToScalar(devClipBounds.fLeft), SkIntToScalar(devPathBounds.fBottom),
|
||||
SkIntToScalar(devClipBounds.fRight), SkIntToScalar(devClipBounds.fBottom));
|
||||
DrawNonAARect(surfaceDrawContext, std::move(paint), userStencilSettings, clip,
|
||||
DrawNonAARect(sdc, std::move(paint), userStencilSettings, clip,
|
||||
SkMatrix::I(), rect, invert);
|
||||
}
|
||||
}
|
||||
|
||||
void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
|
||||
GrSurfaceProxyView view,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPaint&& paint,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip* clip,
|
||||
@ -172,7 +171,7 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
|
||||
|
||||
paint.setCoverageFragmentProcessor(GrTextureEffect::Make(
|
||||
std::move(view), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest));
|
||||
DrawNonAARect(surfaceDrawContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
|
||||
DrawNonAARect(sdc, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
|
||||
dstRect, invert);
|
||||
}
|
||||
|
||||
|
@ -26,26 +26,26 @@ public:
|
||||
, fAllowCaching(allowCaching) {
|
||||
}
|
||||
|
||||
static bool GetShapeAndClipBounds(GrSurfaceDrawContext*,
|
||||
const GrClip* clip,
|
||||
const GrStyledShape& shape,
|
||||
const SkMatrix& matrix,
|
||||
static bool GetShapeAndClipBounds(skgpu::v1::SurfaceDrawContext*,
|
||||
const GrClip*,
|
||||
const GrStyledShape&,
|
||||
const SkMatrix& viewMatrix,
|
||||
SkIRect* unclippedDevShapeBounds,
|
||||
SkIRect* clippedDevShapeBounds,
|
||||
SkIRect* devClipBounds);
|
||||
|
||||
private:
|
||||
static void DrawNonAARect(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
GrPaint&& paint,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip* clip,
|
||||
static void DrawNonAARect(skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&&,
|
||||
const GrUserStencilSettings&,
|
||||
const GrClip*,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkMatrix& localMatrix);
|
||||
static void DrawAroundInvPath(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
GrPaint&& paint,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip* clip,
|
||||
static void DrawAroundInvPath(skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&&,
|
||||
const GrUserStencilSettings&,
|
||||
const GrClip*,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkIRect& devClipBounds,
|
||||
const SkIRect& devPathBounds);
|
||||
@ -54,10 +54,10 @@ private:
|
||||
// space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
|
||||
// any fragment processors in the paint.
|
||||
static void DrawToTargetWithShapeMask(GrSurfaceProxyView,
|
||||
GrSurfaceDrawContext* surfaceDrawContext,
|
||||
GrPaint&& paint,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip* clip,
|
||||
skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&&,
|
||||
const GrUserStencilSettings&,
|
||||
const GrClip*,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkIPoint& textureOriginInDeviceSpace,
|
||||
const SkIRect& deviceSpaceRectToDraw);
|
||||
|
@ -11,10 +11,10 @@
|
||||
#include "include/core/SkPath.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrStencilSettings.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrDisableColorXP.h"
|
||||
#include "src/gpu/geometry/GrShape.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -274,16 +274,16 @@ static GrUserStencilSettings const* const* get_stencil_passes(
|
||||
return gUserToClipTable[fillInverted][op];
|
||||
}
|
||||
|
||||
static void draw_stencil_rect(GrSurfaceDrawContext* rtc, const GrHardClip& clip,
|
||||
static void draw_stencil_rect(skgpu::v1::SurfaceDrawContext* sdc, const GrHardClip& clip,
|
||||
const GrUserStencilSettings* ss, const SkMatrix& matrix,
|
||||
const SkRect& rect, GrAA aa) {
|
||||
GrPaint paint;
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Get());
|
||||
rtc->stencilRect(&clip, ss, std::move(paint), aa, matrix, rect);
|
||||
sdc->stencilRect(&clip, ss, std::move(paint), aa, matrix, rect);
|
||||
}
|
||||
|
||||
static void draw_path(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* rtc,
|
||||
static void draw_path(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPathRenderer* pr, const GrHardClip& clip, const SkIRect& bounds,
|
||||
const GrUserStencilSettings* ss, const SkMatrix& matrix,
|
||||
const GrStyledShape& shape, GrAA aa) {
|
||||
@ -293,10 +293,10 @@ static void draw_path(GrRecordingContext* context,
|
||||
// kMSAA is the only type of AA that's possible on a stencil buffer.
|
||||
GrAAType pathAAType = aa == GrAA::kYes ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
|
||||
GrPathRenderer::DrawPathArgs args{context,
|
||||
GrPathRenderer::DrawPathArgs args{rContext,
|
||||
std::move(paint),
|
||||
ss,
|
||||
rtc,
|
||||
sdc,
|
||||
&clip,
|
||||
&bounds,
|
||||
&matrix,
|
||||
@ -306,12 +306,15 @@ static void draw_path(GrRecordingContext* context,
|
||||
pr->drawPath(args);
|
||||
}
|
||||
|
||||
static void stencil_path(GrRecordingContext* context,
|
||||
GrSurfaceDrawContext* sdc,
|
||||
GrPathRenderer* pr, const GrFixedClip& clip, const SkMatrix& matrix,
|
||||
const GrStyledShape& shape, GrAA aa) {
|
||||
static void stencil_path(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPathRenderer* pr,
|
||||
const GrFixedClip& clip,
|
||||
const SkMatrix& matrix,
|
||||
const GrStyledShape& shape,
|
||||
GrAA aa) {
|
||||
GrPathRenderer::StencilPathArgs args;
|
||||
args.fContext = context;
|
||||
args.fContext = rContext;
|
||||
args.fSurfaceDrawContext = sdc;
|
||||
args.fClip = &clip;
|
||||
args.fClipConservativeBounds = &clip.scissorRect();
|
||||
@ -322,7 +325,7 @@ static void stencil_path(GrRecordingContext* context,
|
||||
pr->stencilPath(args);
|
||||
}
|
||||
|
||||
static GrAA supported_aa(GrSurfaceDrawContext* sdc, GrAA aa) {
|
||||
static GrAA supported_aa(skgpu::v1::SurfaceDrawContext* sdc, GrAA aa) {
|
||||
if (sdc->canUseDynamicMSAA()) {
|
||||
return GrAA::kYes;
|
||||
}
|
||||
@ -339,7 +342,8 @@ static GrAA supported_aa(GrSurfaceDrawContext* sdc, GrAA aa) {
|
||||
|
||||
} // namespace
|
||||
|
||||
GrStencilMaskHelper::GrStencilMaskHelper(GrRecordingContext* rContext, GrSurfaceDrawContext* sdc)
|
||||
GrStencilMaskHelper::GrStencilMaskHelper(GrRecordingContext* rContext,
|
||||
skgpu::v1::SurfaceDrawContext* sdc)
|
||||
: fContext(rContext)
|
||||
, fSDC(sdc)
|
||||
, fClip(sdc->dimensions()) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
class GrShape;
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class SkMatrix;
|
||||
class SkRRect;
|
||||
|
||||
@ -37,7 +37,7 @@ public:
|
||||
// Configure the helper to update the stencil mask within the given rectangle, respecting the
|
||||
// set window rectangles. It will use the provided context and render target to draw into, both
|
||||
// of which must outlive the helper.
|
||||
GrStencilMaskHelper(GrRecordingContext*, GrSurfaceDrawContext*);
|
||||
GrStencilMaskHelper(GrRecordingContext*, skgpu::v1::SurfaceDrawContext*);
|
||||
|
||||
// Returns true if the stencil mask must be redrawn
|
||||
bool init(const SkIRect& maskBounds, uint32_t genID,
|
||||
@ -59,10 +59,10 @@ public:
|
||||
void finish();
|
||||
|
||||
private:
|
||||
GrRecordingContext* fContext;
|
||||
GrSurfaceDrawContext* fSDC;
|
||||
GrStencilClip fClip;
|
||||
int fNumFPs;
|
||||
GrRecordingContext* fContext;
|
||||
skgpu::v1::SurfaceDrawContext* fSDC;
|
||||
GrStencilClip fClip;
|
||||
int fNumFPs;
|
||||
|
||||
using INHERITED = SkNoncopyable;
|
||||
};
|
||||
|
@ -24,24 +24,24 @@
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrSurfaceFillContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBicubicEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(this->singleOwner())
|
||||
#define RETURN_FALSE_IF_ABANDONED if (this->fContext->abandoned()) { return false; }
|
||||
#define RETURN_NULLPTR_IF_ABANDONED if (this->fContext->abandoned()) { return nullptr; }
|
||||
|
||||
std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
|
||||
std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* rContext,
|
||||
GrSurfaceProxyView readView,
|
||||
const GrColorInfo& info) {
|
||||
// It is probably not necessary to check if the context is abandoned here since uses of the
|
||||
// GrSurfaceContext which need the context will mostly likely fail later on without an issue.
|
||||
// However having this hear adds some reassurance in case there is a path doesn't handle an
|
||||
// abandoned context correctly. It also lets us early out of some extra work.
|
||||
if (context->abandoned()) {
|
||||
if (rContext->abandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
GrSurfaceProxy* proxy = readView.proxy();
|
||||
@ -53,25 +53,25 @@ std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* con
|
||||
// colorType here? If so we will need to manually pass that in.
|
||||
GrSwizzle writeSwizzle;
|
||||
if (info.colorType() != GrColorType::kUnknown) {
|
||||
writeSwizzle = context->priv().caps()->getWriteSwizzle(proxy->backendFormat(),
|
||||
writeSwizzle = rContext->priv().caps()->getWriteSwizzle(proxy->backendFormat(),
|
||||
info.colorType());
|
||||
}
|
||||
GrSurfaceProxyView writeView(readView.refProxy(), readView.origin(), writeSwizzle);
|
||||
if (info.alphaType() == kPremul_SkAlphaType || info.alphaType() == kOpaque_SkAlphaType) {
|
||||
surfaceContext = std::make_unique<GrSurfaceDrawContext>(context,
|
||||
std::move(readView),
|
||||
std::move(writeView),
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
SkSurfaceProps());
|
||||
surfaceContext = std::make_unique<skgpu::v1::SurfaceDrawContext>(rContext,
|
||||
std::move(readView),
|
||||
std::move(writeView),
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
SkSurfaceProps());
|
||||
} else {
|
||||
surfaceContext = std::make_unique<GrSurfaceFillContext>(context,
|
||||
surfaceContext = std::make_unique<GrSurfaceFillContext>(rContext,
|
||||
std::move(readView),
|
||||
std::move(writeView),
|
||||
info);
|
||||
}
|
||||
} else {
|
||||
surfaceContext = std::make_unique<GrSurfaceContext>(context, std::move(readView), info);
|
||||
surfaceContext = std::make_unique<GrSurfaceContext>(rContext, std::move(readView), info);
|
||||
}
|
||||
SkDEBUGCODE(surfaceContext->validate();)
|
||||
return surfaceContext;
|
||||
|
@ -26,7 +26,7 @@ class GrRecordingContext;
|
||||
class GrRenderTargetProxy;
|
||||
class GrSingleOwner;
|
||||
class GrSurface;
|
||||
class GrSurfaceDrawContext;
|
||||
namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
|
||||
class GrSurfaceFillContext;
|
||||
class GrSurfaceProxy;
|
||||
class GrTextureProxy;
|
||||
@ -38,13 +38,13 @@ struct SkIRect;
|
||||
*/
|
||||
class GrSurfaceContext {
|
||||
public:
|
||||
// If the passed in GrSurfaceProxy is renderable this will return a GrSurfaceDrawContext,
|
||||
// If the passed in GrSurfaceProxy is renderable this will return a SurfaceDrawContext,
|
||||
// otherwise it will return a GrSurfaceContext.
|
||||
static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*,
|
||||
GrSurfaceProxyView readView,
|
||||
const GrColorInfo&);
|
||||
|
||||
// Makes either a GrSurfaceContext, GrFillDrawContext, or a GrSurfaceDrawContext, depending on
|
||||
// Makes either a GrSurfaceContext, GrFillDrawContext, or a SurfaceDrawContext, depending on
|
||||
// GrRenderable and the GrImageInfo.
|
||||
static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*,
|
||||
const GrImageInfo&,
|
||||
@ -164,7 +164,6 @@ public:
|
||||
return fReadView.asRenderTargetProxyRef();
|
||||
}
|
||||
|
||||
virtual GrSurfaceDrawContext* asSurfaceDrawContext() { return nullptr; }
|
||||
virtual GrSurfaceFillContext* asFillContext() { return nullptr; }
|
||||
|
||||
/**
|
||||
|
@ -11,11 +11,11 @@
|
||||
#include "src/gpu/GrDstProxyView.h"
|
||||
#include "src/gpu/GrImageContextPriv.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#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; }
|
||||
@ -31,7 +31,7 @@ private:
|
||||
GrDrawingManager* fDrawingManager;
|
||||
};
|
||||
|
||||
std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingContext* context,
|
||||
std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingContext* rContext,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
SkISize dimensions,
|
||||
@ -44,41 +44,41 @@ std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingCont
|
||||
GrSwizzle writeSwizzle,
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted) {
|
||||
SkASSERT(context);
|
||||
SkASSERT(rContext);
|
||||
SkASSERT(!dimensions.isEmpty());
|
||||
SkASSERT(sampleCount >= 1);
|
||||
SkASSERT(format.isValid() && format.backend() == context->backend());
|
||||
SkASSERT(format.isValid() && format.backend() == rContext->backend());
|
||||
if (alphaType == kPremul_SkAlphaType || alphaType == kOpaque_SkAlphaType) {
|
||||
return GrSurfaceDrawContext::Make(context,
|
||||
std::move(colorSpace),
|
||||
fit,
|
||||
dimensions,
|
||||
format,
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
isProtected,
|
||||
readSwizzle,
|
||||
writeSwizzle,
|
||||
origin,
|
||||
budgeted,
|
||||
SkSurfaceProps());
|
||||
return skgpu::v1::SurfaceDrawContext::Make(rContext,
|
||||
std::move(colorSpace),
|
||||
fit,
|
||||
dimensions,
|
||||
format,
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
isProtected,
|
||||
readSwizzle,
|
||||
writeSwizzle,
|
||||
origin,
|
||||
budgeted,
|
||||
SkSurfaceProps());
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(format,
|
||||
dimensions,
|
||||
GrRenderable::kYes,
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
fit,
|
||||
budgeted,
|
||||
isProtected);
|
||||
sk_sp<GrTextureProxy> proxy = rContext->priv().proxyProvider()->createProxy(format,
|
||||
dimensions,
|
||||
GrRenderable::kYes,
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
fit,
|
||||
budgeted,
|
||||
isProtected);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
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>(context,
|
||||
auto fillContext = std::make_unique<GrSurfaceFillContext>(rContext,
|
||||
std::move(readView),
|
||||
std::move(writeView),
|
||||
info.colorInfo());
|
||||
@ -86,7 +86,7 @@ std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingCont
|
||||
return fillContext;
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingContext* context,
|
||||
std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingContext* rContext,
|
||||
GrImageInfo info,
|
||||
SkBackingFit fit,
|
||||
int sampleCount,
|
||||
@ -95,37 +95,37 @@ std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::Make(GrRecordingCont
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted) {
|
||||
if (info.alphaType() == kPremul_SkAlphaType || info.alphaType() == kOpaque_SkAlphaType) {
|
||||
return GrSurfaceDrawContext::Make(context,
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
fit,
|
||||
info.dimensions(),
|
||||
SkSurfaceProps(),
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
isProtected,
|
||||
origin,
|
||||
budgeted);
|
||||
return skgpu::v1::SurfaceDrawContext::Make(rContext,
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
fit,
|
||||
info.dimensions(),
|
||||
SkSurfaceProps(),
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
isProtected,
|
||||
origin,
|
||||
budgeted);
|
||||
}
|
||||
GrBackendFormat format = context->priv().caps()->getDefaultBackendFormat(info.colorType(),
|
||||
GrRenderable::kYes);
|
||||
sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(format,
|
||||
info.dimensions(),
|
||||
GrRenderable::kYes,
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
fit,
|
||||
budgeted,
|
||||
isProtected);
|
||||
GrBackendFormat format = rContext->priv().caps()->getDefaultBackendFormat(info.colorType(),
|
||||
GrRenderable::kYes);
|
||||
sk_sp<GrTextureProxy> proxy = rContext->priv().proxyProvider()->createProxy(format,
|
||||
info.dimensions(),
|
||||
GrRenderable::kYes,
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
fit,
|
||||
budgeted,
|
||||
isProtected);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle (format, info.colorType());
|
||||
GrSwizzle writeSwizzle = context->priv().caps()->getWriteSwizzle(format, info.colorType());
|
||||
GrSwizzle readSwizzle = rContext->priv().caps()->getReadSwizzle (format, info.colorType());
|
||||
GrSwizzle writeSwizzle = rContext->priv().caps()->getWriteSwizzle(format, info.colorType());
|
||||
|
||||
GrSurfaceProxyView readView( proxy, origin, readSwizzle);
|
||||
GrSurfaceProxyView writeView(std::move(proxy), origin, writeSwizzle);
|
||||
auto fillContext = std::make_unique<GrSurfaceFillContext>(context,
|
||||
auto fillContext = std::make_unique<GrSurfaceFillContext>(rContext,
|
||||
std::move(readView),
|
||||
std::move(writeView),
|
||||
info.colorInfo());
|
||||
@ -143,17 +143,17 @@ std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::MakeWithFallback(
|
||||
GrSurfaceOrigin origin,
|
||||
SkBudgeted budgeted) {
|
||||
if (info.alphaType() == kPremul_SkAlphaType || info.alphaType() == kOpaque_SkAlphaType) {
|
||||
return GrSurfaceDrawContext::MakeWithFallback(rContext,
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
fit,
|
||||
info.dimensions(),
|
||||
SkSurfaceProps(),
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
isProtected,
|
||||
origin,
|
||||
budgeted);
|
||||
return skgpu::v1::SurfaceDrawContext::MakeWithFallback(rContext,
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
fit,
|
||||
info.dimensions(),
|
||||
SkSurfaceProps(),
|
||||
sampleCount,
|
||||
mipmapped,
|
||||
isProtected,
|
||||
origin,
|
||||
budgeted);
|
||||
}
|
||||
const GrCaps* caps = rContext->priv().caps();
|
||||
|
||||
@ -182,14 +182,14 @@ std::unique_ptr<GrSurfaceFillContext> GrSurfaceFillContext::MakeFromBackendTextu
|
||||
SkASSERT(sampleCount > 0);
|
||||
|
||||
if (info.alphaType() == kPremul_SkAlphaType || info.alphaType() == kOpaque_SkAlphaType) {
|
||||
return GrSurfaceDrawContext::MakeFromBackendTexture(context,
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
tex,
|
||||
sampleCount,
|
||||
origin,
|
||||
SkSurfaceProps(),
|
||||
std::move(releaseHelper));
|
||||
return skgpu::v1::SurfaceDrawContext::MakeFromBackendTexture(context,
|
||||
info.colorType(),
|
||||
info.refColorSpace(),
|
||||
tex,
|
||||
sampleCount,
|
||||
origin,
|
||||
SkSurfaceProps(),
|
||||
std::move(releaseHelper));
|
||||
}
|
||||
const GrBackendFormat& format = tex.getBackendFormat();
|
||||
GrSwizzle readSwizzle, writeSwizzle;
|
||||
@ -334,7 +334,7 @@ void GrSurfaceFillContext::discard() {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceDrawContext", "discard", fContext);
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceFillContext", "discard", fContext);
|
||||
|
||||
AutoCheckFlush acf(this->drawingManager());
|
||||
|
||||
@ -347,7 +347,7 @@ void GrSurfaceFillContext::internalClear(const SkIRect* scissor,
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceDrawContext", "clear", fContext);
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceFillContext", "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
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
/**
|
||||
* Uses GrImageInfo's color type to pick the default texture format. Will return a
|
||||
* GrSurfaceDrawContext if possible.
|
||||
* SurfaceDrawContext if possible.
|
||||
*/
|
||||
static std::unique_ptr<GrSurfaceFillContext> Make(GrRecordingContext*,
|
||||
GrImageInfo,
|
||||
@ -64,7 +64,7 @@ public:
|
||||
|
||||
/**
|
||||
* Makes a custom configured GrSurfaceFillContext where the caller specifies the specific
|
||||
* texture format and swizzles. The color type will be kUnknown. Returns a GrSurfaceDrawContext
|
||||
* texture format and swizzles. The color type will be kUnknown. Returns a SurfaceDrawContext
|
||||
* if possible.
|
||||
*/
|
||||
static std::unique_ptr<GrSurfaceFillContext> Make(GrRecordingContext*,
|
||||
@ -84,7 +84,7 @@ public:
|
||||
/**
|
||||
* Creates a GrSurfaceFillContext 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 GrSurfaceDrawContext if possible.
|
||||
* considered compatible with kUnknown. Returns a SurfaceDrawContext if possible.
|
||||
*/
|
||||
static std::unique_ptr<GrSurfaceFillContext> MakeFromBackendTexture(
|
||||
GrRecordingContext*,
|
||||
|
@ -362,7 +362,7 @@ GrThreadSafeCache::CreateLazyView(GrDirectContext* dContext,
|
||||
GrSurfaceProxy::UseAllocator::kYes);
|
||||
|
||||
// TODO: It seems like this 'newCT' usage should be 'origCT' but this is
|
||||
// what GrSurfaceDrawContext::MakeWithFallback does
|
||||
// what skgpu::v1::SurfaceDrawContext::MakeWithFallback does
|
||||
GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(format, newCT);
|
||||
|
||||
return {{std::move(proxy), origin, swizzle}, std::move(trampoline)};
|
||||
|
@ -153,8 +153,8 @@ bool GrDawnOpsRenderPass::onBindPipeline(const GrProgramInfo& programInfo,
|
||||
}
|
||||
|
||||
void GrDawnOpsRenderPass::onSetScissorRect(const SkIRect& scissor) {
|
||||
// Higher-level GrSurfaceDrawContext and clips should have already ensured draw bounds are
|
||||
// restricted to the render target.
|
||||
// Higher-level skgpu::v1::SurfaceDrawContext and clips should have already ensured draw
|
||||
// bounds are restricted to the render target.
|
||||
SkASSERT(SkIRect::MakeSize(fRenderTarget->dimensions()).contains(scissor));
|
||||
auto nativeScissorRect =
|
||||
GrNativeRect::MakeRelativeTo(fOrigin, fRenderTarget->height(), scissor);
|
||||
|
@ -9,12 +9,12 @@
|
||||
#include "src/gpu/GrColor.h"
|
||||
#include "src/gpu/GrPipeline.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/GrCoverageSetOpXP.h"
|
||||
#include "src/gpu/glsl/GrGLSLBlend.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
|
||||
#include "src/gpu/glsl/GrGLSLXferProcessor.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
class CoverageSetOpXP : public GrXferProcessor {
|
||||
public:
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "src/gpu/ops/GrAAConvexPathRenderer.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrUtil.h"
|
||||
#include "src/gpu/effects/GrBezierEffect.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "src/gpu/ops/GrAAHairLinePathRenderer.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#define PREALLOC_PTARRAY(N) SkSTArray<(N),SkPoint, true>
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
@ -27,6 +26,7 @@
|
||||
#include "src/gpu/ops/GrAALinearizingConvexPathRenderer.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
static const int DEFAULT_BUFFER_SIZE = 100;
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "src/core/SkIPoint16.h"
|
||||
#include "src/gpu/GrClip.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrVx.h"
|
||||
#include "src/gpu/effects/GrModulateAtlasCoverageEffect.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
@ -19,6 +18,7 @@
|
||||
#include "src/gpu/tessellate/GrAtlasRenderTask.h"
|
||||
#include "src/gpu/tessellate/GrTessellationPathRenderer.h"
|
||||
#include "src/gpu/tessellate/shaders/GrTessellationShader.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
using grvx::float2;
|
||||
using grvx::int2;
|
||||
@ -278,7 +278,7 @@ bool GrAtlasPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
GrFPResult GrAtlasPathRenderer::makeAtlasClipEffect(const GrSurfaceDrawContext* sdc,
|
||||
GrFPResult GrAtlasPathRenderer::makeAtlasClipEffect(const skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const GrOp* opBeingClipped,
|
||||
std::unique_ptr<GrFragmentProcessor> inputFP,
|
||||
const SkIRect& drawBounds,
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
// 128^2 total pixels if the surfaceDrawContext supports MSAA or DMSAA.)
|
||||
//
|
||||
// Also returns GrFPFailure() if the view matrix has perspective.
|
||||
GrFPResult makeAtlasClipEffect(const GrSurfaceDrawContext*,
|
||||
GrFPResult makeAtlasClipEffect(const skgpu::v1::SurfaceDrawContext*,
|
||||
const GrOp* opBeingClipped,
|
||||
std::unique_ptr<GrFragmentProcessor> inputFP,
|
||||
const SkIRect& drawBounds,
|
||||
|
@ -19,13 +19,13 @@
|
||||
#include "src/gpu/GrOpFlushState.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBitmapTextGeoProc.h"
|
||||
#include "src/gpu/effects/GrDistanceFieldGeoProc.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
#include "src/gpu/text/GrAtlasManager.h"
|
||||
#include "src/gpu/text/GrDistanceFieldAdjustTable.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
#include "src/gpu/GrDrawOpTest.h"
|
||||
@ -488,7 +488,7 @@ GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
|
||||
GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const SkPaint& skPaint,
|
||||
const SkFont& font,
|
||||
const SkMatrixProvider& mtxProvider,
|
||||
@ -506,11 +506,11 @@ GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto rContext = rtc->recordingContext();
|
||||
auto rContext = sdc->recordingContext();
|
||||
GrSDFTControl control =
|
||||
rContext->priv().getSDFTControl(rtc->surfaceProps().isUseDeviceIndependentFonts());
|
||||
rContext->priv().getSDFTControl(sdc->surfaceProps().isUseDeviceIndependentFonts());
|
||||
|
||||
SkGlyphRunListPainter* painter = rtc->glyphRunPainter();
|
||||
SkGlyphRunListPainter* painter = sdc->glyphRunPainter();
|
||||
sk_sp<GrTextBlob> blob = GrTextBlob::Make(glyphRunList, skPaint, drawMatrix, control, painter);
|
||||
|
||||
if (blob->subRunList().isEmpty()) {
|
||||
@ -521,7 +521,7 @@ GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
|
||||
SkASSERT(subRun);
|
||||
GrOp::Owner op;
|
||||
std::tie(std::ignore, op) = subRun->makeAtlasTextOp(
|
||||
nullptr, mtxProvider, glyphRunList, skPaint, rtc, nullptr);
|
||||
nullptr, mtxProvider, glyphRunList, skPaint, sdc, nullptr);
|
||||
return op;
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,10 @@ public:
|
||||
static constexpr int kMaskTypeCount = static_cast<int>(MaskType::kLast) + 1;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
static GrOp::Owner CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
|
||||
const SkPaint& skPaint,
|
||||
const SkFont& font,
|
||||
const SkMatrixProvider& mtxProvider,
|
||||
static GrOp::Owner CreateOpTestingOnly(skgpu::v1::SurfaceDrawContext*,
|
||||
const SkPaint&,
|
||||
const SkFont&,
|
||||
const SkMatrixProvider&,
|
||||
const char* text,
|
||||
int x,
|
||||
int y);
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
#include "src/gpu/GrAuditTrail.h"
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/ops/GrDashLinePathRenderer.h"
|
||||
#include "src/gpu/ops/GrDashOp.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
GrPathRenderer::CanDrawPath
|
||||
GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrSimpleMesh.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrUtil.h"
|
||||
#include "src/gpu/effects/GrDisableColorXP.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
GrDefaultPathRenderer::GrDefaultPathRenderer() {
|
||||
}
|
||||
@ -592,7 +592,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
bool GrDefaultPathRenderer::internalDrawPath(GrSurfaceDrawContext* surfaceDrawContext,
|
||||
bool GrDefaultPathRenderer::internalDrawPath(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
GrPaint&& paint,
|
||||
GrAAType aaType,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
@ -600,7 +600,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrSurfaceDrawContext* surfaceDrawCo
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrStyledShape& shape,
|
||||
bool stencilOnly) {
|
||||
auto context = surfaceDrawContext->recordingContext();
|
||||
auto context = sdc->recordingContext();
|
||||
|
||||
SkASSERT(GrAAType::kCoverage != aaType);
|
||||
SkPath path;
|
||||
@ -688,7 +688,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrSurfaceDrawContext* surfaceDrawCo
|
||||
SkScalar srcSpaceTol = GrPathUtils::scaleToleranceToSrc(tol, viewMatrix, path.getBounds());
|
||||
|
||||
SkRect devBounds;
|
||||
GetPathDevBounds(path, surfaceDrawContext->asRenderTargetProxy()->backingStoreDimensions(),
|
||||
GetPathDevBounds(path, sdc->asRenderTargetProxy()->backingStoreDimensions(),
|
||||
viewMatrix, &devBounds);
|
||||
|
||||
for (int p = 0; p < passCount; ++p) {
|
||||
@ -714,9 +714,9 @@ bool GrDefaultPathRenderer::internalDrawPath(GrSurfaceDrawContext* surfaceDrawCo
|
||||
viewMatrix;
|
||||
// This is a non-coverage aa rect op since we assert aaType != kCoverage at the start
|
||||
assert_alive(paint);
|
||||
surfaceDrawContext->stencilRect(clip, passes[p], std::move(paint),
|
||||
GrAA(aaType == GrAAType::kMSAA), viewM, bounds,
|
||||
&localMatrix);
|
||||
sdc->stencilRect(clip, passes[p], std::move(paint),
|
||||
GrAA(aaType == GrAAType::kMSAA), viewM, bounds,
|
||||
&localMatrix);
|
||||
} else {
|
||||
bool stencilPass = stencilOnly || passCount > 1;
|
||||
GrOp::Owner op;
|
||||
@ -731,7 +731,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrSurfaceDrawContext* surfaceDrawCo
|
||||
op = DefaultPathOp::Make(context, std::move(paint), path, srcSpaceTol, newCoverage,
|
||||
viewMatrix, isHairline, aaType, devBounds, passes[p]);
|
||||
}
|
||||
surfaceDrawContext->addDrawOp(clip, std::move(op));
|
||||
sdc->addDrawOp(clip, std::move(op));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -31,7 +31,7 @@ private:
|
||||
|
||||
void onStencilPath(const StencilPathArgs&) override;
|
||||
|
||||
bool internalDrawPath(GrSurfaceDrawContext*,
|
||||
bool internalDrawPath(skgpu::v1::SurfaceDrawContext*,
|
||||
GrPaint&&,
|
||||
GrAAType,
|
||||
const GrUserStencilSettings&,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user