Lines Matching +full:path +full:- +full:key
4 * Use of this source code is governed by a BSD-style license that can be
81 sk_sp<SkVertices> makeVertices(const SkPath& path, const SkMatrix& ctm, in makeVertices()
91 return SkShadowTessellator::MakeAmbient(path, noTrans, zParams, fTransparent); in makeVertices()
134 translate->set(0, 0); in isCompatible()
140 *translate = that.fOffset - fOffset; in isCompatible()
146 sk_sp<SkVertices> makeVertices(const SkPath& path, const SkMatrix& ctm, in makeVertices()
154 translate->set(0, 0); in makeVertices()
155 return SkShadowTessellator::MakeSpot(path, ctm, zParams, fDevLightPos, fLightRadius, in makeVertices()
158 translate->set(0, 0); in makeVertices()
159 return SkShadowTessellator::MakeSpot(path, ctm, zParams, fDevLightPos, fLightRadius, in makeVertices()
162 // pick a canonical place to generate shadow, with light centered over path in makeVertices()
170 return SkShadowTessellator::MakeSpot(path, noTrans, zParams, in makeVertices()
235 sk_sp<SkVertices> add(const SkPath& path, const FACTORY& factory, const SkMatrix& matrix, in add() argument
237 … sk_sp<SkVertices> vertices = factory.makeVertices(path, matrix, translate, isLimitElevation); in add()
246 fSize -= fEntries[i].fVertices->approximateSize(); in add()
251 fSize += vertices->approximateSize(); in add()
273 * path. The key represents the path's geometry and not any shadow params.
277 CachedTessellationsRec(const SkResourceCache::Key& key, in CachedTessellationsRec() argument
280 fKey.reset(new uint8_t[key.size()]); in CachedTessellationsRec()
281 memcpy(fKey.get(), &key, key.size()); in CachedTessellationsRec()
284 const Key& getKey() const override { in getKey()
285 return *reinterpret_cast<SkResourceCache::Key*>(fKey.get()); in getKey()
288 size_t bytesUsed() const override { return fTessellations->size(); } in bytesUsed()
297 return fTessellations->find(factory, matrix, translate); in find()
329 * Function called by SkResourceCache when a matching cache key is found. The FACTORY and matrix of
337 findContext->fVertices = in FindVisitor()
338 rec.find(*findContext->fFactory, *findContext->fViewMatrix, &findContext->fTranslate); in FindVisitor()
339 if (findContext->fVertices) { in FindVisitor()
344 findContext->fTessellationsOnFailure = rec.refTessellations(); in FindVisitor()
350 ShadowedPath(const SkPath* path, const SkMatrix* viewMatrix) in ShadowedPath() argument
351 : fPath(path) in ShadowedPath()
354 , fShapeForKey(*path, GrStyle::SimpleFill()) in ShadowedPath()
358 const SkPath& path() const { return *fPath; } in path() function in __anon0747994b0111::ShadowedPath
361 /** Negative means the vertices should not be cached for this path. */
363 void writeKey(void* key) const { in writeKey()
364 fShapeForKey.writeUnstyledKey(reinterpret_cast<uint32_t*>(key)); in writeKey()
368 int keyBytes() const { return -1; } in keyBytes()
369 void writeKey(void* key) const { SK_ABORT("Should never be called"); } in writeKey()
384 // When the SkPathRef genID changes, invalidate a corresponding GrResource described by key.
387 ShadowInvalidator(const SkResourceCache::Key& key) { in ShadowInvalidator() argument
388 fKey.reset(new uint8_t[key.size()]); in ShadowInvalidator()
389 memcpy(fKey.get(), &key, key.size()); in ShadowInvalidator()
393 const SkResourceCache::Key& getKey() const { in getKey()
394 return *reinterpret_cast<SkResourceCache::Key*>(fKey.get()); in getKey()
403 SkResourceCache::Find(this->getKey(), ShadowInvalidator::FindVisitor, nullptr); in changed()
416 SkScalar tx, SkScalar ty, bool)> drawProc, ShadowedPath& path, in draw_shadow() argument
418 FindContext<FACTORY> context(&path.viewMatrix(), &factory); in draw_shadow()
420 SkResourceCache::Key* key = nullptr; in draw_shadow() local
422 // We need to make this array be of the cache's Key so the memory we create the Key in in draw_shadow()
424 AutoSTArray<kMinBytes / sizeof(SkResourceCache::Key), SkResourceCache::Key> keyStorage; in draw_shadow()
425 int keyDataBytes = path.keyBytes(); in draw_shadow()
427 // Store the key... in draw_shadow()
428 keyStorage.reset(keyDataBytes + sizeof(SkResourceCache::Key)); in draw_shadow()
429 key = new (keyStorage.begin()) SkResourceCache::Key(); in draw_shadow()
430 // ... followed by the bytes from path. in draw_shadow()
431 path.writeKey((uint32_t*)(((uint8_t*)keyStorage.begin()) + sizeof(SkResourceCache::Key))); in draw_shadow()
432 key->init(&kNamespace, resource_cache_shared_id(), keyDataBytes); in draw_shadow()
433 SkResourceCache::Find(*key, FindVisitor<FACTORY>, &context); in draw_shadow()
441 // TODO: handle transforming the path as part of the tessellator in draw_shadow()
442 if (key) { in draw_shadow()
450 vertices = tessellations->add(path.path(), factory, path.viewMatrix(), in draw_shadow()
455 auto rec = new CachedTessellationsRec(*key, std::move(tessellations)); in draw_shadow()
456 SkPathPriv::AddGenIDChangeListener(path.path(), sk_make_sp<ShadowInvalidator>(*key)); in draw_shadow()
459 vertices = factory.makeVertices(path.path(), path.viewMatrix(), in draw_shadow()
471 SkColorFilters::Blend(color, SkBlendMode::kModulate)->makeComposed( in draw_shadow()
475 context.fTranslate.fX, context.fTranslate.fY, path.viewMatrix().hasPerspective()); in draw_shadow()
513 SkScalar alphaAdjust = (2.6f + (-2.66667f + 1.06667f*origA)*origA)*origA; in ComputeTonalColors()
514 SkScalar colorAlpha = (3.544762f + (-4.891428f + 2.3466f*luminance)*luminance)*luminance; in ComputeTonalColors()
521 SkScalar greyscaleAlpha = SkTPin(origA*(1 - 0.4f*luminance), 0.0f, 1.0f); in ComputeTonalColors()
528 // (C_a - S_a*C_a)*C_rgb + (1 - (S_a + C_a - S_a*C_a))*B_rgb in ComputeTonalColors()
530 // Assuming premultiplied alpha, this means we scale the color by (C_a - S_a*C_a) and in ComputeTonalColors()
531 // set the alpha to (S_a + C_a - S_a*C_a). in ComputeTonalColors()
532 SkScalar colorScale = colorAlpha*(SK_Scalar1 - greyscaleAlpha); in ComputeTonalColors()
541 static bool fill_shadow_rec(const SkPath& path, const SkPoint3& zPlaneParams, in fill_shadow_rec() argument
556 rec->fZPlaneParams = zPlaneParams; in fill_shadow_rec()
557 rec->fLightPos = { pt.fX, pt.fY, lightPos.fZ }; in fill_shadow_rec()
558 rec->fLightRadius = lightRadius; in fill_shadow_rec()
559 rec->fAmbientColor = ambientColor; in fill_shadow_rec()
560 rec->fSpotColor = spotColor; in fill_shadow_rec()
561 rec->fFlags = flags; in fill_shadow_rec()
566 // Draw an offset spot shadow and outlining ambient shadow for the given path.
567 void SkShadowUtils::DrawShadow(SkCanvas* canvas, const SkPath& path, const SkPoint3& zPlaneParams, in DrawShadow() argument
571 …DrawShadowStyle(canvas, path, zPlaneParams, lightPos, lightRadius, ambientColor, spotColor, flags,… in DrawShadow()
574 void SkShadowUtils::DrawShadowStyle(SkCanvas* canvas, const SkPath& path, const SkPoint3& zPlanePar… in DrawShadowStyle() argument
580 if (!fill_shadow_rec(path, zPlaneParams, lightPos, lightRadius, ambientColor, spotColor, in DrawShadowStyle()
581 flags, canvas->getTotalMatrix(), &rec)) { in DrawShadowStyle()
585 canvas->private_draw_shadow_rec(path, rec); in DrawShadowStyle()
588 bool SkShadowUtils::GetLocalBounds(const SkMatrix& ctm, const SkPath& path, in GetLocalBounds() argument
592 if (!fill_shadow_rec(path, zPlaneParams, lightPos, lightRadius, SK_ColorBLACK, SK_ColorBLACK, in GetLocalBounds()
597 SkDrawShadowMetrics::GetLocalBounds(path, rec, ctm, bounds); in GetLocalBounds()
609 void SkDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) { in drawShadow() argument
614 SkMatrix viewMatrix = this->localToDevice(); in drawShadow()
620 if (vertices->priv().vertexCount()) { in drawShadow()
627 : this->localToDevice() * SkMatrix::Translate(tx, ty)); in drawShadow()
630 // their alpha. We can skip expensive per-vertex color conversion for this. in drawShadow()
631 this->drawVertices(vertices, SkBlender::Mode(mode), paint, /*skipColorXform=*/true); in drawShadow()
635 ShadowedPath shadowedPath(&path, &viewMatrix); in drawShadow()
640 !path.isConvex(); in drawShadow()
641 bool uncached = tiltZPlane || path.isVolatile(); in drawShadow()
656 sk_sp<SkVertices> vertices = SkShadowTessellator::MakeAmbient(path, viewMatrix, in drawShadow()
665 SkBlendMode::kModulate)->makeComposed( in drawShadow()
669 // their alpha. We can skip expensive per-vertex color conversion for this. in drawShadow()
670 this->drawVertices(vertices.get(), in drawShadow()
695 // Pretransform the path to avoid transforming the stroke, below. in drawShadow()
697 path.transform(viewMatrix, &devSpacePath); in drawShadow()
701 // the tesselation, and sets the alpha on the path to 1/AmbientRecipAlpha (or 'a'). in drawShadow()
707 // | |<---------- r ------>| in drawShadow()
708 // |<------|--- f -------------->| in drawShadow()
714 // We now need to outset the path to place the new edge in the center of the in drawShadow()
718 // | |<------|--- r ------>| in drawShadow()
719 // |<------|--- f -|------------>| in drawShadow()
720 // | |<- o ->|<--- f/2 --->| in drawShadow()
722 // r = o + f/2, so o = r - f/2 in drawShadow()
729 SkScalar strokeWidth = 0.5f*(devSpaceOutset - blurRadius); in drawShadow()
739 this->drawPath(devSpacePath, paint); in drawShadow()
747 sk_sp<SkVertices> vertices = SkShadowTessellator::MakeSpot(path, viewMatrix, in drawShadow()
758 SkBlendMode::kModulate)->makeComposed( in drawShadow()
762 // their alpha. We can skip expensive per-vertex color conversion for this. in drawShadow()
763 this->drawVertices(vertices.get(), in drawShadow()
777 SkPoint center = SkPoint::Make(path.getBounds().centerX(), path.getBounds().centerY()); in drawShadow()
787 SkDrawShadowMetrics::GetSpotParams(zPlaneParams.fZ, devLightPos.fX - center.fX, in drawShadow()
788 devLightPos.fY - center.fY, devLightPos.fZ, in drawShadow()
794 viewMatrix.mapRect(&devBounds, path.getBounds()); in drawShadow()
811 } else if (path.isConvex()) { in drawShadow()
848 path.getBounds(), directional, in drawShadow()
859 this->drawPath(path, paint); in drawShadow()