rename the VM blitter to SkVMBlitter
Change-Id: I71ae924d32dc2268cc4a3db1920c08287533f9ae Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430697 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
7fc705bdd7
commit
a7a9443104
@ -406,6 +406,7 @@ skia_core_sources = [
|
||||
"$_src/core/SkVM.cpp",
|
||||
"$_src/core/SkVM.h",
|
||||
"$_src/core/SkVMBlitter.cpp",
|
||||
"$_src/core/SkVMBlitter.h",
|
||||
"$_src/core/SkVM_fwd.h",
|
||||
"$_src/core/SkValidationUtils.h",
|
||||
"$_src/core/SkVertState.cpp",
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "src/core/SkRegionPriv.h"
|
||||
#include "src/core/SkTLazy.h"
|
||||
#include "src/core/SkUtils.h"
|
||||
#include "src/core/SkVMBlitter.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include "src/core/SkXfermodeInterpretation.h"
|
||||
#include "src/shaders/SkShaderBase.h"
|
||||
@ -748,8 +749,8 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
}
|
||||
|
||||
if (gUseSkVMBlitter) {
|
||||
if (auto blitter = SkCreateSkVMBlitter(device, *paint, matrixProvider,
|
||||
alloc, clipShader)) {
|
||||
if (auto blitter = SkVMBlitter::Make(device, *paint, matrixProvider,
|
||||
alloc, clipShader)) {
|
||||
return blitter;
|
||||
}
|
||||
}
|
||||
@ -761,8 +762,8 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
alloc, clipShader)) {
|
||||
return blitter;
|
||||
}
|
||||
if (auto blitter = SkCreateSkVMBlitter(device, *paint, matrixProvider,
|
||||
alloc, clipShader)) {
|
||||
if (auto blitter = SkVMBlitter::Make(device, *paint, matrixProvider,
|
||||
alloc, clipShader)) {
|
||||
return blitter;
|
||||
}
|
||||
return alloc->make<SkNullBlitter>();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "src/core/SkOpts.h"
|
||||
#include "src/core/SkRasterPipeline.h"
|
||||
#include "src/core/SkSpriteBlitter.h"
|
||||
#include "src/core/SkVMBlitter.h"
|
||||
|
||||
extern bool gUseSkVMBlitter;
|
||||
|
||||
@ -187,7 +188,7 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
|
||||
SkASSERT(alloc != nullptr);
|
||||
|
||||
if (gUseSkVMBlitter) {
|
||||
return SkCreateSkVMSpriteBlitter(dst, paint, source,left,top, alloc, std::move(clipShader));
|
||||
return SkVMBlitter::Make(dst, paint, source,left,top, alloc, std::move(clipShader));
|
||||
}
|
||||
|
||||
// TODO: in principle SkRasterPipelineSpriteBlitter could be made to handle this.
|
||||
@ -225,5 +226,5 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
|
||||
return blitter;
|
||||
}
|
||||
|
||||
return SkCreateSkVMSpriteBlitter(dst, paint, source,left,top, alloc, std::move(clipShader));
|
||||
return SkVMBlitter::Make(dst, paint, source,left,top, alloc, std::move(clipShader));
|
||||
}
|
||||
|
@ -173,17 +173,4 @@ SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap&, const SkPaint&,
|
||||
bool shader_is_opaque,
|
||||
SkArenaAlloc*, sk_sp<SkShader> clipShader);
|
||||
|
||||
SkBlitter* SkCreateSkVMBlitter(const SkPixmap& dst,
|
||||
const SkPaint&,
|
||||
const SkMatrixProvider&,
|
||||
SkArenaAlloc*,
|
||||
sk_sp<SkShader> clipShader);
|
||||
|
||||
SkBlitter* SkCreateSkVMSpriteBlitter(const SkPixmap& dst,
|
||||
const SkPaint&,
|
||||
const SkPixmap& sprite,
|
||||
int left, int top,
|
||||
SkArenaAlloc*,
|
||||
sk_sp<SkShader> clipShader);
|
||||
|
||||
#endif
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "src/core/SkRasterPipeline.h"
|
||||
#include "src/core/SkScan.h"
|
||||
#include "src/core/SkVM.h"
|
||||
#include "src/core/SkVMBlitter.h"
|
||||
#include "src/core/SkVertState.h"
|
||||
#include "src/core/SkVerticesPriv.h"
|
||||
#include "src/shaders/SkComposeShader.h"
|
||||
@ -308,7 +309,7 @@ void SkDraw::drawFixedVertices(const SkVertices* vertices, SkBlendMode blendMode
|
||||
// No colors are changing and no texture coordinates are changing, so no updates between
|
||||
// triangles are needed. Use SkVM to blit the triangles.
|
||||
if (!colors && (!texCoords || texCoords == positions)) {
|
||||
if (auto blitter = SkCreateSkVMBlitter(
|
||||
if (auto blitter = SkVMBlitter::Make(
|
||||
fDst, paint, *fMatrixProvider, outerAlloc, this->fRC->clipShader())) {
|
||||
while (vertProc(&state)) {
|
||||
fill_triangle(state, blitter, *fRC, dev2, dev3);
|
||||
|
File diff suppressed because it is too large
Load Diff
106
src/core/SkVMBlitter.h
Normal file
106
src/core/SkVMBlitter.h
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 SkVMBlitter_DEFINED
|
||||
#define SkVMBlitter_DEFINED
|
||||
|
||||
#include "src/core/SkLRUCache.h"
|
||||
#include "src/core/SkVM.h"
|
||||
|
||||
class SkVMBlitter final : public SkBlitter {
|
||||
public:
|
||||
static SkVMBlitter* Make(const SkPixmap& dst,
|
||||
const SkPaint&,
|
||||
const SkMatrixProvider&,
|
||||
SkArenaAlloc*,
|
||||
sk_sp<SkShader> clipShader);
|
||||
|
||||
static SkVMBlitter* Make(const SkPixmap& dst,
|
||||
const SkPaint&,
|
||||
const SkPixmap& sprite,
|
||||
int left, int top,
|
||||
SkArenaAlloc*,
|
||||
sk_sp<SkShader> clipShader);
|
||||
|
||||
SkVMBlitter(const SkPixmap& device,
|
||||
const SkPaint& paint,
|
||||
const SkPixmap* sprite,
|
||||
SkIPoint spriteOffset,
|
||||
const SkMatrixProvider& matrices,
|
||||
sk_sp<SkShader> clip,
|
||||
bool* ok);
|
||||
|
||||
~SkVMBlitter() override;
|
||||
|
||||
private:
|
||||
enum class Coverage { Full, UniformF, MaskA8, MaskLCD16, Mask3D };
|
||||
struct Key {
|
||||
uint64_t shader,
|
||||
clip,
|
||||
blender,
|
||||
colorSpace;
|
||||
uint8_t colorType,
|
||||
alphaType,
|
||||
coverage;
|
||||
uint8_t padding8{0};
|
||||
uint32_t padding{0};
|
||||
// Params::{paint,quality,matrices} are only passed to {shader,clip}->program(),
|
||||
// not used here by the blitter itself. No need to include them in the key;
|
||||
// they'll be folded into the shader key if used.
|
||||
|
||||
bool operator==(const Key& that) const;
|
||||
Key withCoverage(Coverage c) const;
|
||||
};
|
||||
|
||||
struct Params {
|
||||
sk_sp<SkShader> shader;
|
||||
sk_sp<SkShader> clip;
|
||||
sk_sp<SkBlender> blender; // never null
|
||||
SkColorInfo dst;
|
||||
Coverage coverage;
|
||||
SkColor4f paint;
|
||||
const SkMatrixProvider& matrices;
|
||||
|
||||
Params withCoverage(Coverage c) const;
|
||||
};
|
||||
|
||||
static Params EffectiveParams(const SkPixmap& device,
|
||||
const SkPixmap* sprite,
|
||||
SkPaint paint,
|
||||
const SkMatrixProvider& matrices,
|
||||
sk_sp<SkShader> clip);
|
||||
static skvm::Color DstColor(skvm::Builder* p, const Params& params);
|
||||
static void BuildProgram(skvm::Builder* p, const Params& params,
|
||||
skvm::Uniforms* uniforms, SkArenaAlloc* alloc);
|
||||
static Key CacheKey(const Params& params,
|
||||
skvm::Uniforms* uniforms, SkArenaAlloc* alloc, bool* ok);
|
||||
static SkLRUCache<Key, skvm::Program>* TryAcquireProgramCache();
|
||||
static SkString DebugName(const Key& key);
|
||||
static void ReleaseProgramCache();
|
||||
|
||||
skvm::Program buildProgram(Coverage coverage);
|
||||
void updateUniforms(int right, int y);
|
||||
const void* isSprite(int x, int y) const;
|
||||
|
||||
void blitH(int x, int y, int w) override;
|
||||
void blitAntiH(int x, int y, const SkAlpha cov[], const int16_t runs[]) override;
|
||||
void blitMask(const SkMask& mask, const SkIRect& clip) override;
|
||||
|
||||
SkPixmap fDevice;
|
||||
const SkPixmap fSprite; // See isSprite().
|
||||
const SkIPoint fSpriteOffset;
|
||||
skvm::Uniforms fUniforms; // Most data is copied directly into fUniforms,
|
||||
SkArenaAlloc fAlloc{2*sizeof(void*)}; // but a few effects need to ref large content.
|
||||
const Params fParams;
|
||||
const Key fKey;
|
||||
skvm::Program fBlitH,
|
||||
fBlitAntiH,
|
||||
fBlitMaskA8,
|
||||
fBlitMask3D,
|
||||
fBlitMaskLCD16;
|
||||
};
|
||||
#endif // SkVMBlitter_DEFINED
|
Loading…
Reference in New Issue
Block a user