Untangle GrSurfaceDrawContext.h, GrTextureOp.h and GrFillRectOp.h

The dependencies between these headers made modifying the SDC and Ops separately somewhat difficult.

Bug: skia:11837
Change-Id: I0c3ca118ce206bf8db5b6753be1ef46531ae1f58
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430041
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2021-07-20 09:40:13 -04:00 committed by Skia Commit-Bot
parent f4bb3d41d3
commit e40495da3d
13 changed files with 79 additions and 42 deletions

View File

@ -13,6 +13,7 @@
#include "include/gpu/GrDirectContext.h"
#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"
@ -133,7 +134,7 @@ protected:
auto context = canvas->recordingContext();
SkASSERT(context);
GrSurfaceDrawContext::QuadSetEntry batch[kRectCount];
GrQuadSetEntry batch[kRectCount];
for (int i = 0; i < kRectCount; ++i) {
batch[i].fRect = fRects[i];
batch[i].fColor = fColors[i].premul();

View File

@ -138,6 +138,7 @@ skia_gpu_sources = [
"$_src/gpu/GrOpsRenderPass.h",
"$_src/gpu/GrOpsTask.cpp",
"$_src/gpu/GrOpsTask.h",
"$_src/gpu/GrOpsTypes.h",
"$_src/gpu/GrPaint.cpp",
"$_src/gpu/GrPaint.h",
"$_src/gpu/GrPersistentCacheUtils.cpp",

37
src/gpu/GrOpsTypes.h Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrOpsTypes_DEFINED
#define GrOpsTypes_DEFINED
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "include/private/GrTypesPriv.h"
#include "include/private/SkColorData.h"
#include "src/gpu/GrSurfaceProxyView.h"
/** Used by SDC::drawQuadSet and GrFillRectOp */
struct GrQuadSetEntry {
SkRect fRect;
SkPMColor4f fColor; // Overrides any color on the GrPaint
SkMatrix fLocalMatrix;
GrQuadAAFlags fAAFlags;
};
/** Used by SDC::drawTextureSet and GrTextureOp */
struct GrTextureSetEntry {
GrSurfaceProxyView fProxyView;
SkAlphaType fSrcAlphaType;
SkRect fSrcRect;
SkRect fDstRect;
const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix
SkPMColor4f fColor; // {a,a,a,a} for rgb textures, {r,g,b,a} for alpha-only textures
GrQuadAAFlags fAAFlags;
};
#endif

View File

@ -826,7 +826,7 @@ void GrSurfaceDrawContext::drawQuadSet(const GrClip* clip,
GrPaint&& paint,
GrAA aa,
const SkMatrix& viewMatrix,
const QuadSetEntry quads[],
const GrQuadSetEntry quads[],
int cnt) {
GrAAType aaType = this->chooseAAType(aa);
@ -938,7 +938,7 @@ bool GrSurfaceDrawContext::stencilPath(const GrHardClip* clip,
}
void GrSurfaceDrawContext::drawTextureSet(const GrClip* clip,
TextureSetEntry set[],
GrTextureSetEntry set[],
int cnt,
int proxyRunCnt,
GrSamplerState::Filter filter,

View File

@ -30,10 +30,12 @@ class GrDrawOp;
class GrDstProxyView;
class GrHardClip;
class GrOp;
struct GrQuadSetEntry;
class GrRenderTarget;
class GrStyledShape;
class GrStyle;
class GrTextureProxy;
struct GrTextureSetEntry;
struct GrUserStencilSettings;
struct SkDrawShadowRec;
class SkGlyphRunList;
@ -224,17 +226,9 @@ public:
this->drawFilledQuad(clip, std::move(paint), aa, &quad);
}
/** Used with drawQuadSet */
struct QuadSetEntry {
SkRect fRect;
SkPMColor4f fColor; // Overrides any color on the GrPaint
SkMatrix fLocalMatrix;
GrQuadAAFlags fAAFlags;
};
// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
void drawQuadSet(const GrClip* clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix,
const QuadSetEntry[], int cnt);
const GrQuadSetEntry[], int cnt);
/**
* Creates an op that draws a subrectangle of a texture. The passed color is modulated by the
@ -284,17 +278,6 @@ public:
color, mode, aa, &quad, subset);
}
/** Used with drawTextureSet */
struct TextureSetEntry {
GrSurfaceProxyView fProxyView;
SkAlphaType fSrcAlphaType;
SkRect fSrcRect;
SkRect fDstRect;
const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
const SkMatrix* fPreViewMatrix; // If not null, entry's CTM is 'viewMatrix' * fPreViewMatrix
SkPMColor4f fColor; // {a,a,a,a} for rgb textures, {r,g,b,a} for alpha-only textures
GrQuadAAFlags fAAFlags;
};
/**
* Draws a set of textures with a shared filter, color, view matrix, color xform, and
* texture color xform. The textures must all have the same GrTextureType and GrConfig.
@ -307,7 +290,7 @@ public:
* by SkGpuDevice, so no need to incur another iteration over the array.
*/
void drawTextureSet(const GrClip*,
TextureSetEntry[],
GrTextureSetEntry[],
int cnt,
int proxyRunCnt,
GrSamplerState::Filter,

View File

@ -11,8 +11,10 @@
#include "include/core/SkRect.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrGeometryProcessor.h"
#include "src/gpu/GrOpsTypes.h"
#include "src/gpu/GrPaint.h"
#include "src/gpu/GrProgramInfo.h"
#include "src/gpu/GrSurfaceDrawContext.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/geometry/GrQuad.h"
#include "src/gpu/geometry/GrQuadBuffer.h"
@ -479,7 +481,7 @@ GrOp::Owner GrFillRectOp::MakeOp(GrRecordingContext* context,
GrPaint&& paint,
GrAAType aaType,
const SkMatrix& viewMatrix,
const GrSurfaceDrawContext::QuadSetEntry quads[],
const GrQuadSetEntry quads[],
int cnt,
const GrUserStencilSettings* stencilSettings,
int* numConsumed) {
@ -521,7 +523,7 @@ void GrFillRectOp::AddFillRectOps(GrSurfaceDrawContext* rtc,
GrPaint&& paint,
GrAAType aaType,
const SkMatrix& viewMatrix,
const GrSurfaceDrawContext::QuadSetEntry quads[],
const GrQuadSetEntry quads[],
int cnt,
const GrUserStencilSettings* stencilSettings) {

View File

@ -9,13 +9,16 @@
#define GrFillRectOp_DEFINED
#include "include/private/GrTypesPriv.h"
#include "src/gpu/GrSurfaceDrawContext.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
struct DrawQuad;
class GrClip;
class GrDrawOp;
class GrPaint;
class GrQuad;
struct GrQuadSetEntry;
class GrRecordingContext;
class GrSurfaceDrawContext;
struct GrUserStencilSettings;
class SkMatrix;
struct SkRect;
@ -54,7 +57,7 @@ public:
GrPaint&&,
GrAAType,
const SkMatrix& viewMatrix,
const GrSurfaceDrawContext::QuadSetEntry quads[],
const GrQuadSetEntry quads[],
int quadCount,
const GrUserStencilSettings* = nullptr);
@ -69,7 +72,7 @@ private:
GrPaint&&,
GrAAType,
const SkMatrix& viewMatrix,
const GrSurfaceDrawContext::QuadSetEntry quads[],
const GrQuadSetEntry quads[],
int quadCount,
const GrUserStencilSettings*,
int* numConsumed);

View File

@ -22,10 +22,12 @@
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrOpsTypes.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrResourceProviderPriv.h"
#include "src/gpu/GrShaderCaps.h"
#include "src/gpu/GrSurfaceDrawContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
@ -178,7 +180,7 @@ static void normalize_src_quad(const NormalizationParams& params,
// Count the number of proxy runs in the entry set. This usually is already computed by
// SkGpuDevice, but when the BatchLengthLimiter chops the set up it must determine a new proxy count
// for each split.
static int proxy_run_count(const GrSurfaceDrawContext::TextureSetEntry set[], int count) {
static int proxy_run_count(const GrTextureSetEntry set[], int count) {
int actualProxyRunCount = 0;
const GrSurfaceProxy* lastProxy = nullptr;
for (int i = 0; i < count; ++i) {
@ -238,7 +240,7 @@ public:
}
static GrOp::Owner Make(GrRecordingContext* context,
GrSurfaceDrawContext::TextureSetEntry set[],
GrTextureSetEntry set[],
int cnt,
int proxyRunCnt,
GrSamplerState::Filter filter,
@ -478,7 +480,7 @@ private:
fViewCountPairs[0] = {proxyView.detachProxy(), quadCount};
}
TextureOp(GrSurfaceDrawContext::TextureSetEntry set[],
TextureOp(GrTextureSetEntry set[],
int cnt,
int proxyRunCnt,
GrSamplerState::Filter filter,
@ -1203,9 +1205,8 @@ public:
, fTextureColorSpaceXform(textureColorSpaceXform)
, fNumLeft(numEntries) {}
void createOp(GrSurfaceDrawContext::TextureSetEntry set[],
int clumpSize,
GrAAType aaType) {
void createOp(GrTextureSetEntry set[], int clumpSize, GrAAType aaType) {
int clumpProxyCount = proxy_run_count(&set[fNumClumped], clumpSize);
GrOp::Owner op = TextureOp::Make(fContext,
&set[fNumClumped],
@ -1246,7 +1247,7 @@ private:
void GrTextureOp::AddTextureSetOps(GrSurfaceDrawContext* rtc,
const GrClip* clip,
GrRecordingContext* context,
GrSurfaceDrawContext::TextureSetEntry set[],
GrTextureSetEntry set[],
int cnt,
int proxyRunCnt,
GrSamplerState::Filter filter,

View File

@ -12,11 +12,15 @@
#include "include/private/GrTypesPriv.h"
#include "src/gpu/GrColor.h"
#include "src/gpu/GrSamplerState.h"
#include "src/gpu/GrSurfaceDrawContext.h"
#include "src/gpu/ops/GrOp.h"
struct DrawQuad;
class GrClip;
class GrColorSpaceXform;
class GrDrawOp;
class GrSurfaceDrawContext;
class GrTextureProxy;
struct GrTextureSetEntry;
struct SkRect;
class SkMatrix;
@ -59,7 +63,7 @@ public:
static void AddTextureSetOps(GrSurfaceDrawContext*,
const GrClip* clip,
GrRecordingContext*,
GrSurfaceDrawContext::TextureSetEntry[],
GrTextureSetEntry[],
int cnt,
int proxyRunCnt,
GrSamplerState::Filter,

View File

@ -11,6 +11,7 @@
#include "src/core/SkIPoint16.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrOpsTypes.h"
#include "src/gpu/ops/GrFillRectOp.h"
#include "src/gpu/tessellate/GrPathStencilCoverOp.h"

View File

@ -17,6 +17,7 @@
#include "src/gpu/GrBlurUtils.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrOpsTypes.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrStyle.h"
#include "src/gpu/GrSurfaceDrawContext.h"
@ -878,7 +879,7 @@ void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
: GrSamplerState::Filter::kLinear;
SkBlendMode mode = paint.getBlendMode_or(SkBlendMode::kSrcOver);
SkAutoTArray<GrSurfaceDrawContext::TextureSetEntry> textures(count);
SkAutoTArray<GrTextureSetEntry> textures(count);
// We accumulate compatible proxies until we find an an incompatible one or reach the end and
// issue the accumulated 'n' draws starting at 'base'. 'p' represents the number of proxy
// switches that occur within the 'n' entries.

View File

@ -8,6 +8,7 @@
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkBlendModePriv.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrOpsTypes.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceDrawContext.h"
@ -57,7 +58,7 @@ static void fillrectop_creation_test(skiatest::Reporter* reporter, GrDirectConte
std::unique_ptr<GrSurfaceDrawContext> rtc = new_RTC(dContext);
auto quads = new GrSurfaceDrawContext::QuadSetEntry[requestedTotNumQuads];
auto quads = new GrQuadSetEntry[requestedTotNumQuads];
for (int i = 0; i < requestedTotNumQuads; ++i) {
quads[i].fRect = SkRect::MakeWH(100.5f, 100.5f); // prevent the int non-AA optimization
@ -114,7 +115,7 @@ static void textureop_creation_test(skiatest::Reporter* reporter, GrDirectContex
GrSwizzle::RGBA());
}
auto set = new GrSurfaceDrawContext::TextureSetEntry[requestedTotNumQuads];
auto set = new GrTextureSetEntry[requestedTotNumQuads];
for (int i = 0; i < requestedTotNumQuads; ++i) {
if (!allUniqueProxies) {

View File

@ -7,10 +7,12 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/ops/GrTextureOp.h"
#include "src/gpu/geometry/GrQuad.h"
#include "src/gpu/ops/GrTextureOp.h"
#include "tests/Test.h"