зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 6 changesets (bug 1821512) for causing multiple failures. CLOSED TREE
Backed out changeset 97295a57babe (bug 1821512) Backed out changeset 698104c7a5d1 (bug 1821512) Backed out changeset 09aa18e47bf6 (bug 1821512) Backed out changeset 20b46afb225f (bug 1821512) Backed out changeset b531f604ea4c (bug 1821512) Backed out changeset 0a7c0b0773d4 (bug 1821512)
This commit is contained in:
Родитель
98d1a9217c
Коммит
6e2eff1bc5
|
@ -788,7 +788,7 @@ async function runUrlbarTest(
|
|||
};
|
||||
|
||||
let urlbarRect = URLBar.textbox.getBoundingClientRect();
|
||||
const SHADOW_SIZE = 17;
|
||||
const SHADOW_SIZE = 14;
|
||||
let expectedRects = {
|
||||
filter: rects => {
|
||||
// We put text into the urlbar so expect its textbox to change.
|
||||
|
|
|
@ -19,9 +19,7 @@ prefs =
|
|||
[browser_screenshots_test_downloads.js]
|
||||
[browser_screenshots_test_escape.js]
|
||||
[browser_screenshots_test_full_page.js]
|
||||
skip-if =
|
||||
(!debug && os == 'win' && os_version == '6.1') # Bug 1746281
|
||||
os == 'win' && bits == 32 # Bug 1821512
|
||||
skip-if = (!debug && os == 'win' && os_version == '6.1') # Bug 1746281
|
||||
[browser_screenshots_test_page_crash.js]
|
||||
skip-if = !crashreporter
|
||||
[browser_screenshots_test_screenshot_too_big.js]
|
||||
|
|
|
@ -66,19 +66,19 @@ add_task(async function test_fullpageScreenshot() {
|
|||
Assert.equal(111, result.color.topLeft[2], "B color value");
|
||||
|
||||
// top right
|
||||
Assert.equal(56, result.color.topRight[0], "R color value");
|
||||
Assert.equal(156, result.color.topRight[1], "G color value");
|
||||
Assert.equal(156, result.color.topRight[2], "B color value");
|
||||
Assert.equal(55, result.color.topRight[0], "R color value");
|
||||
Assert.equal(155, result.color.topRight[1], "G color value");
|
||||
Assert.equal(155, result.color.topRight[2], "B color value");
|
||||
|
||||
// bottom left
|
||||
Assert.equal(106, result.color.bottomLeft[0], "R color value");
|
||||
Assert.equal(56, result.color.bottomLeft[1], "G color value");
|
||||
Assert.equal(106, result.color.bottomLeft[2], "B color value");
|
||||
Assert.equal(105, result.color.bottomLeft[0], "R color value");
|
||||
Assert.equal(55, result.color.bottomLeft[1], "G color value");
|
||||
Assert.equal(105, result.color.bottomLeft[2], "B color value");
|
||||
|
||||
// bottom right
|
||||
Assert.equal(53, result.color.bottomRight[0], "R color value");
|
||||
Assert.equal(128, result.color.bottomRight[1], "G color value");
|
||||
Assert.equal(153, result.color.bottomRight[2], "B color value");
|
||||
Assert.equal(52, result.color.bottomRight[0], "R color value");
|
||||
Assert.equal(127, result.color.bottomRight[1], "G color value");
|
||||
Assert.equal(152, result.color.bottomRight[2], "B color value");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -151,19 +151,19 @@ add_task(async function test_fullpageScreenshotScrolled() {
|
|||
Assert.equal(111, result.color.topLeft[2], "B color value");
|
||||
|
||||
// top right
|
||||
Assert.equal(56, result.color.topRight[0], "R color value");
|
||||
Assert.equal(156, result.color.topRight[1], "G color value");
|
||||
Assert.equal(156, result.color.topRight[2], "B color value");
|
||||
Assert.equal(55, result.color.topRight[0], "R color value");
|
||||
Assert.equal(155, result.color.topRight[1], "G color value");
|
||||
Assert.equal(155, result.color.topRight[2], "B color value");
|
||||
|
||||
// bottom left
|
||||
Assert.equal(106, result.color.bottomLeft[0], "R color value");
|
||||
Assert.equal(56, result.color.bottomLeft[1], "G color value");
|
||||
Assert.equal(106, result.color.bottomLeft[2], "B color value");
|
||||
Assert.equal(105, result.color.bottomLeft[0], "R color value");
|
||||
Assert.equal(55, result.color.bottomLeft[1], "G color value");
|
||||
Assert.equal(105, result.color.bottomLeft[2], "B color value");
|
||||
|
||||
// bottom right
|
||||
Assert.equal(53, result.color.bottomRight[0], "R color value");
|
||||
Assert.equal(128, result.color.bottomRight[1], "G color value");
|
||||
Assert.equal(153, result.color.bottomRight[2], "B color value");
|
||||
Assert.equal(52, result.color.bottomRight[0], "R color value");
|
||||
Assert.equal(127, result.color.bottomRight[1], "G color value");
|
||||
Assert.equal(152, result.color.bottomRight[2], "B color value");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -2666,10 +2666,10 @@ static Maybe<QuantizedPath> GenerateQuantizedPath(const SkPath& aPath,
|
|||
if (!pb) {
|
||||
return Nothing();
|
||||
}
|
||||
WGR::wgr_builder_set_fill_mode(pb,
|
||||
aPath.getFillType() == SkPathFillType::kWinding
|
||||
? WGR::FillMode::Winding
|
||||
: WGR::FillMode::EvenOdd);
|
||||
WGR::wgr_builder_set_fill_mode(
|
||||
pb, aPath.getFillType() == SkPath::kWinding_FillType
|
||||
? WGR::FillMode::Winding
|
||||
: WGR::FillMode::EvenOdd);
|
||||
|
||||
SkPath::RawIter iter(aPath);
|
||||
SkPoint params[4];
|
||||
|
@ -3077,26 +3077,30 @@ bool DrawTargetWebgl::SharedContext::DrawPathAccel(
|
|||
// path will need to be quantized again because it differs from the
|
||||
// path used for the cache entry, but this allows us to avoid
|
||||
// generating a fill path on a cache hit.
|
||||
Maybe<Rect> cullRect;
|
||||
Matrix invTransform = currentTransform;
|
||||
if (invTransform.Invert()) {
|
||||
// Transform the stroking clip rect from device space to local
|
||||
// space.
|
||||
Rect invRect = invTransform.TransformBounds(Rect(mClipRect));
|
||||
invRect.RoundOut();
|
||||
cullRect = Some(invRect);
|
||||
}
|
||||
SkPath fillPath;
|
||||
if (pathSkia->GetFillPath(*aStrokeOptions, currentTransform, fillPath,
|
||||
cullRect)) {
|
||||
// printf_stderr(" stroke fill... verbs %d, points %d\n",
|
||||
// int(fillPath.countVerbs()),
|
||||
// int(fillPath.countPoints()));
|
||||
if (Maybe<QuantizedPath> qp = GenerateQuantizedPath(
|
||||
fillPath, quantBounds, currentTransform)) {
|
||||
wgrVB = GeneratePathVertexBuffer(
|
||||
*qp, IntRect(-intBounds.TopLeft(), mViewportSize),
|
||||
mRasterizationTruncates, outputBuffer, outputBufferCapacity);
|
||||
SkPaint paint;
|
||||
if (StrokeOptionsToPaint(paint, *aStrokeOptions)) {
|
||||
Maybe<SkRect> cullRect;
|
||||
Matrix invTransform = currentTransform;
|
||||
if (invTransform.Invert()) {
|
||||
// Transform the stroking clip rect from device space to local
|
||||
// space.
|
||||
Rect invRect = invTransform.TransformBounds(Rect(mClipRect));
|
||||
invRect.RoundOut();
|
||||
cullRect = Some(RectToSkRect(invRect));
|
||||
}
|
||||
SkPath fillPath;
|
||||
if (paint.getFillPath(pathSkia->GetPath(), &fillPath,
|
||||
cullRect.ptrOr(nullptr),
|
||||
ComputeResScaleForStroking(currentTransform))) {
|
||||
// printf_stderr(" stroke fill... verbs %d, points %d\n",
|
||||
// int(fillPath.countVerbs()),
|
||||
// int(fillPath.countPoints()));
|
||||
if (Maybe<QuantizedPath> qp = GenerateQuantizedPath(
|
||||
fillPath, quantBounds, currentTransform)) {
|
||||
wgrVB = GeneratePathVertexBuffer(
|
||||
*qp, IntRect(-intBounds.TopLeft(), mViewportSize),
|
||||
mRasterizationTruncates, outputBuffer, outputBufferCapacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ defaults pref(webgl.force-enabled,true)
|
|||
== color_quads.html?e_context=webgl&e_width=401&e_height=401 color_quads.html?e_width=401&e_height=401
|
||||
|
||||
# Test various alpha values for webgl.
|
||||
== color_quads.html?desc=premult-alpha_&e_context=webgl&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_o1=rgb(13,13,13)&e_color_o2=rgb(29,29,29)&e_color_o3=rgb(248,248,248)&e_color_i4=rgb(255,255,255)
|
||||
fuzzy-if(gtkWidget&&useDrawSnapshot,255-255,30000-30000) == color_quads.html?desc=premult-alpha_&e_context=webgl&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_o1=rgb(13,13,13)&e_color_o2=rgb(29,29,29)&e_color_o3=rgb(248,248,248)&e_color_i4=rgb(255,255,255)
|
||||
|
||||
== color_quads.html?desc=no-alpha______&e_context=webgl&e_options={alpha:false}&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_i4=rgb(0,0,0)
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Vector.h"
|
||||
|
||||
#include "skia/include/core/SkBitmap.h"
|
||||
#include "skia/include/core/SkCanvas.h"
|
||||
#include "skia/include/core/SkFont.h"
|
||||
#include "skia/include/core/SkSurface.h"
|
||||
|
@ -22,8 +21,7 @@
|
|||
#include "skia/include/effects/SkGradientShader.h"
|
||||
#include "skia/include/core/SkColorFilter.h"
|
||||
#include "skia/include/core/SkRegion.h"
|
||||
#include "skia/include/effects/SkImageFilters.h"
|
||||
#include "skia/include/private/base/SkMalloc.h"
|
||||
#include "skia/include/effects/SkBlurImageFilter.h"
|
||||
#include "Blur.h"
|
||||
#include "Logging.h"
|
||||
#include "Tools.h"
|
||||
|
@ -435,23 +433,21 @@ static bool ExtractAlphaBitmap(const sk_sp<SkImage>& aImage,
|
|||
// Skia does not fully allocate the last row according to stride.
|
||||
// Since some of our algorithms (i.e. blur) depend on this, we must allocate
|
||||
// the bitmap pixels manually.
|
||||
size_t stride = GetAlignedStride<4>(info.width(), info.bytesPerPixel());
|
||||
if (stride) {
|
||||
CheckedInt<size_t> size = stride;
|
||||
size *= info.height();
|
||||
// We need to leave room for an additional 3 bytes for a potential overrun
|
||||
// in our blurring code.
|
||||
size += 3;
|
||||
if (size.isValid()) {
|
||||
void* buf = sk_malloc_flags(size.value(), 0);
|
||||
if (buf) {
|
||||
SkBitmap bitmap;
|
||||
if (bitmap.installPixels(info, buf, stride, FreeAlphaPixels, nullptr) &&
|
||||
aImage->readPixels(bitmap.info(), bitmap.getPixels(),
|
||||
bitmap.rowBytes(), 0, 0)) {
|
||||
*aResultBitmap = bitmap;
|
||||
return true;
|
||||
}
|
||||
size_t stride = SkAlign4(info.minRowBytes());
|
||||
CheckedInt<size_t> size = stride;
|
||||
size *= info.height();
|
||||
// We need to leave room for an additional 3 bytes for a potential overrun
|
||||
// in our blurring code.
|
||||
size += 3;
|
||||
if (size.isValid()) {
|
||||
void* buf = sk_malloc_flags(size.value(), 0);
|
||||
if (buf) {
|
||||
SkBitmap bitmap;
|
||||
if (bitmap.installPixels(info, buf, stride, FreeAlphaPixels, nullptr) &&
|
||||
aImage->readPixels(bitmap.info(), bitmap.getPixels(),
|
||||
bitmap.rowBytes(), 0, 0)) {
|
||||
*aResultBitmap = bitmap;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -460,6 +456,26 @@ static bool ExtractAlphaBitmap(const sk_sp<SkImage>& aImage,
|
|||
return false;
|
||||
}
|
||||
|
||||
static sk_sp<SkImage> ExtractAlphaForSurface(SourceSurface* aSurface,
|
||||
Maybe<MutexAutoLock>& aLock) {
|
||||
sk_sp<SkImage> image = GetSkImageForSurface(aSurface, &aLock);
|
||||
if (!image) {
|
||||
return nullptr;
|
||||
}
|
||||
if (image->isAlphaOnly()) {
|
||||
return image;
|
||||
}
|
||||
|
||||
SkBitmap bitmap;
|
||||
if (!ExtractAlphaBitmap(image, &bitmap)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Mark the bitmap immutable so that it will be shared rather than copied.
|
||||
bitmap.setImmutable();
|
||||
return SkImage::MakeFromBitmap(bitmap);
|
||||
}
|
||||
|
||||
static void SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern,
|
||||
Maybe<MutexAutoLock>& aLock, Float aAlpha = 1.0,
|
||||
const SkMatrix* aMatrix = nullptr,
|
||||
|
@ -603,12 +619,7 @@ static void SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern,
|
|||
SkTileMode xTile = ExtendModeToTileMode(pat.mExtendMode, Axis::X_AXIS);
|
||||
SkTileMode yTile = ExtendModeToTileMode(pat.mExtendMode, Axis::Y_AXIS);
|
||||
|
||||
SkFilterMode filterMode = pat.mSamplingFilter == SamplingFilter::POINT
|
||||
? SkFilterMode::kNearest
|
||||
: SkFilterMode::kLinear;
|
||||
|
||||
sk_sp<SkShader> shader =
|
||||
image->makeShader(xTile, yTile, SkSamplingOptions(filterMode), mat);
|
||||
sk_sp<SkShader> shader = image->makeShader(xTile, yTile, &mat);
|
||||
if (shader) {
|
||||
aPaint.setShader(shader);
|
||||
} else {
|
||||
|
@ -617,6 +628,10 @@ static void SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern,
|
|||
<< " matrix=" << (mat.isFinite() ? "finite" : "non-finite");
|
||||
aPaint.setColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
|
||||
if (pat.mSamplingFilter == SamplingFilter::POINT) {
|
||||
aPaint.setFilterQuality(kNone_SkFilterQuality);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -695,6 +710,7 @@ struct AutoPaintSetup {
|
|||
mPaint.setAlpha(ColorFloatToByte(aOptions.mAlpha));
|
||||
mAlpha = aOptions.mAlpha;
|
||||
}
|
||||
mPaint.setFilterQuality(kLow_SkFilterQuality);
|
||||
}
|
||||
|
||||
// TODO: Maybe add an operator overload to access this easier?
|
||||
|
@ -729,15 +745,11 @@ void DrawTargetSkia::DrawSurface(SourceSurface* aSurface, const Rect& aDest,
|
|||
image->isAlphaOnly() && aOptions.mCompositionOp != CompositionOp::OP_OVER;
|
||||
|
||||
AutoPaintSetup paint(mCanvas, aOptions, &aDest, forceGroup);
|
||||
if (aSurfOptions.mSamplingFilter == SamplingFilter::POINT) {
|
||||
paint.mPaint.setFilterQuality(kNone_SkFilterQuality);
|
||||
}
|
||||
|
||||
SkFilterMode filterMode =
|
||||
aSurfOptions.mSamplingFilter == SamplingFilter::POINT
|
||||
? SkFilterMode::kNearest
|
||||
: SkFilterMode::kLinear;
|
||||
|
||||
mCanvas->drawImageRect(image, sourceRect, destRect,
|
||||
SkSamplingOptions(filterMode), &paint.mPaint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
mCanvas->drawImageRect(image, sourceRect, destRect, &paint.mPaint);
|
||||
}
|
||||
|
||||
DrawTargetType DrawTargetSkia::GetType() const {
|
||||
|
@ -801,26 +813,23 @@ void DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface* aSurface,
|
|||
|
||||
shadowPaint.setColor(ColorToSkColor(aShadow.mColor, 1.0f));
|
||||
|
||||
mCanvas->drawImage(blurMask.asImage(), shadowDest.x, shadowDest.y,
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &shadowPaint);
|
||||
mCanvas->drawBitmap(blurMask, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
} else {
|
||||
sk_sp<SkImageFilter> blurFilter(
|
||||
SkImageFilters::Blur(aShadow.mSigma, aShadow.mSigma, nullptr));
|
||||
SkBlurImageFilter::Make(aShadow.mSigma, aShadow.mSigma, nullptr));
|
||||
sk_sp<SkColorFilter> colorFilter(SkColorFilters::Blend(
|
||||
ColorToSkColor(aShadow.mColor, 1.0f), SkBlendMode::kSrcIn));
|
||||
|
||||
shadowPaint.setImageFilter(blurFilter);
|
||||
shadowPaint.setColorFilter(colorFilter);
|
||||
|
||||
mCanvas->drawImage(image, shadowDest.x, shadowDest.y,
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &shadowPaint);
|
||||
mCanvas->drawImage(image, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
}
|
||||
|
||||
if (aSurface->GetFormat() != SurfaceFormat::A8) {
|
||||
// Composite the original image after the shadow
|
||||
auto dest = IntPoint::Round(aDest);
|
||||
mCanvas->drawImage(image, dest.x, dest.y,
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &paint);
|
||||
mCanvas->drawImage(image, dest.x, dest.y, &paint);
|
||||
}
|
||||
|
||||
mCanvas->restore();
|
||||
|
@ -1385,59 +1394,59 @@ void DrawTargetSkia::StrokeGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
|
|||
|
||||
void DrawTargetSkia::Mask(const Pattern& aSource, const Pattern& aMask,
|
||||
const DrawOptions& aOptions) {
|
||||
SkIRect maskBounds;
|
||||
if (!mCanvas->getDeviceClipBounds(&maskBounds)) {
|
||||
return;
|
||||
}
|
||||
SkPoint maskOrigin;
|
||||
maskOrigin.iset(maskBounds.fLeft, maskBounds.fTop);
|
||||
|
||||
SkMatrix maskMatrix = mCanvas->getTotalMatrix();
|
||||
maskMatrix.postTranslate(-maskOrigin.fX, -maskOrigin.fY);
|
||||
|
||||
MarkChanged();
|
||||
AutoPaintSetup paint(mCanvas, aOptions, aSource, nullptr, &maskMatrix);
|
||||
|
||||
Maybe<MutexAutoLock> lock;
|
||||
SkPaint maskPaint;
|
||||
SetPaintPattern(maskPaint, aMask, lock);
|
||||
|
||||
sk_sp<SkShader> maskShader(maskPaint.getShader());
|
||||
if (!maskShader && maskPaint.getAlpha() != 0xFF) {
|
||||
if (maskPaint.getAlpha() == 0) {
|
||||
return;
|
||||
}
|
||||
maskShader = SkShaders::Color(maskPaint.getColor());
|
||||
if (!maskShader) {
|
||||
gfxDebug() << "Failed creating Skia clip shader for Mask";
|
||||
return;
|
||||
}
|
||||
SkBitmap maskBitmap;
|
||||
if (!maskBitmap.tryAllocPixelsFlags(
|
||||
SkImageInfo::MakeA8(maskBounds.width(), maskBounds.height()),
|
||||
SkBitmap::kZeroPixels_AllocFlag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MarkChanged();
|
||||
AutoPaintSetup paint(mCanvas, aOptions, aSource);
|
||||
SkCanvas maskCanvas(maskBitmap);
|
||||
maskCanvas.setMatrix(maskMatrix);
|
||||
maskCanvas.drawPaint(maskPaint);
|
||||
|
||||
mCanvas->save();
|
||||
if (maskShader) {
|
||||
mCanvas->clipShader(maskShader);
|
||||
}
|
||||
mCanvas->resetMatrix();
|
||||
|
||||
mCanvas->drawPaint(paint.mPaint);
|
||||
mCanvas->drawBitmap(maskBitmap, maskOrigin.fX, maskOrigin.fY, &paint.mPaint);
|
||||
|
||||
mCanvas->restore();
|
||||
}
|
||||
|
||||
void DrawTargetSkia::MaskSurface(const Pattern& aSource, SourceSurface* aMask,
|
||||
Point aOffset, const DrawOptions& aOptions) {
|
||||
MarkChanged();
|
||||
|
||||
SkMatrix invOffset = SkMatrix::MakeTrans(SkFloatToScalar(-aOffset.x),
|
||||
SkFloatToScalar(-aOffset.y));
|
||||
AutoPaintSetup paint(mCanvas, aOptions, aSource, nullptr, &invOffset);
|
||||
|
||||
Maybe<MutexAutoLock> lock;
|
||||
sk_sp<SkImage> maskImage = GetSkImageForSurface(aMask, &lock);
|
||||
SkMatrix maskOffset = SkMatrix::Translate(
|
||||
PointToSkPoint(aOffset + Point(aMask->GetRect().TopLeft())));
|
||||
sk_sp<SkShader> maskShader = maskImage->makeShader(
|
||||
SkTileMode::kClamp, SkTileMode::kClamp,
|
||||
SkSamplingOptions(SkFilterMode::kLinear), maskOffset);
|
||||
if (!maskShader) {
|
||||
gfxDebug() << "Failed creating Skia clip shader for MaskSurface";
|
||||
sk_sp<SkImage> alphaMask = ExtractAlphaForSurface(aMask, lock);
|
||||
if (!alphaMask) {
|
||||
gfxDebug() << *this << ": MaskSurface() failed to extract alpha for mask";
|
||||
return;
|
||||
}
|
||||
|
||||
MarkChanged();
|
||||
AutoPaintSetup paint(mCanvas, aOptions, aSource);
|
||||
|
||||
mCanvas->save();
|
||||
mCanvas->clipShader(maskShader);
|
||||
|
||||
mCanvas->drawRect(RectToSkRect(Rect(aMask->GetRect()) + aOffset),
|
||||
paint.mPaint);
|
||||
|
||||
mCanvas->restore();
|
||||
mCanvas->drawImage(alphaMask, aOffset.x + aMask->GetRect().x,
|
||||
aOffset.y + aMask->GetRect().y, &paint.mPaint);
|
||||
}
|
||||
|
||||
bool DrawTarget::Draw3DTransformedSurface(SourceSurface* aSurface,
|
||||
|
@ -1489,14 +1498,14 @@ bool DrawTarget::Draw3DTransformedSurface(SourceSurface* aSurface,
|
|||
// Do the transform.
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
SkMatrix xform;
|
||||
GfxMatrixToSkiaMatrix(fullMat, xform);
|
||||
dstCanvas->setMatrix(xform);
|
||||
|
||||
dstCanvas->drawImage(srcImage, 0, 0, SkSamplingOptions(SkFilterMode::kLinear),
|
||||
&paint);
|
||||
dstCanvas->drawImage(srcImage, 0, 0, &paint);
|
||||
dstCanvas->flush();
|
||||
|
||||
// Temporarily reset the DT's transform, since it has already been composed
|
||||
|
@ -1531,13 +1540,13 @@ bool DrawTargetSkia::Draw3DTransformedSurface(SourceSurface* aSurface,
|
|||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
|
||||
SkMatrix xform;
|
||||
GfxMatrixToSkiaMatrix(aMatrix, xform);
|
||||
mCanvas->concat(xform);
|
||||
|
||||
mCanvas->drawImage(image, 0, 0, SkSamplingOptions(SkFilterMode::kLinear),
|
||||
&paint);
|
||||
mCanvas->drawImage(image, 0, 0, &paint);
|
||||
|
||||
mCanvas->restore();
|
||||
|
||||
|
@ -1712,10 +1721,7 @@ bool DrawTargetSkia::Init(const IntSize& aSize, SurfaceFormat aFormat) {
|
|||
// we need to have surfaces that have a stride aligned to 4 for interop with
|
||||
// cairo
|
||||
SkImageInfo info = MakeSkiaImageInfo(aSize, aFormat);
|
||||
size_t stride = GetAlignedStride<4>(info.width(), info.bytesPerPixel());
|
||||
if (!stride) {
|
||||
return false;
|
||||
}
|
||||
size_t stride = SkAlign4(info.minRowBytes());
|
||||
SkSurfaceProps props(0, GetSkPixelGeometry());
|
||||
|
||||
if (aFormat == SurfaceFormat::A8) {
|
||||
|
@ -1934,17 +1940,22 @@ void DrawTargetSkia::PushLayerWithBlend(bool aOpaque, Float aOpacity,
|
|||
const IntRect& aBounds,
|
||||
bool aCopyBackground,
|
||||
CompositionOp aCompositionOp) {
|
||||
PushedLayer layer(GetPermitSubpixelAA(), aMask);
|
||||
mPushedLayers.push_back(layer);
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
paint.setAlpha(ColorFloatToByte(aOpacity));
|
||||
paint.setBlendMode(GfxOpToSkiaOp(aCompositionOp));
|
||||
|
||||
// aBounds is supplied in device space, but SaveLayerRec wants local space.
|
||||
SkRect bounds = SkRect::MakeEmpty();
|
||||
if (!aBounds.IsEmpty()) {
|
||||
Matrix inverseTransform = mTransform;
|
||||
if (inverseTransform.Invert()) {
|
||||
bounds = RectToSkRect(inverseTransform.TransformBounds(Rect(aBounds)));
|
||||
SkRect bounds = IntRectToSkRect(aBounds);
|
||||
if (!bounds.isEmpty()) {
|
||||
SkMatrix inverseCTM;
|
||||
if (mCanvas->getTotalMatrix().invert(&inverseCTM)) {
|
||||
inverseCTM.mapRect(&bounds);
|
||||
} else {
|
||||
bounds.setEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1952,37 +1963,17 @@ void DrawTargetSkia::PushLayerWithBlend(bool aOpaque, Float aOpacity,
|
|||
// copy of the data if this is a copy-on-write snapshot. If we instead held
|
||||
// the lock until the corresponding PopLayer, we'd risk deadlocking if someone
|
||||
// tried to touch the originating DrawTarget while the layer was pushed.
|
||||
sk_sp<SkImage> clipImage = GetSkImageForSurface(aMask, nullptr);
|
||||
bool usedMask = false;
|
||||
if (bool(clipImage)) {
|
||||
Rect maskBounds(aMask->GetRect());
|
||||
sk_sp<SkShader> shader = clipImage->makeShader(
|
||||
SkTileMode::kClamp, SkTileMode::kClamp,
|
||||
SkSamplingOptions(SkFilterMode::kLinear),
|
||||
SkMatrix::Translate(PointToSkPoint(maskBounds.TopLeft())));
|
||||
if (shader) {
|
||||
usedMask = true;
|
||||
mCanvas->save();
|
||||
|
||||
auto oldMatrix = mCanvas->getLocalToDevice();
|
||||
SkMatrix clipMatrix;
|
||||
GfxMatrixToSkiaMatrix(aMaskTransform, clipMatrix);
|
||||
mCanvas->concat(clipMatrix);
|
||||
|
||||
mCanvas->clipRect(RectToSkRect(maskBounds));
|
||||
mCanvas->clipShader(shader);
|
||||
|
||||
mCanvas->setMatrix(oldMatrix);
|
||||
} else {
|
||||
gfxDebug() << "Failed to create Skia clip shader for PushLayerWithBlend";
|
||||
}
|
||||
sk_sp<SkImage> clipImage =
|
||||
aMask ? GetSkImageForSurface(aMask, nullptr) : nullptr;
|
||||
SkMatrix clipMatrix;
|
||||
GfxMatrixToSkiaMatrix(aMaskTransform, clipMatrix);
|
||||
if (aMask) {
|
||||
clipMatrix.preTranslate(aMask->GetRect().X(), aMask->GetRect().Y());
|
||||
}
|
||||
|
||||
PushedLayer layer(GetPermitSubpixelAA(), usedMask ? aMask : nullptr);
|
||||
mPushedLayers.push_back(layer);
|
||||
|
||||
SkCanvas::SaveLayerRec saveRec(
|
||||
aBounds.IsEmpty() ? nullptr : &bounds, &paint, nullptr,
|
||||
aBounds.IsEmpty() ? nullptr : &bounds, &paint, nullptr, clipImage.get(),
|
||||
&clipMatrix,
|
||||
SkCanvas::kPreserveLCDText_SaveLayerFlag |
|
||||
(aCopyBackground ? SkCanvas::kInitWithPrevious_SaveLayerFlag : 0));
|
||||
|
||||
|
@ -2004,10 +1995,6 @@ void DrawTargetSkia::PopLayer() {
|
|||
|
||||
mCanvas->restore();
|
||||
|
||||
if (layer.mMask) {
|
||||
mCanvas->restore();
|
||||
}
|
||||
|
||||
SetTransform(GetTransform());
|
||||
SetPermitSubpixelAA(layer.mOldPermitSubpixelAA);
|
||||
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
|
||||
#include "2D.h"
|
||||
#include "skia/include/core/SkCanvas.h"
|
||||
#include "skia/include/core/SkPathEffect.h"
|
||||
#include "skia/include/core/SkPathTypes.h"
|
||||
#include "skia/include/core/SkShader.h"
|
||||
#include "skia/include/effects/SkDashPathEffect.h"
|
||||
#include "skia/include/core/SkShader.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
@ -148,8 +146,8 @@ static inline bool StrokeOptionsToPaint(SkPaint& aPaint,
|
|||
SkFloatToScalar(aOptions.mDashPattern[i % aOptions.mDashLength]);
|
||||
}
|
||||
|
||||
auto dash = SkDashPathEffect::Make(&pattern.front(), dashCount,
|
||||
SkFloatToScalar(aOptions.mDashOffset));
|
||||
sk_sp<SkPathEffect> dash = SkDashPathEffect::Make(
|
||||
&pattern.front(), dashCount, SkFloatToScalar(aOptions.mDashOffset));
|
||||
aPaint.setPathEffect(dash);
|
||||
}
|
||||
|
||||
|
@ -305,14 +303,14 @@ static inline SkFontHinting GfxHintingToSkiaHinting(FontHinting aHinting) {
|
|||
return SkFontHinting::kNormal;
|
||||
}
|
||||
|
||||
static inline FillRule GetFillRule(SkPathFillType aFillType) {
|
||||
static inline FillRule GetFillRule(SkPath::FillType aFillType) {
|
||||
switch (aFillType) {
|
||||
case SkPathFillType::kWinding:
|
||||
case SkPath::kWinding_FillType:
|
||||
return FillRule::FILL_WINDING;
|
||||
case SkPathFillType::kEvenOdd:
|
||||
case SkPath::kEvenOdd_FillType:
|
||||
return FillRule::FILL_EVEN_ODD;
|
||||
case SkPathFillType::kInverseWinding:
|
||||
case SkPathFillType::kInverseEvenOdd:
|
||||
case SkPath::kInverseWinding_FillType:
|
||||
case SkPath::kInverseEvenOdd_FillType:
|
||||
default:
|
||||
NS_WARNING("Unsupported fill type\n");
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "PathSkia.h"
|
||||
#include "HelpersSkia.h"
|
||||
#include "PathHelpers.h"
|
||||
#include "skia/include/core/SkPathUtils.h"
|
||||
#include "skia/src/core/SkDraw.h"
|
||||
#include "skia/src/core/SkGeometry.h"
|
||||
|
||||
namespace mozilla::gfx {
|
||||
|
@ -30,9 +30,9 @@ PathBuilderSkia::PathBuilderSkia(FillRule aFillRule) { SetFillRule(aFillRule); }
|
|||
void PathBuilderSkia::SetFillRule(FillRule aFillRule) {
|
||||
mFillRule = aFillRule;
|
||||
if (mFillRule == FillRule::FILL_WINDING) {
|
||||
mPath.setFillType(SkPathFillType::kWinding);
|
||||
mPath.setFillType(SkPath::kWinding_FillType);
|
||||
} else {
|
||||
mPath.setFillType(SkPathFillType::kEvenOdd);
|
||||
mPath.setFillType(SkPath::kEvenOdd_FillType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,24 +129,10 @@ bool PathSkia::ContainsPoint(const Point& aPoint,
|
|||
return SkPathContainsPoint(mPath, aPoint, aTransform);
|
||||
}
|
||||
|
||||
bool PathSkia::GetFillPath(const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aTransform, SkPath& aFillPath,
|
||||
const Maybe<Rect>& aClipRect) const {
|
||||
SkPaint paint;
|
||||
if (!StrokeOptionsToPaint(paint, aStrokeOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float ComputeResScaleForStroking(const Matrix& aTransform) {
|
||||
SkMatrix skiaMatrix;
|
||||
GfxMatrixToSkiaMatrix(aTransform, skiaMatrix);
|
||||
|
||||
Maybe<SkRect> cullRect;
|
||||
if (aClipRect.isSome()) {
|
||||
cullRect = Some(RectToSkRect(aClipRect.ref()));
|
||||
}
|
||||
|
||||
return skpathutils::FillPathWithPaint(mPath, paint, &aFillPath,
|
||||
cullRect.ptrOr(nullptr), skiaMatrix);
|
||||
return SkDraw::ComputeResScaleForStroking(skiaMatrix);
|
||||
}
|
||||
|
||||
bool PathSkia::StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
|
||||
|
@ -156,11 +142,15 @@ bool PathSkia::StrokeContainsPoint(const StrokeOptions& aStrokeOptions,
|
|||
return false;
|
||||
}
|
||||
|
||||
SkPath strokePath;
|
||||
if (!GetFillPath(aStrokeOptions, aTransform, strokePath)) {
|
||||
SkPaint paint;
|
||||
if (!StrokeOptionsToPaint(paint, aStrokeOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkPath strokePath;
|
||||
paint.getFillPath(mPath, &strokePath, nullptr,
|
||||
ComputeResScaleForStroking(aTransform));
|
||||
|
||||
return SkPathContainsPoint(strokePath, aPoint, aTransform);
|
||||
}
|
||||
|
||||
|
@ -179,12 +169,15 @@ Rect PathSkia::GetStrokedBounds(const StrokeOptions& aStrokeOptions,
|
|||
return Rect();
|
||||
}
|
||||
|
||||
SkPath fillPath;
|
||||
if (!GetFillPath(aStrokeOptions, aTransform, fillPath)) {
|
||||
SkPaint paint;
|
||||
if (!StrokeOptionsToPaint(paint, aStrokeOptions)) {
|
||||
return Rect();
|
||||
}
|
||||
|
||||
Rect bounds = SkRectToRect(fillPath.computeTightBounds());
|
||||
SkPath result;
|
||||
paint.getFillPath(mPath, &result);
|
||||
|
||||
Rect bounds = SkRectToRect(result.computeTightBounds());
|
||||
return aTransform.TransformBounds(bounds);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,10 +91,6 @@ class PathSkia : public Path {
|
|||
|
||||
Maybe<Rect> AsRect() const override;
|
||||
|
||||
bool GetFillPath(const StrokeOptions& aStrokeOptions,
|
||||
const Matrix& aTransform, SkPath& aFillPath,
|
||||
const Maybe<Rect>& aClipRect = Nothing()) const;
|
||||
|
||||
private:
|
||||
friend class DrawTargetSkia;
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ ScaledFontMac::~ScaledFontMac() {
|
|||
}
|
||||
|
||||
SkTypeface* ScaledFontMac::CreateSkTypeface() {
|
||||
return SkMakeTypefaceFromCTFont(mCTFont).release();
|
||||
return SkCreateTypefaceFromCTFont(mCTFont);
|
||||
}
|
||||
|
||||
void ScaledFontMac::SetupSkFontDrawOptions(SkFont& aFont) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "skia/include/core/SkData.h"
|
||||
#include "skia/include/core/SkImage.h"
|
||||
#include "skia/include/core/SkSurface.h"
|
||||
#include "skia/include/private/base/SkMalloc.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
|
||||
namespace mozilla::gfx {
|
||||
|
@ -135,10 +134,7 @@ bool SourceSurfaceSkia::InitFromImage(const sk_sp<SkImage>& aImage,
|
|||
} else if (aFormat != SurfaceFormat::UNKNOWN) {
|
||||
mFormat = aFormat;
|
||||
SkImageInfo info = MakeSkiaImageInfo(mSize, mFormat);
|
||||
mStride = GetAlignedStride<4>(info.width(), info.bytesPerPixel());
|
||||
if (!mStride) {
|
||||
return false;
|
||||
}
|
||||
mStride = SkAlign4(info.minRowBytes());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -158,10 +154,7 @@ already_AddRefed<SourceSurface> SourceSurfaceSkia::ExtractSubrect(
|
|||
return nullptr;
|
||||
}
|
||||
SkImageInfo info = MakeSkiaImageInfo(aRect.Size(), mFormat);
|
||||
size_t stride = GetAlignedStride<4>(info.width(), info.bytesPerPixel());
|
||||
if (!stride) {
|
||||
return nullptr;
|
||||
}
|
||||
size_t stride = SkAlign4(info.minRowBytes());
|
||||
sk_sp<SkImage> subImage = ReadSkImage(mImage, info, stride, aRect.x, aRect.y);
|
||||
if (!subImage) {
|
||||
return nullptr;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
|
||||
import locale
|
||||
import subprocess
|
||||
|
@ -39,6 +39,7 @@ AllowCompilerWarnings()
|
|||
FINAL_LIBRARY = 'gkmedias'
|
||||
LOCAL_INCLUDES += [
|
||||
'skia',
|
||||
'skia/include/third_party/skcms',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
|
@ -53,10 +54,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
|||
|
||||
if CONFIG['INTEL_ARCHITECTURE']:
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_sse42.cpp'].flags += ['-msse4.2']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
|
||||
SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-mavx2', '-mf16c', '-mfma']
|
||||
SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl']
|
||||
elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
SOURCES['skia/src/opts/SkOpts_crc32.cpp'].flags += ['-march=armv8-a+crc']
|
||||
|
||||
|
@ -103,11 +104,13 @@ import json
|
|||
platforms = ['linux', 'mac', 'android', 'win']
|
||||
|
||||
def parse_sources(output):
|
||||
return set(v.replace('//', 'skia/') for v in output.decode('utf-8').split() if v.endswith('.cpp') or v.endswith('.S'))
|
||||
return set(v.replace('//', 'skia/') for v in output.split() if v.endswith('.cpp') or v.endswith('.S'))
|
||||
|
||||
def generate_opt_sources():
|
||||
cpus = [('intel', 'x86', [':ssse3', ':sse42', ':avx', ':hsw', ':skx']),
|
||||
('arm64', 'arm64', [':crc32'])]
|
||||
cpus = [('intel', 'x86', [':sse2', ':ssse3', ':sse41', ':sse42', ':avx', ':hsw']),
|
||||
('arm', 'arm', [':armv7']),
|
||||
('arm64', 'arm64', [':arm64', ':crc32']),
|
||||
('none', 'none', [':none'])]
|
||||
|
||||
opt_sources = {}
|
||||
for key, cpu, deps in cpus:
|
||||
|
@ -119,7 +122,7 @@ def generate_opt_sources():
|
|||
if output:
|
||||
opt_sources[key].update(parse_sources(output))
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.output.find(b'source_set') < 0:
|
||||
if e.output.find('source_set') < 0:
|
||||
raise
|
||||
|
||||
return opt_sources
|
||||
|
@ -135,11 +138,7 @@ def generate_platform_sources():
|
|||
if output:
|
||||
sources[plat] = parse_sources(output)
|
||||
|
||||
plat_deps = {
|
||||
':fontmgr_win' : 'win',
|
||||
':fontmgr_win_gdi' : 'win',
|
||||
':fontmgr_mac_ct' : 'mac',
|
||||
}
|
||||
plat_deps = {':fontmgr_win' : 'win', ':fontmgr_win_gdi' : 'win'}
|
||||
for dep, key in plat_deps.items():
|
||||
output = subprocess.check_output('cd skia && bin/gn desc out/{1} {0} sources'.format(dep, key), shell=True)
|
||||
if output:
|
||||
|
@ -151,26 +150,33 @@ def generate_platform_sources():
|
|||
if output:
|
||||
sources[key] = parse_sources(output)
|
||||
|
||||
sources.update(generate_opt_sources())
|
||||
return sources
|
||||
return dict(sources.items() + generate_opt_sources().items())
|
||||
|
||||
|
||||
def generate_separated_sources(platform_sources):
|
||||
ignorelist = [
|
||||
'skia/src/android/',
|
||||
'skia/src/atlastext/',
|
||||
'skia/src/c/',
|
||||
'skia/src/effects/',
|
||||
'skia/src/fonts/',
|
||||
'skia/src/ports/SkImageEncoder',
|
||||
'skia/src/ports/SkImageGenerator',
|
||||
'SkBitmapRegion',
|
||||
'SkLite',
|
||||
'SkLight',
|
||||
'SkNormal',
|
||||
'codec',
|
||||
'SkWGL',
|
||||
'SkMemory_malloc',
|
||||
'third_party',
|
||||
'Sk3D',
|
||||
'SkAnimCodecPlayer',
|
||||
'SkCamera',
|
||||
'SkCanvasStack',
|
||||
'SkCanvasStateUtils',
|
||||
'SkFrontBufferedStream',
|
||||
'SkInterpolator',
|
||||
'JSON',
|
||||
'SkMultiPictureDocument',
|
||||
'SkNullCanvas',
|
||||
|
@ -178,9 +184,11 @@ def generate_separated_sources(platform_sources):
|
|||
'SkOverdrawCanvas',
|
||||
'SkPaintFilterCanvas',
|
||||
'SkParseColor',
|
||||
'SkWhitelistTypefaces',
|
||||
'SkXPS',
|
||||
'SkCreateCGImageRef',
|
||||
'skia/src/ports/SkGlobalInitialization',
|
||||
'skia/src/sksl/SkSLJIT',
|
||||
]
|
||||
|
||||
def isignorelisted(value):
|
||||
|
@ -200,9 +208,11 @@ def generate_separated_sources(platform_sources):
|
|||
'skia/src/ports/SkGlobalInitialization_default.cpp',
|
||||
'skia/src/ports/SkMemory_mozalloc.cpp',
|
||||
'skia/src/ports/SkImageGenerator_none.cpp',
|
||||
'skia/modules/skcms/skcms.cc',
|
||||
'skia/third_party/skcms/skcms.cc',
|
||||
'skia/src/core/SkBitmapScaler.cpp',
|
||||
'skia/src/core/SkGlyphBuffer.cpp',
|
||||
'skia/src/core/SkConvolver.cpp',
|
||||
'skia/src/core/SkImageFilterTypes.cpp',
|
||||
'skia/src/ports/SkFontMgr_empty_factory.cpp',
|
||||
},
|
||||
'android': {
|
||||
# 'skia/src/ports/SkDebug_android.cpp',
|
||||
|
@ -275,6 +285,7 @@ def write_cflags(f, values, subsearch, cflag, indent):
|
|||
opt_allowlist = [
|
||||
'SkOpts',
|
||||
'SkBitmapProcState',
|
||||
'SkBitmapScaler',
|
||||
'SkBlitRow',
|
||||
'SkBlitter',
|
||||
'SkSpriteBlitter',
|
||||
|
@ -289,22 +300,26 @@ unified_ignorelist = [
|
|||
'SkBitmapProcState_matrixProcs.cpp',
|
||||
'SkBlitter_A8.cpp',
|
||||
'SkBlitter_ARGB32.cpp',
|
||||
'SkBlitter_RGB16.cpp',
|
||||
'SkBlitter_Sprite.cpp',
|
||||
'SkScan_Antihair.cpp',
|
||||
'SkScan_AntiPath.cpp',
|
||||
'SkScan_DAAPath.cpp',
|
||||
'SkParse.cpp',
|
||||
'SkPDFFont.cpp',
|
||||
'SkPDFDevice.cpp',
|
||||
'SkPDFType1Font.cpp',
|
||||
'SkPictureData.cpp',
|
||||
'SkColorSpace',
|
||||
'SkPath.cpp',
|
||||
'SkPathOpsDebug.cpp',
|
||||
'SkParsePath.cpp',
|
||||
'SkRecorder.cpp',
|
||||
'SkMiniRecorder.cpp',
|
||||
'SkXfermode',
|
||||
'SkMatrix44.cpp',
|
||||
'SkRTree.cpp',
|
||||
'SkVertices.cpp',
|
||||
'SkSLHCodeGenerator.cpp',
|
||||
'SkSLLexer.cpp',
|
||||
] + opt_allowlist
|
||||
|
||||
|
|
|
@ -23,55 +23,35 @@ if CONFIG['MOZ_OPTIMIZE']:
|
|||
skia_opt_flags += ['-O3']
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/base/SkArenaAlloc.cpp',
|
||||
'skia/src/base/SkBezierCurves.cpp',
|
||||
'skia/src/base/SkBlockAllocator.cpp',
|
||||
'skia/src/base/SkBuffer.cpp',
|
||||
'skia/src/base/SkContainers.cpp',
|
||||
'skia/src/base/SkCubics.cpp',
|
||||
'skia/src/base/SkDeque.cpp',
|
||||
'skia/src/base/SkFloatingPoint.cpp',
|
||||
'skia/src/base/SkHalf.cpp',
|
||||
'skia/src/base/SkMalloc.cpp',
|
||||
'skia/src/base/SkMathPriv.cpp',
|
||||
'skia/src/base/SkQuads.cpp',
|
||||
'skia/src/base/SkSafeMath.cpp',
|
||||
'skia/src/base/SkSemaphore.cpp',
|
||||
'skia/src/base/SkTDArray.cpp',
|
||||
'skia/src/base/SkThreadID.cpp',
|
||||
'skia/src/base/SkTSearch.cpp',
|
||||
'skia/src/base/SkUTF.cpp',
|
||||
'skia/src/base/SkUtils.cpp',
|
||||
'skia/src/codec/SkMasks.cpp',
|
||||
'skia/src/core/SkAAClip.cpp',
|
||||
'skia/src/core/SkAlphaRuns.cpp',
|
||||
'skia/src/core/SkAnalyticEdge.cpp',
|
||||
'skia/src/core/SkAnnotation.cpp',
|
||||
'skia/src/core/SkArenaAlloc.cpp',
|
||||
'skia/src/core/SkATrace.cpp',
|
||||
'skia/src/core/SkAutoPixmapStorage.cpp',
|
||||
'skia/src/core/SkBBHFactory.cpp',
|
||||
'skia/src/core/SkBigPicture.cpp',
|
||||
'skia/src/core/SkBitmap.cpp',
|
||||
'skia/src/core/SkBitmapCache.cpp',
|
||||
'skia/src/core/SkBitmapController.cpp',
|
||||
'skia/src/core/SkBitmapDevice.cpp',
|
||||
'skia/src/core/SkBlendMode.cpp',
|
||||
'skia/src/core/SkBlendModeBlender.cpp',
|
||||
'skia/src/core/SkBlurMask.cpp',
|
||||
'skia/src/core/SkBlurMF.cpp',
|
||||
'skia/src/core/SkBuffer.cpp',
|
||||
'skia/src/core/SkCachedData.cpp',
|
||||
'skia/src/core/SkCanvas.cpp',
|
||||
'skia/src/core/SkCanvas_Raster.cpp',
|
||||
'skia/src/core/SkCanvasPriv.cpp',
|
||||
'skia/src/core/SkCapabilities.cpp',
|
||||
'skia/src/core/SkChromeRemoteGlyphCache.cpp',
|
||||
'skia/src/core/SkClipStack.cpp',
|
||||
'skia/src/core/SkClipStackDevice.cpp',
|
||||
'skia/src/core/SkColor.cpp',
|
||||
'skia/src/core/SkColorFilter.cpp',
|
||||
'skia/src/core/SkColorFilter_Matrix.cpp',
|
||||
'skia/src/core/SkCompressedDataUtils.cpp',
|
||||
'skia/src/core/SkContourMeasure.cpp',
|
||||
'skia/src/core/SkConvertPixels.cpp',
|
||||
'skia/src/core/SkConvolver.cpp',
|
||||
'skia/src/core/SkCpu.cpp',
|
||||
'skia/src/core/SkCubicClipper.cpp',
|
||||
'skia/src/core/SkCubicMap.cpp',
|
||||
|
@ -80,6 +60,7 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkDebug.cpp',
|
||||
'skia/src/core/SkDeferredDisplayList.cpp',
|
||||
'skia/src/core/SkDeferredDisplayListRecorder.cpp',
|
||||
'skia/src/core/SkDeque.cpp',
|
||||
'skia/src/core/SkDescriptor.cpp',
|
||||
'skia/src/core/SkDevice.cpp',
|
||||
'skia/src/core/SkDistanceFieldGen.cpp',
|
||||
|
@ -89,7 +70,6 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkDraw_text.cpp',
|
||||
'skia/src/core/SkDraw_vertices.cpp',
|
||||
'skia/src/core/SkDrawable.cpp',
|
||||
'skia/src/core/SkDrawBase.cpp',
|
||||
'skia/src/core/SkDrawLooper.cpp',
|
||||
'skia/src/core/SkDrawShadowInfo.cpp',
|
||||
'skia/src/core/SkEdge.cpp',
|
||||
|
@ -98,19 +78,21 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkExecutor.cpp',
|
||||
'skia/src/core/SkFlattenable.cpp',
|
||||
'skia/src/core/SkFont.cpp',
|
||||
'skia/src/core/SkFont_serial.cpp',
|
||||
'skia/src/core/SkFontDescriptor.cpp',
|
||||
'skia/src/core/SkFontMetricsPriv.cpp',
|
||||
'skia/src/core/SkFontLCDConfig.cpp',
|
||||
'skia/src/core/SkFontMgr.cpp',
|
||||
'skia/src/core/SkFontStream.cpp',
|
||||
'skia/src/core/SkGaussFilter.cpp',
|
||||
'skia/src/core/SkGeometry.cpp',
|
||||
'skia/src/core/SkGlobalInitialization_core.cpp',
|
||||
'skia/src/core/SkGlyph.cpp',
|
||||
'skia/src/core/SkGlyphBuffer.cpp',
|
||||
'skia/src/core/SkGlyphRun.cpp',
|
||||
'skia/src/core/SkGlyphRunPainter.cpp',
|
||||
'skia/src/core/SkGpuBlurUtils.cpp',
|
||||
'skia/src/core/SkGraphics.cpp',
|
||||
'skia/src/core/SkIDChangeListener.cpp',
|
||||
'skia/src/core/SkHalf.cpp',
|
||||
'skia/src/core/SkICC.cpp',
|
||||
'skia/src/core/SkImageFilter.cpp',
|
||||
'skia/src/core/SkImageFilterCache.cpp',
|
||||
'skia/src/core/SkImageFilterTypes.cpp',
|
||||
|
@ -119,28 +101,25 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkLatticeIter.cpp',
|
||||
'skia/src/core/SkLineClipper.cpp',
|
||||
'skia/src/core/SkLocalMatrixImageFilter.cpp',
|
||||
'skia/src/core/SkM44.cpp',
|
||||
'skia/src/core/SkMallocPixelRef.cpp',
|
||||
'skia/src/core/SkMask.cpp',
|
||||
'skia/src/core/SkMaskBlurFilter.cpp',
|
||||
'skia/src/core/SkMaskCache.cpp',
|
||||
'skia/src/core/SkMaskFilter.cpp',
|
||||
'skia/src/core/SkMaskGamma.cpp',
|
||||
'skia/src/core/SkMatrixInvert.cpp',
|
||||
'skia/src/core/SkMath.cpp',
|
||||
'skia/src/core/SkMatrixImageFilter.cpp',
|
||||
'skia/src/core/SkMD5.cpp',
|
||||
'skia/src/core/SkMesh.cpp',
|
||||
'skia/src/core/SkMipmap.cpp',
|
||||
'skia/src/core/SkMipmapAccessor.cpp',
|
||||
'skia/src/core/SkMipmapBuilder.cpp',
|
||||
'skia/src/core/SkMipMap.cpp',
|
||||
'skia/src/core/SkModeColorFilter.cpp',
|
||||
'skia/src/core/SkMultiPictureDraw.cpp',
|
||||
'skia/src/core/SkPaint.cpp',
|
||||
'skia/src/core/SkPaintPriv.cpp',
|
||||
'skia/src/core/SkPath.cpp',
|
||||
'skia/src/core/SkPath_serial.cpp',
|
||||
'skia/src/core/SkPathBuilder.cpp',
|
||||
'skia/src/core/SkPathEffect.cpp',
|
||||
'skia/src/core/SkPathMeasure.cpp',
|
||||
'skia/src/core/SkPathRef.cpp',
|
||||
'skia/src/core/SkPathUtils.cpp',
|
||||
'skia/src/core/SkPicture.cpp',
|
||||
'skia/src/core/SkPictureFlat.cpp',
|
||||
'skia/src/core/SkPictureImageGenerator.cpp',
|
||||
|
@ -149,7 +128,6 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkPictureRecorder.cpp',
|
||||
'skia/src/core/SkPixelRef.cpp',
|
||||
'skia/src/core/SkPixmap.cpp',
|
||||
'skia/src/core/SkPixmapDraw.cpp',
|
||||
'skia/src/core/SkPoint.cpp',
|
||||
'skia/src/core/SkPoint3.cpp',
|
||||
'skia/src/core/SkPromiseImageTexture.cpp',
|
||||
|
@ -159,7 +137,6 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkRasterPipeline.cpp',
|
||||
'skia/src/core/SkRasterPipelineBlitter.cpp',
|
||||
'skia/src/core/SkReadBuffer.cpp',
|
||||
'skia/src/core/SkReadPixelsRec.cpp',
|
||||
'skia/src/core/SkRecord.cpp',
|
||||
'skia/src/core/SkRecordDraw.cpp',
|
||||
'skia/src/core/SkRecordedDrawable.cpp',
|
||||
|
@ -168,19 +145,18 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkRect.cpp',
|
||||
'skia/src/core/SkRegion.cpp',
|
||||
'skia/src/core/SkRegion_path.cpp',
|
||||
'skia/src/core/SkRemoteGlyphCache.cpp',
|
||||
'skia/src/core/SkResourceCache.cpp',
|
||||
'skia/src/core/SkRRect.cpp',
|
||||
'skia/src/core/SkRSXform.cpp',
|
||||
'skia/src/core/SkRuntimeEffect.cpp',
|
||||
'skia/src/core/SkRWBuffer.cpp',
|
||||
'skia/src/core/SkScalar.cpp',
|
||||
'skia/src/core/SkScalerContext.cpp',
|
||||
'skia/src/core/SkScan.cpp',
|
||||
'skia/src/core/SkScan_AAAPath.cpp',
|
||||
'skia/src/core/SkScan_Hairline.cpp',
|
||||
'skia/src/core/SkScan_Path.cpp',
|
||||
'skia/src/core/SkScan_SAAPath.cpp',
|
||||
'skia/src/core/SkSemaphore.cpp',
|
||||
'skia/src/core/SkSharedMutex.cpp',
|
||||
'skia/src/core/SkSLTypeShared.cpp',
|
||||
'skia/src/core/SkSpecialImage.cpp',
|
||||
'skia/src/core/SkSpecialSurface.cpp',
|
||||
'skia/src/core/SkSpinlock.cpp',
|
||||
|
@ -197,37 +173,32 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/core/SkSwizzle.cpp',
|
||||
'skia/src/core/SkTaskGroup.cpp',
|
||||
'skia/src/core/SkTextBlob.cpp',
|
||||
'skia/src/core/SkTextBlobTrace.cpp',
|
||||
'skia/src/core/SkThreadID.cpp',
|
||||
'skia/src/core/SkTime.cpp',
|
||||
'skia/src/core/SkTLS.cpp',
|
||||
'skia/src/core/SkTSearch.cpp',
|
||||
'skia/src/core/SkTypeface.cpp',
|
||||
'skia/src/core/SkTypeface_remote.cpp',
|
||||
'skia/src/core/SkTypefaceCache.cpp',
|
||||
'skia/src/core/SkUnPreMultiply.cpp',
|
||||
'skia/src/core/SkUtils.cpp',
|
||||
'skia/src/core/SkVertState.cpp',
|
||||
'skia/src/core/SkVM.cpp',
|
||||
'skia/src/core/SkVMBlitter.cpp',
|
||||
'skia/src/core/SkWriteBuffer.cpp',
|
||||
'skia/src/core/SkWritePixelsRec.cpp',
|
||||
'skia/src/core/SkWriter32.cpp',
|
||||
'skia/src/core/SkYUVAInfo.cpp',
|
||||
'skia/src/core/SkYUVAPixmaps.cpp',
|
||||
'skia/src/core/SkYUVASizeInfo.cpp',
|
||||
'skia/src/core/SkYUVMath.cpp',
|
||||
'skia/src/core/SkYUVPlanesCache.cpp',
|
||||
'skia/src/effects/imagefilters/SkBlurImageFilter.cpp',
|
||||
'skia/src/effects/imagefilters/SkComposeImageFilter.cpp',
|
||||
'skia/src/effects/SkDashPathEffect.cpp',
|
||||
'skia/src/encode/SkEncoder.cpp',
|
||||
'skia/src/encode/SkICC.cpp',
|
||||
'skia/src/encode/SkImageEncoder.cpp',
|
||||
'skia/src/image/SkImage.cpp',
|
||||
'skia/src/image/SkImage_Base.cpp',
|
||||
'skia/src/image/SkImage_Lazy.cpp',
|
||||
'skia/src/image/SkImage_Raster.cpp',
|
||||
'skia/src/image/SkRescaleAndReadPixels.cpp',
|
||||
'skia/src/image/SkSurface.cpp',
|
||||
'skia/src/image/SkSurface_Base.cpp',
|
||||
'skia/src/image/SkSurface_Null.cpp',
|
||||
'skia/src/image/SkSurface_Raster.cpp',
|
||||
'skia/src/images/SkImageEncoder.cpp',
|
||||
'skia/src/lazy/SkDiscardableMemoryPool.cpp',
|
||||
'skia/src/pathops/SkAddIntersections.cpp',
|
||||
'skia/src/pathops/SkDConicLineIntersection.cpp',
|
||||
|
@ -261,15 +232,15 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/pathops/SkPathWriter.cpp',
|
||||
'skia/src/pathops/SkReduceOrder.cpp',
|
||||
'skia/src/ports/SkDiscardableMemory_none.cpp',
|
||||
'skia/src/ports/SkFontMgr_empty_factory.cpp',
|
||||
'skia/src/ports/SkGlobalInitialization_default.cpp',
|
||||
'skia/src/ports/SkImageGenerator_none.cpp',
|
||||
'skia/src/ports/SkMemory_mozalloc.cpp',
|
||||
'skia/src/ports/SkOSFile_stdio.cpp',
|
||||
'skia/src/sfnt/SkOTTable_name.cpp',
|
||||
'skia/src/sfnt/SkOTUtils.cpp',
|
||||
'skia/src/shaders/gradients/Sk4fGradientBase.cpp',
|
||||
'skia/src/shaders/gradients/Sk4fLinearGradient.cpp',
|
||||
'skia/src/shaders/gradients/SkGradientShader.cpp',
|
||||
'skia/src/shaders/gradients/SkGradientShaderBase.cpp',
|
||||
'skia/src/shaders/gradients/SkLinearGradient.cpp',
|
||||
'skia/src/shaders/gradients/SkRadialGradient.cpp',
|
||||
'skia/src/shaders/gradients/SkSweepGradient.cpp',
|
||||
|
@ -278,138 +249,42 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/shaders/SkColorFilterShader.cpp',
|
||||
'skia/src/shaders/SkColorShader.cpp',
|
||||
'skia/src/shaders/SkComposeShader.cpp',
|
||||
'skia/src/shaders/SkCoordClampShader.cpp',
|
||||
'skia/src/shaders/SkEmptyShader.cpp',
|
||||
'skia/src/shaders/SkGainmapShader.cpp',
|
||||
'skia/src/shaders/SkImageShader.cpp',
|
||||
'skia/src/shaders/SkLocalMatrixShader.cpp',
|
||||
'skia/src/shaders/SkPerlinNoiseShader.cpp',
|
||||
'skia/src/shaders/SkPictureShader.cpp',
|
||||
'skia/src/shaders/SkRTShader.cpp',
|
||||
'skia/src/shaders/SkShader.cpp',
|
||||
'skia/src/shaders/SkTransformShader.cpp',
|
||||
'skia/src/sksl/analysis/SkSLCanExitWithoutReturningValue.cpp',
|
||||
'skia/src/sksl/analysis/SkSLCheckProgramStructure.cpp',
|
||||
'skia/src/sksl/analysis/SkSLFinalizationChecks.cpp',
|
||||
'skia/src/sksl/analysis/SkSLGetLoopControlFlowInfo.cpp',
|
||||
'skia/src/sksl/analysis/SkSLGetLoopUnrollInfo.cpp',
|
||||
'skia/src/sksl/analysis/SkSLGetReturnComplexity.cpp',
|
||||
'skia/src/sksl/analysis/SkSLHasSideEffects.cpp',
|
||||
'skia/src/sksl/analysis/SkSLIsConstantExpression.cpp',
|
||||
'skia/src/sksl/analysis/SkSLIsDynamicallyUniformExpression.cpp',
|
||||
'skia/src/sksl/analysis/SkSLIsSameExpressionTree.cpp',
|
||||
'skia/src/sksl/analysis/SkSLIsTrivialExpression.cpp',
|
||||
'skia/src/sksl/analysis/SkSLProgramUsage.cpp',
|
||||
'skia/src/sksl/analysis/SkSLSwitchCaseContainsExit.cpp',
|
||||
'skia/src/sksl/analysis/SkSLSymbolTableStackBuilder.cpp',
|
||||
'skia/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp',
|
||||
'skia/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp',
|
||||
'skia/src/sksl/codegen/SkSLVMCodeGenerator.cpp',
|
||||
'skia/src/sksl/dsl/DSLBlock.cpp',
|
||||
'skia/src/sksl/dsl/DSLCase.cpp',
|
||||
'skia/src/sksl/dsl/DSLCore.cpp',
|
||||
'skia/src/sksl/dsl/DSLExpression.cpp',
|
||||
'skia/src/sksl/dsl/DSLFunction.cpp',
|
||||
'skia/src/sksl/dsl/DSLLayout.cpp',
|
||||
'skia/src/sksl/dsl/DSLStatement.cpp',
|
||||
'skia/src/sksl/dsl/DSLType.cpp',
|
||||
'skia/src/sksl/dsl/DSLVar.cpp',
|
||||
'skia/src/sksl/dsl/priv/DSLWriter.cpp',
|
||||
'skia/src/sksl/ir/SkSLBinaryExpression.cpp',
|
||||
'skia/src/sksl/ir/SkSLBlock.cpp',
|
||||
'skia/src/sksl/ir/SkSLChildCall.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructor.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorArray.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorArrayCast.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorCompound.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorCompoundCast.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorDiagonalMatrix.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorMatrixResize.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorScalarCast.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorSplat.cpp',
|
||||
'skia/src/sksl/ir/SkSLConstructorStruct.cpp',
|
||||
'skia/src/sksl/ir/SkSLDiscardStatement.cpp',
|
||||
'skia/src/sksl/ir/SkSLDoStatement.cpp',
|
||||
'skia/src/sksl/ir/SkSLExpression.cpp',
|
||||
'skia/src/sksl/ir/SkSLExpressionStatement.cpp',
|
||||
'skia/src/sksl/ir/SkSLFieldAccess.cpp',
|
||||
'skia/src/sksl/ir/SkSLForStatement.cpp',
|
||||
'skia/src/sksl/ir/SkSLFunctionCall.cpp',
|
||||
'skia/src/sksl/ir/SkSLFunctionDeclaration.cpp',
|
||||
'skia/src/sksl/ir/SkSLFunctionDefinition.cpp',
|
||||
'skia/src/sksl/ir/SkSLIfStatement.cpp',
|
||||
'skia/src/sksl/ir/SkSLIndexExpression.cpp',
|
||||
'skia/src/sksl/ir/SkSLInterfaceBlock.cpp',
|
||||
'skia/src/sksl/ir/SkSLLayout.cpp',
|
||||
'skia/src/sksl/ir/SkSLLiteral.cpp',
|
||||
'skia/src/sksl/ir/SkSLModifiers.cpp',
|
||||
'skia/src/sksl/ir/SkSLPostfixExpression.cpp',
|
||||
'skia/src/sksl/ir/SkSLPrefixExpression.cpp',
|
||||
'skia/src/sksl/ir/SkSLProgram.cpp',
|
||||
'skia/src/sksl/ir/SkSLSetting.cpp',
|
||||
'skia/src/sksl/ir/SkSLSwitchStatement.cpp',
|
||||
'skia/src/sksl/ir/SkSLSwizzle.cpp',
|
||||
'skia/src/sksl/ir/SkSLSymbolTable.cpp',
|
||||
'skia/src/sksl/ir/SkSLTernaryExpression.cpp',
|
||||
'skia/src/sksl/ir/SkSLType.cpp',
|
||||
'skia/src/sksl/ir/SkSLTypeReference.cpp',
|
||||
'skia/src/sksl/ir/SkSLVarDeclarations.cpp',
|
||||
'skia/src/sksl/ir/SkSLVariable.cpp',
|
||||
'skia/src/sksl/ir/SkSLVariableReference.cpp',
|
||||
'skia/src/sksl/SkSLAnalysis.cpp',
|
||||
'skia/src/sksl/SkSLBuiltinTypes.cpp',
|
||||
'skia/src/sksl/SkSLASTNode.cpp',
|
||||
'skia/src/sksl/SkSLByteCode.cpp',
|
||||
'skia/src/sksl/SkSLByteCodeGenerator.cpp',
|
||||
'skia/src/sksl/SkSLCFGGenerator.cpp',
|
||||
'skia/src/sksl/SkSLCompiler.cpp',
|
||||
'skia/src/sksl/SkSLConstantFolder.cpp',
|
||||
'skia/src/sksl/SkSLContext.cpp',
|
||||
'skia/src/sksl/SkSLErrorReporter.cpp',
|
||||
'skia/src/sksl/SkSLInliner.cpp',
|
||||
'skia/src/sksl/SkSLIntrinsicList.cpp',
|
||||
'skia/src/sksl/SkSLMangler.cpp',
|
||||
'skia/src/sksl/SkSLModuleLoader.cpp',
|
||||
'skia/src/sksl/SkSLOperator.cpp',
|
||||
'skia/src/sksl/SkSLOutputStream.cpp',
|
||||
'skia/src/sksl/SkSLIRGenerator.cpp',
|
||||
'skia/src/sksl/SkSLParser.cpp',
|
||||
'skia/src/sksl/SkSLPool.cpp',
|
||||
'skia/src/sksl/SkSLPosition.cpp',
|
||||
'skia/src/sksl/SkSLSampleUsage.cpp',
|
||||
'skia/src/sksl/SkSLSectionAndParameterHelper.cpp',
|
||||
'skia/src/sksl/SkSLString.cpp',
|
||||
'skia/src/sksl/SkSLThreadContext.cpp',
|
||||
'skia/src/sksl/SkSLUtil.cpp',
|
||||
'skia/src/sksl/tracing/SkRPDebugTrace.cpp',
|
||||
'skia/src/sksl/tracing/SkSLTraceHook.cpp',
|
||||
'skia/src/sksl/tracing/SkVMDebugTrace.cpp',
|
||||
'skia/src/sksl/tracing/SkVMDebugTracePlayer.cpp',
|
||||
'skia/src/sksl/transform/SkSLAddConstToVarModifiers.cpp',
|
||||
'skia/src/sksl/transform/SkSLEliminateDeadFunctions.cpp',
|
||||
'skia/src/sksl/transform/SkSLEliminateDeadGlobalVariables.cpp',
|
||||
'skia/src/sksl/transform/SkSLEliminateDeadLocalVariables.cpp',
|
||||
'skia/src/sksl/transform/SkSLEliminateEmptyStatements.cpp',
|
||||
'skia/src/sksl/transform/SkSLEliminateUnreachableCode.cpp',
|
||||
'skia/src/sksl/transform/SkSLFindAndDeclareBuiltinFunctions.cpp',
|
||||
'skia/src/sksl/transform/SkSLFindAndDeclareBuiltinVariables.cpp',
|
||||
'skia/src/sksl/transform/SkSLRenamePrivateSymbols.cpp',
|
||||
'skia/src/sksl/transform/SkSLReplaceConstVarsWithLiterals.cpp',
|
||||
'skia/src/sksl/transform/SkSLRewriteIndexedSwizzle.cpp',
|
||||
'skia/src/text/GlyphRun.cpp',
|
||||
'skia/src/text/StrikeForGPU.cpp',
|
||||
'skia/src/utils/mac/SkCTFont.cpp',
|
||||
'skia/src/utils/mac/SkStream_mac.cpp',
|
||||
'skia/src/utils/SkBase64.cpp',
|
||||
'skia/src/utils/SkCharToGlyphCache.cpp',
|
||||
'skia/src/utils/SkClipStackUtils.cpp',
|
||||
'skia/src/utils/SkCustomTypeface.cpp',
|
||||
'skia/src/utils/SkDashPath.cpp',
|
||||
'skia/src/utils/SkEventTracer.cpp',
|
||||
'skia/src/utils/SkFloatToDecimal.cpp',
|
||||
'skia/src/utils/SkGaussianColorFilter.cpp',
|
||||
'skia/src/utils/SkMatrix22.cpp',
|
||||
'skia/src/utils/SkOrderedFontMgr.cpp',
|
||||
'skia/src/utils/SkOSPath.cpp',
|
||||
'skia/src/utils/SkPatchUtils.cpp',
|
||||
'skia/src/utils/SkPolyUtils.cpp',
|
||||
'skia/src/utils/SkShaderUtils.cpp',
|
||||
'skia/src/utils/SkShadowTessellator.cpp',
|
||||
'skia/src/utils/SkShadowUtils.cpp',
|
||||
'skia/src/utils/SkTextUtils.cpp',
|
||||
'skia/src/utils/SkVMVisualizer.cpp',
|
||||
'skia/src/utils/SkThreadUtils_pthread.cpp',
|
||||
'skia/src/utils/SkThreadUtils_win.cpp',
|
||||
'skia/src/utils/SkUTF.cpp',
|
||||
'skia/src/utils/win/SkAutoCoInitialize.cpp',
|
||||
'skia/src/utils/win/SkDWrite.cpp',
|
||||
'skia/src/utils/win/SkDWriteFontFileStream.cpp',
|
||||
|
@ -418,26 +293,28 @@ UNIFIED_SOURCES += [
|
|||
'skia/src/utils/win/SkIStream.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/modules/skcms/skcms.cc',
|
||||
'skia/src/core/SkBitmapProcState.cpp',
|
||||
'skia/src/core/SkBitmapProcState_matrixProcs.cpp',
|
||||
'skia/src/core/SkBitmapScaler.cpp',
|
||||
'skia/src/core/SkBlitRow_D32.cpp',
|
||||
'skia/src/core/SkBlitter.cpp',
|
||||
'skia/src/core/SkBlitter_A8.cpp',
|
||||
'skia/src/core/SkBlitter_ARGB32.cpp',
|
||||
'skia/src/core/SkBlitter_RGB565.cpp',
|
||||
'skia/src/core/SkBlitter_Sprite.cpp',
|
||||
'skia/src/core/SkColorSpace.cpp',
|
||||
'skia/src/core/SkColorSpaceXformSteps.cpp',
|
||||
'skia/src/core/SkMatrix.cpp',
|
||||
'skia/src/core/SkMatrix44.cpp',
|
||||
'skia/src/core/SkMiniRecorder.cpp',
|
||||
'skia/src/core/SkOpts.cpp',
|
||||
'skia/src/core/SkOpts_erms.cpp',
|
||||
'skia/src/core/SkPath.cpp',
|
||||
'skia/src/core/SkPictureData.cpp',
|
||||
'skia/src/core/SkRecorder.cpp',
|
||||
'skia/src/core/SkRTree.cpp',
|
||||
'skia/src/core/SkScan_Antihair.cpp',
|
||||
'skia/src/core/SkScan_AntiPath.cpp',
|
||||
'skia/src/core/SkSpriteBlitter_ARGB32.cpp',
|
||||
'skia/src/core/SkSpriteBlitter_RGB565.cpp',
|
||||
'skia/src/core/SkVertices.cpp',
|
||||
'skia/src/core/SkXfermode.cpp',
|
||||
'skia/src/core/SkXfermodeInterpretation.cpp',
|
||||
|
@ -445,19 +322,22 @@ SOURCES += [
|
|||
'skia/src/sksl/SkSLLexer.cpp',
|
||||
'skia/src/utils/SkParse.cpp',
|
||||
'skia/src/utils/SkParsePath.cpp',
|
||||
'skia/third_party/skcms/skcms.cc',
|
||||
]
|
||||
SOURCES['skia/modules/skcms/skcms.cc'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBitmapProcState.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBitmapProcState_matrixProcs.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBitmapScaler.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBlitRow_D32.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBlitter.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBlitter_A8.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBlitter_ARGB32.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBlitter_RGB565.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkBlitter_Sprite.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkMatrix.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkOpts.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkOpts_erms.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkSpriteBlitter_ARGB32.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/core/SkSpriteBlitter_RGB565.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/third_party/skcms/skcms.cc'].flags += skia_opt_flags
|
||||
if CONFIG['MOZ_ENABLE_SKIA_PDF']:
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/pdf/SkClusterator.cpp',
|
||||
|
@ -490,6 +370,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
|||
'skia/src/ports/SkDebug_android.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
|
@ -498,17 +379,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
|||
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/ports/SkDebug_stdio.cpp',
|
||||
'skia/src/ports/SkFontMgr_mac_ct.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkScalerContext_mac_ct.cpp',
|
||||
'skia/src/ports/SkTypeface_mac_ct.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkFontHost_mac.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
|
||||
UNIFIED_SOURCES += [
|
||||
'skia/src/ports/SkDebug_stdio.cpp',
|
||||
'skia/src/ports/SkOSFile_posix.cpp',
|
||||
'skia/src/ports/SkOSLibrary_posix.cpp',
|
||||
'skia/src/ports/SkTLS_pthread.cpp',
|
||||
]
|
||||
SOURCES += [
|
||||
'skia/src/ports/SkFontHost_cairo.cpp',
|
||||
|
@ -519,22 +402,24 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
|||
'skia/src/ports/SkDebug_win.cpp',
|
||||
'skia/src/ports/SkFontHost_win.cpp',
|
||||
'skia/src/ports/SkFontMgr_win_dw.cpp',
|
||||
'skia/src/ports/SkFontMgr_win_dw_factory.cpp',
|
||||
'skia/src/ports/SkOSFile_win.cpp',
|
||||
'skia/src/ports/SkOSLibrary_win.cpp',
|
||||
'skia/src/ports/SkScalerContext_win_dw.cpp',
|
||||
'skia/src/ports/SkTLS_win.cpp',
|
||||
'skia/src/ports/SkTypeface_win_dw.cpp',
|
||||
]
|
||||
if CONFIG['INTEL_ARCHITECTURE']:
|
||||
SOURCES += [
|
||||
'skia/src/opts/SkOpts_avx.cpp',
|
||||
'skia/src/opts/SkOpts_hsw.cpp',
|
||||
'skia/src/opts/SkOpts_skx.cpp',
|
||||
'skia/src/opts/SkOpts_sse41.cpp',
|
||||
'skia/src/opts/SkOpts_sse42.cpp',
|
||||
'skia/src/opts/SkOpts_ssse3.cpp',
|
||||
]
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/opts/SkOpts_sse42.cpp'].flags += skia_opt_flags
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += skia_opt_flags
|
||||
elif CONFIG['CPU_ARCH'] == 'aarch64':
|
||||
|
@ -550,6 +435,7 @@ AllowCompilerWarnings()
|
|||
FINAL_LIBRARY = 'gkmedias'
|
||||
LOCAL_INCLUDES += [
|
||||
'skia',
|
||||
'skia/include/third_party/skcms',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
|
@ -564,10 +450,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
|||
|
||||
if CONFIG['INTEL_ARCHITECTURE']:
|
||||
SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3']
|
||||
SOURCES['skia/src/opts/SkOpts_sse41.cpp'].flags += ['-msse4.1']
|
||||
SOURCES['skia/src/opts/SkOpts_sse42.cpp'].flags += ['-msse4.2']
|
||||
SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx']
|
||||
SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-mavx2', '-mf16c', '-mfma']
|
||||
SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl']
|
||||
elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
SOURCES['skia/src/opts/SkOpts_crc32.cpp'].flags += ['-march=armv8-a+crc']
|
||||
|
||||
|
|
|
@ -8,18 +8,14 @@
|
|||
#ifndef SkAndroidFrameworkUtils_DEFINED
|
||||
#define SkAndroidFrameworkUtils_DEFINED
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTileMode.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
|
||||
class SkCanvas;
|
||||
struct SkIRect;
|
||||
struct SkRect;
|
||||
class SkSurface;
|
||||
class SkShader;
|
||||
|
||||
/**
|
||||
* SkAndroidFrameworkUtils expose private APIs used only by Android framework.
|
||||
|
@ -27,7 +23,7 @@ class SkShader;
|
|||
class SkAndroidFrameworkUtils {
|
||||
public:
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* clipWithStencil draws the current clip into a stencil buffer with reference value and mask
|
||||
* set to 0x1. This function works only on a GPU canvas.
|
||||
|
@ -37,7 +33,7 @@ public:
|
|||
* @return true on success or false if clip is empty or not a GPU canvas.
|
||||
*/
|
||||
static bool clipWithStencil(SkCanvas* canvas);
|
||||
#endif //defined(SK_GANESH)
|
||||
#endif //SK_SUPPORT_GPU
|
||||
|
||||
static void SafetyNetLog(const char*);
|
||||
|
||||
|
@ -45,10 +41,6 @@ public:
|
|||
|
||||
static int SaveBehind(SkCanvas* canvas, const SkRect* subset);
|
||||
|
||||
// Operating within the canvas' clip stack, this resets the geometry of the clip to be wide
|
||||
// open modula any device clip restriction that was set outside of the clip stack.
|
||||
static void ResetClip(SkCanvas* canvas);
|
||||
|
||||
/**
|
||||
* Unrolls a chain of nested SkPaintFilterCanvas to return the base wrapped canvas.
|
||||
*
|
||||
|
@ -57,31 +49,6 @@ public:
|
|||
* @return SkCanvas that was found in the innermost SkPaintFilterCanvas.
|
||||
*/
|
||||
static SkCanvas* getBaseWrappedCanvas(SkCanvas* canvas);
|
||||
|
||||
/**
|
||||
* If the shader represents a linear gradient ShaderAsALinearGradient
|
||||
* returns true and if info is not null, ShaderAsALinearGradient populates
|
||||
* info with the parameters for the gradient. fColorCount is both an input
|
||||
* and output parameter. On input, it indicates how many entries in
|
||||
* fColors and fColorOffsets can be used, if they are not nullptr. After
|
||||
* asAGradient has run, fColorCount indicates how many color-offset pairs
|
||||
* there are in the gradient. fColorOffsets specifies where on the range of
|
||||
* 0 to 1 to transition to the given color. fPoints represent the endpoints
|
||||
* of the gradient.
|
||||
*/
|
||||
struct LinearGradientInfo {
|
||||
int fColorCount = 0; //!< In-out parameter, specifies passed size
|
||||
// of fColors/fColorOffsets on input, and
|
||||
// actual number of colors/offsets on
|
||||
// output.
|
||||
SkColor* fColors = nullptr; //!< The colors in the gradient.
|
||||
SkScalar* fColorOffsets = nullptr; //!< The unit offset for color transitions.
|
||||
SkPoint fPoints[2]; //!< Type specific, see above.
|
||||
SkTileMode fTileMode;
|
||||
uint32_t fGradientFlags = 0; //!< see SkGradientShader::Flags
|
||||
};
|
||||
|
||||
static bool ShaderAsALinearGradient(SkShader* shader, LinearGradientInfo*);
|
||||
};
|
||||
|
||||
#endif // SK_BUILD_FOR_ANDROID_ANDROID
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "include/core/SkRect.h"
|
||||
|
||||
class SkAndroidCodec;
|
||||
class SkImage;
|
||||
class SkPicture;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +35,19 @@ public:
|
|||
static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>,
|
||||
const SkImageInfo& info, SkIRect cropRect, sk_sp<SkPicture> postProcess);
|
||||
|
||||
/**
|
||||
* Create an SkAnimatedImage from the SkAndroidCodec.
|
||||
*
|
||||
* Returns null on failure to allocate pixels. On success, this will
|
||||
* decode the first frame.
|
||||
*
|
||||
* @param scaledSize Size to draw the image, possibly requiring scaling.
|
||||
* @param cropRect Rectangle to crop to after scaling.
|
||||
* @param postProcess Picture to apply after scaling and cropping.
|
||||
*/
|
||||
static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>,
|
||||
SkISize scaledSize, SkIRect cropRect, sk_sp<SkPicture> postProcess);
|
||||
|
||||
/**
|
||||
* Simpler version that uses the default size, no cropping, and no postProcess.
|
||||
*/
|
||||
|
@ -70,13 +82,6 @@ public:
|
|||
*/
|
||||
int decodeNextFrame();
|
||||
|
||||
/**
|
||||
* Returns the current frame as an SkImage. The SkImage will not change
|
||||
* after it has been returned.
|
||||
* If there is no current frame, nullptr will be returned.
|
||||
*/
|
||||
sk_sp<SkImage> getCurrentFrame();
|
||||
|
||||
/**
|
||||
* How long to display the current frame.
|
||||
*
|
||||
|
@ -105,11 +110,6 @@ public:
|
|||
return fRepetitionCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total number of frames in the animation.
|
||||
*/
|
||||
int getFrameCount() const { return fFrameCount; }
|
||||
|
||||
protected:
|
||||
SkRect onGetBounds() override;
|
||||
void onDraw(SkCanvas*) override;
|
||||
|
@ -138,12 +138,13 @@ private:
|
|||
};
|
||||
|
||||
std::unique_ptr<SkAndroidCodec> fCodec;
|
||||
SkImageInfo fDecodeInfo;
|
||||
const SkISize fScaledSize;
|
||||
const SkImageInfo fDecodeInfo;
|
||||
const SkIRect fCropRect;
|
||||
const sk_sp<SkPicture> fPostProcess;
|
||||
const int fFrameCount;
|
||||
SkMatrix fMatrix;
|
||||
int fSampleSize;
|
||||
const bool fSimple; // no crop, scale, or postprocess
|
||||
SkMatrix fMatrix; // used only if !fSimple
|
||||
|
||||
bool fFinished;
|
||||
int fCurrentFrameDuration;
|
||||
|
@ -153,27 +154,14 @@ private:
|
|||
int fRepetitionCount;
|
||||
int fRepetitionsCompleted;
|
||||
|
||||
SkAnimatedImage(std::unique_ptr<SkAndroidCodec>, const SkImageInfo& requestedInfo,
|
||||
SkIRect cropRect, sk_sp<SkPicture> postProcess);
|
||||
SkAnimatedImage(std::unique_ptr<SkAndroidCodec>, SkISize scaledSize,
|
||||
SkImageInfo decodeInfo, SkIRect cropRect, sk_sp<SkPicture> postProcess);
|
||||
SkAnimatedImage(std::unique_ptr<SkAndroidCodec>);
|
||||
|
||||
int computeNextFrame(int current, bool* animationEnded);
|
||||
double finish();
|
||||
|
||||
/**
|
||||
* True if there is no crop, orientation, or post decoding scaling.
|
||||
*/
|
||||
bool simple() const { return fMatrix.isIdentity() && !fPostProcess
|
||||
&& fCropRect == fDecodeInfo.bounds(); }
|
||||
|
||||
/**
|
||||
* Returns the current frame as an SkImage.
|
||||
*
|
||||
* Like getCurrentFrame, but only returns the raw data from the internal SkBitmap. (i.e. no
|
||||
* scaling, orientation-correction or cropping.) If simple(), this is the final output.
|
||||
*/
|
||||
sk_sp<SkImage> getCurrentFrameSimple();
|
||||
|
||||
using INHERITED = SkDrawable;
|
||||
typedef SkDrawable INHERITED;
|
||||
};
|
||||
|
||||
#endif // SkAnimatedImage_DEFINED
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBRDAllocator_DEFINED
|
||||
#define SkBRDAllocator_DEFINED
|
||||
|
||||
#include "include/codec/SkCodec.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
|
||||
/**
|
||||
* Abstract subclass of SkBitmap's allocator.
|
||||
* Allows the allocator to indicate if the memory it allocates
|
||||
* is zero initialized.
|
||||
*/
|
||||
class SkBRDAllocator : public SkBitmap::Allocator {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Indicates if the memory allocated by this allocator is
|
||||
* zero initialized.
|
||||
*/
|
||||
virtual SkCodec::ZeroInitialized zeroInit() const = 0;
|
||||
};
|
||||
|
||||
#endif // SkBRDAllocator_DEFINED
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBitmapRegionDecoder_DEFINED
|
||||
#define SkBitmapRegionDecoder_DEFINED
|
||||
|
||||
#include "include/android/SkBRDAllocator.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkStream.h"
|
||||
|
||||
/*
|
||||
* This class aims to provide an interface to test multiple implementations of
|
||||
* SkBitmapRegionDecoder.
|
||||
*/
|
||||
class SK_API SkBitmapRegionDecoder {
|
||||
public:
|
||||
|
||||
enum Strategy {
|
||||
kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsetting
|
||||
};
|
||||
|
||||
/*
|
||||
* @param data Refs the data while this object exists, unrefs on destruction
|
||||
* @param strategy Strategy used for scaling and subsetting
|
||||
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
|
||||
*/
|
||||
static SkBitmapRegionDecoder* Create(sk_sp<SkData>, Strategy strategy);
|
||||
|
||||
/*
|
||||
* @param stream Takes ownership of the stream
|
||||
* @param strategy Strategy used for scaling and subsetting
|
||||
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
|
||||
*/
|
||||
static SkBitmapRegionDecoder* Create(
|
||||
SkStreamRewindable* stream, Strategy strategy);
|
||||
|
||||
/*
|
||||
* Decode a scaled region of the encoded image stream
|
||||
*
|
||||
* @param bitmap Container for decoded pixels. It is assumed that the pixels
|
||||
* are initially unallocated and will be allocated by this function.
|
||||
* @param allocator Allocator for the pixels. If this is NULL, the default
|
||||
* allocator (HeapAllocator) will be used.
|
||||
* @param desiredSubset Subset of the original image to decode.
|
||||
* @param sampleSize An integer downscaling factor for the decode.
|
||||
* @param colorType Preferred output colorType.
|
||||
* New implementations should return NULL if they do not support
|
||||
* decoding to this color type.
|
||||
* The old kOriginal_Strategy will decode to a default color type
|
||||
* if this color type is unsupported.
|
||||
* @param requireUnpremul If the image is not opaque, we will use this to determine the
|
||||
* alpha type to use.
|
||||
* @param prefColorSpace If non-null and supported, this is the color space that we will
|
||||
* decode into. Otherwise, we will choose a default.
|
||||
*
|
||||
*/
|
||||
virtual bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
|
||||
const SkIRect& desiredSubset, int sampleSize,
|
||||
SkColorType colorType, bool requireUnpremul,
|
||||
sk_sp<SkColorSpace> prefColorSpace = nullptr) = 0;
|
||||
|
||||
virtual SkEncodedImageFormat getEncodedFormat() = 0;
|
||||
|
||||
virtual SkColorType computeOutputColorType(SkColorType requestedColorType) = 0;
|
||||
|
||||
virtual sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
|
||||
sk_sp<SkColorSpace> prefColorSpace = nullptr) = 0;
|
||||
|
||||
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
|
||||
virtual ~SkBitmapRegionDecoder() {}
|
||||
|
||||
protected:
|
||||
|
||||
SkBitmapRegionDecoder(int width, int height)
|
||||
: fWidth(width)
|
||||
, fHeight(height)
|
||||
{}
|
||||
|
||||
private:
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkImageAndroid_DEFINED
|
||||
#define SkImageAndroid_DEFINED
|
||||
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/gpu/GrTypes.h"
|
||||
|
||||
class SkColorSpace;
|
||||
class GrDirectContext;
|
||||
class SkPixmap;
|
||||
struct AHardwareBuffer;
|
||||
|
||||
namespace sk_image_factory {
|
||||
|
||||
/**
|
||||
* Like SkImagePriv::SkMakeImageFromRasterBitmap, except this can be pinned using
|
||||
* skgpu::Pin and CopyPixelMode is never.
|
||||
*/
|
||||
SK_API sk_sp<SkImage> MakePinnableFromRasterBitmap(const SkBitmap&);
|
||||
|
||||
/** (See Skia bug 7447)
|
||||
Creates SkImage from Android hardware buffer.
|
||||
Returned SkImage takes a reference on the buffer.
|
||||
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
||||
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
SK_API sk_sp<SkImage> MakeFromAHardwareBuffer(
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
SkAlphaType alphaType = kPremul_SkAlphaType);
|
||||
SK_API sk_sp<SkImage> MakeFromAHardwareBuffer(
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
||||
|
||||
/** Creates SkImage from Android hardware buffer and uploads the data from the SkPixmap to it.
|
||||
Returned SkImage takes a reference on the buffer.
|
||||
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
||||
@param context GPU context
|
||||
@param pixmap SkPixmap that contains data to be uploaded to the AHardwareBuffer
|
||||
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
||||
@param surfaceOrigin surface origin for resulting image
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
SK_API sk_sp<SkImage> MakeFromAHardwareBufferWithData(
|
||||
GrDirectContext* context,
|
||||
const SkPixmap& pixmap,
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
||||
} // namespace sk_image_factory
|
||||
|
||||
namespace skgpu::ganesh {
|
||||
/**
|
||||
* Will attempt to upload and lock the contents of the image as a texture, so that subsequent
|
||||
* draws to a gpu-target will come from that texture (and not by looking at the original image
|
||||
* src). In particular this is intended to use the texture even if the image's original content
|
||||
* changes subsequent to this call (i.e. the src is mutable!).
|
||||
*
|
||||
* Only compatible with SkImages created from MakePinnableFromRasterBitmap.
|
||||
*
|
||||
* All successful calls must be balanced by an equal number of calls to UnpinTexture().
|
||||
*
|
||||
* Once in this "pinned" state, the image has all of the same thread restrictions that exist
|
||||
* for a natively created gpu image (e.g. SkImage::MakeFromTexture)
|
||||
* - all drawing, pinning, unpinning must happen in the same thread as the GrContext.
|
||||
*
|
||||
* @return true if the image was successfully uploaded and locked into a texture
|
||||
*/
|
||||
bool PinAsTexture(GrRecordingContext*, SkImage*);
|
||||
|
||||
/**
|
||||
* The balancing call to a successful invocation of PinAsTexture. When a balanced
|
||||
* number of calls have been made, then the "pinned" texture is free to be purged, etc. This
|
||||
* also means that a subsequent "pin" call will look at the original content again, and if
|
||||
* its uniqueID/generationID has changed, then a newer texture will be uploaded/pinned.
|
||||
*
|
||||
* Only compatible with SkImages created from MakePinnableFromRasterBitmap.
|
||||
*
|
||||
* The context passed to unpin must match the one passed to pin.
|
||||
*/
|
||||
void UnpinTexture(GrRecordingContext*, SkImage*);
|
||||
|
||||
} // namespace skgpu::ganesh
|
||||
|
||||
#endif
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAtlasTextContext_DEFINED
|
||||
#define SkAtlasTextContext_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
class SkAtlasTextRenderer;
|
||||
class SkInternalAtlasTextContext;
|
||||
|
||||
SkAtlasTextRenderer* SkGetAtlasTextRendererFromInternalContext(class SkInternalAtlasTextContext&);
|
||||
|
||||
/**
|
||||
* Class that Atlas Text client uses to register their SkAtlasTextRenderer implementation and
|
||||
* to create one or more SkAtlasTextTargets (destination surfaces for text rendering).
|
||||
*/
|
||||
class SK_API SkAtlasTextContext : public SkRefCnt {
|
||||
public:
|
||||
static sk_sp<SkAtlasTextContext> Make(sk_sp<SkAtlasTextRenderer>);
|
||||
|
||||
SkAtlasTextRenderer* renderer() const {
|
||||
return SkGetAtlasTextRendererFromInternalContext(*fInternalContext);
|
||||
}
|
||||
|
||||
SkInternalAtlasTextContext& internal() { return *fInternalContext; }
|
||||
|
||||
private:
|
||||
SkAtlasTextContext() = delete;
|
||||
SkAtlasTextContext(const SkAtlasTextContext&) = delete;
|
||||
SkAtlasTextContext& operator=(const SkAtlasTextContext&) = delete;
|
||||
|
||||
SkAtlasTextContext(sk_sp<SkAtlasTextRenderer>);
|
||||
|
||||
std::unique_ptr<SkInternalAtlasTextContext> fInternalContext;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAtlasTextFont_DEFINED
|
||||
#define SkAtlasTextFont_DEFINED
|
||||
|
||||
#include "include/core/SkFont.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
|
||||
/** Represents a font at a size. TODO: What else do we need here (skewX, scaleX, vertical, ...)? */
|
||||
class SK_API SkAtlasTextFont : public SkRefCnt {
|
||||
public:
|
||||
static sk_sp<SkAtlasTextFont> Make(sk_sp<SkTypeface> typeface, SkScalar size) {
|
||||
return sk_sp<SkAtlasTextFont>(new SkAtlasTextFont(std::move(typeface), size));
|
||||
}
|
||||
|
||||
SkTypeface* typeface() const { return fTypeface.get(); }
|
||||
|
||||
sk_sp<SkTypeface> refTypeface() const { return fTypeface; }
|
||||
|
||||
SkScalar size() const { return fSize; }
|
||||
|
||||
SkFont makeFont() const { return SkFont(fTypeface, fSize); }
|
||||
|
||||
private:
|
||||
SkAtlasTextFont(sk_sp<SkTypeface> typeface, SkScalar size)
|
||||
: fTypeface(std::move(typeface)), fSize(size) {}
|
||||
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
SkScalar fSize;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/core/SkPoint3.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
#ifndef SkAtlasTextRenderer_DEFINED
|
||||
#define SkAtlasTextRenderer_DEFINED
|
||||
|
||||
/**
|
||||
* This is the base class for a renderer implemented by the SkAtlasText client. The
|
||||
* SkAtlasTextContext issues texture creations, deletions, uploads, and vertex draws to the
|
||||
* renderer. The renderer must perform those actions in the order called to correctly render
|
||||
* the text drawn to SkAtlasTextTargets.
|
||||
*/
|
||||
class SK_API SkAtlasTextRenderer : public SkRefCnt {
|
||||
public:
|
||||
enum class AtlasFormat {
|
||||
/** Unsigned normalized 8 bit single channel format. */
|
||||
kA8
|
||||
};
|
||||
|
||||
struct SDFVertex {
|
||||
/** Position in device space (not normalized). The third component is w (not z). */
|
||||
SkPoint3 fPosition;
|
||||
/** Color, same value for all four corners of a glyph quad. */
|
||||
uint32_t fColor;
|
||||
/** Texture coordinate (in texel units, not normalized). */
|
||||
int16_t fTextureCoordX;
|
||||
int16_t fTextureCoordY;
|
||||
};
|
||||
|
||||
virtual ~SkAtlasTextRenderer() = default;
|
||||
|
||||
/**
|
||||
* Create a texture of the provided format with dimensions 'width' x 'height'
|
||||
* and return a unique handle.
|
||||
*/
|
||||
virtual void* createTexture(AtlasFormat, int width, int height) = 0;
|
||||
|
||||
/**
|
||||
* Delete the texture with the passed handle.
|
||||
*/
|
||||
virtual void deleteTexture(void* textureHandle) = 0;
|
||||
|
||||
/**
|
||||
* Place the pixel data specified by 'data' in the texture with handle
|
||||
* 'textureHandle' in the rectangle ['x', 'x' + 'width') x ['y', 'y' + 'height').
|
||||
* 'rowBytes' specifies the byte offset between successive rows in 'data' and will always be
|
||||
* a multiple of the number of bytes per pixel.
|
||||
* The pixel format of data is the same as that of 'textureHandle'.
|
||||
*/
|
||||
virtual void setTextureData(void* textureHandle, const void* data, int x, int y, int width,
|
||||
int height, size_t rowBytes) = 0;
|
||||
|
||||
/**
|
||||
* Draws glyphs using SDFs. The SDF data resides in 'textureHandle'. The array
|
||||
* 'vertices' provides interleaved device-space positions, colors, and
|
||||
* texture coordinates. There are are 4 * 'quadCnt' entries in 'vertices'.
|
||||
*/
|
||||
virtual void drawSDFGlyphs(void* targetHandle, void* textureHandle, const SDFVertex vertices[],
|
||||
int quadCnt) = 0;
|
||||
|
||||
/** Called when a SkAtlasTextureTarget is destroyed. */
|
||||
virtual void targetDeleted(void* targetHandle) = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAtlasTextTarget_DEFINED
|
||||
#define SkAtlasTextTarget_DEFINED
|
||||
|
||||
#include "include/core/SkDeque.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SkAtlasTextContext;
|
||||
class SkAtlasTextFont;
|
||||
class SkMatrix;
|
||||
struct SkPoint;
|
||||
|
||||
/** Represents a client-created renderable surface and is used to draw text into the surface. */
|
||||
class SK_API SkAtlasTextTarget {
|
||||
public:
|
||||
virtual ~SkAtlasTextTarget();
|
||||
|
||||
/**
|
||||
* Creates a text drawing target. ‘handle’ is used to identify this rendering surface when
|
||||
* draws are flushed to the SkAtlasTextContext's SkAtlasTextRenderer.
|
||||
*/
|
||||
static std::unique_ptr<SkAtlasTextTarget> Make(sk_sp<SkAtlasTextContext>,
|
||||
int width,
|
||||
int height,
|
||||
void* handle);
|
||||
|
||||
/**
|
||||
* Enqueues a text draw in the target. The caller provides an array of glyphs and their
|
||||
* positions. The meaning of 'color' here is interpreted by the client's SkAtlasTextRenderer
|
||||
* when it actually renders the text.
|
||||
*/
|
||||
virtual void drawText(const SkGlyphID[], const SkPoint[], int glyphCnt, uint32_t color,
|
||||
const SkAtlasTextFont&) = 0;
|
||||
|
||||
/** Issues all queued text draws to SkAtlasTextRenderer. */
|
||||
virtual void flush() = 0;
|
||||
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
|
||||
void* handle() const { return fHandle; }
|
||||
|
||||
SkAtlasTextContext* context() const { return fContext.get(); }
|
||||
|
||||
/** Saves the current matrix in a stack. Returns the prior depth of the saved matrix stack. */
|
||||
int save();
|
||||
/** Pops the top matrix on the stack if the stack is not empty. */
|
||||
void restore();
|
||||
/**
|
||||
* Pops the matrix stack until the stack depth is count. Does nothing if the depth is already
|
||||
* less than count.
|
||||
*/
|
||||
void restoreToCount(int count);
|
||||
|
||||
/** Pre-translates the current CTM. */
|
||||
void translate(SkScalar dx, SkScalar dy);
|
||||
/** Pre-scales the current CTM. */
|
||||
void scale(SkScalar sx, SkScalar sy);
|
||||
/** Pre-rotates the current CTM about the origin. */
|
||||
void rotate(SkScalar degrees);
|
||||
/** Pre-rotates the current CTM about the (px, py). */
|
||||
void rotate(SkScalar degrees, SkScalar px, SkScalar py);
|
||||
/** Pre-skews the current CTM. */
|
||||
void skew(SkScalar sx, SkScalar sy);
|
||||
/** Pre-concats the current CTM. */
|
||||
void concat(const SkMatrix& matrix);
|
||||
|
||||
protected:
|
||||
SkAtlasTextTarget(sk_sp<SkAtlasTextContext>, int width, int height, void* handle);
|
||||
|
||||
const SkMatrix& ctm() const { return *static_cast<const SkMatrix*>(fMatrixStack.back()); }
|
||||
|
||||
void* const fHandle;
|
||||
const sk_sp<SkAtlasTextContext> fContext;
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
|
||||
private:
|
||||
SkDeque fMatrixStack;
|
||||
int fSaveCnt;
|
||||
|
||||
SkMatrix* accessCTM() const {
|
||||
return static_cast<SkMatrix*>(const_cast<void*>(fMatrixStack.back()));
|
||||
}
|
||||
|
||||
SkAtlasTextTarget() = delete;
|
||||
SkAtlasTextTarget(const SkAtlasTextContext&) = delete;
|
||||
SkAtlasTextTarget& operator=(const SkAtlasTextContext&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_canvas_DEFINED
|
||||
#define sk_canvas_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Save the current matrix and clip on the canvas. When the
|
||||
balancing call to sk_canvas_restore() is made, the previous matrix
|
||||
and clip are restored.
|
||||
*/
|
||||
SK_API void sk_canvas_save(sk_canvas_t*);
|
||||
/**
|
||||
This behaves the same as sk_canvas_save(), but in addition it
|
||||
allocates an offscreen surface. All drawing calls are directed
|
||||
there, and only when the balancing call to sk_canvas_restore() is
|
||||
made is that offscreen transfered to the canvas (or the previous
|
||||
layer).
|
||||
|
||||
@param sk_rect_t* (may be null) This rect, if non-null, is used as
|
||||
a hint to limit the size of the offscreen, and
|
||||
thus drawing may be clipped to it, though that
|
||||
clipping is not guaranteed to happen. If exact
|
||||
clipping is desired, use sk_canvas_clip_rect().
|
||||
@param sk_paint_t* (may be null) The paint is copied, and is applied
|
||||
to the offscreen when sk_canvas_restore() is
|
||||
called.
|
||||
*/
|
||||
SK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
This call balances a previous call to sk_canvas_save() or
|
||||
sk_canvas_save_layer(), and is used to remove all modifications to
|
||||
the matrix and clip state since the last save call. It is an
|
||||
error to call sk_canvas_restore() more times than save and
|
||||
save_layer were called.
|
||||
*/
|
||||
SK_API void sk_canvas_restore(sk_canvas_t*);
|
||||
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified translation.
|
||||
*/
|
||||
SK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified scale.
|
||||
*/
|
||||
SK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified rotation in degrees.
|
||||
*/
|
||||
SK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified rotation in radians.
|
||||
*/
|
||||
SK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified skew.
|
||||
*/
|
||||
SK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified matrix.
|
||||
*/
|
||||
SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*);
|
||||
|
||||
/**
|
||||
Modify the current clip with the specified rectangle. The new
|
||||
current clip will be the intersection of the old clip and the
|
||||
rectange.
|
||||
*/
|
||||
SK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*);
|
||||
/**
|
||||
Modify the current clip with the specified path. The new
|
||||
current clip will be the intersection of the old clip and the
|
||||
path.
|
||||
*/
|
||||
SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*);
|
||||
|
||||
/**
|
||||
Fill the entire canvas (restricted to the current clip) with the
|
||||
specified paint.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified rectangle using the specified paint. The
|
||||
rectangle will be filled or stroked based on the style in the
|
||||
paint.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
* Draw the circle centered at (cx, cy) with radius rad using the specified paint.
|
||||
* The circle will be filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_circle(sk_canvas_t*, float cx, float cy, float rad, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified oval using the specified paint. The oval will be
|
||||
filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified path using the specified paint. The path will be
|
||||
filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified image, with its top/left corner at (x,y), using
|
||||
the specified paint, transformed by the current matrix.
|
||||
|
||||
@param sk_paint_t* (may be NULL) the paint used to draw the image.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*,
|
||||
float x, float y, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified image, scaling and translating so that it fills
|
||||
the specified dst rect. If the src rect is non-null, only that
|
||||
subset of the image is transformed and drawn.
|
||||
|
||||
@param sk_paint_t* (may be NULL) The paint used to draw the image.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*,
|
||||
const sk_rect_t* src,
|
||||
const sk_rect_t* dst, const sk_paint_t*);
|
||||
|
||||
/**
|
||||
Draw the picture into this canvas (replay the pciture's drawing commands).
|
||||
|
||||
@param sk_matrix_t* If non-null, apply that matrix to the CTM when
|
||||
drawing this picture. This is logically
|
||||
equivalent to: save, concat, draw_picture,
|
||||
restore.
|
||||
|
||||
@param sk_paint_t* If non-null, draw the picture into a temporary
|
||||
buffer, and then apply the paint's alpha,
|
||||
colorfilter, imagefilter, and xfermode to that
|
||||
buffer as it is drawn to the canvas. This is
|
||||
logically equivalent to save_layer(paint),
|
||||
draw_picture, restore.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*,
|
||||
const sk_matrix_t*, const sk_paint_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_colorspace_DEFINED
|
||||
#define sk_colorspace_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
SK_API sk_colorspace_t* sk_colorspace_new_srgb();
|
||||
|
||||
SK_API void sk_colorspace_ref(sk_colorspace_t*);
|
||||
SK_API void sk_colorspace_unref(sk_colorspace_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_data_DEFINED
|
||||
#define sk_data_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Returns a new empty sk_data_t. This call must be balanced with a call to
|
||||
sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_empty(void);
|
||||
/**
|
||||
Returns a new sk_data_t by copying the specified source data.
|
||||
This call must be balanced with a call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_with_copy(const void* src, size_t length);
|
||||
/**
|
||||
Pass ownership of the given memory to a new sk_data_t, which will
|
||||
call free() when the refernce count of the data goes to zero. For
|
||||
example:
|
||||
size_t length = 1024;
|
||||
void* buffer = malloc(length);
|
||||
memset(buffer, 'X', length);
|
||||
sk_data_t* data = sk_data_new_from_malloc(buffer, length);
|
||||
This call must be balanced with a call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_from_malloc(const void* memory, size_t length);
|
||||
/**
|
||||
Returns a new sk_data_t using a subset of the data in the
|
||||
specified source sk_data_t. This call must be balanced with a
|
||||
call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_subset(const sk_data_t* src, size_t offset, size_t length);
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_data_t. Must be
|
||||
balanced by a call to sk_data_unref().
|
||||
*/
|
||||
SK_API void sk_data_ref(const sk_data_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the sk_data_t
|
||||
and the memory it is managing. New sk_data_t are created with a
|
||||
reference count of 1.
|
||||
*/
|
||||
SK_API void sk_data_unref(const sk_data_t*);
|
||||
|
||||
/**
|
||||
Returns the number of bytes stored.
|
||||
*/
|
||||
SK_API size_t sk_data_get_size(const sk_data_t*);
|
||||
/**
|
||||
Returns the pointer to the data.
|
||||
*/
|
||||
SK_API const void* sk_data_get_data(const sk_data_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_image_DEFINED
|
||||
#define sk_image_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
* Return a new image that has made a copy of the provided pixels, or NULL on failure.
|
||||
* Balance with a call to sk_image_unref().
|
||||
*/
|
||||
SK_API sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* If the specified data can be interpreted as a compressed image (e.g. PNG or JPEG) then this
|
||||
* returns an image. If the encoded data is not supported, returns NULL.
|
||||
*
|
||||
* On success, the encoded data may be processed immediately, or it may be ref()'d for later
|
||||
* use.
|
||||
*/
|
||||
SK_API sk_image_t* sk_image_new_from_encoded(const sk_data_t* encoded, const sk_irect_t* subset);
|
||||
|
||||
/**
|
||||
* Encode the image's pixels and return the result as a new PNG in a
|
||||
* sk_data_t, which the caller must manage: call sk_data_unref() when
|
||||
* they are done.
|
||||
*
|
||||
* If the image type cannot be encoded, this will return NULL.
|
||||
*/
|
||||
SK_API sk_data_t* sk_image_encode(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Increment the reference count on the given sk_image_t. Must be
|
||||
* balanced by a call to sk_image_unref().
|
||||
*/
|
||||
SK_API void sk_image_ref(const sk_image_t*);
|
||||
/**
|
||||
* Decrement the reference count. If the reference count is 1 before
|
||||
* the decrement, then release both the memory holding the sk_image_t
|
||||
* and the memory it is managing. New sk_image_t are created with a
|
||||
reference count of 1.
|
||||
*/
|
||||
SK_API void sk_image_unref(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Return the width of the sk_image_t/
|
||||
*/
|
||||
SK_API int sk_image_get_width(const sk_image_t*);
|
||||
/**
|
||||
* Return the height of the sk_image_t/
|
||||
*/
|
||||
SK_API int sk_image_get_height(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Returns a non-zero value unique among all images.
|
||||
*/
|
||||
SK_API uint32_t sk_image_get_unique_id(const sk_image_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_imageinfo_DEFINED
|
||||
#define sk_imageinfo_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN_SK_COLORTYPE,
|
||||
RGBA_8888_SK_COLORTYPE,
|
||||
BGRA_8888_SK_COLORTYPE,
|
||||
ALPHA_8_SK_COLORTYPE,
|
||||
GRAY_8_SK_COLORTYPE,
|
||||
RGBA_F16_SK_COLORTYPE,
|
||||
RGBA_F32_SK_COLORTYPE,
|
||||
} sk_colortype_t;
|
||||
|
||||
typedef enum {
|
||||
OPAQUE_SK_ALPHATYPE,
|
||||
PREMUL_SK_ALPHATYPE,
|
||||
UNPREMUL_SK_ALPHATYPE,
|
||||
} sk_alphatype_t;
|
||||
|
||||
/**
|
||||
* Allocate a new imageinfo object. If colorspace is not null, it's owner-count will be
|
||||
* incremented automatically.
|
||||
*/
|
||||
SK_API sk_imageinfo_t* sk_imageinfo_new(int width, int height, sk_colortype_t ct, sk_alphatype_t at,
|
||||
sk_colorspace_t* cs);
|
||||
|
||||
/**
|
||||
* Free the imageinfo object. If it contains a reference to a colorspace, its owner-count will
|
||||
* be decremented automatically.
|
||||
*/
|
||||
SK_API void sk_imageinfo_delete(sk_imageinfo_t*);
|
||||
|
||||
SK_API int32_t sk_imageinfo_get_width(const sk_imageinfo_t*);
|
||||
SK_API int32_t sk_imageinfo_get_height(const sk_imageinfo_t*);
|
||||
SK_API sk_colortype_t sk_imageinfo_get_colortype(const sk_imageinfo_t*);
|
||||
SK_API sk_alphatype_t sk_imageinfo_get_alphatype(const sk_imageinfo_t*);
|
||||
|
||||
/**
|
||||
* Return the colorspace object reference contained in the imageinfo, or null if there is none.
|
||||
* Note: this does not modify the owner-count on the colorspace object. If the caller needs to
|
||||
* use the colorspace beyond the lifetime of the imageinfo, it should manually call
|
||||
* sk_colorspace_ref() (and then call unref() when it is done).
|
||||
*/
|
||||
SK_API sk_colorspace_t* sk_imageinfo_get_colorspace(const sk_imageinfo_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_maskfilter_DEFINED
|
||||
#define sk_maskfilter_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
typedef enum {
|
||||
NORMAL_SK_BLUR_STYLE, //!< fuzzy inside and outside
|
||||
SOLID_SK_BLUR_STYLE, //!< solid inside, fuzzy outside
|
||||
OUTER_SK_BLUR_STYLE, //!< nothing inside, fuzzy outside
|
||||
INNER_SK_BLUR_STYLE, //!< fuzzy inside, nothing outside
|
||||
} sk_blurstyle_t;
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_maskfilter_t. Must be
|
||||
balanced by a call to sk_maskfilter_unref().
|
||||
*/
|
||||
SK_API void sk_maskfilter_ref(sk_maskfilter_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_maskfilter_t and any other associated resources. New
|
||||
sk_maskfilter_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_maskfilter_unref(sk_maskfilter_t*);
|
||||
|
||||
/**
|
||||
Create a blur maskfilter.
|
||||
@param sk_blurstyle_t The SkBlurStyle to use
|
||||
@param sigma Standard deviation of the Gaussian blur to apply. Must be > 0.
|
||||
*/
|
||||
SK_API sk_maskfilter_t* sk_maskfilter_new_blur(sk_blurstyle_t, float sigma);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_matrix_DEFINED
|
||||
#define sk_matrix_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/** Set the matrix to identity */
|
||||
void sk_matrix_set_identity(sk_matrix_t*);
|
||||
|
||||
/** Set the matrix to translate by (tx, ty). */
|
||||
void sk_matrix_set_translate(sk_matrix_t*, float tx, float ty);
|
||||
/**
|
||||
Preconcats the matrix with the specified translation.
|
||||
M' = M * T(dx, dy)
|
||||
*/
|
||||
void sk_matrix_pre_translate(sk_matrix_t*, float tx, float ty);
|
||||
/**
|
||||
Postconcats the matrix with the specified translation.
|
||||
M' = T(dx, dy) * M
|
||||
*/
|
||||
void sk_matrix_post_translate(sk_matrix_t*, float tx, float ty);
|
||||
|
||||
/** Set the matrix to scale by sx and sy. */
|
||||
void sk_matrix_set_scale(sk_matrix_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcats the matrix with the specified scale.
|
||||
M' = M * S(sx, sy)
|
||||
*/
|
||||
void sk_matrix_pre_scale(sk_matrix_t*, float sx, float sy);
|
||||
/**
|
||||
Postconcats the matrix with the specified scale.
|
||||
M' = S(sx, sy) * M
|
||||
*/
|
||||
void sk_matrix_post_scale(sk_matrix_t*, float sx, float sy);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_paint_DEFINED
|
||||
#define sk_paint_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Create a new paint with default settings:
|
||||
antialias : false
|
||||
stroke : false
|
||||
stroke width : 0.0f (hairline)
|
||||
stroke miter : 4.0f
|
||||
stroke cap : BUTT_SK_STROKE_CAP
|
||||
stroke join : MITER_SK_STROKE_JOIN
|
||||
color : opaque black
|
||||
shader : NULL
|
||||
maskfilter : NULL
|
||||
xfermode_mode : SRCOVER_SK_XFERMODE_MODE
|
||||
*/
|
||||
SK_API sk_paint_t* sk_paint_new(void);
|
||||
/**
|
||||
Release the memory storing the sk_paint_t and unref() all
|
||||
associated objects.
|
||||
*/
|
||||
SK_API void sk_paint_delete(sk_paint_t*);
|
||||
|
||||
/**
|
||||
Return true iff the paint has antialiasing enabled.
|
||||
*/
|
||||
SK_API bool sk_paint_is_antialias(const sk_paint_t*);
|
||||
/**
|
||||
Set to true to enable antialiasing, false to disable it on this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
|
||||
|
||||
/**
|
||||
Return the paint's curent drawing color.
|
||||
*/
|
||||
SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's curent drawing color.
|
||||
*/
|
||||
SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
|
||||
|
||||
/* stroke settings */
|
||||
|
||||
/**
|
||||
Return true iff stroking is enabled rather than filling on this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API bool sk_paint_is_stroke(const sk_paint_t*);
|
||||
/**
|
||||
Set to true to enable stroking rather than filling with this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
|
||||
|
||||
/**
|
||||
Return the width for stroking. A value of 0 strokes in hairline mode.
|
||||
*/
|
||||
SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
|
||||
/**
|
||||
Set the width for stroking. A value of 0 strokes in hairline mode
|
||||
(always draw 1-pixel wide, regardless of the matrix).
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
|
||||
|
||||
/**
|
||||
Return the paint's stroke miter value. This is used to control the
|
||||
behavior of miter joins when the joins angle is sharp.
|
||||
*/
|
||||
SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke miter value. This is used to control the
|
||||
behavior of miter joins when the joins angle is sharp. This value
|
||||
must be >= 0.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
|
||||
|
||||
typedef enum {
|
||||
BUTT_SK_STROKE_CAP,
|
||||
ROUND_SK_STROKE_CAP,
|
||||
SQUARE_SK_STROKE_CAP
|
||||
} sk_stroke_cap_t;
|
||||
|
||||
/**
|
||||
Return the paint's stroke cap type, controlling how the start and
|
||||
end of stroked lines and paths are treated.
|
||||
*/
|
||||
SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke cap type, controlling how the start and
|
||||
end of stroked lines and paths are treated.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
|
||||
|
||||
typedef enum {
|
||||
MITER_SK_STROKE_JOIN,
|
||||
ROUND_SK_STROKE_JOIN,
|
||||
BEVEL_SK_STROKE_JOIN
|
||||
} sk_stroke_join_t;
|
||||
|
||||
/**
|
||||
Return the paint's stroke join type, specifies the treatment that
|
||||
is applied to corners in paths and rectangles
|
||||
*/
|
||||
SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke join type, specifies the treatment that
|
||||
is applied to corners in paths and rectangles
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
|
||||
|
||||
/**
|
||||
* Set the paint's shader to the specified parameter. This will automatically call unref() on
|
||||
* any previous value, and call ref() on the new value.
|
||||
*/
|
||||
SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
|
||||
|
||||
/**
|
||||
* Set the paint's maskfilter to the specified parameter. This will automatically call unref() on
|
||||
* any previous value, and call ref() on the new value.
|
||||
*/
|
||||
SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
|
||||
|
||||
/**
|
||||
* Set the paint's xfermode to the specified parameter.
|
||||
*/
|
||||
SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_path_DEFINED
|
||||
#define sk_path_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef enum {
|
||||
CW_SK_PATH_DIRECTION,
|
||||
CCW_SK_PATH_DIRECTION,
|
||||
} sk_path_direction_t;
|
||||
|
||||
/** Create a new, empty path. */
|
||||
SK_API sk_path_t* sk_path_new(void);
|
||||
/** Release the memory used by a sk_path_t. */
|
||||
SK_API void sk_path_delete(sk_path_t*);
|
||||
|
||||
/** Set the beginning of the next contour to the point (x,y). */
|
||||
SK_API void sk_path_move_to(sk_path_t*, float x, float y);
|
||||
/**
|
||||
Add a line from the last point to the specified point (x,y). If no
|
||||
sk_path_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_line_to(sk_path_t*, float x, float y);
|
||||
/**
|
||||
Add a quadratic bezier from the last point, approaching control
|
||||
point (x0,y0), and ending at (x1,y1). If no sk_path_move_to() call
|
||||
has been made for this contour, the first point is automatically
|
||||
set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1);
|
||||
/**
|
||||
Add a conic curve from the last point, approaching control point
|
||||
(x0,y01), and ending at (x1,y1) with weight w. If no
|
||||
sk_path_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_conic_to(sk_path_t*, float x0, float y0, float x1, float y1, float w);
|
||||
/**
|
||||
Add a cubic bezier from the last point, approaching control points
|
||||
(x0,y0) and (x1,y1), and ending at (x2,y2). If no
|
||||
sk_path_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_path_cubic_to(sk_path_t*,
|
||||
float x0, float y0,
|
||||
float x1, float y1,
|
||||
float x2, float y2);
|
||||
/**
|
||||
Close the current contour. If the current point is not equal to the
|
||||
first point of the contour, a line segment is automatically added.
|
||||
*/
|
||||
SK_API void sk_path_close(sk_path_t*);
|
||||
|
||||
/**
|
||||
Add a closed rectangle contour to the path.
|
||||
*/
|
||||
SK_API void sk_path_add_rect(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
|
||||
/**
|
||||
Add a closed oval contour to the path
|
||||
*/
|
||||
SK_API void sk_path_add_oval(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
|
||||
|
||||
/**
|
||||
* If the path is empty, return false and set the rect parameter to [0, 0, 0, 0].
|
||||
* else return true and set the rect parameter to the bounds of the control-points
|
||||
* of the path.
|
||||
*/
|
||||
SK_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_picture_DEFINED
|
||||
#define sk_picture_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Create a new sk_picture_recorder_t. Its resources should be
|
||||
released with a call to sk_picture_recorder_delete().
|
||||
*/
|
||||
SK_API sk_picture_recorder_t* sk_picture_recorder_new(void);
|
||||
/**
|
||||
Release the memory and other resources used by this
|
||||
sk_picture_recorder_t.
|
||||
*/
|
||||
SK_API void sk_picture_recorder_delete(sk_picture_recorder_t*);
|
||||
|
||||
/**
|
||||
Returns the canvas that records the drawing commands
|
||||
|
||||
@param sk_rect_t* the cull rect used when recording this
|
||||
picture. Any drawing the falls outside of this
|
||||
rect is undefined, and may be drawn or it may not.
|
||||
*/
|
||||
SK_API sk_canvas_t* sk_picture_recorder_begin_recording(sk_picture_recorder_t*, const sk_rect_t*);
|
||||
/**
|
||||
Signal that the caller is done recording. This invalidates the
|
||||
canvas returned by begin_recording. Ownership of the sk_picture_t
|
||||
is passed to the caller, who must call sk_picture_unref() when
|
||||
they are done using it. The returned picture is immutable.
|
||||
*/
|
||||
SK_API sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t*);
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_picture_t. Must be
|
||||
balanced by a call to sk_picture_unref().
|
||||
*/
|
||||
SK_API void sk_picture_ref(sk_picture_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_picture_t and any resouces it may be managing. New
|
||||
sk_picture_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_picture_unref(sk_picture_t*);
|
||||
|
||||
/**
|
||||
Returns a non-zero value unique among all pictures.
|
||||
*/
|
||||
SK_API uint32_t sk_picture_get_unique_id(sk_picture_t*);
|
||||
|
||||
/**
|
||||
Return the cull rect specified when this picture was recorded.
|
||||
*/
|
||||
SK_API sk_rect_t sk_picture_get_bounds(sk_picture_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_shader_DEFINED
|
||||
#define sk_shader_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
SK_API void sk_shader_ref(sk_shader_t*);
|
||||
SK_API void sk_shader_unref(sk_shader_t*);
|
||||
|
||||
typedef enum {
|
||||
CLAMP_SK_SHADER_TILEMODE,
|
||||
REPEAT_SK_SHADER_TILEMODE,
|
||||
MIRROR_SK_SHADER_TILEMODE,
|
||||
} sk_shader_tilemode_t;
|
||||
|
||||
/**
|
||||
Returns a shader that generates a linear gradient between the two
|
||||
specified points.
|
||||
|
||||
@param points The start and end points for the gradient.
|
||||
@param colors The array[count] of colors, to be distributed between
|
||||
the two points
|
||||
@param colorPos May be NULL. array[count] of SkScalars, or NULL, of
|
||||
the relative position of each corresponding color
|
||||
in the colors array. If this is NULL, the the
|
||||
colors are distributed evenly between the start
|
||||
and end point. If this is not null, the values
|
||||
must begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param colorCount Must be >=2. The number of colors (and pos if not
|
||||
NULL) entries.
|
||||
@param mode The tiling mode
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2],
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
|
||||
/**
|
||||
Returns a shader that generates a radial gradient given the center
|
||||
and radius.
|
||||
|
||||
@param center The center of the circle for this gradient
|
||||
@param radius Must be positive. The radius of the circle for this
|
||||
gradient
|
||||
@param colors The array[count] of colors, to be distributed
|
||||
between the center and edge of the circle
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the center and edge of
|
||||
the circle. If this is not null, the values must
|
||||
begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param count Must be >= 2. The number of colors (and pos if not
|
||||
NULL) entries
|
||||
@param tileMode The tiling mode
|
||||
@param localMatrix May be NULL
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center,
|
||||
float radius,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
/**
|
||||
Returns a shader that generates a sweep gradient given a center.
|
||||
|
||||
@param center The coordinates of the center of the sweep
|
||||
@param colors The array[count] of colors, to be distributed around
|
||||
the center.
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the center and edge of
|
||||
the circle. If this is not null, the values must
|
||||
begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param colorCount Must be >= 2. The number of colors (and pos if
|
||||
not NULL) entries
|
||||
@param localMatrix May be NULL
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
/**
|
||||
Returns a shader that generates a conical gradient given two circles, or
|
||||
returns NULL if the inputs are invalid. The gradient interprets the
|
||||
two circles according to the following HTML spec.
|
||||
http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
|
||||
|
||||
Returns a shader that generates a sweep gradient given a center.
|
||||
|
||||
@param start, startRadius Defines the first circle.
|
||||
@param end, endRadius Defines the first circle.
|
||||
@param colors The array[count] of colors, to be distributed between
|
||||
the two circles.
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the two circles. If
|
||||
this is not null, the values must begin with 0,
|
||||
end with 1.0, and intermediate values must be
|
||||
strictly increasing.
|
||||
@param colorCount Must be >= 2. The number of colors (and pos if
|
||||
not NULL) entries
|
||||
@param tileMode The tiling mode
|
||||
@param localMatrix May be NULL
|
||||
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_two_point_conical_gradient(
|
||||
const sk_point_t* start,
|
||||
float startRadius,
|
||||
const sk_point_t* end,
|
||||
float endRadius,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_surface_DEFINED
|
||||
#define sk_surface_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Return a new surface, with the memory for the pixels automatically
|
||||
allocated. If the requested surface cannot be created, or the
|
||||
request is not a supported configuration, NULL will be returned.
|
||||
|
||||
@param sk_imageinfo_t* Specify the width, height, color type, and
|
||||
alpha type for the surface.
|
||||
|
||||
@param sk_surfaceprops_t* If not NULL, specify additional non-default
|
||||
properties of the surface.
|
||||
*/
|
||||
SK_API sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*, const sk_surfaceprops_t*);
|
||||
|
||||
/**
|
||||
Create a new surface which will draw into the specified pixels
|
||||
with the specified rowbytes. If the requested surface cannot be
|
||||
created, or the request is not a supported configuration, NULL
|
||||
will be returned.
|
||||
|
||||
@param sk_imageinfo_t* Specify the width, height, color type, and
|
||||
alpha type for the surface.
|
||||
@param void* pixels Specify the location in memory where the
|
||||
destination pixels are. This memory must
|
||||
outlast this surface.
|
||||
@param size_t rowBytes Specify the difference, in bytes, between
|
||||
each adjacent row. Should be at least
|
||||
(width * sizeof(one pixel)).
|
||||
@param sk_surfaceprops_t* If not NULL, specify additional non-default
|
||||
properties of the surface.
|
||||
*/
|
||||
SK_API sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*,
|
||||
void* pixels, size_t rowBytes,
|
||||
const sk_surfaceprops_t* props);
|
||||
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_surface_t and any pixel memory it may be managing. New
|
||||
sk_surface_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_surface_unref(sk_surface_t*);
|
||||
|
||||
/**
|
||||
* Return the canvas associated with this surface. Note: the canvas is owned by the surface,
|
||||
* so the returned object is only valid while the owning surface is valid.
|
||||
*/
|
||||
SK_API sk_canvas_t* sk_surface_get_canvas(sk_surface_t*);
|
||||
|
||||
/**
|
||||
* Call sk_image_unref() when the returned image is no longer used.
|
||||
*/
|
||||
SK_API sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_types_DEFINED
|
||||
#define sk_types_DEFINED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define SK_C_PLUS_PLUS_BEGIN_GUARD extern "C" {
|
||||
#define SK_C_PLUS_PLUS_END_GUARD }
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#define SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
#define SK_C_PLUS_PLUS_END_GUARD
|
||||
#endif
|
||||
|
||||
#if !defined(SK_API)
|
||||
#if defined(SKIA_DLL)
|
||||
#if defined(_MSC_VER)
|
||||
#if SKIA_IMPLEMENTATION
|
||||
#define SK_API __declspec(dllexport)
|
||||
#else
|
||||
#define SK_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SK_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
#define SK_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef uint32_t sk_color_t;
|
||||
|
||||
/* This macro assumes all arguments are >=0 and <=255. */
|
||||
#define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define sk_color_get_a(c) (((c) >> 24) & 0xFF)
|
||||
#define sk_color_get_r(c) (((c) >> 16) & 0xFF)
|
||||
#define sk_color_get_g(c) (((c) >> 8) & 0xFF)
|
||||
#define sk_color_get_b(c) (((c) >> 0) & 0xFF)
|
||||
|
||||
typedef enum {
|
||||
INTERSECT_SK_CLIPTYPE,
|
||||
DIFFERENCE_SK_CLIPTYPE,
|
||||
} sk_cliptype_t;
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN_SK_PIXELGEOMETRY,
|
||||
RGB_H_SK_PIXELGEOMETRY,
|
||||
BGR_H_SK_PIXELGEOMETRY,
|
||||
RGB_V_SK_PIXELGEOMETRY,
|
||||
BGR_V_SK_PIXELGEOMETRY,
|
||||
} sk_pixelgeometry_t;
|
||||
|
||||
typedef struct {
|
||||
sk_pixelgeometry_t pixelGeometry;
|
||||
} sk_surfaceprops_t;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} sk_point_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} sk_irect_t;
|
||||
|
||||
typedef struct {
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
} sk_rect_t;
|
||||
|
||||
/**
|
||||
The sk_matrix_t struct holds a 3x3 perspective matrix for
|
||||
transforming coordinates:
|
||||
|
||||
(X,Y) = T[M]((x,y))
|
||||
X = (M[0] * x + M[1] * y + M[2]) / (M[6] * x + M[7] * y + M[8]);
|
||||
Y = (M[3] * x + M[4] * y + M[5]) / (M[6] * x + M[7] * y + M[8]);
|
||||
|
||||
Therefore, the identity matrix is
|
||||
|
||||
sk_matrix_t identity = {{1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1}};
|
||||
|
||||
A matrix that scales by sx and sy is:
|
||||
|
||||
sk_matrix_t scale = {{sx, 0, 0,
|
||||
0, sy, 0,
|
||||
0, 0, 1}};
|
||||
|
||||
A matrix that translates by tx and ty is:
|
||||
|
||||
sk_matrix_t translate = {{1, 0, tx,
|
||||
0, 1, ty,
|
||||
0, 0, 1}};
|
||||
|
||||
A matrix that rotates around the origin by A radians:
|
||||
|
||||
sk_matrix_t rotate = {{cos(A), -sin(A), 0,
|
||||
sin(A), cos(A), 0,
|
||||
0, 0, 1}};
|
||||
|
||||
Two matrixes can be concatinated by:
|
||||
|
||||
void concat_matrices(sk_matrix_t* dst,
|
||||
const sk_matrix_t* matrixU,
|
||||
const sk_matrix_t* matrixV) {
|
||||
const float* u = matrixU->mat;
|
||||
const float* v = matrixV->mat;
|
||||
sk_matrix_t result = {{
|
||||
u[0] * v[0] + u[1] * v[3] + u[2] * v[6],
|
||||
u[0] * v[1] + u[1] * v[4] + u[2] * v[7],
|
||||
u[0] * v[2] + u[1] * v[5] + u[2] * v[8],
|
||||
u[3] * v[0] + u[4] * v[3] + u[5] * v[6],
|
||||
u[3] * v[1] + u[4] * v[4] + u[5] * v[7],
|
||||
u[3] * v[2] + u[4] * v[5] + u[5] * v[8],
|
||||
u[6] * v[0] + u[7] * v[3] + u[8] * v[6],
|
||||
u[6] * v[1] + u[7] * v[4] + u[8] * v[7],
|
||||
u[6] * v[2] + u[7] * v[5] + u[8] * v[8]
|
||||
}};
|
||||
*dst = result;
|
||||
}
|
||||
*/
|
||||
typedef struct {
|
||||
float mat[9];
|
||||
} sk_matrix_t;
|
||||
|
||||
/**
|
||||
A sk_canvas_t encapsulates all of the state about drawing into a
|
||||
destination This includes a reference to the destination itself,
|
||||
and a stack of matrix/clip values.
|
||||
*/
|
||||
typedef struct sk_canvas_t sk_canvas_t;
|
||||
/**
|
||||
A sk_data_ holds an immutable data buffer.
|
||||
*/
|
||||
typedef struct sk_data_t sk_data_t;
|
||||
/**
|
||||
A sk_image_t is an abstraction for drawing a rectagle of pixels.
|
||||
The content of the image is always immutable, though the actual
|
||||
storage may change, if for example that image can be re-created via
|
||||
encoded data or other means.
|
||||
*/
|
||||
typedef struct sk_image_t sk_image_t;
|
||||
|
||||
/**
|
||||
* Describes the color components. See ICC Profiles.
|
||||
*/
|
||||
typedef struct sk_colorspace_t sk_colorspace_t;
|
||||
|
||||
/**
|
||||
* Describes an image buffer : width, height, pixel type, colorspace, etc.
|
||||
*/
|
||||
typedef struct sk_imageinfo_t sk_imageinfo_t;
|
||||
|
||||
/**
|
||||
A sk_maskfilter_t is an object that perform transformations on an
|
||||
alpha-channel mask before drawing it; it may be installed into a
|
||||
sk_paint_t. Each time a primitive is drawn, it is first
|
||||
scan-converted into a alpha mask, which os handed to the
|
||||
maskfilter, which may create a new mask is to render into the
|
||||
destination.
|
||||
*/
|
||||
typedef struct sk_maskfilter_t sk_maskfilter_t;
|
||||
/**
|
||||
A sk_paint_t holds the style and color information about how to
|
||||
draw geometries, text and bitmaps.
|
||||
*/
|
||||
typedef struct sk_paint_t sk_paint_t;
|
||||
/**
|
||||
A sk_path_t encapsulates compound (multiple contour) geometric
|
||||
paths consisting of straight line segments, quadratic curves, and
|
||||
cubic curves.
|
||||
*/
|
||||
typedef struct sk_path_t sk_path_t;
|
||||
/**
|
||||
A sk_picture_t holds recorded canvas drawing commands to be played
|
||||
back at a later time.
|
||||
*/
|
||||
typedef struct sk_picture_t sk_picture_t;
|
||||
/**
|
||||
A sk_picture_recorder_t holds a sk_canvas_t that records commands
|
||||
to create a sk_picture_t.
|
||||
*/
|
||||
typedef struct sk_picture_recorder_t sk_picture_recorder_t;
|
||||
/**
|
||||
A sk_shader_t specifies the source color(s) for what is being drawn. If a
|
||||
paint has no shader, then the paint's color is used. If the paint
|
||||
has a shader, then the shader's color(s) are use instead, but they
|
||||
are modulated by the paint's alpha.
|
||||
*/
|
||||
typedef struct sk_shader_t sk_shader_t;
|
||||
/**
|
||||
A sk_surface_t holds the destination for drawing to a canvas. For
|
||||
raster drawing, the destination is an array of pixels in memory.
|
||||
For GPU drawing, the destination is a texture or a framebuffer.
|
||||
*/
|
||||
typedef struct sk_surface_t sk_surface_t;
|
||||
|
||||
typedef enum {
|
||||
CLEAR_SK_XFERMODE_MODE,
|
||||
SRC_SK_XFERMODE_MODE,
|
||||
DST_SK_XFERMODE_MODE,
|
||||
SRCOVER_SK_XFERMODE_MODE,
|
||||
DSTOVER_SK_XFERMODE_MODE,
|
||||
SRCIN_SK_XFERMODE_MODE,
|
||||
DSTIN_SK_XFERMODE_MODE,
|
||||
SRCOUT_SK_XFERMODE_MODE,
|
||||
DSTOUT_SK_XFERMODE_MODE,
|
||||
SRCATOP_SK_XFERMODE_MODE,
|
||||
DSTATOP_SK_XFERMODE_MODE,
|
||||
XOR_SK_XFERMODE_MODE,
|
||||
PLUS_SK_XFERMODE_MODE,
|
||||
MODULATE_SK_XFERMODE_MODE,
|
||||
SCREEN_SK_XFERMODE_MODE,
|
||||
OVERLAY_SK_XFERMODE_MODE,
|
||||
DARKEN_SK_XFERMODE_MODE,
|
||||
LIGHTEN_SK_XFERMODE_MODE,
|
||||
COLORDODGE_SK_XFERMODE_MODE,
|
||||
COLORBURN_SK_XFERMODE_MODE,
|
||||
HARDLIGHT_SK_XFERMODE_MODE,
|
||||
SOFTLIGHT_SK_XFERMODE_MODE,
|
||||
DIFFERENCE_SK_XFERMODE_MODE,
|
||||
EXCLUSION_SK_XFERMODE_MODE,
|
||||
MULTIPLY_SK_XFERMODE_MODE,
|
||||
HUE_SK_XFERMODE_MODE,
|
||||
SATURATION_SK_XFERMODE_MODE,
|
||||
COLOR_SK_XFERMODE_MODE,
|
||||
LUMINOSITY_SK_XFERMODE_MODE,
|
||||
} sk_xfermode_mode_t;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
|
@ -9,28 +9,9 @@
|
|||
#define SkAndroidCodec_DEFINED
|
||||
|
||||
#include "include/codec/SkCodec.h"
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/SkEncodedInfo.h"
|
||||
#include "include/private/base/SkNoncopyable.h"
|
||||
#include "modules/skcms/skcms.h"
|
||||
|
||||
// TODO(kjlubick, bungeman) Replace these includes with forward declares
|
||||
#include "include/codec/SkEncodedImageFormat.h" // IWYU pragma: keep
|
||||
#include "include/core/SkAlphaType.h" // IWYU pragma: keep
|
||||
#include "include/core/SkColorType.h" // IWYU pragma: keep
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
class SkData;
|
||||
class SkPngChunkReader;
|
||||
class SkStream;
|
||||
struct SkGainmapInfo;
|
||||
struct SkIRect;
|
||||
|
||||
/**
|
||||
* Abstract interface defining image codec functionality that is necessary for
|
||||
|
@ -38,23 +19,31 @@ struct SkIRect;
|
|||
*/
|
||||
class SK_API SkAndroidCodec : SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* Now that SkAndroidCodec supports multiframe images, there are multiple
|
||||
* ways to handle compositing an oriented frame on top of an oriented frame
|
||||
* with different tradeoffs. SkAndroidCodec now ignores the orientation and
|
||||
* forces the client to handle it.
|
||||
*/
|
||||
enum class ExifOrientationBehavior {
|
||||
/**
|
||||
* Ignore any exif orientation markers in the data.
|
||||
*
|
||||
* getInfo's width and height will match the header of the image, and
|
||||
* no processing will be done to match the marker.
|
||||
*/
|
||||
kIgnore,
|
||||
|
||||
/**
|
||||
* Respect the exif orientation marker.
|
||||
*
|
||||
* getInfo's width and height will represent what they should be after
|
||||
* applying the orientation. For example, if the marker specifies a
|
||||
* rotation by 90 degrees, they will be swapped relative to the header.
|
||||
* getAndroidPixels will apply the orientation as well.
|
||||
*/
|
||||
kRespect,
|
||||
};
|
||||
|
||||
/**
|
||||
* Pass ownership of an SkCodec to a newly-created SkAndroidCodec.
|
||||
*/
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromCodec(std::unique_ptr<SkCodec>);
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromCodec(std::unique_ptr<SkCodec>,
|
||||
ExifOrientationBehavior = ExifOrientationBehavior::kIgnore);
|
||||
|
||||
/**
|
||||
* If this stream represents an encoded image that we know how to decode,
|
||||
|
@ -65,6 +54,8 @@ public:
|
|||
*
|
||||
* If NULL is returned, the stream is deleted immediately. Otherwise, the
|
||||
* SkCodec takes ownership of it, and will delete it when done with it.
|
||||
*
|
||||
* ExifOrientationBehavior is set to kIgnore.
|
||||
*/
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromStream(std::unique_ptr<SkStream>,
|
||||
SkPngChunkReader* = nullptr);
|
||||
|
@ -75,22 +66,15 @@ public:
|
|||
*
|
||||
* The SkPngChunkReader handles unknown chunks in PNGs.
|
||||
* See SkCodec.h for more details.
|
||||
*
|
||||
* ExifOrientationBehavior is set to kIgnore.
|
||||
*/
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
|
||||
|
||||
virtual ~SkAndroidCodec();
|
||||
|
||||
// TODO: fInfo is now just a cache of SkCodec's SkImageInfo. No need to
|
||||
// cache and return a reference here, once Android call-sites are updated.
|
||||
const SkImageInfo& getInfo() const { return fInfo; }
|
||||
|
||||
/**
|
||||
* Return the ICC profile of the encoded data.
|
||||
*/
|
||||
const skcms_ICCProfile* getICCProfile() const {
|
||||
return fCodec->getEncodedInfo().profile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format of the encoded data.
|
||||
*/
|
||||
|
@ -121,8 +105,10 @@ public:
|
|||
/**
|
||||
* @param outputColorType Color type that the client will decode to.
|
||||
* @param prefColorSpace Preferred color space to decode to.
|
||||
* This may not return |prefColorSpace| for
|
||||
* specific color types.
|
||||
* This may not return |prefColorSpace| for a couple reasons.
|
||||
* (1) Android Principles: 565 must be sRGB, F16 must be
|
||||
* linear sRGB, transfer function must be parametric.
|
||||
* (2) Codec Limitations: F16 requires a linear color space.
|
||||
*
|
||||
* Returns the appropriate color space to decode to.
|
||||
*/
|
||||
|
@ -202,12 +188,32 @@ public:
|
|||
// called SkAndroidCodec. On the other hand, it's may be a bit confusing to call
|
||||
// these Options when SkCodec has a slightly different set of Options. Maybe these
|
||||
// should be DecodeOptions or SamplingOptions?
|
||||
struct AndroidOptions : public SkCodec::Options {
|
||||
struct AndroidOptions {
|
||||
AndroidOptions()
|
||||
: SkCodec::Options()
|
||||
: fZeroInitialized(SkCodec::kNo_ZeroInitialized)
|
||||
, fSubset(nullptr)
|
||||
, fSampleSize(1)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Indicates is destination pixel memory is zero initialized.
|
||||
*
|
||||
* The default is SkCodec::kNo_ZeroInitialized.
|
||||
*/
|
||||
SkCodec::ZeroInitialized fZeroInitialized;
|
||||
|
||||
/**
|
||||
* If not NULL, represents a subset of the original image to decode.
|
||||
*
|
||||
* Must be within the bounds returned by getInfo().
|
||||
*
|
||||
* If the EncodedFormat is SkEncodedImageFormat::kWEBP, the top and left
|
||||
* values must be even.
|
||||
*
|
||||
* The default is NULL, meaning a decode of the entire image.
|
||||
*/
|
||||
SkIRect* fSubset;
|
||||
|
||||
/**
|
||||
* The client may provide an integer downscale factor for the decode.
|
||||
* The codec may implement this downscaling by sampling or another
|
||||
|
@ -263,25 +269,8 @@ public:
|
|||
|
||||
SkCodec* codec() const { return fCodec.get(); }
|
||||
|
||||
/**
|
||||
* Retrieve the gainmap for an image.
|
||||
*
|
||||
* @param outInfo On success, this is populated with the parameters for
|
||||
* rendering this gainmap. This parameter must be non-nullptr.
|
||||
*
|
||||
* @param outGainmapImageStream On success, this is populated with a stream from which the
|
||||
* gainmap image may be decoded. This parameter is optional, and
|
||||
* may be set to nullptr.
|
||||
*
|
||||
* @return If this has a gainmap image and that gainmap image was
|
||||
* successfully extracted then return true. Otherwise return
|
||||
* false.
|
||||
*/
|
||||
bool getAndroidGainmap(SkGainmapInfo* outInfo,
|
||||
std::unique_ptr<SkStream>* outGainmapImageStream);
|
||||
|
||||
protected:
|
||||
SkAndroidCodec(SkCodec*);
|
||||
SkAndroidCodec(SkCodec*, ExifOrientationBehavior = ExifOrientationBehavior::kIgnore);
|
||||
|
||||
virtual SkISize onGetSampledDimensions(int sampleSize) const = 0;
|
||||
|
||||
|
@ -292,6 +281,7 @@ protected:
|
|||
|
||||
private:
|
||||
const SkImageInfo fInfo;
|
||||
const ExifOrientationBehavior fOrientationBehavior;
|
||||
std::unique_ptr<SkCodec> fCodec;
|
||||
};
|
||||
#endif // SkAndroidCodec_DEFINED
|
||||
|
|
|
@ -8,43 +8,32 @@
|
|||
#ifndef SkCodec_DEFINED
|
||||
#define SkCodec_DEFINED
|
||||
|
||||
#include "include/codec/SkCodecAnimation.h"
|
||||
#include "include/codec/SkEncodedOrigin.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkYUVAPixmaps.h"
|
||||
#include "include/core/SkYUVASizeInfo.h"
|
||||
#include "include/private/SkEncodedInfo.h"
|
||||
#include "include/private/base/SkNoncopyable.h"
|
||||
#include "modules/skcms/skcms.h"
|
||||
#include "include/private/SkNoncopyable.h"
|
||||
#include "include/private/SkTemplates.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
class SkColorSpace;
|
||||
class SkData;
|
||||
class SkFrameHolder;
|
||||
class SkImage;
|
||||
class SkPngChunkReader;
|
||||
class SkSampler;
|
||||
class SkStream;
|
||||
struct SkGainmapInfo;
|
||||
enum SkAlphaType : int;
|
||||
enum class SkEncodedImageFormat;
|
||||
|
||||
namespace SkCodecAnimation {
|
||||
enum class Blend;
|
||||
enum class DisposalMethod;
|
||||
}
|
||||
|
||||
|
||||
namespace DM {
|
||||
class CodecSrc;
|
||||
} // namespace DM
|
||||
class ColorCodecSrc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstraction layer directly on top of an image codec.
|
||||
|
@ -201,9 +190,6 @@ public:
|
|||
|
||||
/**
|
||||
* Return a reasonable SkImageInfo to decode into.
|
||||
*
|
||||
* If the image has an ICC profile that does not map to an SkColorSpace,
|
||||
* the returned SkImageInfo will use SRGB.
|
||||
*/
|
||||
SkImageInfo getInfo() const { return fEncodedInfo.makeImageInfo(); }
|
||||
|
||||
|
@ -212,13 +198,6 @@ public:
|
|||
return SkIRect::MakeWH(fEncodedInfo.width(), fEncodedInfo.height());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ICC profile of the encoded data.
|
||||
*/
|
||||
const skcms_ICCProfile* getICCProfile() const {
|
||||
return this->getEncodedInfo().profile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image orientation stored in the EXIF data.
|
||||
* If there is no EXIF data, or if we cannot read the EXIF data, returns kTopLeft.
|
||||
|
@ -365,13 +344,9 @@ public:
|
|||
*
|
||||
* If the info contains a non-null SkColorSpace, the codec
|
||||
* will perform the appropriate color space transformation.
|
||||
*
|
||||
* If the caller passes in the SkColorSpace that maps to the
|
||||
* ICC profile reported by getICCProfile(), the color space
|
||||
* transformation is a no-op.
|
||||
*
|
||||
* If the caller passes a null SkColorSpace, no color space
|
||||
* transformation will be done.
|
||||
* If the caller passes in the same color space that was
|
||||
* reported by the codec, the color space transformation is
|
||||
* a no-op.
|
||||
*
|
||||
* If a scanline decode is in progress, scanline mode will end, requiring the client to call
|
||||
* startScanlineDecode() in order to return to decoding scanlines.
|
||||
|
@ -392,35 +367,56 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Return an image containing the pixels.
|
||||
*/
|
||||
std::tuple<sk_sp<SkImage>, SkCodec::Result> getImage(const SkImageInfo& info,
|
||||
const Options* opts = nullptr);
|
||||
std::tuple<sk_sp<SkImage>, SkCodec::Result> getImage();
|
||||
|
||||
/**
|
||||
* If decoding to YUV is supported, this returns true. Otherwise, this
|
||||
* returns false and the caller will ignore output parameter yuvaPixmapInfo.
|
||||
* If decoding to YUV is supported, this returns true. Otherwise, this
|
||||
* returns false and does not modify any of the parameters.
|
||||
*
|
||||
* @param supportedDataTypes Indicates the data type/planar config combinations that are
|
||||
* supported by the caller. If the generator supports decoding to
|
||||
* YUV(A), but not as a type in supportedDataTypes, this method
|
||||
* returns false.
|
||||
* @param yuvaPixmapInfo Output parameter that specifies the planar configuration, subsampling,
|
||||
* orientation, chroma siting, plane color types, and row bytes.
|
||||
* @param sizeInfo Output parameter indicating the sizes and required
|
||||
* allocation widths of the Y, U, V, and A planes. Given current codec
|
||||
* limitations the size of the A plane will always be 0 and the Y, U, V
|
||||
* channels will always be planar.
|
||||
* @param colorSpace Output parameter. If non-NULL this is set to kJPEG,
|
||||
* otherwise this is ignored.
|
||||
*/
|
||||
bool queryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes& supportedDataTypes,
|
||||
SkYUVAPixmapInfo* yuvaPixmapInfo) const;
|
||||
bool queryYUV8(SkYUVASizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
|
||||
if (nullptr == sizeInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = this->onQueryYUV8(sizeInfo, colorSpace);
|
||||
if (result) {
|
||||
for (int i = 0; i <= 2; ++i) {
|
||||
SkASSERT(sizeInfo->fSizes[i].fWidth > 0 && sizeInfo->fSizes[i].fHeight > 0 &&
|
||||
sizeInfo->fWidthBytes[i] > 0);
|
||||
}
|
||||
SkASSERT(!sizeInfo->fSizes[3].fWidth &&
|
||||
!sizeInfo->fSizes[3].fHeight &&
|
||||
!sizeInfo->fWidthBytes[3]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns kSuccess, or another value explaining the type of failure.
|
||||
* This always attempts to perform a full decode. To get the planar
|
||||
* configuration without decoding use queryYUVAInfo().
|
||||
* This always attempts to perform a full decode. If the client only
|
||||
* wants size, it should call queryYUV8().
|
||||
*
|
||||
* @param yuvaPixmaps Contains preallocated pixmaps configured according to a successful call
|
||||
* to queryYUVAInfo().
|
||||
* @param sizeInfo Needs to exactly match the values returned by the
|
||||
* query, except the WidthBytes may be larger than the
|
||||
* recommendation (but not smaller).
|
||||
* @param planes Memory for each of the Y, U, and V planes.
|
||||
*/
|
||||
Result getYUVAPlanes(const SkYUVAPixmaps& yuvaPixmaps);
|
||||
Result getYUV8Planes(const SkYUVASizeInfo& sizeInfo, void* planes[SkYUVASizeInfo::kMaxCount]) {
|
||||
if (!planes || !planes[0] || !planes[1] || !planes[2]) {
|
||||
return kInvalidInput;
|
||||
}
|
||||
SkASSERT(!planes[3]); // TODO: is this a fair assumption?
|
||||
|
||||
if (!this->rewindIfNeeded()) {
|
||||
return kCouldNotRewind;
|
||||
}
|
||||
|
||||
return this->onGetYUV8Planes(sizeInfo, planes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for an incremental decode with the specified options.
|
||||
|
@ -661,53 +657,18 @@ public:
|
|||
*/
|
||||
SkAlphaType fAlphaType;
|
||||
|
||||
/**
|
||||
* Whether the updated rectangle contains alpha.
|
||||
*
|
||||
* This is conservative; it will still be set to true if e.g. a color
|
||||
* index-based frame has a color with alpha but does not use it. In
|
||||
* addition, it may be set to true, even if the final frame, after
|
||||
* blending, is opaque.
|
||||
*/
|
||||
bool fHasAlphaWithinBounds;
|
||||
|
||||
/**
|
||||
* How this frame should be modified before decoding the next one.
|
||||
*/
|
||||
SkCodecAnimation::DisposalMethod fDisposalMethod;
|
||||
|
||||
/**
|
||||
* How this frame should blend with the prior frame.
|
||||
*/
|
||||
SkCodecAnimation::Blend fBlend;
|
||||
|
||||
/**
|
||||
* The rectangle updated by this frame.
|
||||
*
|
||||
* It may be empty, if the frame does not change the image. It will
|
||||
* always be contained by SkCodec::dimensions().
|
||||
*/
|
||||
SkIRect fFrameRect;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return info about a single frame.
|
||||
*
|
||||
* Does not read through the stream, so it should be called after
|
||||
* getFrameCount() to parse any frames that have not already been parsed.
|
||||
*
|
||||
* Only supported by animated (multi-frame) codecs. Note that this is a
|
||||
* property of the codec (the SkCodec subclass), not the image.
|
||||
*
|
||||
* To elaborate, some codecs support animation (e.g. GIF). Others do not
|
||||
* (e.g. BMP). Animated codecs can still represent single frame images.
|
||||
* Calling getFrameInfo(0, etc) will return true for a single frame GIF
|
||||
* even if the overall image is not animated (in that the pixels on screen
|
||||
* do not change over time). When incrementally decoding a GIF image, we
|
||||
* might only know that there's a single frame *so far*.
|
||||
*
|
||||
* For non-animated SkCodec subclasses, it's sufficient but not necessary
|
||||
* for this method to always return false.
|
||||
* Only supported by multi-frame images. Does not read through the stream,
|
||||
* so it should be called after getFrameCount() to parse any frames that
|
||||
* have not already been parsed.
|
||||
*/
|
||||
bool getFrameInfo(int index, FrameInfo* info) const {
|
||||
if (index < 0) {
|
||||
|
@ -724,8 +685,7 @@ public:
|
|||
*
|
||||
* As such, future decoding calls may require a rewind.
|
||||
*
|
||||
* This may return an empty vector for non-animated codecs. See the
|
||||
* getFrameInfo(int, FrameInfo*) comment.
|
||||
* For still (non-animated) image codecs, this will return an empty vector.
|
||||
*/
|
||||
std::vector<FrameInfo> getFrameInfo();
|
||||
|
||||
|
@ -767,14 +727,6 @@ protected:
|
|||
std::unique_ptr<SkStream>,
|
||||
SkEncodedOrigin = kTopLeft_SkEncodedOrigin);
|
||||
|
||||
void setSrcXformFormat(XformFormat pixelFormat);
|
||||
|
||||
XformFormat getSrcXformFormat() const {
|
||||
return fSrcXformFormat;
|
||||
}
|
||||
|
||||
virtual bool onGetGainmapInfo(SkGainmapInfo*, std::unique_ptr<SkStream>*) { return false; }
|
||||
|
||||
virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
|
||||
// By default, scaling is not supported.
|
||||
return this->dimensions();
|
||||
|
@ -801,10 +753,14 @@ protected:
|
|||
void* pixels, size_t rowBytes, const Options&,
|
||||
int* rowsDecoded) = 0;
|
||||
|
||||
virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes&,
|
||||
SkYUVAPixmapInfo*) const { return false; }
|
||||
virtual bool onQueryYUV8(SkYUVASizeInfo*, SkYUVColorSpace*) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual Result onGetYUVAPlanes(const SkYUVAPixmaps&) { return kUnimplemented; }
|
||||
virtual Result onGetYUV8Planes(const SkYUVASizeInfo&,
|
||||
void*[SkYUVASizeInfo::kMaxCount] /*planes*/) {
|
||||
return kUnimplemented;
|
||||
}
|
||||
|
||||
virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
|
||||
// By default, subsets are not supported.
|
||||
|
@ -893,10 +849,10 @@ protected:
|
|||
|
||||
private:
|
||||
const SkEncodedInfo fEncodedInfo;
|
||||
XformFormat fSrcXformFormat;
|
||||
const XformFormat fSrcXformFormat;
|
||||
std::unique_ptr<SkStream> fStream;
|
||||
bool fNeedsRewind = false;
|
||||
const SkEncodedOrigin fOrigin;
|
||||
bool fNeedsRewind;
|
||||
const SkEncodedOrigin fOrigin;
|
||||
|
||||
SkImageInfo fDstInfo;
|
||||
Options fOptions;
|
||||
|
@ -912,13 +868,9 @@ private:
|
|||
skcms_AlphaFormat fDstXformAlphaFormat;
|
||||
|
||||
// Only meaningful during scanline decodes.
|
||||
int fCurrScanline = -1;
|
||||
int fCurrScanline;
|
||||
|
||||
bool fStartedIncrementalDecode = false;
|
||||
|
||||
// Allows SkAndroidCodec to call handleFrameIndex (potentially decoding a prior frame and
|
||||
// clearing to transparent) without SkCodec itself calling it, too.
|
||||
bool fUsingCallbackForHandleFrameIndex = false;
|
||||
bool fStartedIncrementalDecode;
|
||||
|
||||
bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
|
||||
|
||||
|
@ -942,23 +894,10 @@ private:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Callback for decoding a prior frame. The `Options::fFrameIndex` is ignored,
|
||||
// being replaced by frameIndex. This allows opts to actually be a subclass of
|
||||
// SkCodec::Options which SkCodec itself does not know how to copy or modify,
|
||||
// but just passes through to the caller (where it can be reinterpret_cast'd).
|
||||
using GetPixelsCallback = std::function<Result(const SkImageInfo&, void* pixels,
|
||||
size_t rowBytes, const Options& opts,
|
||||
int frameIndex)>;
|
||||
|
||||
/**
|
||||
* Check for a valid Options.fFrameIndex, and decode prior frames if necessary.
|
||||
*
|
||||
* If GetPixelsCallback is not null, it will be used to decode a prior frame instead
|
||||
* of using this SkCodec directly. It may also be used recursively, if that in turn
|
||||
* depends on a prior frame. This is used by SkAndroidCodec.
|
||||
*/
|
||||
Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&,
|
||||
GetPixelsCallback = nullptr);
|
||||
Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&);
|
||||
|
||||
// Methods for scanline decoding.
|
||||
virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
|
||||
|
|
|
@ -39,23 +39,5 @@ namespace SkCodecAnimation {
|
|||
*/
|
||||
kRestorePrevious = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* How to blend the current frame.
|
||||
*/
|
||||
enum class Blend {
|
||||
/**
|
||||
* Blend with the prior frame as if using SkBlendMode::kSrcOver.
|
||||
*/
|
||||
kSrcOver,
|
||||
|
||||
/**
|
||||
* Blend with the prior frame as if using SkBlendMode::kSrc.
|
||||
*
|
||||
* This frame's pixels replace the destination pixels.
|
||||
*/
|
||||
kSrc,
|
||||
};
|
||||
|
||||
} // namespace SkCodecAnimation
|
||||
}
|
||||
#endif // SkCodecAnimation_DEFINED
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkEncodedImageFormat_DEFINED
|
||||
#define SkEncodedImageFormat_DEFINED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Enum describing format of encoded data.
|
||||
*/
|
||||
enum class SkEncodedImageFormat {
|
||||
#ifdef SK_BUILD_FOR_GOOGLE3
|
||||
kUnknown,
|
||||
#endif
|
||||
kBMP,
|
||||
kGIF,
|
||||
kICO,
|
||||
kJPEG,
|
||||
kPNG,
|
||||
kWBMP,
|
||||
kWEBP,
|
||||
kPKM,
|
||||
kKTX,
|
||||
kASTC,
|
||||
kDNG,
|
||||
kHEIF,
|
||||
kAVIF,
|
||||
kJPEGXL,
|
||||
};
|
||||
|
||||
#endif // SkEncodedImageFormat_DEFINED
|
|
@ -26,8 +26,8 @@ enum SkEncodedOrigin {
|
|||
|
||||
/**
|
||||
* Given an encoded origin and the width and height of the source data, returns a matrix
|
||||
* that transforms the source rectangle with upper left corner at [0, 0] and origin to a correctly
|
||||
* oriented destination rectangle of [0, 0, w, h].
|
||||
* that transforms the source rectangle [0, 0, w, h] to a correctly oriented destination
|
||||
* rectangle, with the upper left corner still at [0, 0].
|
||||
*/
|
||||
static inline SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h) {
|
||||
switch (origin) {
|
||||
|
@ -36,19 +36,12 @@ static inline SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, in
|
|||
case kBottomRight_SkEncodedOrigin: return SkMatrix::MakeAll(-1, 0, w, 0, -1, h, 0, 0, 1);
|
||||
case kBottomLeft_SkEncodedOrigin: return SkMatrix::MakeAll( 1, 0, 0, 0, -1, h, 0, 0, 1);
|
||||
case kLeftTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, 1, 0, 0, 0, 0, 1);
|
||||
case kRightTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, w, 1, 0, 0, 0, 0, 1);
|
||||
case kRightBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, w, -1, 0, h, 0, 0, 1);
|
||||
case kLeftBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, -1, 0, h, 0, 0, 1);
|
||||
case kRightTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, h, 1, 0, 0, 0, 0, 1);
|
||||
case kRightBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, h, -1, 0, w, 0, 0, 1);
|
||||
case kLeftBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, -1, 0, w, 0, 0, 1);
|
||||
}
|
||||
SK_ABORT("Unexpected origin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the encoded origin includes a 90 degree rotation, in which case the width
|
||||
* and height of the source data are swapped relative to a correctly oriented destination.
|
||||
*/
|
||||
static inline bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin) {
|
||||
return origin >= kLeftTop_SkEncodedOrigin;
|
||||
}
|
||||
|
||||
#endif // SkEncodedOrigin_DEFINED
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
|
@ -5,18 +6,29 @@
|
|||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkUserConfig_DEFINED
|
||||
#define SkUserConfig_DEFINED
|
||||
|
||||
/* SkTypes.h, the root of the public header files, includes this file
|
||||
SkUserConfig.h after first initializing certain Skia defines, letting
|
||||
this file change or augment those flags.
|
||||
/* SkTypes.h, the root of the public header files, includes SkPreConfig.h,
|
||||
then SkUserConfig.h, then SkPostConfig.h.
|
||||
|
||||
SkPreConfig.h runs first, and it is responsible for initializing certain
|
||||
skia defines.
|
||||
|
||||
SkPostConfig.h runs last, and its job is to just check that the final
|
||||
defines are consistent (i.e. that we don't have mutually conflicting
|
||||
defines).
|
||||
|
||||
SkUserConfig.h (this file) runs in the middle. It gets to change or augment
|
||||
the list of flags initially set in preconfig, and then postconfig checks
|
||||
that everything still makes sense.
|
||||
|
||||
Below are optional defines that add, subtract, or change default behavior
|
||||
in Skia. Your port can locally edit this file to enable/disable flags as
|
||||
you choose, or these can be declared on your command line (i.e. -Dfoo).
|
||||
you choose, or these can be delared on your command line (i.e. -Dfoo).
|
||||
|
||||
By default, this #include file will always default to having all the flags
|
||||
By default, this include file will always default to having all of the flags
|
||||
commented out, so including it will have no effect.
|
||||
*/
|
||||
|
||||
|
@ -27,95 +39,60 @@
|
|||
each 32bit pixel is in premultiplied form). This code can be very useful
|
||||
during development, but will slow things down in a shipping product.
|
||||
|
||||
By default, these mutually exclusive flags are defined in SkTypes.h,
|
||||
By default, these mutually exclusive flags are defined in SkPreConfig.h,
|
||||
based on the presence or absence of NDEBUG, but that decision can be changed
|
||||
here.
|
||||
*/
|
||||
*/
|
||||
//#define SK_DEBUG
|
||||
//#define SK_RELEASE
|
||||
|
||||
/* To write debug messages to a console, skia will call SkDebugf(...) following
|
||||
printf conventions (e.g. const char* format, ...). If you want to redirect
|
||||
this to something other than printf, define yours here
|
||||
*/
|
||||
*/
|
||||
//#define SkDebugf(...) MyFunction(__VA_ARGS__)
|
||||
|
||||
/* Skia has both debug and release asserts. When an assert fails SK_ABORT will
|
||||
be used to report an abort message. SK_ABORT is expected not to return. Skia
|
||||
provides a default implementation which will print the message with SkDebugf
|
||||
and then call sk_abort_no_print.
|
||||
*/
|
||||
//#define SK_ABORT(message, ...)
|
||||
|
||||
/* To specify a different default font strike cache memory limit, define this. If this is
|
||||
undefined, skia will use a built-in value.
|
||||
*/
|
||||
/*
|
||||
* To specify a different default font cache limit, define this. If this is
|
||||
* undefined, skia will use a built-in value.
|
||||
*/
|
||||
//#define SK_DEFAULT_FONT_CACHE_LIMIT (1024 * 1024)
|
||||
|
||||
/* To specify a different default font strike cache count limit, define this. If this is
|
||||
undefined, skia will use a built-in value.
|
||||
*/
|
||||
// #define SK_DEFAULT_FONT_CACHE_COUNT_LIMIT 2048
|
||||
|
||||
/* To specify the default size of the image cache, undefine this and set it to
|
||||
the desired value (in bytes). SkGraphics.h as a runtime API to set this
|
||||
value as well. If this is undefined, a built-in value will be used.
|
||||
*/
|
||||
/*
|
||||
* To specify the default size of the image cache, undefine this and set it to
|
||||
* the desired value (in bytes). SkGraphics.h as a runtime API to set this
|
||||
* value as well. If this is undefined, a built-in value will be used.
|
||||
*/
|
||||
//#define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024)
|
||||
|
||||
/* Define this to set the upper limit for text to support LCD. Values that
|
||||
are very large increase the cost in the font cache and draw slower, without
|
||||
improving readability. If this is undefined, Skia will use its default
|
||||
value (e.g. 48)
|
||||
*/
|
||||
*/
|
||||
//#define SK_MAX_SIZE_FOR_LCDTEXT 48
|
||||
|
||||
/* Change the kN32_SkColorType ordering to BGRA to work in X windows.
|
||||
*/
|
||||
*/
|
||||
//#define SK_R32_SHIFT 16
|
||||
|
||||
/* Determines whether to build code that supports the Ganesh GPU backend. Some classes
|
||||
|
||||
/* Determines whether to build code that supports the GPU backend. Some classes
|
||||
that are not GPU-specific, such as SkShader subclasses, have optional code
|
||||
that is used allows them to interact with this GPU backend. If you'd like to
|
||||
include this code, include -DSK_GANESH in your cflags or uncomment below.
|
||||
Defaults to not set (No Ganesh GPU backend).
|
||||
This define affects the ABI of Skia, so make sure it matches the client which uses
|
||||
the compiled version of Skia.
|
||||
*/
|
||||
//#define SK_GANESH
|
||||
that is used allows them to interact with the GPU backend. If you'd like to
|
||||
omit this code set SK_SUPPORT_GPU to 0. This also allows you to omit the gpu
|
||||
directories from your include search path when you're not building the GPU
|
||||
backend. Defaults to 1 (build the GPU code).
|
||||
*/
|
||||
//#define SK_SUPPORT_GPU 1
|
||||
|
||||
/* Skia makes use of histogram logging macros to trace the frequency of
|
||||
events. By default, Skia provides no-op versions of these macros.
|
||||
Skia consumers can provide their own definitions of these macros to
|
||||
integrate with their histogram collection backend.
|
||||
*/
|
||||
//#define SK_HISTOGRAM_BOOLEAN(name, sample)
|
||||
//#define SK_HISTOGRAM_ENUMERATION(name, sample, enum_size)
|
||||
//#define SK_HISTOGRAM_EXACT_LINEAR(name, sample, value_max)
|
||||
//#define SK_HISTOGRAM_MEMORY_KB(name, sample)
|
||||
|
||||
/* Skia tries to make use of some non-standard C++ language extensions.
|
||||
By default, Skia provides msvc and clang/gcc versions of these macros.
|
||||
Skia consumers can provide their own definitions of these macros to
|
||||
integrate with their own compilers and build system.
|
||||
*/
|
||||
//#define SK_UNUSED [[maybe_unused]]
|
||||
//#define SK_WARN_UNUSED_RESULT [[nodiscard]]
|
||||
//#define SK_ALWAYS_INLINE inline __attribute__((always_inline))
|
||||
//#define SK_NEVER_INLINE __attribute__((noinline))
|
||||
//#define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
|
||||
//#define SK_NO_SANITIZE(A) __attribute__((no_sanitize(A)))
|
||||
//#define SK_TRIVIAL_ABI [[clang::trivial_abi]]
|
||||
|
||||
/*
|
||||
* If compiling Skia as a DLL, public APIs should be exported. Skia will set
|
||||
* SK_API to something sensible for Clang and MSVC, but if clients need to
|
||||
* customize it for their build system or compiler, they may.
|
||||
* If a client needs to use SK_API (e.g. overriding SK_ABORT), then they
|
||||
* *must* define their own, the default will not be defined prior to loading
|
||||
* this file.
|
||||
* events. By default, Skia provides no-op versions of these macros.
|
||||
* Skia consumers can provide their own definitions of these macros to
|
||||
* integrate with their histogram collection backend.
|
||||
*/
|
||||
//#define SK_API __declspec(dllexport)
|
||||
//#define SK_HISTOGRAM_BOOLEAN(name, value)
|
||||
//#define SK_HISTOGRAM_ENUMERATION(name, value, boundary_value)
|
||||
|
||||
#define MOZ_SKIA
|
||||
|
||||
|
@ -129,17 +106,11 @@
|
|||
|
||||
#define SK_RASTERIZE_EVEN_ROUNDING
|
||||
|
||||
#define I_ACKNOWLEDGE_SKIA_DOES_NOT_SUPPORT_BIG_ENDIAN
|
||||
|
||||
#define SK_SUPPORT_GPU 0
|
||||
|
||||
#define SK_DISABLE_SLOW_DEBUG_VALIDATION 1
|
||||
|
||||
#define SK_DISABLE_TYPEFACE_CACHE
|
||||
#define SK_SUPPORT_DEPRECATED_CLIPOPS
|
||||
|
||||
#define SK_USE_FREETYPE_EMBOLDEN
|
||||
|
||||
#define SK_IGNORE_MAC_BLENDING_MATCH_FIX
|
||||
#define SK_SUPPORT_GPU 0
|
||||
|
||||
#ifndef MOZ_IMPLICIT
|
||||
# ifdef MOZ_CLANG_PLUGIN
|
||||
|
@ -149,4 +120,12 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#define SK_DISABLE_SLOW_DEBUG_VALIDATION 1
|
||||
|
||||
#define SK_IGNORE_MAC_BLENDING_MATCH_FIX
|
||||
|
||||
#define I_ACKNOWLEDGE_SKIA_DOES_NOT_SUPPORT_BIG_ENDIAN
|
||||
|
||||
#define SK_DISABLE_TYPEFACE_CACHE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAlphaType_DEFINED
|
||||
#define SkAlphaType_DEFINED
|
||||
|
||||
/** \enum SkAlphaType
|
||||
Describes how to interpret the alpha component of a pixel. A pixel may
|
||||
be opaque, or alpha, describing multiple levels of transparency.
|
||||
|
||||
In simple blending, alpha weights the draw color and the destination
|
||||
color to create a new color. If alpha describes a weight from zero to one:
|
||||
|
||||
new color = draw color * alpha + destination color * (1 - alpha)
|
||||
|
||||
In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
|
||||
|
||||
RGB may have alpha included in each component value; the stored
|
||||
value is the original RGB multiplied by alpha. Premultiplied color
|
||||
components improve performance.
|
||||
*/
|
||||
enum SkAlphaType : int {
|
||||
kUnknown_SkAlphaType, //!< uninitialized
|
||||
kOpaque_SkAlphaType, //!< pixel is opaque
|
||||
kPremul_SkAlphaType, //!< pixel components are premultiplied by alpha
|
||||
kUnpremul_SkAlphaType, //!< pixel components are independent of alpha
|
||||
kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, //!< last valid value
|
||||
};
|
||||
|
||||
/** Returns true if SkAlphaType equals kOpaque_SkAlphaType.
|
||||
|
||||
kOpaque_SkAlphaType is a hint that the SkColorType is opaque, or that all
|
||||
alpha values are set to their 1.0 equivalent. If SkAlphaType is
|
||||
kOpaque_SkAlphaType, and SkColorType is not opaque, then the result of
|
||||
drawing any pixel with a alpha value less than 1.0 is undefined.
|
||||
*/
|
||||
static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
|
||||
return kOpaque_SkAlphaType == at;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -19,8 +19,6 @@ class SkCanvas;
|
|||
* Annotate the canvas by associating the specified URL with the
|
||||
* specified rectangle (in local coordinates, just like drawRect).
|
||||
*
|
||||
* The URL is expected to be escaped and be valid 7-bit ASCII.
|
||||
*
|
||||
* If the backend of this canvas does not support annotations, this call is
|
||||
* safely ignored.
|
||||
*
|
||||
|
|
|
@ -8,56 +8,24 @@
|
|||
#ifndef SkBBHFactory_DEFINED
|
||||
#define SkBBHFactory_DEFINED
|
||||
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include <vector>
|
||||
|
||||
class SkBBoxHierarchy : public SkRefCnt {
|
||||
public:
|
||||
struct Metadata {
|
||||
bool isDraw; // The corresponding SkRect bounds a draw command, not a pure state change.
|
||||
};
|
||||
|
||||
/**
|
||||
* Insert N bounding boxes into the hierarchy.
|
||||
*/
|
||||
virtual void insert(const SkRect[], int N) = 0;
|
||||
virtual void insert(const SkRect[], const Metadata[], int N);
|
||||
|
||||
/**
|
||||
* Populate results with the indices of bounding boxes intersecting that query.
|
||||
*/
|
||||
virtual void search(const SkRect& query, std::vector<int>* results) const = 0;
|
||||
|
||||
/**
|
||||
* Return approximate size in memory of *this.
|
||||
*/
|
||||
virtual size_t bytesUsed() const = 0;
|
||||
|
||||
protected:
|
||||
SkBBoxHierarchy() = default;
|
||||
SkBBoxHierarchy(const SkBBoxHierarchy&) = delete;
|
||||
SkBBoxHierarchy& operator=(const SkBBoxHierarchy&) = delete;
|
||||
};
|
||||
class SkBBoxHierarchy;
|
||||
struct SkRect;
|
||||
|
||||
class SK_API SkBBHFactory {
|
||||
public:
|
||||
/**
|
||||
* Allocate a new SkBBoxHierarchy. Return NULL on failure.
|
||||
*/
|
||||
virtual sk_sp<SkBBoxHierarchy> operator()() const = 0;
|
||||
virtual SkBBoxHierarchy* operator()() const = 0;
|
||||
virtual ~SkBBHFactory() {}
|
||||
|
||||
protected:
|
||||
SkBBHFactory() = default;
|
||||
SkBBHFactory(const SkBBHFactory&) = delete;
|
||||
SkBBHFactory& operator=(const SkBBHFactory&) = delete;
|
||||
};
|
||||
|
||||
class SK_API SkRTreeFactory : public SkBBHFactory {
|
||||
public:
|
||||
sk_sp<SkBBoxHierarchy> operator()() const override;
|
||||
SkBBoxHierarchy* operator()() const override;
|
||||
private:
|
||||
typedef SkBBHFactory INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,32 +8,20 @@
|
|||
#ifndef SkBitmap_DEFINED
|
||||
#define SkBitmap_DEFINED
|
||||
|
||||
#include "include/core/SkAlphaType.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSamplingOptions.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/base/SkCPUTypes.h"
|
||||
#include "include/private/base/SkDebug.h"
|
||||
#include "include/core/SkTileMode.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class SkColorSpace;
|
||||
class SkImage;
|
||||
class SkMatrix;
|
||||
class SkMipmap;
|
||||
struct SkMask;
|
||||
struct SkIRect;
|
||||
struct SkRect;
|
||||
class SkPaint;
|
||||
class SkPixelRef;
|
||||
class SkShader;
|
||||
enum SkColorType : int;
|
||||
enum class SkTileMode;
|
||||
struct SkMask;
|
||||
class SkString;
|
||||
|
||||
/** \class SkBitmap
|
||||
SkBitmap describes a two-dimensional raster pixel array. SkBitmap is built on
|
||||
|
@ -62,14 +50,12 @@ public:
|
|||
|
||||
/** Creates an empty SkBitmap without pixels, with kUnknown_SkColorType,
|
||||
kUnknown_SkAlphaType, and with a width and height of zero. SkPixelRef origin is
|
||||
set to (0, 0).
|
||||
set to (0, 0). SkBitmap is not volatile.
|
||||
|
||||
Use setInfo() to associate SkColorType, SkAlphaType, width, and height
|
||||
after SkBitmap has been created.
|
||||
|
||||
@return empty SkBitmap
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_empty_constructor
|
||||
*/
|
||||
SkBitmap();
|
||||
|
||||
|
@ -78,8 +64,6 @@ public:
|
|||
|
||||
@param src SkBitmap to copy SkImageInfo, and share SkPixelRef
|
||||
@return copy of src
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_copy_const_SkBitmap
|
||||
*/
|
||||
SkBitmap(const SkBitmap& src);
|
||||
|
||||
|
@ -88,8 +72,6 @@ public:
|
|||
|
||||
@param src SkBitmap to copy SkImageInfo, and reassign SkPixelRef
|
||||
@return copy of src
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_move_SkBitmap
|
||||
*/
|
||||
SkBitmap(SkBitmap&& src);
|
||||
|
||||
|
@ -102,8 +84,6 @@ public:
|
|||
|
||||
@param src SkBitmap to copy SkImageInfo, and share SkPixelRef
|
||||
@return copy of src
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_copy_operator
|
||||
*/
|
||||
SkBitmap& operator=(const SkBitmap& src);
|
||||
|
||||
|
@ -112,16 +92,12 @@ public:
|
|||
|
||||
@param src SkBitmap to copy SkImageInfo, and reassign SkPixelRef
|
||||
@return copy of src
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_move_operator
|
||||
*/
|
||||
SkBitmap& operator=(SkBitmap&& src);
|
||||
|
||||
/** Swaps the fields of the two bitmaps.
|
||||
|
||||
@param other SkBitmap exchanged with original
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_swap
|
||||
*/
|
||||
void swap(SkBitmap& other);
|
||||
|
||||
|
@ -157,8 +133,22 @@ public:
|
|||
*/
|
||||
int height() const { return fPixmap.height(); }
|
||||
|
||||
/** Returns SkColorType, one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType.
|
||||
|
||||
@return SkColorType in SkImageInfo
|
||||
*/
|
||||
SkColorType colorType() const { return fPixmap.colorType(); }
|
||||
|
||||
/** Returns SkAlphaType, one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType.
|
||||
|
||||
@return SkAlphaType in SkImageInfo
|
||||
*/
|
||||
SkAlphaType alphaType() const { return fPixmap.alphaType(); }
|
||||
|
||||
/** Returns SkColorSpace, the range of colors, associated with SkImageInfo. The
|
||||
|
@ -167,7 +157,7 @@ public:
|
|||
|
||||
@return SkColorSpace in SkImageInfo, or nullptr
|
||||
*/
|
||||
SkColorSpace* colorSpace() const;
|
||||
SkColorSpace* colorSpace() const { return fPixmap.colorSpace(); }
|
||||
|
||||
/** Returns smart pointer to SkColorSpace, the range of colors, associated with
|
||||
SkImageInfo. The smart pointer tracks the number of objects sharing this
|
||||
|
@ -177,7 +167,7 @@ public:
|
|||
|
||||
@return SkColorSpace in SkImageInfo wrapped in a smart pointer
|
||||
*/
|
||||
sk_sp<SkColorSpace> refColorSpace() const;
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fPixmap.info().refColorSpace(); }
|
||||
|
||||
/** Returns number of bytes per pixel required by SkColorType.
|
||||
Returns zero if colorType( is kUnknown_SkColorType.
|
||||
|
@ -260,9 +250,10 @@ public:
|
|||
This changes SkAlphaType in SkPixelRef; all bitmaps sharing SkPixelRef
|
||||
are affected.
|
||||
|
||||
@param alphaType one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@return true if SkAlphaType is set
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_setAlphaType
|
||||
*/
|
||||
bool setAlphaType(SkAlphaType alphaType);
|
||||
|
||||
|
@ -287,8 +278,6 @@ public:
|
|||
Most immutable SkBitmap checks trigger an assert only on debug builds.
|
||||
|
||||
@return true if pixels are immutable
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_isImmutable
|
||||
*/
|
||||
bool isImmutable() const;
|
||||
|
||||
|
@ -297,8 +286,6 @@ public:
|
|||
Once SkPixelRef is marked immutable, the setting cannot be cleared.
|
||||
|
||||
Writing to immutable SkBitmap pixels triggers an assert on debug builds.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_setImmutable
|
||||
*/
|
||||
void setImmutable();
|
||||
|
||||
|
@ -315,6 +302,26 @@ public:
|
|||
return SkAlphaTypeIsOpaque(this->alphaType());
|
||||
}
|
||||
|
||||
/** Provides a hint to caller that pixels should not be cached. Only true if
|
||||
setIsVolatile() has been called to mark as volatile.
|
||||
|
||||
Volatile state is not shared by other bitmaps sharing the same SkPixelRef.
|
||||
|
||||
@return true if marked volatile
|
||||
*/
|
||||
bool isVolatile() const;
|
||||
|
||||
/** Sets if pixels should be read from SkPixelRef on every access. SkBitmap are not
|
||||
volatile by default; a GPU back end may upload pixel values expecting them to be
|
||||
accessed repeatedly. Marking temporary SkBitmap as volatile provides a hint to
|
||||
SkBaseDevice that the SkBitmap pixels should not be cached. This can
|
||||
improve performance by avoiding overhead and reducing resource
|
||||
consumption on SkBaseDevice.
|
||||
|
||||
@param isVolatile true if backing pixels are temporary
|
||||
*/
|
||||
void setIsVolatile(bool isVolatile);
|
||||
|
||||
/** Resets to its initial state; all fields are set to zero, as if SkBitmap had
|
||||
been initialized by SkBitmap().
|
||||
|
||||
|
@ -323,8 +330,6 @@ public:
|
|||
|
||||
If SkPixelRef is allocated, its reference count is decreased by one, releasing
|
||||
its memory if SkBitmap is the sole owner.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_reset
|
||||
*/
|
||||
void reset();
|
||||
|
||||
|
@ -352,16 +357,12 @@ public:
|
|||
/** Returns SkRect { 0, 0, width(), height() }.
|
||||
|
||||
@param bounds container for floating point rectangle
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_getBounds
|
||||
*/
|
||||
void getBounds(SkRect* bounds) const;
|
||||
|
||||
/** Returns SkIRect { 0, 0, width(), height() }.
|
||||
|
||||
@param bounds container for integral rectangle
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_getBounds_2
|
||||
*/
|
||||
void getBounds(SkIRect* bounds) const;
|
||||
|
||||
|
@ -413,8 +414,6 @@ public:
|
|||
@param imageInfo contains width, height, SkAlphaType, SkColorType, SkColorSpace
|
||||
@param rowBytes imageInfo.minRowBytes() or larger; or zero
|
||||
@return true if SkImageInfo set successfully
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_setInfo
|
||||
*/
|
||||
bool setInfo(const SkImageInfo& imageInfo, size_t rowBytes = 0);
|
||||
|
||||
|
@ -457,8 +456,6 @@ public:
|
|||
|
||||
@param info contains width, height, SkAlphaType, SkColorType, SkColorSpace
|
||||
@param flags kZeroPixels_AllocFlag, or zero
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_allocPixelsFlags
|
||||
*/
|
||||
void allocPixelsFlags(const SkImageInfo& info, uint32_t flags);
|
||||
|
||||
|
@ -495,8 +492,6 @@ public:
|
|||
|
||||
@param info contains width, height, SkAlphaType, SkColorType, SkColorSpace
|
||||
@param rowBytes size of pixel row or larger; may be zero
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_allocPixels
|
||||
*/
|
||||
void allocPixels(const SkImageInfo& info, size_t rowBytes);
|
||||
|
||||
|
@ -531,8 +526,6 @@ public:
|
|||
implementation of malloc().
|
||||
|
||||
@param info contains width, height, SkAlphaType, SkColorType, SkColorSpace
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_allocPixels_2
|
||||
*/
|
||||
void allocPixels(const SkImageInfo& info);
|
||||
|
||||
|
@ -569,8 +562,6 @@ public:
|
|||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param isOpaque true if pixels do not have transparency
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_allocN32Pixels
|
||||
*/
|
||||
void allocN32Pixels(int width, int height, bool isOpaque = false);
|
||||
|
||||
|
@ -630,8 +621,6 @@ public:
|
|||
|
||||
@param pixmap SkImageInfo, pixel address, and rowBytes()
|
||||
@return true if SkImageInfo was set to pixmap.info()
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_installPixels_3
|
||||
*/
|
||||
bool installPixels(const SkPixmap& pixmap);
|
||||
|
||||
|
@ -649,8 +638,6 @@ public:
|
|||
of SkBitmap and SkPixelRef.
|
||||
|
||||
@param pixels address of pixel storage, managed by caller
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_setPixels
|
||||
*/
|
||||
void setPixels(void* pixels);
|
||||
|
||||
|
@ -671,8 +658,6 @@ public:
|
|||
Aborts if info().colorType() is kUnknown_SkColorType, or allocation fails.
|
||||
Abort steps may be provided by the user at compile
|
||||
time by defining SK_ABORT.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_allocPixels_3
|
||||
*/
|
||||
void allocPixels();
|
||||
|
||||
|
@ -695,8 +680,6 @@ public:
|
|||
the user at compile time by defining SK_ABORT.
|
||||
|
||||
@param allocator instance of SkBitmap::Allocator instantiation
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_allocPixels_4
|
||||
*/
|
||||
void allocPixels(Allocator* allocator);
|
||||
|
||||
|
@ -719,8 +702,6 @@ public:
|
|||
Returns (0, 0) if SkPixelRef is nullptr.
|
||||
|
||||
@return pixel origin within SkPixelRef
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_pixelRefOrigin
|
||||
*/
|
||||
SkIPoint pixelRefOrigin() const;
|
||||
|
||||
|
@ -736,8 +717,6 @@ public:
|
|||
@param pixelRef SkPixelRef describing pixel address and rowBytes()
|
||||
@param dx column offset in SkPixelRef for bitmap origin
|
||||
@param dy row offset in SkPixelRef for bitmap origin
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_setPixelRef
|
||||
*/
|
||||
void setPixelRef(sk_sp<SkPixelRef> pixelRef, int dx, int dy);
|
||||
|
||||
|
@ -756,49 +735,28 @@ public:
|
|||
Determines if pixels have changed since last examined.
|
||||
|
||||
@return unique value for pixels in SkPixelRef
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_getGenerationID
|
||||
*/
|
||||
uint32_t getGenerationID() const;
|
||||
|
||||
/** Marks that pixels in SkPixelRef have changed. Subsequent calls to
|
||||
getGenerationID() return a different value.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_notifyPixelsChanged
|
||||
*/
|
||||
void notifyPixelsChanged() const;
|
||||
|
||||
/** Replaces pixel values with c, interpreted as being in the sRGB SkColorSpace.
|
||||
All pixels contained by bounds() are affected. If the colorType() is
|
||||
kGray_8_SkColorType or kRGB_565_SkColorType, then alpha is ignored; RGB is
|
||||
treated as opaque. If colorType() is kAlpha_8_SkColorType, then RGB is ignored.
|
||||
/** Replaces pixel values with c. All pixels contained by bounds() are affected.
|
||||
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then alpha
|
||||
is ignored; RGB is treated as opaque. If colorType() is kAlpha_8_SkColorType,
|
||||
then RGB is ignored.
|
||||
|
||||
@param c unpremultiplied color
|
||||
@param colorSpace SkColorSpace of c
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_eraseColor
|
||||
*/
|
||||
void eraseColor(SkColor4f c, SkColorSpace* colorSpace = nullptr) const;
|
||||
|
||||
/** Replaces pixel values with c, interpreted as being in the sRGB SkColorSpace.
|
||||
All pixels contained by bounds() are affected. If the colorType() is
|
||||
kGray_8_SkColorType or kRGB_565_SkColorType, then alpha is ignored; RGB is
|
||||
treated as opaque. If colorType() is kAlpha_8_SkColorType, then RGB is ignored.
|
||||
|
||||
Input color is ultimately converted to an SkColor4f, so eraseColor(SkColor4f c)
|
||||
will have higher color resolution.
|
||||
|
||||
@param c unpremultiplied color.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_eraseColor
|
||||
@param c unpremultiplied color
|
||||
*/
|
||||
void eraseColor(SkColor c) const;
|
||||
|
||||
/** Replaces pixel values with unpremultiplied color built from a, r, g, and b,
|
||||
interpreted as being in the sRGB SkColorSpace. All pixels contained by
|
||||
bounds() are affected. If the colorType() is kGray_8_SkColorType or
|
||||
kRGB_565_SkColorType, then a is ignored; r, g, and b are treated as opaque.
|
||||
If colorType() is kAlpha_8_SkColorType, then r, g, and b are ignored.
|
||||
/** Replaces pixel values with unpremultiplied color built from a, r, g, and b.
|
||||
All pixels contained by bounds() are affected.
|
||||
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then a
|
||||
is ignored; r, g, and b are treated as opaque. If colorType() is kAlpha_8_SkColorType,
|
||||
then r, g, and b are ignored.
|
||||
|
||||
@param a amount of alpha, from fully transparent (0) to fully opaque (255)
|
||||
@param r amount of red, from no red (0) to full red (255)
|
||||
|
@ -809,36 +767,15 @@ public:
|
|||
this->eraseColor(SkColorSetARGB(a, r, g, b));
|
||||
}
|
||||
|
||||
/** Replaces pixel values inside area with c. interpreted as being in the sRGB
|
||||
SkColorSpace. If area does not intersect bounds(), call has no effect.
|
||||
/** Replaces pixel values inside area with c. If area does not intersect bounds(),
|
||||
call has no effect.
|
||||
|
||||
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then alpha
|
||||
is ignored; RGB is treated as opaque. If colorType() is kAlpha_8_SkColorType,
|
||||
then RGB is ignored.
|
||||
|
||||
@param c unpremultiplied color
|
||||
@param area rectangle to fill
|
||||
@param colorSpace SkColorSpace of c
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_erase
|
||||
*/
|
||||
void erase(SkColor4f c, SkColorSpace* colorSpace, const SkIRect& area) const;
|
||||
void erase(SkColor4f c, const SkIRect& area) const;
|
||||
|
||||
/** Replaces pixel values inside area with c. interpreted as being in the sRGB
|
||||
SkColorSpace. If area does not intersect bounds(), call has no effect.
|
||||
|
||||
If the colorType() is kGray_8_SkColorType or kRGB_565_SkColorType, then alpha
|
||||
is ignored; RGB is treated as opaque. If colorType() is kAlpha_8_SkColorType,
|
||||
then RGB is ignored.
|
||||
|
||||
Input color is ultimately converted to an SkColor4f, so erase(SkColor4f c)
|
||||
will have higher color resolution.
|
||||
|
||||
@param c unpremultiplied color
|
||||
@param area rectangle to fill
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_erase
|
||||
*/
|
||||
void erase(SkColor c, const SkIRect& area) const;
|
||||
|
||||
|
@ -868,23 +805,6 @@ public:
|
|||
return this->pixmap().getColor(x, y);
|
||||
}
|
||||
|
||||
/** Returns pixel at (x, y) as unpremultiplied float color.
|
||||
Returns black with alpha if SkColorType is kAlpha_8_SkColorType.
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined; and returns undefined values or may crash if
|
||||
SK_RELEASE is defined. Fails if SkColorType is kUnknown_SkColorType or
|
||||
pixel address is nullptr.
|
||||
|
||||
SkColorSpace in SkImageInfo is ignored. Some color precision may be lost in the
|
||||
conversion to unpremultiplied color.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return pixel converted to unpremultiplied color
|
||||
*/
|
||||
SkColor4f getColor4f(int x, int y) const { return this->pixmap().getColor4f(x, y); }
|
||||
|
||||
/** Look up the pixel at (x,y) and return its alpha component, normalized to [0..1].
|
||||
This is roughly equivalent to SkGetColorA(getColor()), but can be more efficent
|
||||
(and more precise if the pixels store more than 8 bits per component).
|
||||
|
@ -909,8 +829,6 @@ public:
|
|||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return generic pointer to pixel
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_getAddr
|
||||
*/
|
||||
void* getAddr(int x, int y) const;
|
||||
|
||||
|
@ -962,7 +880,8 @@ public:
|
|||
|
||||
subset may be larger than bounds(). Any area outside of bounds() is ignored.
|
||||
|
||||
Any contents of dst are discarded.
|
||||
Any contents of dst are discarded. isVolatile() setting is copied to dst.
|
||||
dst is set to colorType(), alphaType(), and colorSpace().
|
||||
|
||||
Return false if:
|
||||
- dst is nullptr
|
||||
|
@ -972,8 +891,6 @@ public:
|
|||
@param dst SkBitmap set to subset
|
||||
@param subset rectangle of pixels to reference
|
||||
@return true if dst is replaced by subset
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_extractSubset
|
||||
*/
|
||||
bool extractSubset(SkBitmap* dst, const SkIRect& subset) const;
|
||||
|
||||
|
@ -1033,8 +950,6 @@ public:
|
|||
@param srcX column index whose absolute value is less than width()
|
||||
@param srcY row index whose absolute value is less than height()
|
||||
@return true if pixels are copied to dst
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_readPixels_2
|
||||
*/
|
||||
bool readPixels(const SkPixmap& dst, int srcX, int srcY) const;
|
||||
|
||||
|
@ -1087,8 +1002,6 @@ public:
|
|||
@param dstX column index whose absolute value is less than width()
|
||||
@param dstY row index whose absolute value is less than height()
|
||||
@return true if src pixels are copied to SkBitmap
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_writePixels
|
||||
*/
|
||||
bool writePixels(const SkPixmap& src, int dstX, int dstY);
|
||||
|
||||
|
@ -1172,28 +1085,13 @@ public:
|
|||
|
||||
@param pixmap storage for pixel state if pixels are readable; otherwise, ignored
|
||||
@return true if SkBitmap has direct access to pixels
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_peekPixels
|
||||
*/
|
||||
bool peekPixels(SkPixmap* pixmap) const;
|
||||
|
||||
/**
|
||||
* Make a shader with the specified tiling, matrix and sampling.
|
||||
*/
|
||||
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions&,
|
||||
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy,
|
||||
const SkMatrix* localMatrix = nullptr) const;
|
||||
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions& sampling,
|
||||
const SkMatrix& lm) const;
|
||||
/** Defaults to clamp in both X and Y. */
|
||||
sk_sp<SkShader> makeShader(const SkSamplingOptions& sampling, const SkMatrix& lm) const;
|
||||
sk_sp<SkShader> makeShader(const SkSamplingOptions& sampling,
|
||||
const SkMatrix* lm = nullptr) const;
|
||||
|
||||
/**
|
||||
* Returns a new image from the bitmap. If the bitmap is marked immutable, this will
|
||||
* share the pixel buffer. If not, it will make a copy of the pixels for the image.
|
||||
*/
|
||||
sk_sp<SkImage> asImage() const;
|
||||
// defaults to Clamp in x, and y
|
||||
sk_sp<SkShader> makeShader(const SkMatrix* localMatrix = nullptr) const;
|
||||
|
||||
/** Asserts if internal values are illegal or inconsistent. Only available if
|
||||
SK_DEBUG is defined at compile time.
|
||||
|
@ -1215,7 +1113,7 @@ public:
|
|||
*/
|
||||
virtual bool allocPixelRef(SkBitmap* bitmap) = 0;
|
||||
private:
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
/** \class SkBitmap::HeapAllocator
|
||||
|
@ -1232,20 +1130,20 @@ public:
|
|||
|
||||
@param bitmap SkBitmap containing SkImageInfo as input, and SkPixelRef as output
|
||||
@return true if pixels are allocated
|
||||
|
||||
example: https://fiddle.skia.org/c/@Bitmap_HeapAllocator_allocPixelRef
|
||||
*/
|
||||
bool allocPixelRef(SkBitmap* bitmap) override;
|
||||
};
|
||||
|
||||
private:
|
||||
enum Flags {
|
||||
kImageIsVolatile_Flag = 0x02,
|
||||
};
|
||||
|
||||
sk_sp<SkPixelRef> fPixelRef;
|
||||
SkPixmap fPixmap;
|
||||
sk_sp<SkMipmap> fMips;
|
||||
uint8_t fFlags;
|
||||
|
||||
friend class SkImage_Raster;
|
||||
friend class SkReadBuffer; // unflatten
|
||||
friend class GrProxyProvider; // fMips
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -10,101 +10,54 @@
|
|||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Blends are operators that take in two colors (source, destination) and return a new color.
|
||||
* Many of these operate the same on all 4 components: red, green, blue, alpha. For these,
|
||||
* we just document what happens to one component, rather than naming each one separately.
|
||||
*
|
||||
* Different SkColorTypes have different representations for color components:
|
||||
* 8-bit: 0..255
|
||||
* 6-bit: 0..63
|
||||
* 5-bit: 0..31
|
||||
* 4-bit: 0..15
|
||||
* floats: 0...1
|
||||
*
|
||||
* The documentation is expressed as if the component values are always 0..1 (floats).
|
||||
*
|
||||
* For brevity, the documentation uses the following abbreviations
|
||||
* s : source
|
||||
* d : destination
|
||||
* sa : source alpha
|
||||
* da : destination alpha
|
||||
*
|
||||
* Results are abbreviated
|
||||
* r : if all 4 components are computed in the same manner
|
||||
* ra : result alpha component
|
||||
* rc : result "color": red, green, blue components
|
||||
*/
|
||||
enum class SkBlendMode {
|
||||
kClear, //!< r = 0
|
||||
kSrc, //!< r = s
|
||||
kDst, //!< r = d
|
||||
kSrcOver, //!< r = s + (1-sa)*d
|
||||
kDstOver, //!< r = d + (1-da)*s
|
||||
kSrcIn, //!< r = s * da
|
||||
kDstIn, //!< r = d * sa
|
||||
kSrcOut, //!< r = s * (1-da)
|
||||
kDstOut, //!< r = d * (1-sa)
|
||||
kSrcATop, //!< r = s*da + d*(1-sa)
|
||||
kDstATop, //!< r = d*sa + s*(1-da)
|
||||
kXor, //!< r = s*(1-da) + d*(1-sa)
|
||||
kPlus, //!< r = min(s + d, 1)
|
||||
kModulate, //!< r = s*d
|
||||
kScreen, //!< r = s + d - s*d
|
||||
|
||||
kOverlay, //!< multiply or screen, depending on destination
|
||||
kDarken, //!< rc = s + d - max(s*da, d*sa), ra = kSrcOver
|
||||
kLighten, //!< rc = s + d - min(s*da, d*sa), ra = kSrcOver
|
||||
kColorDodge, //!< brighten destination to reflect source
|
||||
kColorBurn, //!< darken destination to reflect source
|
||||
kHardLight, //!< multiply or screen, depending on source
|
||||
kSoftLight, //!< lighten or darken, depending on source
|
||||
kDifference, //!< rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
|
||||
kExclusion, //!< rc = s + d - two(s*d), ra = kSrcOver
|
||||
kMultiply, //!< r = s*(1-da) + d*(1-sa) + s*d
|
||||
|
||||
kHue, //!< hue of source with saturation and luminosity of destination
|
||||
kSaturation, //!< saturation of source with hue and luminosity of destination
|
||||
kColor, //!< hue and saturation of source with luminosity of destination
|
||||
kLuminosity, //!< luminosity of source with hue and saturation of destination
|
||||
|
||||
kClear, //!< replaces destination with zero: fully transparent
|
||||
kSrc, //!< replaces destination
|
||||
kDst, //!< preserves destination
|
||||
kSrcOver, //!< source over destination
|
||||
kDstOver, //!< destination over source
|
||||
kSrcIn, //!< source trimmed inside destination
|
||||
kDstIn, //!< destination trimmed by source
|
||||
kSrcOut, //!< source trimmed outside destination
|
||||
kDstOut, //!< destination trimmed outside source
|
||||
kSrcATop, //!< source inside destination blended with destination
|
||||
kDstATop, //!< destination inside source blended with source
|
||||
kXor, //!< each of source and destination trimmed outside the other
|
||||
kPlus, //!< sum of colors
|
||||
kModulate, //!< product of premultiplied colors; darkens destination
|
||||
kScreen, //!< multiply inverse of pixels, inverting result; brightens destination
|
||||
kLastCoeffMode = kScreen, //!< last porter duff blend mode
|
||||
kOverlay, //!< multiply or screen, depending on destination
|
||||
kDarken, //!< darker of source and destination
|
||||
kLighten, //!< lighter of source and destination
|
||||
kColorDodge, //!< brighten destination to reflect source
|
||||
kColorBurn, //!< darken destination to reflect source
|
||||
kHardLight, //!< multiply or screen, depending on source
|
||||
kSoftLight, //!< lighten or darken, depending on source
|
||||
kDifference, //!< subtract darker from lighter with higher contrast
|
||||
kExclusion, //!< subtract darker from lighter with lower contrast
|
||||
kMultiply, //!< multiply source with destination, darkening image
|
||||
kLastSeparableMode = kMultiply, //!< last blend mode operating separately on components
|
||||
kHue, //!< hue of source with saturation and luminosity of destination
|
||||
kSaturation, //!< saturation of source with hue and luminosity of destination
|
||||
kColor, //!< hue and saturation of source with luminosity of destination
|
||||
kLuminosity, //!< luminosity of source with hue and saturation of destination
|
||||
kLastMode = kLuminosity, //!< last valid value
|
||||
};
|
||||
|
||||
static constexpr int kSkBlendModeCount = static_cast<int>(SkBlendMode::kLastMode) + 1;
|
||||
|
||||
/**
|
||||
* For Porter-Duff SkBlendModes (those <= kLastCoeffMode), these coefficients describe the blend
|
||||
* equation used. Coefficient-based blend modes specify an equation:
|
||||
* ('dstCoeff' * dst + 'srcCoeff' * src), where the coefficient values are constants, functions of
|
||||
* the src or dst alpha, or functions of the src or dst color.
|
||||
*/
|
||||
enum class SkBlendModeCoeff {
|
||||
kZero, /** 0 */
|
||||
kOne, /** 1 */
|
||||
kSC, /** src color */
|
||||
kISC, /** inverse src color (i.e. 1 - sc) */
|
||||
kDC, /** dst color */
|
||||
kIDC, /** inverse dst color (i.e. 1 - dc) */
|
||||
kSA, /** src alpha */
|
||||
kISA, /** inverse src alpha (i.e. 1 - sa) */
|
||||
kDA, /** dst alpha */
|
||||
kIDA, /** inverse dst alpha (i.e. 1 - da) */
|
||||
|
||||
kCoeffCount
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if 'mode' is a coefficient-based blend mode (<= kLastCoeffMode). If true is
|
||||
* returned, the mode's src and dst coefficient functions are set in 'src' and 'dst'.
|
||||
*/
|
||||
SK_API bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff* src, SkBlendModeCoeff* dst);
|
||||
|
||||
|
||||
/** Returns name of blendMode as null-terminated C string.
|
||||
|
||||
@param blendMode one of:
|
||||
SkBlendMode::kClear, SkBlendMode::kSrc, SkBlendMode::kDst,
|
||||
SkBlendMode::kSrcOver, SkBlendMode::kDstOver, SkBlendMode::kSrcIn,
|
||||
SkBlendMode::kDstIn, SkBlendMode::kSrcOut, SkBlendMode::kDstOut,
|
||||
SkBlendMode::kSrcATop, SkBlendMode::kDstATop, SkBlendMode::kXor,
|
||||
SkBlendMode::kPlus, SkBlendMode::kModulate, SkBlendMode::kScreen,
|
||||
SkBlendMode::kOverlay, SkBlendMode::kDarken, SkBlendMode::kLighten,
|
||||
SkBlendMode::kColorDodge, SkBlendMode::kColorBurn, SkBlendMode::kHardLight,
|
||||
SkBlendMode::kSoftLight, SkBlendMode::kDifference, SkBlendMode::kExclusion,
|
||||
SkBlendMode::kMultiply, SkBlendMode::kHue, SkBlendMode::kSaturation,
|
||||
SkBlendMode::kColor, SkBlendMode::kLuminosity
|
||||
@return C string
|
||||
*/
|
||||
SK_API const char* SkBlendMode_Name(SkBlendMode blendMode);
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* 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 SkBlender_DEFINED
|
||||
#define SkBlender_DEFINED
|
||||
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
|
||||
/**
|
||||
* SkBlender represents a custom blend function in the Skia pipeline. When an SkBlender is
|
||||
* present in a paint, the SkBlendMode is ignored. A blender combines a source color (the
|
||||
* result of our paint) and destination color (from the canvas) into a final color.
|
||||
*/
|
||||
class SK_API SkBlender : public SkFlattenable {
|
||||
public:
|
||||
/**
|
||||
* Create a blender that implements the specified BlendMode.
|
||||
*/
|
||||
static sk_sp<SkBlender> Mode(SkBlendMode mode);
|
||||
|
||||
private:
|
||||
SkBlender() = default;
|
||||
friend class SkBlenderBase;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -8,6 +8,8 @@
|
|||
#ifndef SkBlurTypes_DEFINED
|
||||
#define SkBlurTypes_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
enum SkBlurStyle : int {
|
||||
kNormal_SkBlurStyle, //!< fuzzy inside and outside
|
||||
kSolid_SkBlurStyle, //!< solid inside, fuzzy outside
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -39,17 +39,48 @@ protected:
|
|||
const SkPaint& paint) override = 0;
|
||||
void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
|
||||
const SkPaint& paint) override = 0;
|
||||
void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
|
||||
SkBlendMode, const SkPaint&) override = 0;
|
||||
|
||||
void onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy,
|
||||
const SkPaint* paint) override = 0;
|
||||
void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) override = 0;
|
||||
void onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint* paint) override = 0;
|
||||
void onDrawImageLattice(const SkImage* image, const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst, const SkPaint* paint) override = 0;
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
// This is under active development for Chrome and not used in Android. Hold off on adding
|
||||
// implementations in Android's SkCanvas subclasses until this stabilizes.
|
||||
void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
||||
SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color, SkBlendMode mode) override {}
|
||||
void onDrawEdgeAAImageSet(const SkCanvas::ImageSetEntry imageSet[], int count,
|
||||
const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint) override {}
|
||||
#else
|
||||
void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
||||
SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color, SkBlendMode mode) override = 0;
|
||||
void onDrawEdgeAAImageSet(const SkCanvas::ImageSetEntry imageSet[], int count,
|
||||
const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint) override = 0;
|
||||
#endif
|
||||
|
||||
void onDrawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy,
|
||||
const SkPaint* paint) override = 0;
|
||||
void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint) override = 0;
|
||||
void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint* paint) override = 0;
|
||||
void onDrawBitmapLattice(const SkBitmap& bitmap, const SkCanvas::Lattice& lattice,
|
||||
const SkRect& dst, const SkPaint* paint) override = 0;
|
||||
|
||||
void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
|
||||
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cull,
|
||||
const SkPaint* paint) override = 0;
|
||||
|
||||
void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override = 0;
|
||||
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override = 0;
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCapabilities_DEFINED
|
||||
#define SkCapabilities_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
#include "include/sksl/SkSLVersion.h"
|
||||
namespace SkSL { struct ShaderCaps; }
|
||||
#endif
|
||||
|
||||
#if defined(SK_GRAPHITE)
|
||||
namespace skgpu::graphite { class Caps; }
|
||||
#endif
|
||||
|
||||
class SK_API SkCapabilities : public SkRefCnt {
|
||||
public:
|
||||
static sk_sp<const SkCapabilities> RasterBackend();
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
SkSL::Version skslVersion() const { return fSkSLVersion; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#if defined(SK_GRAPHITE)
|
||||
friend class skgpu::graphite::Caps; // for ctor
|
||||
#endif
|
||||
|
||||
SkCapabilities() = default;
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void initSkCaps(const SkSL::ShaderCaps*);
|
||||
|
||||
SkSL::Version fSkSLVersion = SkSL::Version::k100;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
|
@ -13,7 +13,21 @@
|
|||
enum class SkClipOp {
|
||||
kDifference = 0,
|
||||
kIntersect = 1,
|
||||
kMax_EnumValue = kIntersect
|
||||
|
||||
#ifdef SK_SUPPORT_DEPRECATED_CLIPOPS
|
||||
kUnion_deprecated = 2,
|
||||
kXOR_deprecated = 3,
|
||||
kReverseDifference_deprecated = 4,
|
||||
kReplace_deprecated = 5,
|
||||
#else
|
||||
kExtraEnumNeedInternallyPleaseIgnoreWillGoAway2 = 2,
|
||||
kExtraEnumNeedInternallyPleaseIgnoreWillGoAway3 = 3,
|
||||
kExtraEnumNeedInternallyPleaseIgnoreWillGoAway4 = 4,
|
||||
kExtraEnumNeedInternallyPleaseIgnoreWillGoAway5 = 5,
|
||||
#endif
|
||||
|
||||
// Used internally for validation, can only shrink to 1 when the deprecated flag is gone
|
||||
kMax_EnumValue = 5,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,13 +8,9 @@
|
|||
#ifndef SkColor_DEFINED
|
||||
#define SkColor_DEFINED
|
||||
|
||||
#include "include/core/SkAlphaType.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/base/SkCPUTypes.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
/** \file SkColor.h
|
||||
|
||||
|
@ -79,7 +75,7 @@ static constexpr inline SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU
|
|||
@param a alpha: transparent at zero, fully opaque at 255
|
||||
@return color with transparency
|
||||
*/
|
||||
static constexpr inline SkColor SK_WARN_UNUSED_RESULT SkColorSetA(SkColor c, U8CPU a) {
|
||||
static constexpr inline SkColor SkColorSetA(SkColor c, U8CPU a) {
|
||||
return (c & 0x00FFFFFF) | (a << 24);
|
||||
}
|
||||
|
||||
|
@ -234,21 +230,6 @@ enum class SkColorChannel {
|
|||
kLastEnum = kA,
|
||||
};
|
||||
|
||||
/** Used to represent the channels available in a color type or texture format as a mask. */
|
||||
enum SkColorChannelFlag : uint32_t {
|
||||
kRed_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kR),
|
||||
kGreen_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kG),
|
||||
kBlue_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kB),
|
||||
kAlpha_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kA),
|
||||
kGray_SkColorChannelFlag = 0x10,
|
||||
// Convenience values
|
||||
kGrayAlpha_SkColorChannelFlags = kGray_SkColorChannelFlag | kAlpha_SkColorChannelFlag,
|
||||
kRG_SkColorChannelFlags = kRed_SkColorChannelFlag | kGreen_SkColorChannelFlag,
|
||||
kRGB_SkColorChannelFlags = kRG_SkColorChannelFlags | kBlue_SkColorChannelFlag,
|
||||
kRGBA_SkColorChannelFlags = kRGB_SkColorChannelFlags | kAlpha_SkColorChannelFlag,
|
||||
};
|
||||
static_assert(0 == (kGray_SkColorChannelFlag & kRGBA_SkColorChannelFlags), "bitfield conflict");
|
||||
|
||||
/** \struct SkRGBA4f
|
||||
RGBA color value, holding four floating point components. Color components are always in
|
||||
a known order. kAT determines if the SkRGBA4f's R, G, and B components are premultiplied
|
||||
|
@ -313,9 +294,6 @@ struct SkRGBA4f {
|
|||
*/
|
||||
float* vec() { return &fR; }
|
||||
|
||||
/** As a std::array<float, 4> */
|
||||
std::array<float, 4> array() const { return {fR, fG, fB, fA}; }
|
||||
|
||||
/** Returns one component. Asserts if index is out of range and SK_DEBUG is defined.
|
||||
|
||||
@param index one of: 0 (fR), 1 (fG), 2 (fB), 3 (fA)
|
||||
|
@ -358,16 +336,12 @@ struct SkRGBA4f {
|
|||
|
||||
@param color Color with Alpha, red, blue, and green components
|
||||
@return SkColor as SkRGBA4f
|
||||
|
||||
example: https://fiddle.skia.org/c/@RGBA4f_FromColor
|
||||
*/
|
||||
static SkRGBA4f FromColor(SkColor color); // impl. depends on kAT
|
||||
|
||||
/** Returns closest SkColor to SkRGBA4f. Only allowed if SkRGBA4f is unpremultiplied.
|
||||
|
||||
@return color as SkColor
|
||||
|
||||
example: https://fiddle.skia.org/c/@RGBA4f_toSkColor
|
||||
*/
|
||||
SkColor toSkColor() const; // impl. depends on kAT
|
||||
|
||||
|
@ -407,11 +381,6 @@ struct SkRGBA4f {
|
|||
uint32_t toBytes_RGBA() const;
|
||||
static SkRGBA4f FromBytes_RGBA(uint32_t color);
|
||||
|
||||
/**
|
||||
Returns a copy of the SkRGBA4f but with alpha component set to 1.0f.
|
||||
|
||||
@return opaque color
|
||||
*/
|
||||
SkRGBA4f makeOpaque() const {
|
||||
return { fR, fG, fB, 1.0f };
|
||||
}
|
||||
|
@ -427,8 +396,6 @@ using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>;
|
|||
|
||||
template <> SK_API SkColor4f SkColor4f::FromColor(SkColor);
|
||||
template <> SK_API SkColor SkColor4f::toSkColor() const;
|
||||
template <> SK_API uint32_t SkColor4f::toBytes_RGBA() const;
|
||||
template <> SK_API SkColor4f SkColor4f::FromBytes_RGBA(uint32_t color);
|
||||
|
||||
namespace SkColors {
|
||||
constexpr SkColor4f kTransparent = {0, 0, 0, 0};
|
||||
|
|
|
@ -11,34 +11,60 @@
|
|||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
class GrColorInfo;
|
||||
class GrFragmentProcessor;
|
||||
class GrRecordingContext;
|
||||
class SkBitmap;
|
||||
class SkColorMatrix;
|
||||
class SkColorSpace;
|
||||
struct SkStageRec;
|
||||
class SkString;
|
||||
|
||||
/**
|
||||
* ColorFilters are optional objects in the drawing pipeline. When present in
|
||||
* a paint, they are called with the "src" colors, and return new colors, which
|
||||
* are then passed onto the next stage (either ImageFilter or Xfermode).
|
||||
*
|
||||
* All subclasses are required to be reentrant-safe : it must be legal to share
|
||||
* the same instance between several threads.
|
||||
*/
|
||||
* ColorFilters are optional objects in the drawing pipeline. When present in
|
||||
* a paint, they are called with the "src" colors, and return new colors, which
|
||||
* are then passed onto the next stage (either ImageFilter or Xfermode).
|
||||
*
|
||||
* All subclasses are required to be reentrant-safe : it must be legal to share
|
||||
* the same instance between several threads.
|
||||
*/
|
||||
class SK_API SkColorFilter : public SkFlattenable {
|
||||
public:
|
||||
// DEPRECATED. skbug.com/8941
|
||||
|
||||
bool asColorMode(SkColor* color, SkBlendMode* mode) const {
|
||||
return this->onAsAColorMode(color, mode);
|
||||
}
|
||||
|
||||
/** If the filter can be represented by a source color plus Mode, this
|
||||
* returns true, and sets (if not NULL) the color and mode appropriately.
|
||||
* If not, this returns false and ignores the parameters.
|
||||
*/
|
||||
bool asAColorMode(SkColor* color, SkBlendMode* mode) const;
|
||||
bool asAColorMode(SkColor* color, SkBlendMode* mode) const {
|
||||
return this->onAsAColorMode(color, mode);
|
||||
}
|
||||
|
||||
/** If the filter can be represented by a 5x4 matrix, this
|
||||
* returns true, and sets the matrix appropriately.
|
||||
* If not, this returns false and ignores the parameter.
|
||||
*/
|
||||
bool asAColorMatrix(float matrix[20]) const;
|
||||
bool asAColorMatrix(float matrix[20]) const {
|
||||
return this->onAsAColorMatrix(matrix);
|
||||
}
|
||||
|
||||
// Returns true if the filter is guaranteed to never change the alpha of a color it filters.
|
||||
bool isAlphaUnchanged() const;
|
||||
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const;
|
||||
|
||||
enum Flags {
|
||||
/** If set the filter methods will not change the alpha channel of the colors.
|
||||
*/
|
||||
kAlphaUnchanged_Flag = 1 << 0,
|
||||
};
|
||||
|
||||
/** Returns the flags for this filter. Override in subclasses to return custom flags.
|
||||
*/
|
||||
virtual uint32_t getFlags() const { return 0; }
|
||||
|
||||
SkColor filterColor(SkColor) const;
|
||||
|
||||
|
@ -53,17 +79,68 @@ public:
|
|||
* this filter, applied to the output of the inner filter.
|
||||
*
|
||||
* result = this(inner(...))
|
||||
*
|
||||
* Due to internal limits, it is possible that this will return NULL, so the caller must
|
||||
* always check.
|
||||
*/
|
||||
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* A subclass may implement this factory function to work with the GPU backend. It returns
|
||||
* a GrFragmentProcessor that implemets the color filter in GPU shader code.
|
||||
*
|
||||
* The fragment processor receives a premultiplied input color and produces a premultiplied
|
||||
* output color.
|
||||
*
|
||||
* A null return indicates that the color filter isn't implemented for the GPU backend.
|
||||
*/
|
||||
virtual std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
|
||||
GrRecordingContext*, const GrColorInfo& dstColorInfo) const;
|
||||
#endif
|
||||
|
||||
bool affectsTransparentBlack() const {
|
||||
return this->filterColor(SK_ColorTRANSPARENT) != SK_ColorTRANSPARENT;
|
||||
}
|
||||
|
||||
static void RegisterFlattenables();
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkColorFilter_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkColorFilter_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkColorFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkColorFilter>(static_cast<SkColorFilter*>(
|
||||
SkFlattenable::Deserialize(
|
||||
kSkColorFilter_Type, data, size, procs).release()));
|
||||
}
|
||||
|
||||
protected:
|
||||
SkColorFilter() {}
|
||||
|
||||
virtual bool onAsAColorMatrix(float[20]) const;
|
||||
virtual bool onAsAColorMode(SkColor* color, SkBlendMode* bmode) const;
|
||||
|
||||
private:
|
||||
SkColorFilter() = default;
|
||||
friend class SkColorFilterBase;
|
||||
/*
|
||||
* Returns 1 if this is a single filter (not a composition of other filters), otherwise it
|
||||
* reutrns the number of leaf-node filters in a composition. This should be the same value
|
||||
* as the number of GrFragmentProcessors returned by asFragmentProcessors's array parameter.
|
||||
*
|
||||
* e.g. compose(filter, compose(compose(filter, filter), filter)) --> 4
|
||||
*/
|
||||
virtual int privateComposedFilterCount() const { return 1; }
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
virtual bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const = 0;
|
||||
|
||||
friend class SkComposeColorFilter;
|
||||
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
class SK_API SkColorFilters {
|
||||
|
@ -71,56 +148,18 @@ public:
|
|||
static sk_sp<SkColorFilter> Compose(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner) {
|
||||
return outer ? outer->makeComposed(inner) : inner;
|
||||
}
|
||||
|
||||
// Blends between the constant color (src) and input color (dst) based on the SkBlendMode.
|
||||
// If the color space is null, the constant color is assumed to be defined in sRGB.
|
||||
static sk_sp<SkColorFilter> Blend(const SkColor4f& c, sk_sp<SkColorSpace>, SkBlendMode mode);
|
||||
static sk_sp<SkColorFilter> Blend(SkColor c, SkBlendMode mode);
|
||||
|
||||
static sk_sp<SkColorFilter> Matrix(const SkColorMatrix&);
|
||||
static sk_sp<SkColorFilter> Matrix(const float rowMajor[20]);
|
||||
|
||||
// A version of Matrix which operates in HSLA space instead of RGBA.
|
||||
// I.e. HSLA-to-RGBA(Matrix(RGBA-to-HSLA(input))).
|
||||
static sk_sp<SkColorFilter> HSLAMatrix(const SkColorMatrix&);
|
||||
static sk_sp<SkColorFilter> HSLAMatrix(const float rowMajor[20]);
|
||||
|
||||
static sk_sp<SkColorFilter> LinearToSRGBGamma();
|
||||
static sk_sp<SkColorFilter> SRGBToLinearGamma();
|
||||
static sk_sp<SkColorFilter> Lerp(float t, sk_sp<SkColorFilter> dst, sk_sp<SkColorFilter> src);
|
||||
|
||||
/**
|
||||
* Create a table colorfilter, copying the table into the filter, and
|
||||
* applying it to all 4 components.
|
||||
* a' = table[a];
|
||||
* r' = table[r];
|
||||
* g' = table[g];
|
||||
* b' = table[b];
|
||||
* Components are operated on in unpremultiplied space. If the incomming
|
||||
* colors are premultiplied, they are temporarily unpremultiplied, then
|
||||
* the table is applied, and then the result is remultiplied.
|
||||
*/
|
||||
static sk_sp<SkColorFilter> Table(const uint8_t table[256]);
|
||||
|
||||
/**
|
||||
* Create a table colorfilter, with a different table for each
|
||||
* component [A, R, G, B]. If a given table is NULL, then it is
|
||||
* treated as identity, with the component left unchanged. If a table
|
||||
* is not null, then its contents are copied into the filter.
|
||||
*/
|
||||
static sk_sp<SkColorFilter> TableARGB(const uint8_t tableA[256],
|
||||
const uint8_t tableR[256],
|
||||
const uint8_t tableG[256],
|
||||
const uint8_t tableB[256]);
|
||||
|
||||
/**
|
||||
* Create a colorfilter that multiplies the RGB channels by one color, and
|
||||
* then adds a second color, pinning the result for each component to
|
||||
* [0..255]. The alpha components of the mul and add arguments
|
||||
* are ignored.
|
||||
*/
|
||||
static sk_sp<SkColorFilter> Lighting(SkColor mul, SkColor add);
|
||||
|
||||
private:
|
||||
SkColorFilters() = delete;
|
||||
};
|
||||
|
|
|
@ -9,11 +9,8 @@
|
|||
#define SkColorPriv_DEFINED
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/private/base/SkMath.h"
|
||||
#include "include/private/base/SkTPin.h"
|
||||
#include "include/private/base/SkTo.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "include/core/SkMath.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
/** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a
|
||||
byte into a scale value, so that we can say scale * value >> 8 instead of
|
||||
|
@ -34,7 +31,7 @@ static inline unsigned SkAlpha255To256(U8CPU alpha) {
|
|||
#define SkAlphaMul(value, alpha256) (((value) * (alpha256)) >> 8)
|
||||
|
||||
static inline U8CPU SkUnitScalarClampToByte(SkScalar x) {
|
||||
return static_cast<U8CPU>(SkTPin(x, 0.0f, 1.0f) * 255 + 0.5);
|
||||
return static_cast<U8CPU>(SkScalarPin(x, 0, 1) * 255 + 0.5);
|
||||
}
|
||||
|
||||
#define SK_A32_BITS 8
|
||||
|
@ -148,20 +145,7 @@ static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) {
|
|||
}
|
||||
|
||||
static inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst) {
|
||||
uint32_t scale = SkAlpha255To256(255 - SkGetPackedA32(src));
|
||||
|
||||
uint32_t mask = 0xFF00FF;
|
||||
uint32_t rb = (((dst & mask) * scale) >> 8) & mask;
|
||||
uint32_t ag = (((dst >> 8) & mask) * scale) & ~mask;
|
||||
|
||||
rb += (src & mask);
|
||||
ag += (src & ~mask);
|
||||
|
||||
// Color channels (but not alpha) can overflow, so we have to saturate to 0xFF in each lane.
|
||||
return std::min(rb & 0x000001FF, 0x000000FFU) |
|
||||
std::min(ag & 0x0001FF00, 0x0000FF00U) |
|
||||
std::min(rb & 0x01FF0000, 0x00FF0000U) |
|
||||
(ag & 0xFF000000);
|
||||
return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,14 +8,12 @@
|
|||
#ifndef SkColorSpace_DEFINED
|
||||
#define SkColorSpace_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/base/SkFixed.h"
|
||||
#include "include/private/base/SkOnce.h"
|
||||
#include "modules/skcms/skcms.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "include/private/SkFixed.h"
|
||||
#include "include/private/SkOnce.h"
|
||||
#include "include/third_party/skcms/skcms.h"
|
||||
#include <memory>
|
||||
|
||||
class SkData;
|
||||
|
||||
|
@ -60,7 +58,7 @@ static constexpr skcms_TransferFunction kPQ =
|
|||
static constexpr skcms_TransferFunction kHLG =
|
||||
{-3.0f, 2.0f, 2.0f, 1/0.17883277f, 0.28466892f, 0.55991073f, 0.0f };
|
||||
|
||||
} // namespace SkNamedTransferFn
|
||||
}
|
||||
|
||||
namespace SkNamedGamut {
|
||||
|
||||
|
@ -84,7 +82,7 @@ static constexpr skcms_Matrix3x3 kAdobeRGB = {{
|
|||
{ SkFixedToFloat(0x04fc), SkFixedToFloat(0x0f95), SkFixedToFloat(0xbe9c) },
|
||||
}};
|
||||
|
||||
static constexpr skcms_Matrix3x3 kDisplayP3 = {{
|
||||
static constexpr skcms_Matrix3x3 kDCIP3 = {{
|
||||
{ 0.515102f, 0.291965f, 0.157153f },
|
||||
{ 0.241182f, 0.692236f, 0.0665819f },
|
||||
{ -0.00104941f, 0.0418818f, 0.784378f },
|
||||
|
@ -102,7 +100,7 @@ static constexpr skcms_Matrix3x3 kXYZ = {{
|
|||
{ 0.0f, 0.0f, 1.0f },
|
||||
}};
|
||||
|
||||
} // namespace SkNamedGamut
|
||||
}
|
||||
|
||||
class SK_API SkColorSpace : public SkNVRefCnt<SkColorSpace> {
|
||||
public:
|
||||
|
@ -143,15 +141,19 @@ public:
|
|||
bool gammaIsLinear() const;
|
||||
|
||||
/**
|
||||
* Sets |fn| to the transfer function from this color space. Returns true if the transfer
|
||||
* function can be represented as coefficients to the standard ICC 7-parameter equation.
|
||||
* Returns false otherwise (eg, PQ, HLG).
|
||||
* If the transfer function can be represented as coefficients to the standard
|
||||
* equation, returns true and sets |fn| to the proper values.
|
||||
*
|
||||
* If not, returns false.
|
||||
*/
|
||||
bool isNumericalTransferFn(skcms_TransferFunction* fn) const;
|
||||
|
||||
/**
|
||||
* Returns true and sets |toXYZD50|.
|
||||
* Returns true and sets |toXYZD50| if the color gamut can be described as a matrix.
|
||||
* Returns false otherwise.
|
||||
*/
|
||||
bool toXYZD50(SkMatrix44* toXYZD50) const;
|
||||
|
||||
bool toXYZD50(skcms_Matrix3x3* toXYZD50) const;
|
||||
|
||||
/**
|
||||
|
@ -162,19 +164,23 @@ public:
|
|||
|
||||
/**
|
||||
* Returns a color space with the same gamut as this one, but with a linear gamma.
|
||||
* For color spaces whose gamut can not be described in terms of XYZ D50, returns
|
||||
* linear sRGB.
|
||||
*/
|
||||
sk_sp<SkColorSpace> makeLinearGamma() const;
|
||||
|
||||
/**
|
||||
* Returns a color space with the same gamut as this one, but with the sRGB transfer
|
||||
* function.
|
||||
* Returns a color space with the same gamut as this one, with with the sRGB transfer
|
||||
* function. For color spaces whose gamut can not be described in terms of XYZ D50, returns
|
||||
* sRGB.
|
||||
*/
|
||||
sk_sp<SkColorSpace> makeSRGBGamma() const;
|
||||
|
||||
/**
|
||||
* Returns a color space with the same transfer function as this one, but with the primary
|
||||
* colors rotated. In other words, this produces a new color space that maps RGB to GBR
|
||||
* (when applied to a source), and maps RGB to BRG (when applied to a destination).
|
||||
* colors rotated. For any XYZ space, this produces a new color space that maps RGB to GBR
|
||||
* (when applied to a source), and maps RGB to BRG (when applied to a destination). For other
|
||||
* types of color spaces, returns nullptr.
|
||||
*
|
||||
* This is used for testing, to construct color spaces that have severe and testable behavior.
|
||||
*/
|
||||
|
@ -188,14 +194,15 @@ public:
|
|||
* in some cases: converting ICC fixed point to float, converting white point to D50,
|
||||
* rounding decisions on transfer function and matrix.
|
||||
*
|
||||
* This does not consider a 2.2f exponential transfer function to be sRGB. While these
|
||||
* This does not consider a 2.2f exponential transfer function to be sRGB. While these
|
||||
* functions are similar (and it is sometimes useful to consider them together), this
|
||||
* function checks for logical equality.
|
||||
*/
|
||||
bool isSRGB() const;
|
||||
|
||||
/**
|
||||
* Returns a serialized representation of this color space.
|
||||
* Returns nullptr on failure. Fails when we fallback to serializing ICC data and
|
||||
* the data is too large to serialize.
|
||||
*/
|
||||
sk_sp<SkData> serialize() const;
|
||||
|
||||
|
@ -208,15 +215,14 @@ public:
|
|||
static sk_sp<SkColorSpace> Deserialize(const void* data, size_t length);
|
||||
|
||||
/**
|
||||
* If both are null, we return true. If one is null and the other is not, we return false.
|
||||
* If both are null, we return true. If one is null and the other is not, we return false.
|
||||
* If both are non-null, we do a deeper compare.
|
||||
*/
|
||||
static bool Equals(const SkColorSpace*, const SkColorSpace*);
|
||||
|
||||
void transferFn(float gabcdef[7]) const; // DEPRECATED: Remove when webview usage is gone
|
||||
void transferFn(skcms_TransferFunction* fn) const;
|
||||
void invTransferFn(skcms_TransferFunction* fn) const;
|
||||
void gamutTransformTo(const SkColorSpace* dst, skcms_Matrix3x3* src_to_dst) const;
|
||||
void transferFn(float gabcdef[7]) const;
|
||||
void invTransferFn(float gabcdef[7]) const;
|
||||
void gamutTransformTo(const SkColorSpace* dst, float src_to_dst_row_major[9]) const;
|
||||
|
||||
uint32_t transferFnHash() const { return fTransferFnHash; }
|
||||
uint64_t hash() const { return (uint64_t)fTransferFnHash << 32 | fToXYZD50Hash; }
|
||||
|
@ -224,18 +230,19 @@ public:
|
|||
private:
|
||||
friend class SkColorSpaceSingletonFactory;
|
||||
|
||||
SkColorSpace(const skcms_TransferFunction& transferFn, const skcms_Matrix3x3& toXYZ);
|
||||
SkColorSpace(const float transferFn[7],
|
||||
const skcms_Matrix3x3& toXYZ);
|
||||
|
||||
void computeLazyDstFields() const;
|
||||
|
||||
uint32_t fTransferFnHash;
|
||||
uint32_t fToXYZD50Hash;
|
||||
|
||||
skcms_TransferFunction fTransferFn;
|
||||
skcms_Matrix3x3 fToXYZD50;
|
||||
float fTransferFn[7];
|
||||
float fToXYZD50_3x3[9]; // row-major
|
||||
|
||||
mutable skcms_TransferFunction fInvTransferFn;
|
||||
mutable skcms_Matrix3x3 fFromXYZD50;
|
||||
mutable float fInvTransferFn[7];
|
||||
mutable float fFromXYZD50_3x3[9]; // row-major
|
||||
mutable SkOnce fLazyDstFieldsOnce;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkColorType_DEFINED
|
||||
#define SkColorType_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/** \enum SkColorType
|
||||
Describes how pixel bits encode color. A pixel may be an alpha mask, a grayscale, RGB, or ARGB.
|
||||
|
||||
kN32_SkColorType selects the native 32-bit ARGB format for the current configuration. This can
|
||||
lead to inconsistent results across platforms, so use with caution.
|
||||
*/
|
||||
enum SkColorType : int {
|
||||
kUnknown_SkColorType, //!< uninitialized
|
||||
kAlpha_8_SkColorType, //!< pixel with alpha in 8-bit byte
|
||||
kRGB_565_SkColorType, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
|
||||
kARGB_4444_SkColorType, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word
|
||||
kRGBA_8888_SkColorType, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word
|
||||
kRGB_888x_SkColorType, //!< pixel with 8 bits each for red, green, blue; in 32-bit word
|
||||
kBGRA_8888_SkColorType, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
|
||||
kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
|
||||
kBGRA_1010102_SkColorType, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
|
||||
kRGB_101010x_SkColorType, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
|
||||
kBGR_101010x_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word
|
||||
kBGR_101010x_XR_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
|
||||
kGray_8_SkColorType, //!< pixel with grayscale level in 8-bit byte
|
||||
kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha;
|
||||
// in 64-bit word
|
||||
kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha;
|
||||
// in 64-bit word
|
||||
kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
|
||||
|
||||
// The following 6 colortypes are just for reading from - not for rendering to
|
||||
kR8G8_unorm_SkColorType, //!< pixel with a uint8_t for red and green
|
||||
|
||||
kA16_float_SkColorType, //!< pixel with a half float for alpha
|
||||
kR16G16_float_SkColorType, //!< pixel with a half float for red and green
|
||||
|
||||
kA16_unorm_SkColorType, //!< pixel with a little endian uint16_t for alpha
|
||||
kR16G16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red and green
|
||||
kR16G16B16A16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red, green, blue
|
||||
// and alpha
|
||||
|
||||
kSRGBA_8888_SkColorType,
|
||||
kR8_unorm_SkColorType,
|
||||
|
||||
kLastEnum_SkColorType = kR8_unorm_SkColorType, //!< last valid value
|
||||
|
||||
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
|
||||
kN32_SkColorType = kBGRA_8888_SkColorType,//!< native 32-bit BGRA encoding
|
||||
|
||||
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
||||
kN32_SkColorType = kRGBA_8888_SkColorType,//!< native 32-bit RGBA encoding
|
||||
|
||||
#else
|
||||
kN32_SkColorType = kBGRA_8888_SkColorType,
|
||||
#endif
|
||||
};
|
||||
static constexpr int kSkColorTypeCnt = static_cast<int>(kLastEnum_SkColorType) + 1;
|
||||
|
||||
#endif
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/private/base/SkTDArray.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
struct SkConic;
|
||||
|
||||
|
@ -95,9 +95,6 @@ public:
|
|||
* Initialize the Iter with a path.
|
||||
* The parts of the path that are needed are copied, so the client is free to modify/delete
|
||||
* the path after this call.
|
||||
*
|
||||
* resScale controls the precision of the measure. values > 1 increase the
|
||||
* precision (and possibly slow down the computation).
|
||||
*/
|
||||
SkContourMeasureIter(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
|
||||
~SkContourMeasureIter();
|
||||
|
@ -123,9 +120,29 @@ public:
|
|||
sk_sp<SkContourMeasure> next();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
SkPath::RawIter fIter;
|
||||
SkPath fPath;
|
||||
SkScalar fTolerance;
|
||||
bool fForceClosed;
|
||||
|
||||
std::unique_ptr<Impl> fImpl;
|
||||
// temporary
|
||||
SkTDArray<SkContourMeasure::Segment> fSegments;
|
||||
SkTDArray<SkPoint> fPts; // Points used to define the segments
|
||||
|
||||
SkContourMeasure* buildSegments();
|
||||
|
||||
SkScalar compute_line_seg(SkPoint p0, SkPoint p1, SkScalar distance, unsigned ptIndex);
|
||||
SkScalar compute_quad_segs(const SkPoint pts[3], SkScalar distance,
|
||||
int mint, int maxt, unsigned ptIndex);
|
||||
SkScalar compute_conic_segs(const SkConic& conic, SkScalar distance,
|
||||
int mint, const SkPoint& minPt,
|
||||
int maxt, const SkPoint& maxPt,
|
||||
unsigned ptIndex);
|
||||
SkScalar compute_cubic_segs(const SkPoint pts[4], SkScalar distance,
|
||||
int mint, int maxt, unsigned ptIndex);
|
||||
|
||||
SkContourMeasureIter(const SkContourMeasureIter&) = delete;
|
||||
SkContourMeasureIter& operator=(const SkContourMeasureIter&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#ifndef SkCoverageMode_DEFINED
|
||||
#define SkCoverageMode_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Describes geometric operations (ala SkRegion::Op) that can be applied to coverage bytes.
|
||||
* These can be thought of as variants of porter-duff (SkBlendMode) modes, but only applied
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#define SkCubicMap_DEFINED
|
||||
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Fast evaluation of a cubic ease-in / ease-out curve. This is defined as a parametric cubic
|
||||
|
|
|
@ -8,12 +8,9 @@
|
|||
#ifndef SkData_DEFINED
|
||||
#define SkData_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/private/base/SkAPI.h"
|
||||
#include "include/private/base/SkAssert.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
class SkStream;
|
||||
|
||||
|
@ -54,7 +51,7 @@ public:
|
|||
// only assert we're unique if we're not empty
|
||||
SkASSERT(this->unique());
|
||||
}
|
||||
return const_cast<void*>(fPtr);
|
||||
return fPtr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,12 +86,6 @@ public:
|
|||
*/
|
||||
static sk_sp<SkData> MakeUninitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new data with zero-initialized contents. The caller should call writable_data()
|
||||
* to write into the buffer, but this must be done before another ref() is made.
|
||||
*/
|
||||
static sk_sp<SkData> MakeZeroInitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified c-string
|
||||
* (a null-terminated array of bytes). The returned SkData will have size()
|
||||
|
@ -114,7 +105,7 @@ public:
|
|||
* SkData. Suitable for with const globals.
|
||||
*/
|
||||
static sk_sp<SkData> MakeWithoutCopy(const void* data, size_t length) {
|
||||
return MakeWithProc(data, length, NoopReleaseProc, nullptr);
|
||||
return MakeWithProc(data, length, DummyReleaseProc, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +161,7 @@ private:
|
|||
friend class SkNVRefCnt<SkData>;
|
||||
ReleaseProc fReleaseProc;
|
||||
void* fReleaseProcContext;
|
||||
const void* fPtr;
|
||||
void* fPtr;
|
||||
size_t fSize;
|
||||
|
||||
SkData(const void* ptr, size_t size, ReleaseProc, void* context);
|
||||
|
@ -183,9 +174,9 @@ private:
|
|||
// shared internal factory
|
||||
static sk_sp<SkData> PrivateNewWithCopy(const void* srcOrNull, size_t length);
|
||||
|
||||
static void NoopReleaseProc(const void*, void*); // {}
|
||||
static void DummyReleaseProc(const void*, void*); // {}
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,12 +8,9 @@
|
|||
#ifndef SkDataTable_DEFINED
|
||||
#define SkDataTable_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/private/base/SkAPI.h"
|
||||
#include "include/private/base/SkAssert.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
/**
|
||||
* Like SkData, SkDataTable holds an immutable data buffer. The data buffer is
|
||||
|
@ -112,11 +109,11 @@ private:
|
|||
SkDataTable(const void* array, size_t elemSize, int count,
|
||||
FreeProc, void* context);
|
||||
SkDataTable(const Dir*, int count, FreeProc, void* context);
|
||||
~SkDataTable() override;
|
||||
virtual ~SkDataTable();
|
||||
|
||||
friend class SkDataTableBuilder; // access to Dir
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDeferredDisplayList_DEFINED
|
||||
#define SkDeferredDisplayList_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSurfaceCharacterization.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkDeferredDisplayListPriv;
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "include/private/base/SkTArray.h"
|
||||
#include <map>
|
||||
class GrRenderTask;
|
||||
class GrRenderTargetProxy;
|
||||
#else
|
||||
using GrRenderTargetProxy = SkRefCnt;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This class contains pre-processed gpu operations that can be replayed into
|
||||
* an SkSurface via SkSurface::draw(SkDeferredDisplayList*).
|
||||
*/
|
||||
class SkDeferredDisplayList : public SkNVRefCnt<SkDeferredDisplayList> {
|
||||
public:
|
||||
SK_API ~SkDeferredDisplayList();
|
||||
|
||||
SK_API const SkSurfaceCharacterization& characterization() const {
|
||||
return fCharacterization;
|
||||
}
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
/**
|
||||
* Iterate through the programs required by the DDL.
|
||||
*/
|
||||
class SK_API ProgramIterator {
|
||||
public:
|
||||
ProgramIterator(GrDirectContext*, SkDeferredDisplayList*);
|
||||
~ProgramIterator();
|
||||
|
||||
// This returns true if any work was done. Getting a cache hit does not count as work.
|
||||
bool compile();
|
||||
bool done() const;
|
||||
void next();
|
||||
|
||||
private:
|
||||
GrDirectContext* fDContext;
|
||||
const SkTArray<GrRecordingContext::ProgramData>& fProgramData;
|
||||
int fIndex;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Provides access to functions that aren't part of the public API.
|
||||
SkDeferredDisplayListPriv priv();
|
||||
const SkDeferredDisplayListPriv priv() const; // NOLINT(readability-const-return-type)
|
||||
|
||||
private:
|
||||
friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fArenas'
|
||||
friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
|
||||
friend class SkDeferredDisplayListPriv;
|
||||
|
||||
// This object is the source from which the lazy proxy backing the DDL will pull its backing
|
||||
// texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
|
||||
// can outlive the DDL.
|
||||
class LazyProxyData : public SkRefCnt {
|
||||
#if defined(SK_GANESH)
|
||||
public:
|
||||
// Upon being replayed - this field will be filled in (by the DrawingManager) with the
|
||||
// proxy backing the destination SkSurface. Note that, since there is no good place to
|
||||
// clear it, it can become a dangling pointer. Additionally, since the renderTargetProxy
|
||||
// doesn't get a ref here, the SkSurface that owns it must remain alive until the DDL
|
||||
// is flushed.
|
||||
// TODO: the drawing manager could ref the renderTargetProxy for the DDL and then add
|
||||
// a renderingTask to unref it after the DDL's ops have been executed.
|
||||
GrRenderTargetProxy* fReplayDest = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
|
||||
sk_sp<GrRenderTargetProxy> fTargetProxy,
|
||||
sk_sp<LazyProxyData>);
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
const SkTArray<GrRecordingContext::ProgramData>& programData() const {
|
||||
return fProgramData;
|
||||
}
|
||||
#endif
|
||||
|
||||
const SkSurfaceCharacterization fCharacterization;
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
// These are ordered such that the destructor cleans op tasks up first (which may refer back
|
||||
// to the arena and memory pool in their destructors).
|
||||
GrRecordingContext::OwnedArenas fArenas;
|
||||
SkTArray<sk_sp<GrRenderTask>> fRenderTasks;
|
||||
|
||||
SkTArray<GrRecordingContext::ProgramData> fProgramData;
|
||||
sk_sp<GrRenderTargetProxy> fTargetProxy;
|
||||
sk_sp<LazyProxyData> fLazyProxyData;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
|
@ -8,24 +8,26 @@
|
|||
#ifndef SkDeferredDisplayListRecorder_DEFINED
|
||||
#define SkDeferredDisplayListRecorder_DEFINED
|
||||
|
||||
#include "include/core/SkDeferredDisplayList.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSurfaceCharacterization.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/SkDeferredDisplayList.h"
|
||||
|
||||
class GrBackendFormat;
|
||||
class GrBackendTexture;
|
||||
class GrRecordingContext;
|
||||
class GrYUVABackendTextureInfo;
|
||||
class GrContext;
|
||||
class SkCanvas;
|
||||
class SkImage;
|
||||
class SkPromiseImageTexture;
|
||||
class SkSurface;
|
||||
struct SkYUVAIndex;
|
||||
struct SkYUVASizeInfo;
|
||||
|
||||
/*
|
||||
* This class is intended to be used as:
|
||||
* Get an SkSurfaceCharacterization representing the intended gpu-backed destination SkSurface
|
||||
* Create one of these (an SkDeferredDisplayListRecorder) on the stack
|
||||
* Create one of these (an SkDDLMaker) on the stack
|
||||
* Get the canvas and render into it
|
||||
* Snap off and hold on to an SkDeferredDisplayList
|
||||
* Once your app actually needs the pixels, call SkSurface::draw(SkDeferredDisplayList*)
|
||||
|
@ -48,47 +50,121 @@ public:
|
|||
// Note: ownership of the SkCanvas is not transferred via this call.
|
||||
SkCanvas* getCanvas();
|
||||
|
||||
sk_sp<SkDeferredDisplayList> detach();
|
||||
std::unique_ptr<SkDeferredDisplayList> detach();
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
using PromiseImageTextureContext = SkImage::PromiseImageTextureContext;
|
||||
using PromiseImageTextureFulfillProc = SkImage::PromiseImageTextureFulfillProc;
|
||||
using PromiseImageTextureReleaseProc = SkImage::PromiseImageTextureReleaseProc;
|
||||
using PromiseImageTextureContext = void*;
|
||||
using PromiseImageTextureFulfillProc =
|
||||
sk_sp<SkPromiseImageTexture> (*)(PromiseImageTextureContext);
|
||||
using PromiseImageTextureReleaseProc = void (*)(PromiseImageTextureContext);
|
||||
using PromiseImageTextureDoneProc = void (*)(PromiseImageTextureContext);
|
||||
|
||||
#ifndef SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
|
||||
/** Deprecated: Use SkImage::MakePromiseTexture instead. */
|
||||
sk_sp<SkImage> makePromiseTexture(const GrBackendFormat& backendFormat,
|
||||
int width,
|
||||
int height,
|
||||
GrMipmapped mipmapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureContext textureContext);
|
||||
enum class PromiseImageApiVersion { kLegacy, kNew };
|
||||
|
||||
/** Deprecated: Use SkImage::MakePromiseYUVATexture instead. */
|
||||
sk_sp<SkImage> makeYUVAPromiseTexture(const GrYUVABackendTextureInfo& yuvaBackendTextureInfo,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureContext textureContexts[]);
|
||||
#endif // SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
|
||||
#endif // defined(SK_GANESH)
|
||||
/**
|
||||
Create a new SkImage that is very similar to an SkImage created by MakeFromTexture. The
|
||||
difference is that the caller need not have created the texture nor populated it with the
|
||||
image pixel data. Moreover, the SkImage may be created on a thread as the creation of the
|
||||
image does not require access to the backend API or GrContext. Instead of passing a
|
||||
GrBackendTexture the client supplies a description of the texture consisting of
|
||||
GrBackendFormat, width, height, and GrMipMapped state. The resulting SkImage can be drawn
|
||||
to a SkDeferredDisplayListRecorder or directly to a GPU-backed SkSurface.
|
||||
|
||||
When the actual texture is required to perform a backend API draw, textureFulfillProc will
|
||||
be called to receive a GrBackendTexture. The properties of the GrBackendTexture must match
|
||||
those set during the SkImage creation, and it must refer to a valid existing texture in the
|
||||
backend API context/device, and be populated with the image pixel data. The texture contents
|
||||
cannot be modified until textureReleaseProc is called. The texture cannot be deleted until
|
||||
textureDoneProc is called.
|
||||
|
||||
When all the following are true:
|
||||
* the promise SkImage is deleted,
|
||||
* any SkDeferredDisplayLists that recorded draws referencing the image are deleted,
|
||||
* and all draws referencing the texture have been flushed (via GrContext::flush or
|
||||
SkSurface::flush)
|
||||
the textureReleaseProc is called. When the following additional constraint is met
|
||||
* the texture is safe to delete in the underlying API
|
||||
the textureDoneProc is called. For some APIs (e.g. GL) the two states are equivalent.
|
||||
However, for others (e.g. Vulkan) they are not as it is not legal to delete a texture until
|
||||
the GPU work referencing it has completed.
|
||||
|
||||
There is at most one call to each of textureFulfillProc, textureReleaseProc, and
|
||||
textureDoneProc. textureDoneProc is always called even if image creation fails or if the
|
||||
image is never fulfilled (e.g. it is never drawn or all draws are clipped out). If
|
||||
textureFulfillProc is called then textureReleaseProc will always be called even if
|
||||
textureFulfillProc failed.
|
||||
|
||||
If 'version' is set to kLegacy then the textureReleaseProc call is delayed until the
|
||||
conditions for textureDoneProc are met and then they are both called.
|
||||
|
||||
This call is only valid if the SkDeferredDisplayListRecorder is backed by a GPU context.
|
||||
|
||||
@param backendFormat format of promised gpu texture
|
||||
@param width width of promised gpu texture
|
||||
@param height height of promised gpu texture
|
||||
@param mipMapped mip mapped state of promised gpu texture
|
||||
@param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
|
||||
@param colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType,
|
||||
kRGB_565_SkColorType, kARGB_4444_SkColorType,
|
||||
kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
||||
@param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType,
|
||||
kPremul_SkAlphaType, kUnpremul_SkAlphaType
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@param textureFulfillProc function called to get actual gpu texture
|
||||
@param textureReleaseProc function called when texture can be released
|
||||
@param textureDoneProc function called when we will no longer call textureFulfillProc
|
||||
@param textureContext state passed to textureFulfillProc and textureReleaseProc
|
||||
@param version controls when textureReleaseProc is called
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
sk_sp<SkImage> makePromiseTexture(
|
||||
const GrBackendFormat& backendFormat,
|
||||
int width,
|
||||
int height,
|
||||
GrMipMapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureDoneProc textureDoneProc,
|
||||
PromiseImageTextureContext textureContext,
|
||||
PromiseImageApiVersion version = PromiseImageApiVersion::kLegacy);
|
||||
|
||||
/**
|
||||
This entry point operates like 'makePromiseTexture' but it is used to construct a SkImage
|
||||
from YUV[A] data. The source data may be planar (i.e. spread across multiple textures). In
|
||||
the extreme Y, U, V, and A are all in different planes and thus the image is specified by
|
||||
four textures. 'yuvaIndices' specifies the mapping from texture color channels to Y, U, V,
|
||||
and possibly A components. It therefore indicates how many unique textures compose the full
|
||||
image. Separate textureFulfillProc, textureReleaseProc, and textureDoneProc calls are made
|
||||
for each texture and each texture has its own PromiseImageTextureContext. 'yuvFormats',
|
||||
'yuvaSizes', and 'textureContexts' have one entry for each of the up to four textures, as
|
||||
indicated by 'yuvaIndices'.
|
||||
*/
|
||||
sk_sp<SkImage> makeYUVAPromiseTexture(
|
||||
SkYUVColorSpace yuvColorSpace,
|
||||
const GrBackendFormat yuvaFormats[],
|
||||
const SkISize yuvaSizes[],
|
||||
const SkYUVAIndex yuvaIndices[4],
|
||||
int imageWidth,
|
||||
int imageHeight,
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureDoneProc textureDoneProc,
|
||||
PromiseImageTextureContext textureContexts[],
|
||||
PromiseImageApiVersion version = PromiseImageApiVersion::kLegacy);
|
||||
|
||||
private:
|
||||
SkDeferredDisplayListRecorder(const SkDeferredDisplayListRecorder&) = delete;
|
||||
SkDeferredDisplayListRecorder& operator=(const SkDeferredDisplayListRecorder&) = delete;
|
||||
|
||||
bool init();
|
||||
|
||||
const SkSurfaceCharacterization fCharacterization;
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
sk_sp<GrRecordingContext> fContext;
|
||||
sk_sp<GrRenderTargetProxy> fTargetProxy;
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrContext> fContext;
|
||||
sk_sp<SkDeferredDisplayList::LazyProxyData> fLazyProxyData;
|
||||
sk_sp<SkSurface> fSurface;
|
||||
#endif
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
#ifndef SkDeque_DEFINED
|
||||
#define SkDeque_DEFINED
|
||||
|
||||
#include "include/private/base/SkAPI.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/*
|
||||
* The deque class works by blindly creating memory space of a specified element
|
||||
|
@ -110,7 +108,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
using INHERITED = Iter;
|
||||
typedef Iter INHERITED;
|
||||
};
|
||||
|
||||
private:
|
|
@ -64,7 +64,7 @@ protected:
|
|||
|
||||
// note: subclasses must call close() in their destructor, as the base class
|
||||
// cannot do this for them.
|
||||
~SkDocument() override;
|
||||
virtual ~SkDocument();
|
||||
|
||||
virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height) = 0;
|
||||
virtual void onEndPage() = 0;
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
SkWStream* fStream;
|
||||
State fState;
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,18 +16,19 @@
|
|||
#include "include/core/SkPoint.h"
|
||||
#include <functional> // std::function
|
||||
|
||||
#ifndef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
#error "SkDrawLooper is unsupported"
|
||||
#endif
|
||||
|
||||
class SkArenaAlloc;
|
||||
class SkCanvas;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
struct SkRect;
|
||||
class SkString;
|
||||
|
||||
/** \class SkDrawLooper
|
||||
DEPRECATED: No longer supported in Skia.
|
||||
Subclasses of SkDrawLooper can be attached to a SkPaint. Where they are,
|
||||
and something is drawn to a canvas with that paint, the looper subclass will
|
||||
be called, allowing it to modify the canvas and/or paint for that draw call.
|
||||
More than that, via the next() method, the looper can modify the draw to be
|
||||
invoked multiple times (hence the name loop-er), allow it to perform effects
|
||||
like shadows or frame/fills, that require more than one pass.
|
||||
*/
|
||||
class SK_API SkDrawLooper : public SkFlattenable {
|
||||
public:
|
||||
|
@ -129,7 +130,7 @@ protected:
|
|||
SkDrawLooper() {}
|
||||
|
||||
private:
|
||||
using INHERITED = SkFlattenable;
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,22 +9,14 @@
|
|||
#define SkDrawable_DEFINED
|
||||
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/private/base/SkAPI.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
class GrBackendDrawableInfo;
|
||||
class SkCanvas;
|
||||
class SkMatrix;
|
||||
class SkPicture;
|
||||
enum class GrBackendApi : unsigned int;
|
||||
struct SkDeserialProcs;
|
||||
struct SkIRect;
|
||||
struct SkImageInfo;
|
||||
enum class GrBackendApi : unsigned;
|
||||
struct SkRect;
|
||||
|
||||
/**
|
||||
|
@ -111,12 +103,6 @@ public:
|
|||
*/
|
||||
SkRect getBounds();
|
||||
|
||||
/**
|
||||
* Return approximately how many bytes would be freed if this drawable is destroyed.
|
||||
* The base implementation returns 0 to indicate that this is unknown.
|
||||
*/
|
||||
size_t approximateBytesUsed();
|
||||
|
||||
/**
|
||||
* Calling this invalidates the previous generation ID, and causes a new one to be computed
|
||||
* the next time getGenerationID() is called. Typically this is called by the object itself,
|
||||
|
@ -146,7 +132,6 @@ protected:
|
|||
SkDrawable();
|
||||
|
||||
virtual SkRect onGetBounds() = 0;
|
||||
virtual size_t onApproximateBytesUsed();
|
||||
virtual void onDraw(SkCanvas*) = 0;
|
||||
|
||||
virtual std::unique_ptr<GpuDrawHandler> onSnapGpuDrawHandler(GrBackendApi, const SkMatrix&,
|
||||
|
|
|
@ -1,9 +1,34 @@
|
|||
/*
|
||||
* Copyright 2023 Google LLC
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// TODO(kjlubick) remove this shim after clients have been moved to the new location
|
||||
#include "include/codec/SkEncodedImageFormat.h" // IWYU pragma: export
|
||||
#ifndef SkEncodedImageFormat_DEFINED
|
||||
#define SkEncodedImageFormat_DEFINED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Enum describing format of encoded data.
|
||||
*/
|
||||
enum class SkEncodedImageFormat {
|
||||
#ifdef SK_BUILD_FOR_GOOGLE3
|
||||
kUnknown,
|
||||
#endif
|
||||
kBMP,
|
||||
kGIF,
|
||||
kICO,
|
||||
kJPEG,
|
||||
kPNG,
|
||||
kWBMP,
|
||||
kWEBP,
|
||||
kPKM,
|
||||
kKTX,
|
||||
kASTC,
|
||||
kDNG,
|
||||
kHEIF,
|
||||
};
|
||||
|
||||
#endif // SkEncodedImageFormat_DEFINED
|
||||
|
|
|
@ -17,10 +17,8 @@ public:
|
|||
virtual ~SkExecutor();
|
||||
|
||||
// Create a thread pool SkExecutor with a fixed thread count, by default the number of cores.
|
||||
static std::unique_ptr<SkExecutor> MakeFIFOThreadPool(int threads = 0,
|
||||
bool allowBorrowing = true);
|
||||
static std::unique_ptr<SkExecutor> MakeLIFOThreadPool(int threads = 0,
|
||||
bool allowBorrowing = true);
|
||||
static std::unique_ptr<SkExecutor> MakeFIFOThreadPool(int threads = 0);
|
||||
static std::unique_ptr<SkExecutor> MakeLIFOThreadPool(int threads = 0);
|
||||
|
||||
// There is always a default SkExecutor available by calling SkExecutor::GetDefault().
|
||||
static SkExecutor& GetDefault();
|
||||
|
@ -31,11 +29,6 @@ public:
|
|||
|
||||
// If it makes sense for this executor, use this thread to execute work for a little while.
|
||||
virtual void borrow() {}
|
||||
|
||||
protected:
|
||||
SkExecutor() = default;
|
||||
SkExecutor(const SkExecutor&) = delete;
|
||||
SkExecutor& operator=(const SkExecutor&) = delete;
|
||||
};
|
||||
|
||||
#endif//SkExecutor_DEFINED
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFilterQuality_DEFINED
|
||||
#define SkFilterQuality_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Controls how much filtering to be done when scaling/transforming complex colors
|
||||
* e.g. images
|
||||
*/
|
||||
enum SkFilterQuality {
|
||||
kNone_SkFilterQuality, //!< fastest but lowest quality, typically nearest-neighbor
|
||||
kLow_SkFilterQuality, //!< typically bilerp
|
||||
kMedium_SkFilterQuality, //!< typically bilerp + mipmaps for down-scaling
|
||||
kHigh_SkFilterQuality, //!< slowest but highest quality, typically bicubic or better
|
||||
|
||||
kLast_SkFilterQuality = kHigh_SkFilterQuality,
|
||||
};
|
||||
|
||||
#endif
|
|
@ -9,15 +9,13 @@
|
|||
#define SkFlattenable_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class SkData;
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
struct SkDeserialProcs;
|
||||
|
||||
struct SkSerialProcs;
|
||||
struct SkDeserialProcs;
|
||||
|
||||
/** \class SkFlattenable
|
||||
|
||||
|
@ -29,13 +27,17 @@ class SK_API SkFlattenable : public SkRefCnt {
|
|||
public:
|
||||
enum Type {
|
||||
kSkColorFilter_Type,
|
||||
kSkBlender_Type,
|
||||
kSkDrawable_Type,
|
||||
kSkDrawLooper_Type, // no longer used internally by Skia
|
||||
kSkDrawLooper_Type,
|
||||
kSkImageFilter_Type,
|
||||
kSkMaskFilter_Type,
|
||||
kSkPathEffect_Type,
|
||||
kSkShader_Type,
|
||||
kSkPixelRef_Type,
|
||||
kSkUnused_Type4, // used to be SkRasterizer
|
||||
kSkShaderBase_Type,
|
||||
kSkUnused_Type, // used to be SkUnitMapper
|
||||
kSkUnused_Type2,
|
||||
kSkNormalSource_Type,
|
||||
};
|
||||
|
||||
typedef sk_sp<SkFlattenable> (*Factory)(SkReadBuffer&);
|
||||
|
@ -90,26 +92,15 @@ private:
|
|||
|
||||
friend class SkGraphics;
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
#if defined(SK_DISABLE_EFFECT_DESERIALIZATION)
|
||||
#define SK_REGISTER_FLATTENABLE(type) do{}while(false)
|
||||
#define SK_REGISTER_FLATTENABLE(type) SkFlattenable::Register(#type, type::CreateProc)
|
||||
|
||||
#define SK_FLATTENABLE_HOOKS(type) \
|
||||
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
|
||||
friend class SkFlattenable::PrivateInitializer; \
|
||||
Factory getFactory() const override { return nullptr; } \
|
||||
const char* getTypeName() const override { return #type; }
|
||||
#else
|
||||
#define SK_REGISTER_FLATTENABLE(type) \
|
||||
SkFlattenable::Register(#type, type::CreateProc)
|
||||
|
||||
#define SK_FLATTENABLE_HOOKS(type) \
|
||||
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
|
||||
friend class SkFlattenable::PrivateInitializer; \
|
||||
Factory getFactory() const override { return type::CreateProc; } \
|
||||
const char* getTypeName() const override { return #type; }
|
||||
#endif
|
||||
#define SK_FLATTENABLE_HOOKS(type) \
|
||||
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
|
||||
friend class SkFlattenable::PrivateInitializer; \
|
||||
Factory getFactory() const override { return type::CreateProc; } \
|
||||
const char* getTypeName() const override { return #type; }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
#include "include/core/SkFontTypes.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
#include "include/private/base/SkTemplates.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
|
@ -167,20 +164,30 @@ public:
|
|||
void setBaselineSnap(bool baselineSnap);
|
||||
|
||||
/** Whether edge pixels draw opaque or with partial transparency.
|
||||
|
||||
@return one of: Edging::kAlias, Edging::kAntiAlias, Edging::kSubpixelAntiAlias
|
||||
*/
|
||||
Edging getEdging() const { return (Edging)fEdging; }
|
||||
|
||||
/** Requests, but does not require, that edge pixels draw opaque or with
|
||||
partial transparency.
|
||||
|
||||
@param edging one of: Edging::kAlias, Edging::kAntiAlias, Edging::kSubpixelAntiAlias
|
||||
*/
|
||||
void setEdging(Edging edging);
|
||||
|
||||
/** Sets level of glyph outline adjustment.
|
||||
Does not check for valid values of hintingLevel.
|
||||
|
||||
@param hintingLevel one of: SkFontHinting::kNone, SkFontHinting::kSlight,
|
||||
SkFontHinting::kNormal, SkFontHinting::kFull
|
||||
*/
|
||||
void setHinting(SkFontHinting hintingLevel);
|
||||
|
||||
/** Returns level of glyph outline adjustment.
|
||||
|
||||
@return one of: SkFontHinting::kNone, SkFontHinting::kSlight, SkFontHinting::kNormal,
|
||||
SkFontHinting::kFull
|
||||
*/
|
||||
SkFontHinting getHinting() const { return (SkFontHinting)fHinting; }
|
||||
|
||||
|
@ -293,6 +300,8 @@ public:
|
|||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
|
||||
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
|
||||
@param glyphs storage for glyph indices; may be nullptr
|
||||
@param maxGlyphCount storage capacity
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
|
@ -319,6 +328,8 @@ public:
|
|||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
|
||||
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
int countText(const void* text, size_t byteLength, SkTextEncoding encoding) const {
|
||||
|
@ -331,8 +342,10 @@ public:
|
|||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
|
||||
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
|
||||
@param bounds returns bounding box relative to (0, 0) if not nullptr
|
||||
@return the sum of the default advance widths
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||
SkRect* bounds = nullptr) const {
|
||||
|
@ -341,14 +354,16 @@ public:
|
|||
|
||||
/** Returns the advance width of text.
|
||||
The advance is the normal distance to move before drawing additional text.
|
||||
Returns the bounding box of text if bounds is not nullptr. The paint
|
||||
stroke settings, mask filter, or path effect may modify the bounds.
|
||||
Returns the bounding box of text if bounds is not nullptr. paint
|
||||
stroke width or SkPathEffect may modify the advance with.
|
||||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
|
||||
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
|
||||
@param bounds returns bounding box relative to (0, 0) if not nullptr
|
||||
@param paint optional; may be nullptr
|
||||
@return the sum of the default advance widths
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||
SkRect* bounds, const SkPaint* paint) const;
|
||||
|
@ -435,23 +450,9 @@ public:
|
|||
*/
|
||||
void getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const;
|
||||
|
||||
/** Returns intervals [start, end] describing lines parallel to the advance that intersect
|
||||
* with the glyphs.
|
||||
*
|
||||
* @param glyphs the glyphs to intersect
|
||||
* @param count the number of glyphs and positions
|
||||
* @param pos the position of each glyph
|
||||
* @param top the top of the line intersecting
|
||||
* @param bottom the bottom of the line intersecting
|
||||
@return array of pairs of x values [start, end]. May be empty.
|
||||
*/
|
||||
std::vector<SkScalar> getIntercepts(const SkGlyphID glyphs[], int count, const SkPoint pos[],
|
||||
SkScalar top, SkScalar bottom,
|
||||
const SkPaint* = nullptr) const;
|
||||
|
||||
/** Modifies path to be the outline of the glyph.
|
||||
If the glyph has an outline, modifies path to be the glyph's outline and returns true.
|
||||
The glyph outline may be empty. Degenerate contours in the glyph outline will be skipped.
|
||||
/** Returns path corresponding to glyph outline.
|
||||
If glyph has an outline, copies outline to path and returns true.
|
||||
path returned may be empty.
|
||||
If glyph is described by a bitmap, returns false and ignores path parameter.
|
||||
|
||||
@param glyphID index of glyph
|
||||
|
@ -499,8 +500,6 @@ public:
|
|||
*/
|
||||
void dump() const;
|
||||
|
||||
using sk_is_trivially_relocatable = std::true_type;
|
||||
|
||||
private:
|
||||
enum PrivFlags {
|
||||
kForceAutoHinting_PrivFlag = 1 << 0,
|
||||
|
@ -526,15 +525,14 @@ private:
|
|||
uint8_t fEdging;
|
||||
uint8_t fHinting;
|
||||
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fTypeface)>::value);
|
||||
|
||||
SkScalar setupForAsPaths(SkPaint*);
|
||||
bool hasSomeAntiAliasing() const;
|
||||
|
||||
friend class GrTextBlob;
|
||||
friend class SkFontPriv;
|
||||
friend class SkGlyphRunListPainterCPU;
|
||||
friend class SkGlyphRunListPainter;
|
||||
friend class SkTextBlobCacheDiffCanvas;
|
||||
friend class SkStrikeSpec;
|
||||
friend class SkRemoteGlyphCacheTest;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#ifndef SkFontArguments_DEFINED
|
||||
#define SkFontArguments_DEFINED
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
|
@ -22,28 +21,13 @@ struct SkFontArguments {
|
|||
const Coordinate* coordinates;
|
||||
int coordinateCount;
|
||||
};
|
||||
|
||||
/** Specify a palette to use and overrides for palette entries.
|
||||
*
|
||||
* `overrides` is a list of pairs of palette entry index and color.
|
||||
* The overriden palette entries will use the associated color.
|
||||
* Override pairs with palette entry indices out of range will not be applied.
|
||||
* Later override entries override earlier ones.
|
||||
*/
|
||||
struct Palette {
|
||||
struct Override {
|
||||
int index;
|
||||
SkColor color;
|
||||
};
|
||||
int index;
|
||||
const Override* overrides;
|
||||
int overrideCount;
|
||||
// deprecated, use VariationPosition::Coordinate instead
|
||||
struct Axis {
|
||||
SkFourByteTag fTag;
|
||||
float fStyleValue;
|
||||
};
|
||||
|
||||
SkFontArguments()
|
||||
: fCollectionIndex(0)
|
||||
, fVariationDesignPosition{nullptr, 0}
|
||||
, fPalette{0, nullptr, 0} {}
|
||||
SkFontArguments() : fCollectionIndex(0), fVariationDesignPosition{nullptr, 0} {}
|
||||
|
||||
/** Specify the index of the desired font.
|
||||
*
|
||||
|
@ -55,6 +39,14 @@ struct SkFontArguments {
|
|||
return *this;
|
||||
}
|
||||
|
||||
// deprecated, use setVariationDesignPosition instead.
|
||||
SkFontArguments& setAxes(const Axis* axes, int axisCount) {
|
||||
fVariationDesignPosition.coordinates =
|
||||
reinterpret_cast<const VariationPosition::Coordinate*>(axes);
|
||||
fVariationDesignPosition.coordinateCount = axisCount;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Specify a position in the variation design space.
|
||||
*
|
||||
* Any axis not specified will use the default value.
|
||||
|
@ -71,24 +63,17 @@ struct SkFontArguments {
|
|||
int getCollectionIndex() const {
|
||||
return fCollectionIndex;
|
||||
}
|
||||
|
||||
// deprecated, use getVariationDesignPosition instead.
|
||||
const Axis* getAxes(int* axisCount) const {
|
||||
*axisCount = fVariationDesignPosition.coordinateCount;
|
||||
return reinterpret_cast<const Axis*>(fVariationDesignPosition.coordinates);
|
||||
}
|
||||
VariationPosition getVariationDesignPosition() const {
|
||||
return fVariationDesignPosition;
|
||||
}
|
||||
|
||||
SkFontArguments& setPalette(Palette palette) {
|
||||
fPalette.index = palette.index;
|
||||
fPalette.overrides = palette.overrides;
|
||||
fPalette.overrideCount = palette.overrideCount;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Palette getPalette() const { return fPalette; }
|
||||
|
||||
private:
|
||||
int fCollectionIndex;
|
||||
VariationPosition fVariationDesignPosition;
|
||||
Palette fPalette;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontLCDConfig_DEFINED
|
||||
#define SkFontLCDConfig_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SK_API SkFontLCDConfig {
|
||||
public:
|
||||
/** LCDs either have their color elements arranged horizontally or
|
||||
vertically. When rendering subpixel glyphs we need to know which way
|
||||
round they are.
|
||||
|
||||
Note, if you change this after startup, you'll need to flush the glyph
|
||||
cache because it'll have the wrong type of masks cached.
|
||||
|
||||
@deprecated use SkPixelGeometry instead.
|
||||
*/
|
||||
enum LCDOrientation {
|
||||
kHorizontal_LCDOrientation = 0, //!< this is the default
|
||||
kVertical_LCDOrientation = 1,
|
||||
};
|
||||
|
||||
/** @deprecated set on Device creation. */
|
||||
static void SetSubpixelOrientation(LCDOrientation orientation);
|
||||
/** @deprecated get from Device. */
|
||||
static LCDOrientation GetSubpixelOrientation();
|
||||
|
||||
/** LCD color elements can vary in order. For subpixel text we need to know
|
||||
the order which the LCDs uses so that the color fringes are in the
|
||||
correct place.
|
||||
|
||||
Note, if you change this after startup, you'll need to flush the glyph
|
||||
cache because it'll have the wrong type of masks cached.
|
||||
|
||||
kNONE_LCDOrder means that the subpixel elements are not spatially
|
||||
separated in any usable fashion.
|
||||
|
||||
@deprecated use SkPixelGeometry instead.
|
||||
*/
|
||||
enum LCDOrder {
|
||||
kRGB_LCDOrder = 0, //!< this is the default
|
||||
kBGR_LCDOrder = 1,
|
||||
kNONE_LCDOrder = 2,
|
||||
};
|
||||
|
||||
/** @deprecated set on Device creation. */
|
||||
static void SetSubpixelOrder(LCDOrder order);
|
||||
/** @deprecated get from Device. */
|
||||
static LCDOrder GetSubpixelOrder();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -9,32 +9,12 @@
|
|||
#define SkFontMetrics_DEFINED
|
||||
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/private/base/SkTo.h"
|
||||
|
||||
/** \class SkFontMetrics
|
||||
The metrics of an SkFont.
|
||||
The metric values are consistent with the Skia y-down coordinate system.
|
||||
*/
|
||||
struct SK_API SkFontMetrics {
|
||||
bool operator==(const SkFontMetrics& that) {
|
||||
return
|
||||
this->fFlags == that.fFlags &&
|
||||
this->fTop == that.fTop &&
|
||||
this->fAscent == that.fAscent &&
|
||||
this->fDescent == that.fDescent &&
|
||||
this->fBottom == that.fBottom &&
|
||||
this->fLeading == that.fLeading &&
|
||||
this->fAvgCharWidth == that.fAvgCharWidth &&
|
||||
this->fMaxCharWidth == that.fMaxCharWidth &&
|
||||
this->fXMin == that.fXMin &&
|
||||
this->fXMax == that.fXMax &&
|
||||
this->fXHeight == that.fXHeight &&
|
||||
this->fCapHeight == that.fCapHeight &&
|
||||
this->fUnderlineThickness == that.fUnderlineThickness &&
|
||||
this->fUnderlinePosition == that.fUnderlinePosition &&
|
||||
this->fStrikeoutThickness == that.fStrikeoutThickness &&
|
||||
this->fStrikeoutPosition == that.fStrikeoutPosition;
|
||||
}
|
||||
|
||||
/** \enum FontMetricsFlags
|
||||
FontMetricsFlags indicate when certain metrics are valid;
|
||||
|
@ -46,7 +26,6 @@ struct SK_API SkFontMetrics {
|
|||
kUnderlinePositionIsValid_Flag = 1 << 1, //!< set if fUnderlinePosition is valid
|
||||
kStrikeoutThicknessIsValid_Flag = 1 << 2, //!< set if fStrikeoutThickness is valid
|
||||
kStrikeoutPositionIsValid_Flag = 1 << 3, //!< set if fStrikeoutPosition is valid
|
||||
kBoundsInvalid_Flag = 1 << 4, //!< set if fTop, fBottom, fXMin, fXMax invalid
|
||||
};
|
||||
|
||||
uint32_t fFlags; //!< FontMetricsFlags indicating which metrics are valid
|
||||
|
@ -126,14 +105,6 @@ struct SK_API SkFontMetrics {
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if SkFontMetrics has a valid fTop, fBottom, fXMin, and fXMax.
|
||||
If the bounds are not valid, return false.
|
||||
|
||||
@return true if font specifies maximum glyph bounds
|
||||
*/
|
||||
bool hasBounds() const {
|
||||
return !SkToBool(fFlags & kBoundsInvalid_Flag);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SkData;
|
||||
class SkFontData;
|
||||
class SkStreamAsset;
|
||||
|
@ -34,7 +32,7 @@ protected:
|
|||
SkTypeface* matchStyleCSS3(const SkFontStyle& pattern);
|
||||
|
||||
private:
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
class SK_API SkFontMgr : public SkRefCnt {
|
||||
|
@ -89,6 +87,8 @@ public:
|
|||
const char* bcp47[], int bcp47Count,
|
||||
SkUnichar character) const;
|
||||
|
||||
SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&) const;
|
||||
|
||||
/**
|
||||
* Create a typeface for the specified data and TTC index (pass 0 for none)
|
||||
* or NULL if the data is not recognized. The caller must call unref() on
|
||||
|
@ -106,6 +106,13 @@ public:
|
|||
/* Experimental, API subject to change. */
|
||||
sk_sp<SkTypeface> makeFromStream(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const;
|
||||
|
||||
/**
|
||||
* Create a typeface from the specified font data.
|
||||
* Will return NULL if the typeface could not be created.
|
||||
* The caller must call unref() on the returned object if it is not null.
|
||||
*/
|
||||
sk_sp<SkTypeface> makeFromFontData(std::unique_ptr<SkFontData>) const;
|
||||
|
||||
/**
|
||||
* Create a typeface for the specified fileName and TTC index
|
||||
* (pass 0 for none) or NULL if the file is not found, or its contents are
|
||||
|
@ -119,9 +126,6 @@ public:
|
|||
/** Return the default fontmgr. */
|
||||
static sk_sp<SkFontMgr> RefDefault();
|
||||
|
||||
/* Returns an empty font manager without any typeface dependencies */
|
||||
static sk_sp<SkFontMgr> RefEmpty();
|
||||
|
||||
protected:
|
||||
virtual int onCountFamilies() const = 0;
|
||||
virtual void onGetFamilyName(int index, SkString* familyName) const = 0;
|
||||
|
@ -135,28 +139,25 @@ protected:
|
|||
virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
|
||||
const char* bcp47[], int bcp47Count,
|
||||
SkUnichar character) const = 0;
|
||||
virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
|
||||
const SkFontStyle&) const = 0;
|
||||
|
||||
virtual sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const = 0;
|
||||
virtual sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>,
|
||||
int ttcIndex) const = 0;
|
||||
virtual sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
|
||||
const SkFontArguments&) const = 0;
|
||||
const SkFontArguments&) const;
|
||||
virtual sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const;
|
||||
virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const = 0;
|
||||
|
||||
virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const = 0;
|
||||
|
||||
// this method is never called -- will be removed
|
||||
virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
|
||||
const SkFontStyle&) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Implemented by porting layer to return the default factory. */
|
||||
static sk_sp<SkFontMgr> Factory();
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,10 +15,6 @@ struct SkFontParameters {
|
|||
struct Variation {
|
||||
// Parameters in a variation font axis.
|
||||
struct Axis {
|
||||
constexpr Axis() : tag(0), min(0), def(0), max(0), flags(0) {}
|
||||
constexpr Axis(SkFourByteTag tag, float min, float def, float max, bool hidden) :
|
||||
tag(tag), min(min), def(def), max(max), flags(hidden ? HIDDEN : 0) {}
|
||||
|
||||
// Four character identifier of the font axis (weight, width, slant, italic...).
|
||||
SkFourByteTag tag;
|
||||
// Minimum value supported by this axis.
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
#define SkFontStyle_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/base/SkTPin.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class SK_API SkFontStyle {
|
||||
public:
|
||||
|
@ -77,8 +74,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
friend class SkTypefaceProxyPrototype; // To serialize fValue
|
||||
int32_t fValue;
|
||||
uint32_t fValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,12 +10,8 @@
|
|||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SkData;
|
||||
class SkImageGenerator;
|
||||
class SkOpenTypeSVGDecoder;
|
||||
class SkPath;
|
||||
class SkTraceMemoryDump;
|
||||
|
||||
class SK_API SkGraphics {
|
||||
|
@ -27,6 +23,9 @@ public:
|
|||
*/
|
||||
static void Init();
|
||||
|
||||
// We're in the middle of cleaning this up.
|
||||
static void Term() {}
|
||||
|
||||
/**
|
||||
* Return the max number of bytes that should be used by the font cache.
|
||||
* If the cache needs to allocate more, it will purge previous entries.
|
||||
|
@ -67,6 +66,30 @@ public:
|
|||
*/
|
||||
static int SetFontCacheCountLimit(int count);
|
||||
|
||||
/*
|
||||
* Returns the maximum point size for text that may be cached.
|
||||
*
|
||||
* Sizes above this will be drawn directly from the font's outline.
|
||||
* Setting this to a large value may speed up drawing larger text (repeatedly),
|
||||
* but could cause the cache to purge other sizes more often.
|
||||
*
|
||||
* This value is a hint to the font engine, and the actual limit may be different due to
|
||||
* implementation specific details.
|
||||
*/
|
||||
static int GetFontCachePointSizeLimit();
|
||||
|
||||
/*
|
||||
* Set the maximum point size for text that may be cached, returning the previous value.
|
||||
*
|
||||
* Sizes above this will be drawn directly from the font's outline.
|
||||
* Setting this to a large value may speed up drawing larger text (repeatedly),
|
||||
* but could cause the cache to purge other sizes more often.
|
||||
*
|
||||
* This value is a hint to the font engine, and the actual limit may be different due to
|
||||
* implementation specific details.
|
||||
*/
|
||||
static int SetFontCachePointSizeLimit(int maxPointSize);
|
||||
|
||||
/**
|
||||
* For debugging purposes, this will attempt to purge the font cache. It
|
||||
* does not change the limit, but will cause subsequent font measures and
|
||||
|
@ -75,7 +98,11 @@ public:
|
|||
static void PurgeFontCache();
|
||||
|
||||
/**
|
||||
* This function returns the memory used for temporary images and other resources.
|
||||
* Scaling bitmaps with the kHigh_SkFilterQuality setting is
|
||||
* expensive, so the result is saved in the global Scaled Image
|
||||
* Cache.
|
||||
*
|
||||
* This function returns the memory usage of the Scaled Image Cache.
|
||||
*/
|
||||
static size_t GetResourceCacheTotalBytesUsed();
|
||||
|
||||
|
@ -118,6 +145,16 @@ public:
|
|||
*/
|
||||
static void PurgeAllCaches();
|
||||
|
||||
/**
|
||||
* Applications with command line options may pass optional state, such
|
||||
* as cache sizes, here, for instance:
|
||||
* font-cache-limit=12345678
|
||||
*
|
||||
* The flags format is name=value[;name=value...] with no spaces.
|
||||
* This format is subject to change.
|
||||
*/
|
||||
static void SetFlags(const char* flags);
|
||||
|
||||
typedef std::unique_ptr<SkImageGenerator>
|
||||
(*ImageGeneratorFromEncodedDataFactory)(sk_sp<SkData>);
|
||||
|
||||
|
@ -130,33 +167,6 @@ public:
|
|||
*/
|
||||
static ImageGeneratorFromEncodedDataFactory
|
||||
SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory);
|
||||
|
||||
/**
|
||||
* To draw OpenType SVG data, Skia will look at this runtime function pointer. If this function
|
||||
* pointer is set, the SkTypeface implementations which support OpenType SVG will call this
|
||||
* function to create an SkOpenTypeSVGDecoder to decode the OpenType SVG and draw it as needed.
|
||||
* If this function is not set, the SkTypeface implementations will generally not support
|
||||
* OpenType SVG and attempt to use other glyph representations if available.
|
||||
*/
|
||||
using OpenTypeSVGDecoderFactory =
|
||||
std::unique_ptr<SkOpenTypeSVGDecoder> (*)(const uint8_t* svg, size_t length);
|
||||
static OpenTypeSVGDecoderFactory SetOpenTypeSVGDecoderFactory(OpenTypeSVGDecoderFactory);
|
||||
static OpenTypeSVGDecoderFactory GetOpenTypeSVGDecoderFactory();
|
||||
|
||||
/**
|
||||
* Call early in main() to allow Skia to use a JIT to accelerate CPU-bound operations.
|
||||
*/
|
||||
static void AllowJIT();
|
||||
|
||||
/**
|
||||
* To override the default AA algorithm choice in the CPU backend, provide a function that
|
||||
* returns whether to use analytic (true) or supersampled (false) for a given path.
|
||||
*
|
||||
* NOTE: This is a temporary API, intended for migration of all clients to one algorithm,
|
||||
* and should not be used.
|
||||
*/
|
||||
typedef bool (*PathAnalyticAADeciderProc)(const SkPath&);
|
||||
static void SetPathAnalyticAADecider(PathAnalyticAADeciderProc);
|
||||
};
|
||||
|
||||
class SkAutoGraphics {
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
/*
|
||||
* Copyright 2023 Google LLC
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// TODO(kjlubick) remove this shim after clients have been moved to the new location
|
||||
#include "include/encode/SkICC.h" // IWYU pragma: export
|
||||
#ifndef SkICC_DEFINED
|
||||
#define SkICC_DEFINED
|
||||
|
||||
#include "include/core/SkData.h"
|
||||
|
||||
struct skcms_Matrix3x3;
|
||||
struct skcms_TransferFunction;
|
||||
|
||||
SK_API sk_sp<SkData> SkWriteICCProfile(const skcms_TransferFunction&,
|
||||
const skcms_Matrix3x3& toXYZD50);
|
||||
|
||||
#endif//SkICC_DEFINED
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -8,14 +8,10 @@
|
|||
#ifndef SkImageEncoder_DEFINED
|
||||
#define SkImageEncoder_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkBitmap;
|
||||
class SkData;
|
||||
class SkPixmap;
|
||||
class SkWStream;
|
||||
enum class SkEncodedImageFormat;
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkStream.h"
|
||||
|
||||
/**
|
||||
* Encode SkPixmap in the given binary image format.
|
||||
|
@ -43,7 +39,10 @@ SK_API bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
|
|||
/**
|
||||
* The following helper function wraps SkEncodeImage().
|
||||
*/
|
||||
SK_API bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFormat f, int q);
|
||||
inline bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFormat f, int q) {
|
||||
SkPixmap pixmap;
|
||||
return src.peekPixels(&pixmap) && SkEncodeImage(dst, pixmap, f, q);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode SkPixmap in the given binary image format.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#ifndef SkImageFilter_DEFINED
|
||||
#define SkImageFilter_DEFINED
|
||||
|
||||
#include "include/core/SkFilterQuality.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkRect.h"
|
||||
|
@ -29,6 +30,39 @@ class SkColorFilter;
|
|||
*/
|
||||
class SK_API SkImageFilter : public SkFlattenable {
|
||||
public:
|
||||
class CropRect {
|
||||
public:
|
||||
enum CropEdge {
|
||||
kHasLeft_CropEdge = 0x01,
|
||||
kHasTop_CropEdge = 0x02,
|
||||
kHasWidth_CropEdge = 0x04,
|
||||
kHasHeight_CropEdge = 0x08,
|
||||
kHasAll_CropEdge = 0x0F,
|
||||
};
|
||||
CropRect() {}
|
||||
explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge)
|
||||
: fRect(rect), fFlags(flags) {}
|
||||
uint32_t flags() const { return fFlags; }
|
||||
const SkRect& rect() const { return fRect; }
|
||||
|
||||
/**
|
||||
* Apply this cropRect to the imageBounds. If a given edge of the cropRect is not set, then
|
||||
* the corresponding edge from imageBounds will be used. If "embiggen" is true, the crop
|
||||
* rect is allowed to enlarge the size of the rect, otherwise it may only reduce the rect.
|
||||
* Filters that can affect transparent black should pass "true", while all other filters
|
||||
* should pass "false".
|
||||
*
|
||||
* Note: imageBounds is in "device" space, as the output cropped rectangle will be, so the
|
||||
* matrix is ignored for those. It is only applied to the cropRect's bounds.
|
||||
*/
|
||||
void applyTo(const SkIRect& imageBounds, const SkMatrix& matrix, bool embiggen,
|
||||
SkIRect* cropped) const;
|
||||
|
||||
private:
|
||||
SkRect fRect;
|
||||
uint32_t fFlags;
|
||||
};
|
||||
|
||||
enum MapDirection {
|
||||
kForward_MapDirection,
|
||||
kReverse_MapDirection,
|
||||
|
@ -93,6 +127,22 @@ public:
|
|||
*/
|
||||
sk_sp<SkImageFilter> makeWithLocalMatrix(const SkMatrix& matrix) const;
|
||||
|
||||
/**
|
||||
* Return an imagefilter which transforms its input by the given matrix.
|
||||
* DEPRECATED: Use include/effects/SkImageFilters::MatrixTransform
|
||||
*/
|
||||
static sk_sp<SkImageFilter> MakeMatrixFilter(const SkMatrix& matrix,
|
||||
SkFilterQuality quality,
|
||||
sk_sp<SkImageFilter> input);
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkImageFilter_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkImageFilter_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkImageFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkImageFilter>(static_cast<SkImageFilter*>(
|
||||
|
@ -108,7 +158,7 @@ protected:
|
|||
private:
|
||||
friend class SkImageFilter_Base;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,34 +8,21 @@
|
|||
#ifndef SkImageGenerator_DEFINED
|
||||
#define SkImageGenerator_DEFINED
|
||||
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkYUVAPixmaps.h"
|
||||
#include "include/private/base/SkAPI.h"
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
#include "include/gpu/GrTypes.h"
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include "include/core/SkYUVAIndex.h"
|
||||
#include "include/core/SkYUVASizeInfo.h"
|
||||
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceProxyView;
|
||||
class SkColorSpace;
|
||||
class GrTextureProxy;
|
||||
class GrSamplerState;
|
||||
class SkBitmap;
|
||||
class SkData;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
class SkPicture;
|
||||
class SkSurfaceProps;
|
||||
enum SkAlphaType : int;
|
||||
enum class GrImageTexGenPolicy : int;
|
||||
namespace skgpu { enum class Mipmapped : bool; }
|
||||
struct SkISize;
|
||||
|
||||
class SK_API SkImageGenerator {
|
||||
public:
|
||||
|
@ -67,7 +54,7 @@ public:
|
|||
* Can this generator be used to produce images that will be drawable to the specified context
|
||||
* (or to CPU, if context is nullptr)?
|
||||
*/
|
||||
bool isValid(GrRecordingContext* context) const {
|
||||
bool isValid(GrContext* context) const {
|
||||
return this->onIsValid(context);
|
||||
}
|
||||
|
||||
|
@ -95,91 +82,85 @@ public:
|
|||
*/
|
||||
bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
|
||||
|
||||
bool getPixels(const SkPixmap& pm) {
|
||||
return this->getPixels(pm.info(), pm.writable_addr(), pm.rowBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* If decoding to YUV is supported, this returns true. Otherwise, this
|
||||
* returns false and the caller will ignore output parameter yuvaPixmapInfo.
|
||||
* If decoding to YUV is supported, this returns true. Otherwise, this
|
||||
* returns false and does not modify any of the parameters.
|
||||
*
|
||||
* @param supportedDataTypes Indicates the data type/planar config combinations that are
|
||||
* supported by the caller. If the generator supports decoding to
|
||||
* YUV(A), but not as a type in supportedDataTypes, this method
|
||||
* returns false.
|
||||
* @param yuvaPixmapInfo Output parameter that specifies the planar configuration, subsampling,
|
||||
* orientation, chroma siting, plane color types, and row bytes.
|
||||
* @param sizeInfo Output parameter indicating the sizes and required
|
||||
* allocation widths of the Y, U, V, and A planes.
|
||||
* @param yuvaIndices How the YUVA planes are organized/used
|
||||
* @param colorSpace Output parameter.
|
||||
*/
|
||||
bool queryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes& supportedDataTypes,
|
||||
SkYUVAPixmapInfo* yuvaPixmapInfo) const;
|
||||
bool queryYUVA8(SkYUVASizeInfo* sizeInfo,
|
||||
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
|
||||
SkYUVColorSpace* colorSpace) const;
|
||||
|
||||
/**
|
||||
* Returns true on success and false on failure.
|
||||
* This always attempts to perform a full decode. To get the planar
|
||||
* configuration without decoding use queryYUVAInfo().
|
||||
* This always attempts to perform a full decode. If the client only
|
||||
* wants size, it should call queryYUVA8().
|
||||
*
|
||||
* @param yuvaPixmaps Contains preallocated pixmaps configured according to a successful call
|
||||
* to queryYUVAInfo().
|
||||
* @param sizeInfo Needs to exactly match the values returned by the
|
||||
* query, except the WidthBytes may be larger than the
|
||||
* recommendation (but not smaller).
|
||||
* @param yuvaIndices Needs to exactly match the values returned by the query.
|
||||
* @param planes Memory for the Y, U, V, and A planes. Note that, depending on the
|
||||
* settings in yuvaIndices, anywhere from 1..4 planes could be returned.
|
||||
*/
|
||||
bool getYUVAPlanes(const SkYUVAPixmaps& yuvaPixmaps);
|
||||
bool getYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
|
||||
const SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
|
||||
void* planes[]);
|
||||
|
||||
#if defined(SK_GANESH)
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* If the generator can natively/efficiently return its pixels as a GPU image (backed by a
|
||||
* texture) this will return that image. If not, this will return NULL.
|
||||
*
|
||||
* Regarding the GrRecordingContext parameter:
|
||||
* This routine also supports retrieving only a subset of the pixels. That subset is specified
|
||||
* by the following rectangle:
|
||||
*
|
||||
* subset = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height())
|
||||
*
|
||||
* If subset is not contained inside the generator's bounds, this returns false.
|
||||
*
|
||||
* whole = SkIRect::MakeWH(getInfo().width(), getInfo().height())
|
||||
* if (!whole.contains(subset)) {
|
||||
* return false;
|
||||
* }
|
||||
*
|
||||
* Regarding the GrContext parameter:
|
||||
*
|
||||
* It must be non-NULL. The generator should only succeed if:
|
||||
* - its internal context is the same
|
||||
* - it can somehow convert its texture into one that is valid for the provided context.
|
||||
*
|
||||
* If the mipmapped parameter is kYes, the generator should try to create a TextureProxy that
|
||||
* If the willNeedMipMaps flag is true, the generator should try to create a TextureProxy that
|
||||
* at least has the mip levels allocated and the base layer filled in. If this is not possible,
|
||||
* the generator is allowed to return a non mipped proxy, but this will have some additional
|
||||
* overhead in later allocating mips and copying of the base layer.
|
||||
*
|
||||
* GrImageTexGenPolicy determines whether or not a new texture must be created (and its budget
|
||||
* status) or whether this may (but is not required to) return a pre-existing texture that is
|
||||
* retained by the generator (kDraw).
|
||||
*/
|
||||
GrSurfaceProxyView generateTexture(GrRecordingContext*,
|
||||
const SkImageInfo& info,
|
||||
skgpu::Mipmapped mipmapped,
|
||||
GrImageTexGenPolicy);
|
||||
#endif
|
||||
|
||||
#if defined(SK_GRAPHITE)
|
||||
sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
|
||||
const SkImageInfo&,
|
||||
skgpu::Mipmapped);
|
||||
sk_sp<GrTextureProxy> generateTexture(GrRecordingContext*, const SkImageInfo& info,
|
||||
const SkIPoint& origin,
|
||||
bool willNeedMipMaps);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If the default image decoder system can interpret the specified (encoded) data, then
|
||||
* this returns a new ImageGenerator for it. Otherwise this returns NULL. Either way
|
||||
* the caller is still responsible for managing their ownership of the data.
|
||||
* By default, images will be converted to premultiplied pixels. The alpha type can be
|
||||
* overridden by specifying kPremul_SkAlphaType or kUnpremul_SkAlphaType. Specifying
|
||||
* kOpaque_SkAlphaType is not supported, and will return NULL.
|
||||
*/
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromEncoded(
|
||||
sk_sp<SkData>, std::optional<SkAlphaType> = std::nullopt);
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromEncoded(sk_sp<SkData>);
|
||||
|
||||
/** Return a new image generator backed by the specified picture. If the size is empty or
|
||||
* the picture is NULL, this returns NULL.
|
||||
* The optional matrix and paint arguments are passed to drawPicture() at rasterization
|
||||
* time.
|
||||
*/
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromPicture(const SkISize&, sk_sp<SkPicture>,
|
||||
const SkMatrix*, const SkPaint*,
|
||||
SkImage::BitDepth,
|
||||
sk_sp<SkColorSpace>,
|
||||
SkSurfaceProps props);
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromPicture(const SkISize&, sk_sp<SkPicture>,
|
||||
const SkMatrix*, const SkPaint*,
|
||||
SkImage::BitDepth,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
||||
protected:
|
||||
static constexpr int kNeedNewImageUniqueID = 0;
|
||||
|
||||
|
@ -188,26 +169,22 @@ protected:
|
|||
virtual sk_sp<SkData> onRefEncodedData() { return nullptr; }
|
||||
struct Options {};
|
||||
virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; }
|
||||
virtual bool onIsValid(GrRecordingContext*) const { return true; }
|
||||
virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes&,
|
||||
SkYUVAPixmapInfo*) const { return false; }
|
||||
virtual bool onGetYUVAPlanes(const SkYUVAPixmaps&) { return false; }
|
||||
#if defined(SK_GANESH)
|
||||
// returns nullptr
|
||||
virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
|
||||
GrMipmapped, GrImageTexGenPolicy);
|
||||
virtual bool onIsValid(GrContext*) const { return true; }
|
||||
virtual bool onQueryYUVA8(SkYUVASizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount],
|
||||
SkYUVColorSpace*) const { return false; }
|
||||
virtual bool onGetYUVA8Planes(const SkYUVASizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
|
||||
void*[4] /*planes*/) { return false; }
|
||||
#if SK_SUPPORT_GPU
|
||||
enum class TexGenType {
|
||||
kNone, //image generator does not implement onGenerateTexture
|
||||
kCheap, //onGenerateTexture is implemented and it is fast (does not render offscreen)
|
||||
kExpensive, //onGenerateTexture is implemented and it is relatively slow
|
||||
};
|
||||
|
||||
// Most internal SkImageGenerators produce textures and views that use kTopLeft_GrSurfaceOrigin.
|
||||
// If the generator may produce textures with different origins (e.g.
|
||||
// GrAHardwareBufferImageGenerator) it should override this function to return the correct
|
||||
// origin.
|
||||
virtual GrSurfaceOrigin origin() const { return kTopLeft_GrSurfaceOrigin; }
|
||||
#endif
|
||||
|
||||
#if defined(SK_GRAPHITE)
|
||||
virtual sk_sp<SkImage> onMakeTextureImage(skgpu::graphite::Recorder*,
|
||||
const SkImageInfo&,
|
||||
skgpu::Mipmapped);
|
||||
virtual TexGenType onCanGenerateTexture() const { return TexGenType::kNone; }
|
||||
virtual sk_sp<GrTextureProxy> onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
|
||||
const SkIPoint&,
|
||||
bool willNeedMipMaps); // returns nullptr
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -219,8 +196,7 @@ private:
|
|||
// This is our default impl, which may be different on different platforms.
|
||||
// It is called from NewFromEncoded() after it has checked for any runtime factory.
|
||||
// The SkData will never be NULL, as that will have been checked by NewFromEncoded.
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromEncodedImpl(sk_sp<SkData>,
|
||||
std::optional<SkAlphaType>);
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromEncodedImpl(sk_sp<SkData>);
|
||||
|
||||
SkImageGenerator(SkImageGenerator&&) = delete;
|
||||
SkImageGenerator(const SkImageGenerator&) = delete;
|
||||
|
|
|
@ -8,25 +8,115 @@
|
|||
#ifndef SkImageInfo_DEFINED
|
||||
#define SkImageInfo_DEFINED
|
||||
|
||||
#include "include/core/SkAlphaType.h"
|
||||
#include "include/core/SkColorType.h"
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkMath.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/private/base/SkAPI.h"
|
||||
#include "include/private/base/SkDebug.h"
|
||||
#include "include/private/base/SkMath.h"
|
||||
#include "include/private/base/SkTFitsIn.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include "include/private/SkTFitsIn.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
class SkColorSpace;
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
|
||||
/** \enum SkImageInfo::SkAlphaType
|
||||
Describes how to interpret the alpha component of a pixel. A pixel may
|
||||
be opaque, or alpha, describing multiple levels of transparency.
|
||||
|
||||
In simple blending, alpha weights the draw color and the destination
|
||||
color to create a new color. If alpha describes a weight from zero to one:
|
||||
|
||||
new color = draw color * alpha + destination color * (1 - alpha)
|
||||
|
||||
In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
|
||||
|
||||
RGB may have alpha included in each component value; the stored
|
||||
value is the original RGB multiplied by alpha. Premultiplied color
|
||||
components improve performance.
|
||||
*/
|
||||
enum SkAlphaType {
|
||||
kUnknown_SkAlphaType, //!< uninitialized
|
||||
kOpaque_SkAlphaType, //!< pixel is opaque
|
||||
kPremul_SkAlphaType, //!< pixel components are premultiplied by alpha
|
||||
kUnpremul_SkAlphaType, //!< pixel components are independent of alpha
|
||||
kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, //!< last valid value
|
||||
};
|
||||
|
||||
/** Returns true if SkAlphaType equals kOpaque_SkAlphaType. kOpaque_SkAlphaType is a
|
||||
hint that the SkColorType is opaque, or that all alpha values are set to
|
||||
their 1.0 equivalent. If SkAlphaType is kOpaque_SkAlphaType, and SkColorType is not
|
||||
opaque, then the result of drawing any pixel with a alpha value less than
|
||||
1.0 is undefined.
|
||||
|
||||
@param at one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@return true if at equals kOpaque_SkAlphaType
|
||||
*/
|
||||
static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
|
||||
return kOpaque_SkAlphaType == at;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Temporary macro that allows us to add new color types without breaking Chrome compile. */
|
||||
#define SK_EXTENDED_COLOR_TYPES
|
||||
|
||||
/** \enum SkImageInfo::SkColorType
|
||||
Describes how pixel bits encode color. A pixel may be an alpha mask, a
|
||||
grayscale, RGB, or ARGB.
|
||||
|
||||
kN32_SkColorType selects the native 32-bit ARGB format. On little endian
|
||||
processors, pixels containing 8-bit ARGB components pack into 32-bit
|
||||
kBGRA_8888_SkColorType. On big endian processors, pixels pack into 32-bit
|
||||
kRGBA_8888_SkColorType.
|
||||
*/
|
||||
enum SkColorType {
|
||||
kUnknown_SkColorType, //!< uninitialized
|
||||
kAlpha_8_SkColorType, //!< pixel with alpha in 8-bit byte
|
||||
kRGB_565_SkColorType, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
|
||||
kARGB_4444_SkColorType, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word
|
||||
kRGBA_8888_SkColorType, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word
|
||||
kRGB_888x_SkColorType, //!< pixel with 8 bits each for red, green, blue; in 32-bit word
|
||||
kBGRA_8888_SkColorType, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
|
||||
kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
|
||||
kRGB_101010x_SkColorType, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
|
||||
kGray_8_SkColorType, //!< pixel with grayscale level in 8-bit byte
|
||||
kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
|
||||
kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha; in 64-bit word
|
||||
kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
|
||||
|
||||
// The following 6 colortypes are just for reading from - not for rendering to
|
||||
kR8G8_unorm_SkColorType, //<! pixel with a uint8_t for red and green
|
||||
|
||||
kA16_float_SkColorType, //<! pixel with a half float for alpha
|
||||
kR16G16_float_SkColorType, //<! pixel with a half float for red and green
|
||||
|
||||
kA16_unorm_SkColorType, //<! pixel with a little endian uint16_t for alpha
|
||||
kR16G16_unorm_SkColorType, //<! pixel with a little endian uint16_t for red and green
|
||||
kR16G16B16A16_unorm_SkColorType,//<! pixel with a little endian uint16_t for red, green, blue, and alpha
|
||||
|
||||
kLastEnum_SkColorType = kR16G16B16A16_unorm_SkColorType, //!< last valid value
|
||||
|
||||
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
|
||||
kN32_SkColorType = kBGRA_8888_SkColorType,//!< native ARGB 32-bit encoding
|
||||
|
||||
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
||||
kN32_SkColorType = kRGBA_8888_SkColorType,//!< native ARGB 32-bit encoding
|
||||
|
||||
#else
|
||||
kN32_SkColorType = kBGRA_8888_SkColorType,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Returns the number of bytes required to store a pixel, including unused padding.
|
||||
Returns zero if ct is kUnknown_SkColorType or invalid.
|
||||
|
||||
@param ct one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
||||
@return bytes per pixel
|
||||
*/
|
||||
SK_API int SkColorTypeBytesPerPixel(SkColorType ct);
|
||||
|
@ -34,6 +124,11 @@ SK_API int SkColorTypeBytesPerPixel(SkColorType ct);
|
|||
/** Returns true if SkColorType always decodes alpha to 1.0, making the pixel
|
||||
fully opaque. If true, SkColorType does not reserve bits to encode alpha.
|
||||
|
||||
@param ct one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
||||
@return true if alpha is always set to 1.0
|
||||
*/
|
||||
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct);
|
||||
|
@ -46,6 +141,23 @@ SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct);
|
|||
kUnknown_SkColorType, and SkColorType is not always opaque. If false is returned,
|
||||
canonical is ignored.
|
||||
|
||||
For kUnknown_SkColorType: set canonical to kUnknown_SkAlphaType and return true.
|
||||
For kAlpha_8_SkColorType: set canonical to kPremul_SkAlphaType or
|
||||
kOpaque_SkAlphaType and return true if alphaType is not kUnknown_SkAlphaType.
|
||||
For kRGB_565_SkColorType, kRGB_888x_SkColorType, kRGB_101010x_SkColorType, and
|
||||
kGray_8_SkColorType: set canonical to kOpaque_SkAlphaType and return true.
|
||||
For kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
|
||||
kRGBA_1010102_SkColorType, and kRGBA_F16_SkColorType: set canonical to alphaType
|
||||
and return true if alphaType is not kUnknown_SkAlphaType.
|
||||
|
||||
@param colorType one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
||||
@param alphaType one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@param canonical storage for SkAlphaType
|
||||
@return true if valid SkAlphaType can be associated with colorType
|
||||
*/
|
||||
|
@ -56,35 +168,22 @@ SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alph
|
|||
Describes color range of YUV pixels. The color mapping from YUV to RGB varies
|
||||
depending on the source. YUV pixels may be generated by JPEG images, standard
|
||||
video streams, or high definition video streams. Each has its own mapping from
|
||||
YUV to RGB.
|
||||
YUV and RGB.
|
||||
|
||||
JPEG YUV values encode the full range of 0 to 255 for all three components.
|
||||
Video YUV values often range from 16 to 235 for Y and from 16 to 240 for U and V (limited).
|
||||
Details of encoding and conversion to RGB are described in YCbCr color space.
|
||||
Video YUV values range from 16 to 235 for all three components. Details of
|
||||
encoding and conversion to RGB are described in YCbCr color space.
|
||||
|
||||
The identity colorspace exists to provide a utility mapping from Y to R, U to G and V to B.
|
||||
It can be used to visualize the YUV planes or to explicitly post process the YUV channels.
|
||||
*/
|
||||
enum SkYUVColorSpace : int {
|
||||
kJPEG_Full_SkYUVColorSpace, //!< describes full range
|
||||
kRec601_Limited_SkYUVColorSpace, //!< describes SDTV range
|
||||
kRec709_Full_SkYUVColorSpace, //!< describes HDTV range
|
||||
kRec709_Limited_SkYUVColorSpace,
|
||||
kBT2020_8bit_Full_SkYUVColorSpace, //!< describes UHDTV range, non-constant-luminance
|
||||
kBT2020_8bit_Limited_SkYUVColorSpace,
|
||||
kBT2020_10bit_Full_SkYUVColorSpace,
|
||||
kBT2020_10bit_Limited_SkYUVColorSpace,
|
||||
kBT2020_12bit_Full_SkYUVColorSpace,
|
||||
kBT2020_12bit_Limited_SkYUVColorSpace,
|
||||
kIdentity_SkYUVColorSpace, //!< maps Y->R, U->G, V->B
|
||||
enum SkYUVColorSpace {
|
||||
kJPEG_SkYUVColorSpace, //!< describes full range
|
||||
kRec601_SkYUVColorSpace, //!< describes SDTV range
|
||||
kRec709_SkYUVColorSpace, //!< describes HDTV range
|
||||
kIdentity_SkYUVColorSpace, //!< maps Y->R, U->G, V->B
|
||||
|
||||
kLastEnum_SkYUVColorSpace = kIdentity_SkYUVColorSpace, //!< last valid value
|
||||
|
||||
// Legacy (deprecated) names:
|
||||
kJPEG_SkYUVColorSpace = kJPEG_Full_SkYUVColorSpace,
|
||||
kRec601_SkYUVColorSpace = kRec601_Limited_SkYUVColorSpace,
|
||||
kRec709_SkYUVColorSpace = kRec709_Limited_SkYUVColorSpace,
|
||||
kBT2020_SkYUVColorSpace = kBT2020_8bit_Limited_SkYUVColorSpace,
|
||||
};
|
||||
|
||||
/** \struct SkColorInfo
|
||||
|
@ -101,8 +200,7 @@ public:
|
|||
|
||||
@return empty SkImageInfo
|
||||
*/
|
||||
SkColorInfo();
|
||||
~SkColorInfo();
|
||||
SkColorInfo() = default;
|
||||
|
||||
/** Creates SkColorInfo from SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.
|
||||
|
||||
|
@ -113,31 +211,32 @@ public:
|
|||
combination is supported.
|
||||
@return created SkColorInfo
|
||||
*/
|
||||
SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs);
|
||||
SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs)
|
||||
: fColorSpace(std::move(cs)), fColorType(ct), fAlphaType(at) {}
|
||||
|
||||
SkColorInfo(const SkColorInfo&);
|
||||
SkColorInfo(SkColorInfo&&);
|
||||
SkColorInfo(const SkColorInfo&) = default;
|
||||
SkColorInfo(SkColorInfo&&) = default;
|
||||
|
||||
SkColorInfo& operator=(const SkColorInfo&);
|
||||
SkColorInfo& operator=(SkColorInfo&&);
|
||||
SkColorInfo& operator=(const SkColorInfo&) = default;
|
||||
SkColorInfo& operator=(SkColorInfo&&) = default;
|
||||
|
||||
SkColorSpace* colorSpace() const;
|
||||
sk_sp<SkColorSpace> refColorSpace() const;
|
||||
SkColorSpace* colorSpace() const { return fColorSpace.get(); }
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
|
||||
SkColorType colorType() const { return fColorType; }
|
||||
SkAlphaType alphaType() const { return fAlphaType; }
|
||||
|
||||
bool isOpaque() const {
|
||||
return SkAlphaTypeIsOpaque(fAlphaType)
|
||||
|| SkColorTypeIsAlwaysOpaque(fColorType);
|
||||
}
|
||||
bool isOpaque() const { return SkAlphaTypeIsOpaque(fAlphaType); }
|
||||
|
||||
bool gammaCloseToSRGB() const;
|
||||
bool gammaCloseToSRGB() const { return fColorSpace && fColorSpace->gammaCloseToSRGB(); }
|
||||
|
||||
/** Does other represent the same color type, alpha type, and color space? */
|
||||
bool operator==(const SkColorInfo& other) const;
|
||||
bool operator==(const SkColorInfo& other) const {
|
||||
return fColorType == other.fColorType && fAlphaType == other.fAlphaType &&
|
||||
SkColorSpace::Equals(fColorSpace.get(), other.fColorSpace.get());
|
||||
}
|
||||
|
||||
/** Does other represent a different color type, alpha type, or color space? */
|
||||
bool operator!=(const SkColorInfo& other) const;
|
||||
bool operator!=(const SkColorInfo& other) const { return !(*this == other); }
|
||||
|
||||
/** Creates SkColorInfo with same SkColorType, SkColorSpace, with SkAlphaType set
|
||||
to newAlphaType.
|
||||
|
@ -145,24 +244,28 @@ public:
|
|||
Created SkColorInfo contains newAlphaType even if it is incompatible with
|
||||
SkColorType, in which case SkAlphaType in SkColorInfo is ignored.
|
||||
*/
|
||||
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const;
|
||||
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const {
|
||||
return SkColorInfo(this->colorType(), newAlphaType, this->refColorSpace());
|
||||
}
|
||||
|
||||
/** Creates new SkColorInfo with same SkAlphaType, SkColorSpace, with SkColorType
|
||||
set to newColorType.
|
||||
*/
|
||||
SkColorInfo makeColorType(SkColorType newColorType) const;
|
||||
SkColorInfo makeColorType(SkColorType newColorType) const {
|
||||
return SkColorInfo(newColorType, this->alphaType(), this->refColorSpace());
|
||||
}
|
||||
|
||||
/** Creates SkColorInfo with same SkAlphaType, SkColorType, with SkColorSpace
|
||||
set to cs. cs may be nullptr.
|
||||
*/
|
||||
SkColorInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
|
||||
SkColorInfo makeColorSpace(sk_sp<SkColorSpace> cs) const {
|
||||
return SkColorInfo(this->colorType(), this->alphaType(), std::move(cs));
|
||||
}
|
||||
|
||||
/** Returns number of bytes per pixel required by SkColorType.
|
||||
Returns zero if colorType() is kUnknown_SkColorType.
|
||||
|
||||
@return bytes in pixel
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_bytesPerPixel
|
||||
*/
|
||||
int bytesPerPixel() const;
|
||||
|
||||
|
@ -170,8 +273,6 @@ public:
|
|||
Returns zero for kUnknown_SkColorType.
|
||||
|
||||
@return one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_shiftPerPixel
|
||||
*/
|
||||
int shiftPerPixel() const;
|
||||
|
||||
|
@ -212,15 +313,25 @@ public:
|
|||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param ct one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
||||
@param at one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at);
|
||||
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
|
||||
sk_sp<SkColorSpace> cs);
|
||||
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at);
|
||||
sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return SkImageInfo({width, height}, {ct, at, std::move(cs)});
|
||||
}
|
||||
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at,
|
||||
sk_sp<SkColorSpace> cs);
|
||||
sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return SkImageInfo(dimensions, {ct, at, std::move(cs)});
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,
|
||||
|
||||
|
@ -251,11 +362,16 @@ public:
|
|||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param at one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeN32(int width, int height, SkAlphaType at);
|
||||
static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp<SkColorSpace> cs);
|
||||
static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
|
||||
sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return Make({width, height}, kN32_SkColorType, at, std::move(cs));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
||||
SkAlphaType at, with sRGB SkColorSpace.
|
||||
|
@ -265,9 +381,10 @@ public:
|
|||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param at one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@return created SkImageInfo
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_MakeS32
|
||||
*/
|
||||
static SkImageInfo MakeS32(int width, int height, SkAlphaType at);
|
||||
|
||||
|
@ -285,8 +402,9 @@ public:
|
|||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeN32Premul(int width, int height);
|
||||
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs);
|
||||
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return Make({width, height}, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
||||
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
@ -297,12 +415,12 @@ public:
|
|||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param dimensions width and height, each must be zero or greater
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
@param size width and height, each must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeN32Premul(SkISize dimensions);
|
||||
static SkImageInfo MakeN32Premul(SkISize dimensions, sk_sp<SkColorSpace> cs);
|
||||
static SkImageInfo MakeN32Premul(const SkISize& size) {
|
||||
return MakeN32Premul(size.width(), size.height());
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType,
|
||||
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
@ -311,14 +429,9 @@ public:
|
|||
@param height pixel row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeA8(int width, int height);
|
||||
/** Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType,
|
||||
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
||||
@param dimensions pixel row and column count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeA8(SkISize dimensions);
|
||||
static SkImageInfo MakeA8(int width, int height) {
|
||||
return Make({width, height}, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType,
|
||||
kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
@ -330,7 +443,9 @@ public:
|
|||
@param height pixel row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeUnknown(int width, int height);
|
||||
static SkImageInfo MakeUnknown(int width, int height) {
|
||||
return Make({width, height}, kUnknown_SkColorType, kUnknown_SkAlphaType, nullptr);
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height set to zero,
|
||||
kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
@ -356,8 +471,22 @@ public:
|
|||
*/
|
||||
int height() const { return fDimensions.height(); }
|
||||
|
||||
/** Returns SkColorType, one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
||||
kGray_8_SkColorType, kRGBA_F16_SkColorType.
|
||||
|
||||
@return SkColorType
|
||||
*/
|
||||
SkColorType colorType() const { return fColorInfo.colorType(); }
|
||||
|
||||
/** Returns SkAlphaType, one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType.
|
||||
|
||||
@return SkAlphaType
|
||||
*/
|
||||
SkAlphaType alphaType() const { return fColorInfo.alphaType(); }
|
||||
|
||||
/** Returns SkColorSpace, the range of colors. The reference count of
|
||||
|
@ -365,7 +494,7 @@ public:
|
|||
|
||||
@return SkColorSpace, or nullptr
|
||||
*/
|
||||
SkColorSpace* colorSpace() const;
|
||||
SkColorSpace* colorSpace() const { return fColorInfo.colorSpace(); }
|
||||
|
||||
/** Returns smart pointer to SkColorSpace, the range of colors. The smart pointer
|
||||
tracks the number of objects sharing this SkColorSpace reference so the memory
|
||||
|
@ -375,7 +504,7 @@ public:
|
|||
|
||||
@return SkColorSpace wrapped in a smart pointer
|
||||
*/
|
||||
sk_sp<SkColorSpace> refColorSpace() const;
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fColorInfo.refColorSpace(); }
|
||||
|
||||
/** Returns if SkImageInfo describes an empty area of pixels by checking if either
|
||||
width or height is zero or smaller.
|
||||
|
@ -447,6 +576,9 @@ public:
|
|||
Created SkImageInfo contains newAlphaType even if it is incompatible with
|
||||
SkColorType, in which case SkAlphaType in SkImageInfo is ignored.
|
||||
|
||||
@param newAlphaType one of:
|
||||
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
|
||||
kUnpremul_SkAlphaType
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const {
|
||||
|
@ -456,6 +588,11 @@ public:
|
|||
/** Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height,
|
||||
with SkColorType set to newColorType.
|
||||
|
||||
@param newColorType one of:
|
||||
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
||||
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
||||
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType,
|
||||
kRGB_101010x_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeColorType(SkColorType newColorType) const {
|
||||
|
@ -468,7 +605,9 @@ public:
|
|||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
|
||||
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const {
|
||||
return Make(fDimensions, fColorInfo.makeColorSpace(std::move(cs)));
|
||||
}
|
||||
|
||||
/** Returns number of bytes per pixel required by SkColorType.
|
||||
Returns zero if colorType( is kUnknown_SkColorType.
|
||||
|
@ -490,22 +629,20 @@ public:
|
|||
|
||||
@return width() times bytesPerPixel() as unsigned 64-bit integer
|
||||
*/
|
||||
uint64_t minRowBytes64() const {
|
||||
return (uint64_t)sk_64_mul(this->width(), this->bytesPerPixel());
|
||||
}
|
||||
uint64_t minRowBytes64() const { return sk_64_mul(this->width(), this->bytesPerPixel()); }
|
||||
|
||||
/** Returns minimum bytes per row, computed from pixel width() and SkColorType, which
|
||||
specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit
|
||||
in 31 bits.
|
||||
|
||||
@return width() times bytesPerPixel() as size_t
|
||||
@return width() times bytesPerPixel() as signed 32-bit integer
|
||||
*/
|
||||
size_t minRowBytes() const {
|
||||
uint64_t minRowBytes = this->minRowBytes64();
|
||||
if (!SkTFitsIn<int32_t>(minRowBytes)) {
|
||||
return 0;
|
||||
}
|
||||
return (size_t)minRowBytes;
|
||||
return SkTo<int32_t>(minRowBytes);
|
||||
}
|
||||
|
||||
/** Returns byte offset of pixel from pixel base address.
|
||||
|
@ -517,8 +654,6 @@ public:
|
|||
@param y row index, zero or greater, and less than height()
|
||||
@param rowBytes size of pixel row or larger
|
||||
@return offset within pixel array
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_computeOffset
|
||||
*/
|
||||
size_t computeOffset(int x, int y, size_t rowBytes) const;
|
||||
|
||||
|
@ -550,8 +685,6 @@ public:
|
|||
|
||||
@param rowBytes size of pixel row or larger
|
||||
@return memory required by pixel buffer
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_computeByteSize
|
||||
*/
|
||||
size_t computeByteSize(size_t rowBytes) const;
|
||||
|
||||
|
@ -577,19 +710,13 @@ public:
|
|||
return SIZE_MAX == byteSize;
|
||||
}
|
||||
|
||||
/** Returns true if rowBytes is valid for this SkImageInfo.
|
||||
/** Returns true if rowBytes is smaller than width times pixel size.
|
||||
|
||||
@param rowBytes size of pixel row including padding
|
||||
@return true if rowBytes is large enough to contain pixel row and is properly
|
||||
aligned
|
||||
@param rowBytes size of pixel row or larger
|
||||
@return true if rowBytes is large enough to contain pixel row
|
||||
*/
|
||||
bool validRowBytes(size_t rowBytes) const {
|
||||
if (rowBytes < this->minRowBytes64()) {
|
||||
return false;
|
||||
}
|
||||
int shift = this->shiftPerPixel();
|
||||
size_t alignedRowBytes = rowBytes >> shift << shift;
|
||||
return alignedRowBytes == rowBytes;
|
||||
return rowBytes >= this->minRowBytes64();
|
||||
}
|
||||
|
||||
/** Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
||||
|
|
|
@ -1,438 +0,0 @@
|
|||
/*
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkM44_DEFINED
|
||||
#define SkM44_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
struct SK_API SkV2 {
|
||||
float x, y;
|
||||
|
||||
bool operator==(const SkV2 v) const { return x == v.x && y == v.y; }
|
||||
bool operator!=(const SkV2 v) const { return !(*this == v); }
|
||||
|
||||
static SkScalar Dot(SkV2 a, SkV2 b) { return a.x * b.x + a.y * b.y; }
|
||||
static SkScalar Cross(SkV2 a, SkV2 b) { return a.x * b.y - a.y * b.x; }
|
||||
static SkV2 Normalize(SkV2 v) { return v * (1.0f / v.length()); }
|
||||
|
||||
SkV2 operator-() const { return {-x, -y}; }
|
||||
SkV2 operator+(SkV2 v) const { return {x+v.x, y+v.y}; }
|
||||
SkV2 operator-(SkV2 v) const { return {x-v.x, y-v.y}; }
|
||||
|
||||
SkV2 operator*(SkV2 v) const { return {x*v.x, y*v.y}; }
|
||||
friend SkV2 operator*(SkV2 v, SkScalar s) { return {v.x*s, v.y*s}; }
|
||||
friend SkV2 operator*(SkScalar s, SkV2 v) { return {v.x*s, v.y*s}; }
|
||||
friend SkV2 operator/(SkV2 v, SkScalar s) { return {v.x/s, v.y/s}; }
|
||||
friend SkV2 operator/(SkScalar s, SkV2 v) { return {s/v.x, s/v.y}; }
|
||||
|
||||
void operator+=(SkV2 v) { *this = *this + v; }
|
||||
void operator-=(SkV2 v) { *this = *this - v; }
|
||||
void operator*=(SkV2 v) { *this = *this * v; }
|
||||
void operator*=(SkScalar s) { *this = *this * s; }
|
||||
void operator/=(SkScalar s) { *this = *this / s; }
|
||||
|
||||
SkScalar lengthSquared() const { return Dot(*this, *this); }
|
||||
SkScalar length() const { return SkScalarSqrt(this->lengthSquared()); }
|
||||
|
||||
SkScalar dot(SkV2 v) const { return Dot(*this, v); }
|
||||
SkScalar cross(SkV2 v) const { return Cross(*this, v); }
|
||||
SkV2 normalize() const { return Normalize(*this); }
|
||||
|
||||
const float* ptr() const { return &x; }
|
||||
float* ptr() { return &x; }
|
||||
};
|
||||
|
||||
struct SK_API SkV3 {
|
||||
float x, y, z;
|
||||
|
||||
bool operator==(const SkV3& v) const {
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
}
|
||||
bool operator!=(const SkV3& v) const { return !(*this == v); }
|
||||
|
||||
static SkScalar Dot(const SkV3& a, const SkV3& b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
|
||||
static SkV3 Cross(const SkV3& a, const SkV3& b) {
|
||||
return { a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x };
|
||||
}
|
||||
static SkV3 Normalize(const SkV3& v) { return v * (1.0f / v.length()); }
|
||||
|
||||
SkV3 operator-() const { return {-x, -y, -z}; }
|
||||
SkV3 operator+(const SkV3& v) const { return { x + v.x, y + v.y, z + v.z }; }
|
||||
SkV3 operator-(const SkV3& v) const { return { x - v.x, y - v.y, z - v.z }; }
|
||||
|
||||
SkV3 operator*(const SkV3& v) const {
|
||||
return { x*v.x, y*v.y, z*v.z };
|
||||
}
|
||||
friend SkV3 operator*(const SkV3& v, SkScalar s) {
|
||||
return { v.x*s, v.y*s, v.z*s };
|
||||
}
|
||||
friend SkV3 operator*(SkScalar s, const SkV3& v) { return v*s; }
|
||||
|
||||
void operator+=(SkV3 v) { *this = *this + v; }
|
||||
void operator-=(SkV3 v) { *this = *this - v; }
|
||||
void operator*=(SkV3 v) { *this = *this * v; }
|
||||
void operator*=(SkScalar s) { *this = *this * s; }
|
||||
|
||||
SkScalar lengthSquared() const { return Dot(*this, *this); }
|
||||
SkScalar length() const { return SkScalarSqrt(Dot(*this, *this)); }
|
||||
|
||||
SkScalar dot(const SkV3& v) const { return Dot(*this, v); }
|
||||
SkV3 cross(const SkV3& v) const { return Cross(*this, v); }
|
||||
SkV3 normalize() const { return Normalize(*this); }
|
||||
|
||||
const float* ptr() const { return &x; }
|
||||
float* ptr() { return &x; }
|
||||
};
|
||||
|
||||
struct SK_API SkV4 {
|
||||
float x, y, z, w;
|
||||
|
||||
bool operator==(const SkV4& v) const {
|
||||
return x == v.x && y == v.y && z == v.z && w == v.w;
|
||||
}
|
||||
bool operator!=(const SkV4& v) const { return !(*this == v); }
|
||||
|
||||
static SkScalar Dot(const SkV4& a, const SkV4& b) {
|
||||
return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w;
|
||||
}
|
||||
static SkV4 Normalize(const SkV4& v) { return v * (1.0f / v.length()); }
|
||||
|
||||
SkV4 operator-() const { return {-x, -y, -z, -w}; }
|
||||
SkV4 operator+(const SkV4& v) const { return { x + v.x, y + v.y, z + v.z, w + v.w }; }
|
||||
SkV4 operator-(const SkV4& v) const { return { x - v.x, y - v.y, z - v.z, w - v.w }; }
|
||||
|
||||
SkV4 operator*(const SkV4& v) const {
|
||||
return { x*v.x, y*v.y, z*v.z, w*v.w };
|
||||
}
|
||||
friend SkV4 operator*(const SkV4& v, SkScalar s) {
|
||||
return { v.x*s, v.y*s, v.z*s, v.w*s };
|
||||
}
|
||||
friend SkV4 operator*(SkScalar s, const SkV4& v) { return v*s; }
|
||||
|
||||
SkScalar lengthSquared() const { return Dot(*this, *this); }
|
||||
SkScalar length() const { return SkScalarSqrt(Dot(*this, *this)); }
|
||||
|
||||
SkScalar dot(const SkV4& v) const { return Dot(*this, v); }
|
||||
SkV4 normalize() const { return Normalize(*this); }
|
||||
|
||||
const float* ptr() const { return &x; }
|
||||
float* ptr() { return &x; }
|
||||
|
||||
float operator[](int i) const {
|
||||
SkASSERT(i >= 0 && i < 4);
|
||||
return this->ptr()[i];
|
||||
}
|
||||
float& operator[](int i) {
|
||||
SkASSERT(i >= 0 && i < 4);
|
||||
return this->ptr()[i];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 4x4 matrix used by SkCanvas and other parts of Skia.
|
||||
*
|
||||
* Skia assumes a right-handed coordinate system:
|
||||
* +X goes to the right
|
||||
* +Y goes down
|
||||
* +Z goes into the screen (away from the viewer)
|
||||
*/
|
||||
class SK_API SkM44 {
|
||||
public:
|
||||
SkM44(const SkM44& src) = default;
|
||||
SkM44& operator=(const SkM44& src) = default;
|
||||
|
||||
constexpr SkM44()
|
||||
: fMat{1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1}
|
||||
{}
|
||||
|
||||
SkM44(const SkM44& a, const SkM44& b) {
|
||||
this->setConcat(a, b);
|
||||
}
|
||||
|
||||
enum Uninitialized_Constructor {
|
||||
kUninitialized_Constructor
|
||||
};
|
||||
SkM44(Uninitialized_Constructor) {}
|
||||
|
||||
enum NaN_Constructor {
|
||||
kNaN_Constructor
|
||||
};
|
||||
constexpr SkM44(NaN_Constructor)
|
||||
: fMat{SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN}
|
||||
{}
|
||||
|
||||
/**
|
||||
* The constructor parameters are in row-major order.
|
||||
*/
|
||||
constexpr SkM44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12,
|
||||
SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13,
|
||||
SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14,
|
||||
SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15)
|
||||
// fMat is column-major order in memory.
|
||||
: fMat{m0, m1, m2, m3,
|
||||
m4, m5, m6, m7,
|
||||
m8, m9, m10, m11,
|
||||
m12, m13, m14, m15}
|
||||
{}
|
||||
|
||||
static SkM44 Rows(const SkV4& r0, const SkV4& r1, const SkV4& r2, const SkV4& r3) {
|
||||
SkM44 m(kUninitialized_Constructor);
|
||||
m.setRow(0, r0);
|
||||
m.setRow(1, r1);
|
||||
m.setRow(2, r2);
|
||||
m.setRow(3, r3);
|
||||
return m;
|
||||
}
|
||||
static SkM44 Cols(const SkV4& c0, const SkV4& c1, const SkV4& c2, const SkV4& c3) {
|
||||
SkM44 m(kUninitialized_Constructor);
|
||||
m.setCol(0, c0);
|
||||
m.setCol(1, c1);
|
||||
m.setCol(2, c2);
|
||||
m.setCol(3, c3);
|
||||
return m;
|
||||
}
|
||||
|
||||
static SkM44 RowMajor(const SkScalar r[16]) {
|
||||
return SkM44(r[ 0], r[ 1], r[ 2], r[ 3],
|
||||
r[ 4], r[ 5], r[ 6], r[ 7],
|
||||
r[ 8], r[ 9], r[10], r[11],
|
||||
r[12], r[13], r[14], r[15]);
|
||||
}
|
||||
static SkM44 ColMajor(const SkScalar c[16]) {
|
||||
return SkM44(c[0], c[4], c[ 8], c[12],
|
||||
c[1], c[5], c[ 9], c[13],
|
||||
c[2], c[6], c[10], c[14],
|
||||
c[3], c[7], c[11], c[15]);
|
||||
}
|
||||
|
||||
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z = 0) {
|
||||
return SkM44(1, 0, 0, x,
|
||||
0, 1, 0, y,
|
||||
0, 0, 1, z,
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z = 1) {
|
||||
return SkM44(x, 0, 0, 0,
|
||||
0, y, 0, 0,
|
||||
0, 0, z, 0,
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
static SkM44 Rotate(SkV3 axis, SkScalar radians) {
|
||||
SkM44 m(kUninitialized_Constructor);
|
||||
m.setRotate(axis, radians);
|
||||
return m;
|
||||
}
|
||||
|
||||
// Scales and translates 'src' to fill 'dst' exactly.
|
||||
static SkM44 RectToRect(const SkRect& src, const SkRect& dst);
|
||||
|
||||
static SkM44 LookAt(const SkV3& eye, const SkV3& center, const SkV3& up);
|
||||
static SkM44 Perspective(float near, float far, float angle);
|
||||
|
||||
bool operator==(const SkM44& other) const;
|
||||
bool operator!=(const SkM44& other) const {
|
||||
return !(other == *this);
|
||||
}
|
||||
|
||||
void getColMajor(SkScalar v[]) const {
|
||||
memcpy(v, fMat, sizeof(fMat));
|
||||
}
|
||||
void getRowMajor(SkScalar v[]) const;
|
||||
|
||||
SkScalar rc(int r, int c) const {
|
||||
SkASSERT(r >= 0 && r <= 3);
|
||||
SkASSERT(c >= 0 && c <= 3);
|
||||
return fMat[c*4 + r];
|
||||
}
|
||||
void setRC(int r, int c, SkScalar value) {
|
||||
SkASSERT(r >= 0 && r <= 3);
|
||||
SkASSERT(c >= 0 && c <= 3);
|
||||
fMat[c*4 + r] = value;
|
||||
}
|
||||
|
||||
SkV4 row(int i) const {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
return {fMat[i + 0], fMat[i + 4], fMat[i + 8], fMat[i + 12]};
|
||||
}
|
||||
SkV4 col(int i) const {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
return {fMat[i*4 + 0], fMat[i*4 + 1], fMat[i*4 + 2], fMat[i*4 + 3]};
|
||||
}
|
||||
|
||||
void setRow(int i, const SkV4& v) {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
fMat[i + 0] = v.x;
|
||||
fMat[i + 4] = v.y;
|
||||
fMat[i + 8] = v.z;
|
||||
fMat[i + 12] = v.w;
|
||||
}
|
||||
void setCol(int i, const SkV4& v) {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
memcpy(&fMat[i*4], v.ptr(), sizeof(v));
|
||||
}
|
||||
|
||||
SkM44& setIdentity() {
|
||||
*this = { 1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1 };
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkM44& setTranslate(SkScalar x, SkScalar y, SkScalar z = 0) {
|
||||
*this = { 1, 0, 0, x,
|
||||
0, 1, 0, y,
|
||||
0, 0, 1, z,
|
||||
0, 0, 0, 1 };
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkM44& setScale(SkScalar x, SkScalar y, SkScalar z = 1) {
|
||||
*this = { x, 0, 0, 0,
|
||||
0, y, 0, 0,
|
||||
0, 0, z, 0,
|
||||
0, 0, 0, 1 };
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this matrix to rotate about the specified unit-length axis vector,
|
||||
* by an angle specified by its sin() and cos().
|
||||
*
|
||||
* This does not attempt to verify that axis.length() == 1 or that the sin,cos values
|
||||
* are correct.
|
||||
*/
|
||||
SkM44& setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle);
|
||||
|
||||
/**
|
||||
* Set this matrix to rotate about the specified unit-length axis vector,
|
||||
* by an angle specified in radians.
|
||||
*
|
||||
* This does not attempt to verify that axis.length() == 1.
|
||||
*/
|
||||
SkM44& setRotateUnit(SkV3 axis, SkScalar radians) {
|
||||
return this->setRotateUnitSinCos(axis, SkScalarSin(radians), SkScalarCos(radians));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this matrix to rotate about the specified axis vector,
|
||||
* by an angle specified in radians.
|
||||
*
|
||||
* Note: axis is not assumed to be unit-length, so it will be normalized internally.
|
||||
* If axis is already unit-length, call setRotateAboutUnitRadians() instead.
|
||||
*/
|
||||
SkM44& setRotate(SkV3 axis, SkScalar radians);
|
||||
|
||||
SkM44& setConcat(const SkM44& a, const SkM44& b);
|
||||
|
||||
friend SkM44 operator*(const SkM44& a, const SkM44& b) {
|
||||
return SkM44(a, b);
|
||||
}
|
||||
|
||||
SkM44& preConcat(const SkM44& m) {
|
||||
return this->setConcat(*this, m);
|
||||
}
|
||||
|
||||
SkM44& postConcat(const SkM44& m) {
|
||||
return this->setConcat(m, *this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 0, 1].
|
||||
* For most uses, a bottom row of [0, 0, 0, X] behaves like a non-perspective matrix, though
|
||||
* it will be categorized as perspective. Calling normalizePerspective() will change the
|
||||
* matrix such that, if its bottom row was [0, 0, 0, X], it will be changed to [0, 0, 0, 1]
|
||||
* by scaling the rest of the matrix by 1/X.
|
||||
*
|
||||
* | A B C D | | A/X B/X C/X D/X |
|
||||
* | E F G H | -> | E/X F/X G/X H/X | for X != 0
|
||||
* | I J K L | | I/X J/X K/X L/X |
|
||||
* | 0 0 0 X | | 0 0 0 1 |
|
||||
*/
|
||||
void normalizePerspective();
|
||||
|
||||
/** Returns true if all elements of the matrix are finite. Returns false if any
|
||||
element is infinity, or NaN.
|
||||
|
||||
@return true if matrix has only finite elements
|
||||
*/
|
||||
bool isFinite() const { return SkScalarsAreFinite(fMat, 16); }
|
||||
|
||||
/** If this is invertible, return that in inverse and return true. If it is
|
||||
* not invertible, return false and leave the inverse parameter unchanged.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT invert(SkM44* inverse) const;
|
||||
|
||||
SkM44 SK_WARN_UNUSED_RESULT transpose() const;
|
||||
|
||||
void dump() const;
|
||||
|
||||
////////////
|
||||
|
||||
SkV4 map(float x, float y, float z, float w) const;
|
||||
SkV4 operator*(const SkV4& v) const {
|
||||
return this->map(v.x, v.y, v.z, v.w);
|
||||
}
|
||||
SkV3 operator*(SkV3 v) const {
|
||||
auto v4 = this->map(v.x, v.y, v.z, 0);
|
||||
return {v4.x, v4.y, v4.z};
|
||||
}
|
||||
////////////////////// Converting to/from SkMatrix
|
||||
|
||||
/* When converting from SkM44 to SkMatrix, the third row and
|
||||
* column is dropped. When converting from SkMatrix to SkM44
|
||||
* the third row and column remain as identity:
|
||||
* [ a b c ] [ a b 0 c ]
|
||||
* [ d e f ] -> [ d e 0 f ]
|
||||
* [ g h i ] [ 0 0 1 0 ]
|
||||
* [ g h 0 i ]
|
||||
*/
|
||||
SkMatrix asM33() const {
|
||||
return SkMatrix::MakeAll(fMat[0], fMat[4], fMat[12],
|
||||
fMat[1], fMat[5], fMat[13],
|
||||
fMat[3], fMat[7], fMat[15]);
|
||||
}
|
||||
|
||||
explicit SkM44(const SkMatrix& src)
|
||||
: SkM44(src[SkMatrix::kMScaleX], src[SkMatrix::kMSkewX], 0, src[SkMatrix::kMTransX],
|
||||
src[SkMatrix::kMSkewY], src[SkMatrix::kMScaleY], 0, src[SkMatrix::kMTransY],
|
||||
0, 0, 1, 0,
|
||||
src[SkMatrix::kMPersp0], src[SkMatrix::kMPersp1], 0, src[SkMatrix::kMPersp2])
|
||||
{}
|
||||
|
||||
SkM44& preTranslate(SkScalar x, SkScalar y, SkScalar z = 0);
|
||||
SkM44& postTranslate(SkScalar x, SkScalar y, SkScalar z = 0);
|
||||
|
||||
SkM44& preScale(SkScalar x, SkScalar y);
|
||||
SkM44& preScale(SkScalar x, SkScalar y, SkScalar z);
|
||||
SkM44& preConcat(const SkMatrix&);
|
||||
|
||||
private:
|
||||
/* Stored in column-major.
|
||||
* Indices
|
||||
* 0 4 8 12 1 0 0 trans_x
|
||||
* 1 5 9 13 e.g. 0 1 0 trans_y
|
||||
* 2 6 10 14 0 0 1 trans_z
|
||||
* 3 7 11 15 0 0 0 1
|
||||
*/
|
||||
SkScalar fMat[16];
|
||||
|
||||
friend class SkMatrixPriv;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -38,5 +38,5 @@ namespace SkMallocPixelRef {
|
|||
* Returns NULL on failure.
|
||||
*/
|
||||
SK_API sk_sp<SkPixelRef> MakeWithData(const SkImageInfo&, size_t rowBytes, sk_sp<SkData> data);
|
||||
} // namespace SkMallocPixelRef
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -8,16 +8,14 @@
|
|||
#ifndef SkMaskFilter_DEFINED
|
||||
#define SkMaskFilter_DEFINED
|
||||
|
||||
#include "include/core/SkBlurTypes.h"
|
||||
#include "include/core/SkCoverageMode.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
enum SkBlurStyle : int;
|
||||
struct SkDeserialProcs;
|
||||
class SkMatrix;
|
||||
struct SkRect;
|
||||
class SkString;
|
||||
|
||||
/** \class SkMaskFilter
|
||||
|
||||
|
@ -36,14 +34,40 @@ public:
|
|||
bool respectCTM = true);
|
||||
|
||||
/**
|
||||
* Returns the approximate bounds that would result from filtering the src rect.
|
||||
* The actual result may be different, but it should be contained within the
|
||||
* returned bounds.
|
||||
* Construct a maskfilter whose effect is to first apply the inner filter and then apply
|
||||
* the outer filter to the result of the inner's. Returns nullptr on failure.
|
||||
*/
|
||||
SkRect approximateFilteredBounds(const SkRect& src) const;
|
||||
static sk_sp<SkMaskFilter> MakeCompose(sk_sp<SkMaskFilter> outer, sk_sp<SkMaskFilter> inner);
|
||||
|
||||
/**
|
||||
* Compose two maskfilters together using a coverage mode. Returns nullptr on failure.
|
||||
*/
|
||||
static sk_sp<SkMaskFilter> MakeCombine(sk_sp<SkMaskFilter> filterA, sk_sp<SkMaskFilter> filterB,
|
||||
SkCoverageMode mode);
|
||||
|
||||
/**
|
||||
* Construct a maskfilter with an additional transform.
|
||||
*
|
||||
* Note: unlike shader local matrices, this transform composes next to the CTM.
|
||||
*
|
||||
* TotalMatrix = CTM x MaskFilterMatrix x (optional/downstream) ShaderLocalMatrix
|
||||
*/
|
||||
sk_sp<SkMaskFilter> makeWithMatrix(const SkMatrix&) const;
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkMaskFilter_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkMaskFilter_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkMaskFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkMaskFilter>(static_cast<SkMaskFilter*>(
|
||||
SkFlattenable::Deserialize(
|
||||
kSkMaskFilter_Type, data, size, procs).release()));
|
||||
}
|
||||
|
||||
private:
|
||||
static void RegisterFlattenables();
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkMath_DEFINED
|
||||
#define SkMath_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
// 64bit -> 32bit utilities
|
||||
|
||||
// Handy util that can be passed two ints, and will automatically promote to
|
||||
// 64bits before the multiply, so the caller doesn't have to remember to cast
|
||||
// e.g. (int64_t)a * b;
|
||||
static inline int64_t sk_64_mul(int64_t a, int64_t b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Given an integer and a positive (max) integer, return the value
|
||||
* pinned against 0 and max, inclusive.
|
||||
* @param value The value we want returned pinned between [0...max]
|
||||
* @param max The positive max value
|
||||
* @return 0 if value < 0, max if value > max, else value
|
||||
*/
|
||||
static inline int SkClampMax(int value, int max) {
|
||||
// ensure that max is positive
|
||||
SkASSERT(max >= 0);
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if (value > max) {
|
||||
value = max;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if value is a power of 2. Does not explicitly check for
|
||||
* value <= 0.
|
||||
*/
|
||||
template <typename T> constexpr inline bool SkIsPow2(T value) {
|
||||
return (value & (value - 1)) == 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Return a*b/((1 << shift) - 1), rounding any fractional bits.
|
||||
* Only valid if a and b are unsigned and <= 32767 and shift is > 0 and <= 8
|
||||
*/
|
||||
static inline unsigned SkMul16ShiftRound(U16CPU a, U16CPU b, int shift) {
|
||||
SkASSERT(a <= 32767);
|
||||
SkASSERT(b <= 32767);
|
||||
SkASSERT(shift > 0 && shift <= 8);
|
||||
unsigned prod = a*b + (1 << (shift - 1));
|
||||
return (prod + (prod >> shift)) >> shift;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a*b/255, rounding any fractional bits.
|
||||
* Only valid if a and b are unsigned and <= 32767.
|
||||
*/
|
||||
static inline U8CPU SkMulDiv255Round(U16CPU a, U16CPU b) {
|
||||
SkASSERT(a <= 32767);
|
||||
SkASSERT(b <= 32767);
|
||||
unsigned prod = a*b + 128;
|
||||
return (prod + (prod >> 8)) >> 8;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -8,46 +8,26 @@
|
|||
#ifndef SkMatrix_DEFINED
|
||||
#define SkMatrix_DEFINED
|
||||
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/base/SkMacros.h"
|
||||
#include "include/private/base/SkTo.h"
|
||||
#include "include/private/SkMacros.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
struct SkPoint3;
|
||||
struct SkRSXform;
|
||||
struct SkSize;
|
||||
|
||||
// Remove when clients are updated to live without this
|
||||
#define SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
|
||||
|
||||
/**
|
||||
* When we transform points through a matrix containing perspective (the bottom row is something
|
||||
* other than 0,0,1), the bruteforce math can produce confusing results (since we might divide
|
||||
* by 0, or a negative w value). By default, methods that map rects and paths will apply
|
||||
* perspective clipping, but this can be changed by specifying kYes to those methods.
|
||||
*/
|
||||
enum class SkApplyPerspectiveClip {
|
||||
kNo, //!< Don't pre-clip the geometry before applying the (perspective) matrix
|
||||
kYes, //!< Do pre-clip the geometry before applying the (perspective) matrix
|
||||
};
|
||||
struct SkPoint3;
|
||||
class SkString;
|
||||
|
||||
/** \class SkMatrix
|
||||
SkMatrix holds a 3x3 matrix for transforming coordinates. This allows mapping
|
||||
SkPoint and vectors with translation, scaling, skewing, rotation, and
|
||||
perspective.
|
||||
|
||||
SkMatrix elements are in row major order.
|
||||
SkMatrix constexpr default constructs to identity.
|
||||
SkMatrix elements are in row major order. SkMatrix does not have a constructor,
|
||||
so it must be explicitly initialized. setIdentity() initializes SkMatrix
|
||||
so it has no effect. setTranslate(), setScale(), setSkew(), setRotate(), set9 and setAll()
|
||||
initializes all SkMatrix elements with the corresponding mapping.
|
||||
|
||||
SkMatrix includes a hidden variable that classifies the type of matrix to
|
||||
improve performance. SkMatrix is not thread safe unless getType() is called first.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_063
|
||||
*/
|
||||
SK_BEGIN_REQUIRE_DENSE
|
||||
class SK_API SkMatrix {
|
||||
|
@ -71,12 +51,27 @@ public:
|
|||
@param sy vertical scale factor
|
||||
@return SkMatrix with scale
|
||||
*/
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT Scale(SkScalar sx, SkScalar sy) {
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar sx, SkScalar sy) {
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy);
|
||||
return m;
|
||||
}
|
||||
|
||||
/** Sets SkMatrix to scale by (scale, scale). Returned matrix is:
|
||||
|
||||
| scale 0 0 |
|
||||
| 0 scale 0 |
|
||||
| 0 0 1 |
|
||||
|
||||
@param scale horizontal and vertical scale factor
|
||||
@return SkMatrix with scale
|
||||
*/
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar scale) {
|
||||
SkMatrix m;
|
||||
m.setScale(scale, scale);
|
||||
return m;
|
||||
}
|
||||
|
||||
/** Sets SkMatrix to translate by (dx, dy). Returned matrix is:
|
||||
|
||||
| 1 0 dx |
|
||||
|
@ -87,76 +82,11 @@ public:
|
|||
@param dy vertical translation
|
||||
@return SkMatrix with translation
|
||||
*/
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkScalar dx, SkScalar dy) {
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) {
|
||||
SkMatrix m;
|
||||
m.setTranslate(dx, dy);
|
||||
return m;
|
||||
}
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkVector t) { return Translate(t.x(), t.y()); }
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkIVector t) { return Translate(t.x(), t.y()); }
|
||||
|
||||
/** Sets SkMatrix to rotate by |deg| about a pivot point at (0, 0).
|
||||
|
||||
@param deg rotation angle in degrees (positive rotates clockwise)
|
||||
@return SkMatrix with rotation
|
||||
*/
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT RotateDeg(SkScalar deg) {
|
||||
SkMatrix m;
|
||||
m.setRotate(deg);
|
||||
return m;
|
||||
}
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT RotateDeg(SkScalar deg, SkPoint pt) {
|
||||
SkMatrix m;
|
||||
m.setRotate(deg, pt.x(), pt.y());
|
||||
return m;
|
||||
}
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT RotateRad(SkScalar rad) {
|
||||
return RotateDeg(SkRadiansToDegrees(rad));
|
||||
}
|
||||
|
||||
/** Sets SkMatrix to skew by (kx, ky) about pivot point (0, 0).
|
||||
|
||||
@param kx horizontal skew factor
|
||||
@param ky vertical skew factor
|
||||
@return SkMatrix with skew
|
||||
*/
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT Skew(SkScalar kx, SkScalar ky) {
|
||||
SkMatrix m;
|
||||
m.setSkew(kx, ky);
|
||||
return m;
|
||||
}
|
||||
|
||||
/** \enum SkMatrix::ScaleToFit
|
||||
ScaleToFit describes how SkMatrix is constructed to map one SkRect to another.
|
||||
ScaleToFit may allow SkMatrix to have unequal horizontal and vertical scaling,
|
||||
or may restrict SkMatrix to square scaling. If restricted, ScaleToFit specifies
|
||||
how SkMatrix maps to the side or center of the destination SkRect.
|
||||
*/
|
||||
enum ScaleToFit {
|
||||
kFill_ScaleToFit, //!< scales in x and y to fill destination SkRect
|
||||
kStart_ScaleToFit, //!< scales and aligns to left and top
|
||||
kCenter_ScaleToFit, //!< scales and aligns to center
|
||||
kEnd_ScaleToFit, //!< scales and aligns to right and bottom
|
||||
};
|
||||
|
||||
/** Returns SkMatrix set to scale and translate src to dst. ScaleToFit selects
|
||||
whether mapping completely fills dst or preserves the aspect ratio, and how to
|
||||
align src within dst. Returns the identity SkMatrix if src is empty. If dst is
|
||||
empty, returns SkMatrix set to:
|
||||
|
||||
| 0 0 0 |
|
||||
| 0 0 0 |
|
||||
| 0 0 1 |
|
||||
|
||||
@param src SkRect to map from
|
||||
@param dst SkRect to map to
|
||||
@param mode How to handle the mapping
|
||||
@return SkMatrix mapping src to dst
|
||||
*/
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT RectToRect(const SkRect& src, const SkRect& dst,
|
||||
ScaleToFit mode = kFill_ScaleToFit) {
|
||||
return MakeRectToRect(src, dst, mode);
|
||||
}
|
||||
|
||||
/** Sets SkMatrix to:
|
||||
|
||||
|
@ -326,8 +256,6 @@ public:
|
|||
|
||||
@param tol to be deprecated
|
||||
@return true if SkMatrix only rotates, uniformly scales, translates
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_isSimilarity
|
||||
*/
|
||||
bool isSimilarity(SkScalar tol = SK_ScalarNearlyZero) const;
|
||||
|
||||
|
@ -341,12 +269,10 @@ public:
|
|||
|
||||
@param tol to be deprecated
|
||||
@return true if SkMatrix only rotates, scales, translates
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_preservesRightAngles
|
||||
*/
|
||||
bool preservesRightAngles(SkScalar tol = SK_ScalarNearlyZero) const;
|
||||
|
||||
/** SkMatrix organizes its values in row-major order. These members correspond to
|
||||
/** SkMatrix organizes its values in row order. These members correspond to
|
||||
each value in SkMatrix.
|
||||
*/
|
||||
static constexpr int kMScaleX = 0; //!< horizontal scale factor
|
||||
|
@ -359,7 +285,7 @@ public:
|
|||
static constexpr int kMPersp1 = 7; //!< input y perspective factor
|
||||
static constexpr int kMPersp2 = 8; //!< perspective bias
|
||||
|
||||
/** Affine arrays are in column-major order to match the matrix used by
|
||||
/** Affine arrays are in column major order to match the matrix used by
|
||||
PDF and XPS.
|
||||
*/
|
||||
static constexpr int kAScaleX = 0; //!< horizontal scale factor
|
||||
|
@ -393,19 +319,6 @@ public:
|
|||
return fMat[index];
|
||||
}
|
||||
|
||||
/** Returns one matrix value from a particular row/column. Asserts if index is out
|
||||
of range and SK_DEBUG is defined.
|
||||
|
||||
@param r matrix row to fetch
|
||||
@param c matrix column to fetch
|
||||
@return value at the given matrix position
|
||||
*/
|
||||
SkScalar rc(int r, int c) const {
|
||||
SkASSERT(r >= 0 && r <= 2);
|
||||
SkASSERT(c >= 0 && c <= 2);
|
||||
return fMat[r*3 + c];
|
||||
}
|
||||
|
||||
/** Returns scale factor multiplied by x-axis input, contributing to x-axis output.
|
||||
With mapPoints(), scales SkPoint along the x-axis.
|
||||
|
||||
|
@ -559,8 +472,8 @@ public:
|
|||
@param persp2 perspective scale factor to store
|
||||
*/
|
||||
SkMatrix& setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX,
|
||||
SkScalar skewY, SkScalar scaleY, SkScalar transY,
|
||||
SkScalar persp0, SkScalar persp1, SkScalar persp2) {
|
||||
SkScalar skewY, SkScalar scaleY, SkScalar transY,
|
||||
SkScalar persp0, SkScalar persp1, SkScalar persp2) {
|
||||
fMat[kMScaleX] = scaleX;
|
||||
fMat[kMSkewX] = skewX;
|
||||
fMat[kMTransX] = transX;
|
||||
|
@ -704,8 +617,6 @@ public:
|
|||
|
||||
@param rsxForm compressed SkRSXform matrix
|
||||
@return reference to SkMatrix
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_setRSXform
|
||||
*/
|
||||
SkMatrix& setRSXform(const SkRSXform& rsxForm);
|
||||
|
||||
|
@ -1009,6 +920,34 @@ public:
|
|||
*/
|
||||
SkMatrix& postScale(SkScalar sx, SkScalar sy);
|
||||
|
||||
/** Sets SkMatrix to SkMatrix constructed from scaling by (1/divx, 1/divy),
|
||||
about pivot point (px, py), multiplied by SkMatrix.
|
||||
|
||||
Returns false if either divx or divy is zero.
|
||||
|
||||
Given:
|
||||
|
||||
| J K L | | sx 0 0 |
|
||||
Matrix = | M N O |, I(divx, divy) = | 0 sy 0 |
|
||||
| P Q R | | 0 0 1 |
|
||||
|
||||
where
|
||||
|
||||
sx = 1 / divx
|
||||
sy = 1 / divy
|
||||
|
||||
sets SkMatrix to:
|
||||
|
||||
| sx 0 0 | | J K L | | sx*J sx*K sx*L |
|
||||
I(divx, divy) * Matrix = | 0 sy 0 | | M N O | = | sy*M sy*N sy*O |
|
||||
| 0 0 1 | | P Q R | | P Q R |
|
||||
|
||||
@param divx integer divisor for inverse scale in x
|
||||
@param divy integer divisor for inverse scale in y
|
||||
@return true on successful scale
|
||||
*/
|
||||
bool postIDiv(int divx, int divy);
|
||||
|
||||
/** Sets SkMatrix to SkMatrix constructed from rotating by degrees about pivot point
|
||||
(px, py), multiplied by SkMatrix.
|
||||
This can be thought of as rotating about a pivot point after applying SkMatrix.
|
||||
|
@ -1135,9 +1074,19 @@ public:
|
|||
*/
|
||||
SkMatrix& postConcat(const SkMatrix& other);
|
||||
|
||||
#ifndef SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
|
||||
private:
|
||||
#endif
|
||||
/** \enum SkMatrix::ScaleToFit
|
||||
ScaleToFit describes how SkMatrix is constructed to map one SkRect to another.
|
||||
ScaleToFit may allow SkMatrix to have unequal horizontal and vertical scaling,
|
||||
or may restrict SkMatrix to square scaling. If restricted, ScaleToFit specifies
|
||||
how SkMatrix maps to the side or center of the destination SkRect.
|
||||
*/
|
||||
enum ScaleToFit {
|
||||
kFill_ScaleToFit, //!< scales in x and y to fill destination SkRect
|
||||
kStart_ScaleToFit, //!< scales and aligns to left and top
|
||||
kCenter_ScaleToFit, //!< scales and aligns to center
|
||||
kEnd_ScaleToFit, //!< scales and aligns to right and bottom
|
||||
};
|
||||
|
||||
/** Sets SkMatrix to scale and translate src SkRect to dst SkRect. stf selects whether
|
||||
mapping completely fills dst or preserves the aspect ratio, and how to align
|
||||
src within dst. Returns false if src is empty, and sets SkMatrix to identity.
|
||||
|
@ -1149,9 +1098,9 @@ private:
|
|||
|
||||
@param src SkRect to map from
|
||||
@param dst SkRect to map to
|
||||
@param stf one of: kFill_ScaleToFit, kStart_ScaleToFit,
|
||||
kCenter_ScaleToFit, kEnd_ScaleToFit
|
||||
@return true if SkMatrix can represent SkRect mapping
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_setRectToRect
|
||||
*/
|
||||
bool setRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf);
|
||||
|
||||
|
@ -1166,6 +1115,8 @@ private:
|
|||
|
||||
@param src SkRect to map from
|
||||
@param dst SkRect to map to
|
||||
@param stf one of: kFill_ScaleToFit, kStart_ScaleToFit,
|
||||
kCenter_ScaleToFit, kEnd_ScaleToFit
|
||||
@return SkMatrix mapping src to dst
|
||||
*/
|
||||
static SkMatrix MakeRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf) {
|
||||
|
@ -1173,9 +1124,6 @@ private:
|
|||
m.setRectToRect(src, dst, stf);
|
||||
return m;
|
||||
}
|
||||
#ifndef SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
|
||||
public:
|
||||
#endif
|
||||
|
||||
/** Sets SkMatrix to map src to dst. count must be zero or greater, and four or less.
|
||||
|
||||
|
@ -1189,8 +1137,6 @@ public:
|
|||
@param dst SkPoint to map to
|
||||
@param count number of SkPoint in src and dst
|
||||
@return true if SkMatrix was constructed successfully
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_setPolyToPoly
|
||||
*/
|
||||
bool setPolyToPoly(const SkPoint src[], const SkPoint dst[], int count);
|
||||
|
||||
|
@ -1222,8 +1168,6 @@ public:
|
|||
Affine 3 by 2 matrices in column major order are used by OpenGL and XPS.
|
||||
|
||||
@param affine storage for 3 by 2 affine matrix
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_SetAffineIdentity
|
||||
*/
|
||||
static void SetAffineIdentity(SkScalar affine[6]);
|
||||
|
||||
|
@ -1255,23 +1199,6 @@ public:
|
|||
*/
|
||||
SkMatrix& setAffine(const SkScalar affine[6]);
|
||||
|
||||
/**
|
||||
* A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 1].
|
||||
* However, for most uses (e.g. mapPoints) a bottom row of [0, 0, X] behaves like a
|
||||
* non-perspective matrix, though it will be categorized as perspective. Calling
|
||||
* normalizePerspective() will change the matrix such that, if its bottom row was [0, 0, X],
|
||||
* it will be changed to [0, 0, 1] by scaling the rest of the matrix by 1/X.
|
||||
*
|
||||
* | A B C | | A/X B/X C/X |
|
||||
* | D E F | -> | D/X E/X F/X | for X != 0
|
||||
* | 0 0 X | | 0 0 1 |
|
||||
*/
|
||||
void normalizePerspective() {
|
||||
if (fMat[8] != 1) {
|
||||
this->doNormalizePerspective();
|
||||
}
|
||||
}
|
||||
|
||||
/** Maps src SkPoint array of length count to dst SkPoint array of equal or greater
|
||||
length. SkPoint are mapped by multiplying each SkPoint by SkMatrix. Given:
|
||||
|
||||
|
@ -1297,8 +1224,6 @@ public:
|
|||
@param dst storage for mapped SkPoint
|
||||
@param src SkPoint to transform
|
||||
@param count number of SkPoint to transform
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapPoints
|
||||
*/
|
||||
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const;
|
||||
|
||||
|
@ -1345,37 +1270,9 @@ public:
|
|||
@param dst storage for mapped SkPoint3 array
|
||||
@param src SkPoint3 array to transform
|
||||
@param count items in SkPoint3 array to transform
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapHomogeneousPoints
|
||||
*/
|
||||
void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const;
|
||||
|
||||
/**
|
||||
* Returns homogeneous points, starting with 2D src points (with implied w = 1).
|
||||
*/
|
||||
void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint src[], int count) const;
|
||||
|
||||
/** Returns SkPoint pt multiplied by SkMatrix. Given:
|
||||
|
||||
| A B C | | x |
|
||||
Matrix = | D E F |, pt = | y |
|
||||
| G H I | | 1 |
|
||||
|
||||
result is computed as:
|
||||
|
||||
|A B C| |x| Ax+By+C Dx+Ey+F
|
||||
Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
|
||||
|G H I| |1| Gx+Hy+I Gx+Hy+I
|
||||
|
||||
@param p SkPoint to map
|
||||
@return mapped SkPoint
|
||||
*/
|
||||
SkPoint mapPoint(SkPoint pt) const {
|
||||
SkPoint result;
|
||||
this->mapXY(pt.x(), pt.y(), &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Maps SkPoint (x, y) to result. SkPoint is mapped by multiplying by SkMatrix. Given:
|
||||
|
||||
| A B C | | x |
|
||||
|
@ -1391,8 +1288,6 @@ public:
|
|||
@param x x-axis value of SkPoint to map
|
||||
@param y y-axis value of SkPoint to map
|
||||
@param result storage for mapped SkPoint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapXY
|
||||
*/
|
||||
void mapXY(SkScalar x, SkScalar y, SkPoint* result) const;
|
||||
|
||||
|
@ -1418,33 +1313,6 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** Returns (0, 0) multiplied by SkMatrix. Given:
|
||||
|
||||
| A B C | | 0 |
|
||||
Matrix = | D E F |, pt = | 0 |
|
||||
| G H I | | 1 |
|
||||
|
||||
result is computed as:
|
||||
|
||||
|A B C| |0| C F
|
||||
Matrix * pt = |D E F| |0| = |C F I| = - , -
|
||||
|G H I| |1| I I
|
||||
|
||||
@return mapped (0, 0)
|
||||
*/
|
||||
SkPoint mapOrigin() const {
|
||||
SkScalar x = this->getTranslateX(),
|
||||
y = this->getTranslateY();
|
||||
if (this->hasPerspective()) {
|
||||
SkScalar w = fMat[kMPersp2];
|
||||
if (w) { w = 1 / w; }
|
||||
x *= w;
|
||||
y *= w;
|
||||
}
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
/** Maps src vector array of length count to vector SkPoint array of equal or greater
|
||||
length. Vectors are mapped by multiplying each vector by SkMatrix, treating
|
||||
SkMatrix translation as zero. Given:
|
||||
|
@ -1471,8 +1339,6 @@ public:
|
|||
@param dst storage for mapped vectors
|
||||
@param src vectors to transform
|
||||
@param count number of vectors to transform
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapVectors
|
||||
*/
|
||||
void mapVectors(SkVector dst[], const SkVector src[], int count) const;
|
||||
|
||||
|
@ -1555,13 +1421,9 @@ public:
|
|||
|
||||
@param dst storage for bounds of mapped SkPoint
|
||||
@param src SkRect to map
|
||||
@param pc whether to apply perspective clipping
|
||||
@return true if dst is equivalent to mapped src
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapRect
|
||||
*/
|
||||
bool mapRect(SkRect* dst, const SkRect& src,
|
||||
SkApplyPerspectiveClip pc = SkApplyPerspectiveClip::kYes) const;
|
||||
bool mapRect(SkRect* dst, const SkRect& src) const;
|
||||
|
||||
/** Sets rect to bounds of rect corners mapped by SkMatrix.
|
||||
Returns true if mapped corners are computed rect corners.
|
||||
|
@ -1569,11 +1431,10 @@ public:
|
|||
Returned value is the same as calling rectStaysRect().
|
||||
|
||||
@param rect rectangle to map, and storage for bounds of mapped corners
|
||||
@param pc whether to apply perspective clipping
|
||||
@return true if result is equivalent to mapped rect
|
||||
*/
|
||||
bool mapRect(SkRect* rect, SkApplyPerspectiveClip pc = SkApplyPerspectiveClip::kYes) const {
|
||||
return this->mapRect(rect, *rect, pc);
|
||||
bool mapRect(SkRect* rect) const {
|
||||
return this->mapRect(rect, *rect);
|
||||
}
|
||||
|
||||
/** Returns bounds of src corners mapped by SkMatrix.
|
||||
|
@ -1581,10 +1442,9 @@ public:
|
|||
@param src rectangle to map
|
||||
@return mapped bounds
|
||||
*/
|
||||
SkRect mapRect(const SkRect& src,
|
||||
SkApplyPerspectiveClip pc = SkApplyPerspectiveClip::kYes) const {
|
||||
SkRect mapRect(const SkRect& src) const {
|
||||
SkRect dst;
|
||||
(void)this->mapRect(&dst, src, pc);
|
||||
(void)this->mapRect(&dst, src);
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
@ -1612,9 +1472,6 @@ public:
|
|||
|
||||
@param dst storage for mapped corner SkPoint
|
||||
@param rect SkRect to map
|
||||
|
||||
Note: this does not perform perspective clipping (as that might result in more than
|
||||
4 points, so results are suspect if the matrix contains perspective.
|
||||
*/
|
||||
void mapRectToQuad(SkPoint dst[4], const SkRect& rect) const {
|
||||
// This could potentially be faster if we only transformed each x and y of the rect once.
|
||||
|
@ -1628,8 +1485,6 @@ public:
|
|||
|
||||
@param dst storage for bounds of mapped SkPoint
|
||||
@param src SkRect to map
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapRectScaleTranslate
|
||||
*/
|
||||
void mapRectScaleTranslate(SkRect* dst, const SkRect& src) const;
|
||||
|
||||
|
@ -1640,11 +1495,45 @@ public:
|
|||
|
||||
@param radius circle size to map
|
||||
@return average mapped radius
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_mapRadius
|
||||
*/
|
||||
SkScalar mapRadius(SkScalar radius) const;
|
||||
|
||||
/** Returns true if a unit step on x-axis at some y-axis value mapped through SkMatrix
|
||||
can be represented by a constant vector. Returns true if getType() returns
|
||||
kIdentity_Mask, or combinations of: kTranslate_Mask, kScale_Mask, and kAffine_Mask.
|
||||
|
||||
May return true if getType() returns kPerspective_Mask, but only when SkMatrix
|
||||
does not include rotation or skewing along the y-axis.
|
||||
|
||||
@return true if SkMatrix does not have complex perspective
|
||||
*/
|
||||
bool isFixedStepInX() const;
|
||||
|
||||
/** Returns vector representing a unit step on x-axis at y mapped through SkMatrix.
|
||||
If isFixedStepInX() is false, returned value is undefined.
|
||||
|
||||
@param y position of line parallel to x-axis
|
||||
@return vector advance of mapped unit step on x-axis
|
||||
*/
|
||||
SkVector fixedStepInX(SkScalar y) const;
|
||||
|
||||
/** Returns true if SkMatrix equals m, using an efficient comparison.
|
||||
|
||||
Returns false when the sign of zero values is the different; when one
|
||||
matrix has positive zero value and the other has negative zero value.
|
||||
|
||||
Returns true even when both SkMatrix contain NaN.
|
||||
|
||||
NaN never equals any value, including itself. To improve performance, NaN values
|
||||
are treated as bit patterns that are equal if their bit patterns are equal.
|
||||
|
||||
@param m SkMatrix to compare
|
||||
@return true if m and SkMatrix are represented by identical bit patterns
|
||||
*/
|
||||
bool cheapEqualTo(const SkMatrix& m) const {
|
||||
return 0 == memcmp(fMat, m.fMat, sizeof(fMat));
|
||||
}
|
||||
|
||||
/** Compares a and b; returns true if a and b are numerically equal. Returns true
|
||||
even if sign of zero values are different. Returns false if either SkMatrix
|
||||
contains NaN, even if the other SkMatrix also contains NaN.
|
||||
|
@ -1670,8 +1559,6 @@ public:
|
|||
/** Writes text representation of SkMatrix to standard output. Floating point values
|
||||
are written with limited precision; it may not be possible to reconstruct
|
||||
original SkMatrix from output.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_dump
|
||||
*/
|
||||
void dump() const;
|
||||
|
||||
|
@ -1680,8 +1567,6 @@ public:
|
|||
Returns -1 if scale factor overflows or SkMatrix contains perspective.
|
||||
|
||||
@return minimum scale factor
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_getMinScale
|
||||
*/
|
||||
SkScalar getMinScale() const;
|
||||
|
||||
|
@ -1690,8 +1575,6 @@ public:
|
|||
Returns -1 if scale factor overflows or SkMatrix contains perspective.
|
||||
|
||||
@return maximum scale factor
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_getMaxScale
|
||||
*/
|
||||
SkScalar getMaxScale() const;
|
||||
|
||||
|
@ -1723,8 +1606,6 @@ public:
|
|||
@param scale axes scaling factors; may be nullptr
|
||||
@param remaining SkMatrix without scaling; may be nullptr
|
||||
@return true if scale can be computed
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_decomposeScale
|
||||
*/
|
||||
bool decomposeScale(SkSize* scale, SkMatrix* remaining = nullptr) const;
|
||||
|
||||
|
@ -1735,8 +1616,6 @@ public:
|
|||
| 0 0 1 |
|
||||
|
||||
@return const identity SkMatrix
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_I
|
||||
*/
|
||||
static const SkMatrix& I();
|
||||
|
||||
|
@ -1748,8 +1627,6 @@ public:
|
|||
| SK_ScalarMax SK_ScalarMax SK_ScalarMax |
|
||||
|
||||
@return const invalid SkMatrix
|
||||
|
||||
example: https://fiddle.skia.org/c/@Matrix_InvalidMatrix
|
||||
*/
|
||||
static const SkMatrix& InvalidMatrix();
|
||||
|
||||
|
@ -1777,10 +1654,6 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
friend SkMatrix operator*(const SkMatrix& a, const SkMatrix& b) {
|
||||
return Concat(a, b);
|
||||
}
|
||||
|
||||
/** Sets internal cache to unknown state. Use to force update after repeated
|
||||
modifications to SkMatrix element reference returned by operator[](int index).
|
||||
*/
|
||||
|
@ -1812,17 +1685,14 @@ public:
|
|||
fMat[kMPersp1] = 0;
|
||||
fMat[kMPersp2] = 1;
|
||||
|
||||
int mask = 0;
|
||||
unsigned mask = 0;
|
||||
if (sx != 1 || sy != 1) {
|
||||
mask |= kScale_Mask;
|
||||
}
|
||||
if (tx != 0.0f || ty != 0.0f) {
|
||||
if (tx || ty) {
|
||||
mask |= kTranslate_Mask;
|
||||
}
|
||||
if (sx != 0 && sy != 0) {
|
||||
mask |= kRectStaysRect_Mask;
|
||||
}
|
||||
this->setTypeMask(mask);
|
||||
this->setTypeMask(mask | kRectStaysRect_Mask);
|
||||
}
|
||||
|
||||
/** Returns true if all elements of the matrix are finite. Returns false if any
|
||||
|
@ -1859,12 +1729,12 @@ private:
|
|||
kPerspective_Mask |
|
||||
kRectStaysRect_Mask;
|
||||
|
||||
SkScalar fMat[9];
|
||||
mutable int32_t fTypeMask;
|
||||
SkScalar fMat[9];
|
||||
mutable uint32_t fTypeMask;
|
||||
|
||||
constexpr SkMatrix(SkScalar sx, SkScalar kx, SkScalar tx,
|
||||
SkScalar ky, SkScalar sy, SkScalar ty,
|
||||
SkScalar p0, SkScalar p1, SkScalar p2, int typeMask)
|
||||
SkScalar p0, SkScalar p1, SkScalar p2, uint32_t typeMask)
|
||||
: fMat{sx, kx, tx,
|
||||
ky, sy, ty,
|
||||
p0, p1, p2}
|
||||
|
@ -1880,18 +1750,18 @@ private:
|
|||
SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask ||
|
||||
((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask)
|
||||
== (kUnknown_Mask | kOnlyPerspectiveValid_Mask));
|
||||
fTypeMask = mask;
|
||||
fTypeMask = SkToU8(mask);
|
||||
}
|
||||
|
||||
void orTypeMask(int mask) {
|
||||
SkASSERT((mask & kORableMasks) == mask);
|
||||
fTypeMask |= mask;
|
||||
fTypeMask = SkToU8(fTypeMask | mask);
|
||||
}
|
||||
|
||||
void clearTypeMask(int mask) {
|
||||
// only allow a valid mask
|
||||
SkASSERT((mask & kAllMasks) == mask);
|
||||
fTypeMask &= ~mask;
|
||||
fTypeMask = fTypeMask & ~mask;
|
||||
}
|
||||
|
||||
TypeMask getPerspectiveTypeMaskOnly() const {
|
||||
|
@ -1983,12 +1853,9 @@ private:
|
|||
*/
|
||||
size_t readFromMemory(const void* buffer, size_t length);
|
||||
|
||||
// legacy method -- still needed? why not just postScale(1/divx, ...)?
|
||||
bool postIDiv(int divx, int divy);
|
||||
void doNormalizePerspective();
|
||||
|
||||
friend class SkPerspIter;
|
||||
friend class SkMatrixPriv;
|
||||
friend class SkReader32;
|
||||
friend class SerializationTest;
|
||||
};
|
||||
SK_END_REQUIRE_DENSE
|
||||
|
|
|
@ -0,0 +1,480 @@
|
|||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkMatrix44_DEFINED
|
||||
#define SkMatrix44_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SK_MSCALAR_IS_DOUBLE
|
||||
#ifdef SK_MSCALAR_IS_FLOAT
|
||||
#error "can't define MSCALAR both as DOUBLE and FLOAT"
|
||||
#endif
|
||||
typedef double SkMScalar;
|
||||
|
||||
static inline double SkFloatToMScalar(float x) {
|
||||
return static_cast<double>(x);
|
||||
}
|
||||
static inline float SkMScalarToFloat(double x) {
|
||||
return static_cast<float>(x);
|
||||
}
|
||||
static inline double SkDoubleToMScalar(double x) {
|
||||
return x;
|
||||
}
|
||||
static inline double SkMScalarToDouble(double x) {
|
||||
return x;
|
||||
}
|
||||
static inline double SkMScalarAbs(double x) {
|
||||
return fabs(x);
|
||||
}
|
||||
static const SkMScalar SK_MScalarPI = 3.141592653589793;
|
||||
static const SkMScalar SK_MScalarNaN = SK_DoubleNaN;
|
||||
|
||||
#define SkMScalarFloor(x) sk_double_floor(x)
|
||||
#define SkMScalarCeil(x) sk_double_ceil(x)
|
||||
#define SkMScalarRound(x) sk_double_round(x)
|
||||
|
||||
#define SkMScalarFloorToInt(x) sk_double_floor2int(x)
|
||||
#define SkMScalarCeilToInt(x) sk_double_ceil2int(x)
|
||||
#define SkMScalarRoundToInt(x) sk_double_round2int(x)
|
||||
|
||||
|
||||
#elif defined SK_MSCALAR_IS_FLOAT
|
||||
#ifdef SK_MSCALAR_IS_DOUBLE
|
||||
#error "can't define MSCALAR both as DOUBLE and FLOAT"
|
||||
#endif
|
||||
typedef float SkMScalar;
|
||||
|
||||
static inline float SkFloatToMScalar(float x) {
|
||||
return x;
|
||||
}
|
||||
static inline float SkMScalarToFloat(float x) {
|
||||
return x;
|
||||
}
|
||||
static inline float SkDoubleToMScalar(double x) {
|
||||
return sk_double_to_float(x);
|
||||
}
|
||||
static inline double SkMScalarToDouble(float x) {
|
||||
return static_cast<double>(x);
|
||||
}
|
||||
static inline float SkMScalarAbs(float x) {
|
||||
return sk_float_abs(x);
|
||||
}
|
||||
static const SkMScalar SK_MScalarPI = 3.14159265f;
|
||||
static const SkMScalar SK_MScalarNaN = SK_FloatNaN;
|
||||
|
||||
#define SkMScalarFloor(x) sk_float_floor(x)
|
||||
#define SkMScalarCeil(x) sk_float_ceil(x)
|
||||
#define SkMScalarRound(x) sk_float_round(x)
|
||||
|
||||
#define SkMScalarFloorToInt(x) sk_float_floor2int(x)
|
||||
#define SkMScalarCeilToInt(x) sk_float_ceil2int(x)
|
||||
#define SkMScalarRoundToInt(x) sk_float_round2int(x)
|
||||
|
||||
#endif
|
||||
|
||||
#define SkIntToMScalar(n) static_cast<SkMScalar>(n)
|
||||
|
||||
#define SkMScalarToScalar(x) SkMScalarToFloat(x)
|
||||
#define SkScalarToMScalar(x) SkFloatToMScalar(x)
|
||||
|
||||
static const SkMScalar SK_MScalar1 = 1;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SkVector4 {
|
||||
SkScalar fData[4];
|
||||
|
||||
SkVector4() {
|
||||
this->set(0, 0, 0, 1);
|
||||
}
|
||||
SkVector4(const SkVector4& src) {
|
||||
memcpy(fData, src.fData, sizeof(fData));
|
||||
}
|
||||
SkVector4(SkScalar x, SkScalar y, SkScalar z, SkScalar w = SK_Scalar1) {
|
||||
fData[0] = x;
|
||||
fData[1] = y;
|
||||
fData[2] = z;
|
||||
fData[3] = w;
|
||||
}
|
||||
|
||||
SkVector4& operator=(const SkVector4& src) {
|
||||
memcpy(fData, src.fData, sizeof(fData));
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const SkVector4& v) const {
|
||||
return fData[0] == v.fData[0] && fData[1] == v.fData[1] &&
|
||||
fData[2] == v.fData[2] && fData[3] == v.fData[3];
|
||||
}
|
||||
bool operator!=(const SkVector4& v) const { return !(*this == v); }
|
||||
bool equals(SkScalar x, SkScalar y, SkScalar z, SkScalar w = SK_Scalar1) {
|
||||
return fData[0] == x && fData[1] == y &&
|
||||
fData[2] == z && fData[3] == w;
|
||||
}
|
||||
|
||||
void set(SkScalar x, SkScalar y, SkScalar z, SkScalar w = SK_Scalar1) {
|
||||
fData[0] = x;
|
||||
fData[1] = y;
|
||||
fData[2] = z;
|
||||
fData[3] = w;
|
||||
}
|
||||
};
|
||||
|
||||
/** \class SkMatrix44
|
||||
|
||||
The SkMatrix44 class holds a 4x4 matrix.
|
||||
|
||||
*/
|
||||
class SK_API SkMatrix44 {
|
||||
public:
|
||||
|
||||
enum Uninitialized_Constructor {
|
||||
kUninitialized_Constructor
|
||||
};
|
||||
enum Identity_Constructor {
|
||||
kIdentity_Constructor
|
||||
};
|
||||
enum NaN_Constructor {
|
||||
kNaN_Constructor
|
||||
};
|
||||
|
||||
SkMatrix44(Uninitialized_Constructor) {} // ironically, cannot be constexpr
|
||||
|
||||
constexpr SkMatrix44(Identity_Constructor)
|
||||
: fMat{{ 1, 0, 0, 0, },
|
||||
{ 0, 1, 0, 0, },
|
||||
{ 0, 0, 1, 0, },
|
||||
{ 0, 0, 0, 1, }}
|
||||
, fTypeMask(kIdentity_Mask) {}
|
||||
|
||||
SkMatrix44(NaN_Constructor)
|
||||
: fMat{{ SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN },
|
||||
{ SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN },
|
||||
{ SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN },
|
||||
{ SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN, SK_MScalarNaN }}
|
||||
, fTypeMask(kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask) {}
|
||||
|
||||
constexpr SkMatrix44() : SkMatrix44{kIdentity_Constructor} {}
|
||||
|
||||
SkMatrix44(const SkMatrix44& src) = default;
|
||||
|
||||
SkMatrix44& operator=(const SkMatrix44& src) = default;
|
||||
|
||||
SkMatrix44(const SkMatrix44& a, const SkMatrix44& b) {
|
||||
this->setConcat(a, b);
|
||||
}
|
||||
|
||||
bool operator==(const SkMatrix44& other) const;
|
||||
bool operator!=(const SkMatrix44& other) const {
|
||||
return !(other == *this);
|
||||
}
|
||||
|
||||
/* When converting from SkMatrix44 to SkMatrix, the third row and
|
||||
* column is dropped. When converting from SkMatrix to SkMatrix44
|
||||
* the third row and column remain as identity:
|
||||
* [ a b c ] [ a b 0 c ]
|
||||
* [ d e f ] -> [ d e 0 f ]
|
||||
* [ g h i ] [ 0 0 1 0 ]
|
||||
* [ g h 0 i ]
|
||||
*/
|
||||
SkMatrix44(const SkMatrix&);
|
||||
SkMatrix44& operator=(const SkMatrix& src);
|
||||
operator SkMatrix() const;
|
||||
|
||||
/**
|
||||
* Return a reference to a const identity matrix
|
||||
*/
|
||||
static const SkMatrix44& I();
|
||||
|
||||
using TypeMask = uint8_t;
|
||||
enum : TypeMask {
|
||||
kIdentity_Mask = 0,
|
||||
kTranslate_Mask = 1 << 0, //!< set if the matrix has translation
|
||||
kScale_Mask = 1 << 1, //!< set if the matrix has any scale != 1
|
||||
kAffine_Mask = 1 << 2, //!< set if the matrix skews or rotates
|
||||
kPerspective_Mask = 1 << 3, //!< set if the matrix is in perspective
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a bitfield describing the transformations the matrix may
|
||||
* perform. The bitfield is computed conservatively, so it may include
|
||||
* false positives. For example, when kPerspective_Mask is true, all
|
||||
* other bits may be set to true even in the case of a pure perspective
|
||||
* transform.
|
||||
*/
|
||||
inline TypeMask getType() const { return fTypeMask; }
|
||||
|
||||
/**
|
||||
* Return true if the matrix is identity.
|
||||
*/
|
||||
inline bool isIdentity() const {
|
||||
return kIdentity_Mask == this->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the matrix contains translate or is identity.
|
||||
*/
|
||||
inline bool isTranslate() const {
|
||||
return !(this->getType() & ~kTranslate_Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the matrix only contains scale or translate or is identity.
|
||||
*/
|
||||
inline bool isScaleTranslate() const {
|
||||
return !(this->getType() & ~(kScale_Mask | kTranslate_Mask));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the matrix only contains scale or is identity.
|
||||
*/
|
||||
inline bool isScale() const {
|
||||
return !(this->getType() & ~kScale_Mask);
|
||||
}
|
||||
|
||||
inline bool hasPerspective() const {
|
||||
return SkToBool(this->getType() & kPerspective_Mask);
|
||||
}
|
||||
|
||||
void setIdentity();
|
||||
inline void reset() { this->setIdentity();}
|
||||
|
||||
/**
|
||||
* get a value from the matrix. The row,col parameters work as follows:
|
||||
* (0, 0) scale-x
|
||||
* (0, 3) translate-x
|
||||
* (3, 0) perspective-x
|
||||
*/
|
||||
inline SkMScalar get(int row, int col) const {
|
||||
SkASSERT((unsigned)row <= 3);
|
||||
SkASSERT((unsigned)col <= 3);
|
||||
return fMat[col][row];
|
||||
}
|
||||
|
||||
/**
|
||||
* set a value in the matrix. The row,col parameters work as follows:
|
||||
* (0, 0) scale-x
|
||||
* (0, 3) translate-x
|
||||
* (3, 0) perspective-x
|
||||
*/
|
||||
inline void set(int row, int col, SkMScalar value) {
|
||||
SkASSERT((unsigned)row <= 3);
|
||||
SkASSERT((unsigned)col <= 3);
|
||||
fMat[col][row] = value;
|
||||
this->recomputeTypeMask();
|
||||
}
|
||||
|
||||
inline double getDouble(int row, int col) const {
|
||||
return SkMScalarToDouble(this->get(row, col));
|
||||
}
|
||||
inline void setDouble(int row, int col, double value) {
|
||||
this->set(row, col, SkDoubleToMScalar(value));
|
||||
}
|
||||
inline float getFloat(int row, int col) const {
|
||||
return SkMScalarToFloat(this->get(row, col));
|
||||
}
|
||||
inline void setFloat(int row, int col, float value) {
|
||||
this->set(row, col, SkFloatToMScalar(value));
|
||||
}
|
||||
|
||||
/** These methods allow one to efficiently read matrix entries into an
|
||||
* array. The given array must have room for exactly 16 entries. Whenever
|
||||
* possible, they will try to use memcpy rather than an entry-by-entry
|
||||
* copy.
|
||||
*
|
||||
* Col major indicates that consecutive elements of columns will be stored
|
||||
* contiguously in memory. Row major indicates that consecutive elements
|
||||
* of rows will be stored contiguously in memory.
|
||||
*/
|
||||
void asColMajorf(float[]) const;
|
||||
void asColMajord(double[]) const;
|
||||
void asRowMajorf(float[]) const;
|
||||
void asRowMajord(double[]) const;
|
||||
|
||||
/** These methods allow one to efficiently set all matrix entries from an
|
||||
* array. The given array must have room for exactly 16 entries. Whenever
|
||||
* possible, they will try to use memcpy rather than an entry-by-entry
|
||||
* copy.
|
||||
*
|
||||
* Col major indicates that input memory will be treated as if consecutive
|
||||
* elements of columns are stored contiguously in memory. Row major
|
||||
* indicates that input memory will be treated as if consecutive elements
|
||||
* of rows are stored contiguously in memory.
|
||||
*/
|
||||
void setColMajorf(const float[]);
|
||||
void setColMajord(const double[]);
|
||||
void setRowMajorf(const float[]);
|
||||
void setRowMajord(const double[]);
|
||||
|
||||
#ifdef SK_MSCALAR_IS_FLOAT
|
||||
void setColMajor(const SkMScalar data[]) { this->setColMajorf(data); }
|
||||
void setRowMajor(const SkMScalar data[]) { this->setRowMajorf(data); }
|
||||
#else
|
||||
void setColMajor(const SkMScalar data[]) { this->setColMajord(data); }
|
||||
void setRowMajor(const SkMScalar data[]) { this->setRowMajord(data); }
|
||||
#endif
|
||||
|
||||
/* This sets the top-left of the matrix and clears the translation and
|
||||
* perspective components (with [3][3] set to 1). m_ij is interpreted
|
||||
* as the matrix entry at row = i, col = j. */
|
||||
void set3x3(SkMScalar m_00, SkMScalar m_10, SkMScalar m_20,
|
||||
SkMScalar m_01, SkMScalar m_11, SkMScalar m_21,
|
||||
SkMScalar m_02, SkMScalar m_12, SkMScalar m_22);
|
||||
void set3x3RowMajorf(const float[]);
|
||||
|
||||
void set4x4(SkMScalar m_00, SkMScalar m_10, SkMScalar m_20, SkMScalar m_30,
|
||||
SkMScalar m_01, SkMScalar m_11, SkMScalar m_21, SkMScalar m_31,
|
||||
SkMScalar m_02, SkMScalar m_12, SkMScalar m_22, SkMScalar m_32,
|
||||
SkMScalar m_03, SkMScalar m_13, SkMScalar m_23, SkMScalar m_33);
|
||||
|
||||
void setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz);
|
||||
void preTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz);
|
||||
void postTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz);
|
||||
|
||||
void setScale(SkMScalar sx, SkMScalar sy, SkMScalar sz);
|
||||
void preScale(SkMScalar sx, SkMScalar sy, SkMScalar sz);
|
||||
void postScale(SkMScalar sx, SkMScalar sy, SkMScalar sz);
|
||||
|
||||
inline void setScale(SkMScalar scale) {
|
||||
this->setScale(scale, scale, scale);
|
||||
}
|
||||
inline void preScale(SkMScalar scale) {
|
||||
this->preScale(scale, scale, scale);
|
||||
}
|
||||
inline void postScale(SkMScalar scale) {
|
||||
this->postScale(scale, scale, scale);
|
||||
}
|
||||
|
||||
void setRotateDegreesAbout(SkMScalar x, SkMScalar y, SkMScalar z,
|
||||
SkMScalar degrees) {
|
||||
this->setRotateAbout(x, y, z, degrees * SK_MScalarPI / 180);
|
||||
}
|
||||
|
||||
/** Rotate about the vector [x,y,z]. If that vector is not unit-length,
|
||||
it will be automatically resized.
|
||||
*/
|
||||
void setRotateAbout(SkMScalar x, SkMScalar y, SkMScalar z,
|
||||
SkMScalar radians);
|
||||
/** Rotate about the vector [x,y,z]. Does not check the length of the
|
||||
vector, assuming it is unit-length.
|
||||
*/
|
||||
void setRotateAboutUnit(SkMScalar x, SkMScalar y, SkMScalar z,
|
||||
SkMScalar radians);
|
||||
|
||||
void setConcat(const SkMatrix44& a, const SkMatrix44& b);
|
||||
inline void preConcat(const SkMatrix44& m) {
|
||||
this->setConcat(*this, m);
|
||||
}
|
||||
inline void postConcat(const SkMatrix44& m) {
|
||||
this->setConcat(m, *this);
|
||||
}
|
||||
|
||||
friend SkMatrix44 operator*(const SkMatrix44& a, const SkMatrix44& b) {
|
||||
return SkMatrix44(a, b);
|
||||
}
|
||||
|
||||
/** If this is invertible, return that in inverse and return true. If it is
|
||||
not invertible, return false and leave the inverse parameter in an
|
||||
unspecified state.
|
||||
*/
|
||||
bool invert(SkMatrix44* inverse) const;
|
||||
|
||||
/** Transpose this matrix in place. */
|
||||
void transpose();
|
||||
|
||||
/** Apply the matrix to the src vector, returning the new vector in dst.
|
||||
It is legal for src and dst to point to the same memory.
|
||||
*/
|
||||
void mapScalars(const SkScalar src[4], SkScalar dst[4]) const;
|
||||
inline void mapScalars(SkScalar vec[4]) const {
|
||||
this->mapScalars(vec, vec);
|
||||
}
|
||||
|
||||
#ifdef SK_MSCALAR_IS_DOUBLE
|
||||
void mapMScalars(const SkMScalar src[4], SkMScalar dst[4]) const;
|
||||
#elif defined SK_MSCALAR_IS_FLOAT
|
||||
inline void mapMScalars(const SkMScalar src[4], SkMScalar dst[4]) const {
|
||||
this->mapScalars(src, dst);
|
||||
}
|
||||
#endif
|
||||
inline void mapMScalars(SkMScalar vec[4]) const {
|
||||
this->mapMScalars(vec, vec);
|
||||
}
|
||||
|
||||
friend SkVector4 operator*(const SkMatrix44& m, const SkVector4& src) {
|
||||
SkVector4 dst;
|
||||
m.mapScalars(src.fData, dst.fData);
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**
|
||||
* map an array of [x, y, 0, 1] through the matrix, returning an array
|
||||
* of [x', y', z', w'].
|
||||
*
|
||||
* @param src2 array of [x, y] pairs, with implied z=0 and w=1
|
||||
* @param count number of [x, y] pairs in src2
|
||||
* @param dst4 array of [x', y', z', w'] quads as the output.
|
||||
*/
|
||||
void map2(const float src2[], int count, float dst4[]) const;
|
||||
void map2(const double src2[], int count, double dst4[]) const;
|
||||
|
||||
/** Returns true if transformating an axis-aligned square in 2d by this matrix
|
||||
will produce another 2d axis-aligned square; typically means the matrix
|
||||
is a scale with perhaps a 90-degree rotation. A 3d rotation through 90
|
||||
degrees into a perpendicular plane collapses a square to a line, but
|
||||
is still considered to be axis-aligned.
|
||||
|
||||
By default, tolerates very slight error due to float imprecisions;
|
||||
a 90-degree rotation can still end up with 10^-17 of
|
||||
"non-axis-aligned" result.
|
||||
*/
|
||||
bool preserves2dAxisAlignment(SkMScalar epsilon = SK_ScalarNearlyZero) const;
|
||||
|
||||
void dump() const;
|
||||
|
||||
double determinant() const;
|
||||
|
||||
private:
|
||||
/* This is indexed by [col][row]. */
|
||||
SkMScalar fMat[4][4];
|
||||
TypeMask fTypeMask;
|
||||
|
||||
static constexpr int kAllPublic_Masks = 0xF;
|
||||
|
||||
void as3x4RowMajorf(float[]) const;
|
||||
void set3x4RowMajorf(const float[]);
|
||||
|
||||
SkMScalar transX() const { return fMat[3][0]; }
|
||||
SkMScalar transY() const { return fMat[3][1]; }
|
||||
SkMScalar transZ() const { return fMat[3][2]; }
|
||||
|
||||
SkMScalar scaleX() const { return fMat[0][0]; }
|
||||
SkMScalar scaleY() const { return fMat[1][1]; }
|
||||
SkMScalar scaleZ() const { return fMat[2][2]; }
|
||||
|
||||
SkMScalar perspX() const { return fMat[0][3]; }
|
||||
SkMScalar perspY() const { return fMat[1][3]; }
|
||||
SkMScalar perspZ() const { return fMat[2][3]; }
|
||||
|
||||
void recomputeTypeMask();
|
||||
|
||||
inline void setTypeMask(TypeMask mask) {
|
||||
SkASSERT(0 == (~kAllPublic_Masks & mask));
|
||||
fTypeMask = mask;
|
||||
}
|
||||
|
||||
inline const SkMScalar* values() const { return &fMat[0][0]; }
|
||||
|
||||
friend class SkColorSpace;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,423 +0,0 @@
|
|||
/*
|
||||
* 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 SkMesh_DEFINED
|
||||
#define SkMesh_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
#include "include/core/SkAlphaType.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSpan.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/effects/SkRuntimeEffect.h"
|
||||
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
class GrDirectContext;
|
||||
class SkColorSpace;
|
||||
class SkData;
|
||||
|
||||
namespace SkSL { struct Program; }
|
||||
|
||||
/**
|
||||
* A specification for custom meshes. Specifies the vertex buffer attributes and stride, the
|
||||
* vertex program that produces a user-defined set of varyings, and a fragment program that ingests
|
||||
* the interpolated varyings and produces local coordinates for shading and optionally a color.
|
||||
*
|
||||
* The varyings must include a float2 named "position". If the passed varyings does not
|
||||
* contain such a varying then one is implicitly added to the final specification and the SkSL
|
||||
* Varyings struct described below. It is an error to have a varying named "position" that has a
|
||||
* type other than float2.
|
||||
*
|
||||
* The provided attributes and varyings are used to create Attributes and Varyings structs in SkSL
|
||||
* that are used by the shaders. Each attribute from the Attribute span becomes a member of the
|
||||
* SkSL Attributes struct and likewise for the varyings.
|
||||
*
|
||||
* The signature of the vertex program must be:
|
||||
* Varyings main(const Attributes).
|
||||
*
|
||||
* The signature of the fragment program must be either:
|
||||
* float2 main(const Varyings)
|
||||
* or
|
||||
* float2 main(const Varyings, out (half4|float4) color)
|
||||
*
|
||||
* where the return value is the local coordinates that will be used to access SkShader. If the
|
||||
* color variant is used, the returned color will be blended with SkPaint's SkShader (or SkPaint
|
||||
* color in absence of a SkShader) using the SkBlender passed to SkCanvas drawMesh(). To use
|
||||
* interpolated local space positions as the shader coordinates, equivalent to how SkPaths are
|
||||
* shaded, return the position field from the Varying struct as the coordinates.
|
||||
*
|
||||
* The vertex and fragment programs may both contain uniforms. Uniforms with the same name are
|
||||
* assumed to be shared between stages. It is an error to specify uniforms in the vertex and
|
||||
* fragment program with the same name but different types, dimensionality, or layouts.
|
||||
*/
|
||||
class SkMeshSpecification : public SkNVRefCnt<SkMeshSpecification> {
|
||||
public:
|
||||
/** These values are enforced when creating a specification. */
|
||||
static constexpr size_t kMaxStride = 1024;
|
||||
static constexpr size_t kMaxAttributes = 8;
|
||||
static constexpr size_t kStrideAlignment = 4;
|
||||
static constexpr size_t kOffsetAlignment = 4;
|
||||
static constexpr size_t kMaxVaryings = 6;
|
||||
|
||||
struct Attribute {
|
||||
enum class Type : uint32_t { // CPU representation Shader Type
|
||||
kFloat, // float float
|
||||
kFloat2, // two floats float2
|
||||
kFloat3, // three floats float3
|
||||
kFloat4, // four floats float4
|
||||
kUByte4_unorm, // four bytes half4
|
||||
|
||||
kLast = kUByte4_unorm
|
||||
};
|
||||
Type type;
|
||||
size_t offset;
|
||||
SkString name;
|
||||
};
|
||||
|
||||
struct Varying {
|
||||
enum class Type : uint32_t {
|
||||
kFloat, // "float"
|
||||
kFloat2, // "float2"
|
||||
kFloat3, // "float3"
|
||||
kFloat4, // "float4"
|
||||
kHalf, // "half"
|
||||
kHalf2, // "half2"
|
||||
kHalf3, // "half3"
|
||||
kHalf4, // "half4"
|
||||
|
||||
kLast = kHalf4
|
||||
};
|
||||
Type type;
|
||||
SkString name;
|
||||
};
|
||||
|
||||
using Uniform = SkRuntimeEffect::Uniform;
|
||||
|
||||
~SkMeshSpecification();
|
||||
|
||||
struct Result {
|
||||
sk_sp<SkMeshSpecification> specification;
|
||||
SkString error;
|
||||
};
|
||||
|
||||
/**
|
||||
* If successful the return is a specification and an empty error string. Otherwise, it is a
|
||||
* null specification a non-empty error string.
|
||||
*
|
||||
* @param attributes The vertex attributes that will be consumed by 'vs'. Attributes need
|
||||
* not be tightly packed but attribute offsets must be aligned to
|
||||
* kOffsetAlignment and offset + size may not be greater than
|
||||
* 'vertexStride'. At least one attribute is required.
|
||||
* @param vertexStride The offset between successive attribute values. This must be aligned to
|
||||
* kStrideAlignment.
|
||||
* @param varyings The varyings that will be written by 'vs' and read by 'fs'. This may
|
||||
* be empty.
|
||||
* @param vs The vertex shader code that computes a vertex position and the varyings
|
||||
* from the attributes.
|
||||
* @param fs The fragment code that computes a local coordinate and optionally a
|
||||
* color from the varyings. The local coordinate is used to sample
|
||||
* SkShader.
|
||||
* @param cs The colorspace of the color produced by 'fs'. Ignored if 'fs's main()
|
||||
* function does not have a color out param.
|
||||
* @param at The alpha type of the color produced by 'fs'. Ignored if 'fs's main()
|
||||
* function does not have a color out param. Cannot be kUnknown.
|
||||
*/
|
||||
static Result Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs);
|
||||
static Result Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs);
|
||||
static Result Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at);
|
||||
|
||||
SkSpan<const Attribute> attributes() const { return SkSpan(fAttributes); }
|
||||
|
||||
/**
|
||||
* Combined size of all 'uniform' variables. When creating a SkMesh with this specification
|
||||
* provide an SkData of this size, containing values for all of those variables. Use uniforms()
|
||||
* to get the offset of each uniform within the SkData.
|
||||
*/
|
||||
size_t uniformSize() const;
|
||||
|
||||
/**
|
||||
* Provides info about individual uniforms including the offset into an SkData where each
|
||||
* uniform value should be placed.
|
||||
*/
|
||||
SkSpan<const Uniform> uniforms() const { return SkSpan(fUniforms); }
|
||||
|
||||
/** Returns pointer to the named uniform variable's description, or nullptr if not found. */
|
||||
const Uniform* findUniform(std::string_view name) const;
|
||||
|
||||
/** Returns pointer to the named attribute, or nullptr if not found. */
|
||||
const Attribute* findAttribute(std::string_view name) const;
|
||||
|
||||
/** Returns pointer to the named varying, or nullptr if not found. */
|
||||
const Varying* findVarying(std::string_view name) const;
|
||||
|
||||
size_t stride() const { return fStride; }
|
||||
|
||||
private:
|
||||
friend struct SkMeshSpecificationPriv;
|
||||
|
||||
enum class ColorType {
|
||||
kNone,
|
||||
kHalf4,
|
||||
kFloat4,
|
||||
};
|
||||
|
||||
static Result MakeFromSourceWithStructs(SkSpan<const Attribute> attributes,
|
||||
size_t stride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at);
|
||||
|
||||
SkMeshSpecification(SkSpan<const Attribute>,
|
||||
size_t,
|
||||
SkSpan<const Varying>,
|
||||
int passthroughLocalCoordsVaryingIndex,
|
||||
uint32_t deadVaryingMask,
|
||||
std::vector<Uniform> uniforms,
|
||||
std::unique_ptr<const SkSL::Program>,
|
||||
std::unique_ptr<const SkSL::Program>,
|
||||
ColorType,
|
||||
sk_sp<SkColorSpace>,
|
||||
SkAlphaType);
|
||||
|
||||
SkMeshSpecification(const SkMeshSpecification&) = delete;
|
||||
SkMeshSpecification(SkMeshSpecification&&) = delete;
|
||||
|
||||
SkMeshSpecification& operator=(const SkMeshSpecification&) = delete;
|
||||
SkMeshSpecification& operator=(SkMeshSpecification&&) = delete;
|
||||
|
||||
const std::vector<Attribute> fAttributes;
|
||||
const std::vector<Varying> fVaryings;
|
||||
const std::vector<Uniform> fUniforms;
|
||||
const std::unique_ptr<const SkSL::Program> fVS;
|
||||
const std::unique_ptr<const SkSL::Program> fFS;
|
||||
const size_t fStride;
|
||||
uint32_t fHash;
|
||||
const int fPassthroughLocalCoordsVaryingIndex;
|
||||
const uint32_t fDeadVaryingMask;
|
||||
const ColorType fColorType;
|
||||
const sk_sp<SkColorSpace> fColorSpace;
|
||||
const SkAlphaType fAlphaType;
|
||||
};
|
||||
|
||||
/**
|
||||
* A vertex buffer, a topology, optionally an index buffer, and a compatible SkMeshSpecification.
|
||||
*
|
||||
* The data in the vertex buffer is expected to contain the attributes described by the spec
|
||||
* for vertexCount vertices beginning at vertexOffset. vertexOffset must be aligned to the
|
||||
* SkMeshSpecification's vertex stride. The size of the buffer must be at least vertexOffset +
|
||||
* spec->stride()*vertexCount (even if vertex attributes contains pad at the end of the stride). If
|
||||
* the specified bounds does not contain all the points output by the spec's vertex program when
|
||||
* applied to the vertices in the custom mesh then the result is undefined.
|
||||
*
|
||||
* MakeIndexed may be used to create an indexed mesh. indexCount indices are read from the index
|
||||
* buffer at the specified offset which must be aligned to 2. The indices are always unsigned 16bit
|
||||
* integers. The index count must be at least 3.
|
||||
*
|
||||
* If Make() is used the implicit index sequence is 0, 1, 2, 3, ... and vertexCount must be at least
|
||||
* 3.
|
||||
*
|
||||
* Both Make() and MakeIndexed() take a SkData with the uniform values. See
|
||||
* SkMeshSpecification::uniformSize() and SkMeshSpecification::uniforms() for sizing and packing
|
||||
* uniforms into the SkData.
|
||||
*/
|
||||
class SkMesh {
|
||||
public:
|
||||
class IndexBuffer : public SkRefCnt {
|
||||
public:
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
/**
|
||||
* Modifies the data in the IndexBuffer by copying size bytes from data into the buffer
|
||||
* at offset. Fails if offset + size > this->size() or if either offset or size is not
|
||||
* aligned to 4 bytes. The GrDirectContext* must match that used to create the buffer. We
|
||||
* take it as a parameter to emphasize that the context must be used to update the data and
|
||||
* thus the context must be valid for the current thread.
|
||||
*/
|
||||
bool update(GrDirectContext*, const void* data, size_t offset, size_t size);
|
||||
|
||||
private:
|
||||
virtual bool onUpdate(GrDirectContext*, const void* data, size_t offset, size_t size) = 0;
|
||||
};
|
||||
|
||||
class VertexBuffer : public SkRefCnt {
|
||||
public:
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
/**
|
||||
* Modifies the data in the IndexBuffer by copying size bytes from data into the buffer
|
||||
* at offset. Fails if offset + size > this->size() or if either offset or size is not
|
||||
* aligned to 4 bytes. The GrDirectContext* must match that used to create the buffer. We
|
||||
* take it as a parameter to emphasize that the context must be used to update the data and
|
||||
* thus the context must be valid for the current thread.
|
||||
*/
|
||||
bool update(GrDirectContext*, const void* data, size_t offset, size_t size);
|
||||
|
||||
private:
|
||||
virtual bool onUpdate(GrDirectContext*, const void* data, size_t offset, size_t size) = 0;
|
||||
};
|
||||
|
||||
SkMesh();
|
||||
~SkMesh();
|
||||
|
||||
SkMesh(const SkMesh&);
|
||||
SkMesh(SkMesh&&);
|
||||
|
||||
SkMesh& operator=(const SkMesh&);
|
||||
SkMesh& operator=(SkMesh&&);
|
||||
|
||||
/**
|
||||
* Makes an index buffer to be used with SkMeshes. The buffer may be CPU- or GPU-backed
|
||||
* depending on whether GrDirectContext* is nullptr.
|
||||
*
|
||||
* @param GrDirectContext* If nullptr a CPU-backed object is returned. Otherwise, the data is
|
||||
* uploaded to the GPU and a GPU-backed buffer is returned. It may
|
||||
* only be used to draw into SkSurfaces that are backed by the passed
|
||||
* GrDirectContext.
|
||||
* @param data The data used to populate the buffer, or nullptr to create a zero-
|
||||
* initialized buffer.
|
||||
* @param size Both the size of the data in 'data' and the size of the resulting
|
||||
* buffer.
|
||||
*/
|
||||
static sk_sp<IndexBuffer> MakeIndexBuffer(GrDirectContext*, const void* data, size_t size);
|
||||
|
||||
/**
|
||||
* Makes a copy of an index buffer. The implementation currently only supports a CPU-backed
|
||||
* source buffer.
|
||||
*/
|
||||
static sk_sp<IndexBuffer> CopyIndexBuffer(GrDirectContext*, sk_sp<IndexBuffer>);
|
||||
|
||||
/**
|
||||
* Makes a vertex buffer to be used with SkMeshes. The buffer may be CPU- or GPU-backed
|
||||
* depending on whether GrDirectContext* is nullptr.
|
||||
*
|
||||
* @param GrDirectContext* If nullptr a CPU-backed object is returned. Otherwise, the data is
|
||||
* uploaded to the GPU and a GPU-backed buffer is returned. It may
|
||||
* only be used to draw into SkSurfaces that are backed by the passed
|
||||
* GrDirectContext.
|
||||
* @param data The data used to populate the buffer, or nullptr to create a zero-
|
||||
* initialized buffer.
|
||||
* @param size Both the size of the data in 'data' and the size of the resulting
|
||||
* buffer.
|
||||
*/
|
||||
static sk_sp<VertexBuffer> MakeVertexBuffer(GrDirectContext*, const void*, size_t size);
|
||||
|
||||
/**
|
||||
* Makes a copy of a vertex buffer. The implementation currently only supports a CPU-backed
|
||||
* source buffer.
|
||||
*/
|
||||
static sk_sp<VertexBuffer> CopyVertexBuffer(GrDirectContext*, sk_sp<VertexBuffer>);
|
||||
|
||||
enum class Mode { kTriangles, kTriangleStrip };
|
||||
|
||||
struct Result;
|
||||
|
||||
/**
|
||||
* Creates a non-indexed SkMesh. The returned SkMesh can be tested for validity using
|
||||
* SkMesh::isValid(). An invalid mesh simply fails to draws if passed to SkCanvas::drawMesh().
|
||||
* If the mesh is invalid the returned string give contain the reason for the failure (e.g. the
|
||||
* vertex buffer was null or uniform data too small).
|
||||
*/
|
||||
static Result Make(sk_sp<SkMeshSpecification>,
|
||||
Mode,
|
||||
sk_sp<VertexBuffer>,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
sk_sp<const SkData> uniforms,
|
||||
const SkRect& bounds);
|
||||
|
||||
/**
|
||||
* Creates an indexed SkMesh. The returned SkMesh can be tested for validity using
|
||||
* SkMesh::isValid(). A invalid mesh simply fails to draw if passed to SkCanvas::drawMesh().
|
||||
* If the mesh is invalid the returned string give contain the reason for the failure (e.g. the
|
||||
* index buffer was null or uniform data too small).
|
||||
*/
|
||||
static Result MakeIndexed(sk_sp<SkMeshSpecification>,
|
||||
Mode,
|
||||
sk_sp<VertexBuffer>,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
sk_sp<IndexBuffer>,
|
||||
size_t indexCount,
|
||||
size_t indexOffset,
|
||||
sk_sp<const SkData> uniforms,
|
||||
const SkRect& bounds);
|
||||
|
||||
sk_sp<SkMeshSpecification> refSpec() const { return fSpec; }
|
||||
SkMeshSpecification* spec() const { return fSpec.get(); }
|
||||
|
||||
Mode mode() const { return fMode; }
|
||||
|
||||
sk_sp<VertexBuffer> refVertexBuffer() const { return fVB; }
|
||||
VertexBuffer* vertexBuffer() const { return fVB.get(); }
|
||||
|
||||
size_t vertexOffset() const { return fVOffset; }
|
||||
size_t vertexCount() const { return fVCount; }
|
||||
|
||||
sk_sp<IndexBuffer> refIndexBuffer() const { return fIB; }
|
||||
IndexBuffer* indexBuffer() const { return fIB.get(); }
|
||||
|
||||
size_t indexOffset() const { return fIOffset; }
|
||||
size_t indexCount() const { return fICount; }
|
||||
|
||||
sk_sp<const SkData> refUniforms() const { return fUniforms; }
|
||||
const SkData* uniforms() const { return fUniforms.get(); }
|
||||
|
||||
SkRect bounds() const { return fBounds; }
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
friend struct SkMeshPriv;
|
||||
|
||||
std::tuple<bool, SkString> validate() const;
|
||||
|
||||
sk_sp<SkMeshSpecification> fSpec;
|
||||
|
||||
sk_sp<VertexBuffer> fVB;
|
||||
sk_sp<IndexBuffer> fIB;
|
||||
|
||||
sk_sp<const SkData> fUniforms;
|
||||
|
||||
size_t fVOffset = 0; // Must be a multiple of spec->stride()
|
||||
size_t fVCount = 0;
|
||||
|
||||
size_t fIOffset = 0; // Must be a multiple of sizeof(uint16_t)
|
||||
size_t fICount = 0;
|
||||
|
||||
Mode fMode = Mode::kTriangles;
|
||||
|
||||
SkRect fBounds = SkRect::MakeEmpty();
|
||||
};
|
||||
|
||||
struct SkMesh::Result { SkMesh mesh; SkString error; };
|
||||
|
||||
#endif // SK_ENABLE_SKSL
|
||||
|
||||
#endif
|
|
@ -5,5 +5,5 @@
|
|||
* found in the LICENSE file.
|
||||
*/
|
||||
#ifndef SK_MILESTONE
|
||||
#define SK_MILESTONE 113
|
||||
#define SK_MILESTONE 79
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkMultiPictureDraw_DEFINED
|
||||
#define SkMultiPictureDraw_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
class SkCanvas;
|
||||
class SkPaint;
|
||||
class SkPicture;
|
||||
|
||||
/** \class SkMultiPictureDraw
|
||||
|
||||
The MultiPictureDraw object accepts several picture/canvas pairs and
|
||||
then attempts to optimally draw the pictures into the canvases, sharing
|
||||
as many resources as possible.
|
||||
*/
|
||||
class SK_API SkMultiPictureDraw {
|
||||
public:
|
||||
/**
|
||||
* Create an object to optimize the drawing of multiple pictures.
|
||||
* @param reserve Hint for the number of add calls expected to be issued
|
||||
*/
|
||||
SkMultiPictureDraw(int reserve = 0);
|
||||
~SkMultiPictureDraw() { this->reset(); }
|
||||
|
||||
/**
|
||||
* Add a canvas/picture pair for later rendering.
|
||||
* @param canvas the canvas in which to draw picture
|
||||
* @param picture the picture to draw into canvas
|
||||
* @param matrix if non-NULL, applied to the CTM when drawing
|
||||
* @param paint if non-NULL, draw picture to a temporary buffer
|
||||
* and then apply the paint when the result is drawn
|
||||
*/
|
||||
void add(SkCanvas* canvas,
|
||||
const SkPicture* picture,
|
||||
const SkMatrix* matrix = nullptr,
|
||||
const SkPaint* paint = nullptr);
|
||||
|
||||
/**
|
||||
* Perform all the previously added draws. This will reset the state
|
||||
* of this object. If flush is true, all canvases are flushed after
|
||||
* draw.
|
||||
*/
|
||||
void draw(bool flush = false);
|
||||
|
||||
/**
|
||||
* Abandon all buffered draws and reset to the initial state.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
private:
|
||||
struct DrawData {
|
||||
SkCanvas* fCanvas;
|
||||
const SkPicture* fPicture; // reffed
|
||||
SkMatrix fMatrix;
|
||||
SkPaint* fPaint; // owned
|
||||
|
||||
void init(SkCanvas*, const SkPicture*, const SkMatrix*, const SkPaint*);
|
||||
void draw();
|
||||
|
||||
static void Reset(SkTDArray<DrawData>&);
|
||||
};
|
||||
|
||||
SkTDArray<DrawData> fThreadSafeDrawData;
|
||||
SkTDArray<DrawData> fGPUDrawData;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkOpenTypeSVGDecoder_DEFINED
|
||||
#define SkOpenTypeSVGDecoder_DEFINED
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkSpan.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SkCanvas;
|
||||
|
||||
class SkOpenTypeSVGDecoder {
|
||||
public:
|
||||
/** Each instance probably owns an SVG DOM.
|
||||
* The instance may be cached so needs to report how much memory it retains.
|
||||
*/
|
||||
virtual size_t approximateSize() = 0;
|
||||
virtual bool render(SkCanvas&, int upem, SkGlyphID glyphId,
|
||||
SkColor foregroundColor, SkSpan<SkColor> palette) = 0;
|
||||
virtual ~SkOpenTypeSVGDecoder() = default;
|
||||
};
|
||||
|
||||
#endif // SkOpenTypeSVGDecoder_DEFINED
|
|
@ -22,8 +22,6 @@ public:
|
|||
SkOverdrawCanvas(SkCanvas*);
|
||||
|
||||
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
|
||||
void onDrawGlyphRunList(
|
||||
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
|
||||
void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
|
||||
const SkPaint&) override;
|
||||
void onDrawPaint(const SkPaint&) override;
|
||||
|
@ -35,18 +33,22 @@ public:
|
|||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override;
|
||||
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
|
||||
void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
|
||||
SkBlendMode, const SkPaint&) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
|
||||
void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
|
||||
SrcRectConstraint) override;
|
||||
void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&, const SkPaint*) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override;
|
||||
void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
|
||||
SrcRectConstraint) override;
|
||||
void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, const SkPaint*) override;
|
||||
void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
|
||||
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
|
||||
|
||||
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
|
||||
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
|
||||
|
||||
|
@ -55,15 +57,18 @@ public:
|
|||
|
||||
void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], SkCanvas::QuadAAFlags, const SkColor4f&,
|
||||
SkBlendMode) override;
|
||||
void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
|
||||
private:
|
||||
void drawPosTextCommon(const SkGlyphID[], int, const SkScalar[], int, const SkPoint&,
|
||||
const SkFont&, const SkPaint&);
|
||||
|
||||
inline SkPaint overdrawPaint(const SkPaint& paint);
|
||||
|
||||
SkPaint fPaint;
|
||||
|
||||
using INHERITED = SkCanvasVirtualEnforcer<SkNWayCanvas>;
|
||||
typedef SkCanvasVirtualEnforcer<SkNWayCanvas> INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,28 +8,20 @@
|
|||
#ifndef SkPaint_DEFINED
|
||||
#define SkPaint_DEFINED
|
||||
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkFilterQuality.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/base/SkCPUTypes.h"
|
||||
#include "include/private/base/SkFloatingPoint.h"
|
||||
#include "include/private/base/SkTo.h"
|
||||
#include "include/private/base/SkTypeTraits.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
class SkBlender;
|
||||
class SkColorFilter;
|
||||
class SkColorSpace;
|
||||
struct SkRect;
|
||||
class SkImageFilter;
|
||||
class SkMaskFilter;
|
||||
class SkPath;
|
||||
class SkPathEffect;
|
||||
class SkShader;
|
||||
enum class SkBlendMode;
|
||||
struct SkRect;
|
||||
|
||||
/** \class SkPaint
|
||||
SkPaint controls options applied when drawing. SkPaint collects all
|
||||
|
@ -47,8 +39,6 @@ public:
|
|||
/** Constructs SkPaint with default values.
|
||||
|
||||
@return default initialized SkPaint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_empty_constructor
|
||||
*/
|
||||
SkPaint();
|
||||
|
||||
|
@ -76,8 +66,6 @@ public:
|
|||
|
||||
@param paint original to copy
|
||||
@return shallow copy of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_copy_const_SkPaint
|
||||
*/
|
||||
SkPaint(const SkPaint& paint);
|
||||
|
||||
|
@ -88,8 +76,6 @@ public:
|
|||
|
||||
@param paint original to move
|
||||
@return content of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_move_SkPaint
|
||||
*/
|
||||
SkPaint(SkPaint&& paint);
|
||||
|
||||
|
@ -108,8 +94,6 @@ public:
|
|||
|
||||
@param paint original to copy
|
||||
@return content of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_copy_operator
|
||||
*/
|
||||
SkPaint& operator=(const SkPaint& paint);
|
||||
|
||||
|
@ -122,8 +106,6 @@ public:
|
|||
|
||||
@param paint original to move
|
||||
@return content of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_move_operator
|
||||
*/
|
||||
SkPaint& operator=(SkPaint&& paint);
|
||||
|
||||
|
@ -149,10 +131,22 @@ public:
|
|||
return !(a == b);
|
||||
}
|
||||
|
||||
/** Returns a hash generated from SkPaint values and pointers.
|
||||
Identical hashes guarantee that the paints are
|
||||
equivalent, but differing hashes do not guarantee that the paints have differing
|
||||
contents.
|
||||
|
||||
If operator==(const SkPaint& a, const SkPaint& b) returns true for two paints,
|
||||
their hashes are also equal.
|
||||
|
||||
The hash returned is platform and implementation specific.
|
||||
|
||||
@return a shallow hash
|
||||
*/
|
||||
uint32_t getHash() const;
|
||||
|
||||
/** Sets all SkPaint contents to their initial values. This is equivalent to replacing
|
||||
SkPaint with the result of SkPaint().
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_reset
|
||||
*/
|
||||
void reset();
|
||||
|
||||
|
@ -181,6 +175,25 @@ public:
|
|||
*/
|
||||
void setDither(bool dither) { fBitfields.fDither = static_cast<unsigned>(dither); }
|
||||
|
||||
/** Returns SkFilterQuality, the image filtering level. A lower setting
|
||||
draws faster; a higher setting looks better when the image is scaled.
|
||||
|
||||
@return one of: kNone_SkFilterQuality, kLow_SkFilterQuality,
|
||||
kMedium_SkFilterQuality, kHigh_SkFilterQuality
|
||||
*/
|
||||
SkFilterQuality getFilterQuality() const {
|
||||
return (SkFilterQuality)fBitfields.fFilterQuality;
|
||||
}
|
||||
|
||||
/** Sets SkFilterQuality, the image filtering level. A lower setting
|
||||
draws faster; a higher setting looks better when the image is scaled.
|
||||
Does not check to see if quality is valid.
|
||||
|
||||
@param quality one of: kNone_SkFilterQuality, kLow_SkFilterQuality,
|
||||
kMedium_SkFilterQuality, kHigh_SkFilterQuality
|
||||
*/
|
||||
void setFilterQuality(SkFilterQuality quality);
|
||||
|
||||
/** \enum SkPaint::Style
|
||||
Set Style to fill, stroke, or both fill and stroke geometry.
|
||||
The stroke and fill
|
||||
|
@ -200,22 +213,18 @@ public:
|
|||
static constexpr int kStyleCount = kStrokeAndFill_Style + 1;
|
||||
|
||||
/** Returns whether the geometry is filled, stroked, or filled and stroked.
|
||||
|
||||
@return one of:kFill_Style, kStroke_Style, kStrokeAndFill_Style
|
||||
*/
|
||||
Style getStyle() const { return (Style)fBitfields.fStyle; }
|
||||
|
||||
/** Sets whether the geometry is filled, stroked, or filled and stroked.
|
||||
Has no effect if style is not a legal SkPaint::Style value.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStyle
|
||||
example: https://fiddle.skia.org/c/@Stroke_Width
|
||||
@param style one of: kFill_Style, kStroke_Style, kStrokeAndFill_Style
|
||||
*/
|
||||
void setStyle(Style style);
|
||||
|
||||
/**
|
||||
* Set paint's style to kStroke if true, or kFill if false.
|
||||
*/
|
||||
void setStroke(bool);
|
||||
|
||||
/** Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
|
||||
Use helpers SkColorGetA(), SkColorGetR(), SkColorGetG(), and SkColorGetB() to extract
|
||||
a color component.
|
||||
|
@ -225,7 +234,7 @@ public:
|
|||
SkColor getColor() const { return fColor4f.toSkColor(); }
|
||||
|
||||
/** Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are
|
||||
extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
|
||||
are extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
|
||||
|
||||
@return unpremultiplied RGBA
|
||||
*/
|
||||
|
@ -235,8 +244,6 @@ public:
|
|||
unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
|
||||
|
||||
@param color unpremultiplied ARGB
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setColor
|
||||
*/
|
||||
void setColor(SkColor color);
|
||||
|
||||
|
@ -256,14 +263,12 @@ public:
|
|||
|
||||
/** Retrieves alpha from the color used when stroking and filling.
|
||||
|
||||
@return alpha ranging from zero, fully transparent, to one, fully opaque
|
||||
@return alpha ranging from zero, fully transparent, to 255, fully opaque
|
||||
*/
|
||||
float getAlphaf() const { return fColor4f.fA; }
|
||||
|
||||
// Helper that scales the alpha by 255.
|
||||
uint8_t getAlpha() const {
|
||||
return static_cast<uint8_t>(sk_float_round2int(this->getAlphaf() * 255));
|
||||
}
|
||||
uint8_t getAlpha() const { return uint8_t(sk_float_round2int(this->getAlphaf() * 255)); }
|
||||
|
||||
/** Replaces alpha, leaving RGB
|
||||
unchanged. An out of range value triggers an assert in the debug
|
||||
|
@ -287,8 +292,6 @@ public:
|
|||
@param r amount of red, from no red (0) to full red (255)
|
||||
@param g amount of green, from no green (0) to full green (255)
|
||||
@param b amount of blue, from no blue (0) to full blue (255)
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setARGB
|
||||
*/
|
||||
void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
|
||||
|
||||
|
@ -299,15 +302,11 @@ public:
|
|||
*/
|
||||
SkScalar getStrokeWidth() const { return fWidth; }
|
||||
|
||||
/** Sets the thickness of the pen used by the paint to outline the shape.
|
||||
A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one
|
||||
pixel wide in device space (their thickness does not change as the canvas is scaled).
|
||||
Negative stroke-widths are invalid; setting a negative width will have no effect.
|
||||
/** Sets the thickness of the pen used by the paint to
|
||||
outline the shape.
|
||||
Has no effect if width is less than zero.
|
||||
|
||||
@param width zero thickness for hairline; greater than zero for pen thickness
|
||||
|
||||
example: https://fiddle.skia.org/c/@Miter_Limit
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeWidth
|
||||
*/
|
||||
void setStrokeWidth(SkScalar width);
|
||||
|
||||
|
@ -322,8 +321,6 @@ public:
|
|||
Has no effect if miter is less than zero.
|
||||
|
||||
@param miter zero and greater miter limit
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeMiter
|
||||
*/
|
||||
void setStrokeMiter(SkScalar miter);
|
||||
|
||||
|
@ -368,26 +365,56 @@ public:
|
|||
static constexpr int kJoinCount = kLast_Join + 1;
|
||||
|
||||
/** Returns the geometry drawn at the beginning and end of strokes.
|
||||
|
||||
@return one of: kButt_Cap, kRound_Cap, kSquare_Cap
|
||||
*/
|
||||
Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
|
||||
|
||||
/** Sets the geometry drawn at the beginning and end of strokes.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeCap_a
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeCap_b
|
||||
@param cap one of: kButt_Cap, kRound_Cap, kSquare_Cap;
|
||||
has no effect if cap is not valid
|
||||
*/
|
||||
void setStrokeCap(Cap cap);
|
||||
|
||||
/** Returns the geometry drawn at the corners of strokes.
|
||||
|
||||
@return one of: kMiter_Join, kRound_Join, kBevel_Join
|
||||
*/
|
||||
Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
|
||||
|
||||
/** Sets the geometry drawn at the corners of strokes.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeJoin
|
||||
@param join one of: kMiter_Join, kRound_Join, kBevel_Join;
|
||||
otherwise, has no effect
|
||||
*/
|
||||
void setStrokeJoin(Join join);
|
||||
|
||||
/** Returns the filled equivalent of the stroked path.
|
||||
|
||||
@param src SkPath read to create a filled version
|
||||
@param dst resulting SkPath; may be the same as src, but may not be nullptr
|
||||
@param cullRect optional limit passed to SkPathEffect
|
||||
@param resScale if > 1, increase precision, else if (0 < resScale < 1) reduce precision
|
||||
to favor speed and size
|
||||
@return true if the path represents style fill, or false if it represents hairline
|
||||
*/
|
||||
bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
|
||||
SkScalar resScale = 1) const;
|
||||
|
||||
/** Returns the filled equivalent of the stroked path.
|
||||
|
||||
Replaces dst with the src path modified by SkPathEffect and style stroke.
|
||||
SkPathEffect, if any, is not culled. stroke width is created with default precision.
|
||||
|
||||
@param src SkPath read to create a filled version
|
||||
@param dst resulting SkPath dst may be the same as src, but may not be nullptr
|
||||
@return true if the path represents style fill, or false if it represents hairline
|
||||
*/
|
||||
bool getFillPath(const SkPath& src, SkPath* dst) const {
|
||||
return this->getFillPath(src, dst, nullptr, 1);
|
||||
}
|
||||
|
||||
/** Returns optional colors used when filling a path, such as a gradient.
|
||||
|
||||
Does not alter SkShader SkRefCnt.
|
||||
|
@ -401,8 +428,6 @@ public:
|
|||
Increases SkShader SkRefCnt by one.
|
||||
|
||||
@return SkShader if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refShader
|
||||
*/
|
||||
sk_sp<SkShader> refShader() const;
|
||||
|
||||
|
@ -412,9 +437,6 @@ public:
|
|||
Increments shader SkRefCnt by one.
|
||||
|
||||
@param shader how geometry is filled with color; if nullptr, color is used instead
|
||||
|
||||
example: https://fiddle.skia.org/c/@Color_Filter_Methods
|
||||
example: https://fiddle.skia.org/c/@Paint_setShader
|
||||
*/
|
||||
void setShader(sk_sp<SkShader> shader);
|
||||
|
||||
|
@ -429,8 +451,6 @@ public:
|
|||
Increases SkColorFilter SkRefCnt by one.
|
||||
|
||||
@return SkColorFilter if set, or nullptr
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refColorFilter
|
||||
*/
|
||||
sk_sp<SkColorFilter> refColorFilter() const;
|
||||
|
||||
|
@ -440,63 +460,28 @@ public:
|
|||
Increments filter SkRefCnt by one.
|
||||
|
||||
@param colorFilter SkColorFilter to apply to subsequent draw
|
||||
|
||||
example: https://fiddle.skia.org/c/@Blend_Mode_Methods
|
||||
example: https://fiddle.skia.org/c/@Paint_setColorFilter
|
||||
*/
|
||||
void setColorFilter(sk_sp<SkColorFilter> colorFilter);
|
||||
|
||||
/** If the current blender can be represented as a SkBlendMode enum, this returns that
|
||||
* enum in the optional's value(). If it cannot, then the returned optional does not
|
||||
* contain a value.
|
||||
*/
|
||||
std::optional<SkBlendMode> asBlendMode() const;
|
||||
/** Returns SkBlendMode.
|
||||
By default, returns SkBlendMode::kSrcOver.
|
||||
|
||||
/**
|
||||
* Queries the blender, and if it can be represented as a SkBlendMode, return that mode,
|
||||
* else return the defaultMode provided.
|
||||
*/
|
||||
SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const;
|
||||
@return mode used to combine source color with destination color
|
||||
*/
|
||||
SkBlendMode getBlendMode() const { return (SkBlendMode)fBitfields.fBlendMode; }
|
||||
|
||||
/** Returns true iff the current blender claims to be equivalent to SkBlendMode::kSrcOver.
|
||||
*
|
||||
* Also returns true of the current blender is nullptr.
|
||||
*/
|
||||
bool isSrcOver() const;
|
||||
/** Returns true if SkBlendMode is SkBlendMode::kSrcOver, the default.
|
||||
|
||||
/** Helper method for calling setBlender().
|
||||
*
|
||||
* This sets a blender that implements the specified blendmode enum.
|
||||
*/
|
||||
void setBlendMode(SkBlendMode mode);
|
||||
@return true if SkBlendMode is SkBlendMode::kSrcOver
|
||||
*/
|
||||
bool isSrcOver() const { return (SkBlendMode)fBitfields.fBlendMode == SkBlendMode::kSrcOver; }
|
||||
|
||||
/** Returns the user-supplied blend function, if one has been set.
|
||||
* Does not alter SkBlender's SkRefCnt.
|
||||
*
|
||||
* A nullptr blender signifies the default SrcOver behavior.
|
||||
*
|
||||
* @return the SkBlender assigned to this paint, otherwise nullptr
|
||||
*/
|
||||
SkBlender* getBlender() const { return fBlender.get(); }
|
||||
/** Sets SkBlendMode to mode.
|
||||
Does not check for valid input.
|
||||
|
||||
/** Returns the user-supplied blend function, if one has been set.
|
||||
* Increments the SkBlender's SkRefCnt by one.
|
||||
*
|
||||
* A nullptr blender signifies the default SrcOver behavior.
|
||||
*
|
||||
* @return the SkBlender assigned to this paint, otherwise nullptr
|
||||
*/
|
||||
sk_sp<SkBlender> refBlender() const;
|
||||
|
||||
/** Sets the current blender, increasing its refcnt, and if a blender is already
|
||||
* present, decreasing that object's refcnt.
|
||||
*
|
||||
* A nullptr blender signifies the default SrcOver behavior.
|
||||
*
|
||||
* For convenience, you can call setBlendMode() if the blend effect can be expressed
|
||||
* as one of those values.
|
||||
*/
|
||||
void setBlender(sk_sp<SkBlender> blender);
|
||||
@param mode SkBlendMode used to combine source color and destination
|
||||
*/
|
||||
void setBlendMode(SkBlendMode mode) { fBitfields.fBlendMode = (unsigned)mode; }
|
||||
|
||||
/** Returns SkPathEffect if set, or nullptr.
|
||||
Does not alter SkPathEffect SkRefCnt.
|
||||
|
@ -509,8 +494,6 @@ public:
|
|||
Increases SkPathEffect SkRefCnt by one.
|
||||
|
||||
@return SkPathEffect if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refPathEffect
|
||||
*/
|
||||
sk_sp<SkPathEffect> refPathEffect() const;
|
||||
|
||||
|
@ -520,9 +503,6 @@ public:
|
|||
Increments pathEffect SkRefCnt by one.
|
||||
|
||||
@param pathEffect replace SkPath with a modification when drawn
|
||||
|
||||
example: https://fiddle.skia.org/c/@Mask_Filter_Methods
|
||||
example: https://fiddle.skia.org/c/@Paint_setPathEffect
|
||||
*/
|
||||
void setPathEffect(sk_sp<SkPathEffect> pathEffect);
|
||||
|
||||
|
@ -538,8 +518,6 @@ public:
|
|||
Increases SkMaskFilter SkRefCnt by one.
|
||||
|
||||
@return SkMaskFilter if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refMaskFilter
|
||||
*/
|
||||
sk_sp<SkMaskFilter> refMaskFilter() const;
|
||||
|
||||
|
@ -550,9 +528,6 @@ public:
|
|||
Increments maskFilter SkRefCnt by one.
|
||||
|
||||
@param maskFilter modifies clipping mask generated from drawn geometry
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setMaskFilter
|
||||
example: https://fiddle.skia.org/c/@Typeface_Methods
|
||||
*/
|
||||
void setMaskFilter(sk_sp<SkMaskFilter> maskFilter);
|
||||
|
||||
|
@ -567,8 +542,6 @@ public:
|
|||
Increases SkImageFilter SkRefCnt by one.
|
||||
|
||||
@return SkImageFilter if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refImageFilter
|
||||
*/
|
||||
sk_sp<SkImageFilter> refImageFilter() const;
|
||||
|
||||
|
@ -579,8 +552,6 @@ public:
|
|||
Increments imageFilter SkRefCnt by one.
|
||||
|
||||
@param imageFilter how SkImage is sampled when transformed
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setImageFilter
|
||||
*/
|
||||
void setImageFilter(sk_sp<SkImageFilter> imageFilter);
|
||||
|
||||
|
@ -591,8 +562,6 @@ public:
|
|||
new alpha of zero.
|
||||
|
||||
@return true if SkPaint prevents all drawing
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_nothingToDraw
|
||||
*/
|
||||
bool nothingToDraw() const;
|
||||
|
||||
|
@ -629,7 +598,23 @@ public:
|
|||
@param storage computed bounds of geometry; may not be nullptr
|
||||
@return fast computed bounds
|
||||
*/
|
||||
const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const;
|
||||
const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
|
||||
// Things like stroking, etc... will do math on the bounds rect, assuming that it's sorted.
|
||||
SkASSERT(orig.isSorted());
|
||||
SkPaint::Style style = this->getStyle();
|
||||
// ultra fast-case: filling with no effects that affect geometry
|
||||
if (kFill_Style == style) {
|
||||
uintptr_t effects = 0;
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
|
||||
if (!effects) {
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
|
||||
return this->doComputeFastBounds(orig, storage, style);
|
||||
}
|
||||
|
||||
/** (to be made private)
|
||||
|
||||
|
@ -655,15 +640,12 @@ public:
|
|||
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
|
||||
Style style) const;
|
||||
|
||||
using sk_is_trivially_relocatable = std::true_type;
|
||||
|
||||
private:
|
||||
sk_sp<SkPathEffect> fPathEffect;
|
||||
sk_sp<SkShader> fShader;
|
||||
sk_sp<SkMaskFilter> fMaskFilter;
|
||||
sk_sp<SkColorFilter> fColorFilter;
|
||||
sk_sp<SkImageFilter> fImageFilter;
|
||||
sk_sp<SkBlender> fBlender;
|
||||
|
||||
SkColor4f fColor4f;
|
||||
SkScalar fWidth;
|
||||
|
@ -675,21 +657,12 @@ private:
|
|||
unsigned fCapType : 2;
|
||||
unsigned fJoinType : 2;
|
||||
unsigned fStyle : 2;
|
||||
unsigned fPadding : 24; // 24 == 32 -1-1-2-2-2
|
||||
unsigned fFilterQuality : 2;
|
||||
unsigned fBlendMode : 8; // only need 5-6?
|
||||
unsigned fPadding : 14; // 14==32-1-1-2-2-2-2-8
|
||||
} fBitfields;
|
||||
uint32_t fBitfieldsUInt;
|
||||
};
|
||||
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fPathEffect)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fShader)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fMaskFilter)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fColorFilter)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fImageFilter)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fBlender)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fColor4f)>::value);
|
||||
static_assert(::sk_is_trivially_relocatable<decltype(fBitfields)>::value);
|
||||
|
||||
friend class SkPaintPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPathBuilder_DEFINED
|
||||
#define SkPathBuilder_DEFINED
|
||||
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkPathTypes.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/SkPathRef.h"
|
||||
#include "include/private/base/SkTo.h"
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
class SkRRect;
|
||||
|
||||
class SK_API SkPathBuilder {
|
||||
public:
|
||||
SkPathBuilder();
|
||||
SkPathBuilder(SkPathFillType);
|
||||
SkPathBuilder(const SkPath&);
|
||||
SkPathBuilder(const SkPathBuilder&) = default;
|
||||
~SkPathBuilder();
|
||||
|
||||
SkPathBuilder& operator=(const SkPath&);
|
||||
SkPathBuilder& operator=(const SkPathBuilder&) = default;
|
||||
|
||||
SkPathFillType fillType() const { return fFillType; }
|
||||
SkRect computeBounds() const;
|
||||
|
||||
SkPath snapshot() const; // the builder is unchanged after returning this path
|
||||
SkPath detach(); // the builder is reset to empty after returning this path
|
||||
|
||||
SkPathBuilder& setFillType(SkPathFillType ft) { fFillType = ft; return *this; }
|
||||
SkPathBuilder& setIsVolatile(bool isVolatile) { fIsVolatile = isVolatile; return *this; }
|
||||
|
||||
SkPathBuilder& reset();
|
||||
|
||||
SkPathBuilder& moveTo(SkPoint pt);
|
||||
SkPathBuilder& moveTo(SkScalar x, SkScalar y) { return this->moveTo(SkPoint::Make(x, y)); }
|
||||
|
||||
SkPathBuilder& lineTo(SkPoint pt);
|
||||
SkPathBuilder& lineTo(SkScalar x, SkScalar y) { return this->lineTo(SkPoint::Make(x, y)); }
|
||||
|
||||
SkPathBuilder& quadTo(SkPoint pt1, SkPoint pt2);
|
||||
SkPathBuilder& quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
|
||||
return this->quadTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2));
|
||||
}
|
||||
SkPathBuilder& quadTo(const SkPoint pts[2]) { return this->quadTo(pts[0], pts[1]); }
|
||||
|
||||
SkPathBuilder& conicTo(SkPoint pt1, SkPoint pt2, SkScalar w);
|
||||
SkPathBuilder& conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
|
||||
return this->conicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), w);
|
||||
}
|
||||
SkPathBuilder& conicTo(const SkPoint pts[2], SkScalar w) {
|
||||
return this->conicTo(pts[0], pts[1], w);
|
||||
}
|
||||
|
||||
SkPathBuilder& cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
|
||||
SkPathBuilder& cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
|
||||
return this->cubicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), SkPoint::Make(x3, y3));
|
||||
}
|
||||
SkPathBuilder& cubicTo(const SkPoint pts[3]) {
|
||||
return this->cubicTo(pts[0], pts[1], pts[2]);
|
||||
}
|
||||
|
||||
SkPathBuilder& close();
|
||||
|
||||
// Append a series of lineTo(...)
|
||||
SkPathBuilder& polylineTo(const SkPoint pts[], int count);
|
||||
SkPathBuilder& polylineTo(const std::initializer_list<SkPoint>& list) {
|
||||
return this->polylineTo(list.begin(), SkToInt(list.size()));
|
||||
}
|
||||
|
||||
// Relative versions of segments, relative to the previous position.
|
||||
|
||||
SkPathBuilder& rLineTo(SkPoint pt);
|
||||
SkPathBuilder& rLineTo(SkScalar x, SkScalar y) { return this->rLineTo({x, y}); }
|
||||
SkPathBuilder& rQuadTo(SkPoint pt1, SkPoint pt2);
|
||||
SkPathBuilder& rQuadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
|
||||
return this->rQuadTo({x1, y1}, {x2, y2});
|
||||
}
|
||||
SkPathBuilder& rConicTo(SkPoint p1, SkPoint p2, SkScalar w);
|
||||
SkPathBuilder& rConicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
|
||||
return this->rConicTo({x1, y1}, {x2, y2}, w);
|
||||
}
|
||||
SkPathBuilder& rCubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
|
||||
SkPathBuilder& rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
|
||||
return this->rCubicTo({x1, y1}, {x2, y2}, {x3, y3});
|
||||
}
|
||||
|
||||
// Arcs
|
||||
|
||||
/** Appends arc to the builder. Arc added is part of ellipse
|
||||
bounded by oval, from startAngle through sweepAngle. Both startAngle and
|
||||
sweepAngle are measured in degrees, where zero degrees is aligned with the
|
||||
positive x-axis, and positive sweeps extends arc clockwise.
|
||||
|
||||
arcTo() adds line connecting the builder's last point to initial arc point if forceMoveTo
|
||||
is false and the builder is not empty. Otherwise, added contour begins with first point
|
||||
of arc. Angles greater than -360 and less than 360 are treated modulo 360.
|
||||
|
||||
@param oval bounds of ellipse containing arc
|
||||
@param startAngleDeg starting angle of arc in degrees
|
||||
@param sweepAngleDeg sweep, in degrees. Positive is clockwise; treated modulo 360
|
||||
@param forceMoveTo true to start a new contour with arc
|
||||
@return reference to the builder
|
||||
*/
|
||||
SkPathBuilder& arcTo(const SkRect& oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg,
|
||||
bool forceMoveTo);
|
||||
|
||||
/** Appends arc to SkPath, after appending line if needed. Arc is implemented by conic
|
||||
weighted to describe part of circle. Arc is contained by tangent from
|
||||
last SkPath point to p1, and tangent from p1 to p2. Arc
|
||||
is part of circle sized to radius, positioned so it touches both tangent lines.
|
||||
|
||||
If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath.
|
||||
The length of vector from p1 to p2 does not affect arc.
|
||||
|
||||
Arc sweep is always less than 180 degrees. If radius is zero, or if
|
||||
tangents are nearly parallel, arcTo() appends line from last SkPath SkPoint to p1.
|
||||
|
||||
arcTo() appends at most one line and one conic.
|
||||
arcTo() implements the functionality of PostScript arct and HTML Canvas arcTo.
|
||||
|
||||
@param p1 SkPoint common to pair of tangents
|
||||
@param p2 end of second tangent
|
||||
@param radius distance from arc to circle center
|
||||
@return reference to SkPath
|
||||
*/
|
||||
SkPathBuilder& arcTo(SkPoint p1, SkPoint p2, SkScalar radius);
|
||||
|
||||
enum ArcSize {
|
||||
kSmall_ArcSize, //!< smaller of arc pair
|
||||
kLarge_ArcSize, //!< larger of arc pair
|
||||
};
|
||||
|
||||
/** Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe
|
||||
part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves
|
||||
from last SkPath SkPoint to (xy.fX, xy.fY), choosing one of four possible routes:
|
||||
clockwise or counterclockwise,
|
||||
and smaller or larger.
|
||||
|
||||
Arc sweep is always less than 360 degrees. arcTo() appends line to xy if either
|
||||
radii are zero, or if last SkPath SkPoint equals (xy.fX, xy.fY). arcTo() scales radii r to
|
||||
fit last SkPath SkPoint and xy if both are greater than zero but too small to describe
|
||||
an arc.
|
||||
|
||||
arcTo() appends up to four conic curves.
|
||||
arcTo() implements the functionality of SVG arc, although SVG sweep-flag value is
|
||||
opposite the integer value of sweep; SVG sweep-flag uses 1 for clockwise, while
|
||||
kCW_Direction cast to int is zero.
|
||||
|
||||
@param r radii on axes before x-axis rotation
|
||||
@param xAxisRotate x-axis rotation in degrees; positive values are clockwise
|
||||
@param largeArc chooses smaller or larger arc
|
||||
@param sweep chooses clockwise or counterclockwise arc
|
||||
@param xy end of arc
|
||||
@return reference to SkPath
|
||||
*/
|
||||
SkPathBuilder& arcTo(SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep,
|
||||
SkPoint xy);
|
||||
|
||||
/** Appends arc to the builder, as the start of new contour. Arc added is part of ellipse
|
||||
bounded by oval, from startAngle through sweepAngle. Both startAngle and
|
||||
sweepAngle are measured in degrees, where zero degrees is aligned with the
|
||||
positive x-axis, and positive sweeps extends arc clockwise.
|
||||
|
||||
If sweepAngle <= -360, or sweepAngle >= 360; and startAngle modulo 90 is nearly
|
||||
zero, append oval instead of arc. Otherwise, sweepAngle values are treated
|
||||
modulo 360, and arc may or may not draw depending on numeric rounding.
|
||||
|
||||
@param oval bounds of ellipse containing arc
|
||||
@param startAngleDeg starting angle of arc in degrees
|
||||
@param sweepAngleDeg sweep, in degrees. Positive is clockwise; treated modulo 360
|
||||
@return reference to this builder
|
||||
*/
|
||||
SkPathBuilder& addArc(const SkRect& oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg);
|
||||
|
||||
// Add a new contour
|
||||
|
||||
SkPathBuilder& addRect(const SkRect&, SkPathDirection, unsigned startIndex);
|
||||
SkPathBuilder& addOval(const SkRect&, SkPathDirection, unsigned startIndex);
|
||||
SkPathBuilder& addRRect(const SkRRect&, SkPathDirection, unsigned startIndex);
|
||||
|
||||
SkPathBuilder& addRect(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
|
||||
return this->addRect(rect, dir, 0);
|
||||
}
|
||||
SkPathBuilder& addOval(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
|
||||
// legacy start index: 1
|
||||
return this->addOval(rect, dir, 1);
|
||||
}
|
||||
SkPathBuilder& addRRect(const SkRRect& rrect, SkPathDirection dir = SkPathDirection::kCW) {
|
||||
// legacy start indices: 6 (CW) and 7 (CCW)
|
||||
return this->addRRect(rrect, dir, dir == SkPathDirection::kCW ? 6 : 7);
|
||||
}
|
||||
|
||||
SkPathBuilder& addCircle(SkScalar center_x, SkScalar center_y, SkScalar radius,
|
||||
SkPathDirection dir = SkPathDirection::kCW);
|
||||
|
||||
SkPathBuilder& addPolygon(const SkPoint pts[], int count, bool isClosed);
|
||||
SkPathBuilder& addPolygon(const std::initializer_list<SkPoint>& list, bool isClosed) {
|
||||
return this->addPolygon(list.begin(), SkToInt(list.size()), isClosed);
|
||||
}
|
||||
|
||||
SkPathBuilder& addPath(const SkPath&);
|
||||
|
||||
// Performance hint, to reserve extra storage for subsequent calls to lineTo, quadTo, etc.
|
||||
|
||||
void incReserve(int extraPtCount, int extraVerbCount);
|
||||
void incReserve(int extraPtCount) {
|
||||
this->incReserve(extraPtCount, extraPtCount);
|
||||
}
|
||||
|
||||
SkPathBuilder& offset(SkScalar dx, SkScalar dy);
|
||||
|
||||
SkPathBuilder& toggleInverseFillType() {
|
||||
fFillType = (SkPathFillType)((unsigned)fFillType ^ 2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
SkPathRef::PointsArray fPts;
|
||||
SkPathRef::VerbsArray fVerbs;
|
||||
SkPathRef::ConicWeightsArray fConicWeights;
|
||||
|
||||
SkPathFillType fFillType;
|
||||
bool fIsVolatile;
|
||||
|
||||
unsigned fSegmentMask;
|
||||
SkPoint fLastMovePoint;
|
||||
int fLastMoveIndex; // only needed until SkPath is immutable
|
||||
bool fNeedsMoveVerb;
|
||||
|
||||
enum IsA {
|
||||
kIsA_JustMoves, // we only have 0 or more moves
|
||||
kIsA_MoreThanMoves, // we have verbs other than just move
|
||||
kIsA_Oval, // we are 0 or more moves followed by an oval
|
||||
kIsA_RRect, // we are 0 or more moves followed by a rrect
|
||||
};
|
||||
IsA fIsA = kIsA_JustMoves;
|
||||
int fIsAStart = -1; // tracks direction iff fIsA is not unknown
|
||||
bool fIsACCW = false; // tracks direction iff fIsA is not unknown
|
||||
|
||||
int countVerbs() const { return fVerbs.size(); }
|
||||
|
||||
// called right before we add a (non-move) verb
|
||||
void ensureMove() {
|
||||
fIsA = kIsA_MoreThanMoves;
|
||||
if (fNeedsMoveVerb) {
|
||||
this->moveTo(fLastMovePoint);
|
||||
}
|
||||
}
|
||||
|
||||
SkPath make(sk_sp<SkPathRef>) const;
|
||||
|
||||
SkPathBuilder& privateReverseAddPath(const SkPath&);
|
||||
|
||||
friend class SkPathPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче