diff options
Diffstat (limited to 'chromium/third_party/skia/include')
65 files changed, 1109 insertions, 1092 deletions
diff --git a/chromium/third_party/skia/include/android/SkBRDAllocator.h b/chromium/third_party/skia/include/android/SkBRDAllocator.h deleted file mode 100644 index ae842b74b17..00000000000 --- a/chromium/third_party/skia/include/android/SkBRDAllocator.h +++ /dev/null @@ -1,29 +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 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 diff --git a/chromium/third_party/skia/include/android/SkBitmapRegionDecoder.h b/chromium/third_party/skia/include/android/SkBitmapRegionDecoder.h deleted file mode 100644 index 18ba90b7741..00000000000 --- a/chromium/third_party/skia/include/android/SkBitmapRegionDecoder.h +++ /dev/null @@ -1,92 +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 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 diff --git a/chromium/third_party/skia/include/atlastext/SkAtlasTextContext.h b/chromium/third_party/skia/include/atlastext/SkAtlasTextContext.h deleted file mode 100644 index d13ec51e231..00000000000 --- a/chromium/third_party/skia/include/atlastext/SkAtlasTextContext.h +++ /dev/null @@ -1,42 +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 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 diff --git a/chromium/third_party/skia/include/atlastext/SkAtlasTextFont.h b/chromium/third_party/skia/include/atlastext/SkAtlasTextFont.h deleted file mode 100644 index 8bab5bfc85a..00000000000 --- a/chromium/third_party/skia/include/atlastext/SkAtlasTextFont.h +++ /dev/null @@ -1,38 +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 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 diff --git a/chromium/third_party/skia/include/atlastext/SkAtlasTextRenderer.h b/chromium/third_party/skia/include/atlastext/SkAtlasTextRenderer.h deleted file mode 100644 index e572bb6e52d..00000000000 --- a/chromium/third_party/skia/include/atlastext/SkAtlasTextRenderer.h +++ /dev/null @@ -1,72 +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. - */ - -#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 diff --git a/chromium/third_party/skia/include/atlastext/SkAtlasTextTarget.h b/chromium/third_party/skia/include/atlastext/SkAtlasTextTarget.h deleted file mode 100644 index ca8eca71930..00000000000 --- a/chromium/third_party/skia/include/atlastext/SkAtlasTextTarget.h +++ /dev/null @@ -1,100 +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 SkAtlasTextTarget_DEFINED -#define SkAtlasTextTarget_DEFINED - -#include "include/core/SkRefCnt.h" -#include "include/core/SkScalar.h" -#include "include/private/SkDeque.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 diff --git a/chromium/third_party/skia/include/core/SkCanvas.h b/chromium/third_party/skia/include/core/SkCanvas.h index 975aab059b6..36c4d3eeaeb 100644 --- a/chromium/third_party/skia/include/core/SkCanvas.h +++ b/chromium/third_party/skia/include/core/SkCanvas.h @@ -684,35 +684,6 @@ public: , fSaveLayerFlags(saveLayerFlags) {} - /** Experimental. Not ready for general use. - Sets fBounds, fPaint, fBackdrop, fClipMask, fClipMatrix, and fSaveLayerFlags. - clipMatrix uses alpha channel of image, transformed by clipMatrix, to clip - layer when drawn to SkCanvas. - - @param bounds layer dimensions; may be nullptr - @param paint graphics state applied to layer when overlaying prior - layer; may be nullptr - @param backdrop If not null, this causes the current layer to be filtered by - backdrop, and then drawn into the new layer - (respecting the current clip). - If null, the new layer is initialized with transparent-black. - @param clipMask clip applied to layer; may be nullptr - @param clipMatrix matrix applied to clipMask; may be nullptr to use - identity matrix - @param saveLayerFlags SaveLayerRec options to modify layer - @return SaveLayerRec fully specified - */ - SaveLayerRec(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop, - const SkImage* clipMask, const SkMatrix* clipMatrix, - SaveLayerFlags saveLayerFlags) - : fBounds(bounds) - , fPaint(paint) - , fBackdrop(backdrop) - , fClipMask(clipMask) - , fClipMatrix(clipMatrix) - , fSaveLayerFlags(saveLayerFlags) - {} - /** hints at layer size limit */ const SkRect* fBounds = nullptr; @@ -727,12 +698,6 @@ public: */ const SkImageFilter* fBackdrop = nullptr; - /** clips layer with mask alpha */ - const SkImage* fClipMask = nullptr; - - /** transforms mask alpha used to clip */ - const SkMatrix* fClipMatrix = nullptr; - /** preserves LCD text, creates with prior layer contents */ SaveLayerFlags fSaveLayerFlags = 0; }; @@ -1130,7 +1095,17 @@ public: example: https://fiddle.skia.org/c/@Canvas_drawColor */ - void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver); + void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver) { + this->drawColor(SkColor4f::FromColor(color), mode); + } + + /** Fills clip with color color. + mode determines how ARGB is combined with destination. + + @param color SkColor4f representing unpremultiplied color. + @param mode SkBlendMode used to combine source color and destination + */ + void drawColor(const SkColor4f& color, SkBlendMode mode = SkBlendMode::kSrcOver); /** Fills clip with color color using SkBlendMode::kSrc. This has the effect of replacing all pixels contained by clip with color. @@ -1138,6 +1113,15 @@ public: @param color unpremultiplied ARGB */ void clear(SkColor color) { + this->clear(SkColor4f::FromColor(color)); + } + + /** Fills clip with color color using SkBlendMode::kSrc. + This has the effect of replacing all pixels contained by clip with color. + + @param color SkColor4f representing unpremultiplied color. + */ + void clear(const SkColor4f& color) { this->drawColor(color, SkBlendMode::kSrc); } @@ -1486,8 +1470,8 @@ public: /** Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just @@ -1518,8 +1502,8 @@ public: boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just @@ -1548,8 +1532,8 @@ public: /** Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just @@ -1572,8 +1556,8 @@ public: /** Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just @@ -1601,8 +1585,8 @@ public: isrc is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just @@ -1633,8 +1617,8 @@ public: /** Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If generated mask extends beyond image bounds, replicate image edge colors, just @@ -1645,10 +1629,6 @@ public: current CTM, so will reflect the dst rect geometry and is equivalent to drawRect(dst). - constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to - sample within image; set to kFast_SrcRectConstraint allows sampling outside to - improve performance. - @param image SkImage containing pixels, dimensions, and format @param dst destination SkRect of image to draw to @param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter, @@ -1665,8 +1645,8 @@ public: Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If paint SkFilterQuality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint SkFilterQuality, use kLow_SkFilterQuality to filter pixels. @@ -1692,8 +1672,8 @@ public: Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If paint SkFilterQuality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint SkFilterQuality, use kLow_SkFilterQuality to filter pixels. @@ -1717,8 +1697,8 @@ public: /** Draws SkBitmap bitmap, with its top-left corner at (left, top), using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, @@ -1738,8 +1718,8 @@ public: /** Draws SkRect src of SkBitmap bitmap, scaled and translated to fill SkRect dst. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, @@ -1766,8 +1746,8 @@ public: isrc is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, @@ -1794,8 +1774,8 @@ public: bitmap bounds is on integer pixel boundaries; dst may include fractional boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If bitmap is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from bitmap bounds. If generated mask extends beyond bitmap bounds, replicate bitmap edge colors, @@ -1856,8 +1836,8 @@ public: Additionally transform draw using clip, SkMatrix, and optional SkPaint paint. - If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. If image is kAlpha_8_SkColorType, apply SkShader. + If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and + SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader. If paint contains SkMaskFilter, generate mask from image bounds. If paint SkFilterQuality set to kNone_SkFilterQuality, disable pixel filtering. For all other values of paint SkFilterQuality, use kLow_SkFilterQuality to filter pixels. @@ -1987,7 +1967,7 @@ public: size is 12 point. All elements of paint: SkPathEffect, SkMaskFilter, SkShader, - SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By + SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs. @param text character code points or glyphs drawn @@ -2015,7 +1995,7 @@ public: size is 12 point. All elements of paint: SkPathEffect, SkMaskFilter, SkShader, - SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By + SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs. @param str character code points drawn, @@ -2044,7 +2024,7 @@ public: size is 12 point. All elements of paint: SkPathEffect, SkMaskFilter, SkShader, - SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By + SkColorFilter, and SkImageFilter; apply to text. By default, draws filled black glyphs. @param str character code points drawn, @@ -2070,7 +2050,7 @@ public: SkTextEncoding must be set to SkTextEncoding::kGlyphID. Elements of paint: anti-alias, SkBlendMode, color including alpha, - SkColorFilter, SkPaint dither, SkDrawLooper, SkMaskFilter, SkPathEffect, SkShader, and + SkColorFilter, SkPaint dither, SkMaskFilter, SkPathEffect, SkShader, and SkPaint::Style; apply to blob. If SkPaint contains SkPaint::kStroke_Style: SkPaint miter limit, SkPaint::Cap, SkPaint::Join, and SkPaint stroke width; apply to SkPath created from blob. @@ -2095,7 +2075,7 @@ public: SkTextEncoding must be set to SkTextEncoding::kGlyphID. Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter, - SkImageFilter, and SkDrawLooper; apply to blob. + and SkImageFilter; apply to blob. @param blob glyphs, positions, and their paints' text size, typeface, and so on @param x horizontal offset applied to blob @@ -2164,8 +2144,11 @@ public: } /** Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. - If vertices texs and vertices colors are defined in vertices, and SkPaint paint - contains SkShader, SkBlendMode mode combines vertices colors with SkShader. + If paint contains an SkShader and vertices does not contain texCoords, the shader + is mapped using the vertices' positions. + + If vertices colors are defined in vertices, and SkPaint paint contains SkShader, + SkBlendMode mode combines vertices colors with SkShader. @param vertices triangle mesh to draw @param mode combines vertices colors with SkShader, if both are present @@ -2183,8 +2166,11 @@ public: } /** Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix. - If vertices texs and vertices colors are defined in vertices, and SkPaint paint - contains SkShader, SkBlendMode mode combines vertices colors with SkShader. + If paint contains an SkShader and vertices does not contain texCoords, the shader + is mapped using the vertices' positions. + + If vertices colors are defined in vertices, and SkPaint paint contains SkShader, + SkBlendMode mode combines vertices colors with SkShader. @param vertices triangle mesh to draw @param mode combines vertices colors with SkShader, if both are present @@ -2217,7 +2203,8 @@ public: bottom-right, bottom-left order. If paint contains SkShader, SkPoint array texCoords maps SkShader as texture to - corners in top-left, top-right, bottom-right, bottom-left order. + corners in top-left, top-right, bottom-right, bottom-left order. If texCoords is + nullptr, SkShader is mapped using positions (derived from cubics). @param cubics SkPath cubic array, sharing common points @param colors color array, one for each corner @@ -2245,7 +2232,8 @@ public: bottom-right, bottom-left order. If paint contains SkShader, SkPoint array texCoords maps SkShader as texture to - corners in top-left, top-right, bottom-right, bottom-left order. + corners in top-left, top-right, bottom-right, bottom-left order. If texCoords is + nullptr, SkShader is mapped using positions (derived from cubics). @param cubics SkPath cubic array, sharing common points @param colors color array, one for each corner @@ -2733,8 +2721,7 @@ private: void internalDrawPaint(const SkPaint& paint); void internalSaveLayer(const SaveLayerRec&, SaveLayerStrategy); void internalSaveBehind(const SkRect*); - void internalDrawDevice(SkBaseDevice*, const SkPaint*, SkImage* clipImage, - const SkMatrix& clipMatrix); + void internalDrawDevice(SkBaseDevice*, const SkPaint*); void internalConcat44(const SkM44&); diff --git a/chromium/third_party/skia/include/core/SkColorFilter.h b/chromium/third_party/skia/include/core/SkColorFilter.h index 1222862f399..b9f680835a6 100644 --- a/chromium/third_party/skia/include/core/SkColorFilter.h +++ b/chromium/third_party/skia/include/core/SkColorFilter.h @@ -11,70 +11,44 @@ #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 SkArenaAlloc; -class SkBitmap; class SkColorMatrix; -class SkColorSpace; -struct SkStageRec; - -namespace skvm { - class Builder; - struct F32; - struct Uniforms; - struct Color; -} /** - * 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); - } + bool asColorMode(SkColor* color, SkBlendMode* mode) const; /** 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 { - return this->onAsAColorMode(color, mode); - } + bool asAColorMode(SkColor* color, SkBlendMode* mode) const; /** 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 { - return this->onAsAColorMatrix(matrix); - } - - bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const; - - skvm::Color program(skvm::Builder*, skvm::Color, - SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const; + bool asAColorMatrix(float matrix[20]) const; + // deprecated, use isAlphaUnchanged() enum Flags { - /** If set the filter methods will not change the alpha channel of the colors. - */ kAlphaUnchanged_Flag = 1 << 0, }; + uint32_t getFlags() const; + - /** Returns the flags for this filter. Override in subclasses to return custom flags. - */ - virtual uint32_t getFlags() const { return 0; } + // Returns true if the filter is guaranteed to never change the alpha of a color it filters. + bool isAlphaUnchanged() const; SkColor filterColor(SkColor) const; @@ -92,52 +66,13 @@ public: */ 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) { - 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: - virtual bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const = 0; - - virtual skvm::Color onProgram(skvm::Builder*, skvm::Color, - SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const = 0; + SkColorFilter() = default; + friend class SkColorFilterBase; typedef SkFlattenable INHERITED; }; diff --git a/chromium/third_party/skia/include/core/SkColorSpace.h b/chromium/third_party/skia/include/core/SkColorSpace.h index f64b5702d67..9bc14afad01 100644 --- a/chromium/third_party/skia/include/core/SkColorSpace.h +++ b/chromium/third_party/skia/include/core/SkColorSpace.h @@ -86,8 +86,6 @@ static constexpr skcms_Matrix3x3 kDisplayP3 = {{ { 0.241182f, 0.692236f, 0.0665819f }, { -0.00104941f, 0.0418818f, 0.784378f }, }}; -// TODO: skia:9792 We originally misnamed this matrix... delete this incorrect alias? -static constexpr skcms_Matrix3x3 kDCIP3 = kDisplayP3; static constexpr skcms_Matrix3x3 kRec2020 = {{ { 0.673459f, 0.165661f, 0.125100f }, diff --git a/chromium/third_party/skia/include/core/SkDeferredDisplayList.h b/chromium/third_party/skia/include/core/SkDeferredDisplayList.h index f63d94636da..ef14f17ce10 100644 --- a/chromium/third_party/skia/include/core/SkDeferredDisplayList.h +++ b/chromium/third_party/skia/include/core/SkDeferredDisplayList.h @@ -21,6 +21,8 @@ class SkDeferredDisplayListPriv; class GrRenderTask; class GrRenderTargetProxy; struct GrCCPerOpsTaskPaths; +#else +using GrRenderTargetProxy = SkRefCnt; #endif /* @@ -83,6 +85,7 @@ private: }; SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization, + sk_sp<GrRenderTargetProxy> fTargetProxy, sk_sp<LazyProxyData>); #if SK_SUPPORT_GPU @@ -108,6 +111,7 @@ private: SkTArray<sk_sp<GrRenderTask>> fRenderTasks; SkTArray<GrRecordingContext::ProgramData> fProgramData; + sk_sp<GrRenderTargetProxy> fTargetProxy; sk_sp<LazyProxyData> fLazyProxyData; #endif }; diff --git a/chromium/third_party/skia/include/core/SkDeferredDisplayListRecorder.h b/chromium/third_party/skia/include/core/SkDeferredDisplayListRecorder.h index ecb61f851b4..6e38c93a294 100644 --- a/chromium/third_party/skia/include/core/SkDeferredDisplayListRecorder.h +++ b/chromium/third_party/skia/include/core/SkDeferredDisplayListRecorder.h @@ -158,6 +158,7 @@ private: #if SK_SUPPORT_GPU sk_sp<GrContext> fContext; + sk_sp<GrRenderTargetProxy> fTargetProxy; sk_sp<SkDeferredDisplayList::LazyProxyData> fLazyProxyData; sk_sp<SkSurface> fSurface; #endif diff --git a/chromium/third_party/skia/include/core/SkDrawLooper.h b/chromium/third_party/skia/include/core/SkDrawLooper.h index 529fdb99cd1..0273a18c058 100644 --- a/chromium/third_party/skia/include/core/SkDrawLooper.h +++ b/chromium/third_party/skia/include/core/SkDrawLooper.h @@ -23,12 +23,7 @@ class SkPaint; struct SkRect; /** \class SkDrawLooper - 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. + DEPRECATED: No longer supported in Skia. */ class SK_API SkDrawLooper : public SkFlattenable { public: diff --git a/chromium/third_party/skia/include/core/SkFlattenable.h b/chromium/third_party/skia/include/core/SkFlattenable.h index eede64f3317..bb9d70faef6 100644 --- a/chromium/third_party/skia/include/core/SkFlattenable.h +++ b/chromium/third_party/skia/include/core/SkFlattenable.h @@ -28,7 +28,7 @@ public: enum Type { kSkColorFilter_Type, kSkDrawable_Type, - kSkDrawLooper_Type, + kSkDrawLooper_Type, // no longer used internally by Skia kSkImageFilter_Type, kSkMaskFilter_Type, kSkPathEffect_Type, @@ -95,12 +95,23 @@ private: typedef SkRefCnt INHERITED; }; -#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; } +#if defined(SK_DISABLE_EFFECT_DESERIALIZATION) + #define SK_REGISTER_FLATTENABLE(type) do{}while(false) + + #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 #endif diff --git a/chromium/third_party/skia/include/core/SkFontStyle.h b/chromium/third_party/skia/include/core/SkFontStyle.h index 50b5bd026da..dfb2ec9dc4d 100644 --- a/chromium/third_party/skia/include/core/SkFontStyle.h +++ b/chromium/third_party/skia/include/core/SkFontStyle.h @@ -74,7 +74,7 @@ public: } private: - uint32_t fValue; + int32_t fValue; }; #endif diff --git a/chromium/third_party/skia/include/core/SkImage.h b/chromium/third_party/skia/include/core/SkImage.h index db885397354..2a359446211 100644 --- a/chromium/third_party/skia/include/core/SkImage.h +++ b/chromium/third_party/skia/include/core/SkImage.h @@ -493,16 +493,21 @@ public: /** Creates an SkImage by storing the specified YUVA planes into an image, to be rendered via multitexturing. - @param context GPU context - @param yuvColorSpace How the YUV values are converted to RGB - @param yuvaTextures array of (up to four) YUVA textures on GPU which contain the, - possibly interleaved, YUVA planes - @param yuvaIndices array indicating which texture in yuvaTextures, and channel - in that texture, maps to each component of YUVA. - @param imageSize size of the resulting image - @param imageOrigin origin of the resulting image. - @param imageColorSpace range of colors of the resulting image; may be nullptr - @return created SkImage, or nullptr + When all the provided backend textures can be released 'textureReleaseProc' will be called + with 'releaseContext'. It will be called even if this method fails. + + @param context GPU context + @param yuvColorSpace How the YUV values are converted to RGB + @param yuvaTextures array of (up to four) YUVA textures on GPU which contain the, + possibly interleaved, YUVA planes + @param yuvaIndices array indicating which texture in yuvaTextures, and channel + in that texture, maps to each component of YUVA. + @param imageSize size of the resulting image + @param imageOrigin origin of the resulting image. + @param imageColorSpace range of colors of the resulting image; may be nullptr + @param textureReleaseProc called when the backend textures can be released + @param releaseContext state passed to textureReleaseProc + @return created SkImage, or nullptr */ static sk_sp<SkImage> MakeFromYUVATextures(GrContext* context, SkYUVColorSpace yuvColorSpace, @@ -510,7 +515,9 @@ public: const SkYUVAIndex yuvaIndices[4], SkISize imageSize, GrSurfaceOrigin imageOrigin, - sk_sp<SkColorSpace> imageColorSpace = nullptr); + sk_sp<SkColorSpace> imageColorSpace = nullptr, + TextureReleaseProc textureReleaseProc = nullptr, + ReleaseContext releaseContext = nullptr); /** Creates SkImage from pixmap array representing YUVA data. SkImage is uploaded to GPU back-end using context. @@ -767,6 +774,9 @@ public: SkTileMode rules to fill drawn area outside SkImage. localMatrix permits transforming SkImage before SkCanvas matrix is applied. + Note: since no filter-quality is specified, it will be determined at draw time using + the paint. + @param tmx tiling in the x direction @param tmy tiling in the y direction @param localMatrix SkImage transformation, or nullptr @@ -778,6 +788,9 @@ public: return this->makeShader(tmx, tmy, &localMatrix); } + sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, const SkMatrix* localMatrix, + SkFilterQuality) const; + /** Creates SkShader from SkImage. SkShader dimensions are taken from SkImage. SkShader uses SkShader::kClamp_TileMode to fill drawn area outside SkImage. localMatrix permits transforming SkImage before SkCanvas matrix is applied. @@ -841,8 +854,13 @@ public: */ GrSemaphoresSubmitted flush(GrContext* context, const GrFlushInfo& flushInfo); - /** Version of flush() that uses a default GrFlushInfo. */ - void flush(GrContext*); + /** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the + GPU. + */ + void flushAndSubmit(GrContext*); + + /** Deprecated. */ + void flush(GrContext* context) { this->flushAndSubmit(context); } /** Retrieves the back-end texture. If SkImage has no back-end texture, an invalid object is returned. Call GrBackendTexture::isValid to determine if the result diff --git a/chromium/third_party/skia/include/core/SkImageInfo.h b/chromium/third_party/skia/include/core/SkImageInfo.h index 8ba9b406d72..b4c2c56cae7 100644 --- a/chromium/third_party/skia/include/core/SkImageInfo.h +++ b/chromium/third_party/skia/include/core/SkImageInfo.h @@ -55,17 +55,11 @@ static inline bool SkAlphaTypeIsOpaque(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. + 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. + 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 { kUnknown_SkColorType, //!< uninitialized @@ -80,27 +74,30 @@ enum SkColorType { 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 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_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 + 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_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 + 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 + 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 ARGB 32-bit encoding + kN32_SkColorType = kRGBA_8888_SkColorType,//!< native 32-bit RGBA encoding #else #error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order" @@ -139,11 +136,11 @@ 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 and RGB. + YUV to RGB. JPEG YUV values encode the full range of 0 to 255 for all three components. - 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. + Video YUV values range from 16 to 235 for Y and from 16 to 240 for U and V. + 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. @@ -584,20 +581,22 @@ public: @return width() times bytesPerPixel() as unsigned 64-bit integer */ - uint64_t minRowBytes64() const { return sk_64_mul(this->width(), this->bytesPerPixel()); } + uint64_t minRowBytes64() const { + return (uint64_t)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 signed 32-bit integer + @return width() times bytesPerPixel() as size_t */ size_t minRowBytes() const { uint64_t minRowBytes = this->minRowBytes64(); if (!SkTFitsIn<int32_t>(minRowBytes)) { return 0; } - return SkTo<int32_t>(minRowBytes); + return (size_t)minRowBytes; } /** Returns byte offset of pixel from pixel base address. diff --git a/chromium/third_party/skia/include/core/SkMatrix.h b/chromium/third_party/skia/include/core/SkMatrix.h index dca1a110622..f54bb557cdc 100644 --- a/chromium/third_party/skia/include/core/SkMatrix.h +++ b/chromium/third_party/skia/include/core/SkMatrix.h @@ -63,27 +63,12 @@ public: @param sy vertical scale factor @return SkMatrix with scale */ - static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar sx, SkScalar sy) { + static SkMatrix SK_WARN_UNUSED_RESULT Scale(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 | @@ -94,23 +79,43 @@ public: @param dy vertical translation @return SkMatrix with translation */ - static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) { + static SkMatrix SK_WARN_UNUSED_RESULT Translate(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 translate by (t.x(), t.y()). Returned matrix is: + /** Sets SkMatrix to rotate by |deg| about a pivot point at (0, 0). - | 1 0 t.x() | - | 0 1 t.y() | - | 0 0 1 | - - @param t translation vector - @return SkMatrix with translation + @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 RotateRad(SkScalar rad) { + return RotateDeg(SkRadiansToDegrees(rad)); + } + +#ifdef SK_SUPPORT_LEGACY_MATRIX_FACTORIES + // DEPRECATED + static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) { + return Translate(dx, dy); + } + static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar sx, SkScalar sy) { + return Scale(sx, sy); + } + static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar scale) { + return Scale(scale, scale); + } static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkVector t) { return MakeTrans(t.x(), t.y()); } static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkIVector t) { return MakeTrans(t.x(), t.y()); } + // end DEPRECATED +#endif /** Sets SkMatrix to: @@ -1677,6 +1682,10 @@ 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). */ @@ -1708,7 +1717,7 @@ public: fMat[kMPersp1] = 0; fMat[kMPersp2] = 1; - unsigned mask = 0; + int mask = 0; if (sx != 1 || sy != 1) { mask |= kScale_Mask; } @@ -1752,12 +1761,12 @@ private: kPerspective_Mask | kRectStaysRect_Mask; - SkScalar fMat[9]; - mutable uint32_t fTypeMask; + SkScalar fMat[9]; + mutable int32_t fTypeMask; constexpr SkMatrix(SkScalar sx, SkScalar kx, SkScalar tx, SkScalar ky, SkScalar sy, SkScalar ty, - SkScalar p0, SkScalar p1, SkScalar p2, uint32_t typeMask) + SkScalar p0, SkScalar p1, SkScalar p2, int typeMask) : fMat{sx, kx, tx, ky, sy, ty, p0, p1, p2} @@ -1773,18 +1782,18 @@ private: SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask || ((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask) == (kUnknown_Mask | kOnlyPerspectiveValid_Mask)); - fTypeMask = SkToU8(mask); + fTypeMask = mask; } void orTypeMask(int mask) { SkASSERT((mask & kORableMasks) == mask); - fTypeMask = SkToU8(fTypeMask | mask); + fTypeMask |= mask; } void clearTypeMask(int mask) { // only allow a valid mask SkASSERT((mask & kAllMasks) == mask); - fTypeMask = fTypeMask & ~mask; + fTypeMask &= ~mask; } TypeMask getPerspectiveTypeMaskOnly() const { @@ -1882,7 +1891,6 @@ private: friend class SkPerspIter; friend class SkMatrixPriv; - friend class SkReader32; friend class SerializationTest; }; SK_END_REQUIRE_DENSE diff --git a/chromium/third_party/skia/include/core/SkMilestone.h b/chromium/third_party/skia/include/core/SkMilestone.h index 5f118966174..1cc0de26203 100644 --- a/chromium/third_party/skia/include/core/SkMilestone.h +++ b/chromium/third_party/skia/include/core/SkMilestone.h @@ -5,5 +5,5 @@ * found in the LICENSE file. */ #ifndef SK_MILESTONE -#define SK_MILESTONE 84 +#define SK_MILESTONE 85 #endif diff --git a/chromium/third_party/skia/include/core/SkPaint.h b/chromium/third_party/skia/include/core/SkPaint.h index 86b511b5c55..96d0b714475 100644 --- a/chromium/third_party/skia/include/core/SkPaint.h +++ b/chromium/third_party/skia/include/core/SkPaint.h @@ -235,6 +235,11 @@ public: */ 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. @@ -316,9 +321,10 @@ public: */ SkScalar getStrokeWidth() const { return fWidth; } - /** Sets the thickness of the pen used by the paint to - outline the shape. - Has no effect if width is less than zero. + /** 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. @param width zero thickness for hairline; greater than zero for pen thickness @@ -589,7 +595,6 @@ public: @param imageFilter how SkImage is sampled when transformed - example: https://fiddle.skia.org/c/@Draw_Looper_Methods example: https://fiddle.skia.org/c/@Paint_setImageFilter */ void setImageFilter(sk_sp<SkImageFilter> imageFilter); diff --git a/chromium/third_party/skia/include/core/SkPath.h b/chromium/third_party/skia/include/core/SkPath.h index 9f6b3e8e491..a2e7c34ed78 100644 --- a/chromium/third_party/skia/include/core/SkPath.h +++ b/chromium/third_party/skia/include/core/SkPath.h @@ -1322,6 +1322,17 @@ public: this->transform(matrix, this, pc); } + SkPath makeTransform(const SkMatrix& m, + SkApplyPerspectiveClip pc = SkApplyPerspectiveClip::kYes) const { + SkPath dst; + this->transform(m, &dst, pc); + return dst; + } + + SkPath makeScale(SkScalar sx, SkScalar sy) { + return this->makeTransform(SkMatrix::Scale(sx, sy), SkApplyPerspectiveClip::kNo); + } + /** Returns last point on SkPath in lastPt. Returns false if SkPoint array is empty, storing (0, 0) if lastPt is not nullptr. @@ -1748,6 +1759,8 @@ public: bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); } private: + SkPath(sk_sp<SkPathRef>, SkPathFillType, bool isVolatile); + sk_sp<SkPathRef> fPathRef; int fLastMoveToIndex; mutable std::atomic<uint8_t> fConvexity; // SkPathConvexityType @@ -1832,6 +1845,7 @@ private: friend class SkAutoPathBoundsUpdate; friend class SkAutoDisableOvalCheck; friend class SkAutoDisableDirectionCheck; + friend class SkPathBuilder; friend class SkPathEdgeIter; friend class SkPathWriter; friend class SkOpBuilder; diff --git a/chromium/third_party/skia/include/core/SkPathBuilder.h b/chromium/third_party/skia/include/core/SkPathBuilder.h new file mode 100644 index 00000000000..3269f49e2fc --- /dev/null +++ b/chromium/third_party/skia/include/core/SkPathBuilder.h @@ -0,0 +1,101 @@ +/* + * 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/SkMatrix.h" +#include "include/core/SkPath.h" +#include "include/core/SkPathTypes.h" +#include "include/private/SkTDArray.h" + +class SkPathBuilder { +public: + SkPathBuilder(); + ~SkPathBuilder(); + + SkPath snapshot(); // the builder is unchanged after returning this path + SkPath detach(); // the builder is reset to empty after returning this path + + void setFillType(SkPathFillType ft) { fFillType = ft; } + void setIsVolatile(bool isVolatile) { fIsVolatile = isVolatile; } + + SkPathBuilder& reset(); + + SkPathBuilder& moveTo(SkPoint pt); + SkPathBuilder& lineTo(SkPoint pt); + SkPathBuilder& quadTo(SkPoint pt1, SkPoint pt2); + SkPathBuilder& conicTo(SkPoint pt1, SkPoint pt2, SkScalar w); + SkPathBuilder& cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3); + SkPathBuilder& close(); + + SkPathBuilder& moveTo(SkScalar x, SkScalar y) { return this->moveTo(SkPoint::Make(x, y)); } + SkPathBuilder& lineTo(SkScalar x, SkScalar y) { return this->lineTo(SkPoint::Make(x, y)); } + 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(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(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& 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) { + return this->addOval(rect, dir, 0); + } + SkPathBuilder& addRRect(const SkRRect& rect, SkPathDirection dir = SkPathDirection::kCW) { + return this->addRRect(rect, dir, 0); + } + + void incReserve(int extraPtCount, int extraVerbCount); + void incReserve(int extraPtCount) { + this->incReserve(extraPtCount, extraPtCount); + } + + static SkPath Make(const SkPoint[], int pointCount, + const uint8_t[], int verbCount, + const SkScalar[], int conicWeightCount, + SkPathFillType, bool isVolatile = false); + +private: + SkTDArray<SkPoint> fPts; + SkTDArray<uint8_t> fVerbs; + SkTDArray<SkScalar> fConicWeights; + + SkPathFillType fFillType; + bool fIsVolatile; + + unsigned fSegmentMask; + SkPoint fLastMovePoint; + bool fNeedsMoveVerb; + + int countVerbs() const { return fVerbs.count(); } + + void ensureMove() { + if (fNeedsMoveVerb) { + this->moveTo(fLastMovePoint); + } + } +}; + +#endif + diff --git a/chromium/third_party/skia/include/core/SkPixmap.h b/chromium/third_party/skia/include/core/SkPixmap.h index d7beb295687..8cacfd07df1 100644 --- a/chromium/third_party/skia/include/core/SkPixmap.h +++ b/chromium/third_party/skia/include/core/SkPixmap.h @@ -369,7 +369,7 @@ public: const uint8_t* addr8(int x, int y) const { SkASSERT((unsigned)x < (unsigned)fInfo.width()); SkASSERT((unsigned)y < (unsigned)fInfo.height()); - return (const uint8_t*)((const char*)this->addr8() + y * fRowBytes + (x << 0)); + return (const uint8_t*)((const char*)this->addr8() + (size_t)y * fRowBytes + (x << 0)); } /** Returns readable pixel address at (x, y). @@ -387,7 +387,7 @@ public: const uint16_t* addr16(int x, int y) const { SkASSERT((unsigned)x < (unsigned)fInfo.width()); SkASSERT((unsigned)y < (unsigned)fInfo.height()); - return (const uint16_t*)((const char*)this->addr16() + y * fRowBytes + (x << 1)); + return (const uint16_t*)((const char*)this->addr16() + (size_t)y * fRowBytes + (x << 1)); } /** Returns readable pixel address at (x, y). @@ -405,7 +405,7 @@ public: const uint32_t* addr32(int x, int y) const { SkASSERT((unsigned)x < (unsigned)fInfo.width()); SkASSERT((unsigned)y < (unsigned)fInfo.height()); - return (const uint32_t*)((const char*)this->addr32() + y * fRowBytes + (x << 2)); + return (const uint32_t*)((const char*)this->addr32() + (size_t)y * fRowBytes + (x << 2)); } /** Returns readable pixel address at (x, y). @@ -423,7 +423,7 @@ public: const uint64_t* addr64(int x, int y) const { SkASSERT((unsigned)x < (unsigned)fInfo.width()); SkASSERT((unsigned)y < (unsigned)fInfo.height()); - return (const uint64_t*)((const char*)this->addr64() + y * fRowBytes + (x << 3)); + return (const uint64_t*)((const char*)this->addr64() + (size_t)y * fRowBytes + (x << 3)); } /** Returns readable pixel address at (x, y). diff --git a/chromium/third_party/skia/include/core/SkString.h b/chromium/third_party/skia/include/core/SkString.h index 0982e003374..6f1d972da28 100644 --- a/chromium/third_party/skia/include/core/SkString.h +++ b/chromium/third_party/skia/include/core/SkString.h @@ -181,8 +181,10 @@ public: char& operator[](size_t n) { return this->writable_str()[n]; } void reset(); - /** Destructive resize, does not preserve contents. */ - void resize(size_t len) { this->set(nullptr, len); } + /** String contents are preserved on resize. (For destructive resize, `set(nullptr, length)`.) + * `resize` automatically reserves an extra byte at the end of the buffer for a null terminator. + */ + void resize(size_t len); void set(const SkString& src) { *this = src; } void set(const char text[]); void set(const char text[], size_t len); @@ -219,6 +221,7 @@ public: void prependScalar(SkScalar value) { this->insertScalar((size_t)-1, value); } void printf(const char format[], ...) SK_PRINTF_LIKE(2, 3); + void printVAList(const char format[], va_list); void appendf(const char format[], ...) SK_PRINTF_LIKE(2, 3); void appendVAList(const char format[], va_list); void prependf(const char format[], ...) SK_PRINTF_LIKE(2, 3); @@ -239,20 +242,18 @@ public: private: struct Rec { public: - constexpr Rec(uint32_t len, int32_t refCnt) - : fLength(len), fRefCnt(refCnt), fBeginningOfData(0) - { } + constexpr Rec(uint32_t len, int32_t refCnt) : fLength(len), fRefCnt(refCnt) {} static sk_sp<Rec> Make(const char text[], size_t len); - uint32_t fLength; // logically size_t, but we want it to stay 32bits - mutable std::atomic<int32_t> fRefCnt; - char fBeginningOfData; - char* data() { return &fBeginningOfData; } const char* data() const { return &fBeginningOfData; } - void ref() const; void unref() const; bool unique() const; + + uint32_t fLength; // logically size_t, but we want it to stay 32 bits + mutable std::atomic<int32_t> fRefCnt; + char fBeginningOfData = '\0'; + private: // Ensure the unsized delete is called. void operator delete(void* p) { ::operator delete(p); } diff --git a/chromium/third_party/skia/include/core/SkSurface.h b/chromium/third_party/skia/include/core/SkSurface.h index 62698bb8155..bf151c05dea 100644 --- a/chromium/third_party/skia/include/core/SkSurface.h +++ b/chromium/third_party/skia/include/core/SkSurface.h @@ -28,6 +28,7 @@ class SkPaint; class SkSurfaceCharacterization; class GrBackendRenderTarget; class GrBackendSemaphore; +class GrBackendSurfaceMutableState; class GrBackendTexture; class GrContext; class GrRecordingContext; @@ -183,6 +184,10 @@ public: not exceed context capabilities, and the context must be able to support back-end textures. + Upon success textureReleaseProc is called when it is safe to delete the texture in the + backend API (accounting only for use of the texture by this surface). If SkSurface creation + fails textureReleaseProc is called before this function returns. + If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. @param context GPU context @@ -214,6 +219,10 @@ public: not exceed context capabilities, and the context must be able to support back-end render targets. + Upon success releaseProc is called when it is safe to delete the render target in the + backend API (accounting only for use of the render target by this surface). If SkSurface + creation fails releaseProc is called before this function returns. + If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. @param context GPU context @@ -221,8 +230,8 @@ public: @param colorSpace range of colors @param surfaceProps LCD striping orientation and setting for device independent fonts; may be nullptr - @param releaseProc function called when texture can be released - @param releaseContext state passed to textureReleaseProc + @param releaseProc function called when backendRenderTarget can be released + @param releaseContext state passed to releaseProc @return SkSurface if all parameters are valid; otherwise, nullptr */ static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context, @@ -234,29 +243,8 @@ public: RenderTargetReleaseProc releaseProc = nullptr, ReleaseContext releaseContext = nullptr); - /** Wraps a GPU-backed texture into SkSurface. Caller must ensure backendTexture is - valid for the lifetime of returned SkSurface. If sampleCnt greater than zero, - creates an intermediate MSAA SkSurface which is used for drawing backendTexture. - - SkSurface is returned if all parameters are valid. backendTexture is valid if - its pixel configuration agrees with colorSpace and context; for instance, if - backendTexture has an sRGB configuration, then context must support sRGB, - and colorSpace must be present. Further, backendTexture width and height must - not exceed context capabilities. - - Returned SkSurface is available only for drawing into, and cannot generate an - SkImage. - - If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. - - @param context GPU context - @param backendTexture texture residing on GPU - @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing - @param colorSpace range of colors; may be nullptr - @param surfaceProps LCD striping orientation and setting for device independent - fonts; may be nullptr - @return SkSurface if all parameters are valid; otherwise, nullptr - */ +#if GR_TEST_UTILS + // TODO: Remove this. static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context, const GrBackendTexture& backendTexture, GrSurfaceOrigin origin, @@ -264,6 +252,7 @@ public: SkColorType colorType, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps); +#endif #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26 /** Private. @@ -454,6 +443,10 @@ public: SkSurfaceCharacterization::isCompatible can be used to determine if a given backend texture is compatible with a specific surface characterization. + Upon success textureReleaseProc is called when it is safe to delete the texture in the + backend API (accounting only for use of the texture by this surface). If SkSurface creation + fails textureReleaseProc is called before this function returns. + @param context GPU context @param characterization characterization of the desired surface @param backendTexture texture residing on GPU @@ -586,6 +579,10 @@ public: used. The GrBackendFormat and dimensions of replacement texture must match that of the original. + Upon success textureReleaseProc is called when it is safe to delete the texture in the + backend API (accounting only for use of the texture by this surface). If SkSurface creation + fails textureReleaseProc is called before this function returns. + @param backendTexture the new backing texture for the surface @param mode Retain or discard current Content @param textureReleaseProc function called when texture can be released @@ -652,8 +649,7 @@ public: /** Draws SkSurface contents to canvas, with its top-left corner at (x, y). - If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter, - SkBlendMode, and SkDrawLooper. + If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter, and SkBlendMode. @param canvas SkCanvas drawn into @param x horizontal offset in SkCanvas @@ -818,7 +814,8 @@ public: When the pixel data is ready the caller's ReadPixelsCallback is called with a AsyncReadResult containing pixel data in the requested color type, alpha type, and color space. The AsyncReadResult will have count() == 1. Upon failure the callback is called - with nullptr for AsyncReadResult. + with nullptr for AsyncReadResult. For a GPU surface this flushes work but a submit must + occur to guarantee a finite time before the callback is called. The data is valid for the lifetime of AsyncReadResult with the exception that if the SkSurface is GPU-backed the data is immediately invalidated if the GrContext is abandoned @@ -846,7 +843,9 @@ public: When the pixel data is ready the caller's ReadPixelsCallback is called with a AsyncReadResult containing the planar data. The AsyncReadResult will have count() == 3. - Upon failure the callback is called with nullptr for AsyncReadResult. + Upon failure the callback is called with nullptr for AsyncReadResult. For a GPU surface this + flushes work but a submit must occur to guarantee a finite time before the callback is + called. The data is valid for the lifetime of AsyncReadResult with the exception that if the SkSurface is GPU-backed the data is immediately invalidated if the GrContext is abandoned @@ -916,21 +915,26 @@ public: Skia will correctly order its own draws and pixel operations. This must to be used to ensure correct ordering when the surface backing store is accessed outside Skia (e.g. direct use of the 3D API or a windowing system). GrContext has additional flush and submit methods that - apply to all surfaces and images created from a GrContext. + apply to all surfaces and images created from a GrContext. This is equivalent to calling + SkSurface::flush with a default GrFlushInfo followed by GrContext::submit. */ void flushAndSubmit(); - /** - * Deprecated. - */ - void flush() { this->flushAndSubmit(); } - enum class BackendSurfaceAccess { kNoAccess, //!< back-end object will not be used by client kPresent, //!< back-end surface will be used for presenting to screen }; - /** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA. + /** Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface + MSAA. A call to GrContext::submit is always required to ensure work is actually sent to the + gpu. Some specific API details: + GL: Commands are actually sent to the driver, but glFlush is never called. Thus some + sync objects from the flush will not be valid until a submission occurs. + + Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command + buffer or encoder objects. However, these objects are not sent to the gpu until a + submission occurs. + The work that is submitted to the GPU will be dependent on the BackendSurfaceAccess that is passed in. @@ -946,13 +950,19 @@ public: The GrFlushInfo describes additional options to flush. Please see documentation at GrFlushInfo for more info. - If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will - have been submitted and can be waited on (it is possible Skia failed to create a subset of - the semaphores). If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not - have submitted any semaphores to be signaled on the GPU. Thus the client should not have - the GPU wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether - semaphores were submitted to the GPU or not, the client is still responsible for deleting - any initialized semaphores. + If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be + submitted to the gpu during the next submit call (it is possible Skia failed to create a + subset of the semaphores). The client should not wait on these semaphores until after submit + has been called, but must keep them alive until then. If a submit flag was passed in with + the flush these valid semaphores can we waited on immediately. If this call returns + GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on + the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in + with the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the + client is still responsible for deleting any initialized semaphores. + Regardleess of semaphore submission the context will still be flushed. It should be + emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not + happen. It simply means there were no semaphores submitted to the GPU. A caller should only + take this as a failure if they passed in semaphores to be submitted. Pending surface commands are flushed regardless of the return result. @@ -961,27 +971,48 @@ public: */ GrSemaphoresSubmitted flush(BackendSurfaceAccess access, const GrFlushInfo& info); - /** Deprecated - */ - GrSemaphoresSubmitted flush(BackendSurfaceAccess access, GrFlushFlags flags, - int numSemaphores, GrBackendSemaphore signalSemaphores[], - GrGpuFinishedProc finishedProc = nullptr, - GrGpuFinishedContext finishedContext = nullptr); + /** Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface + MSAA. A call to GrContext::submit is always required to ensure work is actually sent to the + gpu. Some specific API details: + GL: Commands are actually sent to the driver, but glFlush is never called. Thus some + sync objects from the flush will not be valid until a submission occurs. - /** The below enum and flush call are deprecated - */ - enum FlushFlags { - kNone_FlushFlags = 0, - // flush will wait till all submitted GPU work is finished before returning. - kSyncCpu_FlushFlag = 0x1, - }; - GrSemaphoresSubmitted flush(BackendSurfaceAccess access, FlushFlags flags, - int numSemaphores, GrBackendSemaphore signalSemaphores[]); + Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command + buffer or encoder objects. However, these objects are not sent to the gpu until a + submission occurs. - /** Deprecated. + The GrFlushInfo describes additional options to flush. Please see documentation at + GrFlushInfo for more info. + + If a GrBackendSurfaceMutableState is passed in, at the end of the flush we will transition + the surface to be in the state requested by the GrBackendSurfaceMutableState. If the surface + (or SkImage or GrBackendSurface wrapping the same backend object) is used again after this + flush the state may be changed and no longer match what is requested here. This is often + used if the surface will be used for presenting or external use and the client wants backend + object to be prepped for that use. A finishedProc or semaphore on the GrFlushInfo will also + include the work for any requested state change. + + If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be + submitted to the gpu during the next submit call (it is possible Skia failed to create a + subset of the semaphores). The client should not wait on these semaphores until after submit + has been called, but must keep them alive until then. If a submit flag was passed in with + the flush these valid semaphores can we waited on immediately. If this call returns + GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on + the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in + with the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the + client is still responsible for deleting any initialized semaphores. + Regardleess of semaphore submission the context will still be flushed. It should be + emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not + happen. It simply means there were no semaphores submitted to the GPU. A caller should only + take this as a failure if they passed in semaphores to be submitted. + + Pending surface commands are flushed regardless of the return result. + + @param info flush options + @param access optional state change request after flush */ - GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores, - GrBackendSemaphore signalSemaphores[]); + GrSemaphoresSubmitted flush(const GrFlushInfo& info, + const GrBackendSurfaceMutableState* newState = nullptr); /** Inserts a list of GPU semaphores that the current GPU-backed API must wait on before executing any more commands on the GPU for this surface. Skia will take ownership of the diff --git a/chromium/third_party/skia/include/core/SkTypes.h b/chromium/third_party/skia/include/core/SkTypes.h index 860105d5377..93eeb548ff1 100644 --- a/chromium/third_party/skia/include/core/SkTypes.h +++ b/chromium/third_party/skia/include/core/SkTypes.h @@ -263,12 +263,6 @@ # undef SK_DIRECT3D #endif -#if !defined(SK_SUPPORT_ATLAS_TEXT) -# define SK_SUPPORT_ATLAS_TEXT 0 -#elif SK_SUPPORT_ATLAS_TEXT && !SK_SUPPORT_GPU -# error "SK_SUPPORT_ATLAS_TEXT requires SK_SUPPORT_GPU" -#endif - #if !defined(SkUNREACHABLE) # if defined(_MSC_VER) && !defined(__clang__) # define SkUNREACHABLE __assume(false) @@ -285,22 +279,20 @@ # define SK_DUMP_GOOGLE3_STACK() #endif -#ifdef SK_BUILD_FOR_WIN - // Lets visual studio follow error back to source - #define SK_DUMP_LINE_FORMAT(message) \ - SkDebugf("%s(%d): fatal error: \"%s\"\n", __FILE__, __LINE__, message) -#else - #define SK_DUMP_LINE_FORMAT(message) \ - SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, message) -#endif - #ifndef SK_ABORT -# define SK_ABORT(message) \ +# ifdef SK_BUILD_FOR_WIN + // This style lets Visual Studio follow errors back to the source file. +# define SK_DUMP_LINE_FORMAT "%s(%d)" +# else +# define SK_DUMP_LINE_FORMAT "%s:%d" +# endif +# define SK_ABORT(message, ...) \ do { \ - SK_DUMP_LINE_FORMAT(message); \ - SK_DUMP_GOOGLE3_STACK(); \ - sk_abort_no_print(); \ - SkUNREACHABLE; \ + SkDebugf(SK_DUMP_LINE_FORMAT ": fatal error: \"" message "\"\n", \ + __FILE__, __LINE__, ##__VA_ARGS__); \ + SK_DUMP_GOOGLE3_STACK(); \ + sk_abort_no_print(); \ + SkUNREACHABLE; \ } while (false) #endif @@ -325,12 +317,7 @@ /** - * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. The - * relationship between the byte order and shift values depends on machine endianness. If the shift - * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R channel on a little - * endian machine and the A channel on a big endian machine. Thus, given those shifts values, - * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and - * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine. + * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. */ #ifdef SK_CPU_BENDIAN # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ @@ -461,16 +448,16 @@ SK_API extern void sk_abort_no_print(void); // x - 4; // } #define SkASSERT_RELEASE(cond) \ - static_cast<void>( (cond) ? (void)0 : []{ SK_ABORT("assert(" #cond ")"); }() ) + static_cast<void>( (cond) ? (void)0 : []{ SK_ABORT("assert(%s)", #cond); }() ) #ifdef SK_DEBUG #define SkASSERT(cond) SkASSERT_RELEASE(cond) #define SkASSERTF(cond, fmt, ...) static_cast<void>( (cond) ? (void)0 : [&]{ \ SkDebugf(fmt"\n", __VA_ARGS__); \ - SK_ABORT("assert(" #cond ")"); \ + SK_ABORT("assert(%s)", #cond); \ }() ) - #define SkDEBUGFAIL(message) SK_ABORT(message) - #define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__) + #define SkDEBUGFAIL(message) SK_ABORT("%s", message) + #define SkDEBUGFAILF(fmt, ...) SK_ABORT(fmt, ##__VA_ARGS__) #define SkDEBUGCODE(...) __VA_ARGS__ #define SkDEBUGF(...) SkDebugf(__VA_ARGS__) #define SkAssertResult(cond) SkASSERT(cond) @@ -547,7 +534,7 @@ template <typename T> static constexpr bool SkIsAlignPtr(T x) { typedef uint32_t SkFourByteTag; static inline constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d) { - return (((uint8_t)a << 24) | ((uint8_t)b << 16) | ((uint8_t)c << 8) | (uint8_t)d); + return (((uint32_t)a << 24) | ((uint32_t)b << 16) | ((uint32_t)c << 8) | (uint32_t)d); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chromium/third_party/skia/include/core/SkVertices.h b/chromium/third_party/skia/include/core/SkVertices.h index 0f666f83c87..ec76488b155 100644 --- a/chromium/third_party/skia/include/core/SkVertices.h +++ b/chromium/third_party/skia/include/core/SkVertices.h @@ -64,6 +64,9 @@ public: * the vertex shader. For positions or vectors, markerName identifies what matrix is used in * the vertex shader to transform the data. Those names should match a named transform on the * CTM stack, created by calling SkCanvas::markCTM(). + * + * For attributes with a usage of kVector, kNormalVector, or kPosition, a null markerName + * will transform the attribute by the canvas CTM matrix. */ struct Attribute { enum class Type : uint8_t { diff --git a/chromium/third_party/skia/include/docs/SkPDFDocument.h b/chromium/third_party/skia/include/docs/SkPDFDocument.h index db525b99b7b..28b07f5b467 100644 --- a/chromium/third_party/skia/include/docs/SkPDFDocument.h +++ b/chromium/third_party/skia/include/docs/SkPDFDocument.h @@ -88,13 +88,18 @@ public: // and then a value of the proper type according to the spec. void appendInt(const char* owner, const char* name, int value); void appendFloat(const char* owner, const char* name, float value); - void appendString(const char* owner, const char* name, const char* value); + void appendName(const char* owner, const char* attrName, const char* value); + void appendString(const char* owner, const char* attrName, const char* value); void appendFloatArray(const char* owner, const char* name, const std::vector<float>& value); + // Deprecated. void appendStringArray(const char* owner, - const char* name, - const std::vector<SkString>& value); + const char* attrName, + const std::vector<SkString>& values); + void appendNodeIdArray(const char* owner, + const char* attrName, + const std::vector<int>& nodeIds); private: friend class ::SkPDFTagTree; @@ -116,10 +121,6 @@ struct StructureElementNode { SkString fAlt; SkString fLang; - // Deprecated. Use fChildVector instead. - StructureElementNode* fChildren = nullptr; - size_t fChildCount = 0; - // Deprecated. Use fTypeString instead. DocumentStructureType fType = DocumentStructureType::kNonStruct; }; diff --git a/chromium/third_party/skia/include/effects/SkBlurDrawLooper.h b/chromium/third_party/skia/include/effects/SkBlurDrawLooper.h index 4a1ae83142a..77d9ae50c92 100644 --- a/chromium/third_party/skia/include/effects/SkBlurDrawLooper.h +++ b/chromium/third_party/skia/include/effects/SkBlurDrawLooper.h @@ -5,15 +5,13 @@ * found in the LICENSE file. */ - #ifndef SkBlurDrawLooper_DEFINED #define SkBlurDrawLooper_DEFINED #include "include/core/SkDrawLooper.h" /** - * Draws a shadow of the object (possibly offset), and then draws the original object in - * its original position. + * DEPRECATED: No longer supported in Skia. */ namespace SkBlurDrawLooper { sk_sp<SkDrawLooper> SK_API Make(SkColor4f color, SkColorSpace* cs, diff --git a/chromium/third_party/skia/include/effects/SkLayerDrawLooper.h b/chromium/third_party/skia/include/effects/SkLayerDrawLooper.h index 8d10e8c2d63..f11727e5e32 100644 --- a/chromium/third_party/skia/include/effects/SkLayerDrawLooper.h +++ b/chromium/third_party/skia/include/effects/SkLayerDrawLooper.h @@ -13,6 +13,9 @@ #include "include/core/SkPaint.h" #include "include/core/SkPoint.h" +/** + * DEPRECATED: No longer supported by Skia. + */ class SK_API SkLayerDrawLooper : public SkDrawLooper { public: ~SkLayerDrawLooper() override; diff --git a/chromium/third_party/skia/include/effects/SkLumaColorFilter.h b/chromium/third_party/skia/include/effects/SkLumaColorFilter.h index 038461d3d2c..0d6eacb0ae2 100644 --- a/chromium/third_party/skia/include/effects/SkLumaColorFilter.h +++ b/chromium/third_party/skia/include/effects/SkLumaColorFilter.h @@ -30,30 +30,14 @@ class SkRasterPipeline; * not luminance, a dot-product of linear color channels. So at least * SkLumaColorFilter and feColorMatrix+luminanceToAlpha agree there.) */ - - #include "include/core/SkFlattenable.h" - -class SK_API SkLumaColorFilter : public SkColorFilter { +class SK_API SkLumaColorFilter { public: static sk_sp<SkColorFilter> Make(); -#if SK_SUPPORT_GPU - std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*, - const GrColorInfo&) const override; -#endif - -protected: - void flatten(SkWriteBuffer&) const override; - private: - SK_FLATTENABLE_HOOKS(SkLumaColorFilter) - - SkLumaColorFilter(); - bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override; - skvm::Color onProgram(skvm::Builder*, skvm::Color, - SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const override; + friend class SkFlattenable; - typedef SkColorFilter INHERITED; + static void RegisterFlattenable(); }; #endif diff --git a/chromium/third_party/skia/include/effects/SkRuntimeEffect.h b/chromium/third_party/skia/include/effects/SkRuntimeEffect.h index 3d812523d55..d570de6a013 100644 --- a/chromium/third_party/skia/include/effects/SkRuntimeEffect.h +++ b/chromium/third_party/skia/include/effects/SkRuntimeEffect.h @@ -95,9 +95,6 @@ public: const SkMatrix* localMatrix, bool isOpaque); - sk_sp<SkColorFilter> makeColorFilter(sk_sp<SkData> inputs, - sk_sp<SkColorFilter> children[], - size_t childCount); sk_sp<SkColorFilter> makeColorFilter(sk_sp<SkData> inputs); const SkString& source() const { return fSkSL; } diff --git a/chromium/third_party/skia/include/effects/SkStrokeAndFillPathEffect.h b/chromium/third_party/skia/include/effects/SkStrokeAndFillPathEffect.h new file mode 100644 index 00000000000..fbde6493340 --- /dev/null +++ b/chromium/third_party/skia/include/effects/SkStrokeAndFillPathEffect.h @@ -0,0 +1,28 @@ +/* + * 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 SkStrokeAndFillPathEffect_DEFINED +#define SkStrokeAndFillPathEffect_DEFINED + +#include "include/core/SkPaint.h" +#include "include/core/SkPathEffect.h" +#include "include/pathops/SkPathOps.h" + +class SK_API SkStrokeAndFillPathEffect { +public: + /* If the paint is set to stroke, this will add the stroke and fill geometries + * together (hoping that the winding-direction works out). + * + * If the paint is set to fill, this effect is ignored. + * + * Note that if the paint is set to stroke and the stroke-width is 0, then + * this will turn the geometry into just a fill. + */ + static sk_sp<SkPathEffect> Make(); +}; + +#endif diff --git a/chromium/third_party/skia/include/gpu/GrBackendSurface.h b/chromium/third_party/skia/include/gpu/GrBackendSurface.h index 373d23f92cc..6e52b118db2 100644 --- a/chromium/third_party/skia/include/gpu/GrBackendSurface.h +++ b/chromium/third_party/skia/include/gpu/GrBackendSurface.h @@ -8,6 +8,7 @@ #ifndef GrBackendSurface_DEFINED #define GrBackendSurface_DEFINED +#include "include/gpu/GrBackendSurfaceMutableState.h" #include "include/gpu/GrTypes.h" #include "include/gpu/gl/GrGLTypes.h" #include "include/gpu/mock/GrMockTypes.h" @@ -19,6 +20,7 @@ #include "include/gpu/dawn/GrDawnTypes.h" #endif +class GrBackendSurfaceMutableStateImpl; class GrVkImageLayout; class GrGLTextureParameters; @@ -224,7 +226,7 @@ private: class SK_API GrBackendTexture { public: // Creates an invalid backend texture. - GrBackendTexture() : fIsValid(false) {} + GrBackendTexture(); // The GrGLTextureInfo must have a valid fFormat. GrBackendTexture(int width, @@ -232,9 +234,11 @@ public: GrMipMapped, const GrGLTextureInfo& glInfo); +#ifdef SK_VULKAN GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo); +#endif #ifdef SK_METAL GrBackendTexture(int width, @@ -319,6 +323,13 @@ public: // in pointer and returns true. Otherwise returns false if the backend API is not Mock. bool getMockTextureInfo(GrMockTextureInfo*) const; + // If the client changes any of the mutable backend of the GrBackendTexture they should call + // this function to inform Skia that those values have changed. The backend API specific state + // that can be set from this function are: + // + // Vulkan: VkImageLayout and QueueFamilyIndex + void setMutableState(const GrBackendSurfaceMutableState&); + // Returns true if we are working with protected content. bool isProtected() const; @@ -333,6 +344,8 @@ public: #endif private: + friend class GrVkGpu; // for getMutableState + sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState() const; #ifdef SK_GL friend class GrGLTexture; @@ -347,12 +360,10 @@ private: #ifdef SK_VULKAN friend class GrVkTexture; - friend class GrVkGpu; // for getGrVkImageLayout GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo, - sk_sp<GrVkImageLayout> layout); - sk_sp<GrVkImageLayout> getGrVkImageLayout() const; + sk_sp<GrBackendSurfaceMutableStateImpl> mutableState); #endif #ifdef SK_DIRECT3D @@ -390,12 +401,14 @@ private: #ifdef SK_DAWN GrDawnTextureInfo fDawnInfo; #endif + + sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState; }; class SK_API GrBackendRenderTarget { public: // Creates an invalid backend texture. - GrBackendRenderTarget() : fIsValid(false) {} + GrBackendRenderTarget(); // The GrGLTextureInfo must have a valid fFormat. GrBackendRenderTarget(int width, @@ -412,6 +425,7 @@ public: const GrDawnRenderTargetInfo& dawnInfo); #endif +#ifdef SK_VULKAN /** Deprecated, use version that does not take stencil bits. */ GrBackendRenderTarget(int width, int height, @@ -419,6 +433,7 @@ public: int stencilBits, const GrVkImageInfo& vkInfo); GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo); +#endif #ifdef SK_METAL GrBackendRenderTarget(int width, @@ -495,6 +510,13 @@ public: // in pointer and returns true. Otherwise returns false if the backend API is not Mock. bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const; + // If the client changes any of the mutable backend of the GrBackendTexture they should call + // this function to inform Skia that those values have changed. The backend API specific state + // that can be set from this function are: + // + // Vulkan: VkImageLayout and QueueFamilyIndex + void setMutableState(const GrBackendSurfaceMutableState&); + // Returns true if we are working with protected content. bool isProtected() const; @@ -507,12 +529,15 @@ public: #endif private: - friend class GrVkGpu; // for getGrVkImageLayout - sk_sp<GrVkImageLayout> getGrVkImageLayout() const; + friend class GrVkGpu; // for getMutableState + sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState() const; +#ifdef SK_VULKAN friend class GrVkRenderTarget; GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo, - sk_sp<GrVkImageLayout> layout); + sk_sp<GrBackendSurfaceMutableStateImpl> mutableState); +#endif + #ifdef SK_DIRECT3D friend class GrD3DGpu; friend class GrD3DRenderTarget; @@ -550,6 +575,7 @@ private: #ifdef SK_DAWN GrDawnRenderTargetInfo fDawnInfo; #endif + sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState; }; #endif diff --git a/chromium/third_party/skia/include/gpu/GrBackendSurfaceMutableState.h b/chromium/third_party/skia/include/gpu/GrBackendSurfaceMutableState.h new file mode 100644 index 00000000000..6425cb52260 --- /dev/null +++ b/chromium/third_party/skia/include/gpu/GrBackendSurfaceMutableState.h @@ -0,0 +1,66 @@ +/* + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrBackendSurfaceMutableState_DEFINED +#define GrBackendSurfaceMutableState_DEFINED + +#include "include/gpu/GrTypes.h" + +#ifdef SK_VULKAN +#include "include/private/GrVkTypesPriv.h" +#endif + +/** + * Since Skia and clients can both modify gpu textures and their connected state, Skia needs a way + * for clients to inform us if they have modifiend any of this state. In order to not need setters + * for every single API and state, we use this class to be a generic wrapper around all the mutable + * state. This class is used for calls that inform Skia of these texture/image state changes by the + * client as well as for requesting state changes to be done by Skia. The backend specific state + * that is wrapped by this class are: + * + * Vulkan: VkImageLayout and QueueFamilyIndex + */ +class GrBackendSurfaceMutableState { +public: +#ifdef SK_VULKAN + GrBackendSurfaceMutableState(VkImageLayout layout, uint32_t queueFamilyIndex) + : fVkState(layout, queueFamilyIndex) + , fBackend(GrBackend::kVulkan) {} +#endif + + GrBackendSurfaceMutableState& operator=(const GrBackendSurfaceMutableState& that) { + switch (fBackend) { + case GrBackend::kVulkan: +#ifdef SK_VULKAN + SkASSERT(that.fBackend == GrBackend::kVulkan); + fVkState = that.fVkState; +#endif + break; + + default: + (void)that; + SkUNREACHABLE; + } + fBackend = that.fBackend; + return *this; + } + +private: + friend class GrBackendSurfaceMutableStateImpl; + friend class GrVkGpu; + + union { + char fDummy; +#ifdef SK_VULKAN + GrVkSharedImageInfo fVkState; +#endif + }; + + GrBackend fBackend; +}; + +#endif diff --git a/chromium/third_party/skia/include/gpu/GrContext.h b/chromium/third_party/skia/include/gpu/GrContext.h index 9dcba2ca2f4..64137383687 100644 --- a/chromium/third_party/skia/include/gpu/GrContext.h +++ b/chromium/third_party/skia/include/gpu/GrContext.h @@ -36,7 +36,6 @@ class GrResourceProvider; class GrStrikeCache; class GrSurfaceProxy; class GrSwizzle; -class GrTextContext; class GrTextureProxy; struct GrVkBackendContext; @@ -62,7 +61,10 @@ public: /** * The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned - * GrContext is first destroyed or abandoned. + * GrContext is destroyed. This also means that any objects created with this GrContext (e.g. + * SkSurfaces, SkImages, etc.) must also be released as they may hold refs on the GrContext. + * Once all these objects and the GrContext are released, then it is safe to delete the vulkan + * objects. */ static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&, const GrContextOptions&); static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&); @@ -98,6 +100,7 @@ public: ~GrContext() override; + // TODO: Remove this from public after migrating Chrome. sk_sp<GrContextThreadSafeProxy> threadSafeProxy(); /** @@ -133,7 +136,10 @@ public: * API calls may crash. * * For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to - * create the GrContext must be alive before calling abandonContext. + * create the GrContext must be kept alive even after abandoning the context. Those objects must + * live for the lifetime of the GrContext object itself. The reason for this is so that + * we can continue to delete any outstanding GrBackendTextures/RenderTargets which must be + * cleaned up even in a device lost state. */ void abandonContext() override; @@ -146,6 +152,23 @@ public: bool abandoned() override; /** + * Checks if the underlying 3D API reported an out-of-memory error. If this returns true it is + * reset and will return false until another out-of-memory error is reported by the 3D API. If + * the context is abandoned then this will report false. + * + * Currently this is implemented for: + * + * OpenGL [ES] - Note that client calls to glGetError() may swallow GL_OUT_OF_MEMORY errors and + * therefore hide the error from Skia. Also, it is not advised to use this in combination with + * enabling GrContextOptions::fSkipGLErrorChecks. That option may prevent GrContext from ever + * checking the GL context for OOM. + * + * Vulkan - Reports true if VK_ERROR_OUT_OF_HOST_MEMORY or VK_ERROR_OUT_OF_DEVICE_MEMORY has + * occurred. + */ + bool oomed(); + + /** * This is similar to abandonContext() however the underlying 3D context is not yet lost and * the GrContext will cleanup all allocated resources before returning. After returning it will * assume that the underlying context may no longer be valid. @@ -296,7 +319,6 @@ public: /////////////////////////////////////////////////////////////////////////// // Misc. - /** * Inserts a list of GPU semaphores that the current GPU-backed API must wait on before * executing any more commands on the GPU. Skia will take ownership of the underlying semaphores @@ -307,82 +329,56 @@ public: bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores); /** - * Call to ensure all drawing to the context has been issued to the underlying 3D API. - */ - void flushAndSubmit() { this->flush(GrFlushInfo(), GrPrepareForExternalIORequests()); } - - /** - * Deprecated. + * Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D + * API. This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by + * GrContext::submit. */ - void flush() { this->flushAndSubmit(); } + void flushAndSubmit() { + this->flush(GrFlushInfo()); + this->submit(); + } /** - * Call to ensure all drawing to the context has been issued to the underlying 3D API. + * Call to ensure all drawing to the context has been flushed to underlying 3D API specific + * objects. A call to GrContext::submit is always required to ensure work is actually sent to + * the gpu. Some specific API details: + * GL: Commands are actually sent to the driver, but glFlush is never called. Thus some + * sync objects from the flush will not be valid until a submission occurs. + * + * Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command + * buffer or encoder objects. However, these objects are not sent to the gpu until a + * submission occurs. * - * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will have - * been submitted and can be waited on (it is possible Skia failed to create a subset of the - * semaphores). If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have - * submitted any semaphores to be signaled on the GPU. Thus the client should not have the GPU - * wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether - * semaphores were submitted to the GPU or not, the client is still responsible for deleting any - * initialized semaphores. + * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be + * submitted to the gpu during the next submit call (it is possible Skia failed to create a + * subset of the semaphores). The client should not wait on these semaphores until after submit + * has been called, and must keep them alive until then. If this call returns + * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on + * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with + * the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the + * client is still responsible for deleting any initialized semaphores. * Regardleess of semaphore submission the context will still be flushed. It should be * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not * happen. It simply means there were no semaphores submitted to the GPU. A caller should only * take this as a failure if they passed in semaphores to be submitted. */ - GrSemaphoresSubmitted flush(const GrFlushInfo& info) { - return this->flush(info, GrPrepareForExternalIORequests()); - } + GrSemaphoresSubmitted flush(const GrFlushInfo& info); /** - * Call to ensure all drawing to the context has been issued to the underlying 3D API. + * Submit outstanding work to the gpu from all previously un-submitted flushes. The return + * value of the submit will indicate whether or not the submission to the GPU was successful. * - * If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have created or - * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on - * any of the semaphores passed in with the GrFlushInfo. However, any pending commands to the - * context will still be flushed. It should be emphasized that a return value of - * GrSemaphoresSubmitted::kNo does not mean the flush did not happen. It simply means there were - * no semaphores submitted to the GPU. A caller should only take this as a failure if they - * passed in semaphores to be submitted. + * If the call returns true, all previously passed in semaphores in flush calls will have been + * submitted to the GPU and they can safely be waited on. The caller should wait on those + * semaphores or perform some other global synchronization before deleting the semaphores. * - * If the GrPrepareForExternalIORequests contains valid gpu backed SkSurfaces or SkImages, Skia - * will put the underlying backend objects into a state that is ready for external uses. See - * declaration of GrPreopareForExternalIORequests for more details. - */ - GrSemaphoresSubmitted flush(const GrFlushInfo&, const GrPrepareForExternalIORequests&); - - /** - * Deprecated. - */ - GrSemaphoresSubmitted flush(GrFlushFlags flags, int numSemaphores, - GrBackendSemaphore signalSemaphores[], - GrGpuFinishedProc finishedProc = nullptr, - GrGpuFinishedContext finishedContext = nullptr) { - GrFlushInfo info; - info.fFlags = flags; - info.fNumSemaphores = numSemaphores; - info.fSignalSemaphores = signalSemaphores; - info.fFinishedProc = finishedProc; - info.fFinishedContext = finishedContext; - return this->flush(info); - } - - /** - * Deprecated. - */ - GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores, - GrBackendSemaphore signalSemaphores[]) { - GrFlushInfo info; - info.fNumSemaphores = numSemaphores; - info.fSignalSemaphores = signalSemaphores; - return this->flush(info); - } - - /** - * Placeholder no-op submit call. + * If it returns false, then those same semaphores will not have been submitted and we will not + * try to submit them again. The caller is free to delete the semaphores at any time. + * + * If the syncCpu flag is true this function will return once the gpu has finished with all + * submitted work. */ - bool submit(bool syncToCpu = false); + bool submit(bool syncCpu = false); /** * Checks whether any asynchronous work is complete and if so calls related callbacks. @@ -472,8 +468,8 @@ public: * If possible, create a backend texture initialized to a particular color. The client should * ensure that the returned backend texture is valid. The client can pass in a finishedProc * to be notified when the data has been uploaded by the gpu and the texture can be deleted. The - * client can assume the upload work has been submitted to the gpu. The finishedProc will always - * get called even if we failed to create the GrBackendTexture. + * client is required to call GrContext::submit to send the upload work to the gpu. The + * finishedProc will always get called even if we failed to create the GrBackendTexture. * For the Vulkan backend the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */ @@ -490,8 +486,8 @@ public: * If possible, create a backend texture initialized to a particular color. The client should * ensure that the returned backend texture is valid. The client can pass in a finishedProc * to be notified when the data has been uploaded by the gpu and the texture can be deleted. The - * client can assume the upload work has been submitted to the gpu. The finishedProc will always - * get called even if we failed to create the GrBackendTexture. + * client is required to call GrContext::submit to send the upload work to the gpu. The + * finishedProc will always get called even if we failed to create the GrBackendTexture. * If successful, the created backend texture will be compatible with the provided * SkColorType. * For the Vulkan backend the layout of the created VkImage will be: @@ -510,9 +506,9 @@ public: * If possible, create a backend texture initialized to a particular color that is * compatible with the provided characterization. The client should ensure that the * returned backend texture is valid. The client can pass in a finishedProc to be notified when - * the data has been uploaded by the gpu and the texture can be deleted. The client can assume - * the upload work has been submitted to the gpu. The finishedProc will always get called even - * if we failed to create the GrBackendTexture. + * the data has been uploaded by the gpu and the texture can be deleted. The client is required + * to call GrContext::submit to send the upload work to the gpu. The finishedProc will always + * get called even if we failed to create the GrBackendTexture. * For the Vulkan backend the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if texturaeble * VK_IMAGE_LAYOUT_UNDEFINED if not textureable @@ -526,11 +522,12 @@ public: * If possible, create a backend texture initialized with the provided pixmap data. The client * should ensure that the returned backend texture is valid. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture. * If successful, the created backend texture will be compatible with the provided * pixmap(s). Compatible, in this case, means that the backend format will be the result - * of calling defaultBackendFormat on the base pixmap's colortype. + * of calling defaultBackendFormat on the base pixmap's colortype. The src data can be deleted + * when this call returns. * If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired * the data for all the mipmap levels must be provided. In the mipmapped case all the * colortypes of the provided pixmaps must be the same. Additionally, all the miplevels @@ -558,8 +555,8 @@ public: * If possible, updates a backend texture to be filled to a particular color. The client should * check the return value to see if the update was successful. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to update the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to update the GrBackendTexture. * For the Vulkan backend after a successful update the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */ @@ -572,10 +569,11 @@ public: * If possible, updates a backend texture filled with the provided pixmap data. The client * should check the return value to see if the update was successful. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture. * The backend texture must be compatible with the provided pixmap(s). Compatible, in this case, - * means that the backend format is compatible with the base pixmap's colortype. + * means that the backend format is compatible with the base pixmap's colortype. The src data + * can be deleted when this call returns. * If the backend texture is mip mapped, the data for all the mipmap levels must be provided. * In the mipmapped case all the colortypes of the provided pixmaps must be the same. * Additionally, all the miplevels must be sized correctly (please see @@ -604,8 +602,8 @@ public: *If possible, create a compressed backend texture initialized to a particular color. The * client should ensure that the returned backend texture is valid. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture. * For the Vulkan backend the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */ @@ -629,8 +627,8 @@ public: * If possible, create a backend texture initialized with the provided raw data. The client * should ensure that the returned backend texture is valid. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture * If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired * the data for all the mipmap levels must be provided. Additionally, all the miplevels * must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount). @@ -653,6 +651,26 @@ public: GrGpuFinishedProc finishedProc = nullptr, GrGpuFinishedContext finishedContext = nullptr); + /** + * Updates the state of the GrBackendTexture/RenderTarget to have the passed in + * GrBackendSurfaceMutableState. All objects that wrap the backend surface (i.e. SkSurfaces and + * SkImages) will also be aware of this state change. This call does not submit the state change + * to the gpu, but requires the client to call GrContext::submit to send it to the GPU. The work + * for this call is ordered linearly with all other calls that require GrContext::submit to be + * called (e.g updateBackendTexture and flush). If finishedProc is not null then it will be + * called with finishedContext after the state transition is known to have occurred on the GPU. + * + * See GrBackendSurfaceMutableState to see what state can be set via this call. + */ + bool setBackendTextureState(const GrBackendTexture&, + const GrBackendSurfaceMutableState&, + GrGpuFinishedProc finishedProc = nullptr, + GrGpuFinishedContext finishedContext = nullptr); + bool setBackendRenderTargetState(const GrBackendRenderTarget&, + const GrBackendSurfaceMutableState&, + GrGpuFinishedProc finishedProc = nullptr, + GrGpuFinishedContext finishedContext = nullptr); + void deleteBackendTexture(GrBackendTexture); // This interface allows clients to pre-compile shaders and populate the runtime program cache. @@ -680,16 +698,14 @@ public: #endif protected: - GrContext(GrBackendApi, const GrContextOptions&, int32_t contextID = SK_InvalidGenID); + GrContext(sk_sp<GrContextThreadSafeProxy>); - bool init(sk_sp<const GrCaps>) override; + bool init() override; GrContext* asDirectContext() override { return this; } virtual GrAtlasManager* onGetAtlasManager() = 0; - sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy; - private: // fTaskGroup must appear before anything that uses it (e.g. fGpu), so that it is destroyed // after all of its users. Clients of fTaskGroup will generally want to ensure that they call diff --git a/chromium/third_party/skia/include/gpu/GrContextOptions.h b/chromium/third_party/skia/include/gpu/GrContextOptions.h index 5bdf37687c1..2f3d5b92e5e 100644 --- a/chromium/third_party/skia/include/gpu/GrContextOptions.h +++ b/chromium/third_party/skia/include/gpu/GrContextOptions.h @@ -134,16 +134,20 @@ struct SK_API GrContextOptions { /** * Below this threshold size in device space distance field fonts won't be used. Distance field - * fonts don't support hinting which is more important at smaller sizes. A negative value means - * use the default threshold. + * fonts don't support hinting which is more important at smaller sizes. */ - float fMinDistanceFieldFontSize = -1.f; + float fMinDistanceFieldFontSize = 18; /** - * Above this threshold size in device space glyphs are drawn as individual paths. A negative - * value means use the default threshold. + * Above this threshold size in device space glyphs are drawn as individual paths. */ - float fGlyphsAsPathsFontSize = -1.f; +#if defined(SK_BUILD_FOR_ANDROID) + float fGlyphsAsPathsFontSize = 384; +#elif defined(SK_BUILD_FOR_MAC) + float fGlyphsAsPathsFontSize = 256; +#else + float fGlyphsAsPathsFontSize = 324; +#endif /** * Can the glyph atlas use multiple textures. If allowed, the each texture's size is bound by @@ -258,17 +262,14 @@ struct SK_API GrContextOptions { bool fClearAllTextures = false; /** - * Include or exclude specific GPU path renderers. + * Randomly generate a (false) GL_OUT_OF_MEMORY error */ - GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault; -#endif + bool fRandomGLOOM = false; -#if SK_SUPPORT_ATLAS_TEXT /** - * Controls whether distance field glyph vertices always have 3 components even when the view - * matrix does not have perspective. + * Include or exclude specific GPU path renderers. */ - Enable fDistanceFieldGlyphVerticesAlwaysHaveW = Enable::kDefault; + GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault; #endif GrDriverBugWorkarounds fDriverBugWorkarounds; diff --git a/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h b/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h index bfd37ac77e1..ca4cb313dcd 100644 --- a/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h +++ b/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h @@ -8,11 +8,16 @@ #ifndef GrContextThreadSafeProxy_DEFINED #define GrContextThreadSafeProxy_DEFINED -#include "include/private/GrContext_Base.h" +#include "include/core/SkImageInfo.h" +#include "include/core/SkRefCnt.h" +#include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrTypes.h" + +#include <atomic> class GrBackendFormat; +class GrCaps; class GrContextThreadSafeProxyPriv; -struct SkImageInfo; class SkSurfaceCharacterization; class SkSurfaceProps; @@ -20,9 +25,9 @@ class SkSurfaceProps; * Can be used to perform actions related to the generating GrContext in a thread safe manner. The * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrContext. */ -class SK_API GrContextThreadSafeProxy : public GrContext_Base { +class SK_API GrContextThreadSafeProxy final : public SkNVRefCnt<GrContextThreadSafeProxy> { public: - ~GrContextThreadSafeProxy() override; + ~GrContextThreadSafeProxy(); /** * Create a surface characterization for a DDL that will be replayed into the GrContext @@ -73,13 +78,13 @@ public: * * The caller should check that the returned format is valid. */ - GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const { - return INHERITED::defaultBackendFormat(ct, renderable); - } + GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const; + + bool isValid() const { return nullptr != fCaps; } bool operator==(const GrContextThreadSafeProxy& that) const { // Each GrContext should only ever have a single thread-safe proxy. - SkASSERT((this == &that) == (this->contextID() == that.contextID())); + SkASSERT((this == &that) == (this->fContextID == that.fContextID)); return this == &that; } @@ -93,11 +98,21 @@ private: friend class GrContextThreadSafeProxyPriv; // for ctor and hidden methods // DDL TODO: need to add unit tests for backend & maybe options - GrContextThreadSafeProxy(GrBackendApi, const GrContextOptions&, uint32_t contextID); + GrContextThreadSafeProxy(GrBackendApi, const GrContextOptions&); + + void abandonContext(); + bool abandoned() const; - bool init(sk_sp<const GrCaps>) override; + // TODO: This should be part of the constructor but right now we have a chicken-and-egg problem + // with GrContext where we get the caps by creating a GPU which requires a context (see the + // `init` method on GrContext_Base). + void init(sk_sp<const GrCaps>); - typedef GrContext_Base INHERITED; + const GrBackendApi fBackend; + const GrContextOptions fOptions; + const uint32_t fContextID; + sk_sp<const GrCaps> fCaps; + std::atomic<bool> fAbandoned{false}; }; #endif diff --git a/chromium/third_party/skia/include/gpu/GrTypes.h b/chromium/third_party/skia/include/gpu/GrTypes.h index e7d4f7e4c8c..b6f5e6fb39a 100644 --- a/chromium/third_party/skia/include/gpu/GrTypes.h +++ b/chromium/third_party/skia/include/gpu/GrTypes.h @@ -227,13 +227,16 @@ static const uint32_t kAll_GrBackendState = 0xffffffff; enum GrFlushFlags { kNone_GrFlushFlags = 0, - // flush will wait till all submitted GPU work is finished before returning. + // Deprecated: Use syncCpu call on submit instead. kSyncCpu_GrFlushFlag = 0x1, }; typedef void* GrGpuFinishedContext; typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext); +typedef void* GrGpuSubmittedContext; +typedef void (*GrGpuSubmittedProc)(GrGpuSubmittedContext submittedContext, bool success); + /** * Struct to supply options to flush calls. * @@ -241,7 +244,8 @@ typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext); * passes in an array of fNumSemaphores GrBackendSemaphores. In general these GrBackendSemaphore's * can be either initialized or not. If they are initialized, the backend uses the passed in * semaphore. If it is not initialized, a new semaphore is created and the GrBackendSemaphore - * object is initialized with that semaphore. + * object is initialized with that semaphore. The semaphores are not sent to the GPU until the next + * GrContext::submit call is made. See the GrContext::submit for more information. * * The client will own and be responsible for deleting the underlying semaphores that are stored * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects @@ -251,52 +255,40 @@ typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext); * from this flush call and all previous flush calls has finished on the GPU. If the flush call * fails due to an error and nothing ends up getting sent to the GPU, the finished proc is called * immediately. + * + * If a submittedProc is provided, the submittedProc will be called when all work from this flush + * call is submitted to the GPU. If the flush call fails due to an error and nothing will get sent + * to the GPU, the submitted proc is called immediately. It is possibly that when work is finally + * submitted, that the submission actual fails. In this case we will not reattempt to do the + * submission. Skia notifies the client of these via the success bool passed into the submittedProc. + * The submittedProc is useful to the client to know when semaphores that were sent with the flush + * have actually been submitted to the GPU so that they can be waited on (or deleted if the submit + * fails). + * Note about GL: In GL work gets sent to the driver immediately during the flush call, but we don't + * really know when the driver sends the work to the GPU. Therefore, we treat the submitted proc as + * we do in other backends. It will be called when the next GrContext::submit is called after the + * flush (or possibly during the flush if there is no work to be done for the flush). The main use + * case for the submittedProc is to know when semaphores have been sent to the GPU and even in GL + * it is required to call GrContext::submit to flush them. So a client should be able to treat all + * backend APIs the same in terms of how the submitted procs are treated. */ struct GrFlushInfo { - GrFlushFlags fFlags = kNone_GrFlushFlags; - int fNumSemaphores = 0; - GrBackendSemaphore* fSignalSemaphores = nullptr; - GrGpuFinishedProc fFinishedProc = nullptr; + GrFlushFlags fFlags = kNone_GrFlushFlags; + int fNumSemaphores = 0; + GrBackendSemaphore* fSignalSemaphores = nullptr; + GrGpuFinishedProc fFinishedProc = nullptr; GrGpuFinishedContext fFinishedContext = nullptr; + GrGpuSubmittedProc fSubmittedProc = nullptr; + GrGpuSubmittedContext fSubmittedContext = nullptr; }; /** - * Enum used as return value when flush with semaphores so the client knows whether the semaphores - * were submitted to GPU or not. + * Enum used as return value when flush with semaphores so the client knows whether the valid + * semaphores will be submitted on the next GrContext::submit call. */ enum class GrSemaphoresSubmitted : bool { kNo = false, kYes = true }; -/** - * Array of SkImages and SkSurfaces which Skia will prepare for external use when passed into a - * flush call on GrContext. All the SkImages and SkSurfaces must be GPU backed. - * - * If fPrepareSurfaceForPresent is not nullptr, then it must be an array the size of fNumSurfaces. - * Each entry in the array corresponds to the SkSurface at the same index in the fSurfaces array. If - * an entry is true, then that surface will be prepared for both external use and present. - * - * Currently this only has an effect if the backend API is Vulkan. In this case, all the underlying - * VkImages associated with the SkImages and SkSurfaces will be transitioned into the VkQueueFamily - * in which they were originally wrapped or created with. This allows a client to wrap a VkImage - * from a queue which is different from the graphics queue and then have Skia transition it back to - * that queue without needing to delete the SkImage or SkSurface. If the an SkSurface is also - * flagged to be prepared for present, then its VkImageLayout will be set to - * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR if the VK_KHR_swapchain extension has been enabled for the - * GrContext and the original queue is not VK_QUEUE_FAMILY_EXTERNAL or VK_QUEUE_FAMILY_FOREIGN_EXT. - * - * If an SkSurface or SkImage is used again, it will be transitioned back to the graphics queue and - * whatever layout is needed for its use. - */ -struct GrPrepareForExternalIORequests { - int fNumImages = 0; - SkImage** fImages = nullptr; - int fNumSurfaces = 0; - SkSurface** fSurfaces = nullptr; - bool* fPrepareSurfaceForPresent = nullptr; - - bool hasRequests() const { return fNumImages || fNumSurfaces; } -}; - #endif diff --git a/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h b/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h index 17655bdbedb..c571314cae4 100644 --- a/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h +++ b/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h @@ -49,6 +49,13 @@ struct SK_API GrGLInterface : public SkRefCnt { private: typedef SkRefCnt INHERITED; +#if GR_GL_CHECK_ERROR + // This is here to avoid having our debug code that checks for a GL error after most GL calls + // accidentally swallow an OOM that should be reported. + mutable bool fOOMed = false; + bool fSuppressErrorLogging = false; +#endif + public: GrGLInterface(); @@ -57,6 +64,19 @@ public: // extensions. bool validate() const; +#if GR_GL_CHECK_ERROR + GrGLenum checkError(const char* location, const char* call) const; + bool checkAndResetOOMed() const; + void suppressErrorLogging(); +#endif + +#if GR_TEST_UTILS + GrGLInterface(const GrGLInterface& that) + : fStandard(that.fStandard) + , fExtensions(that.fExtensions) + , fFunctions(that.fFunctions) {} +#endif + // Indicates the type of GL implementation union { GrGLStandard fStandard; diff --git a/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h b/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h index b4c55c81d5b..897a83105eb 100644 --- a/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h +++ b/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h @@ -110,12 +110,12 @@ struct GrMockOptions { // GrCaps options. bool fMipMapSupport = false; bool fDrawInstancedSupport = false; - bool fTessellationSupport = false; bool fHalfFloatVertexAttributeSupport = false; uint32_t fMapBufferFlags = 0; int fMaxTextureSize = 2048; int fMaxRenderTargetSize = 2048; int fMaxVertexAttributes = 16; + int fMaxTessellationSegments = 0; ConfigOptions fConfigOptions[kGrColorTypeCnt]; ConfigOptions fCompressedOptions[SkImage::kCompressionTypeCount]; diff --git a/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h b/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h index 5102496b831..b25d5458d90 100644 --- a/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h +++ b/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h @@ -50,11 +50,43 @@ public: kGpuWritesCpuReads, }; - virtual bool allocateMemoryForImage(VkImage image, AllocationPropertyFlags flags, - GrVkBackendMemory*) = 0; + // DEPRECATED: Use and implement allocateImageMemory instead + virtual bool allocateMemoryForImage(VkImage, AllocationPropertyFlags, GrVkBackendMemory*) { + // The default implementation here is so clients can delete this virtual as the switch to + // the new one which returns a VkResult. + return false; + } + + virtual VkResult allocateImageMemory(VkImage image, AllocationPropertyFlags flags, + GrVkBackendMemory* memory) { + bool result = this->allocateMemoryForImage(image, flags, memory); + // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is + // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to + // mean something specific happened like device lost or oom. This will be removed once we + // update clients to implement this virtual. + return result ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; + } + + // DEPRECATED: Use and implement allocateBufferMemory instead + virtual bool allocateMemoryForBuffer(VkBuffer, BufferUsage, AllocationPropertyFlags, + GrVkBackendMemory*) { + // The default implementation here is so clients can delete this virtual as the switch to + // the new one which returns a VkResult. + return false; + } + + virtual VkResult allocateBufferMemory(VkBuffer buffer, + BufferUsage usage, + AllocationPropertyFlags flags, + GrVkBackendMemory* memory) { + bool result = this->allocateMemoryForBuffer(buffer, usage, flags, memory); + // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is + // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to + // mean something specific happened like device lost or oom. This will be removed once we + // update clients to implement this virtual. + return result ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; + } - virtual bool allocateMemoryForBuffer(VkBuffer buffer, BufferUsage usage, - AllocationPropertyFlags flags, GrVkBackendMemory*) = 0; // Fills out the passed in GrVkAlloc struct for the passed in GrVkBackendMemory. virtual void getAllocInfo(const GrVkBackendMemory&, GrVkAlloc*) const = 0; @@ -62,7 +94,15 @@ public: // Maps the entire allocation and returns a pointer to the start of the allocation. The // implementation may map more memory than just the allocation, but the returned pointer must // point at the start of the memory for the requested allocation. - virtual void* mapMemory(const GrVkBackendMemory&) = 0; + virtual void* mapMemory(const GrVkBackendMemory&) { return nullptr; } + virtual VkResult mapMemory(const GrVkBackendMemory& memory, void** data) { + *data = this->mapMemory(memory); + // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is + // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to + // mean something specific happened like device lost or oom. This will be removed once we + // update clients to implement this virtual. + return *data ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; + } virtual void unmapMemory(const GrVkBackendMemory&) = 0; // The following two calls are used for managing non-coherent memory. The offset is relative to @@ -70,10 +110,18 @@ public: // must make sure that the offset + size passed in is less that or equal to the allocation size. // It is the responsibility of the implementation to make sure all alignment requirements are // followed. The client should not have to deal with any sort of alignment issues. - virtual void flushMappedMemory(const GrVkBackendMemory&, VkDeviceSize offset, - VkDeviceSize size) = 0; - virtual void invalidateMappedMemory(const GrVkBackendMemory&, VkDeviceSize offset, - VkDeviceSize size)= 0; + virtual void flushMappedMemory(const GrVkBackendMemory&, VkDeviceSize, VkDeviceSize) {} + virtual VkResult flushMemory(const GrVkBackendMemory& memory, VkDeviceSize offset, + VkDeviceSize size) { + this->flushMappedMemory(memory, offset, size); + return VK_SUCCESS; + } + virtual void invalidateMappedMemory(const GrVkBackendMemory&, VkDeviceSize, VkDeviceSize) {} + virtual VkResult invalidateMemory(const GrVkBackendMemory& memory, VkDeviceSize offset, + VkDeviceSize size) { + this->invalidateMappedMemory(memory, offset, size); + return VK_SUCCESS; + } virtual void freeMemory(const GrVkBackendMemory&) = 0; diff --git a/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h b/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h index c7353677d5c..e869238899b 100644 --- a/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h +++ b/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h @@ -105,7 +105,7 @@ struct GrVkYcbcrConversionInfo { VkChromaLocation yChromaOffset, VkFilter chromaFilter, VkBool32 forceExplicitReconstruction, - uint64_t externalFormat, + int64_t externalFormat, VkFormatFeatureFlags externalFormatFeatures) : GrVkYcbcrConversionInfo(VK_FORMAT_UNDEFINED, externalFormat, ycbcrModel, ycbcrRange, xChromaOffset, yChromaOffset, chromaFilter, @@ -135,7 +135,7 @@ struct GrVkYcbcrConversionInfo { // The external format. Must be non-zero for external images, zero otherwise. // Should be compatible to be used in a VkExternalFormatANDROID struct. - uint64_t fExternalFormat; + int64_t fExternalFormat; VkSamplerYcbcrModelConversion fYcbcrModel; VkSamplerYcbcrRange fYcbcrRange; @@ -149,6 +149,12 @@ struct GrVkYcbcrConversionInfo { VkFormatFeatureFlags fFormatFeatures; }; +/* + * When wrapping a GrBackendTexture or GrBackendRendenderTarget, the fCurrentQueueFamily should + * either be VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_EXTERNAL, or VK_QUEUE_FAMILY_FOREIGN_EXT. If + * fSharingMode is VK_SHARING_MODE_EXCLUSIVE then fCurrentQueueFamily can also be the graphics + * queue index passed into Skia. + */ struct GrVkImageInfo { VkImage fImage; GrVkAlloc fAlloc; @@ -159,6 +165,7 @@ struct GrVkImageInfo { uint32_t fCurrentQueueFamily; GrProtected fProtected; GrVkYcbcrConversionInfo fYcbcrConversionInfo; + VkSharingMode fSharingMode; GrVkImageInfo() : fImage(VK_NULL_HANDLE) @@ -169,7 +176,8 @@ struct GrVkImageInfo { , fLevelCount(0) , fCurrentQueueFamily(VK_QUEUE_FAMILY_IGNORED) , fProtected(GrProtected::kNo) - , fYcbcrConversionInfo() {} + , fYcbcrConversionInfo() + , fSharingMode(VK_SHARING_MODE_EXCLUSIVE) {} GrVkImageInfo(VkImage image, GrVkAlloc alloc, @@ -179,7 +187,8 @@ struct GrVkImageInfo { uint32_t levelCount, uint32_t currentQueueFamily = VK_QUEUE_FAMILY_IGNORED, GrProtected isProtected = GrProtected::kNo, - GrVkYcbcrConversionInfo ycbcrConversionInfo = GrVkYcbcrConversionInfo()) + GrVkYcbcrConversionInfo ycbcrConversionInfo = GrVkYcbcrConversionInfo(), + VkSharingMode sharingMode = VK_SHARING_MODE_EXCLUSIVE) : fImage(image) , fAlloc(alloc) , fImageTiling(imageTiling) @@ -188,18 +197,20 @@ struct GrVkImageInfo { , fLevelCount(levelCount) , fCurrentQueueFamily(currentQueueFamily) , fProtected(isProtected) - , fYcbcrConversionInfo(ycbcrConversionInfo) {} + , fYcbcrConversionInfo(ycbcrConversionInfo) + , fSharingMode(sharingMode) {} - GrVkImageInfo(const GrVkImageInfo& info, VkImageLayout layout) + GrVkImageInfo(const GrVkImageInfo& info, VkImageLayout layout, uint32_t familyQueueIndex) : fImage(info.fImage) , fAlloc(info.fAlloc) , fImageTiling(info.fImageTiling) , fImageLayout(layout) , fFormat(info.fFormat) , fLevelCount(info.fLevelCount) - , fCurrentQueueFamily(info.fCurrentQueueFamily) + , fCurrentQueueFamily(familyQueueIndex) , fProtected(info.fProtected) - , fYcbcrConversionInfo(info.fYcbcrConversionInfo) {} + , fYcbcrConversionInfo(info.fYcbcrConversionInfo) + , fSharingMode(info.fSharingMode) {} #if GR_TEST_UTILS bool operator==(const GrVkImageInfo& that) const { @@ -207,7 +218,8 @@ struct GrVkImageInfo { fImageTiling == that.fImageTiling && fImageLayout == that.fImageLayout && fFormat == that.fFormat && fLevelCount == that.fLevelCount && fCurrentQueueFamily == that.fCurrentQueueFamily && fProtected == that.fProtected && - fYcbcrConversionInfo == that.fYcbcrConversionInfo; + fYcbcrConversionInfo == that.fYcbcrConversionInfo && + fSharingMode == that.fSharingMode; } #endif }; diff --git a/chromium/third_party/skia/include/ports/SkFontMgr_mac_ct.h b/chromium/third_party/skia/include/ports/SkFontMgr_mac_ct.h new file mode 100644 index 00000000000..45cba65b5da --- /dev/null +++ b/chromium/third_party/skia/include/ports/SkFontMgr_mac_ct.h @@ -0,0 +1,27 @@ +/* + * 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 SkFontMgr_mac_ct_DEFINED +#define SkFontMgr_mac_ct_DEFINED + +#include "include/core/SkRefCnt.h" +#include "include/core/SkTypes.h" + +#ifdef SK_BUILD_FOR_MAC +#import <ApplicationServices/ApplicationServices.h> +#endif + +#ifdef SK_BUILD_FOR_IOS +#include <CoreText/CoreText.h> +#endif + +class SkFontMgr; + +/** Create a font manager for CoreText. If the collection is nullptr the system default will be used. */ +SK_API extern sk_sp<SkFontMgr> SkFontMgr_New_CoreText(CTFontCollectionRef); + +#endif // SkFontMgr_mac_ct_DEFINED diff --git a/chromium/third_party/skia/include/private/GrContext_Base.h b/chromium/third_party/skia/include/private/GrContext_Base.h index b5b3119361f..326c9107724 100644 --- a/chromium/third_party/skia/include/private/GrContext_Base.h +++ b/chromium/third_party/skia/include/private/GrContext_Base.h @@ -16,6 +16,7 @@ class GrBaseContextPriv; class GrCaps; class GrContext; +class GrContextThreadSafeProxy; class GrImageContext; class GrRecordingContext; @@ -26,7 +27,7 @@ public: /* * The 3D API backing this context */ - SK_API GrBackendApi backend() const { return fBackend; } + SK_API GrBackendApi backend() const; /* * Retrieve the default GrBackendFormat for a given SkColorType and renderability. @@ -39,6 +40,9 @@ public: SK_API GrBackendFormat compressedBackendFormat(SkImage::CompressionType) const; + // TODO: When the public version is gone, rename to refThreadSafeProxy and add raw ptr ver. + sk_sp<GrContextThreadSafeProxy> threadSafeProxy(); + // Provides access to functions that aren't part of the public API. GrBaseContextPriv priv(); const GrBaseContextPriv priv() const; @@ -46,9 +50,9 @@ public: protected: friend class GrBaseContextPriv; // for hidden functions - GrContext_Base(GrBackendApi backend, const GrContextOptions& options, uint32_t contextID); + GrContext_Base(sk_sp<GrContextThreadSafeProxy>); - virtual bool init(sk_sp<const GrCaps>); + virtual bool init(); /** * An identifier for this context. The id is used by all compatible contexts. For example, @@ -57,7 +61,7 @@ protected: * a third thread with a direct context, then all three contexts will report the same id. * It is an error for an image to be used with contexts that report different ids. */ - uint32_t contextID() const { return fContextID; } + uint32_t contextID() const; bool matches(GrContext_Base* candidate) const { return candidate->contextID() == this->contextID(); @@ -66,7 +70,7 @@ protected: /* * The options in effect for this context */ - const GrContextOptions& options() const { return fOptions; } + const GrContextOptions& options() const; const GrCaps* caps() const; sk_sp<const GrCaps> refCaps() const; @@ -75,12 +79,9 @@ protected: virtual GrRecordingContext* asRecordingContext() { return nullptr; } virtual GrContext* asDirectContext() { return nullptr; } -private: - const GrBackendApi fBackend; - const GrContextOptions fOptions; - const uint32_t fContextID; - sk_sp<const GrCaps> fCaps; + sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy; +private: typedef SkRefCnt INHERITED; }; diff --git a/chromium/third_party/skia/include/private/GrImageContext.h b/chromium/third_party/skia/include/private/GrImageContext.h index 9dc0acb8154..65d30642bc5 100644 --- a/chromium/third_party/skia/include/private/GrImageContext.h +++ b/chromium/third_party/skia/include/private/GrImageContext.h @@ -18,10 +18,6 @@ class GrImageContext : public GrContext_Base { public: ~GrImageContext() override; - SK_API GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const { - return INHERITED::defaultBackendFormat(ct, renderable); - } - // Provides access to functions that aren't part of the public API. GrImageContextPriv priv(); const GrImageContextPriv priv() const; @@ -29,7 +25,7 @@ public: protected: friend class GrImageContextPriv; // for hidden functions - GrImageContext(GrBackendApi, const GrContextOptions&, uint32_t contextID); + GrImageContext(sk_sp<GrContextThreadSafeProxy>); SK_API virtual void abandonContext(); SK_API virtual bool abandoned(); @@ -44,7 +40,6 @@ protected: private: std::unique_ptr<GrProxyProvider> fProxyProvider; - bool fAbandoned = false; // In debug builds we guard against improper thread handling // This guard is passed to the GrDrawingManager and, from there to all the diff --git a/chromium/third_party/skia/include/private/GrRecordingContext.h b/chromium/third_party/skia/include/private/GrRecordingContext.h index 921731c5dd0..945ed3e9e61 100644 --- a/chromium/third_party/skia/include/private/GrRecordingContext.h +++ b/chromium/third_party/skia/include/private/GrRecordingContext.h @@ -75,8 +75,8 @@ protected: std::unique_ptr<SkArenaAlloc> fRecordTimeAllocator; }; - GrRecordingContext(GrBackendApi, const GrContextOptions&, uint32_t contextID); - bool init(sk_sp<const GrCaps>) override; + GrRecordingContext(sk_sp<GrContextThreadSafeProxy>); + bool init() override; void setupDrawingManager(bool sortOpsTasks, bool reduceOpsTaskSplitting); void abandonContext() override; diff --git a/chromium/third_party/skia/include/private/GrResourceKey.h b/chromium/third_party/skia/include/private/GrResourceKey.h index 977eecf25ed..ee39e903048 100644 --- a/chromium/third_party/skia/include/private/GrResourceKey.h +++ b/chromium/third_party/skia/include/private/GrResourceKey.h @@ -62,7 +62,7 @@ protected: } else { size_t bytes = that.size(); SkASSERT(SkIsAlign4(bytes)); - fKey.reset(SkToInt(bytes / sizeof(uint32_t))); + fKey.reset(bytes / sizeof(uint32_t)); memcpy(fKey.get(), that.fKey.get(), bytes); this->validate(); } @@ -103,10 +103,10 @@ protected: class Builder { public: Builder(GrResourceKey* key, uint32_t domain, int data32Count) : fKey(key) { - SkASSERT(data32Count >= 0); + size_t count = SkToSizeT(data32Count); SkASSERT(domain != kInvalidDomain); - key->fKey.reset(kMetaDataCnt + data32Count); - int size = (data32Count + kMetaDataCnt) * sizeof(uint32_t); + key->fKey.reset(kMetaDataCnt + count); + size_t size = (count + kMetaDataCnt) * sizeof(uint32_t); SkASSERT(SkToU16(size) == size); SkASSERT(SkToU16(domain) == domain); key->fKey[kDomainAndSize_MetaDataIdx] = domain | (size << 16); @@ -128,7 +128,7 @@ protected: SkASSERT(fKey); SkDEBUGCODE(size_t dataCount = fKey->internalSize() / sizeof(uint32_t) - kMetaDataCnt;) SkASSERT(SkToU32(dataIdx) < dataCount); - return fKey->fKey[kMetaDataCnt + dataIdx]; + return fKey->fKey[(int)kMetaDataCnt + dataIdx]; } private: diff --git a/chromium/third_party/skia/include/private/GrSharedEnums.h b/chromium/third_party/skia/include/private/GrSharedEnums.h index d745b70bd43..cdb0f80b14d 100644 --- a/chromium/third_party/skia/include/private/GrSharedEnums.h +++ b/chromium/third_party/skia/include/private/GrSharedEnums.h @@ -15,17 +15,15 @@ /** * We have coverage effects that clip rendering to the edge of some geometric primitive. * This enum specifies how that clipping is performed. Not all factories that take a - * GrProcessorEdgeType will succeed with all values and it is up to the caller to check for - * a NULL return. + * GrProcessorEdgeType will succeed with all values and it is up to the caller to verify success. */ enum class GrClipEdgeType { kFillBW, kFillAA, kInverseFillBW, kInverseFillAA, - kHairlineAA, - kLast = kHairlineAA + kLast = kInverseFillAA }; enum class PMConversion { diff --git a/chromium/third_party/skia/include/private/GrSingleOwner.h b/chromium/third_party/skia/include/private/GrSingleOwner.h index 6369ae82c88..0bbaeb7849f 100644 --- a/chromium/third_party/skia/include/private/GrSingleOwner.h +++ b/chromium/third_party/skia/include/private/GrSingleOwner.h @@ -14,30 +14,39 @@ #include "include/private/SkMutex.h" #include "include/private/SkThreadID.h" +#define GR_ASSERT_SINGLE_OWNER(obj) \ + GrSingleOwner::AutoEnforce debug_SingleOwner(obj, __FILE__, __LINE__); + // This is a debug tool to verify an object is only being used from one thread at a time. class GrSingleOwner { public: GrSingleOwner() : fOwner(kIllegalThreadID), fReentranceCount(0) {} struct AutoEnforce { - AutoEnforce(GrSingleOwner* so) : fSO(so) { fSO->enter(); } - ~AutoEnforce() { fSO->exit(); } + AutoEnforce(GrSingleOwner* so, const char* file, int line) + : fFile(file), fLine(line), fSO(so) { + fSO->enter(file, line); + } + ~AutoEnforce() { fSO->exit(fFile, fLine); } + const char* fFile; + int fLine; GrSingleOwner* fSO; }; private: - void enter() { + void enter(const char* file, int line) { SkAutoMutexExclusive lock(fMutex); SkThreadID self = SkGetThreadID(); - SkASSERT(fOwner == self || fOwner == kIllegalThreadID); + SkASSERTF(fOwner == self || fOwner == kIllegalThreadID, "%s:%d Single owner failure.", + file, line); fReentranceCount++; fOwner = self; } - void exit() { + void exit(const char* file, int line) { SkAutoMutexExclusive lock(fMutex); - SkASSERT(fOwner == SkGetThreadID()); + SkASSERTF(fOwner == SkGetThreadID(), "%s:%d Single owner failure.", file, line); fReentranceCount--; if (fReentranceCount == 0) { fOwner = kIllegalThreadID; @@ -49,6 +58,7 @@ private: int fReentranceCount SK_GUARDED_BY(fMutex); }; #else +#define GR_ASSERT_SINGLE_OWNER(obj) class GrSingleOwner {}; // Provide a dummy implementation so we can pass pointers to constructors #endif diff --git a/chromium/third_party/skia/include/private/GrTypesPriv.h b/chromium/third_party/skia/include/private/GrTypesPriv.h index 03ac124c0d4..21e13b80ccd 100644 --- a/chromium/third_party/skia/include/private/GrTypesPriv.h +++ b/chromium/third_party/skia/include/private/GrTypesPriv.h @@ -99,6 +99,13 @@ enum class GrTexturable : bool { kYes = true }; +// A DDL recorder has its own proxy provider and proxy cache. This enum indicates if +// a given proxy provider is one of these special ones. +enum class GrDDLProvider : bool { + kNo = false, + kYes = true +}; + /** * Formats for masks, used by the font cache. Important that these are 0-based. */ @@ -114,18 +121,16 @@ static const int kMaskFormatCount = kLast_GrMaskFormat + 1; /** * Return the number of bytes-per-pixel for the specified mask format. */ -static inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) { +inline constexpr int GrMaskFormatBytesPerPixel(GrMaskFormat format) { SkASSERT(format < kMaskFormatCount); // kA8 (0) -> 1 // kA565 (1) -> 2 // kARGB (2) -> 4 - static const int sBytesPerPixel[] = {1, 2, 4}; - static_assert(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, "array_size_mismatch"); static_assert(kA8_GrMaskFormat == 0, "enum_order_dependency"); static_assert(kA565_GrMaskFormat == 1, "enum_order_dependency"); static_assert(kARGB_GrMaskFormat == 2, "enum_order_dependency"); - return sBytesPerPixel[(int)format]; + return SkTo<int>(1u << format); } /** Ownership rules for external GPU resources imported into Skia. */ @@ -650,10 +655,8 @@ static inline GrClipEdgeType GrInvertProcessorEdgeType(const GrClipEdgeType edge return GrClipEdgeType::kFillBW; case GrClipEdgeType::kInverseFillAA: return GrClipEdgeType::kFillAA; - case GrClipEdgeType::kHairlineAA: - SK_ABORT("Hairline fill isn't invertible."); } - return GrClipEdgeType::kFillAA; // suppress warning. + SkUNREACHABLE; } /** diff --git a/chromium/third_party/skia/include/private/GrVkTypesPriv.h b/chromium/third_party/skia/include/private/GrVkTypesPriv.h index 49b392c52b5..b46cf8bf914 100644 --- a/chromium/third_party/skia/include/private/GrVkTypesPriv.h +++ b/chromium/third_party/skia/include/private/GrVkTypesPriv.h @@ -11,7 +11,7 @@ #include "include/core/SkRefCnt.h" #include "include/gpu/vk/GrVkTypes.h" -class GrVkImageLayout; +class GrBackendSurfaceMutableStateImpl; // This struct is to used to store the the actual information about the vulkan backend image on the // GrBackendTexture and GrBackendRenderTarget. When a client calls getVkImageInfo on a @@ -20,8 +20,7 @@ class GrVkImageLayout; // current VkImageLayout which can be shared with an internal GrVkImage so that layout updates can // be seen by all users of the image. struct GrVkBackendSurfaceInfo { - GrVkBackendSurfaceInfo(GrVkImageInfo info, GrVkImageLayout* layout) - : fImageInfo(info), fLayout(layout) {} + GrVkBackendSurfaceInfo(GrVkImageInfo info) : fImageInfo(info) {} void cleanup(); @@ -31,11 +30,7 @@ struct GrVkBackendSurfaceInfo { // attempt to unref the old fLayout on this object. void assign(const GrVkBackendSurfaceInfo&, bool isValid); - void setImageLayout(VkImageLayout layout); - - sk_sp<GrVkImageLayout> getGrVkImageLayout() const; - - GrVkImageInfo snapImageInfo() const; + GrVkImageInfo snapImageInfo(const GrBackendSurfaceMutableStateImpl*) const; bool isProtected() const { return fImageInfo.fProtected == GrProtected::kYes; } #if GR_TEST_UTILS @@ -44,7 +39,43 @@ struct GrVkBackendSurfaceInfo { private: GrVkImageInfo fImageInfo; - GrVkImageLayout* fLayout; +}; + +class GrVkSharedImageInfo { +public: + GrVkSharedImageInfo(VkImageLayout layout, uint32_t queueFamilyIndex) + : fLayout(layout) + , fQueueFamilyIndex(queueFamilyIndex) {} + + GrVkSharedImageInfo& operator=(const GrVkSharedImageInfo& that) { + fLayout = that.getImageLayout(); + fQueueFamilyIndex = that.getQueueFamilyIndex(); + return *this; + } + + void setImageLayout(VkImageLayout layout) { + // Defaulting to use std::memory_order_seq_cst + fLayout.store(layout); + } + + VkImageLayout getImageLayout() const { + // Defaulting to use std::memory_order_seq_cst + return fLayout.load(); + } + + void setQueueFamilyIndex(uint32_t queueFamilyIndex) { + // Defaulting to use std::memory_order_seq_cst + fQueueFamilyIndex.store(queueFamilyIndex); + } + + uint32_t getQueueFamilyIndex() const { + // Defaulting to use std::memory_order_seq_cst + return fQueueFamilyIndex.load(); + } + +private: + std::atomic<VkImageLayout> fLayout; + std::atomic<uint32_t> fQueueFamilyIndex; }; #endif diff --git a/chromium/third_party/skia/include/private/SkChecksum.h b/chromium/third_party/skia/include/private/SkChecksum.h index 8e2a4ba5248..6339239d65c 100644 --- a/chromium/third_party/skia/include/private/SkChecksum.h +++ b/chromium/third_party/skia/include/private/SkChecksum.h @@ -11,14 +11,9 @@ #include "include/core/SkString.h" #include "include/core/SkTypes.h" #include "include/private/SkNoncopyable.h" +#include "include/private/SkOpts_spi.h" #include "include/private/SkTLogic.h" -// #include "src/core/SkOpts.h" -// It's sort of pesky to be able to include SkOpts.h here, so we'll just re-declare what we need. -namespace SkOpts { - extern uint32_t (*hash_fn)(const void*, size_t, uint32_t); -} - class SkChecksum : SkNoncopyable { public: /** diff --git a/chromium/third_party/skia/include/private/SkColorData.h b/chromium/third_party/skia/include/private/SkColorData.h index 2090ab4b7ee..aba610eacf6 100644 --- a/chromium/third_party/skia/include/private/SkColorData.h +++ b/chromium/third_party/skia/include/private/SkColorData.h @@ -435,6 +435,7 @@ static inline uint32_t Sk4f_toL32(const Sk4f& px) { using SkPMColor4f = SkRGBA4f<kPremul_SkAlphaType>; constexpr SkPMColor4f SK_PMColor4fTRANSPARENT = { 0, 0, 0, 0 }; +constexpr SkPMColor4f SK_PMColor4fBLACK = { 0, 0, 0, 1 }; constexpr SkPMColor4f SK_PMColor4fWHITE = { 1, 1, 1, 1 }; constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity, SK_FloatNegativeInfinity, diff --git a/chromium/third_party/skia/include/private/SkFixed.h b/chromium/third_party/skia/include/private/SkFixed.h index af858efc89c..6e8990f574b 100644 --- a/chromium/third_party/skia/include/private/SkFixed.h +++ b/chromium/third_party/skia/include/private/SkFixed.h @@ -62,7 +62,7 @@ typedef int32_t SkFixed; SkASSERT(n >= -32768 && n <= 32767); // Left shifting a negative value has undefined behavior in C, so we cast to unsigned before // shifting. - return (unsigned)n << 16; + return (SkFixed)( (unsigned)n << 16 ); } #else // Left shifting a negative value has undefined behavior in C, so we cast to unsigned before @@ -76,13 +76,13 @@ typedef int32_t SkFixed; #define SkFixedFloorToInt(x) ((x) >> 16) static inline SkFixed SkFixedRoundToFixed(SkFixed x) { - return (x + SK_FixedHalf) & 0xFFFF0000; + return (SkFixed)( (uint32_t)(x + SK_FixedHalf) & 0xFFFF0000 ); } static inline SkFixed SkFixedCeilToFixed(SkFixed x) { - return (x + SK_Fixed1 - 1) & 0xFFFF0000; + return (SkFixed)( (uint32_t)(x + SK_Fixed1 - 1) & 0xFFFF0000 ); } static inline SkFixed SkFixedFloorToFixed(SkFixed x) { - return x & 0xFFFF0000; + return (SkFixed)( (uint32_t)x & 0xFFFF0000 ); } #define SkFixedAbs(x) SkAbs32(x) diff --git a/chromium/third_party/skia/include/private/SkImageInfoPriv.h b/chromium/third_party/skia/include/private/SkImageInfoPriv.h index 582867162f6..6a3c0d17362 100644 --- a/chromium/third_party/skia/include/private/SkImageInfoPriv.h +++ b/chromium/third_party/skia/include/private/SkImageInfoPriv.h @@ -74,7 +74,7 @@ static int SkColorTypeShiftPerPixel(SkColorType ct) { } static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { - return width * SkColorTypeBytesPerPixel(ct); + return (size_t)(width * SkColorTypeBytesPerPixel(ct)); } static inline bool SkColorTypeIsValid(unsigned value) { @@ -85,7 +85,7 @@ static inline size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size if (kUnknown_SkColorType == ct) { return 0; } - return y * rowBytes + (x << SkColorTypeShiftPerPixel(ct)); + return (size_t)y * rowBytes + ((size_t)x << SkColorTypeShiftPerPixel(ct)); } static inline bool SkColorTypeIsNormalized(SkColorType ct) { diff --git a/chromium/third_party/skia/include/private/SkOpts_spi.h b/chromium/third_party/skia/include/private/SkOpts_spi.h new file mode 100644 index 00000000000..528e322113b --- /dev/null +++ b/chromium/third_party/skia/include/private/SkOpts_spi.h @@ -0,0 +1,21 @@ +/* + * 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 SkOpts_spi_DEFINED +#define SkOpts_spi_DEFINED + +#include "include/core/SkTypes.h" + +// These are exposed as SK_SPI (e.g. SkParagraph), the rest of SkOpts is +// declared in src/core + +namespace SkOpts { + // The fastest high quality 32-bit hash we can provide on this platform. + extern uint32_t SK_SPI (*hash_fn)(const void* data, size_t bytes, uint32_t seed); +} + +#endif diff --git a/chromium/third_party/skia/include/private/SkPathRef.h b/chromium/third_party/skia/include/private/SkPathRef.h index 7afe4f9a52e..f9533d72615 100644 --- a/chromium/third_party/skia/include/private/SkPathRef.h +++ b/chromium/third_party/skia/include/private/SkPathRef.h @@ -42,6 +42,24 @@ class SkWBuffer; class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> { public: + SkPathRef(SkTDArray<SkPoint> points, SkTDArray<uint8_t> verbs, SkTDArray<SkScalar> weights, + unsigned segmentMask) + : fPoints(std::move(points)) + , fVerbs(std::move(verbs)) + , fConicWeights(std::move(weights)) + { + fBoundsIsDirty = true; // this also invalidates fIsFinite + fGenerationID = kEmptyGenID; + fSegmentMask = segmentMask; + fIsOval = false; + fIsRRect = false; + // The next two values don't matter unless fIsOval or fIsRRect are true. + fRRectOrOvalIsCCW = false; + fRRectOrOvalStartIdx = 0xAC; + SkDEBUGCODE(fEditorsAttached.store(0);) + SkDEBUGCODE(this->validate();) + } + class Editor { public: Editor(sk_sp<SkPathRef>* pathRef, diff --git a/chromium/third_party/skia/include/private/SkSemaphore.h b/chromium/third_party/skia/include/private/SkSemaphore.h index 265847b5e83..d7318be5779 100644 --- a/chromium/third_party/skia/include/private/SkSemaphore.h +++ b/chromium/third_party/skia/include/private/SkSemaphore.h @@ -19,7 +19,7 @@ public: constexpr SkSemaphore(int count = 0) : fCount(count), fOSSemaphore(nullptr) {} // Cleanup the underlying OS semaphore. - ~SkSemaphore(); + SK_SPI ~SkSemaphore(); // Increment the counter n times. // Generally it's better to call signal(n) instead of signal() n times. @@ -30,7 +30,7 @@ public: void wait(); // If the counter is positive, decrement it by 1 and return true, otherwise return false. - bool try_wait(); + SK_SPI bool try_wait(); private: // This implementation follows the general strategy of @@ -44,8 +44,8 @@ private: // moving the count from >=0 to <0 or vice-versa, i.e. sleeping or waking threads. struct OSSemaphore; - void osSignal(int n); - void osWait(); + SK_SPI void osSignal(int n); + SK_SPI void osWait(); std::atomic<int> fCount; SkOnce fOSSemaphoreOnce; diff --git a/chromium/third_party/skia/include/private/SkTArray.h b/chromium/third_party/skia/include/private/SkTArray.h index 78ce51b270a..cc59aa6ba8b 100644 --- a/chromium/third_party/skia/include/private/SkTArray.h +++ b/chromium/third_party/skia/include/private/SkTArray.h @@ -20,10 +20,15 @@ #include <new> #include <utility> -/** When MEM_MOVE is true T will be bit copied when moved. - When MEM_MOVE is false, T will be copy constructed / destructed. - In all cases T will be default-initialized on allocation, - and its destructor will be called from this object's destructor. +/** SkTArray<T> implements a typical, mostly std::vector-like array. + Each T will be default-initialized on allocation, and ~T will be called on destruction. + + MEM_MOVE controls the behavior when a T needs to be moved (e.g. when the array is resized) + - true: T will be bit-copied via memcpy. + - false: T will be moved via move-constructors. + + Modern implementations of std::vector<T> will generally provide similar performance + characteristics when used with appropriate care. Consider using std::vector<T> in new code. */ template <typename T, bool MEM_MOVE = false> class SkTArray { public: @@ -47,10 +52,23 @@ public: } SkTArray(SkTArray&& that) { - // TODO: If 'that' owns its memory why don't we just steal the pointer? - this->init(that.fCount); - that.move(fItemArray); - that.fCount = 0; + if (that.fOwnMemory) { + fItemArray = that.fItemArray; + fCount = that.fCount; + fAllocCount = that.fAllocCount; + fOwnMemory = true; + fReserved = that.fReserved; + + that.fItemArray = nullptr; + that.fCount = 0; + that.fAllocCount = 0; + that.fOwnMemory = true; + that.fReserved = false; + } else { + this->init(that.fCount); + that.move(fItemArray); + that.fCount = 0; + } } /** @@ -351,6 +369,9 @@ public: return fItemArray[i]; } + T& at(int i) { return (*this)[i]; } + const T& at(int i) const { return (*this)[i]; } + /** * equivalent to operator[](0) */ @@ -455,7 +476,7 @@ private: fReserved = false; } else { fAllocCount = std::max(count, std::max(kMinHeapAllocCount, reserveCount)); - fItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T)); + fItemArray = (T*)sk_malloc_throw((size_t)fAllocCount, sizeof(T)); fOwnMemory = true; fReserved = reserveCount > 0; } @@ -505,7 +526,7 @@ private: } template <bool E = MEM_MOVE> std::enable_if_t<!E, void> move(void* dst) { for (int i = 0; i < fCount; ++i) { - new (static_cast<char*>(dst) + sizeof(T) * i) T(std::move(fItemArray[i])); + new (static_cast<char*>(dst) + sizeof(T) * (size_t)i) T(std::move(fItemArray[i])); fItemArray[i].~T(); } } @@ -551,7 +572,7 @@ private: fAllocCount = Sk64_pin_to_s32(newAllocCount); SkASSERT(fAllocCount >= newCount); - T* newItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T)); + T* newItemArray = (T*)sk_malloc_throw((size_t)fAllocCount, sizeof(T)); this->move(newItemArray); if (fOwnMemory) { sk_free(fItemArray); diff --git a/chromium/third_party/skia/include/private/SkTDArray.h b/chromium/third_party/skia/include/private/SkTDArray.h index 33d4d7cc2ba..9d475f6f8ea 100644 --- a/chromium/third_party/skia/include/private/SkTDArray.h +++ b/chromium/third_party/skia/include/private/SkTDArray.h @@ -17,6 +17,13 @@ #include <initializer_list> #include <utility> +/** SkTDArray<T> implements a std::vector-like array for raw data-only objects that do not require + construction or destruction. The constructor and destructor for T will not be called; T objects + will always be moved via raw memcpy. Newly created T objects will contain uninitialized memory. + + In most cases, std::vector<T> can provide a similar level of performance for POD objects when + used with appropriate care. In new code, consider std::vector<T> instead. +*/ template <typename T> class SkTDArray { public: SkTDArray() : fArray(nullptr), fReserve(0), fCount(0) {} @@ -365,7 +372,7 @@ private: SkASSERT_RELEASE( SkTFitsIn<int>(reserve) ); fReserve = SkTo<int>(reserve); - fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); + fArray = (T*)sk_realloc_throw(fArray, (size_t)fReserve * sizeof(T)); } }; diff --git a/chromium/third_party/skia/include/private/SkTemplates.h b/chromium/third_party/skia/include/private/SkTemplates.h index 477bbcb397f..1edf8120e4b 100644 --- a/chromium/third_party/skia/include/private/SkTemplates.h +++ b/chromium/third_party/skia/include/private/SkTemplates.h @@ -114,6 +114,10 @@ public: return fArray[index]; } + // aliases matching other types like std::vector + const T* data() const { return fArray; } + T* data() { return fArray; } + private: std::unique_ptr<T[]> fArray; SkDEBUGCODE(int fCount = 0;) @@ -203,6 +207,11 @@ public: return fArray[index]; } + // aliases matching other types like std::vector + const T* data() const { return fArray; } + T* data() { return fArray; } + size_t size() const { return fCount; } + private: #if defined(SK_BUILD_FOR_GOOGLE3) // Stack frame size is limited for SK_BUILD_FOR_GOOGLE3. 4k is less than the actual max, but some functions diff --git a/chromium/third_party/skia/include/third_party/skcms/skcms.h b/chromium/third_party/skia/include/third_party/skcms/skcms.h index 486844abae8..eec1442f7c1 100644 --- a/chromium/third_party/skia/include/third_party/skcms/skcms.h +++ b/chromium/third_party/skia/include/third_party/skcms/skcms.h @@ -307,6 +307,9 @@ SKCMS_API bool skcms_PrimariesToXYZD50(float rx, float ry, float wx, float wy, skcms_Matrix3x3* toXYZD50); +// Call before your first call to skcms_Transform() to skip runtime CPU detection. +SKCMS_API void skcms_DisableRuntimeCPUDetection(void); + // Utilities for programmatically constructing profiles static inline void skcms_Init(skcms_ICCProfile* p) { memset(p, 0, sizeof(*p)); diff --git a/chromium/third_party/skia/include/utils/SkCamera.h b/chromium/third_party/skia/include/utils/SkCamera.h index 1d018fb29a2..51a7d4d6b07 100644 --- a/chromium/third_party/skia/include/utils/SkCamera.h +++ b/chromium/third_party/skia/include/utils/SkCamera.h @@ -10,6 +10,7 @@ #ifndef SkCamera_DEFINED #define SkCamera_DEFINED +#include "include/core/SkM44.h" #include "include/core/SkMatrix.h" #include "include/private/SkNoncopyable.h" @@ -21,76 +22,17 @@ class SkCanvas; // DEPRECATED -struct SkUnit3D { - SkScalar fX, fY, fZ; - - void set(SkScalar x, SkScalar y, SkScalar z) { - fX = x; fY = y; fZ = z; - } - static SkScalar Dot(const SkUnit3D&, const SkUnit3D&); - static void Cross(const SkUnit3D&, const SkUnit3D&, SkUnit3D* cross); -}; - -// DEPRECATED -struct SkPoint3D { - SkScalar fX, fY, fZ; - - void set(SkScalar x, SkScalar y, SkScalar z) { - fX = x; fY = y; fZ = z; - } - SkScalar normalize(SkUnit3D*) const; -}; -typedef SkPoint3D SkVector3D; - -// DEPRECATED -struct SkMatrix3D { - SkScalar fMat[3][4]; - - void reset(); - - void setRow(int row, SkScalar a, SkScalar b, SkScalar c, SkScalar d = 0) { - SkASSERT((unsigned)row < 3); - fMat[row][0] = a; - fMat[row][1] = b; - fMat[row][2] = c; - fMat[row][3] = d; - } - - void setRotateX(SkScalar deg); - void setRotateY(SkScalar deg); - void setRotateZ(SkScalar deg); - void setTranslate(SkScalar x, SkScalar y, SkScalar z); - - void preRotateX(SkScalar deg); - void preRotateY(SkScalar deg); - void preRotateZ(SkScalar deg); - void preTranslate(SkScalar x, SkScalar y, SkScalar z); - - void setConcat(const SkMatrix3D& a, const SkMatrix3D& b); - void mapPoint(const SkPoint3D& src, SkPoint3D* dst) const; - void mapVector(const SkVector3D& src, SkVector3D* dst) const; - - void mapPoint(SkPoint3D* v) const { - this->mapPoint(*v, v); - } - - void mapVector(SkVector3D* v) const { - this->mapVector(*v, v); - } -}; - -// DEPRECATED class SkPatch3D { public: SkPatch3D(); void reset(); - void transform(const SkMatrix3D&, SkPatch3D* dst = nullptr) const; + void transform(const SkM44&, SkPatch3D* dst = nullptr) const; // dot a unit vector with the patch's normal SkScalar dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const; - SkScalar dotWith(const SkVector3D& v) const { - return this->dotWith(v.fX, v.fY, v.fZ); + SkScalar dotWith(const SkV3& v) const { + return this->dotWith(v.x, v.y, v.z); } // deprecated, but still here for animator (for now) @@ -99,8 +41,8 @@ public: private: public: // make public for SkDraw3D for now - SkVector3D fU, fV; - SkPoint3D fOrigin; + SkV3 fU, fV; + SkV3 fOrigin; friend class SkCamera3D; }; @@ -114,10 +56,10 @@ public: void update(); void patchToMatrix(const SkPatch3D&, SkMatrix* matrix) const; - SkPoint3D fLocation; // origin of the camera's space - SkPoint3D fAxis; // view direction - SkPoint3D fZenith; // up direction - SkPoint3D fObserver; // eye position (may not be the same as the origin) + SkV3 fLocation; // origin of the camera's space + SkV3 fAxis; // view direction + SkV3 fZenith; // up direction + SkV3 fObserver; // eye position (may not be the same as the origin) private: mutable SkMatrix fOrientation; @@ -154,8 +96,8 @@ public: private: struct Rec { - Rec* fNext; - SkMatrix3D fMatrix; + Rec* fNext; + SkM44 fMatrix; }; Rec* fRec; Rec fInitialRec; diff --git a/chromium/third_party/skia/include/utils/SkCustomTypeface.h b/chromium/third_party/skia/include/utils/SkCustomTypeface.h index 36640999898..61f32afed5e 100644 --- a/chromium/third_party/skia/include/utils/SkCustomTypeface.h +++ b/chromium/third_party/skia/include/utils/SkCustomTypeface.h @@ -8,6 +8,7 @@ #ifndef SkCustomTypeface_DEFINED #define SkCustomTypeface_DEFINED +#include "include/core/SkFontMetrics.h" #include "include/core/SkImage.h" #include "include/core/SkPaint.h" #include "include/core/SkPath.h" @@ -20,19 +21,21 @@ class SkStream; class SkCustomTypefaceBuilder { public: - SkCustomTypefaceBuilder(int numGlyphs); + SkCustomTypefaceBuilder(); void setGlyph(SkGlyphID, float advance, const SkPath&); void setGlyph(SkGlyphID, float advance, const SkPath&, const SkPaint&); void setGlyph(SkGlyphID, float advance, sk_sp<SkImage>, float scale); void setGlyph(SkGlyphID, float advance, sk_sp<SkPicture>); + void setMetrics(const SkFontMetrics& fm, float scale = 1); + sk_sp<SkTypeface> detach(); private: - int fGlyphCount; std::vector<SkPath> fPaths; std::vector<float> fAdvances; + SkFontMetrics fMetrics; static sk_sp<SkTypeface> Deserialize(SkStream*); diff --git a/chromium/third_party/skia/include/utils/SkRandom.h b/chromium/third_party/skia/include/utils/SkRandom.h index 0678010362a..ba40732b9cf 100644 --- a/chromium/third_party/skia/include/utils/SkRandom.h +++ b/chromium/third_party/skia/include/utils/SkRandom.h @@ -49,7 +49,7 @@ public: * Returns value [0...1) as an IEEE float */ float nextF() { - unsigned int floatint = 0x3f800000 | (this->nextU() >> 9); + int floatint = 0x3f800000 | (int)(this->nextU() >> 9); float f = SkBits2Float(floatint) - 1.0f; return f; } |