epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkMallocPixelRef.h" |
| 9 | #include "include/core/SkPaint.h" |
| 10 | #include "include/core/SkPicture.h" |
| 11 | #include "include/core/SkScalar.h" |
Ben Wagner | 729a23f | 2019-05-17 16:29:34 -0400 | [diff] [blame] | 12 | #include "src/core/SkArenaAlloc.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/core/SkColorSpacePriv.h" |
| 14 | #include "src/core/SkColorSpaceXformSteps.h" |
| 15 | #include "src/core/SkRasterPipeline.h" |
| 16 | #include "src/core/SkReadBuffer.h" |
| 17 | #include "src/core/SkTLazy.h" |
Mike Klein | 8e71744 | 2020-01-07 10:22:33 -0600 | [diff] [blame] | 18 | #include "src/core/SkVM.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "src/core/SkWriteBuffer.h" |
| 20 | #include "src/shaders/SkBitmapProcShader.h" |
| 21 | #include "src/shaders/SkColorShader.h" |
| 22 | #include "src/shaders/SkEmptyShader.h" |
| 23 | #include "src/shaders/SkPictureShader.h" |
| 24 | #include "src/shaders/SkShaderBase.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 25 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 26 | #if SK_SUPPORT_GPU |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 27 | #include "src/gpu/GrFragmentProcessor.h" |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 28 | #endif |
| 29 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 30 | SkShaderBase::SkShaderBase(const SkMatrix* localMatrix) |
| 31 | : fLocalMatrix(localMatrix ? *localMatrix : SkMatrix::I()) { |
mtklein | 435eba7 | 2014-12-01 12:06:24 -0800 | [diff] [blame] | 32 | // Pre-cache so future calls to fLocalMatrix.getType() are threadsafe. |
| 33 | (void)fLocalMatrix.getType(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Mike Klein | de2244c | 2018-12-04 11:16:08 -0500 | [diff] [blame] | 36 | SkShaderBase::~SkShaderBase() {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 38 | void SkShaderBase::flatten(SkWriteBuffer& buffer) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 39 | this->INHERITED::flatten(buffer); |
commit-bot@chromium.org | 5970f62 | 2014-05-12 20:42:21 +0000 | [diff] [blame] | 40 | bool hasLocalM = !fLocalMatrix.isIdentity(); |
bsalomon@google.com | f94b3a4 | 2012-10-31 18:09:01 +0000 | [diff] [blame] | 41 | buffer.writeBool(hasLocalM); |
| 42 | if (hasLocalM) { |
| 43 | buffer.writeMatrix(fLocalMatrix); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 47 | SkTCopyOnFirstWrite<SkMatrix> |
| 48 | SkShaderBase::totalLocalMatrix(const SkMatrix* preLocalMatrix, |
| 49 | const SkMatrix* postLocalMatrix) const { |
| 50 | SkTCopyOnFirstWrite<SkMatrix> m(fLocalMatrix); |
| 51 | |
| 52 | if (preLocalMatrix) { |
| 53 | m.writable()->preConcat(*preLocalMatrix); |
| 54 | } |
| 55 | |
| 56 | if (postLocalMatrix) { |
| 57 | m.writable()->postConcat(*postLocalMatrix); |
| 58 | } |
| 59 | |
| 60 | return m; |
| 61 | } |
| 62 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 63 | bool SkShaderBase::computeTotalInverse(const SkMatrix& ctm, |
| 64 | const SkMatrix* outerLocalMatrix, |
| 65 | SkMatrix* totalInverse) const { |
Florin Malita | c6c5ead | 2018-04-11 15:33:40 -0400 | [diff] [blame] | 66 | return SkMatrix::Concat(ctm, *this->totalLocalMatrix(outerLocalMatrix)).invert(totalInverse); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 69 | bool SkShaderBase::asLuminanceColor(SkColor* colorPtr) const { |
reed | 8367b8c | 2014-08-22 08:30:20 -0700 | [diff] [blame] | 70 | SkColor storage; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 71 | if (nullptr == colorPtr) { |
reed | 8367b8c | 2014-08-22 08:30:20 -0700 | [diff] [blame] | 72 | colorPtr = &storage; |
| 73 | } |
| 74 | if (this->onAsLuminanceColor(colorPtr)) { |
| 75 | *colorPtr = SkColorSetA(*colorPtr, 0xFF); // we only return opaque |
| 76 | return true; |
| 77 | } |
| 78 | return false; |
| 79 | } |
| 80 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 81 | SkShaderBase::Context* SkShaderBase::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const { |
Mike Reed | e92aae6 | 2018-10-17 10:21:51 -0400 | [diff] [blame] | 82 | #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT |
Florin Malita | af2769d | 2018-04-04 13:46:35 -0400 | [diff] [blame] | 83 | // We always fall back to raster pipeline when perspective is present. |
| 84 | if (rec.fMatrix->hasPerspective() || |
| 85 | fLocalMatrix.hasPerspective() || |
| 86 | (rec.fLocalMatrix && rec.fLocalMatrix->hasPerspective()) || |
| 87 | !this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, nullptr)) { |
| 88 | return nullptr; |
| 89 | } |
| 90 | |
| 91 | return this->onMakeContext(rec, alloc); |
Mike Reed | e92aae6 | 2018-10-17 10:21:51 -0400 | [diff] [blame] | 92 | #else |
| 93 | return nullptr; |
| 94 | #endif |
commit-bot@chromium.org | f3e5059 | 2014-04-30 23:29:02 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 97 | SkShaderBase::Context::Context(const SkShaderBase& shader, const ContextRec& rec) |
commit-bot@chromium.org | 80116dc | 2014-05-06 17:16:03 +0000 | [diff] [blame] | 98 | : fShader(shader), fCTM(*rec.fMatrix) |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 99 | { |
Florin Malita | af2769d | 2018-04-04 13:46:35 -0400 | [diff] [blame] | 100 | // We should never use a context with perspective. |
Florin Malita | 5769dd2 | 2017-07-12 13:31:25 -0400 | [diff] [blame] | 101 | SkASSERT(!rec.fMatrix->hasPerspective()); |
| 102 | SkASSERT(!rec.fLocalMatrix || !rec.fLocalMatrix->hasPerspective()); |
Florin Malita | af2769d | 2018-04-04 13:46:35 -0400 | [diff] [blame] | 103 | SkASSERT(!shader.getLocalMatrix().hasPerspective()); |
Florin Malita | 7d022e0 | 2017-05-15 15:06:39 -0400 | [diff] [blame] | 104 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 105 | // Because the context parameters must be valid at this point, we know that the matrix is |
| 106 | // invertible. |
Florin Malita | 26368c3 | 2017-05-08 13:03:24 -0400 | [diff] [blame] | 107 | SkAssertResult(fShader.computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, &fTotalInverse)); |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 108 | |
commit-bot@chromium.org | e901b6d | 2014-05-01 19:31:31 +0000 | [diff] [blame] | 109 | fPaintAlpha = rec.fPaint->getAlpha(); |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 112 | SkShaderBase::Context::~Context() {} |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 113 | |
Mike Reed | 011d166 | 2019-02-28 17:19:25 -0500 | [diff] [blame] | 114 | bool SkShaderBase::ContextRec::isLegacyCompatible(SkColorSpace* shaderColorSpace) const { |
Mike Klein | a7bb87e | 2019-12-03 11:04:54 -0600 | [diff] [blame] | 115 | // In legacy pipelines, shaders always produce premul (or opaque) and the destination is also |
| 116 | // always premul (or opaque). (And those "or opaque" caveats won't make any difference here.) |
| 117 | SkAlphaType shaderAT = kPremul_SkAlphaType, |
| 118 | dstAT = kPremul_SkAlphaType; |
| 119 | return 0 == SkColorSpaceXformSteps{shaderColorSpace, shaderAT, |
| 120 | fDstColorSpace, dstAT}.flags.mask(); |
Mike Reed | 011d166 | 2019-02-28 17:19:25 -0500 | [diff] [blame] | 121 | } |
| 122 | |
Mike Reed | fae8fce | 2019-04-03 10:27:45 -0400 | [diff] [blame] | 123 | SkImage* SkShader::isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const { |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 124 | return as_SB(this)->onIsAImage(localMatrix, xy); |
| 125 | } |
| 126 | |
vandebo@chromium.org | d3ae779 | 2011-02-24 00:21:06 +0000 | [diff] [blame] | 127 | SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { |
| 128 | return kNone_GradientType; |
| 129 | } |
| 130 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 131 | #if SK_SUPPORT_GPU |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 132 | std::unique_ptr<GrFragmentProcessor> SkShaderBase::asFragmentProcessor(const GrFPArgs&) const { |
bsalomon | c21b09e | 2015-08-28 18:46:56 -0700 | [diff] [blame] | 133 | return nullptr; |
rileya@google.com | 03c1c35 | 2012-07-20 20:02:43 +0000 | [diff] [blame] | 134 | } |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 135 | #endif |
rileya@google.com | 03c1c35 | 2012-07-20 20:02:43 +0000 | [diff] [blame] | 136 | |
Mike Reed | 7656b2c | 2019-04-08 11:48:20 -0400 | [diff] [blame] | 137 | sk_sp<SkShader> SkShaderBase::makeAsALocalMatrixShader(SkMatrix*) const { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 138 | return nullptr; |
commit-bot@chromium.org | 8fae213 | 2014-05-07 22:26:37 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Mike Reed | c8bea7d | 2019-04-09 13:55:36 -0400 | [diff] [blame] | 141 | sk_sp<SkShader> SkShaders::Empty() { return sk_make_sp<SkEmptyShader>(); } |
| 142 | sk_sp<SkShader> SkShaders::Color(SkColor color) { return sk_make_sp<SkColorShader>(color); } |
reed | 8367b8c | 2014-08-22 08:30:20 -0700 | [diff] [blame] | 143 | |
Mike Reed | 50acf8f | 2019-04-08 13:20:23 -0400 | [diff] [blame] | 144 | sk_sp<SkShader> SkBitmap::makeShader(SkTileMode tmx, SkTileMode tmy, const SkMatrix* lm) const { |
| 145 | if (lm && !lm->invert(nullptr)) { |
| 146 | return nullptr; |
| 147 | } |
| 148 | return SkMakeBitmapShader(*this, tmx, tmy, lm, kIfMutable_SkCopyPixelsMode); |
| 149 | } |
| 150 | |
| 151 | sk_sp<SkShader> SkBitmap::makeShader(const SkMatrix* lm) const { |
| 152 | return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, lm); |
| 153 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 154 | |
Mike Reed | 1386b2d | 2019-03-13 21:15:05 -0400 | [diff] [blame] | 155 | bool SkShaderBase::appendStages(const SkStageRec& rec) const { |
Mike Reed | 1d8c42e | 2017-08-29 14:58:19 -0400 | [diff] [blame] | 156 | return this->onAppendStages(rec); |
Florin Malita | 9206c76 | 2017-01-30 12:08:05 -0500 | [diff] [blame] | 157 | } |
| 158 | |
Mike Reed | 1386b2d | 2019-03-13 21:15:05 -0400 | [diff] [blame] | 159 | bool SkShaderBase::onAppendStages(const SkStageRec& rec) const { |
Mike Klein | 541cbd4 | 2019-01-30 13:11:33 -0500 | [diff] [blame] | 160 | // SkShader::Context::shadeSpan() handles the paint opacity internally, |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 161 | // but SkRasterPipelineBlitter applies it as a separate stage. |
Mike Klein | 541cbd4 | 2019-01-30 13:11:33 -0500 | [diff] [blame] | 162 | // We skip the internal shadeSpan() step by forcing the paint opaque. |
Mike Reed | 1d8c42e | 2017-08-29 14:58:19 -0400 | [diff] [blame] | 163 | SkTCopyOnFirstWrite<SkPaint> opaquePaint(rec.fPaint); |
| 164 | if (rec.fPaint.getAlpha() != SK_AlphaOPAQUE) { |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 165 | opaquePaint.writable()->setAlpha(SK_AlphaOPAQUE); |
| 166 | } |
| 167 | |
Mike Klein | 894328d | 2019-03-21 10:06:38 -0500 | [diff] [blame] | 168 | ContextRec cr(*opaquePaint, rec.fCTM, rec.fLocalM, rec.fDstColorType, sk_srgb_singleton()); |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 169 | |
Mike Klein | b11ab57 | 2018-10-24 06:42:14 -0400 | [diff] [blame] | 170 | struct CallbackCtx : SkRasterPipeline_CallbackCtx { |
Mike Klein | b0b2c96 | 2019-03-21 10:33:51 -0500 | [diff] [blame] | 171 | sk_sp<const SkShader> shader; |
| 172 | Context* ctx; |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 173 | }; |
Mike Reed | 1d8c42e | 2017-08-29 14:58:19 -0400 | [diff] [blame] | 174 | auto cb = rec.fAlloc->make<CallbackCtx>(); |
Mike Klein | b0b2c96 | 2019-03-21 10:33:51 -0500 | [diff] [blame] | 175 | cb->shader = sk_ref_sp(this); |
| 176 | cb->ctx = as_SB(this)->makeContext(cr, rec.fAlloc); |
Mike Klein | b11ab57 | 2018-10-24 06:42:14 -0400 | [diff] [blame] | 177 | cb->fn = [](SkRasterPipeline_CallbackCtx* self, int active_pixels) { |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 178 | auto c = (CallbackCtx*)self; |
| 179 | int x = (int)c->rgba[0], |
Mike Klein | 541cbd4 | 2019-01-30 13:11:33 -0500 | [diff] [blame] | 180 | y = (int)c->rgba[1]; |
| 181 | SkPMColor tmp[SkRasterPipeline_kMaxStride]; |
| 182 | c->ctx->shadeSpan(x,y, tmp, active_pixels); |
| 183 | |
| 184 | for (int i = 0; i < active_pixels; i++) { |
| 185 | auto rgba_4f = SkPMColor4f::FromPMColor(tmp[i]); |
| 186 | memcpy(c->rgba + 4*i, rgba_4f.vec(), 4*sizeof(float)); |
| 187 | } |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | if (cb->ctx) { |
Mike Klein | e8de024 | 2018-03-10 12:37:11 -0500 | [diff] [blame] | 191 | rec.fPipeline->append(SkRasterPipeline::seed_shader); |
Mike Reed | 1d8c42e | 2017-08-29 14:58:19 -0400 | [diff] [blame] | 192 | rec.fPipeline->append(SkRasterPipeline::callback, cb); |
Mike Klein | 894328d | 2019-03-21 10:06:38 -0500 | [diff] [blame] | 193 | rec.fAlloc->make<SkColorSpaceXformSteps>(sk_srgb_singleton(), kPremul_SkAlphaType, |
| 194 | rec.fDstCS, kPremul_SkAlphaType) |
| 195 | ->apply(rec.fPipeline, true); |
Mike Reed | 6867eee | 2017-06-02 13:25:15 -0400 | [diff] [blame] | 196 | return true; |
| 197 | } |
Mike Klein | 44d3279 | 2017-05-10 12:29:38 -0400 | [diff] [blame] | 198 | return false; |
| 199 | } |
| 200 | |
Mike Klein | 0393505 | 2019-11-01 11:36:55 -0500 | [diff] [blame] | 201 | bool SkShaderBase::program(skvm::Builder* p, |
Mike Klein | f6a715b | 2019-12-30 15:24:18 -0600 | [diff] [blame] | 202 | const SkMatrix& ctm, const SkMatrix* localM, |
| 203 | SkFilterQuality quality, SkColorSpace* dstCS, |
Mike Klein | 3ab7128 | 2020-01-06 19:53:39 -0600 | [diff] [blame] | 204 | skvm::Uniforms* uniforms, SkArenaAlloc* alloc, |
Mike Klein | f3d4109 | 2019-11-04 13:22:02 -0600 | [diff] [blame] | 205 | skvm::F32 x, skvm::F32 y, |
Mike Klein | b9f2088 | 2019-11-08 12:14:15 -0600 | [diff] [blame] | 206 | skvm::F32* r, skvm::F32* g, skvm::F32* b, skvm::F32* a) const { |
Mike Klein | 0393505 | 2019-11-01 11:36:55 -0500 | [diff] [blame] | 207 | // Force opaque alpha for all opaque shaders. |
| 208 | // |
Mike Klein | b9f2088 | 2019-11-08 12:14:15 -0600 | [diff] [blame] | 209 | // This is primarily nice in that we usually have a 1.0f constant splat |
Mike Klein | 0393505 | 2019-11-01 11:36:55 -0500 | [diff] [blame] | 210 | // somewhere in the program anyway, and this will let us drop the work the |
| 211 | // shader notionally does to produce alpha, p->extract(...), etc. in favor |
| 212 | // of that simple hoistable splat. |
| 213 | // |
| 214 | // More subtly, it makes isOpaque() a parameter to all shader program |
| 215 | // generation, guaranteeing that is-opaque bit is mixed into the overall |
| 216 | // shader program hash and blitter Key. This makes it safe for us to use |
| 217 | // that bit to make decisions when constructing an SkVMBlitter, like doing |
| 218 | // SrcOver -> Src strength reduction. |
Mike Klein | 3ab7128 | 2020-01-06 19:53:39 -0600 | [diff] [blame] | 219 | if (this->onProgram(p, ctm,localM, quality,dstCS, uniforms,alloc, x,y, r,g,b,a)) { |
Mike Klein | fb9146f | 2019-11-05 05:49:34 -0600 | [diff] [blame] | 220 | if (this->isOpaque()) { |
Mike Klein | b9f2088 | 2019-11-08 12:14:15 -0600 | [diff] [blame] | 221 | *a = p->splat(1.0f); |
Mike Klein | 0393505 | 2019-11-01 11:36:55 -0500 | [diff] [blame] | 222 | } |
| 223 | return true; |
| 224 | } |
| 225 | return false; |
| 226 | } |
| 227 | |
Mike Klein | 8e71744 | 2020-01-07 10:22:33 -0600 | [diff] [blame] | 228 | bool SkShaderBase::onProgram(skvm::Builder*, |
| 229 | const SkMatrix& ctm, const SkMatrix* localM, |
| 230 | SkFilterQuality quality, SkColorSpace* dstCS, |
| 231 | skvm::Uniforms* uniforms, SkArenaAlloc* alloc, |
| 232 | skvm::F32 x, skvm::F32 y, |
| 233 | skvm::F32* r, skvm::F32* g, skvm::F32* b, skvm::F32* a) const { |
| 234 | return false; |
| 235 | } |
| 236 | |
Mike Klein | 85754d5 | 2020-01-22 10:04:11 -0600 | [diff] [blame] | 237 | void SkShaderBase::ApplyMatrix(skvm::Builder* p, const SkMatrix& m, |
| 238 | skvm::F32* x, skvm::F32* y, skvm::Uniforms* uniforms) { |
| 239 | if (m.isIdentity()) { |
| 240 | // That was easy. |
| 241 | } else if (m.isTranslate()) { |
| 242 | *x = p->add(*x, p->uniformF(uniforms->pushF(m[2]))); |
| 243 | *y = p->add(*y, p->uniformF(uniforms->pushF(m[5]))); |
| 244 | } else if (m.isScaleTranslate()) { |
| 245 | *x = p->mad(*x, p->uniformF(uniforms->pushF(m[0])), p->uniformF(uniforms->pushF(m[2]))); |
| 246 | *y = p->mad(*y, p->uniformF(uniforms->pushF(m[4])), p->uniformF(uniforms->pushF(m[5]))); |
| 247 | } else { // Affine or perspective. |
| 248 | auto dot = [&,X=*x,Y=*y](int row) { |
| 249 | return p->mad(X, p->uniformF(uniforms->pushF(m[3*row+0])), |
| 250 | p->mad(Y, p->uniformF(uniforms->pushF(m[3*row+1])), |
| 251 | p->uniformF(uniforms->pushF(m[3*row+2])))); |
| 252 | }; |
| 253 | *x = dot(0); |
| 254 | *y = dot(1); |
| 255 | if (m.hasPerspective()) { |
| 256 | *x = p->div(*x, dot(2)); |
| 257 | *y = p->div(*y, dot(2)); |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
reed | 0ccc62d | 2016-05-04 13:09:39 -0700 | [diff] [blame] | 262 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
reed | 830dfd8 | 2016-03-16 12:29:01 -0700 | [diff] [blame] | 263 | |
reed | 60c9b58 | 2016-04-03 09:11:13 -0700 | [diff] [blame] | 264 | sk_sp<SkFlattenable> SkEmptyShader::CreateProc(SkReadBuffer&) { |
Mike Reed | c8bea7d | 2019-04-09 13:55:36 -0400 | [diff] [blame] | 265 | return SkShaders::Empty(); |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 266 | } |