Only in skia: animations
Only in skia: bench
Only in skia: bin
Only in skia: build
Only in skia: BUILD.gn
Only in skia: build_overrides
Only in skia: buildtools
Only in skia: .clang-format
Only in skia: .clang-tidy
Only in skia: client_utils
Only in skia: codereview.settings
Only in skia: common
Only in skia: CONTRIBUTING
Only in skia: CQ_COMMITTERS
Only in skia: demos.skia.org
Only in skia: DEPS
Only in skia: dm
Only in skia: docker
Only in skia: docs
Only in skia: example
Only in skia: experimental
Only in skia: fuzz
Only in skia: .git
Only in skia: .gitignore
Only in skia: gm
Only in skia: .gn
Only in skia: gn
Only in skia: go.mod
Only in skia: go.sum
Only in skia/include: android
Only in skia/include: c
Only in skia/include: codec
diff --recursive --unified skia/include/config/SkUserConfig.h tiny-skia/skia/include/config/SkUserConfig.h
@@ -74,7 +74,7 @@
directories from your include search path when you're not building the GPU
backend. Defaults to 1 (build the GPU code).
*/
-//#define SK_SUPPORT_GPU 1
+#define SK_SUPPORT_GPU 0
/* Skia makes use of histogram logging macros to trace the frequency of
* events. By default, Skia provides no-op versions of these macros.
diff --recursive --unified skia/include/core/.directory tiny-skia/skia/include/core/.directory
@@ -1,5 +1,5 @@
[Dolphin]
-Timestamp=2020,6,29,15,42,46
+Timestamp=2020,6,29,15,52,49
Version=4
ViewMode=1
VisibleRoles=Icons_text,Icons_size
Only in skia/include/core: SkAnnotation.h
Only in skia/include/core: SkBBHFactory.h
diff --recursive --unified skia/include/core/SkCanvas.h tiny-skia/skia/include/core/SkCanvas.h
@@ -11,7 +11,6 @@
#include "include/core/SkBlendMode.h"
#include "include/core/SkClipOp.h"
#include "include/core/SkColor.h"
-#include "include/core/SkFontTypes.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkM44.h"
#include "include/core/SkMatrix.h"
@@ -32,15 +31,12 @@
#include <memory>
#include <vector>
-class GrContext;
-class GrRenderTargetContext;
class SkBaseDevice;
class SkBitmap;
class SkData;
class SkDrawable;
struct SkDrawShadowRec;
class SkFont;
-class SkGlyphRunBuilder;
class SkImage;
class SkImageFilter;
class SkMarkerStack;
@@ -281,14 +277,6 @@
*/
sk_sp<SkSurface> makeSurface(const SkImageInfo& info, const SkSurfaceProps* props = nullptr);
- /** Returns GPU context of the GPU surface associated with SkCanvas.
-
- @return GPU context, if available; nullptr otherwise
-
- example: https://fiddle.skia.org/c/@Canvas_getGrContext
- */
- virtual GrContext* getGrContext();
-
/** Sometimes a canvas is owned by a surface. If it is, getSurface() will return a bare
* pointer to that surface, else this will return nullptr.
*/
@@ -1951,453 +1939,6 @@
const SkPaint* paint = nullptr,
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
- /** Draws text, with origin at (x, y), using clip, SkMatrix, SkFont font,
- and SkPaint paint.
-
- When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or
- SkTextEncoding::kUTF32, this function uses the default
- character-to-glyph mapping from the SkTypeface in font. It does not
- perform typeface fallback for characters not found in the SkTypeface.
- It does not perform kerning or other complex shaping; glyphs are
- positioned based on their default advances.
-
- Text meaning depends on SkTextEncoding.
-
- Text size is affected by SkMatrix and SkFont text size. Default text
- size is 12 point.
-
- All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
- SkColorFilter, and SkImageFilter; apply to text. By
- default, draws filled black glyphs.
-
- @param text character code points or glyphs drawn
- @param byteLength byte length of text array
- @param encoding text encoding used in the text array
- @param x start of text on x-axis
- @param y start of text on y-axis
- @param font typeface, text size and so, used to describe the text
- @param paint blend, color, and so on, used to draw
- */
- void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding,
- SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint);
-
- /** Draws null terminated string, with origin at (x, y), using clip, SkMatrix,
- SkFont font, and SkPaint paint.
-
- This function uses the default character-to-glyph mapping from the
- SkTypeface in font. It does not perform typeface fallback for
- characters not found in the SkTypeface. It does not perform kerning;
- glyphs are positioned based on their default advances.
-
- String str is encoded as UTF-8.
-
- Text size is affected by SkMatrix and font text size. Default text
- size is 12 point.
-
- All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
- SkColorFilter, and SkImageFilter; apply to text. By
- default, draws filled black glyphs.
-
- @param str character code points drawn,
- ending with a char value of zero
- @param x start of string on x-axis
- @param y start of string on y-axis
- @param font typeface, text size and so, used to describe the text
- @param paint blend, color, and so on, used to draw
- */
- void drawString(const char str[], SkScalar x, SkScalar y, const SkFont& font,
- const SkPaint& paint) {
- this->drawSimpleText(str, strlen(str), SkTextEncoding::kUTF8, x, y, font, paint);
- }
-
- /** Draws SkString, with origin at (x, y), using clip, SkMatrix, SkFont font,
- and SkPaint paint.
-
- This function uses the default character-to-glyph mapping from the
- SkTypeface in font. It does not perform typeface fallback for
- characters not found in the SkTypeface. It does not perform kerning;
- glyphs are positioned based on their default advances.
-
- SkString str is encoded as UTF-8.
-
- Text size is affected by SkMatrix and SkFont text size. Default text
- size is 12 point.
-
- All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
- SkColorFilter, and SkImageFilter; apply to text. By
- default, draws filled black glyphs.
-
- @param str character code points drawn,
- ending with a char value of zero
- @param x start of string on x-axis
- @param y start of string on y-axis
- @param font typeface, text size and so, used to describe the text
- @param paint blend, color, and so on, used to draw
- */
- void drawString(const SkString& str, SkScalar x, SkScalar y, const SkFont& font,
- const SkPaint& paint) {
- this->drawSimpleText(str.c_str(), str.size(), SkTextEncoding::kUTF8, x, y, font, paint);
- }
-
- /** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
-
- blob contains glyphs, their positions, and paint attributes specific to text:
- SkTypeface, SkPaint text size, SkPaint text scale x,
- SkPaint text skew x, SkPaint::Align, SkPaint::Hinting, anti-alias, SkPaint fake bold,
- SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text,
- and SkPaint subpixel text.
-
- SkTextEncoding must be set to SkTextEncoding::kGlyphID.
-
- Elements of paint: anti-alias, SkBlendMode, color including alpha,
- 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.
-
- @param blob glyphs, positions, and their paints' text size, typeface, and so on
- @param x horizontal offset applied to blob
- @param y vertical offset applied to blob
- @param paint blend, color, stroking, and so on, used to draw
-
- example: https://fiddle.skia.org/c/@Canvas_drawTextBlob
- */
- void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
-
- /** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
-
- blob contains glyphs, their positions, and paint attributes specific to text:
- SkTypeface, SkPaint text size, SkPaint text scale x,
- SkPaint text skew x, SkPaint::Align, SkPaint::Hinting, anti-alias, SkPaint fake bold,
- SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text,
- and SkPaint subpixel text.
-
- SkTextEncoding must be set to SkTextEncoding::kGlyphID.
-
- Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter,
- 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
- @param y vertical offset applied to blob
- @param paint blend, color, stroking, and so on, used to draw
- */
- void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) {
- this->drawTextBlob(blob.get(), x, y, paint);
- }
-
- /** Draws SkPicture picture, using clip and SkMatrix.
- Clip and SkMatrix are unchanged by picture contents, as if
- save() was called before and restore() was called after drawPicture().
-
- SkPicture records a series of draw commands for later playback.
-
- @param picture recorded drawing commands to play
- */
- void drawPicture(const SkPicture* picture) {
- this->drawPicture(picture, nullptr, nullptr);
- }
-
- /** Draws SkPicture picture, using clip and SkMatrix.
- Clip and SkMatrix are unchanged by picture contents, as if
- save() was called before and restore() was called after drawPicture().
-
- SkPicture records a series of draw commands for later playback.
-
- @param picture recorded drawing commands to play
- */
- void drawPicture(const sk_sp<SkPicture>& picture) {
- this->drawPicture(picture.get());
- }
-
- /** Draws SkPicture picture, using clip and SkMatrix; transforming picture with
- SkMatrix matrix, if provided; and use SkPaint paint alpha, SkColorFilter,
- SkImageFilter, and SkBlendMode, if provided.
-
- If paint is non-null, then the picture is always drawn into a temporary layer before
- actually landing on the canvas. Note that drawing into a layer can also change its
- appearance if there are any non-associative blendModes inside any of the pictures elements.
-
- @param picture recorded drawing commands to play
- @param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
- @param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
-
- example: https://fiddle.skia.org/c/@Canvas_drawPicture_3
- */
- void drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
-
- /** Draws SkPicture picture, using clip and SkMatrix; transforming picture with
- SkMatrix matrix, if provided; and use SkPaint paint alpha, SkColorFilter,
- SkImageFilter, and SkBlendMode, if provided.
-
- If paint is non-null, then the picture is always drawn into a temporary layer before
- actually landing on the canvas. Note that drawing into a layer can also change its
- appearance if there are any non-associative blendModes inside any of the pictures elements.
-
- @param picture recorded drawing commands to play
- @param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
- @param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
- */
- void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix,
- const SkPaint* paint) {
- this->drawPicture(picture.get(), matrix, paint);
- }
-
- /** Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
- 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
- @param paint specifies the SkShader, used as SkVertices texture; may be nullptr
-
- example: https://fiddle.skia.org/c/@Canvas_drawVertices
- */
- void drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint);
-
- /** Variant of 3-parameter drawVertices, using the default of Modulate for the blend
- * parameter. Note that SkVertices that include per-vertex-data ignore this mode parameter.
- */
- void drawVertices(const SkVertices* vertices, const SkPaint& paint) {
- this->drawVertices(vertices, SkBlendMode::kModulate, paint);
- }
-
- /** Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
- 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
- @param paint specifies the SkShader, used as SkVertices texture, may be nullptr
-
- example: https://fiddle.skia.org/c/@Canvas_drawVertices_2
- */
- void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint);
-
- /** Variant of 3-parameter drawVertices, using the default of Modulate for the blend
- * parameter. Note that SkVertices that include per-vertex-data ignore this mode parameter.
- */
- void drawVertices(const sk_sp<SkVertices>& vertices, const SkPaint& paint) {
- this->drawVertices(vertices, SkBlendMode::kModulate, paint);
- }
-
- /** Draws a Coons patch: the interpolation of four cubics with shared corners,
- associating a color, and optionally a texture SkPoint, with each corner.
-
- Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
- alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated
- as Coons patch texture; SkBlendMode mode combines color colors and SkShader if
- both are provided.
-
- SkPoint array cubics specifies four SkPath cubic starting at the top-left corner,
- in clockwise order, sharing every fourth point. The last SkPath cubic ends at the
- first point.
-
- Color array color associates colors with corners in top-left, top-right,
- 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. 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
- @param texCoords SkPoint array of texture coordinates, mapping SkShader to corners;
- may be nullptr
- @param mode SkBlendMode for colors, and for SkShader if paint has one
- @param paint SkShader, SkColorFilter, SkBlendMode, used to draw
- */
- void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
-
- /** Draws SkPath cubic Coons patch: the interpolation of four cubics with shared corners,
- associating a color, and optionally a texture SkPoint, with each corner.
-
- Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
- alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated
- as Coons patch texture; SkBlendMode mode combines color colors and SkShader if
- both are provided.
-
- SkPoint array cubics specifies four SkPath cubic starting at the top-left corner,
- in clockwise order, sharing every fourth point. The last SkPath cubic ends at the
- first point.
-
- Color array color associates colors with corners in top-left, top-right,
- 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. 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
- @param texCoords SkPoint array of texture coordinates, mapping SkShader to corners;
- may be nullptr
- @param paint SkShader, SkColorFilter, SkBlendMode, used to draw
- */
- void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], const SkPaint& paint) {
- this->drawPatch(cubics, colors, texCoords, SkBlendMode::kModulate, paint);
- }
-
- /** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
- paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
- to draw, if present. For each entry in the array, SkRect tex locates sprite in
- atlas, and SkRSXform xform transforms it into destination space.
-
- xform, text, and colors if present, must contain count entries.
- Optional colors are applied for each sprite using SkBlendMode mode, treating
- sprite as source and colors as destination.
- Optional cullRect is a conservative bounds of all transformed sprites.
- If cullRect is outside of clip, canvas can skip drawing.
-
- If atlas is nullptr, this draws nothing.
-
- @param atlas SkImage containing sprites
- @param xform SkRSXform mappings for sprites in atlas
- @param tex SkRect locations of sprites in atlas
- @param colors one per sprite, blended with sprite using SkBlendMode; may be nullptr
- @param count number of sprites to draw
- @param mode SkBlendMode combining colors and sprites
- @param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
- @param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
- */
- void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
- const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
- const SkPaint* paint);
-
- /** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
- paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
- to draw, if present. For each entry in the array, SkRect tex locates sprite in
- atlas, and SkRSXform xform transforms it into destination space.
-
- xform, text, and colors if present, must contain count entries.
- Optional colors is applied for each sprite using SkBlendMode.
- Optional cullRect is a conservative bounds of all transformed sprites.
- If cullRect is outside of clip, canvas can skip drawing.
-
- @param atlas SkImage containing sprites
- @param xform SkRSXform mappings for sprites in atlas
- @param tex SkRect locations of sprites in atlas
- @param colors one per sprite, blended with sprite using SkBlendMode; may be nullptr
- @param count number of sprites to draw
- @param mode SkBlendMode combining colors and sprites
- @param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
- @param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
- */
- void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
- const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
- const SkPaint* paint) {
- this->drawAtlas(atlas.get(), xform, tex, colors, count, mode, cullRect, paint);
- }
-
- /** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
- paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
- to draw, if present. For each entry in the array, SkRect tex locates sprite in
- atlas, and SkRSXform xform transforms it into destination space.
-
- xform and text must contain count entries.
- Optional cullRect is a conservative bounds of all transformed sprites.
- If cullRect is outside of clip, canvas can skip drawing.
-
- @param atlas SkImage containing sprites
- @param xform SkRSXform mappings for sprites in atlas
- @param tex SkRect locations of sprites in atlas
- @param count number of sprites to draw
- @param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
- @param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
- */
- void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
- const SkRect* cullRect, const SkPaint* paint) {
- this->drawAtlas(atlas, xform, tex, nullptr, count, SkBlendMode::kDst, cullRect, paint);
- }
-
- /** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
- paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
- to draw, if present. For each entry in the array, SkRect tex locates sprite in
- atlas, and SkRSXform xform transforms it into destination space.
-
- xform and text must contain count entries.
- Optional cullRect is a conservative bounds of all transformed sprites.
- If cullRect is outside of clip, canvas can skip drawing.
-
- @param atlas SkImage containing sprites
- @param xform SkRSXform mappings for sprites in atlas
- @param tex SkRect locations of sprites in atlas
- @param count number of sprites to draw
- @param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
- @param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
- */
- void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
- int count, const SkRect* cullRect, const SkPaint* paint) {
- this->drawAtlas(atlas.get(), xform, tex, nullptr, count, SkBlendMode::kDst,
- cullRect, paint);
- }
-
- /** Draws SkDrawable drawable using clip and SkMatrix, concatenated with
- optional matrix.
-
- If SkCanvas has an asynchronous implementation, as is the case
- when it is recording into SkPicture, then drawable will be referenced,
- so that SkDrawable::draw() can be called when the operation is finalized. To force
- immediate drawing, call SkDrawable::draw() instead.
-
- @param drawable custom struct encapsulating drawing commands
- @param matrix transformation applied to drawing; may be nullptr
-
- example: https://fiddle.skia.org/c/@Canvas_drawDrawable
- */
- void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr);
-
- /** Draws SkDrawable drawable using clip and SkMatrix, offset by (x, y).
-
- If SkCanvas has an asynchronous implementation, as is the case
- when it is recording into SkPicture, then drawable will be referenced,
- so that SkDrawable::draw() can be called when the operation is finalized. To force
- immediate drawing, call SkDrawable::draw() instead.
-
- @param drawable custom struct encapsulating drawing commands
- @param x offset into SkCanvas writable pixels on x-axis
- @param y offset into SkCanvas writable pixels on y-axis
-
- example: https://fiddle.skia.org/c/@Canvas_drawDrawable_2
- */
- void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y);
-
- /** Associates SkRect on SkCanvas with an annotation; a key-value pair, where the key is
- a null-terminated UTF-8 string, and optional value is stored as SkData.
-
- Only some canvas implementations, such as recording to SkPicture, or drawing to
- document PDF, use annotations.
-
- @param rect SkRect extent of canvas to annotate
- @param key string used for lookup
- @param value data holding value stored in annotation
-
- example: https://fiddle.skia.org/c/@Canvas_drawAnnotation_2
- */
- void drawAnnotation(const SkRect& rect, const char key[], SkData* value);
-
- /** Associates SkRect on SkCanvas when an annotation; a key-value pair, where the key is
- a null-terminated UTF-8 string, and optional value is stored as SkData.
-
- Only some canvas implementations, such as recording to SkPicture, or drawing to
- document PDF, use annotations.
-
- @param rect SkRect extent of canvas to annotate
- @param key string used for lookup
- @param value data holding value stored in annotation
- */
- void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value) {
- this->drawAnnotation(rect, key, value.get());
- }
-
/** Returns true if clip is empty; that is, nothing will draw.
May do work when called; it should not be called
@@ -2439,23 +1980,14 @@
///////////////////////////////////////////////////////////////////////////
// don't call
- virtual GrRenderTargetContext* internal_private_accessTopLayerRenderTargetContext();
SkIRect internal_private_getTopLayerBounds() const { return getTopLayerBounds(); }
- // TEMP helpers until we switch virtual over to const& for src-rect
- void legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint,
- SrcRectConstraint constraint = kStrict_SrcRectConstraint);
-
/**
* Returns the global clip as a region. If the clip contains AA, then only the bounds
* of the clip may be returned.
*/
void temporary_internal_getRgnClip(SkRegion* region);
- void private_draw_shadow_rec(const SkPath&, const SkDrawShadowRec&);
-
-
protected:
// default impl defers to getDevice()->newSurface(info)
virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props);
@@ -2507,16 +2039,9 @@
virtual void onDrawPath(const SkPath& path, const SkPaint& paint);
virtual void onDrawRegion(const SkRegion& region, const SkPaint& paint);
- virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint);
-
- virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint);
- virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint);
virtual void onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, const SkPaint* paint);
virtual void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint);
@@ -2525,17 +2050,6 @@
virtual void onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
const SkPaint* paint);
- virtual void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
- const SkColor colors[], int count, SkBlendMode mode,
- const SkRect* cull, const SkPaint* paint);
-
- virtual void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value);
- virtual void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&);
-
- virtual void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix);
- virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
- const SkPaint* paint);
-
virtual void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
const SkColor4f& color, SkBlendMode mode);
virtual void onDrawEdgeAAImageSet(const ImageSetEntry imageSet[], int count,
@@ -2778,8 +2292,6 @@
void validateClip() const {}
#endif
- std::unique_ptr<SkGlyphRunBuilder> fScratchGlyphRunBuilder;
-
typedef SkRefCnt INHERITED;
};
diff --recursive --unified skia/include/core/SkCanvasVirtualEnforcer.h tiny-skia/skia/include/core/SkCanvasVirtualEnforcer.h
@@ -31,12 +31,6 @@
void onDrawPath(const SkPath& path, const SkPaint& paint) override = 0;
void onDrawRegion(const SkRegion& region, const SkPaint& paint) override = 0;
- void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) override = 0;
-
- void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode mode,
- const SkPaint& paint) override = 0;
void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) override = 0;
@@ -67,17 +61,6 @@
const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkPaint* paint,
SkCanvas::SrcRectConstraint constraint) override = 0;
#endif
-
- void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
- const SkColor colors[], int count, SkBlendMode mode, const SkRect* cull,
- const SkPaint* paint) override = 0;
-
- void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override = 0;
- void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override = 0;
-
- void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override = 0;
- void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
- const SkPaint* paint) override = 0;
};
#endif
diff --recursive --unified skia/include/core/SkColorFilter.h tiny-skia/skia/include/core/SkColorFilter.h
@@ -10,7 +10,6 @@
#include "include/core/SkBlendMode.h"
#include "include/core/SkColor.h"
-#include "include/core/SkFlattenable.h"
class SkColorMatrix;
@@ -22,7 +21,7 @@
* 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 {
+class SK_API SkColorFilter : public SkRefCnt {
public:
// DEPRECATED. skbug.com/8941
@@ -66,15 +65,9 @@
*/
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const;
- static SkFlattenable::Type GetFlattenableType() {
- return kSkColorFilter_Type;
- }
-
private:
SkColorFilter() = default;
friend class SkColorFilterBase;
-
- typedef SkFlattenable INHERITED;
};
class SK_API SkColorFilters {
diff --recursive --unified skia/include/core/SkColorSpace.h tiny-skia/skia/include/core/SkColorSpace.h
@@ -9,13 +9,12 @@
#define SkColorSpace_DEFINED
#include "include/core/SkRefCnt.h"
+#include "include/core/SkData.h"
#include "include/private/SkFixed.h"
#include "include/private/SkOnce.h"
#include "include/third_party/skcms/skcms.h"
#include <memory>
-class SkData;
-
/**
* Describes a color gamut with primaries and a white point.
*/
Only in skia/include/core: SkCubicMap.h
diff --recursive --unified skia/include/core/SkData.h tiny-skia/skia/include/core/SkData.h
@@ -115,30 +115,6 @@
static sk_sp<SkData> MakeFromMalloc(const void* data, size_t length);
/**
- * Create a new dataref the file with the specified path.
- * If the file cannot be opened, this returns NULL.
- */
- static sk_sp<SkData> MakeFromFileName(const char path[]);
-
- /**
- * Create a new dataref from a stdio FILE.
- * This does not take ownership of the FILE, nor close it.
- * The caller is free to close the FILE at its convenience.
- * The FILE must be open for reading only.
- * Returns NULL on failure.
- */
- static sk_sp<SkData> MakeFromFILE(FILE* f);
-
- /**
- * Create a new dataref from a file descriptor.
- * This does not take ownership of the file descriptor, nor close it.
- * The caller is free to close the file descriptor at its convenience.
- * The file descriptor must be open for reading only.
- * Returns NULL on failure.
- */
- static sk_sp<SkData> MakeFromFD(int fd);
-
- /**
* Attempt to read size bytes into a SkData. If the read succeeds, return the data,
* else return NULL. Either way the stream's cursor may have been changed as a result
* of calling read().
Only in skia/include/core: SkDeferredDisplayList.h
Only in skia/include/core: SkDeferredDisplayListRecorder.h
Only in skia/include/core: SkDocument.h
Only in skia/include/core: SkDrawable.h
Only in skia/include/core: SkDrawLooper.h
Only in skia/include/core: SkEncodedImageFormat.h
Only in skia/include/core: SkExecutor.h
Only in skia/include/core: SkFlattenable.h
Only in skia/include/core: SkFontArguments.h
Only in skia/include/core: SkFont.h
Only in skia/include/core: SkFontLCDConfig.h
Only in skia/include/core: SkFontMetrics.h
Only in skia/include/core: SkFontMgr.h
Only in skia/include/core: SkFontParameters.h
Only in skia/include/core: SkFontStyle.h
Only in skia/include/core: SkFontTypes.h
diff --recursive --unified skia/include/core/SkGraphics.h tiny-skia/skia/include/core/SkGraphics.h
@@ -11,7 +11,6 @@
#include "include/core/SkRefCnt.h"
class SkData;
-class SkImageGenerator;
class SkTraceMemoryDump;
class SK_API SkGraphics {
@@ -27,77 +26,6 @@
static void Term() {}
/**
- * Return the max number of bytes that should be used by the font cache.
- * If the cache needs to allocate more, it will purge previous entries.
- * This max can be changed by calling SetFontCacheLimit().
- */
- static size_t GetFontCacheLimit();
-
- /**
- * Specify the max number of bytes that should be used by the font cache.
- * If the cache needs to allocate more, it will purge previous entries.
- *
- * This function returns the previous setting, as if GetFontCacheLimit()
- * had be called before the new limit was set.
- */
- static size_t SetFontCacheLimit(size_t bytes);
-
- /**
- * Return the number of bytes currently used by the font cache.
- */
- static size_t GetFontCacheUsed();
-
- /**
- * Return the number of entries in the font cache.
- * A cache "entry" is associated with each typeface + pointSize + matrix.
- */
- static int GetFontCacheCountUsed();
-
- /**
- * Return the current limit to the number of entries in the font cache.
- * A cache "entry" is associated with each typeface + pointSize + matrix.
- */
- static int GetFontCacheCountLimit();
-
- /**
- * Set the limit to the number of entries in the font cache, and return
- * the previous value. If this new value is lower than the previous,
- * it will automatically try to purge entries to meet the new limit.
- */
- static int SetFontCacheCountLimit(int count);
-
- /*
- * Returns the maximum point size for text that may be cached.
- *
- * Sizes above this will be drawn directly from the font's outline.
- * Setting this to a large value may speed up drawing larger text (repeatedly),
- * but could cause the cache to purge other sizes more often.
- *
- * This value is a hint to the font engine, and the actual limit may be different due to
- * implementation specific details.
- */
- static int GetFontCachePointSizeLimit();
-
- /*
- * Set the maximum point size for text that may be cached, returning the previous value.
- *
- * Sizes above this will be drawn directly from the font's outline.
- * Setting this to a large value may speed up drawing larger text (repeatedly),
- * but could cause the cache to purge other sizes more often.
- *
- * This value is a hint to the font engine, and the actual limit may be different due to
- * implementation specific details.
- */
- static int SetFontCachePointSizeLimit(int maxPointSize);
-
- /**
- * For debugging purposes, this will attempt to purge the font cache. It
- * does not change the limit, but will cause subsequent font measures and
- * draws to be recreated, since they will no longer be in the cache.
- */
- static void PurgeFontCache();
-
- /**
* Scaling bitmaps with the kHigh_SkFilterQuality setting is
* expensive, so the result is saved in the global Scaled Image
* Cache.
@@ -132,41 +60,12 @@
static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit);
/**
- * Dumps memory usage of caches using the SkTraceMemoryDump interface. See SkTraceMemoryDump
- * for usage of this method.
- */
- static void DumpMemoryStatistics(SkTraceMemoryDump* dump);
-
- /**
* Free as much globally cached memory as possible. This will purge all private caches in Skia,
* including font and image caches.
*
* If there are caches associated with GPU context, those will not be affected by this call.
*/
static void PurgeAllCaches();
-
- /**
- * Applications with command line options may pass optional state, such
- * as cache sizes, here, for instance:
- * font-cache-limit=12345678
- *
- * The flags format is name=value[;name=value...] with no spaces.
- * This format is subject to change.
- */
- static void SetFlags(const char* flags);
-
- typedef std::unique_ptr<SkImageGenerator>
- (*ImageGeneratorFromEncodedDataFactory)(sk_sp<SkData>);
-
- /**
- * To instantiate images from encoded data, first looks at this runtime function-ptr. If it
- * exists, it is called to create an SkImageGenerator from SkData. If there is no function-ptr
- * or there is, but it returns NULL, then skia will call its internal default implementation.
- *
- * Returns the previous factory (which could be NULL).
- */
- static ImageGeneratorFromEncodedDataFactory
- SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory);
};
class SkAutoGraphics {
Only in skia/include/core: SkICC.h
Only in skia/include/core: SkImageEncoder.h
diff --recursive --unified skia/include/core/SkImageFilter.h tiny-skia/skia/include/core/SkImageFilter.h
@@ -9,9 +9,9 @@
#define SkImageFilter_DEFINED
#include "include/core/SkFilterQuality.h"
-#include "include/core/SkFlattenable.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
+#include "include/core/SkRefCnt.h"
class SkColorFilter;
@@ -28,7 +28,7 @@
* then it will be post transformed to match what would have been produced if the geometry were
* drawn with the total canvas matrix to begin with.
*/
-class SK_API SkImageFilter : public SkFlattenable {
+class SK_API SkImageFilter : public SkRefCnt {
public:
class CropRect {
public:
@@ -135,20 +135,6 @@
SkFilterQuality quality,
sk_sp<SkImageFilter> input);
- static SkFlattenable::Type GetFlattenableType() {
- return kSkImageFilter_Type;
- }
-
- SkFlattenable::Type getFlattenableType() const override {
- return kSkImageFilter_Type;
- }
-
- static sk_sp<SkImageFilter> Deserialize(const void* data, size_t size,
- const SkDeserialProcs* procs = nullptr) {
- return sk_sp<SkImageFilter>(static_cast<SkImageFilter*>(
- SkFlattenable::Deserialize(kSkImageFilter_Type, data, size, procs).release()));
- }
-
protected:
sk_sp<SkImageFilter> refMe() const {
@@ -157,8 +143,6 @@
private:
friend class SkImageFilter_Base;
-
- typedef SkFlattenable INHERITED;
};
#endif
Only in skia/include/core: SkImageGenerator.h
diff --recursive --unified skia/include/core/SkImage.h tiny-skia/skia/include/core/SkImage.h
@@ -8,14 +8,13 @@
#ifndef SkImage_DEFINED
#define SkImage_DEFINED
+#include "include/core/SkPixmap.h"
#include "include/core/SkFilterQuality.h"
-#include "include/core/SkImageEncoder.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkTileMode.h"
-#include "include/gpu/GrTypes.h"
#include <functional> // std::function
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
@@ -29,9 +28,6 @@
class SkPaint;
class SkPicture;
class SkSurface;
-class GrBackendTexture;
-class GrContext;
-class GrContextThreadSafeProxy;
struct SkYUVAIndex;
@@ -157,483 +153,15 @@
static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator,
const SkIRect* subset = nullptr);
- /**
- * Return an image backed by the encoded data, but attempt to defer decoding until the image
- * is actually used/drawn. This deferral allows the system to cache the result, either on the
- * CPU or on the GPU, depending on where the image is drawn. If memory is low, the cache may
- * be purged, causing the next draw of the image to have to re-decode.
- *
- * The subset parameter specifies a area within the decoded image to create the image from.
- * If subset is null, then the entire image is returned.
- *
- * This is similar to DecodeTo[Raster,Texture], but this method will attempt to defer the
- * actual decode, while the DecodeTo... method explicitly decode and allocate the backend
- * when the call is made.
- *
- * If the encoded format is not supported, or subset is outside of the bounds of the decoded
- * image, nullptr is returned.
- *
- * @param encoded the encoded data
- * @param length the number of bytes of encoded data
- * @param subset the bounds of the pixels within the decoded image to return. may be null.
- * @return created SkImage, or nullptr
-
- example: https://fiddle.skia.org/c/@Image_MakeFromEncoded
- */
- static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr);
-
- /**
- * Decode the data in encoded/length into a raster image.
- *
- * The subset parameter specifies a area within the decoded image to create the image from.
- * If subset is null, then the entire image is returned.
- *
- * This is similar to MakeFromEncoded, but this method will always decode immediately, and
- * allocate the memory for the pixels for the lifetime of the returned image.
- *
- * If the encoded format is not supported, or subset is outside of the bounds of the decoded
- * image, nullptr is returned.
- *
- * @param encoded the encoded data
- * @param length the number of bytes of encoded data
- * @param subset the bounds of the pixels within the decoded image to return. may be null.
- * @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> DecodeToRaster(const void* encoded, size_t length,
- const SkIRect* subset = nullptr);
- static sk_sp<SkImage> DecodeToRaster(const sk_sp<SkData>& data,
- const SkIRect* subset = nullptr) {
- return DecodeToRaster(data->data(), data->size(), subset);
- }
-
- /**
- * Decode the data in encoded/length into a texture-backed image.
- *
- * The subset parameter specifies a area within the decoded image to create the image from.
- * If subset is null, then the entire image is returned.
- *
- * This is similar to MakeFromEncoded, but this method will always decode immediately, and
- * allocate the texture for the pixels for the lifetime of the returned image.
- *
- * If the encoded format is not supported, or subset is outside of the bounds of the decoded
- * image, nullptr is returned.
- *
- * @param encoded the encoded data
- * @param length the number of bytes of encoded data
- * @param subset the bounds of the pixels within the decoded image to return. may be null.
- * @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> DecodeToTexture(GrContext* ctx, const void* encoded, size_t length,
- const SkIRect* subset = nullptr);
- static sk_sp<SkImage> DecodeToTexture(GrContext* ctx, const sk_sp<SkData>& data,
- const SkIRect* subset = nullptr) {
- return DecodeToTexture(ctx, data->data(), data->size(), subset);
- }
-
- /*
- * Experimental:
- * Skia | GL_COMPRESSED_* | MTLPixelFormat* | VK_FORMAT_*_BLOCK
- * --------------------------------------------------------------------------------------
- * kETC2_RGB8_UNORM | ETC1_RGB8 | ETC2_RGB8 (iOS-only) | ETC2_R8G8B8_UNORM
- * | RGB8_ETC2 | |
- * --------------------------------------------------------------------------------------
- * kBC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | N/A | BC1_RGB_UNORM
- * --------------------------------------------------------------------------------------
- * kBC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA (macOS-only)| BC1_RGBA_UNORM
- */
- enum class CompressionType {
- kNone,
- kETC2_RGB8_UNORM, // the same as ETC1
-
- kBC1_RGB8_UNORM,
- kBC1_RGBA8_UNORM,
- kLast = kBC1_RGBA8_UNORM,
- };
-
- static constexpr int kCompressionTypeCount = static_cast<int>(CompressionType::kLast) + 1;
-
- static const CompressionType kETC1_CompressionType = CompressionType::kETC2_RGB8_UNORM;
-
- /** Creates a GPU-backed SkImage from compressed data.
-
- This method will return an SkImage representing the compressed data.
- If the GPU doesn't support the specified compression method, the data
- will be decompressed and then wrapped in a GPU-backed image.
-
- Note: one can query the supported compression formats via
- GrContext::compressedBackendFormat.
-
- @param context GPU context
- @param data compressed data to store in SkImage
- @param width width of full SkImage
- @param height height of full SkImage
- @param type type of compression used
- @param mipMapped does 'data' contain data for all the mipmap levels?
- @param isProtected do the contents of 'data' require DRM protection (on Vulkan)?
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeTextureFromCompressed(GrContext* context,
- sk_sp<SkData> data,
- int width, int height,
- CompressionType type,
- GrMipMapped mipMapped = GrMipMapped::kNo,
- GrProtected isProtected = GrProtected::kNo);
- /** To be deprecated. Use MakeTextureFromCompressed.
- */
- static sk_sp<SkImage> MakeFromCompressed(GrContext* context,
- sk_sp<SkData> data,
- int width, int height,
- CompressionType type,
- GrMipMapped mipMapped = GrMipMapped::kNo,
- GrProtected isProtected = GrProtected::kNo) {
- return MakeTextureFromCompressed(context, data, width, height, type,
- mipMapped, isProtected);
-
- }
-
- /** Creates a CPU-backed SkImage from compressed data.
-
- This method will decompress the compressed data and create an image wrapping
- it. Any mipmap levels present in the compressed data are discarded.
-
- @param data compressed data to store in SkImage
- @param width width of full SkImage
- @param height height of full SkImage
- @param type type of compression used
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeRasterFromCompressed(sk_sp<SkData> data,
- int width, int height,
- CompressionType type);
-
/** User function called when supplied texture may be deleted.
*/
typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
- /** Creates SkImage from GPU texture associated with context. Caller is responsible for
- managing the lifetime of GPU texture.
-
- SkImage is returned if format of backendTexture is recognized and supported.
- Recognized formats vary by GPU back-end.
-
- @param context GPU context
- @param backendTexture texture residing on GPU
- @param colorSpace range of colors; may be nullptr
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromTexture(GrContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin,
- SkColorType colorType,
- SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace) {
- return MakeFromTexture(context, backendTexture, origin, colorType, alphaType, colorSpace,
- nullptr, nullptr);
- }
-
- /** Creates SkImage from GPU texture associated with context. GPU texture must stay
- valid and unchanged until textureReleaseProc is called. textureReleaseProc is
- passed releaseContext when SkImage is deleted or no longer refers to texture.
-
- SkImage is returned if format of backendTexture is recognized and supported.
- Recognized formats vary by GPU back-end.
-
- @param context GPU context
- @param backendTexture texture residing on GPU
- @param colorSpace This describes the color space of this image's contents, as
- seen after sampling. In general, if the format of the backend
- texture is SRGB, some linear colorSpace should be supplied
- (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the
- backend texture is linear, then the colorSpace should include
- a description of the transfer function as
- well (e.g., SkColorSpace::MakeSRGB()).
- @param textureReleaseProc function called when texture can be released
- @param releaseContext state passed to textureReleaseProc
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromTexture(GrContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin,
- SkColorType colorType,
- SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace,
- TextureReleaseProc textureReleaseProc,
- ReleaseContext releaseContext);
-
- /** Creates an SkImage from a GPU backend texture. The backend texture must stay
- valid and unchanged until textureReleaseProc is called. The textureReleaseProc is
- called when the SkImage is deleted or no longer refers to the texture and will be
- passed the releaseContext.
-
- An SkImage is returned if the format of backendTexture is recognized and supported.
- Recognized formats vary by GPU back-end.
-
- @param context the GPU context
- @param backendTexture a texture already allocated by the GPU
- @param alphaType This characterizes the nature of the alpha values in the
- backend texture. For opaque compressed formats (e.g., ETC1)
- this should usually be set to kOpaque_SkAlphaType.
- @param colorSpace This describes the color space of this image's contents, as
- seen after sampling. In general, if the format of the backend
- texture is SRGB, some linear colorSpace should be supplied
- (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the
- backend texture is linear, then the colorSpace should include
- a description of the transfer function as
- well (e.g., SkColorSpace::MakeSRGB()).
- @param textureReleaseProc function called when the backend texture can be released
- @param releaseContext state passed to textureReleaseProc
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromCompressedTexture(GrContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin,
- SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
- /** Creates SkImage from pixmap. SkImage is uploaded to GPU back-end using context.
-
- Created SkImage is available to other GPU contexts, and is available across thread
- boundaries. All contexts must be in the same GPU share group, or otherwise
- share resources.
-
- When SkImage is no longer referenced, context releases texture memory
- asynchronously.
-
- GrBackendTexture created from pixmap is uploaded to match SkSurface created with
- dstColorSpace. SkColorSpace of SkImage is determined by pixmap.colorSpace().
-
- SkImage is returned referring to GPU back-end if context is not nullptr,
- format of data is recognized and supported, and if context supports moving
- resources between contexts. Otherwise, pixmap pixel data is copied and SkImage
- as returned in raster format if possible; nullptr may be returned.
- Recognized GPU formats vary by platform and GPU back-end.
-
- @param context GPU context
- @param pixmap SkImageInfo, pixel address, and row bytes
- @param buildMips create SkImage as mip map if true
- @param dstColorSpace range of colors of matching SkSurface on GPU
- @param limitToMaxTextureSize downscale image to GPU maximum texture size, if necessary
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap,
- bool buildMips,
- bool limitToMaxTextureSize = false);
-
- /** Creates SkImage from backendTexture associated with context. backendTexture and
- returned SkImage are managed internally, and are released when no longer needed.
-
- SkImage is returned if format of backendTexture is recognized and supported.
- Recognized formats vary by GPU back-end.
-
- @param context GPU context
- @param backendTexture texture residing on GPU
- @param colorSpace range of colors; may be nullptr
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin surfaceOrigin,
- SkColorType colorType,
- SkAlphaType alphaType = kPremul_SkAlphaType,
- sk_sp<SkColorSpace> colorSpace = nullptr);
-
- /** Creates an SkImage by flattening the specified YUVA planes into a single, interleaved RGBA
- image.
-
- @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
- */
- static sk_sp<SkImage> MakeFromYUVATexturesCopy(GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- SkISize imageSize,
- GrSurfaceOrigin imageOrigin,
- sk_sp<SkColorSpace> imageColorSpace = nullptr);
-
- /** Creates an SkImage by flattening the specified YUVA planes into a single, interleaved RGBA
- image. 'backendTexture' is used to store the result of the flattening.
-
- @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 backendTexture the resource that stores the final pixels
- @param imageColorSpace range of colors of the resulting image; may be nullptr
- @param textureReleaseProc function called when backendTexture can be released
- @param releaseContext state passed to textureReleaseProc
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromYUVATexturesCopyWithExternalBackend(
- GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- SkISize imageSize,
- GrSurfaceOrigin imageOrigin,
- const GrBackendTexture& backendTexture,
- sk_sp<SkColorSpace> imageColorSpace = nullptr,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
- /** Creates an SkImage by storing the specified YUVA planes into an image, to be rendered
- via multitexturing.
-
- 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,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- SkISize imageSize,
- GrSurfaceOrigin imageOrigin,
- 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.
-
- Each GrBackendTexture created from yuvaPixmaps array is uploaded to match SkSurface
- using SkColorSpace of SkPixmap. SkColorSpace of SkImage is determined by imageColorSpace.
-
- SkImage is returned referring to GPU back-end if context is not nullptr and
- format of data is recognized and supported. Otherwise, nullptr is returned.
- Recognized GPU formats vary by platform and GPU back-end.
-
- @param context GPU context
- @param yuvColorSpace How the YUV values are converted to RGB
- @param yuvaPixmaps array of (up to four) SkPixmap which contain the,
- possibly interleaved, YUVA planes
- @param yuvaIndices array indicating which pixmap in yuvaPixmaps, and channel
- in that pixmap, maps to each component of YUVA.
- @param imageSize size of the resulting image
- @param imageOrigin origin of the resulting image.
- @param buildMips create internal YUVA textures as mip map if true
- @param limitToMaxTextureSize downscale image to GPU maximum texture size, if necessary
- @param imageColorSpace range of colors of the resulting image; may be nullptr
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromYUVAPixmaps(
- GrContext* context, SkYUVColorSpace yuvColorSpace, const SkPixmap yuvaPixmaps[],
- const SkYUVAIndex yuvaIndices[4], SkISize imageSize, GrSurfaceOrigin imageOrigin,
- bool buildMips, bool limitToMaxTextureSize = false,
- sk_sp<SkColorSpace> imageColorSpace = nullptr);
-
- /** To be deprecated.
- */
- static sk_sp<SkImage> MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvTextures[3],
- GrSurfaceOrigin imageOrigin,
- sk_sp<SkColorSpace> imageColorSpace = nullptr);
-
- /** To be deprecated.
- */
- static sk_sp<SkImage> MakeFromYUVTexturesCopyWithExternalBackend(
- GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvTextures[3],
- GrSurfaceOrigin imageOrigin,
- const GrBackendTexture& backendTexture,
- sk_sp<SkColorSpace> imageColorSpace = nullptr);
-
- /** Creates SkImage from copy of nv12Textures, an array of textures on GPU.
- nv12Textures[0] contains pixels for YUV component y plane.
- nv12Textures[1] contains pixels for YUV component u plane,
- followed by pixels for YUV component v plane.
- Returned SkImage has the dimensions nv12Textures[2].
- yuvColorSpace describes how YUV colors convert to RGB colors.
-
- @param context GPU context
- @param yuvColorSpace How the YUV values are converted to RGB
- @param nv12Textures array of YUV textures on GPU
- @param imageColorSpace range of colors; may be nullptr
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromNV12TexturesCopy(GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture nv12Textures[2],
- GrSurfaceOrigin imageOrigin,
- sk_sp<SkColorSpace> imageColorSpace = nullptr);
-
- /** Creates SkImage from copy of nv12Textures, an array of textures on GPU.
- nv12Textures[0] contains pixels for YUV component y plane.
- nv12Textures[1] contains pixels for YUV component u plane,
- followed by pixels for YUV component v plane.
- Returned SkImage has the dimensions nv12Textures[2] and stores pixels in backendTexture.
- yuvColorSpace describes how YUV colors convert to RGB colors.
-
- @param context GPU context
- @param yuvColorSpace How the YUV values are converted to RGB
- @param nv12Textures array of YUV textures on GPU
- @param backendTexture the resource that stores the final pixels
- @param imageColorSpace range of colors; may be nullptr
- @param textureReleaseProc function called when backendTexture can be released
- @param releaseContext state passed to textureReleaseProc
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromNV12TexturesCopyWithExternalBackend(
- GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture nv12Textures[2],
- GrSurfaceOrigin imageOrigin,
- const GrBackendTexture& backendTexture,
- sk_sp<SkColorSpace> imageColorSpace = nullptr,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
enum class BitDepth {
kU8, //!< uses 8-bit unsigned int per color component
kF16, //!< uses 16-bit float per color component
};
- /** Creates SkImage from picture. Returned SkImage width and height are set by dimensions.
- SkImage draws picture with matrix and paint, set to bitDepth and colorSpace.
-
- If matrix is nullptr, draws with identity SkMatrix. If paint is nullptr, draws
- with default SkPaint. colorSpace may be nullptr.
-
- @param picture stream of drawing commands
- @param dimensions width and height
- @param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
- @param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
- @param bitDepth 8-bit integer or 16-bit float: per component
- @param colorSpace range of colors; may be nullptr
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
- const SkMatrix* matrix, const SkPaint* paint,
- BitDepth bitDepth,
- sk_sp<SkColorSpace> colorSpace);
-
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
/** (See Skia bug 7447)
Creates SkImage from Android hardware buffer.
@@ -817,65 +345,6 @@
*/
bool peekPixels(SkPixmap* pixmap) const;
- /** Returns true the contents of SkImage was created on or uploaded to GPU memory,
- and is available as a GPU texture.
-
- @return true if SkImage is a GPU texture
-
- example: https://fiddle.skia.org/c/@Image_isTextureBacked
- */
- bool isTextureBacked() const;
-
- /** Returns true if SkImage can be drawn on either raster surface or GPU surface.
- If context is nullptr, tests if SkImage draws on raster surface;
- otherwise, tests if SkImage draws on GPU surface associated with context.
-
- SkImage backed by GPU texture may become invalid if associated GrContext is
- invalid. lazy image may be invalid and may not draw to raster surface or
- GPU surface or both.
-
- @param context GPU context
- @return true if SkImage can be drawn
-
- example: https://fiddle.skia.org/c/@Image_isValid
- */
- bool isValid(GrContext* context) const;
-
- /** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
- texture-backed (including promise texture images) or if the the GrContext does not
- have the same context ID as the context backing the image then this is a no-op.
-
- If the image was not used in any non-culled draws recorded on the passed GrContext then
- this is a no-op unless the GrFlushInfo contains semaphores, a finish proc, or uses
- kSyncCpu_GrFlushFlag. Those are respected even when the image has not been used.
-
- @param context the context on which to flush pending usages of the image.
- @param info flush options
- */
- GrSemaphoresSubmitted flush(GrContext* context, const GrFlushInfo& flushInfo);
-
- /** 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
- is valid.
-
- If flushPendingGrContextIO is true, completes deferred I/O operations.
-
- If origin in not nullptr, copies location of content drawn into SkImage.
-
- @param flushPendingGrContextIO flag to flush outstanding requests
- @return back-end API texture handle; invalid on failure
- */
- GrBackendTexture getBackendTexture(bool flushPendingGrContextIO,
- GrSurfaceOrigin* origin = nullptr) const;
-
/** \enum SkImage::CachingHint
CachingHint selects whether Skia may internally cache SkBitmap generated by
decoding SkImage, or by copying SkImage from GPU to CPU. The default behavior
@@ -987,56 +456,6 @@
bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality,
CachingHint cachingHint = kAllow_CachingHint) const;
- /** Encodes SkImage pixels, returning result as SkData.
-
- Returns nullptr if encoding fails, or if encodedImageFormat is not supported.
-
- SkImage encoding in a format requires both building with one or more of:
- SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP; and platform support
- for the encoded format.
-
- If SK_BUILD_FOR_MAC or SK_BUILD_FOR_IOS is defined, encodedImageFormat can
- additionally be one of: SkEncodedImageFormat::kICO, SkEncodedImageFormat::kBMP,
- SkEncodedImageFormat::kGIF.
-
- quality is a platform and format specific metric trading off size and encoding
- error. When used, quality equaling 100 encodes with the least error. quality may
- be ignored by the encoder.
-
- @param encodedImageFormat one of: SkEncodedImageFormat::kJPEG, SkEncodedImageFormat::kPNG,
- SkEncodedImageFormat::kWEBP
- @param quality encoder specific metric with 100 equaling best
- @return encoded SkImage, or nullptr
-
- example: https://fiddle.skia.org/c/@Image_encodeToData
- */
- sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const;
-
- /** Encodes SkImage pixels, returning result as SkData. Returns existing encoded data
- if present; otherwise, SkImage is encoded with SkEncodedImageFormat::kPNG. Skia
- must be built with SK_ENCODE_PNG to encode SkImage.
-
- Returns nullptr if existing encoded data is missing or invalid, and
- encoding fails.
-
- @return encoded SkImage, or nullptr
-
- example: https://fiddle.skia.org/c/@Image_encodeToData_2
- */
- sk_sp<SkData> encodeToData() const;
-
- /** Returns encoded SkImage pixels as SkData, if SkImage was created from supported
- encoded stream format. Platform support for formats vary and may require building
- with one or more of: SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP.
-
- Returns nullptr if SkImage contents are not encoded.
-
- @return encoded SkImage, or nullptr
-
- example: https://fiddle.skia.org/c/@Image_refEncodedData
- */
- sk_sp<SkData> refEncodedData() const;
-
/** Returns subset of SkImage. subset must be fully contained by SkImage dimensions().
The implementation may share pixels, or may copy them.
@@ -1050,30 +469,6 @@
*/
sk_sp<SkImage> makeSubset(const SkIRect& subset) const;
- /** Returns SkImage backed by GPU texture associated with context. Returned SkImage is
- compatible with SkSurface created with dstColorSpace. The returned SkImage respects
- mipMapped setting; if mipMapped equals GrMipMapped::kYes, the backing texture
- allocates mip map levels.
-
- The mipMapped parameter is effectively treated as kNo if MIP maps are not supported by the
- GPU.
-
- Returns original SkImage if the image is already texture-backed, the context matches, and
- mipMapped is compatible with the backing GPU texture. SkBudgeted is ignored in this case.
-
- Returns nullptr if context is nullptr, or if SkImage was created with another
- GrContext.
-
- @param GrContext GPU context
- @param GrMipMapped whether created SkImage texture must allocate mip map levels
- @param SkBudgeted whether to count a newly created texture for the returned image
- counts against the GrContext's budget.
- @return created SkImage, or nullptr
- */
- sk_sp<SkImage> makeTextureImage(GrContext*,
- GrMipMapped = GrMipMapped::kNo,
- SkBudgeted = SkBudgeted::kYes) const;
-
/** Returns raster image or lazy image. Copies SkImage backed by GPU texture into
CPU memory if needed. Returns original SkImage if decoded in raster bitmap,
or if encoded in a stream.
@@ -1086,86 +481,12 @@
*/
sk_sp<SkImage> makeNonTextureImage() const;
- /** Returns raster image. Copies SkImage backed by GPU texture into CPU memory,
- or decodes SkImage from lazy image. Returns original SkImage if decoded in
- raster bitmap.
-
- Returns nullptr if copy, decode, or pixel read fails.
-
- If cachingHint is kAllow_CachingHint, pixels may be retained locally.
- If cachingHint is kDisallow_CachingHint, pixels are not added to the local cache.
-
- @return raster image, or nullptr
-
- example: https://fiddle.skia.org/c/@Image_makeRasterImage
- */
- sk_sp<SkImage> makeRasterImage(CachingHint cachingHint = kDisallow_CachingHint) const;
-
- /** Creates filtered SkImage. filter processes original SkImage, potentially changing
- color, position, and size. subset is the bounds of original SkImage processed
- by filter. clipBounds is the expected bounds of the filtered SkImage. outSubset
- is required storage for the actual bounds of the filtered SkImage. offset is
- required storage for translation of returned SkImage.
-
- Returns nullptr if SkImage could not be created. If nullptr is returned, outSubset
- and offset are undefined.
-
- Useful for animation of SkImageFilter that varies size from frame to frame.
- Returned SkImage is created larger than required by filter so that GPU texture
- can be reused with different sized effects. outSubset describes the valid bounds
- of GPU texture returned. offset translates the returned SkImage to keep subsequent
- animation frames aligned with respect to each other.
-
- @param context the GrContext in play - if it exists
- @param filter how SkImage is sampled when transformed
- @param subset bounds of SkImage processed by filter
- @param clipBounds expected bounds of filtered SkImage
- @param outSubset storage for returned SkImage bounds
- @param offset storage for returned SkImage translation
- @return filtered SkImage, or nullptr
- */
- sk_sp<SkImage> makeWithFilter(GrContext* context,
- const SkImageFilter* filter, const SkIRect& subset,
- const SkIRect& clipBounds, SkIRect* outSubset,
- SkIPoint* offset) const;
-
/** To be deprecated.
*/
sk_sp<SkImage> makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
const SkIRect& clipBounds, SkIRect* outSubset,
SkIPoint* offset) const;
- /** Defines a callback function, taking one parameter of type GrBackendTexture with
- no return value. Function is called when back-end texture is to be released.
- */
- typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc;
-
- /** Creates a GrBackendTexture from the provided SkImage. Returns true and
- stores result in backendTexture and backendTextureReleaseProc if
- texture is created; otherwise, returns false and leaves
- backendTexture and backendTextureReleaseProc unmodified.
-
- Call backendTextureReleaseProc after deleting backendTexture.
- backendTextureReleaseProc cleans up auxiliary data related to returned
- backendTexture. The caller must delete returned backendTexture after use.
-
- If SkImage is both texture backed and singly referenced, image is returned in
- backendTexture without conversion or making a copy. SkImage is singly referenced
- if its was transferred solely using std::move().
-
- If SkImage is not texture backed, returns texture with SkImage contents.
-
- @param context GPU context
- @param image SkImage used for texture
- @param backendTexture storage for back-end texture
- @param backendTextureReleaseProc storage for clean up function
- @return true if back-end texture was created
- */
- static bool MakeBackendTextureFromSkImage(GrContext* context,
- sk_sp<SkImage> image,
- GrBackendTexture* backendTexture,
- BackendTextureReleaseProc* backendTextureReleaseProc);
-
/** Deprecated.
*/
enum LegacyBitmapMode {
diff --recursive --unified skia/include/core/SkMaskFilter.h tiny-skia/skia/include/core/SkMaskFilter.h
@@ -10,7 +10,7 @@
#include "include/core/SkBlurTypes.h"
#include "include/core/SkCoverageMode.h"
-#include "include/core/SkFlattenable.h"
+#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
class SkMatrix;
@@ -21,7 +21,7 @@
SkMaskFilter is the base class for object that perform transformations on
the mask before drawing it. An example subclass is Blur.
*/
-class SK_API SkMaskFilter : public SkFlattenable {
+class SK_API SkMaskFilter : public SkRefCnt {
public:
/** Create a blur maskfilter.
* @param style The SkBlurStyle to use
@@ -31,25 +31,6 @@
*/
static sk_sp<SkMaskFilter> MakeBlur(SkBlurStyle style, SkScalar sigma,
bool respectCTM = true);
-
- static SkFlattenable::Type GetFlattenableType() {
- return kSkMaskFilter_Type;
- }
-
- SkFlattenable::Type getFlattenableType() const override {
- return kSkMaskFilter_Type;
- }
-
- static sk_sp<SkMaskFilter> Deserialize(const void* data, size_t size,
- const SkDeserialProcs* procs = nullptr) {
- return sk_sp<SkMaskFilter>(static_cast<SkMaskFilter*>(
- SkFlattenable::Deserialize(
- kSkMaskFilter_Type, data, size, procs).release()));
- }
-
-private:
- static void RegisterFlattenables();
- friend class SkFlattenable;
};
#endif
Only in skia/include/core: SkMilestone.h
Only in skia/include/core: SkOverdrawCanvas.h
diff --recursive --unified skia/include/core/SkPathEffect.h tiny-skia/skia/include/core/SkPathEffect.h
@@ -8,10 +8,10 @@
#ifndef SkPathEffect_DEFINED
#define SkPathEffect_DEFINED
-#include "include/core/SkFlattenable.h"
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
+#include "include/core/SkRefCnt.h"
class SkPath;
class SkStrokeRec;
@@ -24,7 +24,7 @@
Dashing is implemented as a subclass of SkPathEffect.
*/
-class SK_API SkPathEffect : public SkFlattenable {
+class SK_API SkPathEffect : public SkRefCnt {
public:
/**
* Returns a patheffect that apples each effect (first and second) to the original path,
@@ -144,23 +144,6 @@
DashType asADash(DashInfo* info) const;
- static void RegisterFlattenables();
-
- static SkFlattenable::Type GetFlattenableType() {
- return kSkPathEffect_Type;
- }
-
- SkFlattenable::Type getFlattenableType() const override {
- return kSkPathEffect_Type;
- }
-
- static sk_sp<SkPathEffect> Deserialize(const void* data, size_t size,
- const SkDeserialProcs* procs = nullptr) {
- return sk_sp<SkPathEffect>(static_cast<SkPathEffect*>(
- SkFlattenable::Deserialize(
- kSkPathEffect_Type, data, size, procs).release()));
- }
-
protected:
SkPathEffect() {}
@@ -180,8 +163,6 @@
// illegal
SkPathEffect(const SkPathEffect&);
SkPathEffect& operator=(const SkPathEffect&);
-
- typedef SkFlattenable INHERITED;
};
#endif
diff --recursive --unified skia/include/core/SkPath.h tiny-skia/skia/include/core/SkPath.h
@@ -1644,50 +1644,6 @@
};
- /** Returns true if the point (x, y) is contained by SkPath, taking into
- account FillType.
-
- @param x x-axis value of containment test
- @param y y-axis value of containment test
- @return true if SkPoint is in SkPath
-
- example: https://fiddle.skia.org/c/@Path_contains
- */
- bool contains(SkScalar x, SkScalar y) const;
-
- /** Writes text representation of SkPath to stream. If stream is nullptr, writes to
- standard output. Set forceClose to true to get edges used to fill SkPath.
- Set dumpAsHex true to generate exact binary representations
- of floating point numbers used in SkPoint array and conic weights.
-
- @param stream writable SkWStream receiving SkPath text representation; may be nullptr
- @param forceClose true if missing kClose_Verb is output
- @param dumpAsHex true if SkScalar values are written as hexadecimal
-
- example: https://fiddle.skia.org/c/@Path_dump
- */
- void dump(SkWStream* stream, bool forceClose, bool dumpAsHex) const;
-
- /** Writes text representation of SkPath to standard output. The representation may be
- directly compiled as C++ code. Floating point values are written
- with limited precision; it may not be possible to reconstruct original SkPath
- from output.
-
- example: https://fiddle.skia.org/c/@Path_dump_2
- */
- void dump() const;
-
- /** Writes text representation of SkPath to standard output. The representation may be
- directly compiled as C++ code. Floating point values are written
- in hexadecimal to preserve their exact bit pattern. The output reconstructs the
- original SkPath.
-
- Use instead of dump() when submitting
-
- example: https://fiddle.skia.org/c/@Path_dumpHex
- */
- void dumpHex() const;
-
/** Writes SkPath to buffer, returning the number of bytes written.
Pass nullptr to obtain the storage size.
Only in skia/include/core: SkPicture.h
Only in skia/include/core: SkPictureRecorder.h
diff --recursive --unified skia/include/core/SkPixelRef.h tiny-skia/skia/include/core/SkPixelRef.h
@@ -22,7 +22,6 @@
struct SkIRect;
-class GrTexture;
class SkDiscardableMemory;
/** \class SkPixelRef
@@ -116,7 +115,6 @@
friend class SkSurface_Raster; // For the two methods above.
void setImmutableWithID(uint32_t genID);
- friend void SkBitmapCache_setImmutableWithID(SkPixelRef*, uint32_t);
typedef SkRefCnt INHERITED;
};
Only in skia/include/core: SkPngChunkReader.h
Only in skia/include/core: SkPromiseImageTexture.h
diff --recursive --unified skia/include/core/SkRect.h tiny-skia/skia/include/core/SkRect.h
@@ -1312,31 +1312,6 @@
@return pointer to fLeft
*/
const SkScalar* asScalars() const { return &fLeft; }
-
- /** Writes text representation of SkRect to standard output. Set asHex to true to
- generate exact binary representations of floating point numbers.
-
- @param asHex true if SkScalar values are written as hexadecimal
-
- example: https://fiddle.skia.org/c/@Rect_dump
- */
- void dump(bool asHex) const;
-
- /** Writes text representation of SkRect to standard output. The representation may be
- directly compiled as C++ code. Floating point values are written
- with limited precision; it may not be possible to reconstruct original SkRect
- from output.
- */
- void dump() const { this->dump(false); }
-
- /** Writes text representation of SkRect to standard output. The representation may be
- directly compiled as C++ code. Floating point values are written
- in hexadecimal to preserve their exact bit pattern. The output reconstructs the
- original SkRect.
-
- Use instead of dump() when submitting
- */
- void dumpHex() const { this->dump(true); }
};
inline bool SkIRect::contains(const SkRect& r) const {
diff --recursive --unified skia/include/core/SkRRect.h tiny-skia/skia/include/core/SkRRect.h
@@ -466,30 +466,6 @@
*/
bool transform(const SkMatrix& matrix, SkRRect* dst) const;
- /** Writes text representation of SkRRect to standard output.
- Set asHex true to generate exact binary representations
- of floating point numbers.
-
- @param asHex true if SkScalar values are written as hexadecimal
-
- example: https://fiddle.skia.org/c/@RRect_dump
- */
- void dump(bool asHex) const;
-
- /** Writes text representation of SkRRect to standard output. The representation
- may be directly compiled as C++ code. Floating point values are written
- with limited precision; it may not be possible to reconstruct original
- SkRRect from output.
- */
- void dump() const { this->dump(false); }
-
- /** Writes text representation of SkRRect to standard output. The representation
- may be directly compiled as C++ code. Floating point values are written
- in hexadecimal to preserve their exact bit pattern. The output reconstructs the
- original SkRRect.
- */
- void dumpHex() const { this->dump(true); }
-
private:
static bool AreRectAndRadiiValid(const SkRect&, const SkVector[4]);
Only in skia/include/core: SkRWBuffer.h
diff --recursive --unified skia/include/core/SkSerialProcs.h tiny-skia/skia/include/core/SkSerialProcs.h
@@ -9,8 +9,6 @@
#define SkSerialProcs_DEFINED
#include "include/core/SkImage.h"
-#include "include/core/SkPicture.h"
-#include "include/core/SkTypeface.h"
/**
* A serial-proc is asked to serialize the specified object (e.g. picture or image).
@@ -24,7 +22,6 @@
typedef sk_sp<SkData> (*SkSerialPictureProc)(SkPicture*, void* ctx);
typedef sk_sp<SkData> (*SkSerialImageProc)(SkImage*, void* ctx);
-typedef sk_sp<SkData> (*SkSerialTypefaceProc)(SkTypeface*, void* ctx);
/**
* Called with the encoded form of a picture (previously written with a custom
@@ -41,12 +38,6 @@
*/
typedef sk_sp<SkImage> (*SkDeserialImageProc)(const void* data, size_t length, void* ctx);
-/**
- * Called with the encoded form of a typeface (previously written with a custom
- * SkSerialTypefaceProc proc). Return a typeface object, or nullptr indicating failure.
- */
-typedef sk_sp<SkTypeface> (*SkDeserialTypefaceProc)(const void* data, size_t length, void* ctx);
-
struct SK_API SkSerialProcs {
SkSerialPictureProc fPictureProc = nullptr;
void* fPictureCtx = nullptr;
@@ -54,7 +45,6 @@
SkSerialImageProc fImageProc = nullptr;
void* fImageCtx = nullptr;
- SkSerialTypefaceProc fTypefaceProc = nullptr;
void* fTypefaceCtx = nullptr;
};
@@ -65,7 +55,6 @@
SkDeserialImageProc fImageProc = nullptr;
void* fImageCtx = nullptr;
- SkDeserialTypefaceProc fTypefaceProc = nullptr;
void* fTypefaceCtx = nullptr;
};
diff --recursive --unified skia/include/core/SkShader.h tiny-skia/skia/include/core/SkShader.h
@@ -11,7 +11,6 @@
#include "include/core/SkBlendMode.h"
#include "include/core/SkColor.h"
#include "include/core/SkFilterQuality.h"
-#include "include/core/SkFlattenable.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkTileMode.h"
@@ -24,8 +23,6 @@
class SkPath;
class SkPicture;
class SkRasterPipeline;
-class GrContext;
-class GrFragmentProcessor;
/** \class SkShader
*
@@ -37,7 +34,7 @@
* w/o having to modify the original shader... only the paint's alpha needs
* to be modified.
*/
-class SK_API SkShader : public SkFlattenable {
+class SK_API SkShader : public SkRefCnt {
public:
/**
* Returns true if the shader is guaranteed to produce only opaque
@@ -130,8 +127,6 @@
private:
SkShader() = default;
friend class SkShaderBase;
-
- typedef SkFlattenable INHERITED;
};
class SK_API SkShaders {
diff --recursive --unified skia/include/core/SkStream.h tiny-skia/skia/include/core/SkStream.h
@@ -43,11 +43,6 @@
virtual ~SkStream() {}
SkStream() {}
- /**
- * Attempts to open the specified file as a stream, returns nullptr on failure.
- */
- static std::unique_ptr<SkStreamAsset> MakeFromFile(const char path[]);
-
/** Reads or skips size number of bytes.
* If buffer == NULL, skip size bytes, return how many were skipped.
* If buffer != NULL, copy size bytes into buffer, return how many were copied.
@@ -296,70 +291,6 @@
////////////////////////////////////////////////////////////////////////////////////////
-#include <stdio.h>
-
-/** A stream that wraps a C FILE* file stream. */
-class SK_API SkFILEStream : public SkStreamAsset {
-public:
- /** Initialize the stream by calling sk_fopen on the specified path.
- * This internal stream will be closed in the destructor.
- */
- explicit SkFILEStream(const char path[] = nullptr);
-
- /** Initialize the stream with an existing C FILE stream.
- * The current position of the C FILE stream will be considered the
- * beginning of the SkFILEStream.
- * The C FILE stream will be closed in the destructor.
- */
- explicit SkFILEStream(FILE* file);
-
- ~SkFILEStream() override;
-
- static std::unique_ptr<SkFILEStream> Make(const char path[]) {
- std::unique_ptr<SkFILEStream> stream(new SkFILEStream(path));
- return stream->isValid() ? std::move(stream) : nullptr;
- }
-
- /** Returns true if the current path could be opened. */
- bool isValid() const { return fFILE != nullptr; }
-
- /** Close this SkFILEStream. */
- void close();
-
- size_t read(void* buffer, size_t size) override;
- bool isAtEnd() const override;
-
- bool rewind() override;
- std::unique_ptr<SkStreamAsset> duplicate() const {
- return std::unique_ptr<SkStreamAsset>(this->onDuplicate());
- }
-
- size_t getPosition() const override;
- bool seek(size_t position) override;
- bool move(long offset) override;
-
- std::unique_ptr<SkStreamAsset> fork() const {
- return std::unique_ptr<SkStreamAsset>(this->onFork());
- }
-
- size_t getLength() const override;
-
-private:
- explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset);
- explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset, size_t originalOffset);
-
- SkStreamAsset* onDuplicate() const override;
- SkStreamAsset* onFork() const override;
-
- std::shared_ptr<FILE> fFILE;
- // My own council will I keep on sizes and offsets.
- size_t fSize;
- size_t fOffset;
- size_t fOriginalOffset;
-
- typedef SkStreamAsset INHERITED;
-};
-
class SK_API SkMemoryStream : public SkStreamMemory {
public:
SkMemoryStream();
@@ -435,26 +366,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////
-class SK_API SkFILEWStream : public SkWStream {
-public:
- SkFILEWStream(const char path[]);
- ~SkFILEWStream() override;
-
- /** Returns true if the current path could be opened.
- */
- bool isValid() const { return fFILE != nullptr; }
-
- bool write(const void* buffer, size_t size) override;
- void flush() override;
- void fsync();
- size_t bytesWritten() const override;
-
-private:
- FILE* fFILE;
-
- typedef SkWStream INHERITED;
-};
-
class SK_API SkDynamicMemoryWStream : public SkWStream {
public:
SkDynamicMemoryWStream() = default;
diff --recursive --unified skia/include/core/SkString.h tiny-skia/skia/include/core/SkString.h
@@ -192,7 +192,7 @@
void insert(size_t offset, const SkString& src) { this->insert(offset, src.c_str(), src.size()); }
void insert(size_t offset, const char text[]);
void insert(size_t offset, const char text[], size_t len);
- void insertUnichar(size_t offset, SkUnichar);
+// void insertUnichar(size_t offset, SkUnichar);
void insertS32(size_t offset, int32_t value);
void insertS64(size_t offset, int64_t value, int minDigits = 0);
void insertU32(size_t offset, uint32_t value);
@@ -203,7 +203,7 @@
void append(const SkString& str) { this->insert((size_t)-1, str); }
void append(const char text[]) { this->insert((size_t)-1, text); }
void append(const char text[], size_t len) { this->insert((size_t)-1, text, len); }
- void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); }
+// void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); }
void appendS32(int32_t value) { this->insertS32((size_t)-1, value); }
void appendS64(int64_t value, int minDigits = 0) { this->insertS64((size_t)-1, value, minDigits); }
void appendU32(uint32_t value) { this->insertU32((size_t)-1, value); }
@@ -214,7 +214,7 @@
void prepend(const SkString& str) { this->insert(0, str); }
void prepend(const char text[]) { this->insert(0, text); }
void prepend(const char text[], size_t len) { this->insert(0, text, len); }
- void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); }
+// void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); }
void prependS32(int32_t value) { this->insertS32(0, value); }
void prependS64(int32_t value, int minDigits = 0) { this->insertS64(0, value, minDigits); }
void prependHex(uint32_t value, int minDigits = 0) { this->insertHex(0, value, minDigits); }
Only in skia/include/core: SkSurfaceCharacterization.h
diff --recursive --unified skia/include/core/SkSurface.h tiny-skia/skia/include/core/SkSurface.h
@@ -12,27 +12,13 @@
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceProps.h"
-#include "include/gpu/GrTypes.h"
-
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
#include <android/hardware_buffer.h>
#endif
-#ifdef SK_METAL
-#include "include/gpu/mtl/GrMtlTypes.h"
-#endif
-
class SkCanvas;
class SkDeferredDisplayList;
class SkPaint;
-class SkSurfaceCharacterization;
-class GrBackendRenderTarget;
-class GrBackendSemaphore;
-class GrBackendSurfaceMutableState;
-class GrBackendTexture;
-class GrContext;
-class GrRecordingContext;
-class GrRenderTarget;
/** \class SkSurface
SkSurface is responsible for managing the pixels that a canvas draws into. The pixels can be
@@ -173,315 +159,6 @@
/** User function called when supplied texture may be deleted. */
typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
- /** Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture 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, 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
- @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
- @param textureReleaseProc function called when texture can be released
- @param releaseContext state passed to textureReleaseProc
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin, int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
- /** Wraps a GPU-backed buffer into SkSurface. Caller must ensure backendRenderTarget
- is valid for the lifetime of returned SkSurface.
-
- SkSurface is returned if all parameters are valid. backendRenderTarget is valid if
- its pixel configuration agrees with colorSpace and context; for instance, if
- backendRenderTarget has an sRGB configuration, then context must support sRGB,
- and colorSpace must be present. Further, backendRenderTarget width and height must
- 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
- @param backendRenderTarget GPU intermediate memory buffer
- @param colorSpace range of colors
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @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,
- const GrBackendRenderTarget& backendRenderTarget,
- GrSurfaceOrigin origin,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- RenderTargetReleaseProc releaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
-#if GR_TEST_UTILS
- // TODO: Remove this.
- static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps);
-#endif
-
-#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
- /** Private.
- Creates SkSurface from Android hardware buffer.
- Returned SkSurface takes a reference on the buffer. The ref on the buffer will be released
- when the SkSurface is destroyed and there is no pending work on the GPU involving the
- buffer.
-
- Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
-
- Currently this is only supported for buffers that can be textured as well as rendered to.
- In other words that must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and
- AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
-
- @param context GPU context
- @param hardwareBuffer AHardwareBuffer Android hardware buffer
- @param colorSpace range of colors; may be nullptr
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @return created SkSurface, or nullptr
- */
- static sk_sp<SkSurface> MakeFromAHardwareBuffer(GrContext* context,
- AHardwareBuffer* hardwareBuffer,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps);
-#endif
-
-#ifdef SK_METAL
- /** Creates SkSurface from CAMetalLayer.
- Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be
- released when the SkSurface is destroyed.
-
- Only available when Metal API is enabled.
-
- Will grab the current drawable from the layer and use its texture as a backendRT to
- create a renderable surface.
-
- @param context GPU context
- @param layer GrMTLHandle (expected to be a CAMetalLayer*)
- @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
- @param drawable Pointer to drawable to be filled in when this surface is
- instantiated; may not be nullptr
- @return created SkSurface, or nullptr
- */
- static sk_sp<SkSurface> MakeFromCAMetalLayer(GrContext* context,
- GrMTLHandle layer,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- GrMTLHandle* drawable)
- SK_API_AVAILABLE_CA_METAL_LAYER;
-
- /** Creates SkSurface from MTKView.
- Returned SkSurface takes a reference on the MTKView. The ref on the layer will be
- released when the SkSurface is destroyed.
-
- Only available when Metal API is enabled.
-
- Will grab the current drawable from the layer and use its texture as a backendRT to
- create a renderable surface.
-
- @param context GPU context
- @param layer GrMTLHandle (expected to be a MTKView*)
- @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 created SkSurface, or nullptr
- */
- static sk_sp<SkSurface> MakeFromMTKView(GrContext* context,
- GrMTLHandle mtkView,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps)
- SK_API_AVAILABLE(macos(10.11), ios(9.0));
-#endif
-
- /** Returns SkSurface on GPU indicated by context. Allocates memory for
- pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
- selects whether allocation for pixels is tracked by context. imageInfo
- describes the pixel format in SkColorType, and transparency in
- SkAlphaType, and color matching in SkColorSpace.
-
- sampleCount requests the number of samples per pixel.
- Pass zero to disable multi-sample anti-aliasing. The request is rounded
- up to the next supported count, or rounded down if it is larger than the
- maximum supported count.
-
- surfaceOrigin pins either the top-left or the bottom-left corner to the origin.
-
- shouldCreateWithMips hints that SkImage returned by makeImageSnapshot() is mip map.
-
- If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
-
- @param context GPU context
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace;
- width, or height, or both, may be zero
- @param sampleCount samples per pixel, or 0 to disable full scene anti-aliasing
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @param shouldCreateWithMips hint that SkSurface will host mip map images
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
- const SkImageInfo& imageInfo,
- int sampleCount, GrSurfaceOrigin surfaceOrigin,
- const SkSurfaceProps* surfaceProps,
- bool shouldCreateWithMips = false);
-
- /** Returns SkSurface on GPU indicated by context. Allocates memory for
- pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
- selects whether allocation for pixels is tracked by context. imageInfo
- describes the pixel format in SkColorType, and transparency in
- SkAlphaType, and color matching in SkColorSpace.
-
- sampleCount requests the number of samples per pixel.
- Pass zero to disable multi-sample anti-aliasing. The request is rounded
- up to the next supported count, or rounded down if it is larger than the
- maximum supported count.
-
- SkSurface bottom-left corner is pinned to the origin.
-
- @param context GPU context
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width, or height, or both, may be zero
- @param sampleCount samples per pixel, or 0 to disable multi-sample anti-aliasing
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
- const SkImageInfo& imageInfo, int sampleCount,
- const SkSurfaceProps* surfaceProps) {
- return MakeRenderTarget(context, budgeted, imageInfo, sampleCount,
- kBottomLeft_GrSurfaceOrigin, surfaceProps);
- }
-
- /** Returns SkSurface on GPU indicated by context. Allocates memory for
- pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
- selects whether allocation for pixels is tracked by context. imageInfo
- describes the pixel format in SkColorType, and transparency in
- SkAlphaType, and color matching in SkColorSpace.
-
- SkSurface bottom-left corner is pinned to the origin.
-
- @param context GPU context
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width, or height, or both, may be zero
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
- const SkImageInfo& imageInfo) {
- if (!imageInfo.width() || !imageInfo.height()) {
- return nullptr;
- }
- return MakeRenderTarget(context, budgeted, imageInfo, 0, kBottomLeft_GrSurfaceOrigin,
- nullptr);
- }
-
- /** Returns SkSurface on GPU indicated by context that is compatible with the provided
- characterization. budgeted selects whether allocation for pixels is tracked by context.
-
- @param context GPU context
- @param characterization description of the desired SkSurface
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
- const SkSurfaceCharacterization& characterization,
- SkBudgeted budgeted);
-
- /** Wraps a backend texture in an SkSurface - setting up the surface to match the provided
- characterization. The caller must ensure the texture is valid for the lifetime of
- returned SkSurface.
-
- If the backend texture and surface characterization are incompatible then null will
- be returned.
-
- Usually, the GrContext::createBackendTexture variant that takes a surface characterization
- should be used to create the backend texture. If not,
- 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
- @param textureReleaseProc function called when texture can be released
- @param releaseContext state passed to textureReleaseProc
- @return SkSurface if all parameters are compatible; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context,
- const SkSurfaceCharacterization& characterzation,
- const GrBackendTexture& backendTexture,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
- /** Is this surface compatible with the provided characterization?
-
- This method can be used to determine if an existing SkSurface is a viable destination
- for an SkDeferredDisplayList.
-
- @param characterization The characterization for which a compatibility check is desired
- @return true if this surface is compatible with the characterization;
- false otherwise
- */
- bool isCompatible(const SkSurfaceCharacterization& characterization) const;
-
- /** Returns SkSurface without backing pixels. Drawing to SkCanvas returned from SkSurface
- has no effect. Calling makeImageSnapshot() on returned SkSurface returns nullptr.
-
- @param width one or greater
- @param height one or greater
- @return SkSurface if width and height are positive; otherwise, nullptr
-
- example: https://fiddle.skia.org/c/@Surface_MakeNull
- */
- static sk_sp<SkSurface> MakeNull(int width, int height);
-
/** Returns pixel count in each row; may be zero or greater.
@return number of pixel columns
@@ -525,12 +202,6 @@
*/
void notifyContentWillChange(ContentChangeMode mode);
- /** Returns the GPU context of the GPU surface.
-
- @return GPU context, if available; nullptr otherwise
- */
- GrContext* getContext();
-
enum BackendHandleAccess {
kFlushRead_BackendHandleAccess, //!< back-end object is readable
kFlushWrite_BackendHandleAccess, //!< back-end object is writable
@@ -552,48 +223,6 @@
static const BackendHandleAccess kDiscardWrite_TextureHandleAccess =
kDiscardWrite_BackendHandleAccess;
- /** Retrieves the back-end texture. If SkSurface has no back-end texture, an invalid
- object is returned. Call GrBackendTexture::isValid to determine if the result
- is valid.
-
- The returned GrBackendTexture should be discarded if the SkSurface is drawn to or deleted.
-
- @return GPU texture reference; invalid on failure
- */
- GrBackendTexture getBackendTexture(BackendHandleAccess backendHandleAccess);
-
- /** Retrieves the back-end render target. If SkSurface has no back-end render target, an invalid
- object is returned. Call GrBackendRenderTarget::isValid to determine if the result
- is valid.
-
- The returned GrBackendRenderTarget should be discarded if the SkSurface is drawn to
- or deleted.
-
- @return GPU render target reference; invalid on failure
- */
- GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess backendHandleAccess);
-
- /** If the surface was made via MakeFromBackendTexture then it's backing texture may be
- substituted with a different texture. The contents of the previous backing texture are
- copied into the new texture. SkCanvas state is preserved. The original sample count is
- 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
- @param releaseContext state passed to textureReleaseProc
- */
- bool replaceBackendTexture(const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin,
- ContentChangeMode mode = kRetain_ContentChangeMode,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
/** Returns SkCanvas that draws into SkSurface. Subsequent calls return the same SkCanvas.
SkCanvas returned is managed and owned by SkSurface, and is deleted when SkSurface
is deleted.
@@ -769,108 +398,6 @@
*/
bool readPixels(const SkBitmap& dst, int srcX, int srcY);
- /** The result from asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420(). */
- class AsyncReadResult {
- public:
- AsyncReadResult(const AsyncReadResult&) = delete;
- AsyncReadResult(AsyncReadResult&&) = delete;
- AsyncReadResult& operator=(const AsyncReadResult&) = delete;
- AsyncReadResult& operator=(AsyncReadResult&&) = delete;
-
- virtual ~AsyncReadResult() = default;
- virtual int count() const = 0;
- virtual const void* data(int i) const = 0;
- virtual size_t rowBytes(int i) const = 0;
-
- protected:
- AsyncReadResult() = default;
- };
-
- /** Client-provided context that is passed to client-provided ReadPixelsContext. */
- using ReadPixelsContext = void*;
-
- /** Client-provided callback to asyncRescaleAndReadPixels() or
- asyncRescaleAndReadPixelsYUV420() that is called when read result is ready or on failure.
- */
- using ReadPixelsCallback = void(ReadPixelsContext, std::unique_ptr<const AsyncReadResult>);
-
- /** Controls the gamma that rescaling occurs in for asyncRescaleAndReadPixels() and
- asyncRescaleAndReadPixelsYUV420().
- */
- enum RescaleGamma : bool { kSrc, kLinear };
-
- /** Makes surface pixel data available to caller, possibly asynchronously. It can also rescale
- the surface pixels.
-
- Currently asynchronous reads are only supported on the GPU backend and only when the
- underlying 3D API supports transfer buffers and CPU/GPU synchronization primitives. In all
- other cases this operates synchronously.
-
- Data is read from the source sub-rectangle, is optionally converted to a linear gamma, is
- rescaled to the size indicated by 'info', is then converted to the color space, color type,
- and alpha type of 'info'. A 'srcRect' that is not contained by the bounds of the surface
- causes failure.
-
- 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. 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
- or destroyed.
-
- @param info info of the requested pixels
- @param srcRect subrectangle of surface to read
- @param rescaleGamma controls whether rescaling is done in the surface's gamma or whether
- the source data is transformed to a linear gamma before rescaling.
- @param rescaleQuality controls the quality (and cost) of the rescaling
- @param callback function to call with result of the read
- @param context passed to callback
- */
- void asyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect,
- RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality,
- ReadPixelsCallback callback, ReadPixelsContext context);
-
- /**
- Similar to asyncRescaleAndReadPixels but performs an additional conversion to YUV. The
- RGB->YUV conversion is controlled by 'yuvColorSpace'. The YUV data is returned as three
- planes ordered y, u, v. The u and v planes are half the width and height of the resized
- rectangle. The y, u, and v values are single bytes. Currently this fails if 'dstSize'
- width and height are not even. A 'srcRect' that is not contained by the bounds of the
- surface causes failure.
-
- 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. 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
- or destroyed.
-
- @param yuvColorSpace The transformation from RGB to YUV. Applied to the resized image
- after it is converted to dstColorSpace.
- @param dstColorSpace The color space to convert the resized image to, after rescaling.
- @param srcRect The portion of the surface to rescale and convert to YUV planes.
- @param dstSize The size to rescale srcRect to
- @param rescaleGamma controls whether rescaling is done in the surface's gamma or whether
- the source data is transformed to a linear gamma before rescaling.
- @param rescaleQuality controls the quality (and cost) of the rescaling
- @param callback function to call with the planar read result
- @param context passed to callback
- */
- void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
- sk_sp<SkColorSpace> dstColorSpace,
- const SkIRect& srcRect,
- const SkISize& dstSize,
- RescaleGamma rescaleGamma,
- SkFilterQuality rescaleQuality,
- ReadPixelsCallback callback,
- ReadPixelsContext);
-
/** Copies SkRect of pixels from the src SkPixmap to the SkSurface.
Source SkRect corners are (0, 0) and (src.width(), src.height()).
@@ -925,134 +452,6 @@
kPresent, //!< back-end surface will be used for presenting to screen
};
- /** 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.
-
- If BackendSurfaceAccess::kNoAccess is passed in all commands will be issued to the GPU.
-
- If BackendSurfaceAccess::kPresent is passed in and the backend API is not Vulkan, it is
- treated the same as kNoAccess. If the backend API is Vulkan, the VkImage that backs the
- SkSurface will be transferred back to its original queue. If the SkSurface was created by
- wrapping a VkImage, the queue will be set to the queue which was originally passed in on
- the GrVkImageInfo. Additionally, if the original queue was not external or foreign the
- layout of the VkImage will be set to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
-
- 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 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 access type of access the call will do on the backend object after flush
- @param info flush options
- */
- GrSemaphoresSubmitted flush(BackendSurfaceAccess access, const GrFlushInfo& info);
-
- /** 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 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 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
- underlying semaphores and delete them once they have been signaled and waited on.
- If this call returns false, then the GPU back-end will not wait on any passed in semaphores,
- and the client will still own the semaphores.
-
- @param numSemaphores size of waitSemaphores array
- @param waitSemaphores array of semaphore containers
- @return true if GPU is waiting on semaphores
- */
- bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
-
- /** Initializes SkSurfaceCharacterization that can be used to perform GPU back-end
- processing in a separate thread. Typically this is used to divide drawing
- into multiple tiles. SkDeferredDisplayListRecorder records the drawing commands
- for each tile.
-
- Return true if SkSurface supports characterization. raster surface returns false.
-
- @param characterization properties for parallel drawing
- @return true if supported
-
- example: https://fiddle.skia.org/c/@Surface_characterize
- */
- bool characterize(SkSurfaceCharacterization* characterization) const;
-
- /** Draws deferred display list created using SkDeferredDisplayListRecorder.
- Has no effect and returns false if SkSurfaceCharacterization stored in
- deferredDisplayList is not compatible with SkSurface.
-
- raster surface returns false.
-
- @param deferredDisplayList drawing commands
- @return false if deferredDisplayList is not compatible
-
- example: https://fiddle.skia.org/c/@Surface_draw_2
- */
- bool draw(SkDeferredDisplayList* deferredDisplayList);
-
protected:
SkSurface(int width, int height, const SkSurfaceProps* surfaceProps);
SkSurface(const SkImageInfo& imageInfo, const SkSurfaceProps* surfaceProps);
Only in skia/include/core: SkSwizzle.h
Only in skia/include/core: SkTextBlob.h
Only in skia/include/core: SkTime.h
Only in skia/include/core: SkTraceMemoryDump.h
Only in skia/include/core: SkTypeface.h
diff --recursive --unified skia/include/core/SkTypes.h tiny-skia/skia/include/core/SkTypes.h
@@ -417,10 +417,6 @@
# define SK_HISTOGRAM_ENUMERATION(name, value, boundary_value)
#endif
-#ifndef SK_DISABLE_LEGACY_SHADERCONTEXT
-#define SK_ENABLE_LEGACY_SHADERCONTEXT
-#endif
-
#ifdef SK_ENABLE_API_AVAILABLE
#define SK_API_AVAILABLE API_AVAILABLE
#else
diff --recursive --unified skia/include/core/SkYUVASizeInfo.h tiny-skia/skia/include/core/SkYUVASizeInfo.h
@@ -8,7 +8,6 @@
#ifndef SkYUVASizeInfo_DEFINED
#define SkYUVASizeInfo_DEFINED
-#include "include/codec/SkEncodedOrigin.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkSize.h"
@@ -35,7 +34,7 @@
* YUVA data often comes from formats like JPEG that support EXIF orientation.
* Code that operates on the raw YUV data often needs to know that orientation.
*/
- SkEncodedOrigin fOrigin = kDefault_SkEncodedOrigin;
+// SkEncodedOrigin fOrigin = kDefault_SkEncodedOrigin;
bool operator==(const SkYUVASizeInfo& that) const {
for (int i = 0; i < kMaxCount; ++i) {
Only in skia/include: docs
Only in skia/include/effects: Sk1DPathEffect.h
Only in skia/include/effects: Sk2DPathEffect.h
Only in skia/include/effects: SkAlphaThresholdFilter.h
Only in skia/include/effects: SkArithmeticImageFilter.h
Only in skia/include/effects: SkBlurDrawLooper.h
Only in skia/include/effects: SkBlurImageFilter.h
Only in skia/include/effects: SkBlurMaskFilter.h
Only in skia/include/effects: SkColorFilterImageFilter.h
Only in skia/include/effects: SkColorMatrixFilter.h
Only in skia/include/effects: SkComposeImageFilter.h
Only in skia/include/effects: SkCornerPathEffect.h
Only in skia/include/effects: SkDiscretePathEffect.h
Only in skia/include/effects: SkDisplacementMapEffect.h
Only in skia/include/effects: SkDropShadowImageFilter.h
Only in skia/include/effects: SkHighContrastFilter.h
Only in skia/include/effects: SkImageFilters.h
Only in skia/include/effects: SkImageSource.h
Only in skia/include/effects: SkLayerDrawLooper.h
Only in skia/include/effects: SkLightingImageFilter.h
Only in skia/include/effects: SkLumaColorFilter.h
Only in skia/include/effects: SkMagnifierImageFilter.h
Only in skia/include/effects: SkMatrixConvolutionImageFilter.h
Only in skia/include/effects: SkMergeImageFilter.h
Only in skia/include/effects: SkMorphologyImageFilter.h
Only in skia/include/effects: SkOffsetImageFilter.h
Only in skia/include/effects: SkOpPathEffect.h
Only in skia/include/effects: SkOverdrawColorFilter.h
Only in skia/include/effects: SkPaintImageFilter.h
Only in skia/include/effects: SkPerlinNoiseShader.h
Only in skia/include/effects: SkPictureImageFilter.h
Only in skia/include/effects: SkRuntimeEffect.h
Only in skia/include/effects: SkShaderMaskFilter.h
Only in skia/include/effects: SkStrokeAndFillPathEffect.h
Only in skia/include/effects: SkTableColorFilter.h
Only in skia/include/effects: SkTableMaskFilter.h
Only in skia/include/effects: SkTileImageFilter.h
Only in skia/include/effects: SkTrimPathEffect.h
Only in skia/include/effects: SkXfermodeImageFilter.h
Only in skia/include: encode
Only in skia/include: gpu
diff --recursive --unified skia/include/pathops/SkPathOps.h tiny-skia/skia/include/pathops/SkPathOps.h
@@ -27,87 +27,4 @@
kReverseDifference_SkPathOp, //!< subtract the first path from the op path
};
-/** Set this path to the result of applying the Op to this path and the
- specified path: this = (this op operand).
- The resulting path will be constructed from non-overlapping contours.
- The curve order is reduced where possible so that cubics may be turned
- into quadratics, and quadratics maybe turned into lines.
-
- Returns true if operation was able to produce a result;
- otherwise, result is unmodified.
-
- @param one The first operand (for difference, the minuend)
- @param two The second operand (for difference, the subtrahend)
- @param op The operator to apply.
- @param result The product of the operands. The result may be one of the
- inputs.
- @return True if the operation succeeded.
- */
-bool SK_API Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result);
-
-/** Set this path to a set of non-overlapping contours that describe the
- same area as the original path.
- The curve order is reduced where possible so that cubics may
- be turned into quadratics, and quadratics maybe turned into lines.
-
- Returns true if operation was able to produce a result;
- otherwise, result is unmodified.
-
- @param path The path to simplify.
- @param result The simplified path. The result may be the input.
- @return True if simplification succeeded.
- */
-bool SK_API Simplify(const SkPath& path, SkPath* result);
-
-/** Set the resulting rectangle to the tight bounds of the path.
-
- @param path The path measured.
- @param result The tight bounds of the path.
- @return True if the bounds could be computed.
- */
-bool SK_API TightBounds(const SkPath& path, SkRect* result);
-
-/** Set the result with fill type winding to area equivalent to path.
- Returns true if successful. Does not detect if path contains contours which
- contain self-crossings or cross other contours; in these cases, may return
- true even though result does not fill same area as path.
-
- Returns true if operation was able to produce a result;
- otherwise, result is unmodified. The result may be the input.
-
- @param path The path typically with fill type set to even odd.
- @param result The equivalent path with fill type set to winding.
- @return True if winding path was set.
- */
-bool SK_API AsWinding(const SkPath& path, SkPath* result);
-
-/** Perform a series of path operations, optimized for unioning many paths together.
- */
-class SK_API SkOpBuilder {
-public:
- /** Add one or more paths and their operand. The builder is empty before the first
- path is added, so the result of a single add is (emptyPath OP path).
-
- @param path The second operand.
- @param _operator The operator to apply to the existing and supplied paths.
- */
- void add(const SkPath& path, SkPathOp _operator);
-
- /** Computes the sum of all paths and operands, and resets the builder to its
- initial state.
-
- @param result The product of the operands.
- @return True if the operation succeeded.
- */
- bool resolve(SkPath* result);
-
-private:
- SkTArray<SkPath> fPathRefs;
- SkTDArray<SkPathOp> fOps;
-
- static bool FixWinding(SkPath* path);
- static void ReversePath(SkPath* path);
- void reset();
-};
-
#endif
Only in skia/include: ports
Only in skia/include/private: GrContext_Base.h
Only in skia/include/private: GrD3DTypesPriv.h
Only in skia/include/private: GrGLTypesPriv.h
Only in skia/include/private: GrImageContext.h
Only in skia/include/private: GrRecordingContext.h
Only in skia/include/private: GrResourceKey.h
Only in skia/include/private: GrSharedEnums.h
Only in skia/include/private: GrSingleOwner.h
Only in skia/include/private: GrTypesPriv.h
Only in skia/include/private: GrVkTypesPriv.h
Only in skia/include/private: SkEncodedInfo.h
Only in skia/include/private: SkShadowFlags.h
Only in skia/include/private: SkSpinlock.h
Only in skia/include: svg
Only in skia/include/third_party: vulkan
Only in skia/include/utils: mac
Only in skia/include/utils: SkAnimCodecPlayer.h
Only in skia/include/utils: SkBase64.h
Only in skia/include/utils: SkCamera.h
Only in skia/include/utils: SkCanvasStateUtils.h
Only in skia/include/utils: SkCustomTypeface.h
Only in skia/include/utils: SkEventTracer.h
Only in skia/include/utils: SkInterpolator.h
Only in skia/include/utils: SkLuaCanvas.h
Only in skia/include/utils: SkLua.h
Only in skia/include/utils: SkNoDrawCanvas.h
Only in skia/include/utils: SkNullCanvas.h
Only in skia/include/utils: SkNWayCanvas.h
Only in skia/include/utils: SkPaintFilterCanvas.h
Only in skia/include/utils: SkParse.h
Only in skia/include/utils: SkParsePath.h
Only in skia/include/utils: SkShadowUtils.h
Only in skia/include/utils: SkTextUtils.h
Only in skia: infra
Only in skia: modules
Only in skia: OWNERS
Only in skia: platform_tools
Only in skia: PRESUBMIT.py
Only in skia: public.bzl
Only in skia: README.chromium
Only in skia: RELEASE_NOTES.txt
Only in skia: resources
Only in skia: samplecode
Only in skia: site
Only in skia: specs
Only in skia/src: android
Only in skia/src: c
Only in skia/src: codec
diff --recursive --unified skia/src/core/.directory tiny-skia/skia/src/core/.directory
@@ -1,5 +1,5 @@
[Dolphin]
-Timestamp=2020,6,29,15,41,27
+Timestamp=2020,6,29,15,52,50
Version=4
ViewMode=1
VisibleRoles=Icons_text,Icons_size
Only in skia/src/core: SkAnnotation.cpp
Only in skia/src/core: SkAnnotationKeys.h
Only in skia/src/core: SkArenaAllocList.h
Only in skia/src/core: SkATrace.cpp
Only in skia/src/core: SkATrace.h
Only in skia/src/core: SkAutoPixmapStorage.cpp
Only in skia/src/core: SkAutoPixmapStorage.h
Only in skia/src/core: SkBBHFactory.cpp
Only in skia/src/core: SkBigPicture.cpp
Only in skia/src/core: SkBigPicture.h
diff --recursive --unified skia/src/core/SkBitmapCache.cpp tiny-skia/skia/src/core/SkBitmapCache.cpp
@@ -52,167 +52,6 @@
};
}
-//////////////////////
-#include "src/core/SkDiscardableMemory.h"
-#include "src/core/SkNextID.h"
-
-void SkBitmapCache_setImmutableWithID(SkPixelRef* pr, uint32_t id) {
- pr->setImmutableWithID(id);
-}
-
-class SkBitmapCache::Rec : public SkResourceCache::Rec {
-public:
- Rec(const SkBitmapCacheDesc& desc, const SkImageInfo& info, size_t rowBytes,
- std::unique_ptr<SkDiscardableMemory> dm, void* block)
- : fKey(desc)
- , fDM(std::move(dm))
- , fMalloc(block)
- , fInfo(info)
- , fRowBytes(rowBytes)
- {
- SkASSERT(!(fDM && fMalloc)); // can't have both
-
- // We need an ID to return with the bitmap/pixelref. We can't necessarily use the key/desc
- // ID - lazy images cache the same ID with multiple keys (in different color types).
- fPrUniqueID = SkNextID::ImageID();
- }
-
- ~Rec() override {
- SkASSERT(0 == fExternalCounter);
- if (fDM && fDiscardableIsLocked) {
- SkASSERT(fDM->data());
- fDM->unlock();
- }
- sk_free(fMalloc); // may be null
- }
-
- const Key& getKey() const override { return fKey; }
- size_t bytesUsed() const override {
- return sizeof(fKey) + fInfo.computeByteSize(fRowBytes);
- }
- bool canBePurged() override {
- SkAutoMutexExclusive ama(fMutex);
- return fExternalCounter == 0;
- }
- void postAddInstall(void* payload) override {
- SkAssertResult(this->install(static_cast<SkBitmap*>(payload)));
- }
-
- const char* getCategory() const override { return "bitmap"; }
- SkDiscardableMemory* diagnostic_only_getDiscardable() const override {
- return fDM.get();
- }
-
- static void ReleaseProc(void* addr, void* ctx) {
- Rec* rec = static_cast<Rec*>(ctx);
- SkAutoMutexExclusive ama(rec->fMutex);
-
- SkASSERT(rec->fExternalCounter > 0);
- rec->fExternalCounter -= 1;
- if (rec->fDM) {
- SkASSERT(rec->fMalloc == nullptr);
- if (rec->fExternalCounter == 0) {
- rec->fDM->unlock();
- rec->fDiscardableIsLocked = false;
- }
- } else {
- SkASSERT(rec->fMalloc != nullptr);
- }
- }
-
- bool install(SkBitmap* bitmap) {
- SkAutoMutexExclusive ama(fMutex);
-
- if (!fDM && !fMalloc) {
- return false;
- }
-
- if (fDM) {
- if (!fDiscardableIsLocked) {
- SkASSERT(fExternalCounter == 0);
- if (!fDM->lock()) {
- fDM.reset(nullptr);
- return false;
- }
- fDiscardableIsLocked = true;
- }
- SkASSERT(fDM->data());
- }
-
- bitmap->installPixels(fInfo, fDM ? fDM->data() : fMalloc, fRowBytes, ReleaseProc, this);
- SkBitmapCache_setImmutableWithID(bitmap->pixelRef(), fPrUniqueID);
- fExternalCounter++;
-
- return true;
- }
-
- static bool Finder(const SkResourceCache::Rec& baseRec, void* contextBitmap) {
- Rec* rec = (Rec*)&baseRec;
- SkBitmap* result = (SkBitmap*)contextBitmap;
- return rec->install(result);
- }
-
-private:
- BitmapKey fKey;
-
- SkMutex fMutex;
-
- // either fDM or fMalloc can be non-null, but not both
- std::unique_ptr<SkDiscardableMemory> fDM;
- void* fMalloc;
-
- SkImageInfo fInfo;
- size_t fRowBytes;
- uint32_t fPrUniqueID;
-
- // This field counts the number of external pixelrefs we have created.
- // They notify us when they are destroyed so we can decrement this.
- int fExternalCounter = 0;
- bool fDiscardableIsLocked = true;
-};
-
-void SkBitmapCache::PrivateDeleteRec(Rec* rec) { delete rec; }
-
-SkBitmapCache::RecPtr SkBitmapCache::Alloc(const SkBitmapCacheDesc& desc, const SkImageInfo& info,
- SkPixmap* pmap) {
- // Ensure that the info matches the subset (i.e. the subset is the entire image)
- SkASSERT(info.width() == desc.fSubset.width());
- SkASSERT(info.height() == desc.fSubset.height());
-
- const size_t rb = info.minRowBytes();
- size_t size = info.computeByteSize(rb);
- if (SkImageInfo::ByteSizeOverflowed(size)) {
- return nullptr;
- }
-
- std::unique_ptr<SkDiscardableMemory> dm;
- void* block = nullptr;
-
- auto factory = SkResourceCache::GetDiscardableFactory();
- if (factory) {
- dm.reset(factory(size));
- } else {
- block = sk_malloc_canfail(size);
- }
- if (!dm && !block) {
- return nullptr;
- }
- *pmap = SkPixmap(info, dm ? dm->data() : block, rb);
- return RecPtr(new Rec(desc, info, rb, std::move(dm), block));
-}
-
-void SkBitmapCache::Add(RecPtr rec, SkBitmap* bitmap) {
- SkResourceCache::Add(rec.release(), bitmap);
-}
-
-bool SkBitmapCache::Find(const SkBitmapCacheDesc& desc, SkBitmap* result) {
- desc.validate();
- return SkResourceCache::Find(BitmapKey(desc), SkBitmapCache::Rec::Finder, result);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-
#define CHECK_LOCAL(localCache, localName, globalName, ...) \
((localCache) ? localCache->localName(__VA_ARGS__) : SkResourceCache::globalName(__VA_ARGS__))
diff --recursive --unified skia/src/core/SkBitmapCache.h tiny-skia/skia/src/core/SkBitmapCache.h
@@ -37,25 +37,6 @@
static SkBitmapCacheDesc Make(uint32_t genID, const SkIRect& subset);
};
-class SkBitmapCache {
-public:
- /**
- * Search based on the desc. If found, returns true and
- * result will be set to the matching bitmap with its pixels already locked.
- */
- static bool Find(const SkBitmapCacheDesc&, SkBitmap* result);
-
- class Rec;
- struct RecDeleter { void operator()(Rec* r) { PrivateDeleteRec(r); } };
- typedef std::unique_ptr<Rec, RecDeleter> RecPtr;
-
- static RecPtr Alloc(const SkBitmapCacheDesc&, const SkImageInfo&, SkPixmap*);
- static void Add(RecPtr, SkBitmap*);
-
-private:
- static void PrivateDeleteRec(Rec*);
-};
-
class SkMipMapCache {
public:
static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&,
diff --recursive --unified skia/src/core/SkBitmapController.h tiny-skia/skia/src/core/SkBitmapController.h
@@ -11,7 +11,6 @@
#include "include/core/SkBitmap.h"
#include "include/core/SkFilterQuality.h"
#include "include/core/SkMatrix.h"
-#include "src/core/SkBitmapCache.h"
#include "src/core/SkMipMap.h"
class SkImage_Base;
diff --recursive --unified skia/src/core/SkBitmap.cpp tiny-skia/skia/src/core/SkBitmap.cpp
@@ -25,8 +25,6 @@
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkPixelRefPriv.h"
#include "src/core/SkPixmapPriv.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/core/SkWritePixelsRec.h"
#include <cstring>
diff --recursive --unified skia/src/core/SkBitmapDevice.cpp tiny-skia/skia/src/core/SkBitmapDevice.cpp
@@ -21,7 +21,6 @@
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkSpecialImage.h"
-#include "src/core/SkStrikeCache.h"
#include "src/core/SkTLazy.h"
#include "src/image/SkImage_Base.h"
@@ -215,11 +214,7 @@
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap)
: INHERITED(bitmap.info(), SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType))
, fBitmap(bitmap)
- , fRCStack(bitmap.width(), bitmap.height())
- , fGlyphPainter(this->surfaceProps(),
- bitmap.colorType(),
- bitmap.colorSpace(),
- SkStrikeCache::GlobalStrikeCache()) {
+ , fRCStack(bitmap.width(), bitmap.height()) {
SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
}
@@ -232,11 +227,7 @@
: INHERITED(bitmap.info(), surfaceProps)
, fBitmap(bitmap)
, fRasterHandle(hndl)
- , fRCStack(bitmap.width(), bitmap.height())
- , fGlyphPainter(this->surfaceProps(),
- bitmap.colorType(),
- bitmap.colorSpace(),
- SkStrikeCache::GlobalStrikeCache()) {
+ , fRCStack(bitmap.width(), bitmap.height()) {
SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
if (coverage) {
@@ -548,15 +539,6 @@
this->drawRect(*dstPtr, paintWithShader);
}
-void SkBitmapDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
- LOOP_TILER( drawGlyphRunList(glyphRunList, &fGlyphPainter), nullptr )
-}
-
-void SkBitmapDevice::drawVertices(const SkVertices* vertices, SkBlendMode bmode,
- const SkPaint& paint) {
- BDDraw(this).drawVertices(vertices, bmode, paint);
-}
-
void SkBitmapDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPaint& origPaint) {
SkASSERT(!origPaint.getImageFilter());
SkASSERT(!origPaint.getMaskFilter());
@@ -580,19 +562,7 @@
}
}
-void SkBitmapDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
- const SkRect tex[], const SkColor colors[], int count,
- SkBlendMode mode, const SkPaint& paint) {
- // set this to true for performance comparisons with the old drawVertices way
- if (false) {
- this->INHERITED::drawAtlas(atlas, xform, tex, colors, count, mode, paint);
- return;
- }
- BDDraw(this).drawAtlas(atlas, xform, tex, colors, count, mode, paint);
-}
-
///////////////////////////////////////////////////////////////////////////////
-
void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPaint& origPaint) {
SkASSERT(!src->isTextureBacked());
SkASSERT(!origPaint.getMaskFilter());
diff --recursive --unified skia/src/core/SkBitmapDevice.h tiny-skia/skia/src/core/SkBitmapDevice.h
@@ -17,7 +17,6 @@
#include "include/core/SkSize.h"
#include "include/core/SkSurfaceProps.h"
#include "src/core/SkDevice.h"
-#include "src/core/SkGlyphRunPainter.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkRasterClipStack.h"
@@ -93,10 +92,6 @@
void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint&, SkCanvas::SrcRectConstraint) override;
- void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
- void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
- void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
- SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
///////////////////////////////////////////////////////////////////////////
@@ -157,7 +152,6 @@
void* fRasterHandle = nullptr;
SkRasterClipStack fRCStack;
std::unique_ptr<SkBitmap> fCoverage; // if non-null, will have the same dimensions as fBitmap
- SkGlyphRunListPainter fGlyphPainter;
typedef SkBaseDevice INHERITED;
diff --recursive --unified skia/src/core/SkBitmapProcState.cpp tiny-skia/skia/src/core/SkBitmapProcState.cpp
@@ -5,12 +5,10 @@
* found in the LICENSE file.
*/
-#include "include/core/SkImageEncoder.h"
#include "include/core/SkPaint.h"
#include "include/core/SkShader.h"
#include "include/private/SkColorData.h"
#include "include/private/SkMacros.h"
-#include "src/core/SkBitmapCache.h"
#include "src/core/SkBitmapController.h"
#include "src/core/SkBitmapProcState.h"
#include "src/core/SkMipMap.h"
diff --recursive --unified skia/src/core/SkBlendModePriv.h tiny-skia/skia/src/core/SkBlendModePriv.h
@@ -25,9 +25,4 @@
SkPMColor4f SkBlendMode_Apply(SkBlendMode, const SkPMColor4f& src, const SkPMColor4f& dst);
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrXferProcessor.h"
-const GrXPFactory* SkBlendMode_AsXPFactory(SkBlendMode);
-#endif
-
#endif
diff --recursive --unified skia/src/core/SkBlitter.cpp tiny-skia/skia/src/core/SkBlitter.cpp
@@ -18,11 +18,9 @@
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkPaintPriv.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkRegionPriv.h"
#include "src/core/SkTLazy.h"
#include "src/core/SkUtils.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/core/SkXfermodeInterpretation.h"
#include "src/shaders/SkShaderBase.h"
@@ -773,14 +771,7 @@
// Legacy blitters keep their shader state on a shader context.
SkShaderBase::Context* shaderContext = nullptr;
if (paint->getShader()) {
- shaderContext = as_SB(paint->getShader())->makeContext(
- {*paint, ctm, nullptr, device.colorType(), device.colorSpace()},
- alloc);
-
- // Creating the context isn't always possible... try fallbacks before giving up.
- if (!shaderContext) {
- return create_SkRP_or_SkVMBlitter();
- }
+ return create_SkRP_or_SkVMBlitter();
}
switch (device.colorType()) {
diff --recursive --unified skia/src/core/SkBlurMF.cpp tiny-skia/skia/src/core/SkBlurMF.cpp
@@ -5,39 +5,17 @@
* found in the LICENSE file.
*/
+#include "include/core/SkBitmap.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkRRect.h"
+#include "include/core/SkPath.h"
#include "include/core/SkStrokeRec.h"
#include "include/core/SkVertices.h"
#include "src/core/SkBlurMask.h"
#include "src/core/SkBlurPriv.h"
-#include "src/core/SkGpuBlurUtils.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkRRectPriv.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkStringUtils.h"
-#include "src/core/SkWriteBuffer.h"
-
-#if SK_SUPPORT_GPU
-#include "include/private/GrRecordingContext.h"
-#include "src/gpu/GrFragmentProcessor.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrRenderTargetContext.h"
-#include "src/gpu/GrResourceProvider.h"
-#include "src/gpu/GrShaderCaps.h"
-#include "src/gpu/GrStyle.h"
-#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/effects/GrTextureEffect.h"
-#include "src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h"
-#include "src/gpu/effects/generated/GrRRectBlurEffect.h"
-#include "src/gpu/effects/generated/GrRectBlurEffect.h"
-#include "src/gpu/geometry/GrStyledShape.h"
-#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
-#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
-#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
-#include "src/gpu/glsl/GrGLSLUniformHandler.h"
-#endif
class SkBlurMaskFilterImpl : public SkMaskFilterBase {
public:
@@ -48,26 +26,6 @@
bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
SkIPoint* margin) const override;
-#if SK_SUPPORT_GPU
- bool canFilterMaskGPU(const GrStyledShape& shape,
- const SkIRect& devSpaceShapeBounds,
- const SkIRect& clipBounds,
- const SkMatrix& ctm,
- SkIRect* maskRect) const override;
- bool directFilterMaskGPU(GrRecordingContext*,
- GrRenderTargetContext* renderTargetContext,
- GrPaint&&,
- const GrClip*,
- const SkMatrix& viewMatrix,
- const GrStyledShape& shape) const override;
- GrSurfaceProxyView filterMaskGPU(GrRecordingContext*,
- GrSurfaceProxyView srcView,
- GrColorType srcColorType,
- SkAlphaType srcAlphaType,
- const SkMatrix& ctm,
- const SkIRect& maskRect) const override;
-#endif
-
void computeFastBounds(const SkRect&, SkRect*) const override;
bool asABlur(BlurRec*) const override;
@@ -89,7 +47,6 @@
bool ignoreXform() const { return !fRespectCTM; }
private:
- SK_FLATTENABLE_HOOKS(SkBlurMaskFilterImpl)
// To avoid unseemly allocation requests (esp. for finite platforms like
// handset) we limit the radius so something manageable. (as opposed to
// a request like 10,000)
@@ -100,7 +57,6 @@
bool fRespectCTM;
SkBlurMaskFilterImpl(SkReadBuffer&);
- void flatten(SkWriteBuffer&) const override;
SkScalar computeXformedSigma(const SkMatrix& ctm) const {
SkScalar xformedSigma = this->ignoreXform() ? fSigma : ctm.mapRadius(fSigma);
@@ -694,240 +650,6 @@
src.fRight + pad, src.fBottom + pad);
}
-sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
- const SkScalar sigma = buffer.readScalar();
- SkBlurStyle style = buffer.read32LE(kLastEnum_SkBlurStyle);
-
- uint32_t flags = buffer.read32LE(0x3); // historically we only recorded 2 bits
- bool respectCTM = !(flags & 1); // historically we stored ignoreCTM in low bit
-
- if (buffer.isVersionLT(SkPicturePriv::kRemoveOccluderFromBlurMaskFilter)) {
- SkRect unused;
- buffer.readRect(&unused);
- }
-
- return SkMaskFilter::MakeBlur((SkBlurStyle)style, sigma, respectCTM);
-}
-
-void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
- buffer.writeScalar(fSigma);
- buffer.writeUInt(fBlurStyle);
- buffer.writeUInt(!fRespectCTM); // historically we recorded ignoreCTM
-}
-
-
-#if SK_SUPPORT_GPU
-
-bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrRecordingContext* context,
- GrRenderTargetContext* renderTargetContext,
- GrPaint&& paint,
- const GrClip* clip,
- const SkMatrix& viewMatrix,
- const GrStyledShape& shape) const {
- SkASSERT(renderTargetContext);
-
- if (fBlurStyle != kNormal_SkBlurStyle) {
- return false;
- }
-
- if (!viewMatrix.isScaleTranslate()) {
- return false;
- }
-
- // TODO: we could handle blurred stroked circles
- if (!shape.style().isSimpleFill()) {
- return false;
- }
-
- SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- if (xformedSigma <= 0) {
- return false;
- }
-
- SkRRect srcRRect;
- bool inverted;
- if (!shape.asRRect(&srcRRect, nullptr, nullptr, &inverted) || inverted) {
- return false;
- }
-
- SkRRect devRRect;
- if (!srcRRect.transform(viewMatrix, &devRRect)) {
- return false;
- }
-
- if (!SkRRectPriv::AllCornersCircular(devRRect)) {
- return false;
- }
-
- std::unique_ptr<GrFragmentProcessor> fp;
-
- if (devRRect.isRect() || SkRRectPriv::IsCircle(devRRect)) {
- if (devRRect.isRect()) {
- fp = GrRectBlurEffect::Make(
- /*inputFP=*/nullptr, context, *context->priv().caps()->shaderCaps(),
- devRRect.rect(), xformedSigma);
- } else {
- fp = GrCircleBlurFragmentProcessor::Make(/*inputFP=*/nullptr, context, devRRect.rect(),
- xformedSigma);
- }
-
- if (!fp) {
- return false;
- }
- paint.addCoverageFragmentProcessor(std::move(fp));
-
- SkRect srcProxyRect = srcRRect.rect();
- SkScalar outsetX = 3.0f*fSigma;
- SkScalar outsetY = 3.0f*fSigma;
- if (this->ignoreXform()) {
- // When we're ignoring the CTM the padding added to the source rect also needs to ignore
- // the CTM. The matrix passed in here is guaranteed to be just scale and translate so we
- // can just grab the X and Y scales off the matrix and pre-undo the scale.
- outsetX /= SkScalarAbs(viewMatrix.getScaleX());
- outsetY /= SkScalarAbs(viewMatrix.getScaleY());
- }
- srcProxyRect.outset(outsetX, outsetY);
-
- renderTargetContext->drawRect(clip, std::move(paint), GrAA::kNo, viewMatrix, srcProxyRect);
- return true;
- }
-
- fp = GrRRectBlurEffect::Make(/*inputFP=*/nullptr, context, fSigma, xformedSigma,
- srcRRect, devRRect);
- if (!fp) {
- return false;
- }
-
- if (!this->ignoreXform()) {
- SkRect srcProxyRect = srcRRect.rect();
- srcProxyRect.outset(3.0f*fSigma, 3.0f*fSigma);
-
- SkVertices::Builder builder(SkVertices::kTriangles_VertexMode, 4, 6, 0);
- srcProxyRect.toQuad(builder.positions());
-
- static const uint16_t fullIndices[6] = { 0, 1, 2, 0, 2, 3 };
- memcpy(builder.indices(), fullIndices, sizeof(fullIndices));
- sk_sp<SkVertices> vertices = builder.detach();
-
- paint.addCoverageFragmentProcessor(std::move(fp));
- SkSimpleMatrixProvider matrixProvider(viewMatrix);
- renderTargetContext->drawVertices(clip, std::move(paint), matrixProvider,
- std::move(vertices));
- } else {
- SkMatrix inverse;
- if (!viewMatrix.invert(&inverse)) {
- return false;
- }
-
- float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
- SkRect proxyRect = devRRect.rect();
- proxyRect.outset(extra, extra);
-
- paint.addCoverageFragmentProcessor(std::move(fp));
- renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo,
- SkMatrix::I(), proxyRect, inverse);
- }
-
- return true;
-}
-
-bool SkBlurMaskFilterImpl::canFilterMaskGPU(const GrStyledShape& shape,
- const SkIRect& devSpaceShapeBounds,
- const SkIRect& clipBounds,
- const SkMatrix& ctm,
- SkIRect* maskRect) const {
- SkScalar xformedSigma = this->computeXformedSigma(ctm);
- if (xformedSigma <= 0) {
- maskRect->setEmpty();
- return false;
- }
-
- if (maskRect) {
- float sigma3 = 3 * SkScalarToFloat(xformedSigma);
-
- // Outset srcRect and clipRect by 3 * sigma, to compute affected blur area.
- SkIRect clipRect = clipBounds.makeOutset(sigma3, sigma3);
- SkIRect srcRect = devSpaceShapeBounds.makeOutset(sigma3, sigma3);
-
- if (!srcRect.intersect(clipRect)) {
- srcRect.setEmpty();
- }
- *maskRect = srcRect;
- }
-
- // We prefer to blur paths with small blur radii on the CPU.
- static const SkScalar kMIN_GPU_BLUR_SIZE = SkIntToScalar(64);
- static const SkScalar kMIN_GPU_BLUR_SIGMA = SkIntToScalar(32);
-
- if (devSpaceShapeBounds.width() <= kMIN_GPU_BLUR_SIZE &&
- devSpaceShapeBounds.height() <= kMIN_GPU_BLUR_SIZE &&
- xformedSigma <= kMIN_GPU_BLUR_SIGMA) {
- return false;
- }
-
- return true;
-}
-
-GrSurfaceProxyView SkBlurMaskFilterImpl::filterMaskGPU(GrRecordingContext* context,
- GrSurfaceProxyView srcView,
- GrColorType srcColorType,
- SkAlphaType srcAlphaType,
- const SkMatrix& ctm,
- const SkIRect& maskRect) const {
- // 'maskRect' isn't snapped to the UL corner but the mask in 'src' is.
- const SkIRect clipRect = SkIRect::MakeWH(maskRect.width(), maskRect.height());
-
- SkScalar xformedSigma = this->computeXformedSigma(ctm);
- SkASSERT(xformedSigma > 0);
-
- // If we're doing a normal blur, we can clobber the pathTexture in the
- // gaussianBlur. Otherwise, we need to save it for later compositing.
- bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
- auto srcBounds = SkIRect::MakeSize(srcView.proxy()->dimensions());
- auto renderTargetContext = SkGpuBlurUtils::GaussianBlur(context,
- srcView,
- srcColorType,
- srcAlphaType,
- nullptr,
- clipRect,
- srcBounds,
- xformedSigma,
- xformedSigma,
- SkTileMode::kClamp);
- if (!renderTargetContext || !renderTargetContext->asTextureProxy()) {
- return {};
- }
-
- if (!isNormalBlur) {
- GrPaint paint;
- // Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(GrTextureEffect::Make(std::move(srcView), srcAlphaType));
- if (kInner_SkBlurStyle == fBlurStyle) {
- // inner: dst = dst * src
- paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
- } else if (kSolid_SkBlurStyle == fBlurStyle) {
- // solid: dst = src + dst - src * dst
- // = src + (1 - src) * dst
- paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op);
- } else if (kOuter_SkBlurStyle == fBlurStyle) {
- // outer: dst = dst * (1 - src)
- // = 0 * src + (1 - src) * dst
- paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
- } else {
- paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
- }
-
- renderTargetContext->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
- SkRect::Make(clipRect));
- }
-
- return renderTargetContext->readSurfaceView();
-}
-
-#endif // SK_SUPPORT_GPU
-
-void sk_register_blur_maskfilter_createproc() { SK_REGISTER_FLATTENABLE(SkBlurMaskFilterImpl); }
-
sk_sp<SkMaskFilter> SkMaskFilter::MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM) {
if (SkScalarIsFinite(sigma) && sigma > 0) {
return sk_sp<SkMaskFilter>(new SkBlurMaskFilterImpl(sigma, style, respectCTM));
diff --recursive --unified skia/src/core/SkCanvas.cpp tiny-skia/skia/src/core/SkCanvas.cpp
@@ -11,16 +11,14 @@
#include "include/core/SkImage.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkPathEffect.h"
-#include "include/core/SkPicture.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRasterHandleAllocator.h"
#include "include/core/SkString.h"
-#include "include/core/SkTextBlob.h"
#include "include/core/SkVertices.h"
-#include "include/effects/SkRuntimeEffect.h"
+#include "include/core/SkMaskFilter.h"
#include "include/private/SkNx.h"
#include "include/private/SkTo.h"
-#include "include/utils/SkNoDrawCanvas.h"
+#include "include/private/SkChecksum.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkBitmapDevice.h"
#include "src/core/SkCanvasPriv.h"
@@ -38,22 +36,14 @@
#include "src/core/SkPaintPriv.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkSpecialImage.h"
-#include "src/core/SkStrikeCache.h"
#include "src/core/SkTLazy.h"
#include "src/core/SkTextFormatParams.h"
-#include "src/core/SkTraceEvent.h"
#include "src/core/SkVerticesPriv.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkSurface_Base.h"
-#include "src/utils/SkPatchUtils.h"
#include <new>
-#if SK_SUPPORT_GPU
-#include "include/gpu/GrContext.h"
-#include "src/gpu/SkGr.h"
-#endif
-
#define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0)
#define RETURN_ON_FALSE(pred) do { if (!(pred)) return; } while (0)
@@ -518,8 +508,6 @@
device->setMarkerStack(fMarkerStack.get());
}
-
- fScratchGlyphRunBuilder = std::make_unique<SkGlyphRunBuilder>();
}
SkCanvas::SkCanvas()
@@ -861,7 +849,6 @@
}
int SkCanvas::saveLayer(const SaveLayerRec& rec) {
- TRACE_EVENT0("skia", TRACE_FUNC);
if (rec.fPaint && rec.fPaint->nothingToDraw()) {
// no need for the layer (or any of the draws until the matching restore()
this->save();
@@ -1067,7 +1054,6 @@
}
void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy strategy) {
- TRACE_EVENT0("skia", TRACE_FUNC);
const SkRect* bounds = rec.fBounds;
SaveLayerFlags saveLayerFlags = rec.fSaveLayerFlags;
@@ -1847,19 +1833,8 @@
return fMCRec->fMatrix;
}
-GrRenderTargetContext* SkCanvas::internal_private_accessTopLayerRenderTargetContext() {
- SkBaseDevice* dev = this->getTopDevice();
- return dev ? dev->accessRenderTargetContext() : nullptr;
-}
-
-GrContext* SkCanvas::getGrContext() {
- SkBaseDevice* device = this->getTopDevice();
- return device ? device->context() : nullptr;
-}
-
void SkCanvas::drawDRRect(const SkRRect& outer, const SkRRect& inner,
const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
if (outer.isEmpty()) {
return;
}
@@ -1881,24 +1856,20 @@
}
void SkCanvas::drawPaint(const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
this->onDrawPaint(paint);
}
void SkCanvas::drawRect(const SkRect& r, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
// To avoid redundant logic in our culling code and various backends, we always sort rects
// before passing them along.
this->onDrawRect(r.makeSorted(), paint);
}
void SkCanvas::drawClippedToSaveBehind(const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
this->onDrawBehind(paint);
}
void SkCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
if (region.isEmpty()) {
return;
}
@@ -1911,76 +1882,24 @@
}
void SkCanvas::drawOval(const SkRect& r, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
// To avoid redundant logic in our culling code and various backends, we always sort rects
// before passing them along.
this->onDrawOval(r.makeSorted(), paint);
}
void SkCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
this->onDrawRRect(rrect, paint);
}
void SkCanvas::drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
this->onDrawPoints(mode, count, pts, paint);
}
-void SkCanvas::drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode,
- const SkPaint& paint) {
- this->drawVertices(vertices.get(), mode, paint);
-}
-
-void SkCanvas::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- RETURN_ON_NULL(vertices);
-
- // We expect fans to be converted to triangles when building or deserializing SkVertices.
- SkASSERT(vertices->priv().mode() != SkVertices::kTriangleFan_VertexMode);
-
- // If the vertices contain custom attributes, ensure they line up with the paint's shader.
- const SkRuntimeEffect* effect =
- paint.getShader() ? as_SB(paint.getShader())->asRuntimeEffect() : nullptr;
- if ((size_t)vertices->priv().attributeCount() != (effect ? effect->varyings().count() : 0)) {
- return;
- }
- if (effect) {
- int attrIndex = 0;
- for (const auto& v : effect->varyings()) {
- const SkVertices::Attribute& attr(vertices->priv().attributes()[attrIndex++]);
- // Mismatch between the SkSL varying and the vertex shader output for this attribute
- if (attr.channelCount() != v.fWidth) {
- return;
- }
- // If we can't provide any of the asked-for matrices, we can't draw this
- if (attr.fMarkerID && !fMarkerStack->findMarker(attr.fMarkerID, nullptr)) {
- return;
- }
- }
- }
-
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
- // Preserve legacy behavior for Android: ignore the SkShader if there are no texCoords present
- if (paint.getShader() &&
- !(vertices->priv().hasTexCoords() || vertices->priv().hasCustomData())) {
- SkPaint noShaderPaint(paint);
- noShaderPaint.setShader(nullptr);
- this->onDrawVerticesObject(vertices, mode, noShaderPaint);
- return;
- }
-#endif
-
- this->onDrawVerticesObject(vertices, mode, paint);
-}
-
void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
this->onDrawPath(path, paint);
}
void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
RETURN_ON_NULL(image);
this->onDrawImage(image, x, y, paint);
}
@@ -1994,7 +1913,6 @@
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
RETURN_ON_NULL(image);
if (!fillable(dst) || !fillable(src)) {
return;
@@ -2043,7 +1961,6 @@
void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
RETURN_ON_NULL(image);
if (dst.isEmpty()) {
return;
@@ -2058,7 +1975,6 @@
void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
const SkPaint* paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
RETURN_ON_NULL(image);
if (dst.isEmpty()) {
return;
@@ -2106,56 +2022,9 @@
constraint);
}
-void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
- const SkColor colors[], int count, SkBlendMode mode,
- const SkRect* cull, const SkPaint* paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- RETURN_ON_NULL(atlas);
- if (count <= 0) {
- return;
- }
- SkASSERT(atlas);
- SkASSERT(tex);
- this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
-}
-
-void SkCanvas::drawAnnotation(const SkRect& rect, const char key[], SkData* value) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- if (key) {
- this->onDrawAnnotation(rect, key, value);
- }
-}
-
-void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, SrcRectConstraint constraint) {
- if (src) {
- this->drawImageRect(image, *src, dst, paint, constraint);
- } else {
- this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()),
- dst, paint, constraint);
- }
-}
-
-void SkCanvas::private_draw_shadow_rec(const SkPath& path, const SkDrawShadowRec& rec) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- this->onDrawShadowRec(path, rec);
-}
-
-void SkCanvas::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
- SkPaint paint;
- const SkRect& pathBounds = path.getBounds();
-
- DRAW_BEGIN(paint, &pathBounds)
- while (iter.next()) {
- iter.fDevice->drawShadow(path, rec);
- }
- DRAW_END
-}
-
void SkCanvas::experimental_DrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
QuadAAFlags aaFlags, const SkColor4f& color,
SkBlendMode mode) {
- TRACE_EVENT0("skia", TRACE_FUNC);
// Make sure the rect is sorted before passing it along
this->onDrawEdgeAAQuad(rect.makeSorted(), clip, aaFlags, color, mode);
}
@@ -2165,7 +2034,6 @@
const SkMatrix preViewMatrices[],
const SkPaint* paint,
SrcRectConstraint constraint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
this->onDrawEdgeAAImageSet(imageSet, cnt, dstClips, preViewMatrices, paint, constraint);
}
@@ -2581,164 +2449,6 @@
DRAW_END
}
-void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- SkRect storage;
- const SkRect* bounds = nullptr;
- if (paint.canComputeFastBounds()) {
- storage = blob->bounds().makeOffset(x, y);
- SkRect tmp;
- if (this->quickReject(paint.computeFastBounds(storage, &tmp))) {
- return;
- }
- bounds = &storage;
- }
-
- // We cannot filter in the looper as we normally do, because the paint is
- // incomplete at this point (text-related attributes are embedded within blob run paints).
- DRAW_BEGIN(paint, bounds)
-
- while (iter.next()) {
- fScratchGlyphRunBuilder->drawTextBlob(draw.paint(), *blob, {x, y}, iter.fDevice);
- }
-
- DRAW_END
-}
-
-// These call the (virtual) onDraw... method
-void SkCanvas::drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding,
- SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- if (byteLength) {
- sk_msan_assert_initialized(text, SkTAddOffset<const void>(text, byteLength));
- this->drawTextBlob(SkTextBlob::MakeFromText(text, byteLength, font, encoding), x, y, paint);
- }
-}
-
-void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- RETURN_ON_NULL(blob);
- RETURN_ON_FALSE(blob->bounds().makeOffset(x, y).isFinite());
-
- // Overflow if more than 2^21 glyphs stopping a buffer overflow latter in the stack.
- // See chromium:1080481
- // TODO: can consider unrolling a few at a time if this limit becomes a problem.
- int totalGlyphCount = 0;
- constexpr int kMaxGlyphCount = 1 << 21;
- SkTextBlob::Iter i(*blob);
- SkTextBlob::Iter::Run r;
- while (i.next(&r)) {
- int glyphsLeft = kMaxGlyphCount - totalGlyphCount;
- RETURN_ON_FALSE(r.fGlyphCount <= glyphsLeft);
- totalGlyphCount += r.fGlyphCount;
- }
- this->onDrawTextBlob(blob, x, y, paint);
-}
-
-void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
- const SkPaint& paint) {
- DRAW_BEGIN(paint, nullptr)
-
- while (iter.next()) {
- // In the common case of one iteration we could std::move vertices here.
- iter.fDevice->drawVertices(vertices, bmode, draw.paint());
- }
-
- DRAW_END
-}
-
-void SkCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode bmode,
- const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- if (nullptr == cubics) {
- return;
- }
-
- this->onDrawPatch(cubics, colors, texCoords, bmode, paint);
-}
-
-void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode bmode,
- const SkPaint& paint) {
- // Since a patch is always within the convex hull of the control points, we discard it when its
- // bounding rectangle is completely outside the current clip.
- SkRect bounds;
- bounds.setBounds(cubics, SkPatchUtils::kNumCtrlPts);
- if (this->quickReject(bounds)) {
- return;
- }
-
- DRAW_BEGIN(paint, nullptr)
-
- while (iter.next()) {
- iter.fDevice->drawPatch(cubics, colors, texCoords, bmode, paint);
- }
-
- DRAW_END
-}
-
-void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) {
-#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
- TRACE_EVENT0("skia", TRACE_FUNC);
-#endif
- RETURN_ON_NULL(dr);
- if (x || y) {
- SkMatrix matrix = SkMatrix::Translate(x, y);
- this->onDrawDrawable(dr, &matrix);
- } else {
- this->onDrawDrawable(dr, nullptr);
- }
-}
-
-void SkCanvas::drawDrawable(SkDrawable* dr, const SkMatrix* matrix) {
-#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
- TRACE_EVENT0("skia", TRACE_FUNC);
-#endif
- RETURN_ON_NULL(dr);
- if (matrix && matrix->isIdentity()) {
- matrix = nullptr;
- }
- this->onDrawDrawable(dr, matrix);
-}
-
-void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) {
- // drawable bounds are no longer reliable (e.g. android displaylist)
- // so don't use them for quick-reject
- this->getDevice()->drawDrawable(dr, matrix, this);
-}
-
-void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
- const SkColor colors[], int count, SkBlendMode bmode,
- const SkRect* cull, const SkPaint* paint) {
- if (cull && this->quickReject(*cull)) {
- return;
- }
-
- SkPaint pnt;
- if (paint) {
- pnt = *paint;
- }
-
- DRAW_BEGIN(pnt, nullptr)
- while (iter.next()) {
- iter.fDevice->drawAtlas(atlas, xform, tex, colors, count, bmode, pnt);
- }
- DRAW_END
-}
-
-void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
- SkASSERT(key);
-
- SkPaint paint;
- DRAW_BEGIN(paint, nullptr)
- while (iter.next()) {
- iter.fDevice->drawAnnotation(rect, key, value);
- }
- DRAW_END
-}
-
void SkCanvas::onDrawEdgeAAQuad(const SkRect& r, const SkPoint clip[4], QuadAAFlags edgeAA,
const SkColor4f& color, SkBlendMode mode) {
SkASSERT(r.isSorted());
@@ -2862,7 +2572,6 @@
void SkCanvas::drawArc(const SkRect& oval, SkScalar startAngle,
SkScalar sweepAngle, bool useCenter,
const SkPaint& paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
if (oval.isEmpty() || !sweepAngle) {
return;
}
@@ -2870,58 +2579,6 @@
}
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_DISABLE_SKPICTURE
-void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint) {}
-
-
-void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
- const SkPaint* paint) {}
-#else
-/**
- * This constant is trying to balance the speed of ref'ing a subpicture into a parent picture,
- * against the playback cost of recursing into the subpicture to get at its actual ops.
- *
- * For now we pick a conservatively small value, though measurement (and other heuristics like
- * the type of ops contained) may justify changing this value.
- */
-#define kMaxPictureOpsToUnrollInsteadOfRef 1
-
-void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint) {
- TRACE_EVENT0("skia", TRACE_FUNC);
- RETURN_ON_NULL(picture);
-
- if (matrix && matrix->isIdentity()) {
- matrix = nullptr;
- }
- if (picture->approximateOpCount() <= kMaxPictureOpsToUnrollInsteadOfRef) {
- SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect());
- picture->playback(this);
- } else {
- this->onDrawPicture(picture, matrix, paint);
- }
-}
-
-void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
- const SkPaint* paint) {
- if (!paint || paint->canComputeFastBounds()) {
- SkRect bounds = picture->cullRect();
- if (paint) {
- paint->computeFastBounds(bounds, &bounds);
- }
- if (matrix) {
- matrix->mapRect(&bounds);
- }
- if (this->quickReject(bounds)) {
- return;
- }
- }
-
- SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect());
- picture->playback(this);
-}
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
SkCanvas::LayerIter::LayerIter(SkCanvas* canvas) {
@@ -3016,26 +2673,6 @@
}
///////////////////////////////////////////////////////////////////////////////
-
-SkNoDrawCanvas::SkNoDrawCanvas(int width, int height)
- : INHERITED(SkIRect::MakeWH(width, height)) {}
-
-SkNoDrawCanvas::SkNoDrawCanvas(const SkIRect& bounds)
- : INHERITED(bounds) {}
-
-SkNoDrawCanvas::SkNoDrawCanvas(sk_sp<SkBaseDevice> device)
- : INHERITED(device) {}
-
-SkCanvas::SaveLayerStrategy SkNoDrawCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
- (void)this->INHERITED::getSaveLayerStrategy(rec);
- return kNoLayer_SaveLayerStrategy;
-}
-
-bool SkNoDrawCanvas::onDoSaveBehind(const SkRect*) {
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
static_assert((int)SkRegion::kDifference_Op == (int)kDifference_SkClipOp, "");
static_assert((int)SkRegion::kIntersect_Op == (int)kIntersect_SkClipOp, "");
diff --recursive --unified skia/src/core/SkCanvasPriv.cpp tiny-skia/skia/src/core/SkCanvasPriv.cpp
@@ -7,8 +7,6 @@
#include "src/core/SkAutoMalloc.h"
#include "src/core/SkCanvasPriv.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriter32.h"
#include <locale>
@@ -36,55 +34,6 @@
fCanvas->restoreToCount(fSaveCount);
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-bool SkCanvasPriv::ReadLattice(SkReadBuffer& buffer, SkCanvas::Lattice* lattice) {
- lattice->fXCount = buffer.readInt();
- lattice->fXDivs = buffer.skipT<int32_t>(lattice->fXCount);
- lattice->fYCount = buffer.readInt();
- lattice->fYDivs = buffer.skipT<int32_t>(lattice->fYCount);
- int flagCount = buffer.readInt();
- lattice->fRectTypes = nullptr;
- lattice->fColors = nullptr;
- if (flagCount) {
- lattice->fRectTypes = buffer.skipT<SkCanvas::Lattice::RectType>(flagCount);
- lattice->fColors = buffer.skipT<SkColor>(flagCount);
- }
- lattice->fBounds = buffer.skipT<SkIRect>();
- return buffer.isValid();
-}
-
-size_t SkCanvasPriv::WriteLattice(void* buffer, const SkCanvas::Lattice& lattice) {
- int flagCount = lattice.fRectTypes ? (lattice.fXCount + 1) * (lattice.fYCount + 1) : 0;
-
- const size_t size = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * sizeof(int32_t) +
- SkAlign4(flagCount * sizeof(SkCanvas::Lattice::RectType)) +
- SkAlign4(flagCount * sizeof(SkColor)) +
- sizeof(SkIRect);
-
- if (buffer) {
- SkWriter32 writer(buffer, size);
- writer.write32(lattice.fXCount);
- writer.write(lattice.fXDivs, lattice.fXCount * sizeof(uint32_t));
- writer.write32(lattice.fYCount);
- writer.write(lattice.fYDivs, lattice.fYCount * sizeof(uint32_t));
- writer.write32(flagCount);
- writer.writePad(lattice.fRectTypes, flagCount * sizeof(uint8_t));
- writer.write(lattice.fColors, flagCount * sizeof(SkColor));
- SkASSERT(lattice.fBounds);
- writer.write(lattice.fBounds, sizeof(SkIRect));
- SkASSERT(writer.bytesWritten() == size);
- }
- return size;
-};
-
-void SkCanvasPriv::WriteLattice(SkWriteBuffer& buffer, const SkCanvas::Lattice& lattice) {
- const size_t size = WriteLattice(nullptr, lattice);
- SkAutoSMalloc<1024> storage(size);
- WriteLattice(storage.get(), lattice);
- buffer.writePad32(storage.get(), size);
-}
-
void SkCanvasPriv::GetDstClipAndMatrixCounts(const SkCanvas::ImageSetEntry set[], int count,
int* totalDstClipCount, int* totalMatrixCount) {
int dstClipCount = 0;
diff --recursive --unified skia/src/core/SkCanvasPriv.h tiny-skia/skia/src/core/SkCanvasPriv.h
@@ -30,15 +30,6 @@
kDontClipToLayer_SaveLayerFlag = SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag,
};
- // The lattice has pointers directly into the readbuffer
- static bool ReadLattice(SkReadBuffer&, SkCanvas::Lattice*);
-
- static void WriteLattice(SkWriteBuffer&, const SkCanvas::Lattice&);
-
- // return the byte-size of the lattice, even if the buffer is null
- // storage must be 4-byte aligned
- static size_t WriteLattice(void* storage, const SkCanvas::Lattice&);
-
static SkCanvas::SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFlags);
static int SaveBehind(SkCanvas* canvas, const SkRect* subset) {
diff --recursive --unified skia/src/core/SkClipStack.cpp tiny-skia/skia/src/core/SkClipStack.cpp
@@ -15,10 +15,6 @@
#include <atomic>
#include <new>
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrProxyProvider.h"
-#endif
-
SkClipStack::Element::Element(const Element& that) {
switch (that.getDeviceSpaceType()) {
case DeviceSpaceType::kEmpty:
@@ -53,12 +49,6 @@
}
SkClipStack::Element::~Element() {
-#if SK_SUPPORT_GPU
- for (int i = 0; i < fKeysToInvalidate.count(); ++i) {
- fProxyProvider->processInvalidUniqueKey(fKeysToInvalidate[i], nullptr,
- GrProxyProvider::InvalidateGPUResource::kYes);
- }
-#endif
}
bool SkClipStack::Element::operator== (const Element& element) const {
@@ -1070,68 +1060,3 @@
return back->getGenID();
}
-
-#ifdef SK_DEBUG
-void SkClipStack::Element::dump() const {
- static const char* kTypeStrings[] = {
- "empty",
- "rect",
- "rrect",
- "path",
- "shader"
- };
- static_assert(0 == static_cast<int>(DeviceSpaceType::kEmpty), "enum mismatch");
- static_assert(1 == static_cast<int>(DeviceSpaceType::kRect), "enum mismatch");
- static_assert(2 == static_cast<int>(DeviceSpaceType::kRRect), "enum mismatch");
- static_assert(3 == static_cast<int>(DeviceSpaceType::kPath), "enum mismatch");
- static_assert(4 == static_cast<int>(DeviceSpaceType::kShader), "enum mismatch");
- static_assert(SK_ARRAY_COUNT(kTypeStrings) == kTypeCnt, "enum mismatch");
-
- static const char* kOpStrings[] = {
- "difference",
- "intersect",
- "union",
- "xor",
- "reverse-difference",
- "replace",
- };
- static_assert(0 == static_cast<int>(kDifference_SkClipOp), "enum mismatch");
- static_assert(1 == static_cast<int>(kIntersect_SkClipOp), "enum mismatch");
- static_assert(2 == static_cast<int>(kUnion_SkClipOp), "enum mismatch");
- static_assert(3 == static_cast<int>(kXOR_SkClipOp), "enum mismatch");
- static_assert(4 == static_cast<int>(kReverseDifference_SkClipOp), "enum mismatch");
- static_assert(5 == static_cast<int>(kReplace_SkClipOp), "enum mismatch");
- static_assert(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, "enum mismatch");
-
- SkDebugf("Type: %s, Op: %s, AA: %s, Save Count: %d\n", kTypeStrings[(int)fDeviceSpaceType],
- kOpStrings[static_cast<int>(fOp)], (fDoAA ? "yes" : "no"), fSaveCount);
- switch (fDeviceSpaceType) {
- case DeviceSpaceType::kEmpty:
- SkDebugf("\n");
- break;
- case DeviceSpaceType::kRect:
- this->getDeviceSpaceRect().dump();
- SkDebugf("\n");
- break;
- case DeviceSpaceType::kRRect:
- this->getDeviceSpaceRRect().dump();
- SkDebugf("\n");
- break;
- case DeviceSpaceType::kPath:
- this->getDeviceSpacePath().dump(nullptr, true, false);
- break;
- case DeviceSpaceType::kShader:
- // SkShaders don't provide much introspection that's worth while.
- break;
- }
-}
-
-void SkClipStack::dump() const {
- B2TIter iter(*this);
- const Element* e;
- while ((e = iter.next())) {
- e->dump();
- SkDebugf("\n");
- }
-}
-#endif
diff --recursive --unified skia/src/core/SkClipStack.h tiny-skia/skia/src/core/SkClipStack.h
@@ -19,12 +19,6 @@
#include "src/core/SkMessageBus.h"
#include "src/core/SkTLazy.h"
-#if SK_SUPPORT_GPU
-class GrProxyProvider;
-
-#include "include/private/GrResourceKey.h"
-#endif
-
// Because a single save/restore state can have multiple clips, this class
// stores the stack depth (fSaveCount) and clips (fDeque) separately.
// Each clip in fDeque stores the stack state to which it belongs
@@ -179,32 +173,6 @@
fDeviceSpacePath.get()->isInverseFillType();
}
-#ifdef SK_DEBUG
- /**
- * Dumps the element to SkDebugf. This is intended for Skia development debugging
- * Don't rely on the existence of this function or the formatting of its output.
- */
- void dump() const;
-#endif
-
-#if SK_SUPPORT_GPU
- /**
- * This is used to purge any GPU resource cache items that become unreachable when
- * the element is destroyed because their key is based on this element's gen ID.
- */
- void addResourceInvalidationMessage(GrProxyProvider* proxyProvider,
- const GrUniqueKey& key) const {
- SkASSERT(proxyProvider);
-
- if (!fProxyProvider) {
- fProxyProvider = proxyProvider;
- }
- SkASSERT(fProxyProvider == proxyProvider);
-
- fKeysToInvalidate.push_back(key);
- }
-#endif
-
private:
friend class SkClipStack;
@@ -234,10 +202,7 @@
bool fIsIntersectionOfRects;
uint32_t fGenID;
-#if SK_SUPPORT_GPU
- mutable GrProxyProvider* fProxyProvider = nullptr;
- mutable SkTArray<GrUniqueKey> fKeysToInvalidate;
-#endif
+
Element(int saveCount) {
this->initCommon(saveCount, kReplace_SkClipOp, false);
this->setEmpty();
diff --recursive --unified skia/src/core/SkColorFilterBase.h tiny-skia/skia/src/core/SkColorFilterBase.h
@@ -10,14 +10,10 @@
#include "include/core/SkColorFilter.h"
-class GrColorInfo;
-class GrFragmentProcessor;
-class GrRecordingContext;
class SkArenaAlloc;
class SkBitmap;
class SkColorSpace;
struct SkStageRec;
-using GrFPResult = std::tuple<bool, std::unique_ptr<GrFragmentProcessor>>;
namespace skvm {
class Builder;
@@ -37,41 +33,10 @@
*/
virtual uint32_t onGetFlags() const { return 0; }
-#if SK_SUPPORT_GPU
- /**
- * A subclass may implement this factory function to work with the GPU backend. It returns
- * a GrFragmentProcessor that implements 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:
SkColorFilterBase() {}
@@ -85,8 +50,6 @@
SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const = 0;
friend class SkColorFilter;
-
- typedef SkFlattenable INHERITED;
};
static inline SkColorFilterBase* as_CFB(SkColorFilter* filter) {
diff --recursive --unified skia/src/core/SkColorFilter.cpp tiny-skia/skia/src/core/SkColorFilter.cpp
@@ -6,25 +6,20 @@
*/
#include "include/core/SkRefCnt.h"
+#include "include/core/SkPaint.h"
#include "include/core/SkString.h"
#include "include/core/SkUnPreMultiply.h"
#include "include/private/SkNx.h"
#include "include/private/SkTDArray.h"
+#include "include/private/SkColorData.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkColorFilterBase.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkColorSpaceXformSteps.h"
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
-
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrColorSpaceXform.h"
-#include "src/gpu/GrFragmentProcessor.h"
-#include "src/gpu/effects/generated/GrMixerEffect.h"
-#endif
+#include "src/core/SkEffectPriv.h"
bool SkColorFilter::asColorMode(SkColor* color, SkBlendMode* mode) const {
return as_CFB(this)->onAsAColorMode(color, mode);
@@ -54,13 +49,6 @@
return false;
}
-#if SK_SUPPORT_GPU
-std::unique_ptr<GrFragmentProcessor> SkColorFilterBase::asFragmentProcessor(GrRecordingContext*,
- const GrColorInfo&) const {
- return nullptr;
-}
-#endif
-
bool SkColorFilterBase::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
return this->onAppendStages(rec, shaderIsOpaque);
}
@@ -134,27 +122,6 @@
return c ? fOuter->program(p, c, dstCS, uniforms, alloc) : skvm::Color{};
}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
- GrRecordingContext* context, const GrColorInfo& dstColorInfo) const override {
- auto innerFP = fInner->asFragmentProcessor(context, dstColorInfo);
- auto outerFP = fOuter->asFragmentProcessor(context, dstColorInfo);
- if (!innerFP || !outerFP) {
- return nullptr;
- }
- std::unique_ptr<GrFragmentProcessor> series[] = { std::move(innerFP), std::move(outerFP) };
- return GrFragmentProcessor::RunInSeries(series, 2);
- }
-#endif
-
- SK_FLATTENABLE_HOOKS(SkComposeColorFilter)
-
-protected:
- void flatten(SkWriteBuffer& buffer) const override {
- buffer.writeFlattenable(fOuter.get());
- buffer.writeFlattenable(fInner.get());
- }
-
private:
SkComposeColorFilter(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner)
: fOuter(as_CFB_sp(std::move(outer)))
@@ -169,12 +136,6 @@
typedef SkColorFilter INHERITED;
};
-sk_sp<SkFlattenable> SkComposeColorFilter::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkColorFilter> outer(buffer.readColorFilter());
- sk_sp<SkColorFilter> inner(buffer.readColorFilter());
- return outer ? outer->makeComposed(std::move(inner)) : inner;
-}
-
sk_sp<SkColorFilter> SkColorFilter::makeComposed(sk_sp<SkColorFilter> inner) const {
if (!inner) {
return sk_ref_sp(this);
@@ -202,23 +163,6 @@
}
}()) {}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
- const GrColorInfo&) const override {
- // wish our caller would let us know if our input was opaque...
- SkAlphaType at = kPremul_SkAlphaType;
- switch (fDir) {
- case Direction::kLinearToSRGB:
- return GrColorSpaceXformEffect::Make(sk_srgb_linear_singleton(), at,
- sk_srgb_singleton(), at);
- case Direction::kSRGBToLinear:
- return GrColorSpaceXformEffect::Make(sk_srgb_singleton(), at,
- sk_srgb_linear_singleton(), at);
- }
- return nullptr;
- }
-#endif
-
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
if (!shaderIsOpaque) {
rec.fPipeline->append(SkRasterPipeline::unpremul);
@@ -237,13 +181,6 @@
return premul(fSteps.program(p, uniforms, unpremul(c)));
}
- SK_FLATTENABLE_HOOKS(SkSRGBGammaColorFilter)
-
-protected:
- void flatten(SkWriteBuffer& buffer) const override {
- buffer.write32(static_cast<uint32_t>(fDir));
- }
-
private:
const Direction fDir;
SkColorSpaceXformSteps fSteps;
@@ -252,14 +189,6 @@
typedef SkColorFilterBase INHERITED;
};
-sk_sp<SkFlattenable> SkSRGBGammaColorFilter::CreateProc(SkReadBuffer& buffer) {
- uint32_t dir = buffer.read32();
- if (!buffer.validate(dir <= 1)) {
- return nullptr;
- }
- return sk_sp<SkFlattenable>(new SkSRGBGammaColorFilter(static_cast<Direction>(dir)));
-}
-
template <SkSRGBGammaColorFilter::Direction dir>
sk_sp<SkColorFilter> MakeSRGBGammaCF() {
static SkColorFilter* gSingleton = new SkSRGBGammaColorFilter(dir);
@@ -332,25 +261,6 @@
: skvm::Color{};
}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
- GrRecordingContext* context, const GrColorInfo& dstColorInfo) const override {
- return GrMixerEffect::Make(
- fCF0->asFragmentProcessor(context, dstColorInfo),
- fCF1 ? fCF1->asFragmentProcessor(context, dstColorInfo) : nullptr,
- fWeight);
- }
-#endif
-
- SK_FLATTENABLE_HOOKS(SkMixerColorFilter)
-
-protected:
- void flatten(SkWriteBuffer& buffer) const override {
- buffer.writeFlattenable(fCF0.get());
- buffer.writeFlattenable(fCF1.get());
- buffer.writeScalar(fWeight);
- }
-
private:
sk_sp<SkColorFilterBase> fCF0;
sk_sp<SkColorFilterBase> fCF1;
@@ -361,13 +271,6 @@
typedef SkColorFilterBase INHERITED;
};
-sk_sp<SkFlattenable> SkMixerColorFilter::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkColorFilter> cf0(buffer.readColorFilter());
- sk_sp<SkColorFilter> cf1(buffer.readColorFilter());
- const float weight = buffer.readScalar();
- return SkColorFilters::Lerp(weight, std::move(cf0), std::move(cf1));
-}
-
sk_sp<SkColorFilter> SkColorFilters::Lerp(float weight, sk_sp<SkColorFilter> cf0,
sk_sp<SkColorFilter> cf1) {
if (!cf0 && !cf1) {
@@ -392,14 +295,3 @@
? new SkMixerColorFilter(std::move(cf0), std::move(cf1), weight)
: new SkMixerColorFilter(std::move(cf1), nullptr, 1 - weight));
}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include "src/core/SkModeColorFilter.h"
-
-void SkColorFilterBase::RegisterFlattenables() {
- SK_REGISTER_FLATTENABLE(SkComposeColorFilter);
- SK_REGISTER_FLATTENABLE(SkModeColorFilter);
- SK_REGISTER_FLATTENABLE(SkSRGBGammaColorFilter);
- SK_REGISTER_FLATTENABLE(SkMixerColorFilter);
-}
diff --recursive --unified skia/src/core/SkColorFilter_Matrix.cpp tiny-skia/skia/src/core/SkColorFilter_Matrix.cpp
@@ -13,10 +13,9 @@
#include "include/private/SkNx.h"
#include "src/core/SkColorFilter_Matrix.h"
#include "src/core/SkColorSpacePriv.h"
+#include "src/core/SkEffectPriv.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
static uint16_t ComputeFlags(const float matrix[20]) {
const float* srcA = matrix + 15;
@@ -39,26 +38,6 @@
return this->INHERITED::onGetFlags() | fFlags;
}
-void SkColorFilter_Matrix::flatten(SkWriteBuffer& buffer) const {
- SkASSERT(sizeof(fMatrix)/sizeof(float) == 20);
- buffer.writeScalarArray(fMatrix, 20);
-
- // RGBA flag
- buffer.writeBool(fDomain == Domain::kRGBA);
-}
-
-sk_sp<SkFlattenable> SkColorFilter_Matrix::CreateProc(SkReadBuffer& buffer) {
- float matrix[20];
- if (!buffer.readScalarArray(matrix, 20)) {
- return nullptr;
- }
-
- auto is_rgba = buffer.isVersionLT(SkPicturePriv::kMatrixColorFilterDomain_Version) ||
- buffer.readBool();
- return is_rgba ? SkColorFilters::Matrix(matrix)
- : SkColorFilters::HSLAMatrix(matrix);
-}
-
bool SkColorFilter_Matrix::onAsAColorMatrix(float matrix[20]) const {
if (matrix) {
memcpy(matrix, fMatrix, 20 * sizeof(float));
@@ -123,35 +102,6 @@
return premul(c); // note: rasterpipeline version does clamp01 first
}
-#if SK_SUPPORT_GPU
-#include "src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h"
-#include "src/gpu/effects/generated/GrHSLToRGBFilterEffect.h"
-#include "src/gpu/effects/generated/GrRGBToHSLFilterEffect.h"
-std::unique_ptr<GrFragmentProcessor> SkColorFilter_Matrix::asFragmentProcessor(
- GrRecordingContext*, const GrColorInfo&) const {
- switch (fDomain) {
- case Domain::kRGBA:
- return GrColorMatrixFragmentProcessor::Make(/* inputFP = */ nullptr,
- fMatrix,
- /* premulInput = */ true,
- /* clampRGBOutput = */ true,
- /* premulOutput = */ true);
- case Domain::kHSLA: {
- auto fp = GrRGBToHSLFilterEffect::Make(/* inputFP = */ nullptr);
- fp = GrColorMatrixFragmentProcessor::Make(std::move(fp), fMatrix,
- /* premulInput = */ false,
- /* clampRGBOutput = */ false,
- /* premulOutput = */ false);
- fp = GrHSLToRGBFilterEffect::Make(std::move(fp));
- return fp;
- }
- }
-
- SkUNREACHABLE;
-}
-
-#endif
-
///////////////////////////////////////////////////////////////////////////////
static sk_sp<SkColorFilter> MakeMatrix(const float array[20],
@@ -172,21 +122,3 @@
sk_sp<SkColorFilter> SkColorFilters::HSLAMatrix(const float array[20]) {
return MakeMatrix(array, SkColorFilter_Matrix::Domain::kHSLA);
}
-
-void SkColorFilter_Matrix::RegisterFlattenables() {
- SK_REGISTER_FLATTENABLE(SkColorFilter_Matrix);
-
- // This subclass was removed 4/2019
- SkFlattenable::Register("SkColorMatrixFilterRowMajor255",
- [](SkReadBuffer& buffer) -> sk_sp<SkFlattenable> {
- float matrix[20];
- if (buffer.readScalarArray(matrix, 20)) {
- matrix[ 4] *= (1.0f/255);
- matrix[ 9] *= (1.0f/255);
- matrix[14] *= (1.0f/255);
- matrix[19] *= (1.0f/255);
- return SkColorFilters::Matrix(matrix);
- }
- return nullptr;
- });
-}
diff --recursive --unified skia/src/core/SkColorFilter_Matrix.h tiny-skia/skia/src/core/SkColorFilter_Matrix.h
@@ -18,19 +18,9 @@
uint32_t onGetFlags() const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
- const GrColorInfo&) const override;
-#endif
-
- static void RegisterFlattenables();
-
private:
- void flatten(SkWriteBuffer&) const override;
bool onAsAColorMatrix(float matrix[20]) const override;
- SK_FLATTENABLE_HOOKS(SkColorFilter_Matrix)
-
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Color,
SkColorSpace* dstCS,
Only in skia/src/core: SkCompressedDataUtils.cpp
Only in skia/src/core: SkCompressedDataUtils.h
diff --recursive --unified skia/src/core/SkCoreBlitters.h tiny-skia/skia/src/core/SkCoreBlitters.h
@@ -12,7 +12,6 @@
#include "src/core/SkBlitRow.h"
#include "src/core/SkBlitter.h"
#include "src/core/SkXfermodePriv.h"
-#include "src/shaders/SkBitmapProcShader.h"
#include "src/shaders/SkShaderBase.h"
class SkRasterBlitter : public SkBlitter {
Only in skia/src/core: SkCubicClipper.cpp
Only in skia/src/core: SkCubicClipper.h
Only in skia/src/core: SkCubicMap.cpp
Only in skia/src/core: SkCubicSolver.h
diff --recursive --unified skia/src/core/SkData.cpp tiny-skia/skia/src/core/SkData.cpp
@@ -8,9 +8,7 @@
#include "include/core/SkData.h"
#include "include/core/SkStream.h"
#include "include/private/SkOnce.h"
-#include "src/core/SkOSFile.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
+#include "include/private/SkMalloc.h"
#include <new>
SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context)
@@ -115,41 +113,6 @@
return sk_sp<SkData>(new SkData(ptr, length, proc, ctx));
}
-// assumes fPtr was allocated with sk_fmmap
-static void sk_mmap_releaseproc(const void* addr, void* ctx) {
- size_t length = reinterpret_cast<size_t>(ctx);
- sk_fmunmap(addr, length);
-}
-
-sk_sp<SkData> SkData::MakeFromFILE(FILE* f) {
- size_t size;
- void* addr = sk_fmmap(f, &size);
- if (nullptr == addr) {
- return nullptr;
- }
-
- return SkData::MakeWithProc(addr, size, sk_mmap_releaseproc, reinterpret_cast<void*>(size));
-}
-
-sk_sp<SkData> SkData::MakeFromFileName(const char path[]) {
- FILE* f = path ? sk_fopen(path, kRead_SkFILE_Flag) : nullptr;
- if (nullptr == f) {
- return nullptr;
- }
- auto data = MakeFromFILE(f);
- sk_fclose(f);
- return data;
-}
-
-sk_sp<SkData> SkData::MakeFromFD(int fd) {
- size_t size;
- void* addr = sk_fdmmap(fd, &size);
- if (nullptr == addr) {
- return nullptr;
- }
- return SkData::MakeWithProc(addr, size, sk_mmap_releaseproc, reinterpret_cast<void*>(size));
-}
-
// assumes context is a SkData
static void sk_dataref_releaseproc(const void*, void* context) {
SkData* src = reinterpret_cast<SkData*>(context);
Only in skia/src/core: SkDeferredDisplayList.cpp
diff --recursive --unified skia/src/core/SkDeferredDisplayListPriv.h tiny-skia/skia/src/core/SkDeferredDisplayListPriv.h
@@ -17,24 +17,6 @@
class SkDeferredDisplayListPriv {
public:
-#if SK_SUPPORT_GPU
- int numRenderTasks() const {
- return fDDL->fRenderTasks.count();
- }
-
- GrRenderTargetProxy* targetProxy() const {
- return fDDL->fTargetProxy.get();
- }
-
- const SkDeferredDisplayList::LazyProxyData* lazyProxyData() const {
- return fDDL->fLazyProxyData.get();
- }
-
- const SkTArray<GrRecordingContext::ProgramData>& programData() const {
- return fDDL->programData();
- }
-#endif
-
private:
explicit SkDeferredDisplayListPriv(SkDeferredDisplayList* ddl) : fDDL(ddl) {}
SkDeferredDisplayListPriv(const SkDeferredDisplayListPriv&); // unimpl
Only in skia/src/core: SkDeferredDisplayListRecorder.cpp
Only in skia/src/core: SkDescriptor.cpp
Only in skia/src/core: SkDescriptor.h
diff --recursive --unified skia/src/core/SkDevice.cpp tiny-skia/skia/src/core/SkDevice.cpp
@@ -8,15 +8,14 @@
#include "src/core/SkDevice.h"
#include "include/core/SkColorFilter.h"
-#include "include/core/SkDrawable.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkPathMeasure.h"
#include "include/core/SkRSXform.h"
#include "include/core/SkShader.h"
#include "include/core/SkVertices.h"
#include "include/private/SkTo.h"
-#include "src/core/SkDraw.h"
#include "src/core/SkGlyphRun.h"
+#include "src/core/SkDraw.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkLatticeIter.h"
@@ -26,11 +25,9 @@
#include "src/core/SkRasterClip.h"
#include "src/core/SkSpecialImage.h"
#include "src/core/SkTLazy.h"
-#include "src/core/SkTextBlobPriv.h"
#include "src/core/SkUtils.h"
#include "src/image/SkImage_Base.h"
#include "src/shaders/SkLocalMatrixShader.h"
-#include "src/utils/SkPatchUtils.h"
SkBaseDevice::SkBaseDevice(const SkImageInfo& info, const SkSurfaceProps& surfaceProps)
: SkMatrixProvider(/* fLocalToDevice = */ SkMatrix::I())
@@ -152,16 +149,6 @@
this->drawPath(path, paint, true);
}
-void SkBaseDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode bmode, const SkPaint& paint) {
- SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, &this->localToDevice());
- auto vertices = SkPatchUtils::MakeVertices(cubics, colors, texCoords, lod.width(), lod.height(),
- this->imageInfo().colorSpace());
- if (vertices) {
- this->drawVertices(vertices.get(), bmode, paint);
- }
-}
-
void SkBaseDevice::drawImageNine(const SkImage* image, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
SkLatticeIter iter(image->width(), image->height(), center, dst);
@@ -199,51 +186,6 @@
}
}
-static SkPoint* quad_to_tris(SkPoint tris[6], const SkPoint quad[4]) {
- tris[0] = quad[0];
- tris[1] = quad[1];
- tris[2] = quad[2];
-
- tris[3] = quad[0];
- tris[4] = quad[2];
- tris[5] = quad[3];
-
- return tris + 6;
-}
-
-void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
- const SkRect tex[], const SkColor colors[], int quadCount,
- SkBlendMode mode, const SkPaint& paint) {
- const int triCount = quadCount << 1;
- const int vertexCount = triCount * 3;
- uint32_t flags = SkVertices::kHasTexCoords_BuilderFlag;
- if (colors) {
- flags |= SkVertices::kHasColors_BuilderFlag;
- }
- SkVertices::Builder builder(SkVertices::kTriangles_VertexMode, vertexCount, 0, flags);
-
- SkPoint* vPos = builder.positions();
- SkPoint* vTex = builder.texCoords();
- SkColor* vCol = builder.colors();
- for (int i = 0; i < quadCount; ++i) {
- SkPoint tmp[4];
- xform[i].toQuad(tex[i].width(), tex[i].height(), tmp);
- vPos = quad_to_tris(vPos, tmp);
-
- tex[i].toQuad(tmp);
- vTex = quad_to_tris(vTex, tmp);
-
- if (colors) {
- sk_memset32(vCol, colors[i], 6);
- vCol += 6;
- }
- }
- SkPaint p(paint);
- p.setShader(atlas->makeShader());
- this->drawVertices(builder.detach().get(), mode, p);
-}
-
-
void SkBaseDevice::drawEdgeAAQuad(const SkRect& r, const SkPoint clip[4], SkCanvas::QuadAAFlags aa,
const SkColor4f& color, SkBlendMode mode) {
SkPaint paint;
@@ -309,12 +251,6 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-void SkBaseDevice::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix, SkCanvas* canvas) {
- drawable->draw(canvas, matrix);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
void SkBaseDevice::drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&) {}
sk_sp<SkSpecialImage> SkBaseDevice::makeSpecial(const SkBitmap&) { return nullptr; }
sk_sp<SkSpecialImage> SkBaseDevice::makeSpecial(const SkImage*) { return nullptr; }
@@ -361,54 +297,6 @@
#include "src/core/SkUtils.h"
-void SkBaseDevice::drawGlyphRunRSXform(const SkFont& font, const SkGlyphID glyphs[],
- const SkRSXform xform[], int count, SkPoint origin,
- const SkPaint& paint) {
- const SkM44 originalLocalToDevice = this->localToDevice44();
- if (!originalLocalToDevice.isFinite() || !SkScalarIsFinite(font.getSize()) ||
- !SkScalarIsFinite(font.getScaleX()) ||
- !SkScalarIsFinite(font.getSkewX())) {
- return;
- }
-
- SkPoint sharedPos{0, 0}; // we're at the origin
- SkGlyphID glyphID;
- SkGlyphRun glyphRun{
- font,
- SkSpan<const SkPoint>{&sharedPos, 1},
- SkSpan<const SkGlyphID>{&glyphID, 1},
- SkSpan<const char>{},
- SkSpan<const uint32_t>{}
- };
-
- for (int i = 0; i < count; i++) {
- glyphID = glyphs[i];
- // now "glyphRun" is pointing at the current glyphID
-
- SkMatrix glyphToDevice;
- glyphToDevice.setRSXform(xform[i]).postTranslate(origin.fX, origin.fY);
-
- // We want to rotate each glyph by the rsxform, but we don't want to rotate "space"
- // (i.e. the shader that cares about the ctm) so we have to undo our little ctm trick
- // with a localmatrixshader so that the shader draws as if there was no change to the ctm.
- SkPaint transformingPaint{paint};
- auto shader = transformingPaint.getShader();
- if (shader) {
- SkMatrix inverse;
- if (glyphToDevice.invert(&inverse)) {
- transformingPaint.setShader(shader->makeWithLocalMatrix(inverse));
- } else {
- transformingPaint.setShader(nullptr); // can't handle this xform
- }
- }
-
- this->setLocalToDevice(originalLocalToDevice * SkM44(glyphToDevice));
-
- this->drawGlyphRunList(SkGlyphRunList{glyphRun, transformingPaint});
- }
- this->setLocalToDevice(originalLocalToDevice);
-}
-
//////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps const&) {
diff --recursive --unified skia/src/core/SkDevice.h tiny-skia/skia/src/core/SkDevice.h
@@ -259,20 +259,6 @@
virtual void drawImageLattice(const SkImage*, const SkCanvas::Lattice&,
const SkRect& dst, const SkPaint&);
- virtual void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) = 0;
- virtual void drawShadow(const SkPath&, const SkDrawShadowRec&);
-
- virtual void drawGlyphRunList(const SkGlyphRunList& glyphRunList) = 0;
- // default implementation calls drawVertices
- virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint);
-
- // default implementation calls drawPath
- virtual void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[],
- const SkColor[], int count, SkBlendMode, const SkPaint&);
-
- virtual void drawAnnotation(const SkRect&, const char[], SkData*) {}
-
// Default impl always calls drawRect() with a solid-color paint, setting it to anti-aliased
// only when all edge flags are set. If there's a clip region, it draws that using drawPath,
// or uses clipPath().
@@ -290,11 +276,6 @@
*/
virtual void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) = 0;
- void drawGlyphRunRSXform(const SkFont&, const SkGlyphID[], const SkRSXform[], int count,
- SkPoint origin, const SkPaint& paint);
-
- virtual void drawDrawable(SkDrawable*, const SkMatrix*, SkCanvas*);
-
virtual void drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&);
virtual sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&);
virtual sk_sp<SkSpecialImage> makeSpecial(const SkImage*);
@@ -312,8 +293,6 @@
///////////////////////////////////////////////////////////////////////////
- virtual GrContext* context() const { return nullptr; }
-
virtual sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&);
virtual bool onPeekPixels(SkPixmap*) { return false; }
@@ -382,11 +361,6 @@
friend class SkSurface_Raster;
friend class DeviceTestingAccess;
- // Temporarily friend the SkGlyphRunBuilder until drawPosText is gone.
- friend class SkGlyphRun;
- friend class SkGlyphRunList;
- friend class SkGlyphRunBuilder;
-
// used to change the backend's pixels (and possibly config/rowbytes)
// but cannot change the width/height, so there should be no change to
// any clip information.
@@ -395,11 +369,6 @@
virtual bool forceConservativeRasterClip() const { return false; }
- /**
- * Don't call this!
- */
- virtual GrRenderTargetContext* accessRenderTargetContext() { return nullptr; }
-
// Configure the device's coordinate spaces, specifying both how its device image maps back to
// the global space (via 'deviceToGlobal') and the initial CTM of the device (via
// 'localToDevice', i.e. what geometry drawn into this device will be transformed with).
@@ -494,8 +463,6 @@
void drawRRect(const SkRRect&, const SkPaint&) override {}
void drawPath(const SkPath&, const SkPaint&, bool) override {}
void drawDevice(SkBaseDevice*, int, int, const SkPaint&) override {}
- void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override {}
- void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override {}
private:
typedef SkBaseDevice INHERITED;
Only in skia/src/core: SkDocument.cpp
Only in skia/src/core: SkDrawable.cpp
Only in skia/src/core: SkDraw_atlas.cpp
diff --recursive --unified skia/src/core/SkDraw.h tiny-skia/skia/src/core/SkDraw.h
@@ -14,7 +14,7 @@
#include "include/core/SkPaint.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkStrokeRec.h"
-#include "src/core/SkGlyphRunPainter.h"
+#include "src/core/SkArenaAlloc.h"
#include "src/core/SkMask.h"
class SkBitmap;
@@ -28,9 +28,8 @@
class SkRasterClip;
struct SkRect;
class SkRRect;
-class SkVertices;
-class SkDraw : public SkGlyphRunListPainter::BitmapDevicePainter {
+class SkDraw {
public:
SkDraw();
@@ -61,9 +60,6 @@
void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
const SkPaint&) const;
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
- void drawGlyphRunList(const SkGlyphRunList& glyphRunList,
- SkGlyphRunListPainter* glyphPainter) const;
- void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) const;
void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
SkBlendMode, const SkPaint&);
@@ -80,13 +76,6 @@
this->drawPath(src, paint, nullptr, false, !isHairline, customBlitter);
}
- void paintPaths(SkDrawableGlyphBuffer* drawables,
- SkScalar scale,
- SkPoint origin,
- const SkPaint& paint) const override;
-
- void paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint) const override;
-
static bool ComputeMaskBounds(const SkRect& devPathBounds, const SkIRect* clipBounds,
const SkMaskFilter* filter, const SkMatrix* filterMatrix,
SkIRect* bounds);
@@ -125,10 +114,6 @@
private:
void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const;
- void draw_fixed_vertices(const SkVertices*, SkBlendMode, const SkPaint&, const SkMatrix&,
- const SkPoint dev2[], const SkPoint3 dev3[], SkArenaAlloc*) const;
- void draw_vdata_vertices(const SkVertices*, const SkPaint&, const SkMatrix&,
- const SkPoint[], const SkPoint3[], SkArenaAlloc*) const;
void drawPath(const SkPath&,
const SkPaint&,
Only in skia/src/core: SkDrawLooper.cpp
diff --recursive --unified skia/src/core/SkDrawProcs.h tiny-skia/skia/src/core/SkDrawProcs.h
@@ -9,7 +9,6 @@
#define SkDrawProcs_DEFINED
#include "src/core/SkDraw.h"
-#include "src/core/SkGlyph.h"
bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
SkScalar* coverage);
Only in skia/src/core: SkDrawShadowInfo.cpp
Only in skia/src/core: SkDrawShadowInfo.h
Only in skia/src/core: SkDraw_text.cpp
Only in skia/src/core: SkDraw_vertices.cpp
Only in skia/src/core: SkExecutor.cpp
Only in skia/src/core: SkFixed15.h
Only in skia/src/core: SkFlattenable.cpp
Only in skia/src/core: SkFont.cpp
Only in skia/src/core: SkFontDescriptor.cpp
Only in skia/src/core: SkFontDescriptor.h
Only in skia/src/core: SkFontLCDConfig.cpp
Only in skia/src/core: SkFontMgr.cpp
Only in skia/src/core: SkFontMgrPriv.h
Only in skia/src/core: SkFontPriv.h
Only in skia/src/core: SkFont_serial.cpp
Only in skia/src/core: SkFontStream.cpp
Only in skia/src/core: SkFontStream.h
Only in skia/src/core: SkFuzzLogging.h
Only in skia/src/core: SkGlobalInitialization_core.cpp
Only in skia/src/core: SkGlyphBuffer.cpp
Only in skia/src/core: SkGlyphBuffer.h
Only in skia/src/core: SkGlyph.cpp
Only in skia/src/core: SkGlyph.h
Only in skia/src/core: SkGlyphRun.cpp
diff --recursive --unified skia/src/core/SkGlyphRun.h tiny-skia/skia/src/core/SkGlyphRun.h
@@ -11,165 +11,11 @@
#include <functional>
#include <vector>
-#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkTypes.h"
#include "include/private/SkTemplates.h"
#include "src/core/SkSpan.h"
-#include "src/core/SkZip.h"
-
-class SkBaseDevice;
-class SkGlyph;
-class SkTextBlob;
-class SkTextBlobRunIterator;
-
-class SkGlyphRun {
-public:
- SkGlyphRun() = default;
- SkGlyphRun(const SkFont& font,
- SkSpan<const SkPoint> positions,
- SkSpan<const SkGlyphID> glyphIDs,
- SkSpan<const char> text,
- SkSpan<const uint32_t> clusters);
- SkGlyphRun(const SkGlyphRun& glyphRun, const SkFont& font);
-
- size_t runSize() const { return fSource.size(); }
- SkSpan<const SkPoint> positions() const { return fSource.get<1>(); }
- SkSpan<const SkGlyphID> glyphsIDs() const { return fSource.get<0>(); }
- SkZip<const SkGlyphID, const SkPoint> source() const { return fSource; }
- const SkFont& font() const { return fFont; }
- SkSpan<const uint32_t> clusters() const { return fClusters; }
- SkSpan<const char> text() const { return fText; }
-
-private:
- // GlyphIDs and positions.
- const SkZip<const SkGlyphID, const SkPoint> fSource;
- // Original text from SkTextBlob if present. Will be empty of not present.
- const SkSpan<const char> fText;
- // Original clusters from SkTextBlob if present. Will be empty if not present.
- const SkSpan<const uint32_t> fClusters;
- // Paint for this run modified to have glyph encoding and left alignment.
- SkFont fFont;
-};
-
-class SkGlyphRunList {
- SkSpan<const SkGlyphRun> fGlyphRuns;
-
-public:
- SkGlyphRunList();
- // Blob maybe null.
- SkGlyphRunList(
- const SkPaint& paint,
- const SkTextBlob* blob,
- SkPoint origin,
- SkSpan<const SkGlyphRun> glyphRunList);
-
- SkGlyphRunList(const SkGlyphRun& glyphRun, const SkPaint& paint);
-
- uint64_t uniqueID() const;
- bool anyRunsLCD() const;
- bool anyRunsSubpixelPositioned() const;
- void temporaryShuntBlobNotifyAddedToCache(uint32_t cacheID) const;
-
- bool canCache() const { return fOriginalTextBlob != nullptr; }
- size_t runCount() const { return fGlyphRuns.size(); }
- size_t totalGlyphCount() const {
- size_t glyphCount = 0;
- for(const auto& run : fGlyphRuns) {
- glyphCount += run.runSize();
- }
- return glyphCount;
- }
- bool allFontsFinite() const;
-
- SkPoint origin() const { return fOrigin; }
- const SkPaint& paint() const { return *fOriginalPaint; }
- const SkTextBlob* blob() const { return fOriginalTextBlob; }
-
- auto begin() -> decltype(fGlyphRuns.begin()) { return fGlyphRuns.begin(); }
- auto end() -> decltype(fGlyphRuns.end()) { return fGlyphRuns.end(); }
- auto begin() const -> decltype(fGlyphRuns.cbegin()) { return fGlyphRuns.cbegin(); }
- auto end() const -> decltype(fGlyphRuns.cend()) { return fGlyphRuns.cend(); }
- auto size() const -> decltype(fGlyphRuns.size()) { return fGlyphRuns.size(); }
- auto empty() const -> decltype(fGlyphRuns.empty()) { return fGlyphRuns.empty(); }
- auto operator [] (size_t i) const -> decltype(fGlyphRuns[i]) { return fGlyphRuns[i]; }
-
-private:
- const SkPaint* fOriginalPaint{nullptr}; // This should be deleted soon.
- // The text blob is needed to hookup the call back that the SkTextBlob destructor calls. It
- // should be used for nothing else
- const SkTextBlob* fOriginalTextBlob{nullptr};
- SkPoint fOrigin = {0, 0};
-};
-
-class SkGlyphIDSet {
-public:
- SkSpan<const SkGlyphID> uniquifyGlyphIDs(
- uint32_t universeSize, SkSpan<const SkGlyphID> glyphIDs,
- SkGlyphID* uniqueGlyphIDs, uint16_t* denseindices);
-private:
- size_t fUniverseToUniqueSize{0};
- SkAutoTMalloc<uint16_t> fUniverseToUnique;
-};
-
-class SkGlyphRunBuilder {
-public:
- void drawTextUTF8(
- const SkPaint& paint, const SkFont&, const void* bytes, size_t byteLength, SkPoint origin);
- void drawGlyphsWithPositions(
- const SkPaint&, const SkFont&, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos);
- void drawTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin, SkBaseDevice*);
-
- void textBlobToGlyphRunListIgnoringRSXForm(
- const SkPaint& paint, const SkTextBlob& blob, SkPoint origin);
-
- const SkGlyphRunList& useGlyphRunList();
-
- bool empty() const { return fGlyphRunListStorage.empty(); }
-
-private:
- void initialize(size_t totalRunSize);
- SkSpan<const SkGlyphID> textToGlyphIDs(
- const SkFont& font, const void* bytes, size_t byteLength, SkTextEncoding);
-
- void makeGlyphRun(
- const SkFont& font,
- SkSpan<const SkGlyphID> glyphIDs,
- SkSpan<const SkPoint> positions,
- SkSpan<const char> text,
- SkSpan<const uint32_t> clusters);
-
- void makeGlyphRunList(const SkPaint& paint, const SkTextBlob* blob, SkPoint origin);
-
- void simplifyDrawText(
- const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
- SkPoint origin, SkPoint* positions,
- SkSpan<const char> text = SkSpan<const char>{},
- SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
- void simplifyDrawPosTextH(
- const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
- const SkScalar* xpos, SkScalar constY, SkPoint* positions,
- SkSpan<const char> text = SkSpan<const char>{},
- SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
- void simplifyDrawPosText(
- const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,
- const SkPoint* pos,
- SkSpan<const char> text = SkSpan<const char>{},
- SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
- void simplifyTextBlobIgnoringRSXForm(
- const SkTextBlobRunIterator& it,
- SkPoint* positions);
-
- size_t fMaxTotalRunSize{0};
- SkAutoTMalloc<SkPoint> fPositions;
-
- std::vector<SkGlyphRun> fGlyphRunListStorage;
- SkGlyphRunList fGlyphRunList;
-
- // Used as a temporary for preparing using utfN text. This implies that only one run of
- // glyph ids will ever be needed because blobs are already glyph based.
- std::vector<SkGlyphID> fScratchGlyphIDs;
-};
#endif // SkGlyphRun_DEFINED
+
Only in skia/src/core: SkGlyphRunPainter.cpp
Only in skia/src/core: SkGlyphRunPainter.h
Only in skia/src/core: SkGpuBlurUtils.cpp
Only in skia/src/core: SkGpuBlurUtils.h
diff --recursive --unified skia/src/core/SkGraphics.cpp tiny-skia/skia/src/core/SkGraphics.cpp
@@ -15,17 +15,13 @@
#include "include/core/SkRefCnt.h"
#include "include/core/SkShader.h"
#include "include/core/SkStream.h"
-#include "include/core/SkTime.h"
#include "src/core/SkBlitter.h"
#include "src/core/SkCpu.h"
#include "src/core/SkGeometry.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkOpts.h"
#include "src/core/SkResourceCache.h"
-#include "src/core/SkScalerContext.h"
-#include "src/core/SkStrikeCache.h"
#include "src/core/SkTSearch.h"
-#include "src/core/SkTypefaceCache.h"
#include <stdlib.h>
@@ -35,100 +31,7 @@
SkOpts::Init();
}
-///////////////////////////////////////////////////////////////////////////////
-
-void SkGraphics::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
- SkResourceCache::DumpMemoryStatistics(dump);
- SkStrikeCache::DumpMemoryStatistics(dump);
-}
-
void SkGraphics::PurgeAllCaches() {
- SkGraphics::PurgeFontCache();
SkGraphics::PurgeResourceCache();
SkImageFilter_Base::PurgeCache();
}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static const char kFontCacheLimitStr[] = "font-cache-limit";
-static const size_t kFontCacheLimitLen = sizeof(kFontCacheLimitStr) - 1;
-
-static const struct {
- const char* fStr;
- size_t fLen;
- size_t (*fFunc)(size_t);
-} gFlags[] = {
- { kFontCacheLimitStr, kFontCacheLimitLen, SkGraphics::SetFontCacheLimit }
-};
-
-/* flags are of the form param; or param=value; */
-void SkGraphics::SetFlags(const char* flags) {
- if (!flags) {
- return;
- }
- const char* nextSemi;
- do {
- size_t len = strlen(flags);
- const char* paramEnd = flags + len;
- const char* nextEqual = strchr(flags, '=');
- if (nextEqual && paramEnd > nextEqual) {
- paramEnd = nextEqual;
- }
- nextSemi = strchr(flags, ';');
- if (nextSemi && paramEnd > nextSemi) {
- paramEnd = nextSemi;
- }
- size_t paramLen = paramEnd - flags;
- for (int i = 0; i < (int)SK_ARRAY_COUNT(gFlags); ++i) {
- if (paramLen != gFlags[i].fLen) {
- continue;
- }
- if (strncmp(flags, gFlags[i].fStr, paramLen) == 0) {
- size_t val = 0;
- if (nextEqual) {
- val = (size_t) atoi(nextEqual + 1);
- }
- (gFlags[i].fFunc)(val);
- break;
- }
- }
- flags = nextSemi + 1;
- } while (nextSemi);
-}
-
-size_t SkGraphics::GetFontCacheLimit() {
- return SkStrikeCache::GlobalStrikeCache()->getCacheSizeLimit();
-}
-
-size_t SkGraphics::SetFontCacheLimit(size_t bytes) {
- return SkStrikeCache::GlobalStrikeCache()->setCacheSizeLimit(bytes);
-}
-
-size_t SkGraphics::GetFontCacheUsed() {
- return SkStrikeCache::GlobalStrikeCache()->getTotalMemoryUsed();
-}
-
-int SkGraphics::GetFontCacheCountLimit() {
- return SkStrikeCache::GlobalStrikeCache()->getCacheCountLimit();
-}
-
-int SkGraphics::SetFontCacheCountLimit(int count) {
- return SkStrikeCache::GlobalStrikeCache()->setCacheCountLimit(count);
-}
-
-int SkGraphics::GetFontCacheCountUsed() {
- return SkStrikeCache::GlobalStrikeCache()->getCacheCountUsed();
-}
-
-int SkGraphics::GetFontCachePointSizeLimit() {
- return SkStrikeCache::GlobalStrikeCache()->getCachePointSizeLimit();
-}
-
-int SkGraphics::SetFontCachePointSizeLimit(int limit) {
- return SkStrikeCache::GlobalStrikeCache()->setCachePointSizeLimit(limit);
-}
-
-void SkGraphics::PurgeFontCache() {
- SkStrikeCache::GlobalStrikeCache()->purgeAll();
- SkTypefaceCache::PurgeAll();
-}
Only in skia/src/core: SkICC.cpp
Only in skia/src/core: SkICCPriv.h
diff --recursive --unified skia/src/core/SkImageFilter_Base.h tiny-skia/skia/src/core/SkImageFilter_Base.h
@@ -15,9 +15,6 @@
#include "src/core/SkImageFilterTypes.h"
-class GrFragmentProcessor;
-class GrRecordingContext;
-
// True base class that all SkImageFilter implementations need to extend from. This provides the
// actual API surface that Skia will use to compute the filtered images.
class SkImageFilter_Base : public SkImageFilter {
@@ -185,8 +182,6 @@
~SkImageFilter_Base() override;
- void flatten(SkWriteBuffer&) const override;
-
// DEPRECATED - Use the private context-only variant
virtual sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const = 0;
@@ -279,24 +274,6 @@
// other filters to need to call it.
Context mapContext(const Context& ctx) const;
-#if SK_SUPPORT_GPU
- static sk_sp<SkSpecialImage> DrawWithFP(GrRecordingContext* context,
- std::unique_ptr<GrFragmentProcessor> fp,
- const SkIRect& bounds,
- SkColorType colorType,
- const SkColorSpace* colorSpace,
- GrProtected isProtected = GrProtected::kNo);
-
- /**
- * Returns a version of the passed-in image (possibly the original), that is in a colorspace
- * with the same gamut as the one from the OutputProperties. This allows filters that do many
- * texture samples to guarantee that any color space conversion has happened before running.
- */
- static sk_sp<SkSpecialImage> ImageToColorSpace(SkSpecialImage* src,
- SkColorType colorType,
- SkColorSpace* colorSpace);
-#endif
-
// If 'srcBounds' will sample outside the border of 'originalSrcBounds' (i.e., the sample
// will wrap around to the other side) we must preserve the far side of the src along that
// axis (e.g., if we will sample beyond the left edge of the src, the right side must be
diff --recursive --unified skia/src/core/SkImageFilter.cpp tiny-skia/skia/src/core/SkImageFilter.cpp
@@ -9,28 +9,16 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkRect.h"
-#include "include/effects/SkComposeImageFilter.h"
+#include "include/core/SkColorFilter.h"
#include "include/private/SkSafe32.h"
-#include "src/core/SkFuzzLogging.h"
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkLocalMatrixImageFilter.h"
#include "src/core/SkMatrixImageFilter.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkSpecialImage.h"
#include "src/core/SkSpecialSurface.h"
#include "src/core/SkValidationUtils.h"
-#include "src/core/SkWriteBuffer.h"
-#if SK_SUPPORT_GPU
-#include "include/gpu/GrContext.h"
-#include "include/private/GrRecordingContext.h"
-#include "src/gpu/GrColorSpaceXform.h"
-#include "src/gpu/GrContextPriv.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrRenderTargetContext.h"
-#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/SkGr.h"
-#endif
+#include "src/core/SkColorFilterBase.h"
#include <atomic>
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -166,46 +154,6 @@
SkImageFilterCache::Get()->purgeByImageFilter(this);
}
-bool SkImageFilter_Base::Common::unflatten(SkReadBuffer& buffer, int expectedCount) {
- const int count = buffer.readInt();
- if (!buffer.validate(count >= 0)) {
- return false;
- }
- if (!buffer.validate(expectedCount < 0 || count == expectedCount)) {
- return false;
- }
-
- SkASSERT(fInputs.empty());
- for (int i = 0; i < count; i++) {
- fInputs.push_back(buffer.readBool() ? buffer.readImageFilter() : nullptr);
- if (!buffer.isValid()) {
- return false;
- }
- }
- SkRect rect;
- buffer.readRect(&rect);
- if (!buffer.isValid() || !buffer.validate(SkIsValidRect(rect))) {
- return false;
- }
-
- uint32_t flags = buffer.readUInt();
- fCropRect = CropRect(rect, flags);
- return buffer.isValid();
-}
-
-void SkImageFilter_Base::flatten(SkWriteBuffer& buffer) const {
- buffer.writeInt(fInputs.count());
- for (int i = 0; i < fInputs.count(); i++) {
- const SkImageFilter* input = this->getInput(i);
- buffer.writeBool(input != nullptr);
- if (input != nullptr) {
- buffer.writeFlattenable(input);
- }
- }
- buffer.writeRect(fCropRect.rect());
- buffer.writeUInt(fCropRect.flags());
-}
-
skif::FilterResult<For::kOutput> SkImageFilter_Base::filterImage(const skif::Context& context) const {
// TODO (michaelludwig) - Old filters have an implicit assumption that the source image
// (originally passed separately) has an origin of (0, 0). SkComposeImageFilter makes an effort
@@ -558,68 +506,6 @@
return ctx.withNewDesiredOutput(childOutput);
}
-#if SK_SUPPORT_GPU
-sk_sp<SkSpecialImage> SkImageFilter_Base::DrawWithFP(GrRecordingContext* context,
- std::unique_ptr<GrFragmentProcessor> fp,
- const SkIRect& bounds,
- SkColorType colorType,
- const SkColorSpace* colorSpace,
- GrProtected isProtected) {
- GrPaint paint;
- paint.addColorFragmentProcessor(std::move(fp));
- paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
-
- auto renderTargetContext = GrRenderTargetContext::Make(
- context, SkColorTypeToGrColorType(colorType), sk_ref_sp(colorSpace),
- SkBackingFit::kApprox, bounds.size(), 1, GrMipMapped::kNo, isProtected,
- kBottomLeft_GrSurfaceOrigin);
- if (!renderTargetContext) {
- return nullptr;
- }
-
- SkIRect dstIRect = SkIRect::MakeWH(bounds.width(), bounds.height());
- SkRect srcRect = SkRect::Make(bounds);
- SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- renderTargetContext->fillRectToRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
- dstRect, srcRect);
-
- return SkSpecialImage::MakeDeferredFromGpu(
- context, dstIRect, kNeedNewImageUniqueID_SpecialImage,
- renderTargetContext->readSurfaceView(), renderTargetContext->colorInfo().colorType(),
- renderTargetContext->colorInfo().refColorSpace());
-}
-
-sk_sp<SkSpecialImage> SkImageFilter_Base::ImageToColorSpace(SkSpecialImage* src,
- SkColorType colorType,
- SkColorSpace* colorSpace) {
- // There are several conditions that determine if we actually need to convert the source to the
- // destination's color space. Rather than duplicate that logic here, just try to make an xform
- // object. If that produces something, then both are tagged, and the source is in a different
- // gamut than the dest. There is some overhead to making the xform, but those are cached, and
- // if we get one back, that means we're about to use it during the conversion anyway.
- auto colorSpaceXform = GrColorSpaceXform::Make(src->getColorSpace(), src->alphaType(),
- colorSpace, kPremul_SkAlphaType);
-
- if (!colorSpaceXform) {
- // No xform needed, just return the original image
- return sk_ref_sp(src);
- }
-
- sk_sp<SkSpecialSurface> surf(src->makeSurface(colorType, colorSpace,
- SkISize::Make(src->width(), src->height())));
- if (!surf) {
- return sk_ref_sp(src);
- }
-
- SkCanvas* canvas = surf->getCanvas();
- SkASSERT(canvas);
- SkPaint p;
- p.setBlendMode(SkBlendMode::kSrc);
- src->draw(canvas, 0, 0, &p);
- return surf->makeImageSnapshot();
-}
-#endif
-
// In repeat mode, when we are going to sample off one edge of the srcBounds we require the
// opposite side be preserved.
SkIRect SkImageFilter_Base::DetermineRepeatedSrcBound(const SkIRect& srcBounds,
diff --recursive --unified skia/src/core/SkImageFilterTypes.h tiny-skia/skia/src/core/SkImageFilterTypes.h
@@ -12,7 +12,6 @@
#include "src/core/SkSpecialImage.h"
#include "src/core/SkSpecialSurface.h"
-class GrRecordingContext;
class SkImageFilter;
class SkImageFilterCache;
class SkSpecialSurface;
@@ -635,9 +634,6 @@
// The output device's color type, which can be used for intermediate images to be
// compatible with the eventual target of the filtered result.
SkColorType colorType() const { return fColorType; }
-#if SK_SUPPORT_GPU
- GrColorType grColorType() const { return SkColorTypeToGrColorType(fColorType); }
-#endif
// The output device's color space, so intermediate images can match, and so filtering can
// be performed in the destination color space.
SkColorSpace* colorSpace() const { return fColorSpace; }
@@ -656,8 +652,6 @@
// True if image filtering should occur on the GPU if possible.
bool gpuBacked() const { return fSource.image()->isTextureBacked(); }
- // The recording context to use when computing the filter with the GPU.
- GrRecordingContext* getContext() const { return fSource.image()->getContext(); }
/**
* Since a context can be built directly, its constructor has no chance to "return null" if
Only in skia/src/core: SkImageGenerator.cpp
diff --recursive --unified skia/src/core/SkImageInfo.cpp tiny-skia/skia/src/core/SkImageInfo.cpp
@@ -6,9 +6,7 @@
*/
#include "include/private/SkImageInfoPriv.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkSafeMath.h"
-#include "src/core/SkWriteBuffer.h"
int SkColorTypeBytesPerPixel(SkColorType ct) {
switch (ct) {
diff --recursive --unified skia/src/core/SkImagePriv.h tiny-skia/skia/src/core/SkImagePriv.h
@@ -11,6 +11,7 @@
#include "include/core/SkImage.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTileMode.h"
+#include "include/core/SkPixelRef.h"
enum SkCopyPixelsMode {
kIfMutable_SkCopyPixelsMode, //!< only copy src pixels if they are marked mutable
@@ -60,32 +61,6 @@
extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
/**
- * Will attempt to upload and lock the contents of the image as a texture, so that subsequent
- * draws to a gpu-target will come from that texture (and not by looking at the original image
- * src). In particular this is intended to use the texture even if the image's original content
- * changes subsequent to this call (i.e. the src is mutable!).
- *
- * All successful calls must be balanced by an equal number of calls to SkImage_unpinAsTexture().
- *
- * Once in this "pinned" state, the image has all of the same thread restrictions that exist
- * for a natively created gpu image (e.g. SkImage::MakeFromTexture)
- * - all drawing, pinning, unpinning must happen in the same thread as the GrContext.
- *
- * @return true if the image was successfully uploaded and locked into a texture
- */
-bool SkImage_pinAsTexture(const SkImage*, GrContext*);
-
-/**
- * The balancing call to a successful invokation of SkImage_pinAsTexture. When a balanced number of
- * calls have been made, then the "pinned" texture is free to be purged, etc. This also means that a
- * subsequent "pin" call will look at the original content again, and if its uniqueID/generationID
- * has changed, then a newer texture will be uploaded/pinned.
- *
- * The context passed to unpin must match the one passed to pin.
- */
-void SkImage_unpinAsTexture(const SkImage*, GrContext*);
-
-/**
* Returns the bounds of the image relative to its encoded buffer. For all non-lazy images,
* this returns (0,0,width,height). For a lazy-image, it may return a subset of that rect.
*/
Only in skia/src/core: SkLegacyGpuBlurUtils.cpp
diff --recursive --unified skia/src/core/SkLocalMatrixImageFilter.cpp tiny-skia/skia/src/core/SkLocalMatrixImageFilter.cpp
@@ -7,7 +7,6 @@
#include "include/core/SkString.h"
#include "src/core/SkLocalMatrixImageFilter.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkSpecialImage.h"
sk_sp<SkImageFilter> SkLocalMatrixImageFilter::Make(const SkMatrix& localM,
@@ -31,18 +30,6 @@
, fLocalM(localM) {
}
-sk_sp<SkFlattenable> SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
- SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
- SkMatrix lm;
- buffer.readMatrix(&lm);
- return SkLocalMatrixImageFilter::Make(lm, common.getInput(0));
-}
-
-void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writeMatrix(fLocalM);
-}
-
sk_sp<SkSpecialImage> SkLocalMatrixImageFilter::onFilterImage(const Context& ctx,
SkIPoint* offset) const {
Context localCtx = ctx.withNewMapping(ctx.mapping().concatLocal(fLocalM));
diff --recursive --unified skia/src/core/SkLocalMatrixImageFilter.h tiny-skia/skia/src/core/SkLocalMatrixImageFilter.h
@@ -8,7 +8,6 @@
#ifndef SkLocalMatrixImageFilter_DEFINED
#define SkLocalMatrixImageFilter_DEFINED
-#include "include/core/SkFlattenable.h"
#include "src/core/SkImageFilter_Base.h"
/**
@@ -22,7 +21,6 @@
SkRect computeFastBounds(const SkRect&) const override;
protected:
- void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;
@@ -30,8 +28,6 @@
bool onCanHandleComplexCTM() const override { return true; }
private:
- SK_FLATTENABLE_HOOKS(SkLocalMatrixImageFilter)
-
SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input);
SkMatrix fLocalM;
diff --recursive --unified skia/src/core/SkMaskFilterBase.h tiny-skia/skia/src/core/SkMaskFilterBase.h
@@ -9,30 +9,12 @@
#define SkMaskFilterBase_DEFINED
#include "include/core/SkBlurTypes.h"
-#include "include/core/SkFlattenable.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkStrokeRec.h"
#include "include/private/SkNoncopyable.h"
#include "src/core/SkMask.h"
-#if SK_SUPPORT_GPU
-#include "include/private/GrTypesPriv.h"
-#endif
-
-class GrClip;
-struct GrFPArgs;
-class GrFragmentProcessor;
-class GrPaint;
-class GrRecordingContext;
-class GrRenderTarget;
-class GrRenderTargetContext;
-class GrResourceProvider;
-class GrStyledShape;
-class GrSurfaceProxyView;
-class GrTexture;
-class GrTextureProxy;
-
class SkBitmap;
class SkBlitter;
class SkCachedData;
@@ -64,77 +46,6 @@
virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
SkIPoint* margin) const = 0;
-#if SK_SUPPORT_GPU
- /**
- * Returns a processor if the filter can be expressed a single-pass GrProcessor without
- * requiring an explicit input mask. Per-pixel, the effect receives the incoming mask's
- * coverage as the input color and outputs the filtered covereage value. This means that each
- * pixel's filtered coverage must only depend on the unfiltered mask value for that pixel and
- * not on surrounding values.
- */
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs& args) const;
-
- /**
- * Returns true iff asFragmentProcessor() will return a processor
- */
- bool hasFragmentProcessor() const;
-
- /**
- * If asFragmentProcessor() fails the filter may be implemented on the GPU by a subclass
- * overriding filterMaskGPU (declared below). That code path requires constructing a
- * src mask as input. Since that is a potentially expensive operation, the subclass must also
- * override this function to indicate whether filterTextureMaskGPU would succeeed if the mask
- * were to be created.
- *
- * 'maskRect' returns the device space portion of the mask that the filter needs. The mask
- * passed into 'filterMaskGPU' should have the same extent as 'maskRect' but be
- * translated to the upper-left corner of the mask (i.e., (maskRect.fLeft, maskRect.fTop)
- * appears at (0, 0) in the mask).
- *
- * Logically, how this works is:
- * canFilterMaskGPU is called
- * if (it returns true)
- * the returned mask rect is used for quick rejecting
- * the mask rect is used to generate the mask
- * filterMaskGPU is called to filter the mask
- *
- * TODO: this should work as:
- * if (canFilterMaskGPU(devShape, ...)) // rect, rrect, drrect, path
- * filterMaskGPU(devShape, ...)
- * this would hide the RRect special case and the mask generation
- */
- virtual bool canFilterMaskGPU(const GrStyledShape&,
- const SkIRect& devSpaceShapeBounds,
- const SkIRect& clipBounds,
- const SkMatrix& ctm,
- SkIRect* maskRect) const;
-
- /**
- * Try to directly render the mask filter into the target. Returns true if drawing was
- * successful. If false is returned then paint is unmodified.
- */
- virtual bool directFilterMaskGPU(GrRecordingContext*,
- GrRenderTargetContext*,
- GrPaint&& paint,
- const GrClip*,
- const SkMatrix& viewMatrix,
- const GrStyledShape& shape) const;
-
- /**
- * This function is used to implement filters that require an explicit src mask. It should only
- * be called if canFilterMaskGPU returned true and the maskRect param should be the output from
- * that call.
- * Implementations are free to get the GrContext from the src texture in order to create
- * additional textures and perform multiple passes.
- */
- virtual GrSurfaceProxyView filterMaskGPU(GrRecordingContext*,
- GrSurfaceProxyView srcView,
- GrColorType srcColorType,
- SkAlphaType srcAlphaType,
- const SkMatrix& ctm,
- const SkIRect& maskRect) const;
-#endif
-
/**
* The fast bounds function is used to enable the paint to be culled early
* in the drawing pipeline. This function accepts the current bounds of the
@@ -162,11 +73,6 @@
protected:
SkMaskFilterBase() {}
-#if SK_SUPPORT_GPU
- virtual std::unique_ptr<GrFragmentProcessor> onAsFragmentProcessor(const GrFPArgs&) const;
- virtual bool onHasFragmentProcessor() const;
-#endif
-
enum FilterReturn {
kFalse_FilterReturn,
kTrue_FilterReturn,
@@ -227,8 +133,6 @@
*/
bool filterRRect(const SkRRect& devRRect, const SkMatrix& ctm, const SkRasterClip&,
SkBlitter*) const;
-
- typedef SkFlattenable INHERITED;
};
inline SkMaskFilterBase* as_MFB(SkMaskFilter* mf) {
diff --recursive --unified skia/src/core/SkMaskFilter.cpp tiny-skia/skia/src/core/SkMaskFilter.cpp
@@ -17,15 +17,6 @@
#include "src/core/SkDraw.h"
#include "src/core/SkPathPriv.h"
#include "src/core/SkRasterClip.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
-
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrFragmentProcessor.h"
-#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
-#include "src/gpu/text/GrSDFMaskFilter.h"
-#endif
SkMaskFilterBase::NinePatch::~NinePatch() {
if (fCache) {
@@ -303,54 +294,6 @@
return kUnimplemented_FilterReturn;
}
-#if SK_SUPPORT_GPU
-std::unique_ptr<GrFragmentProcessor>
-SkMaskFilterBase::asFragmentProcessor(const GrFPArgs& args) const {
- auto fp = this->onAsFragmentProcessor(args);
- if (fp) {
- SkASSERT(this->hasFragmentProcessor());
- } else {
- SkASSERT(!this->hasFragmentProcessor());
- }
- return fp;
-}
-bool SkMaskFilterBase::hasFragmentProcessor() const {
- return this->onHasFragmentProcessor();
-}
-
-std::unique_ptr<GrFragmentProcessor>
-SkMaskFilterBase::onAsFragmentProcessor(const GrFPArgs&) const {
- return nullptr;
-}
-bool SkMaskFilterBase::onHasFragmentProcessor() const { return false; }
-
-bool SkMaskFilterBase::canFilterMaskGPU(const GrStyledShape& shape,
- const SkIRect& devSpaceShapeBounds,
- const SkIRect& clipBounds,
- const SkMatrix& ctm,
- SkIRect* maskRect) const {
- return false;
-}
-
-bool SkMaskFilterBase::directFilterMaskGPU(GrRecordingContext*,
- GrRenderTargetContext*,
- GrPaint&&,
- const GrClip*,
- const SkMatrix& viewMatrix,
- const GrStyledShape&) const {
- return false;
-}
-
-GrSurfaceProxyView SkMaskFilterBase::filterMaskGPU(GrRecordingContext*,
- GrSurfaceProxyView view,
- GrColorType srcColorType,
- SkAlphaType srcAlphaType,
- const SkMatrix& ctm,
- const SkIRect& maskRect) const {
- return {};
-}
-#endif
-
void SkMaskFilterBase::computeFastBounds(const SkRect& src, SkRect* dst) const {
SkMask srcM, dstM;
@@ -365,10 +308,3 @@
dst->set(srcM.fBounds);
}
}
-
-void SkMaskFilter::RegisterFlattenables() {
- sk_register_blur_maskfilter_createproc();
-#if SK_SUPPORT_GPU
- gr_register_sdf_maskfilter_createproc();
-#endif
-}
Only in skia/src/core: SkMaskGamma.cpp
Only in skia/src/core: SkMaskGamma.h
diff --recursive --unified skia/src/core/SkMatrixImageFilter.cpp tiny-skia/skia/src/core/SkMatrixImageFilter.cpp
@@ -9,10 +9,8 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkRect.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkSpecialImage.h"
#include "src/core/SkSpecialSurface.h"
-#include "src/core/SkWriteBuffer.h"
SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform,
SkFilterQuality filterQuality,
@@ -30,20 +28,6 @@
std::move(input)));
}
-sk_sp<SkFlattenable> SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
- SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
- SkMatrix matrix;
- buffer.readMatrix(&matrix);
-
- return Make(matrix, buffer.read32LE(kLast_SkFilterQuality), common.getInput(0));
-}
-
-void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writeMatrix(fTransform);
- buffer.writeInt(fFilterQuality);
-}
-
sk_sp<SkSpecialImage> SkMatrixImageFilter::onFilterImage(const Context& ctx,
SkIPoint* offset) const {
diff --recursive --unified skia/src/core/SkMatrixImageFilter.h tiny-skia/skia/src/core/SkMatrixImageFilter.h
@@ -8,7 +8,6 @@
#ifndef SkMatrixImageFilter_DEFINED
#define SkMatrixImageFilter_DEFINED
-#include "include/core/SkFlattenable.h"
#include "include/core/SkMatrix.h"
#include "src/core/SkImageFilter_Base.h"
@@ -36,15 +35,12 @@
SkMatrixImageFilter(const SkMatrix& transform,
SkFilterQuality,
sk_sp<SkImageFilter> input);
- void flatten(SkWriteBuffer&) const override;
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;
private:
- SK_FLATTENABLE_HOOKS(SkMatrixImageFilter)
-
SkMatrix fTransform;
SkFilterQuality fFilterQuality;
typedef SkImageFilter_Base INHERITED;
Only in skia/src/core: SkMD5.cpp
Only in skia/src/core: SkMD5.h
Only in skia/src/core: SkMiniRecorder.cpp
Only in skia/src/core: SkMiniRecorder.h
diff --recursive --unified skia/src/core/SkModeColorFilter.cpp tiny-skia/skia/src/core/SkModeColorFilter.cpp
@@ -16,10 +16,9 @@
#include "src/core/SkColorSpaceXformSteps.h"
#include "src/core/SkModeColorFilter.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
#include "src/core/SkValidationUtils.h"
-#include "src/core/SkWriteBuffer.h"
+#include "src/core/SkEffectPriv.h"
//////////////////////////////////////////////////////////////////////////////////////////////////
@@ -51,17 +50,6 @@
return flags;
}
-void SkModeColorFilter::flatten(SkWriteBuffer& buffer) const {
- buffer.writeColor(fColor);
- buffer.writeUInt((int)fMode);
-}
-
-sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
- SkColor color = buffer.readColor();
- SkBlendMode mode = (SkBlendMode)buffer.readUInt();
- return SkColorFilters::Blend(color, mode);
-}
-
bool SkModeColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
rec.fPipeline->append(SkRasterPipeline::move_src_dst);
SkColor4f color = SkColor4f::FromColor(fColor);
@@ -82,38 +70,6 @@
}
///////////////////////////////////////////////////////////////////////////////
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrBlend.h"
-#include "src/gpu/SkGr.h"
-#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
-#include "src/gpu/effects/generated/GrConstColorProcessor.h"
-
-std::unique_ptr<GrFragmentProcessor> SkModeColorFilter::asFragmentProcessor(
- GrRecordingContext*, const GrColorInfo& dstColorInfo) const {
- if (SkBlendMode::kDst == fMode) {
- return nullptr;
- }
-
- auto constFP = GrConstColorProcessor::Make(/*inputFP=*/nullptr,
- SkColorToPMColor4f(fColor, dstColorInfo),
- GrConstColorProcessor::InputMode::kIgnore);
- auto fp = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(constFP), fMode);
- if (!fp) {
- return nullptr;
- }
-#ifdef SK_DEBUG
- // With a solid color input this should always be able to compute the blended color
- // (at least for coeff modes)
- if ((unsigned)fMode <= (unsigned)SkBlendMode::kLastCoeffMode) {
- SkASSERT(fp->hasConstantOutputForConstantInput());
- }
-#endif
- return fp;
-}
-
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
sk_sp<SkColorFilter> SkColorFilters::Blend(SkColor color, SkBlendMode mode) {
if (!SkIsValidMode(mode)) {
diff --recursive --unified skia/src/core/SkModeColorFilter.h tiny-skia/skia/src/core/SkModeColorFilter.h
@@ -18,17 +18,9 @@
uint32_t onGetFlags() const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
- const GrColorInfo&) const override;
-#endif
-
- SK_FLATTENABLE_HOOKS(SkModeColorFilter)
-
protected:
SkModeColorFilter(SkColor color, SkBlendMode mode);
- void flatten(SkWriteBuffer&) const override;
bool onAsAColorMode(SkColor*, SkBlendMode*) const override;
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
diff --recursive --unified skia/src/core/SkOpts.cpp tiny-skia/skia/src/core/SkOpts.cpp
@@ -38,7 +38,6 @@
#define SK_OPTS_NS portable
#endif
-#include "src/core/SkCubicSolver.h"
#include "src/opts/SkBitmapProcState_opts.h"
#include "src/opts/SkBlitMask_opts.h"
#include "src/opts/SkBlitRow_opts.h"
@@ -81,8 +80,6 @@
DEFINE_DEFAULT(rect_memset32);
DEFINE_DEFAULT(rect_memset64);
- DEFINE_DEFAULT(cubic_solver);
-
DEFINE_DEFAULT(hash_fn);
DEFINE_DEFAULT(S32_alpha_D32_filter_DX);
@@ -126,7 +123,7 @@
#if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_AVX
if (SkCpu::Supports(SkCpu::AVX)) { Init_avx(); }
- if (SkCpu::Supports(SkCpu::HSW)) { Init_hsw(); }
+// if (SkCpu::Supports(SkCpu::HSW)) { Init_hsw(); }
#endif
#if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SKX
Only in skia/src/core: SkOrderedReadBuffer.h
Only in skia/src/core: SkOSFile.h
Only in skia/src/core: SkOverdrawCanvas.cpp
diff --recursive --unified skia/src/core/SkPaint.cpp tiny-skia/skia/src/core/SkPaint.cpp
@@ -15,24 +15,20 @@
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkStrokeRec.h"
-#include "include/core/SkTypeface.h"
#include "include/private/SkMutex.h"
#include "include/private/SkTo.h"
#include "src/core/SkColorFilterBase.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkColorSpaceXformSteps.h"
#include "src/core/SkDraw.h"
-#include "src/core/SkMaskGamma.h"
#include "src/core/SkOpts.h"
#include "src/core/SkPaintDefaults.h"
#include "src/core/SkPaintPriv.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkSafeRange.h"
-#include "src/core/SkStringUtils.h"
#include "src/core/SkStroke.h"
#include "src/core/SkSurfacePriv.h"
#include "src/core/SkTLazy.h"
-#include "src/core/SkWriteBuffer.h"
+#include "src/core/SkMaskFilterBase.h"
#include "src/shaders/SkShaderBase.h"
// define this to get a printf for out-of-range parameter in setters
@@ -187,263 +183,6 @@
///////////////////////////////////////////////////////////////////////////////
-#include "include/core/SkStream.h"
-
-#ifdef SK_DEBUG
- static void ASSERT_FITS_IN(uint32_t value, int bitCount) {
- SkASSERT(bitCount > 0 && bitCount <= 32);
- uint32_t mask = ~0U;
- mask >>= (32 - bitCount);
- SkASSERT(0 == (value & ~mask));
- }
-#else
- #define ASSERT_FITS_IN(value, bitcount)
-#endif
-
-enum FlatFlags {
- kHasTypeface_FlatFlag = 0x1,
- kHasEffects_FlatFlag = 0x2,
-
- kFlatFlagMask = 0x3,
-};
-
-enum BitsPerField {
- kFlags_BPF = 16,
- kHint_BPF = 2,
- kFilter_BPF = 2,
- kFlatFlags_BPF = 3,
-};
-
-static inline int BPF_Mask(int bits) {
- return (1 << bits) - 1;
-}
-
-// SkPaint originally defined flags, some of which now apply to SkFont. These are renames
-// of those flags, split into categories depending on which objects they (now) apply to.
-
-enum PaintFlagsForPaint {
- kAA_PaintFlagForPaint = 0x01,
- kDither_PaintFlagForPaint = 0x04,
-};
-
-enum PaintFlagsForFont {
- kFakeBold_PaintFlagForFont = 0x20,
- kLinear_PaintFlagForFont = 0x40,
- kSubpixel_PaintFlagForFont = 0x80,
- kLCD_PaintFlagForFont = 0x200,
- kEmbeddedBitmap_PaintFlagForFont = 0x400,
- kAutoHinting_PaintFlagForFont = 0x800,
-};
-
-static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed, SkFont* font) {
- uint32_t f = packed >> 16;
- paint->setAntiAlias((f & kAA_PaintFlagForPaint) != 0);
- paint->setDither((f & kDither_PaintFlagForPaint) != 0);
- if (font) {
- font->setEmbolden((f & kFakeBold_PaintFlagForFont) != 0);
- font->setLinearMetrics((f & kLinear_PaintFlagForFont) != 0);
- font->setSubpixel((f & kSubpixel_PaintFlagForFont) != 0);
- font->setEmbeddedBitmaps((f & kEmbeddedBitmap_PaintFlagForFont) != 0);
- font->setForceAutoHinting((f & kAutoHinting_PaintFlagForFont) != 0);
-
- font->setHinting((SkFontHinting)((packed >> 14) & BPF_Mask(kHint_BPF)));
-
- if (f & kAA_PaintFlagForPaint) {
- if (f & kLCD_PaintFlagForFont) {
- font->setEdging(SkFont::Edging::kSubpixelAntiAlias);
- } else {
- font->setEdging(SkFont::Edging::kAntiAlias);
- }
- } else {
- font->setEdging(SkFont::Edging::kAlias);
- }
- }
-
- paint->setFilterQuality((SkFilterQuality)((packed >> 10) & BPF_Mask(kFilter_BPF)));
- return (FlatFlags)(packed & kFlatFlagMask);
-}
-
-template <typename T> uint32_t shift_bits(T value, unsigned shift, unsigned bits) {
- SkASSERT(shift + bits <= 32);
- uint32_t v = static_cast<uint32_t>(value);
- ASSERT_FITS_IN(v, bits);
- return v << shift;
-}
-
-/* Packing the paint
- flags : 8 // 2...
- blend : 8 // 30+
- cap : 2 // 3
- join : 2 // 3
- style : 2 // 3
- filter: 2 // 4
- flat : 8 // 1...
- total : 32
- */
-static uint32_t pack_v68(const SkPaint& paint, unsigned flatFlags) {
- uint32_t packed = 0;
- packed |= shift_bits(((unsigned)paint.isDither() << 1) |
- (unsigned)paint.isAntiAlias(), 0, 8);
- packed |= shift_bits(paint.getBlendMode(), 8, 8);
- packed |= shift_bits(paint.getStrokeCap(), 16, 2);
- packed |= shift_bits(paint.getStrokeJoin(), 18, 2);
- packed |= shift_bits(paint.getStyle(), 20, 2);
- packed |= shift_bits(paint.getFilterQuality(), 22, 2);
- packed |= shift_bits(flatFlags, 24, 8);
- return packed;
-}
-
-static uint32_t unpack_v68(SkPaint* paint, uint32_t packed, SkSafeRange& safe) {
- paint->setAntiAlias((packed & 1) != 0);
- paint->setDither((packed & 2) != 0);
- packed >>= 8;
- paint->setBlendMode(safe.checkLE(packed & 0xFF, SkBlendMode::kLastMode));
- packed >>= 8;
- paint->setStrokeCap(safe.checkLE(packed & 0x3, SkPaint::kLast_Cap));
- packed >>= 2;
- paint->setStrokeJoin(safe.checkLE(packed & 0x3, SkPaint::kLast_Join));
- packed >>= 2;
- paint->setStyle(safe.checkLE(packed & 0x3, SkPaint::kStrokeAndFill_Style));
- packed >>= 2;
- paint->setFilterQuality(safe.checkLE(packed & 0x3, kLast_SkFilterQuality));
- packed >>= 2;
- return packed;
-}
-
-/* To save space/time, we analyze the paint, and write a truncated version of
- it if there are not tricky elements like shaders, etc.
- */
-void SkPaintPriv::Flatten(const SkPaint& paint, SkWriteBuffer& buffer) {
- uint8_t flatFlags = 0;
-
- if (paint.getPathEffect() ||
- paint.getShader() ||
- paint.getMaskFilter() ||
- paint.getColorFilter() ||
- paint.getImageFilter()) {
- flatFlags |= kHasEffects_FlatFlag;
- }
-
- buffer.writeScalar(paint.getStrokeWidth());
- buffer.writeScalar(paint.getStrokeMiter());
- buffer.writeColor4f(paint.getColor4f());
-
- buffer.write32(pack_v68(paint, flatFlags));
-
- if (flatFlags & kHasEffects_FlatFlag) {
- buffer.writeFlattenable(paint.getPathEffect());
- buffer.writeFlattenable(paint.getShader());
- buffer.writeFlattenable(paint.getMaskFilter());
- buffer.writeFlattenable(paint.getColorFilter());
- buffer.write32(0); // legacy, was drawlooper
- buffer.writeFlattenable(paint.getImageFilter());
- }
-}
-
-SkReadPaintResult SkPaintPriv::Unflatten_PreV68(SkPaint* paint, SkReadBuffer& buffer, SkFont* font) {
- SkSafeRange safe;
-
- {
- SkScalar sz = buffer.readScalar();
- SkScalar sx = buffer.readScalar();
- SkScalar kx = buffer.readScalar();
- if (font) {
- font->setSize(sz);
- font->setScaleX(sx);
- font->setSkewX(kx);
- }
- }
-
- paint->setStrokeWidth(buffer.readScalar());
- paint->setStrokeMiter(buffer.readScalar());
- if (buffer.isVersionLT(SkPicturePriv::kFloat4PaintColor_Version)) {
- paint->setColor(buffer.readColor());
- } else {
- SkColor4f color;
- buffer.readColor4f(&color);
- paint->setColor(color, sk_srgb_singleton());
- }
-
- unsigned flatFlags = unpack_paint_flags(paint, buffer.readUInt(), font);
-
- uint32_t tmp = buffer.readUInt();
- paint->setStrokeCap(safe.checkLE((tmp >> 24) & 0xFF, SkPaint::kLast_Cap));
- paint->setStrokeJoin(safe.checkLE((tmp >> 16) & 0xFF, SkPaint::kLast_Join));
- paint->setStyle(safe.checkLE((tmp >> 12) & 0xF, SkPaint::kStrokeAndFill_Style));
- paint->setBlendMode(safe.checkLE(tmp & 0xFF, SkBlendMode::kLastMode));
-
- sk_sp<SkTypeface> tf;
- if (flatFlags & kHasTypeface_FlatFlag) {
- tf = buffer.readTypeface();
- }
- if (font) {
- font->setTypeface(tf);
- }
-
- if (flatFlags & kHasEffects_FlatFlag) {
- paint->setPathEffect(buffer.readPathEffect());
- paint->setShader(buffer.readShader());
- paint->setMaskFilter(buffer.readMaskFilter());
- paint->setColorFilter(buffer.readColorFilter());
- (void)buffer.read32(); // use to be SkRasterizer
- (void)buffer.read32(); // used to be drawlooper
- paint->setImageFilter(buffer.readImageFilter());
- } else {
- paint->setPathEffect(nullptr);
- paint->setShader(nullptr);
- paint->setMaskFilter(nullptr);
- paint->setColorFilter(nullptr);
- paint->setImageFilter(nullptr);
- }
-
- if (!buffer.validate(safe)) {
- paint->reset();
- return kFailed_ReadPaint;
- }
- return kSuccess_PaintAndFont;
-}
-
-SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, SkFont* font) {
- if (buffer.isVersionLT(SkPicturePriv::kPaintDoesntSerializeFonts_Version)) {
- return Unflatten_PreV68(paint, buffer, font);
- }
-
- SkSafeRange safe;
-
- paint->setStrokeWidth(buffer.readScalar());
- paint->setStrokeMiter(buffer.readScalar());
- {
- SkColor4f color;
- buffer.readColor4f(&color);
- paint->setColor(color, sk_srgb_singleton());
- }
-
- unsigned flatFlags = unpack_v68(paint, buffer.readUInt(), safe);
-
- if (flatFlags & kHasEffects_FlatFlag) {
- paint->setPathEffect(buffer.readPathEffect());
- paint->setShader(buffer.readShader());
- paint->setMaskFilter(buffer.readMaskFilter());
- paint->setColorFilter(buffer.readColorFilter());
- (void)buffer.readDrawLooper();
- paint->setImageFilter(buffer.readImageFilter());
- } else {
- paint->setPathEffect(nullptr);
- paint->setShader(nullptr);
- paint->setMaskFilter(nullptr);
- paint->setColorFilter(nullptr);
- paint->setImageFilter(nullptr);
- }
-
- if (!buffer.validate(safe)) {
- paint->reset();
- return kFailed_ReadPaint;
- }
- return kSuccess_JustPaint;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
SkScalar resScale) const {
if (!src.isFinite()) {
diff --recursive --unified skia/src/core/SkPaintDefaults.h tiny-skia/skia/src/core/SkPaintDefaults.h
@@ -8,8 +8,6 @@
#ifndef SkPaintDefaults_DEFINED
#define SkPaintDefaults_DEFINED
-#include "include/core/SkFontTypes.h"
-
/**
* Any of these can be specified by the build system (or SkUserConfig.h)
* to change the default values for a SkPaint. This file should not be
diff --recursive --unified skia/src/core/SkPaintPriv.h tiny-skia/skia/src/core/SkPaintPriv.h
@@ -73,9 +73,6 @@
// Since we may be filtering now, we need to know what color space to filter in,
// typically the color space of the device we're drawing into.
static void RemoveColorFilter(SkPaint*, SkColorSpace* dstCS);
-
-private:
- static SkReadPaintResult Unflatten_PreV68(SkPaint* paint, SkReadBuffer& buffer, SkFont*);
};
#endif
diff --recursive --unified skia/src/core/SkPath.cpp tiny-skia/skia/src/core/SkPath.cpp
@@ -14,7 +14,6 @@
#include "include/private/SkPathRef.h"
#include "include/private/SkTo.h"
#include "src/core/SkBuffer.h"
-#include "src/core/SkCubicClipper.h"
#include "src/core/SkGeometry.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkPathMakers.h"
@@ -1884,139 +1883,12 @@
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
-#include "src/core/SkStringUtils.h"
-
-static void append_params(SkString* str, const char label[], const SkPoint pts[],
- int count, SkScalarAsStringType strType, SkScalar conicWeight = -12345) {
- str->append(label);
- str->append("(");
-
- const SkScalar* values = &pts[0].fX;
- count *= 2;
-
- for (int i = 0; i < count; ++i) {
- SkAppendScalar(str, values[i], strType);
- if (i < count - 1) {
- str->append(", ");
- }
- }
- if (conicWeight != -12345) {
- str->append(", ");
- SkAppendScalar(str, conicWeight, strType);
- }
- str->append(");");
- if (kHex_SkScalarAsStringType == strType) {
- str->append(" // ");
- for (int i = 0; i < count; ++i) {
- SkAppendScalarDec(str, values[i]);
- if (i < count - 1) {
- str->append(", ");
- }
- }
- if (conicWeight >= 0) {
- str->append(", ");
- SkAppendScalarDec(str, conicWeight);
- }
- }
- str->append("\n");
-}
-
-void SkPath::dump(SkWStream* wStream, bool forceClose, bool dumpAsHex) const {
- SkScalarAsStringType asType = dumpAsHex ? kHex_SkScalarAsStringType : kDec_SkScalarAsStringType;
- Iter iter(*this, forceClose);
- SkPoint pts[4];
- Verb verb;
-
- SkString builder;
- char const * const gFillTypeStrs[] = {
- "Winding",
- "EvenOdd",
- "InverseWinding",
- "InverseEvenOdd",
- };
- builder.printf("path.setFillType(SkPathFillType::k%s);\n",
- gFillTypeStrs[(int) this->getFillType()]);
- while ((verb = iter.next(pts)) != kDone_Verb) {
- switch (verb) {
- case kMove_Verb:
- append_params(&builder, "path.moveTo", &pts[0], 1, asType);
- break;
- case kLine_Verb:
- append_params(&builder, "path.lineTo", &pts[1], 1, asType);
- break;
- case kQuad_Verb:
- append_params(&builder, "path.quadTo", &pts[1], 2, asType);
- break;
- case kConic_Verb:
- append_params(&builder, "path.conicTo", &pts[1], 2, asType, iter.conicWeight());
- break;
- case kCubic_Verb:
- append_params(&builder, "path.cubicTo", &pts[1], 3, asType);
- break;
- case kClose_Verb:
- builder.append("path.close();\n");
- break;
- default:
- SkDebugf(" path: UNKNOWN VERB %d, aborting dump...\n", verb);
- verb = kDone_Verb; // stop the loop
- break;
- }
- if (!wStream && builder.size()) {
- SkDebugf("%s", builder.c_str());
- builder.reset();
- }
- }
- if (wStream) {
- wStream->writeText(builder.c_str());
- }
-}
-
-void SkPath::dump() const {
- this->dump(nullptr, false, false);
-}
-
-void SkPath::dumpHex() const {
- this->dump(nullptr, false, true);
-}
-
bool SkPath::isValidImpl() const {
if ((fFillType & ~3) != 0) {
return false;
}
-#ifdef SK_DEBUG_PATH
- if (!fBoundsIsDirty) {
- SkRect bounds;
-
- bool isFinite = compute_pt_bounds(&bounds, *fPathRef.get());
- if (SkToBool(fIsFinite) != isFinite) {
- return false;
- }
-
- if (fPathRef->countPoints() <= 1) {
- // if we're empty, fBounds may be empty but translated, so we can't
- // necessarily compare to bounds directly
- // try path.addOval(2, 2, 2, 2) which is empty, but the bounds will
- // be [2, 2, 2, 2]
- if (!bounds.isEmpty() || !fBounds.isEmpty()) {
- return false;
- }
- } else {
- if (bounds.isEmpty()) {
- if (!fBounds.isEmpty()) {
- return false;
- }
- } else {
- if (!fBounds.isEmpty()) {
- if (!fBounds.contains(bounds)) {
- return false;
- }
- }
- }
- }
- }
-#endif // SK_DEBUG_PATH
return true;
}
@@ -2564,509 +2436,6 @@
///////////////////////////////////////////////////////////////////////////////
-static bool between(SkScalar a, SkScalar b, SkScalar c) {
- SkASSERT(((a <= b && b <= c) || (a >= b && b >= c)) == ((a - b) * (c - b) <= 0)
- || (SkScalarNearlyZero(a) && SkScalarNearlyZero(b) && SkScalarNearlyZero(c)));
- return (a - b) * (c - b) <= 0;
-}
-
-static SkScalar eval_cubic_pts(SkScalar c0, SkScalar c1, SkScalar c2, SkScalar c3,
- SkScalar t) {
- SkScalar A = c3 + 3*(c1 - c2) - c0;
- SkScalar B = 3*(c2 - c1 - c1 + c0);
- SkScalar C = 3*(c1 - c0);
- SkScalar D = c0;
- return poly_eval(A, B, C, D, t);
-}
-
-template <size_t N> static void find_minmax(const SkPoint pts[],
- SkScalar* minPtr, SkScalar* maxPtr) {
- SkScalar min, max;
- min = max = pts[0].fX;
- for (size_t i = 1; i < N; ++i) {
- min = std::min(min, pts[i].fX);
- max = std::max(max, pts[i].fX);
- }
- *minPtr = min;
- *maxPtr = max;
-}
-
-static bool checkOnCurve(SkScalar x, SkScalar y, const SkPoint& start, const SkPoint& end) {
- if (start.fY == end.fY) {
- return between(start.fX, x, end.fX) && x != end.fX;
- } else {
- return x == start.fX && y == start.fY;
- }
-}
-
-static int winding_mono_cubic(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurveCount) {
- SkScalar y0 = pts[0].fY;
- SkScalar y3 = pts[3].fY;
-
- int dir = 1;
- if (y0 > y3) {
- using std::swap;
- swap(y0, y3);
- dir = -1;
- }
- if (y < y0 || y > y3) {
- return 0;
- }
- if (checkOnCurve(x, y, pts[0], pts[3])) {
- *onCurveCount += 1;
- return 0;
- }
- if (y == y3) {
- return 0;
- }
-
- // quickreject or quickaccept
- SkScalar min, max;
- find_minmax<4>(pts, &min, &max);
- if (x < min) {
- return 0;
- }
- if (x > max) {
- return dir;
- }
-
- // compute the actual x(t) value
- SkScalar t;
- if (!SkCubicClipper::ChopMonoAtY(pts, y, &t)) {
- return 0;
- }
- SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t);
- if (SkScalarNearlyEqual(xt, x)) {
- if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they're start points
- *onCurveCount += 1;
- return 0;
- }
- }
- return xt < x ? dir : 0;
-}
-
-static int winding_cubic(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurveCount) {
- SkPoint dst[10];
- int n = SkChopCubicAtYExtrema(pts, dst);
- int w = 0;
- for (int i = 0; i <= n; ++i) {
- w += winding_mono_cubic(&dst[i * 3], x, y, onCurveCount);
- }
- return w;
-}
-
-static double conic_eval_numerator(const SkScalar src[], SkScalar w, SkScalar t) {
- SkASSERT(src);
- SkASSERT(t >= 0 && t <= 1);
- SkScalar src2w = src[2] * w;
- SkScalar C = src[0];
- SkScalar A = src[4] - 2 * src2w + C;
- SkScalar B = 2 * (src2w - C);
- return poly_eval(A, B, C, t);
-}
-
-
-static double conic_eval_denominator(SkScalar w, SkScalar t) {
- SkScalar B = 2 * (w - 1);
- SkScalar C = 1;
- SkScalar A = -B;
- return poly_eval(A, B, C, t);
-}
-
-static int winding_mono_conic(const SkConic& conic, SkScalar x, SkScalar y, int* onCurveCount) {
- const SkPoint* pts = conic.fPts;
- SkScalar y0 = pts[0].fY;
- SkScalar y2 = pts[2].fY;
-
- int dir = 1;
- if (y0 > y2) {
- using std::swap;
- swap(y0, y2);
- dir = -1;
- }
- if (y < y0 || y > y2) {
- return 0;
- }
- if (checkOnCurve(x, y, pts[0], pts[2])) {
- *onCurveCount += 1;
- return 0;
- }
- if (y == y2) {
- return 0;
- }
-
- SkScalar roots[2];
- SkScalar A = pts[2].fY;
- SkScalar B = pts[1].fY * conic.fW - y * conic.fW + y;
- SkScalar C = pts[0].fY;
- A += C - 2 * B; // A = a + c - 2*(b*w - yCept*w + yCept)
- B -= C; // B = b*w - w * yCept + yCept - a
- C -= y;
- int n = SkFindUnitQuadRoots(A, 2 * B, C, roots);
- SkASSERT(n <= 1);
- SkScalar xt;
- if (0 == n) {
- // zero roots are returned only when y0 == y
- // Need [0] if dir == 1
- // and [2] if dir == -1
- xt = pts[1 - dir].fX;
- } else {
- SkScalar t = roots[0];
- xt = conic_eval_numerator(&pts[0].fX, conic.fW, t) / conic_eval_denominator(conic.fW, t);
- }
- if (SkScalarNearlyEqual(xt, x)) {
- if (x != pts[2].fX || y != pts[2].fY) { // don't test end points; they're start points
- *onCurveCount += 1;
- return 0;
- }
- }
- return xt < x ? dir : 0;
-}
-
-static bool is_mono_quad(SkScalar y0, SkScalar y1, SkScalar y2) {
- // return SkScalarSignAsInt(y0 - y1) + SkScalarSignAsInt(y1 - y2) != 0;
- if (y0 == y1) {
- return true;
- }
- if (y0 < y1) {
- return y1 <= y2;
- } else {
- return y1 >= y2;
- }
-}
-
-static int winding_conic(const SkPoint pts[], SkScalar x, SkScalar y, SkScalar weight,
- int* onCurveCount) {
- SkConic conic(pts, weight);
- SkConic chopped[2];
- // If the data points are very large, the conic may not be monotonic but may also
- // fail to chop. Then, the chopper does not split the original conic in two.
- bool isMono = is_mono_quad(pts[0].fY, pts[1].fY, pts[2].fY) || !conic.chopAtYExtrema(chopped);
- int w = winding_mono_conic(isMono ? conic : chopped[0], x, y, onCurveCount);
- if (!isMono) {
- w += winding_mono_conic(chopped[1], x, y, onCurveCount);
- }
- return w;
-}
-
-static int winding_mono_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurveCount) {
- SkScalar y0 = pts[0].fY;
- SkScalar y2 = pts[2].fY;
-
- int dir = 1;
- if (y0 > y2) {
- using std::swap;
- swap(y0, y2);
- dir = -1;
- }
- if (y < y0 || y > y2) {
- return 0;
- }
- if (checkOnCurve(x, y, pts[0], pts[2])) {
- *onCurveCount += 1;
- return 0;
- }
- if (y == y2) {
- return 0;
- }
- // bounds check on X (not required. is it faster?)
-#if 0
- if (pts[0].fX > x && pts[1].fX > x && pts[2].fX > x) {
- return 0;
- }
-#endif
-
- SkScalar roots[2];
- int n = SkFindUnitQuadRoots(pts[0].fY - 2 * pts[1].fY + pts[2].fY,
- 2 * (pts[1].fY - pts[0].fY),
- pts[0].fY - y,
- roots);
- SkASSERT(n <= 1);
- SkScalar xt;
- if (0 == n) {
- // zero roots are returned only when y0 == y
- // Need [0] if dir == 1
- // and [2] if dir == -1
- xt = pts[1 - dir].fX;
- } else {
- SkScalar t = roots[0];
- SkScalar C = pts[0].fX;
- SkScalar A = pts[2].fX - 2 * pts[1].fX + C;
- SkScalar B = 2 * (pts[1].fX - C);
- xt = poly_eval(A, B, C, t);
- }
- if (SkScalarNearlyEqual(xt, x)) {
- if (x != pts[2].fX || y != pts[2].fY) { // don't test end points; they're start points
- *onCurveCount += 1;
- return 0;
- }
- }
- return xt < x ? dir : 0;
-}
-
-static int winding_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurveCount) {
- SkPoint dst[5];
- int n = 0;
-
- if (!is_mono_quad(pts[0].fY, pts[1].fY, pts[2].fY)) {
- n = SkChopQuadAtYExtrema(pts, dst);
- pts = dst;
- }
- int w = winding_mono_quad(pts, x, y, onCurveCount);
- if (n > 0) {
- w += winding_mono_quad(&pts[2], x, y, onCurveCount);
- }
- return w;
-}
-
-static int winding_line(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurveCount) {
- SkScalar x0 = pts[0].fX;
- SkScalar y0 = pts[0].fY;
- SkScalar x1 = pts[1].fX;
- SkScalar y1 = pts[1].fY;
-
- SkScalar dy = y1 - y0;
-
- int dir = 1;
- if (y0 > y1) {
- using std::swap;
- swap(y0, y1);
- dir = -1;
- }
- if (y < y0 || y > y1) {
- return 0;
- }
- if (checkOnCurve(x, y, pts[0], pts[1])) {
- *onCurveCount += 1;
- return 0;
- }
- if (y == y1) {
- return 0;
- }
- SkScalar cross = (x1 - x0) * (y - pts[0].fY) - dy * (x - x0);
-
- if (!cross) {
- // zero cross means the point is on the line, and since the case where
- // y of the query point is at the end point is handled above, we can be
- // sure that we're on the line (excluding the end point) here
- if (x != x1 || y != pts[1].fY) {
- *onCurveCount += 1;
- }
- dir = 0;
- } else if (SkScalarSignAsInt(cross) == dir) {
- dir = 0;
- }
- return dir;
-}
-
-static void tangent_cubic(const SkPoint pts[], SkScalar x, SkScalar y,
- SkTDArray<SkVector>* tangents) {
- if (!between(pts[0].fY, y, pts[1].fY) && !between(pts[1].fY, y, pts[2].fY)
- && !between(pts[2].fY, y, pts[3].fY)) {
- return;
- }
- if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX)
- && !between(pts[2].fX, x, pts[3].fX)) {
- return;
- }
- SkPoint dst[10];
- int n = SkChopCubicAtYExtrema(pts, dst);
- for (int i = 0; i <= n; ++i) {
- SkPoint* c = &dst[i * 3];
- SkScalar t;
- if (!SkCubicClipper::ChopMonoAtY(c, y, &t)) {
- continue;
- }
- SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t);
- if (!SkScalarNearlyEqual(x, xt)) {
- continue;
- }
- SkVector tangent;
- SkEvalCubicAt(c, t, nullptr, &tangent, nullptr);
- tangents->push_back(tangent);
- }
-}
-
-static void tangent_conic(const SkPoint pts[], SkScalar x, SkScalar y, SkScalar w,
- SkTDArray<SkVector>* tangents) {
- if (!between(pts[0].fY, y, pts[1].fY) && !between(pts[1].fY, y, pts[2].fY)) {
- return;
- }
- if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX)) {
- return;
- }
- SkScalar roots[2];
- SkScalar A = pts[2].fY;
- SkScalar B = pts[1].fY * w - y * w + y;
- SkScalar C = pts[0].fY;
- A += C - 2 * B; // A = a + c - 2*(b*w - yCept*w + yCept)
- B -= C; // B = b*w - w * yCept + yCept - a
- C -= y;
- int n = SkFindUnitQuadRoots(A, 2 * B, C, roots);
- for (int index = 0; index < n; ++index) {
- SkScalar t = roots[index];
- SkScalar xt = conic_eval_numerator(&pts[0].fX, w, t) / conic_eval_denominator(w, t);
- if (!SkScalarNearlyEqual(x, xt)) {
- continue;
- }
- SkConic conic(pts, w);
- tangents->push_back(conic.evalTangentAt(t));
- }
-}
-
-static void tangent_quad(const SkPoint pts[], SkScalar x, SkScalar y,
- SkTDArray<SkVector>* tangents) {
- if (!between(pts[0].fY, y, pts[1].fY) && !between(pts[1].fY, y, pts[2].fY)) {
- return;
- }
- if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX)) {
- return;
- }
- SkScalar roots[2];
- int n = SkFindUnitQuadRoots(pts[0].fY - 2 * pts[1].fY + pts[2].fY,
- 2 * (pts[1].fY - pts[0].fY),
- pts[0].fY - y,
- roots);
- for (int index = 0; index < n; ++index) {
- SkScalar t = roots[index];
- SkScalar C = pts[0].fX;
- SkScalar A = pts[2].fX - 2 * pts[1].fX + C;
- SkScalar B = 2 * (pts[1].fX - C);
- SkScalar xt = poly_eval(A, B, C, t);
- if (!SkScalarNearlyEqual(x, xt)) {
- continue;
- }
- tangents->push_back(SkEvalQuadTangentAt(pts, t));
- }
-}
-
-static void tangent_line(const SkPoint pts[], SkScalar x, SkScalar y,
- SkTDArray<SkVector>* tangents) {
- SkScalar y0 = pts[0].fY;
- SkScalar y1 = pts[1].fY;
- if (!between(y0, y, y1)) {
- return;
- }
- SkScalar x0 = pts[0].fX;
- SkScalar x1 = pts[1].fX;
- if (!between(x0, x, x1)) {
- return;
- }
- SkScalar dx = x1 - x0;
- SkScalar dy = y1 - y0;
- if (!SkScalarNearlyEqual((x - x0) * dy, dx * (y - y0))) {
- return;
- }
- SkVector v;
- v.set(dx, dy);
- tangents->push_back(v);
-}
-
-static bool contains_inclusive(const SkRect& r, SkScalar x, SkScalar y) {
- return r.fLeft <= x && x <= r.fRight && r.fTop <= y && y <= r.fBottom;
-}
-
-bool SkPath::contains(SkScalar x, SkScalar y) const {
- bool isInverse = this->isInverseFillType();
- if (this->isEmpty()) {
- return isInverse;
- }
-
- if (!contains_inclusive(this->getBounds(), x, y)) {
- return isInverse;
- }
-
- SkPath::Iter iter(*this, true);
- bool done = false;
- int w = 0;
- int onCurveCount = 0;
- do {
- SkPoint pts[4];
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- case SkPath::kClose_Verb:
- break;
- case SkPath::kLine_Verb:
- w += winding_line(pts, x, y, &onCurveCount);
- break;
- case SkPath::kQuad_Verb:
- w += winding_quad(pts, x, y, &onCurveCount);
- break;
- case SkPath::kConic_Verb:
- w += winding_conic(pts, x, y, iter.conicWeight(), &onCurveCount);
- break;
- case SkPath::kCubic_Verb:
- w += winding_cubic(pts, x, y, &onCurveCount);
- break;
- case SkPath::kDone_Verb:
- done = true;
- break;
- }
- } while (!done);
- bool evenOddFill = SkPathFillType::kEvenOdd == this->getFillType()
- || SkPathFillType::kInverseEvenOdd == this->getFillType();
- if (evenOddFill) {
- w &= 1;
- }
- if (w) {
- return !isInverse;
- }
- if (onCurveCount <= 1) {
- return SkToBool(onCurveCount) ^ isInverse;
- }
- if ((onCurveCount & 1) || evenOddFill) {
- return SkToBool(onCurveCount & 1) ^ isInverse;
- }
- // If the point touches an even number of curves, and the fill is winding, check for
- // coincidence. Count coincidence as places where the on curve points have identical tangents.
- iter.setPath(*this, true);
- done = false;
- SkTDArray<SkVector> tangents;
- do {
- SkPoint pts[4];
- int oldCount = tangents.count();
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- case SkPath::kClose_Verb:
- break;
- case SkPath::kLine_Verb:
- tangent_line(pts, x, y, &tangents);
- break;
- case SkPath::kQuad_Verb:
- tangent_quad(pts, x, y, &tangents);
- break;
- case SkPath::kConic_Verb:
- tangent_conic(pts, x, y, iter.conicWeight(), &tangents);
- break;
- case SkPath::kCubic_Verb:
- tangent_cubic(pts, x, y, &tangents);
- break;
- case SkPath::kDone_Verb:
- done = true;
- break;
- }
- if (tangents.count() > oldCount) {
- int last = tangents.count() - 1;
- const SkVector& tangent = tangents[last];
- if (SkScalarNearlyZero(SkPointPriv::LengthSqd(tangent))) {
- tangents.remove(last);
- } else {
- for (int index = 0; index < last; ++index) {
- const SkVector& test = tangents[index];
- if (SkScalarNearlyZero(test.cross(tangent))
- && SkScalarSignAsInt(tangent.fX * test.fX) <= 0
- && SkScalarSignAsInt(tangent.fY * test.fY) <= 0) {
- tangents.remove(last);
- tangents.removeShuffle(index);
- break;
- }
- }
- }
- }
- } while (!done);
- return SkToBool(tangents.count()) ^ isInverse;
-}
-
int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2,
SkScalar w, SkPoint pts[], int pow2) {
const SkConic conic(p0, p1, p2, w);
diff --recursive --unified skia/src/core/SkPathEffect.cpp tiny-skia/skia/src/core/SkPathEffect.cpp
@@ -7,8 +7,6 @@
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
///////////////////////////////////////////////////////////////////////////////
@@ -57,11 +55,6 @@
SkASSERT(fPE1.get());
}
- void flatten(SkWriteBuffer& buffer) const override {
- buffer.writeFlattenable(fPE0.get());
- buffer.writeFlattenable(fPE1.get());
- }
-
// these are visible to our subclasses
sk_sp<SkPathEffect> fPE0;
sk_sp<SkPathEffect> fPE1;
@@ -110,8 +103,6 @@
}
private:
- SK_FLATTENABLE_HOOKS(SkComposePathEffect)
-
// illegal
SkComposePathEffect(const SkComposePathEffect&);
SkComposePathEffect& operator=(const SkComposePathEffect&);
@@ -120,12 +111,6 @@
typedef SkPairPathEffect INHERITED;
};
-sk_sp<SkFlattenable> SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
- sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
- return SkComposePathEffect::Make(std::move(pe0), std::move(pe1));
-}
-
///////////////////////////////////////////////////////////////////////////////
/** \class SkSumPathEffect
@@ -150,8 +135,6 @@
return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second));
}
- SK_FLATTENABLE_HOOKS(SkSumPathEffect)
-
protected:
SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second)
: INHERITED(first, second) {}
@@ -172,12 +155,6 @@
typedef SkPairPathEffect INHERITED;
};
-sk_sp<SkFlattenable> SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
- sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
- return SkSumPathEffect::Make(pe0, pe1);
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkPathEffect::MakeSum(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) {
@@ -188,8 +165,3 @@
sk_sp<SkPathEffect> inner) {
return SkComposePathEffect::Make(std::move(outer), std::move(inner));
}
-
-void SkPathEffect::RegisterFlattenables() {
- SK_REGISTER_FLATTENABLE(SkComposePathEffect);
- SK_REGISTER_FLATTENABLE(SkSumPathEffect);
-}
Only in skia/src/core: SkPictureCommon.h
Only in skia/src/core: SkPicture.cpp
Only in skia/src/core: SkPictureData.cpp
Only in skia/src/core: SkPictureData.h
Only in skia/src/core: SkPictureFlat.cpp
Only in skia/src/core: SkPictureFlat.h
Only in skia/src/core: SkPictureImageGenerator.cpp
Only in skia/src/core: SkPicturePlayback.cpp
Only in skia/src/core: SkPicturePlayback.h
Only in skia/src/core: SkPicturePriv.h
Only in skia/src/core: SkPictureRecord.cpp
Only in skia/src/core: SkPictureRecorder.cpp
Only in skia/src/core: SkPictureRecord.h
diff --recursive --unified skia/src/core/SkPixelRef.cpp tiny-skia/skia/src/core/SkPixelRef.cpp
@@ -10,7 +10,6 @@
#include "src/core/SkBitmapCache.h"
#include "src/core/SkNextID.h"
#include "src/core/SkPixelRefPriv.h"
-#include "src/core/SkTraceEvent.h"
#include <atomic>
diff --recursive --unified skia/src/core/SkPixmap.cpp tiny-skia/skia/src/core/SkPixmap.cpp
@@ -559,55 +559,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
-static bool draw_orientation(const SkPixmap& dst, const SkPixmap& src, SkEncodedOrigin origin) {
- auto surf = SkSurface::MakeRasterDirect(dst.info(), dst.writable_addr(), dst.rowBytes());
- if (!surf) {
- return false;
- }
-
- SkBitmap bm;
- bm.installPixels(src);
-
- SkMatrix m = SkEncodedOriginToMatrix(origin, src.width(), src.height());
-
- SkPaint p;
- p.setBlendMode(SkBlendMode::kSrc);
- surf->getCanvas()->concat(m);
- surf->getCanvas()->drawBitmap(bm, 0, 0, &p);
- return true;
-}
-
-bool SkPixmapPriv::Orient(const SkPixmap& dst, const SkPixmap& src, SkEncodedOrigin origin) {
- if (src.colorType() != dst.colorType()) {
- return false;
- }
- // note: we just ignore alphaType and colorSpace for this transformation
-
- int w = src.width();
- int h = src.height();
- if (ShouldSwapWidthHeight(origin)) {
- using std::swap;
- swap(w, h);
- }
- if (dst.width() != w || dst.height() != h) {
- return false;
- }
- if (w == 0 || h == 0) {
- return true;
- }
-
- // check for aliasing to self
- if (src.addr() == dst.addr()) {
- return kTopLeft_SkEncodedOrigin == origin;
- }
- return draw_orientation(dst, src, origin);
-}
-
-bool SkPixmapPriv::ShouldSwapWidthHeight(SkEncodedOrigin origin) {
- // The last four SkEncodedOrigin values involve 90 degree rotations
- return origin >= kLeftTop_SkEncodedOrigin;
-}
-
SkImageInfo SkPixmapPriv::SwapWidthHeight(const SkImageInfo& info) {
return info.makeWH(info.height(), info.width());
}
diff --recursive --unified skia/src/core/SkPixmapPriv.h tiny-skia/skia/src/core/SkPixmapPriv.h
@@ -8,54 +8,12 @@
#ifndef SkPixmapPriv_DEFINED
#define SkPixmapPriv_DEFINED
-#include "include/codec/SkEncodedOrigin.h"
#include "include/core/SkPixmap.h"
-#include "src/core/SkAutoPixmapStorage.h"
class SkPixmapPriv {
public:
- /**
- * Copy the pixels in this pixmap into dst, applying the orientation transformations specified
- * by the flags. If the inputs are invalid, this returns false and no copy is made.
- */
- static bool Orient(const SkPixmap& dst, const SkPixmap& src, SkEncodedOrigin);
-
- static bool ShouldSwapWidthHeight(SkEncodedOrigin o);
static SkImageInfo SwapWidthHeight(const SkImageInfo& info);
- /**
- * Decode an image and then copy into dst, applying origin.
- *
- * @param dst SkPixmap to write the final image, after
- * applying the origin.
- * @param origin SkEncodedOrigin to apply to the raw pixels.
- * @param decode Function for decoding into a pixmap without
- * applying the origin.
- */
-
- template <typename Fn>
- static bool Orient(const SkPixmap& dst, SkEncodedOrigin origin, Fn&& decode) {
- SkAutoPixmapStorage storage;
- const SkPixmap* tmp = &dst;
- if (origin != kTopLeft_SkEncodedOrigin) {
- auto info = dst.info();
- if (ShouldSwapWidthHeight(origin)) {
- info = SwapWidthHeight(info);
- }
- if (!storage.tryAlloc(info)) {
- return false;
- }
- tmp = &storage;
- }
- if (!decode(*tmp)) {
- return false;
- }
- if (tmp != &dst) {
- return Orient(dst, *tmp, origin);
- }
- return true;
- }
-
static void ResetPixmapKeepInfo(SkPixmap* pm, const void* address, size_t rowBytes) {
pm->fRowBytes = rowBytes;
pm->fPixels = address;
Only in skia/src/core: SkPromiseImageTexture.cpp
Only in skia/src/core: SkPtrRecorder.cpp
Only in skia/src/core: SkPtrRecorder.h
diff --recursive --unified skia/src/core/SkRasterPipeline.h tiny-skia/skia/src/core/SkRasterPipeline.h
@@ -161,14 +161,14 @@
float* read_from = rgba;
};
-namespace SkSL {
-class ByteCode;
-class ByteCodeFunction;
-}
+//namespace SkSL {
+//class ByteCode;
+//class ByteCodeFunction;
+//}
struct SkRasterPipeline_InterpreterCtx {
- const SkSL::ByteCode* byteCode;
- const SkSL::ByteCodeFunction* fn;
+// const SkSL::ByteCode* byteCode;
+// const SkSL::ByteCodeFunction* fn;
SkColor4f paintColor;
sk_sp<SkData> inputs;
Only in skia/src/core: SkReadBuffer.cpp
Only in skia/src/core: SkReadBuffer.h
Only in skia/src/core: SkRecord.cpp
Only in skia/src/core: SkRecordDraw.cpp
Only in skia/src/core: SkRecordDraw.h
Only in skia/src/core: SkRecordedDrawable.cpp
Only in skia/src/core: SkRecordedDrawable.h
Only in skia/src/core: SkRecorder.cpp
Only in skia/src/core: SkRecorder.h
Only in skia/src/core: SkRecord.h
Only in skia/src/core: SkRecordOpts.cpp
Only in skia/src/core: SkRecordOpts.h
Only in skia/src/core: SkRecordPattern.h
Only in skia/src/core: SkRecords.cpp
Only in skia/src/core: SkRecords.h
diff --recursive --unified skia/src/core/SkRect.cpp tiny-skia/skia/src/core/SkRect.cpp
@@ -137,39 +137,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////
-#include "include/core/SkString.h"
-#include "src/core/SkStringUtils.h"
-
-static const char* set_scalar(SkString* storage, SkScalar value, SkScalarAsStringType asType) {
- storage->reset();
- SkAppendScalar(storage, value, asType);
- return storage->c_str();
-}
-
-void SkRect::dump(bool asHex) const {
- SkScalarAsStringType asType = asHex ? kHex_SkScalarAsStringType : kDec_SkScalarAsStringType;
-
- SkString line;
- if (asHex) {
- SkString tmp;
- line.printf( "SkRect::MakeLTRB(%s, /* %f */\n", set_scalar(&tmp, fLeft, asType), fLeft);
- line.appendf(" %s, /* %f */\n", set_scalar(&tmp, fTop, asType), fTop);
- line.appendf(" %s, /* %f */\n", set_scalar(&tmp, fRight, asType), fRight);
- line.appendf(" %s /* %f */);", set_scalar(&tmp, fBottom, asType), fBottom);
- } else {
- SkString strL, strT, strR, strB;
- SkAppendScalarDec(&strL, fLeft);
- SkAppendScalarDec(&strT, fTop);
- SkAppendScalarDec(&strR, fRight);
- SkAppendScalarDec(&strB, fBottom);
- line.printf("SkRect::MakeLTRB(%s, %s, %s, %s);",
- strL.c_str(), strT.c_str(), strR.c_str(), strB.c_str());
- }
- SkDebugf("%s\n", line.c_str());
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
template<typename R, typename C>
static bool subtract(const R& a, const R& b, R* out) {
static constexpr C kZero = C(0);
Only in skia/src/core: SkRemoteGlyphCache.cpp
Only in skia/src/core: SkRemoteGlyphCache.h
diff --recursive --unified skia/src/core/SkResourceCache.cpp tiny-skia/skia/src/core/SkResourceCache.cpp
@@ -7,7 +7,6 @@
#include "src/core/SkResourceCache.h"
-#include "include/core/SkTraceMemoryDump.h"
#include "include/private/SkMutex.h"
#include "include/private/SkTo.h"
#include "src/core/SkDiscardableMemory.h"
@@ -581,25 +580,3 @@
void SkResourceCache::TestDumpMemoryStatistics() {
VisitAll(dump_visitor, nullptr);
}
-
-static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context) {
- SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context);
- SkString dumpName = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getCategory(), &rec);
- SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable();
- if (discardable) {
- dump->setDiscardableMemoryBacking(dumpName.c_str(), *discardable);
-
- // The discardable memory size will be calculated by dumper, but we also dump what we think
- // the size of object in memory is irrespective of whether object is live or dead.
- dump->dumpNumericValue(dumpName.c_str(), "discardable_size", "bytes", rec.bytesUsed());
- } else {
- dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed());
- dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr);
- }
-}
-
-void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
- // Since resource could be backed by malloc or discardable, the cache always dumps detailed
- // stats to be accurate.
- VisitAll(sk_trace_dump_visitor, dump);
-}
diff --recursive --unified skia/src/core/SkResourceCache.h tiny-skia/skia/src/core/SkResourceCache.h
@@ -168,11 +168,6 @@
static void TestDumpMemoryStatistics();
- /** Dump memory usage statistics of every Rec in the cache using the
- SkTraceMemoryDump interface.
- */
- static void DumpMemoryStatistics(SkTraceMemoryDump* dump);
-
/**
* Returns the DiscardableFactory used by the global cache, or nullptr.
*/
diff --recursive --unified skia/src/core/SkRRect.cpp tiny-skia/skia/src/core/SkRRect.cpp
@@ -568,28 +568,6 @@
(rr->readFromMemory(&storage, SkRRect::kSizeInMemory) == SkRRect::kSizeInMemory);
}
-#include "include/core/SkString.h"
-#include "src/core/SkStringUtils.h"
-
-void SkRRect::dump(bool asHex) const {
- SkScalarAsStringType asType = asHex ? kHex_SkScalarAsStringType : kDec_SkScalarAsStringType;
-
- fRect.dump(asHex);
- SkString line("const SkPoint corners[] = {\n");
- for (int i = 0; i < 4; ++i) {
- SkString strX, strY;
- SkAppendScalar(&strX, fRadii[i].x(), asType);
- SkAppendScalar(&strY, fRadii[i].y(), asType);
- line.appendf(" { %s, %s },", strX.c_str(), strY.c_str());
- if (asHex) {
- line.appendf(" /* %f %f */", fRadii[i].x(), fRadii[i].y());
- }
- line.append("\n");
- }
- line.append("};");
- SkDebugf("%s\n", line.c_str());
-}
-
///////////////////////////////////////////////////////////////////////////////
/**
Only in skia/src/core: SkRTree.cpp
Only in skia/src/core: SkRTree.h
Only in skia/src/core: SkRuntimeEffect.cpp
Only in skia/src/core: SkRWBuffer.cpp
Only in skia/src/core: SkScalerCache.cpp
Only in skia/src/core: SkScalerCache.h
Only in skia/src/core: SkScalerContext.cpp
Only in skia/src/core: SkScalerContext.h
Only in skia/src/core: SkSharedMutex.cpp
Only in skia/src/core: SkSharedMutex.h
diff --recursive --unified skia/src/core/SkSpecialImage.cpp tiny-skia/skia/src/core/SkSpecialImage.cpp
@@ -14,17 +14,6 @@
#include "src/core/SkSurfacePriv.h"
#include "src/image/SkImage_Base.h"
-#if SK_SUPPORT_GPU
-#include "include/gpu/GrContext.h"
-#include "include/private/GrRecordingContext.h"
-#include "src/gpu/GrContextPriv.h"
-#include "src/gpu/GrImageInfo.h"
-#include "src/gpu/GrProxyProvider.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/GrTextureProxy.h"
-#include "src/image/SkImage_Gpu.h"
-#endif
-
// Currently the raster imagefilters can only handle certain imageinfos. Call this to know if
// a given info is supported.
static bool valid_for_imagefilters(const SkImageInfo& info) {
@@ -44,14 +33,8 @@
virtual bool onGetROPixels(SkBitmap*) const = 0;
- virtual GrRecordingContext* onGetContext() const { return nullptr; }
-
virtual SkColorSpace* onGetColorSpace() const = 0;
-#if SK_SUPPORT_GPU
- virtual GrSurfaceProxyView onView(GrRecordingContext* context) const = 0;
-#endif
-
// This subset is relative to the backing store's coordinate frame, it has already been mapped
// from the content rect by the non-virtual makeSubset().
virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
@@ -94,23 +77,13 @@
}
bool SkSpecialImage::isTextureBacked() const {
- return SkToBool(as_SIB(this)->onGetContext());
-}
-
-GrRecordingContext* SkSpecialImage::getContext() const {
- return as_SIB(this)->onGetContext();
+ return false;
}
SkColorSpace* SkSpecialImage::getColorSpace() const {
return as_SIB(this)->onGetColorSpace();
}
-#if SK_SUPPORT_GPU
-GrSurfaceProxyView SkSpecialImage::view(GrRecordingContext* context) const {
- return as_SIB(this)->onView(context);
-}
-#endif
-
sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(
SkColorType colorType, const SkColorSpace* colorSpace, const SkISize& size,
SkAlphaType at, const SkSurfaceProps* props) const {
@@ -137,7 +110,7 @@
}
}
-#if defined(SK_DEBUG) || SK_SUPPORT_GPU
+#if defined(SK_DEBUG)
static bool rect_fits(const SkIRect& rect, int width, int height) {
if (0 == width && 0 == height) {
SkASSERT(0 == rect.fLeft && 0 == rect.fRight && 0 == rect.fTop && 0 == rect.fBottom);
@@ -157,15 +130,6 @@
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
-#if SK_SUPPORT_GPU
- if (context) {
- GrSurfaceProxyView view = as_IB(image)->refView(context, GrMipMapped::kNo);
- return MakeDeferredFromGpu(context, subset, image->uniqueID(), view,
- SkColorTypeToGrColorType(image->colorType()),
- image->refColorSpace(), props);
- }
-#endif
-
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm)) {
return MakeFromRaster(subset, bm, props);
@@ -207,16 +171,6 @@
return fBitmap.colorSpace();
}
-#if SK_SUPPORT_GPU
- GrSurfaceProxyView onView(GrRecordingContext* context) const override {
- if (context) {
- return GrMakeCachedBitmapProxyView(context, fBitmap);
- }
-
- return {};
- }
-#endif
-
sk_sp<SkSpecialSurface> onMakeSurface(SkColorType colorType, const SkColorSpace* colorSpace,
const SkISize& size, SkAlphaType at,
const SkSurfaceProps* props) const override {
@@ -310,159 +264,3 @@
return sk_make_sp<SkSpecialImage_Raster>(
SkIRect::MakeWH(subset.width(), subset.height()), tmp, props);
}
-
-#if SK_SUPPORT_GPU
-///////////////////////////////////////////////////////////////////////////////
-static sk_sp<SkImage> wrap_proxy_in_image(GrRecordingContext* context, GrSurfaceProxyView view,
- SkColorType colorType, SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace) {
- // CONTEXT TODO: remove this use of 'backdoor' to create an SkImage
- return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context->priv().backdoor()),
- kNeedNewImageUniqueID, std::move(view), colorType, alphaType,
- std::move(colorSpace));
-}
-
-class SkSpecialImage_Gpu : public SkSpecialImage_Base {
-public:
- SkSpecialImage_Gpu(GrRecordingContext* context, const SkIRect& subset,
- uint32_t uniqueID, GrSurfaceProxyView view, GrColorType ct,
- SkAlphaType at, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props)
- : INHERITED(subset, uniqueID, props)
- , fContext(context)
- , fView(std::move(view))
- , fColorType(ct)
- , fAlphaType(at)
- , fColorSpace(std::move(colorSpace)) {
- }
-
- SkAlphaType alphaType() const override { return fAlphaType; }
-
- SkColorType colorType() const override { return GrColorTypeToSkColorType(fColorType); }
-
- size_t getSize() const override {
- return fView.proxy()->gpuMemorySize(*fContext->priv().caps());
- }
-
- void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const override {
- SkRect dst = SkRect::MakeXYWH(x, y,
- this->subset().width(), this->subset().height());
-
- // TODO: In this instance we know we're going to draw a sub-portion of the backing
- // texture into the canvas so it is okay to wrap it in an SkImage. This poses
- // some problems for full deferral however in that when the deferred SkImage_Gpu
- // instantiates itself it is going to have to either be okay with having a larger
- // than expected backing texture (unlikely) or the 'fit' of the SurfaceProxy needs
- // to be tightened (if it is deferred).
- sk_sp<SkImage> img =
- sk_sp<SkImage>(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()), this->uniqueID(),
- fView, this->colorType(), fAlphaType, fColorSpace));
-
- canvas->drawImageRect(img, this->subset(),
- dst, paint, SkCanvas::kStrict_SrcRectConstraint);
- }
-
- GrRecordingContext* onGetContext() const override { return fContext; }
-
- GrSurfaceProxyView onView(GrRecordingContext* context) const override { return fView; }
-
- bool onGetROPixels(SkBitmap* dst) const override {
- // This should never be called: All GPU image filters are implemented entirely on the GPU,
- // so we never perform read-back.
- SkASSERT(false);
- return false;
- }
-
- SkColorSpace* onGetColorSpace() const override {
- return fColorSpace.get();
- }
-
- sk_sp<SkSpecialSurface> onMakeSurface(SkColorType colorType, const SkColorSpace* colorSpace,
- const SkISize& size, SkAlphaType at,
- const SkSurfaceProps* props) const override {
- if (!fContext) {
- return nullptr;
- }
-
- return SkSpecialSurface::MakeRenderTarget(fContext, size.width(), size.height(),
- SkColorTypeToGrColorType(colorType),
- sk_ref_sp(colorSpace), props);
- }
-
- sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
- return SkSpecialImage::MakeDeferredFromGpu(fContext,
- subset,
- this->uniqueID(),
- fView,
- fColorType,
- fColorSpace,
- &this->props(),
- fAlphaType);
- }
-
- sk_sp<SkImage> onAsImage(const SkIRect* subset) const override {
- GrSurfaceProxy* proxy = fView.proxy();
- if (subset) {
- if (proxy->isFunctionallyExact() && *subset == SkIRect::MakeSize(proxy->dimensions())) {
- proxy->priv().exactify(false);
- // The existing GrTexture is already tight so reuse it in the SkImage
- return wrap_proxy_in_image(fContext, fView, this->colorType(), fAlphaType,
- fColorSpace);
- }
-
- auto subsetView = GrSurfaceProxyView::Copy(fContext, fView, GrMipMapped::kNo, *subset,
- SkBackingFit::kExact, SkBudgeted::kYes);
- if (!subsetView) {
- return nullptr;
- }
- SkASSERT(subsetView.asTextureProxy());
- SkASSERT(subsetView.proxy()->priv().isExact());
-
- // MDB: this is acceptable (wrapping subsetProxy in an SkImage) bc Copy will
- // return a kExact-backed proxy
- return wrap_proxy_in_image(fContext, std::move(subsetView), this->colorType(),
- fAlphaType, fColorSpace);
- }
-
- proxy->priv().exactify(true);
-
- return wrap_proxy_in_image(fContext, fView, this->colorType(), fAlphaType, fColorSpace);
- }
-
- sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
- const SkISize& size, SkAlphaType at) const override {
- // TODO (michaelludwig): Why does this ignore colorType but onMakeSurface doesn't ignore it?
- // Once makeTightSurface() goes away, should this type overriding behavior be moved into
- // onMakeSurface() or is this unnecessary?
- colorType = colorSpace && colorSpace->gammaIsLinear()
- ? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType;
- SkImageInfo info = SkImageInfo::Make(size, colorType, at, sk_ref_sp(colorSpace));
- // CONTEXT TODO: remove this use of 'backdoor' to create an SkSurface
- return SkSurface::MakeRenderTarget(fContext->priv().backdoor(), SkBudgeted::kYes, info);
- }
-
-private:
- GrRecordingContext* fContext;
- GrSurfaceProxyView fView;
- const GrColorType fColorType;
- const SkAlphaType fAlphaType;
- sk_sp<SkColorSpace> fColorSpace;
-
- typedef SkSpecialImage_Base INHERITED;
-};
-
-sk_sp<SkSpecialImage> SkSpecialImage::MakeDeferredFromGpu(GrRecordingContext* context,
- const SkIRect& subset,
- uint32_t uniqueID,
- GrSurfaceProxyView view,
- GrColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props,
- SkAlphaType at) {
- if (!context || context->priv().abandoned() || !view.asTextureProxy()) {
- return nullptr;
- }
- SkASSERT_RELEASE(rect_fits(subset, view.proxy()->width(), view.proxy()->height()));
- return sk_make_sp<SkSpecialImage_Gpu>(context, subset, uniqueID, std::move(view), colorType,
- at, std::move(colorSpace), props);
-}
-#endif
diff --recursive --unified skia/src/core/SkSpecialImage.h tiny-skia/skia/src/core/SkSpecialImage.h
@@ -13,13 +13,7 @@
#include "include/core/SkSurfaceProps.h"
#include "src/core/SkNextID.h"
-#if SK_SUPPORT_GPU
-#include "include/private/GrTypesPriv.h"
-#include "src/gpu/GrSurfaceProxyView.h"
-#endif
-
class GrRecordingContext;
-class GrTextureProxy;
class SkBitmap;
class SkCanvas;
class SkImage;
@@ -76,16 +70,6 @@
static sk_sp<SkSpecialImage> CopyFromRaster(const SkIRect& subset,
const SkBitmap&,
const SkSurfaceProps* = nullptr);
-#if SK_SUPPORT_GPU
- static sk_sp<SkSpecialImage> MakeDeferredFromGpu(GrRecordingContext*,
- const SkIRect& subset,
- uint32_t uniqueID,
- GrSurfaceProxyView,
- GrColorType,
- sk_sp<SkColorSpace>,
- const SkSurfaceProps* = nullptr,
- SkAlphaType at = kPremul_SkAlphaType);
-#endif
/**
* Create a new special surface with a backend that is compatible with this special image.
@@ -130,21 +114,6 @@
bool isTextureBacked() const;
/**
- * Return the GrRecordingContext if the SkSpecialImage is GrTexture-backed
- */
- GrRecordingContext* getContext() const;
-
-#if SK_SUPPORT_GPU
- /**
- * Regardless of how the underlying backing data is stored, returns the contents as a
- * GrSurfaceProxyView. The returned view's proxy represents the entire backing image, so texture
- * coordinates must be mapped from the content rect (e.g. relative to 'subset()') to the proxy's
- * space (offset by subset().topLeft()).
- */
- GrSurfaceProxyView view(GrRecordingContext*) const;
-#endif
-
- /**
* Regardless of the underlying backing store, return the contents as an SkBitmap.
* The returned bitmap represents the subset accessed by this image, thus (0,0) refers to the
* top-left corner of 'subset'.
diff --recursive --unified skia/src/core/SkSpecialSurface.cpp tiny-skia/skia/src/core/SkSpecialSurface.cpp
@@ -114,75 +114,3 @@
return sk_make_sp<SkSpecialSurface_Raster>(info, std::move(pr), subset, props);
}
-
-#if SK_SUPPORT_GPU
-///////////////////////////////////////////////////////////////////////////////
-#include "include/private/GrRecordingContext.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/SkGpuDevice.h"
-
-class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
-public:
- SkSpecialSurface_Gpu(GrRecordingContext* context,
- std::unique_ptr<GrRenderTargetContext> renderTargetContext,
- int width, int height, const SkIRect& subset)
- : INHERITED(subset, &renderTargetContext->surfaceProps())
- , fReadView(renderTargetContext->readSurfaceView()) {
- // CONTEXT TODO: remove this use of 'backdoor' to create an SkGpuDevice
- auto device = SkGpuDevice::Make(context->priv().backdoor(), std::move(renderTargetContext),
- SkGpuDevice::kUninit_InitContents);
- if (!device) {
- return;
- }
-
- fCanvas.reset(new SkCanvas(std::move(device)));
- fCanvas->clipRect(SkRect::Make(subset));
-#ifdef SK_IS_BOT
- fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness
-#endif
- }
-
- sk_sp<SkSpecialImage> onMakeImageSnapshot() override {
- if (!fReadView.asTextureProxy()) {
- return nullptr;
- }
- GrColorType ct = SkColorTypeToGrColorType(fCanvas->imageInfo().colorType());
-
- // Note: SkSpecialImages can only be snapShotted once, so this call is destructive and we
- // move fReadMove.
- return SkSpecialImage::MakeDeferredFromGpu(fCanvas->getGrContext(),
- this->subset(),
- kNeedNewImageUniqueID_SpecialImage,
- std::move(fReadView), ct,
- fCanvas->imageInfo().refColorSpace(),
- &this->props());
- }
-
-private:
- GrSurfaceProxyView fReadView;
- typedef SkSpecialSurface_Base INHERITED;
-};
-
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrRecordingContext* context,
- int width, int height,
- GrColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props) {
- if (!context) {
- return nullptr;
- }
- auto renderTargetContext = GrRenderTargetContext::Make(
- context, colorType, std::move(colorSpace), SkBackingFit::kApprox, {width, height}, 1,
- GrMipMapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes,
- props);
- if (!renderTargetContext) {
- return nullptr;
- }
-
- const SkIRect subset = SkIRect::MakeWH(width, height);
-
- return sk_make_sp<SkSpecialSurface_Gpu>(context, std::move(renderTargetContext),
- width, height, subset);
-}
-
-#endif
diff --recursive --unified skia/src/core/SkSpecialSurface.h tiny-skia/skia/src/core/SkSpecialSurface.h
@@ -12,13 +12,6 @@
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceProps.h"
-#if SK_SUPPORT_GPU
-#include "include/private/GrTypesPriv.h"
-#endif
-
-class GrBackendFormat;
-class GrContext;
-class GrRecordingContext;
class SkBitmap;
class SkCanvas;
class SkSpecialImage;
@@ -56,16 +49,6 @@
*/
sk_sp<SkSpecialImage> makeImageSnapshot();
-#if SK_SUPPORT_GPU
- /**
- * Allocate a new GPU-backed SkSpecialSurface. If the requested surface cannot
- * be created, nullptr will be returned.
- */
- static sk_sp<SkSpecialSurface> MakeRenderTarget(GrRecordingContext*, int width, int height,
- GrColorType, sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* = nullptr);
-#endif
-
/**
* Use and existing SkBitmap as the backing store.
*/
Only in skia/src/core: SkSpinlock.cpp
diff --recursive --unified skia/src/core/SkStream.cpp tiny-skia/skia/src/core/SkStream.cpp
@@ -13,9 +13,7 @@
#include "include/private/SkFixed.h"
#include "include/private/SkTFitsIn.h"
#include "include/private/SkTo.h"
-#include "src/core/SkOSFile.h"
#include "src/core/SkSafeMath.h"
-#include "src/core/SkStreamPriv.h"
#include <limits>
@@ -151,109 +149,6 @@
///////////////////////////////////////////////////////////////////////////////
-SkFILEStream::SkFILEStream(std::shared_ptr<FILE> file, size_t size,
- size_t offset, size_t originalOffset)
- : fFILE(std::move(file))
- , fSize(size)
- , fOffset(std::min(offset, fSize))
- , fOriginalOffset(std::min(originalOffset, fSize))
-{ }
-
-SkFILEStream::SkFILEStream(std::shared_ptr<FILE> file, size_t size, size_t offset)
- : SkFILEStream(std::move(file), size, offset, offset)
-{ }
-
-SkFILEStream::SkFILEStream(FILE* file)
- : SkFILEStream(std::shared_ptr<FILE>(file, sk_fclose),
- file ? sk_fgetsize(file) : 0,
- file ? sk_ftell(file) : 0)
-{ }
-
-
-SkFILEStream::SkFILEStream(const char path[])
- : SkFILEStream(path ? sk_fopen(path, kRead_SkFILE_Flag) : nullptr)
-{ }
-
-SkFILEStream::~SkFILEStream() {
- this->close();
-}
-
-void SkFILEStream::close() {
- fFILE.reset();
- fSize = 0;
- fOffset = 0;
-}
-
-size_t SkFILEStream::read(void* buffer, size_t size) {
- if (size > fSize - fOffset) {
- size = fSize - fOffset;
- }
- size_t bytesRead = size;
- if (buffer) {
- bytesRead = sk_qread(fFILE.get(), buffer, size, fOffset);
- }
- if (bytesRead == SIZE_MAX) {
- return 0;
- }
- fOffset += bytesRead;
- return bytesRead;
-}
-
-bool SkFILEStream::isAtEnd() const {
- if (fOffset == fSize) {
- return true;
- }
- return fOffset >= sk_fgetsize(fFILE.get());
-}
-
-bool SkFILEStream::rewind() {
- fOffset = fOriginalOffset;
- return true;
-}
-
-SkStreamAsset* SkFILEStream::onDuplicate() const {
- return new SkFILEStream(fFILE, fSize, fOriginalOffset, fOriginalOffset);
-}
-
-size_t SkFILEStream::getPosition() const {
- SkASSERT(fOffset >= fOriginalOffset);
- return fOffset - fOriginalOffset;
-}
-
-bool SkFILEStream::seek(size_t position) {
- fOffset = std::min(SkSafeMath::Add(position, fOriginalOffset), fSize);
- return true;
-}
-
-bool SkFILEStream::move(long offset) {
- if (offset < 0) {
- if (offset == std::numeric_limits<long>::min()
- || !SkTFitsIn<size_t>(-offset)
- || (size_t) (-offset) >= this->getPosition()) {
- fOffset = fOriginalOffset;
- } else {
- fOffset += offset;
- }
- } else if (!SkTFitsIn<size_t>(offset)) {
- fOffset = fSize;
- } else {
- fOffset = std::min(SkSafeMath::Add(fOffset, (size_t) offset), fSize);
- }
-
- SkASSERT(fOffset >= fOriginalOffset && fOffset <= fSize);
- return true;
-}
-
-SkStreamAsset* SkFILEStream::onFork() const {
- return new SkFILEStream(fFILE, fSize, fOffset, fOriginalOffset);
-}
-
-size_t SkFILEStream::getLength() const {
- return fSize - fOriginalOffset;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
static sk_sp<SkData> newFromParams(const void* src, size_t size, bool copyData) {
if (copyData) {
return SkData::MakeWithCopy(src, size);
@@ -390,56 +285,6 @@
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-SkFILEWStream::SkFILEWStream(const char path[])
-{
- fFILE = sk_fopen(path, kWrite_SkFILE_Flag);
-}
-
-SkFILEWStream::~SkFILEWStream()
-{
- if (fFILE) {
- sk_fclose(fFILE);
- }
-}
-
-size_t SkFILEWStream::bytesWritten() const {
- return sk_ftell(fFILE);
-}
-
-bool SkFILEWStream::write(const void* buffer, size_t size)
-{
- if (fFILE == nullptr) {
- return false;
- }
-
- if (sk_fwrite(buffer, size, fFILE) != size)
- {
- SkDEBUGCODE(SkDebugf("SkFILEWStream failed writing %d bytes\n", size);)
- sk_fclose(fFILE);
- fFILE = nullptr;
- return false;
- }
- return true;
-}
-
-void SkFILEWStream::flush()
-{
- if (fFILE) {
- sk_fflush(fFILE);
- }
-}
-
-void SkFILEWStream::fsync()
-{
- flush();
- if (fFILE) {
- sk_fsync(fFILE);
- }
-}
-
-////////////////////////////////////////////////////////////////////////
static inline void sk_memcpy_4bytes(void* dst, const void* src, size_t size) {
if (size == 4) {
@@ -877,71 +722,3 @@
this->reset();
return stream;
}
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-static sk_sp<SkData> mmap_filename(const char path[]) {
- FILE* file = sk_fopen(path, kRead_SkFILE_Flag);
- if (nullptr == file) {
- return nullptr;
- }
-
- auto data = SkData::MakeFromFILE(file);
- sk_fclose(file);
- return data;
-}
-
-std::unique_ptr<SkStreamAsset> SkStream::MakeFromFile(const char path[]) {
- auto data(mmap_filename(path));
- if (data) {
- return std::make_unique<SkMemoryStream>(std::move(data));
- }
-
- // If we get here, then our attempt at using mmap failed, so try normal file access.
- auto stream = std::make_unique<SkFILEStream>(path);
- if (!stream->isValid()) {
- return nullptr;
- }
- return std::move(stream);
-}
-
-// Declared in SkStreamPriv.h:
-sk_sp<SkData> SkCopyStreamToData(SkStream* stream) {
- SkASSERT(stream != nullptr);
-
- if (stream->hasLength()) {
- return SkData::MakeFromStream(stream, stream->getLength());
- }
-
- SkDynamicMemoryWStream tempStream;
- const size_t bufferSize = 4096;
- char buffer[bufferSize];
- do {
- size_t bytesRead = stream->read(buffer, bufferSize);
- tempStream.write(buffer, bytesRead);
- } while (!stream->isAtEnd());
- return tempStream.detachAsData();
-}
-
-bool SkStreamCopy(SkWStream* out, SkStream* input) {
- const char* base = static_cast<const char*>(input->getMemoryBase());
- if (base && input->hasPosition() && input->hasLength()) {
- // Shortcut that avoids the while loop.
- size_t position = input->getPosition();
- size_t length = input->getLength();
- SkASSERT(length >= position);
- return out->write(&base[position], length - position);
- }
- char scratch[4096];
- size_t count;
- while (true) {
- count = input->read(scratch, sizeof(scratch));
- if (0 == count) {
- return true;
- }
- if (!out->write(scratch, count)) {
- return false;
- }
- }
-}
Only in skia/src/core: SkStreamPriv.h
Only in skia/src/core: SkStrikeCache.cpp
Only in skia/src/core: SkStrikeCache.h
Only in skia/src/core: SkStrikeForGPU.cpp
Only in skia/src/core: SkStrikeForGPU.h
Only in skia/src/core: SkStrikeSpec.cpp
Only in skia/src/core: SkStrikeSpec.h
diff --recursive --unified skia/src/core/SkString.cpp tiny-skia/skia/src/core/SkString.cpp
@@ -9,7 +9,6 @@
#include "include/private/SkTo.h"
#include "src/core/SkSafeMath.h"
#include "src/core/SkUtils.h"
-#include "src/utils/SkUTF.h"
#include <cstdio>
#include <new>
@@ -426,14 +425,14 @@
}
}
-void SkString::insertUnichar(size_t offset, SkUnichar uni) {
- char buffer[SkUTF::kMaxBytesInUTF8Sequence];
- size_t len = SkUTF::ToUTF8(uni, buffer);
-
- if (len) {
- this->insert(offset, buffer, len);
- }
-}
+//void SkString::insertUnichar(size_t offset, SkUnichar uni) {
+// char buffer[SkUTF::kMaxBytesInUTF8Sequence];
+// size_t len = SkUTF::ToUTF8(uni, buffer);
+
+// if (len) {
+// this->insert(offset, buffer, len);
+// }
+//}
void SkString::insertS32(size_t offset, int32_t dec) {
char buffer[SkStrAppendS32_MaxSize];
Only in skia/src/core: SkStringUtils.cpp
Only in skia/src/core: SkStringUtils.h
Only in skia/src/core: SkSurfaceCharacterization.cpp
Only in skia/src/core: SkSwizzle.cpp
Only in skia/src/core: SkTaskGroup.cpp
Only in skia/src/core: SkTaskGroup.h
Only in skia/src/core: SkTDPQueue.h
Only in skia/src/core: SkTextBlob.cpp
Only in skia/src/core: SkTextBlobPriv.h
Only in skia/src/core: SkTextBlobTrace.cpp
Only in skia/src/core: SkTextBlobTrace.h
Only in skia/src/core: SkTime.cpp
Only in skia/src/core: SkTMultiMap.h
Only in skia/src/core: SkTraceEventCommon.h
Only in skia/src/core: SkTraceEvent.h
Only in skia/src/core: SkTSearch.cpp
diff --recursive --unified skia/src/core/SkTSearch.h tiny-skia/skia/src/core/SkTSearch.h
@@ -105,41 +105,6 @@
return SkTSearch(base, count, target, elemSize, functor);
}
-int SkStrSearch(const char*const* base, int count, const char target[],
- size_t target_len, size_t elemSize);
-int SkStrSearch(const char*const* base, int count, const char target[],
- size_t elemSize);
-
-/** Like SkStrSearch, but treats target as if it were all lower-case. Assumes that
- base points to a table of lower-case strings.
-*/
-int SkStrLCSearch(const char*const* base, int count, const char target[],
- size_t target_len, size_t elemSize);
-int SkStrLCSearch(const char*const* base, int count, const char target[],
- size_t elemSize);
-
-/** Helper class to convert a string to lower-case, but only modifying the ascii
- characters. This makes the routine very fast and never changes the string
- length, but it is not suitable for linguistic purposes. Normally this is
- used for buiding and searching string tables.
-*/
-class SkAutoAsciiToLC {
-public:
- SkAutoAsciiToLC(const char str[], size_t len = (size_t)-1);
- ~SkAutoAsciiToLC();
-
- const char* lc() const { return fLC; }
- size_t length() const { return fLength; }
-
-private:
- char* fLC; // points to either the heap or fStorage
- size_t fLength;
- enum {
- STORAGE = 64
- };
- char fStorage[STORAGE+1];
-};
-
// Helper when calling qsort with a compare proc that has typed its arguments
#define SkCastForQSort(compare) reinterpret_cast<int (*)(const void*, const void*)>(compare)
Only in skia/src/core: SkTTopoSort.h
Only in skia/src/core: SkTypefaceCache.cpp
Only in skia/src/core: SkTypefaceCache.h
Only in skia/src/core: SkTypeface.cpp
Only in skia/src/core: SkTypeface_remote.cpp
Only in skia/src/core: SkTypeface_remote.h
Only in skia/src/core: SkUtilsArm.cpp
diff --recursive --unified skia/src/core/SkUtils.cpp tiny-skia/skia/src/core/SkUtils.cpp
@@ -20,12 +20,6 @@
*srcPtr = ptr;
return c;
}
-SkUnichar SkUTF8_NextUnichar(const char** p) {
- return next<char>(p, SkUTF::kMaxBytesInUTF8Sequence, SkUTF::NextUTF8);
-}
-SkUnichar SkUTF16_NextUnichar(const uint16_t** p) {
- return next<uint16_t>(p, 2, SkUTF::NextUTF16);
-}
///////////////////////////////////////////////////////////////////////////////
diff --recursive --unified skia/src/core/SkUtils.h tiny-skia/skia/src/core/SkUtils.h
@@ -8,9 +8,7 @@
#ifndef SkUtils_DEFINED
#define SkUtils_DEFINED
-#include "include/core/SkFontTypes.h"
#include "src/core/SkOpts.h"
-#include "src/utils/SkUTF.h"
/** Similar to memset(), but it assigns a 16, 32, or 64-bit value into the buffer.
@param buffer The memory to have value copied into it
@@ -29,39 +27,32 @@
///////////////////////////////////////////////////////////////////////////////
-// Unlike the functions in SkUTF.h, these two functions do not take an array
-// length parameter. When possible, use SkUTF::NextUTF{8,16} instead.
-SkUnichar SkUTF8_NextUnichar(const char**);
-SkUnichar SkUTF16_NextUnichar(const uint16_t**);
-
-///////////////////////////////////////////////////////////////////////////////
-
static inline bool SkUTF16_IsLeadingSurrogate(uint16_t c) { return ((c) & 0xFC00) == 0xD800; }
static inline bool SkUTF16_IsTrailingSurrogate (uint16_t c) { return ((c) & 0xFC00) == 0xDC00; }
///////////////////////////////////////////////////////////////////////////////
-static inline int SkUTFN_CountUnichars(SkTextEncoding enc, const void* utfN, size_t bytes) {
- switch (enc) {
- case SkTextEncoding::kUTF8: return SkUTF::CountUTF8((const char*)utfN, bytes);
- case SkTextEncoding::kUTF16: return SkUTF::CountUTF16((const uint16_t*)utfN, bytes);
- case SkTextEncoding::kUTF32: return SkUTF::CountUTF32((const int32_t*)utfN, bytes);
- default: SkDEBUGFAIL("unknown text encoding"); return -1;
- }
-}
-
-static inline SkUnichar SkUTFN_Next(SkTextEncoding enc, const void** ptr, const void* stop) {
- switch (enc) {
- case SkTextEncoding::kUTF8:
- return SkUTF::NextUTF8((const char**)ptr, (const char*)stop);
- case SkTextEncoding::kUTF16:
- return SkUTF::NextUTF16((const uint16_t**)ptr, (const uint16_t*)stop);
- case SkTextEncoding::kUTF32:
- return SkUTF::NextUTF32((const int32_t**)ptr, (const int32_t*)stop);
- default: SkDEBUGFAIL("unknown text encoding"); return -1;
- }
-}
+//static inline int SkUTFN_CountUnichars(SkTextEncoding enc, const void* utfN, size_t bytes) {
+// switch (enc) {
+// case SkTextEncoding::kUTF8: return SkUTF::CountUTF8((const char*)utfN, bytes);
+// case SkTextEncoding::kUTF16: return SkUTF::CountUTF16((const uint16_t*)utfN, bytes);
+// case SkTextEncoding::kUTF32: return SkUTF::CountUTF32((const int32_t*)utfN, bytes);
+// default: SkDEBUGFAIL("unknown text encoding"); return -1;
+// }
+//}
+
+//static inline SkUnichar SkUTFN_Next(SkTextEncoding enc, const void** ptr, const void* stop) {
+// switch (enc) {
+// case SkTextEncoding::kUTF8:
+// return SkUTF::NextUTF8((const char**)ptr, (const char*)stop);
+// case SkTextEncoding::kUTF16:
+// return SkUTF::NextUTF16((const uint16_t**)ptr, (const uint16_t*)stop);
+// case SkTextEncoding::kUTF32:
+// return SkUTF::NextUTF32((const int32_t**)ptr, (const int32_t*)stop);
+// default: SkDEBUGFAIL("unknown text encoding"); return -1;
+// }
+//}
///////////////////////////////////////////////////////////////////////////////
diff --recursive --unified skia/src/core/SkVertices.cpp tiny-skia/skia/src/core/SkVertices.cpp
@@ -11,11 +11,9 @@
#include "include/private/SkTo.h"
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkOpts.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkSafeMath.h"
#include "src/core/SkSafeRange.h"
#include "src/core/SkVerticesPriv.h"
-#include "src/core/SkWriteBuffer.h"
#include <atomic>
#include <new>
@@ -377,133 +375,6 @@
#define kHasTexs_Mask 0x100
#define kHasColors_Mask 0x200
-void SkVerticesPriv::encode(SkWriteBuffer& buffer) const {
- // packed has room for additional flags in the future
- uint32_t packed = static_cast<uint32_t>(fVertices->fMode);
- SkASSERT((packed & ~kMode_Mask) == 0); // our mode fits in the mask bits
- if (fVertices->fTexs) {
- packed |= kHasTexs_Mask;
- }
- if (fVertices->fColors) {
- packed |= kHasColors_Mask;
- }
-
- SkVertices::Sizes sizes = fVertices->getSizes();
- SkASSERT(!sizes.fBuilderTriFanISize);
-
- // Header
- buffer.writeUInt(packed);
- buffer.writeInt(fVertices->fVertexCount);
- buffer.writeInt(fVertices->fIndexCount);
- buffer.writeInt(fVertices->fAttributeCount);
-
- // Attribute metadata
- for (int i = 0; i < fVertices->fAttributeCount; ++i) {
- buffer.writeInt(static_cast<int>(fVertices->fAttributes[i].fType));
- buffer.writeInt(static_cast<int>(fVertices->fAttributes[i].fUsage));
- buffer.writeString(fVertices->fAttributes[i].fMarkerName);
- }
-
- // Data arrays
- buffer.writeByteArray(fVertices->fPositions, sizes.fVSize);
- buffer.writeByteArray(fVertices->fCustomData, sizes.fDSize);
- buffer.writeByteArray(fVertices->fTexs, sizes.fTSize);
- buffer.writeByteArray(fVertices->fColors, sizes.fCSize);
- // if index-count is odd, we won't be 4-bytes aligned, so we call the pad version
- buffer.writeByteArray(fVertices->fIndices, sizes.fISize);
-}
-
-sk_sp<SkVertices> SkVerticesPriv::Decode(SkReadBuffer& buffer) {
- if (buffer.isVersionLT(SkPicturePriv::kVerticesUseReadBuffer_Version)) {
- // Old versions used an embedded blob that was serialized with SkWriter32/SkReader32.
- // We don't support loading those, but skip over the vertices to keep the buffer valid.
- auto data = buffer.readByteArrayAsData();
- (void)data;
- return nullptr;
- }
-
- auto decode = [](SkReadBuffer& buffer) -> sk_sp<SkVertices> {
- SkSafeRange safe;
-
- const uint32_t packed = buffer.readUInt();
- const int vertexCount = safe.checkGE(buffer.readInt(), 0);
- const int indexCount = safe.checkGE(buffer.readInt(), 0);
- const int attrCount = safe.checkGE(buffer.readInt(), 0);
- const SkVertices::VertexMode mode = safe.checkLE<SkVertices::VertexMode>(
- packed & kMode_Mask, SkVertices::kLast_VertexMode);
- const bool hasTexs = SkToBool(packed & kHasTexs_Mask);
- const bool hasColors = SkToBool(packed & kHasColors_Mask);
-
- if (!safe // Invalid header fields
- || attrCount > SkVertices::kMaxCustomAttributes // Too many custom attributes?
- || (attrCount > 0 && (hasTexs || hasColors))) { // Overspecified (incompatible features)
- return nullptr;
- }
-
- SkVertices::Attribute attrs[SkVertices::kMaxCustomAttributes];
- SkString attrNames[SkVertices::kMaxCustomAttributes];
- for (int i = 0; i < attrCount; ++i) {
- auto type = buffer.checkRange(SkVertices::Attribute::Type::kFloat,
- SkVertices::Attribute::Type::kByte4_unorm);
- auto usage = buffer.checkRange(SkVertices::Attribute::Usage::kRaw,
- SkVertices::Attribute::Usage::kPosition);
- buffer.readString(&attrNames[i]);
- const char* markerName = attrNames[i].isEmpty() ? nullptr : attrNames[i].c_str();
- if (markerName && !SkCanvasPriv::ValidateMarker(markerName)) {
- return nullptr;
- }
- attrs[i] = SkVertices::Attribute(type, usage, markerName);
- }
-
- // Ensure that all of the attribute metadata was valid before proceeding
- if (!buffer.isValid()) {
- return nullptr;
- }
-
- const SkVertices::Desc desc{mode, vertexCount, indexCount, hasTexs, hasColors,
- attrCount ? attrs : nullptr, attrCount};
- SkVertices::Sizes sizes(desc);
- if (!sizes.isValid()) {
- return nullptr;
- }
-
- SkVertices::Builder builder(desc);
- if (!builder.isValid()) {
- return nullptr;
- }
-
- buffer.readByteArray(builder.positions(), sizes.fVSize);
- buffer.readByteArray(builder.customData(), sizes.fDSize);
- buffer.readByteArray(builder.texCoords(), sizes.fTSize);
- buffer.readByteArray(builder.colors(), sizes.fCSize);
- size_t isize = (mode == SkVertices::kTriangleFan_VertexMode) ? sizes.fBuilderTriFanISize
- : sizes.fISize;
- buffer.readByteArray(builder.indices(), isize);
-
- if (!buffer.isValid()) {
- return nullptr;
- }
-
- if (indexCount > 0) {
- // validate that the indices are in range
- const uint16_t* indices = builder.indices();
- for (int i = 0; i < indexCount; ++i) {
- if (indices[i] >= (unsigned)vertexCount) {
- return nullptr;
- }
- }
- }
-
- return builder.detach();
- };
-
- if (auto verts = decode(buffer)) {
- return verts;
- }
- buffer.validate(false);
- return nullptr;
-}
-
void SkVertices::operator delete(void* p) {
::operator delete(p);
}
diff --recursive --unified skia/src/core/SkVerticesPriv.h tiny-skia/skia/src/core/SkVerticesPriv.h
@@ -44,9 +44,6 @@
// Never called due to RVO in priv(), but must exist for MSVC 2017.
SkVerticesPriv(const SkVerticesPriv&) = default;
- void encode(SkWriteBuffer&) const;
- static sk_sp<SkVertices> Decode(SkReadBuffer&);
-
private:
explicit SkVerticesPriv(SkVertices* vertices) : fVertices(vertices) {}
SkVerticesPriv& operator=(const SkVerticesPriv&) = delete;
Only in skia/src/core: SkVertState.cpp
Only in skia/src/core: SkVertState.h
diff --recursive --unified skia/src/core/SkVMBlitter.cpp tiny-skia/skia/src/core/SkVMBlitter.cpp
@@ -414,10 +414,6 @@
}
bool onAppendStages(const SkStageRec&, bool) const override { return true; }
-
- // Only created here, should never be flattened / unflattened.
- Factory getFactory() const override { return nullptr; }
- const char* getTypeName() const override { return "NoopColorFilter"; }
};
struct DitherShader : public SkShaderBase {
@@ -425,10 +421,6 @@
sk_sp<SkShader> fShader;
- // Only created here temporarily... never serialized.
- Factory getFactory() const override { return nullptr; }
- const char* getTypeName() const override { return "DitherShader"; }
-
bool isOpaque() const override { return fShader->isOpaque(); }
skvm::Color onProgram(skvm::Builder* p,
@@ -637,25 +629,6 @@
"%zu, prev was %zu", fUniforms.buf.size(), prev);
skvm::Program program = builder.done(debug_name(key).c_str());
- if (false) {
- static std::atomic<int> missed{0},
- total{0};
- if (!program.hasJIT()) {
- SkDebugf("\ncouldn't JIT %s\n", debug_name(key).c_str());
- builder.dump();
- program.dump();
-
- SkString path = SkStringPrintf("/tmp/%s.dot", debug_name(key).c_str());
- SkFILEWStream tmp(path.c_str());
- builder.dot(&tmp);
-
- missed++;
- }
- if (0 == total++) {
- atexit([]{ SkDebugf("SkVMBlitter compiled %d programs, %d without JIT.\n",
- total.load(), missed.load()); });
- }
- }
return program;
}
diff --recursive --unified skia/src/core/SkVM.cpp tiny-skia/skia/src/core/SkVM.cpp
@@ -8,7 +8,6 @@
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/private/SkChecksum.h"
-#include "include/private/SkSpinlock.h"
#include "include/private/SkTFitsIn.h"
#include "include/private/SkThreadID.h"
#include "include/private/SkVx.h"
Only in skia/src/core: SkWriteBuffer.cpp
Only in skia/src/core: SkWriteBuffer.h
Only in skia/src/core: SkWriter32.cpp
Only in skia/src/core: SkWriter32.h
diff --recursive --unified skia/src/core/SkXfermode.cpp tiny-skia/skia/src/core/SkXfermode.cpp
@@ -12,17 +12,8 @@
#include "src/core/SkMathPriv.h"
#include "src/core/SkOpts.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/core/SkXfermodePriv.h"
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrFragmentProcessor.h"
-#include "src/gpu/effects/GrCustomXfermode.h"
-#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
-#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
-#endif
-
///////////////////////////////////////////////////////////////////////////////////////////////////
class SkProcCoeffXfermode : public SkXfermode {
@@ -137,17 +128,3 @@
}
return false;
}
-
-#if SK_SUPPORT_GPU
-const GrXPFactory* SkBlendMode_AsXPFactory(SkBlendMode mode) {
- if (SkBlendMode_AsCoeff(mode, nullptr, nullptr)) {
- const GrXPFactory* result = GrPorterDuffXPFactory::Get(mode);
- SkASSERT(result);
- return result;
- }
-
- SkASSERT(GrCustomXfermode::IsSupportedMode(mode));
- return GrCustomXfermode::Get(mode);
-}
-#endif
-
diff --recursive --unified skia/src/core/SkXfermodePriv.h tiny-skia/skia/src/core/SkXfermodePriv.h
@@ -12,9 +12,6 @@
#include "include/core/SkColor.h"
#include "include/core/SkRefCnt.h"
-class GrFragmentProcessor;
-class GrTexture;
-class GrXPFactory;
class SkRasterPipeline;
class SkString;
Only in skia/src/core: SkYUVMath.cpp
Only in skia/src/core: SkYUVMath.h
Only in skia/src/core: SkYUVPlanesCache.cpp
Only in skia/src/core: SkYUVPlanesCache.h
Only in skia/src/core: SkZip.h
Only in skia/src/effects: imagefilters
Only in skia/src/effects: Sk1DPathEffect.cpp
Only in skia/src/effects: Sk2DPathEffect.cpp
Only in skia/src/effects: SkColorMatrix.cpp
Only in skia/src/effects: SkColorMatrixFilter.cpp
Only in skia/src/effects: SkCornerPathEffect.cpp
diff --recursive --unified skia/src/effects/SkDashImpl.h tiny-skia/skia/src/effects/SkDashImpl.h
@@ -16,7 +16,6 @@
protected:
~SkDashImpl() override;
- void flatten(SkWriteBuffer&) const override;
bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
bool onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
@@ -25,8 +24,6 @@
DashType onAsADash(DashInfo* info) const override;
private:
- SK_FLATTENABLE_HOOKS(SkDashImpl)
-
SkScalar* fIntervals;
int32_t fCount;
SkScalar fPhase;
diff --recursive --unified skia/src/effects/SkDashPathEffect.cpp tiny-skia/skia/src/effects/SkDashPathEffect.cpp
@@ -9,8 +9,6 @@
#include "include/core/SkStrokeRec.h"
#include "include/private/SkTo.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/effects/SkDashImpl.h"
#include "src/utils/SkDashPathPriv.h"
@@ -367,27 +365,6 @@
return kDash_DashType;
}
-void SkDashImpl::flatten(SkWriteBuffer& buffer) const {
- buffer.writeScalar(fPhase);
- buffer.writeScalarArray(fIntervals, fCount);
-}
-
-sk_sp<SkFlattenable> SkDashImpl::CreateProc(SkReadBuffer& buffer) {
- const SkScalar phase = buffer.readScalar();
- uint32_t count = buffer.getArrayCount();
-
- // Don't allocate gigantic buffers if there's not data for them.
- if (!buffer.validateCanReadN<SkScalar>(count)) {
- return nullptr;
- }
-
- SkAutoSTArray<32, SkScalar> intervals(count);
- if (buffer.readScalarArray(intervals.get(), count)) {
- return SkDashPathEffect::Make(intervals.get(), SkToInt(count), phase);
- }
- return nullptr;
-}
-
//////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count, SkScalar phase) {
Only in skia/src/effects: SkDiscretePathEffect.cpp
Only in skia/src/effects: SkEmbossMask.cpp
Only in skia/src/effects: SkEmbossMaskFilter.cpp
Only in skia/src/effects: SkEmbossMaskFilter.h
Only in skia/src/effects: SkEmbossMask.h
Only in skia/src/effects: SkHighContrastFilter.cpp
Only in skia/src/effects: SkLayerDrawLooper.cpp
Only in skia/src/effects: SkLumaColorFilter.cpp
Only in skia/src/effects: SkOpPathEffect.cpp
Only in skia/src/effects: SkOpPE.h
Only in skia/src/effects: SkOverdrawColorFilter.cpp
Only in skia/src/effects: SkPackBits.cpp
Only in skia/src/effects: SkPackBits.h
Only in skia/src/effects: SkShaderMaskFilter.cpp
Only in skia/src/effects: SkTableColorFilter.cpp
Only in skia/src/effects: SkTableMaskFilter.cpp
Only in skia/src/effects: SkTrimPathEffect.cpp
Only in skia/src/effects: SkTrimPE.h
Only in skia/src: fonts
Only in skia/src: gpu
diff --recursive --unified skia/src/image/SkImage_Base.h tiny-skia/skia/src/image/SkImage_Base.h
@@ -12,18 +12,9 @@
#include "include/core/SkSurface.h"
#include <atomic>
-#if SK_SUPPORT_GPU
-#include "include/private/SkTDArray.h"
-#include "src/gpu/GrSurfaceProxyView.h"
-#include "src/gpu/GrTextureProxy.h"
-
-class GrRecordingContext;
-class GrTexture;
-#endif
-
#include <new>
-class GrSamplerState;
+class GrRecordingContext;
class SkCachedData;
struct SkYUVASizeInfo;
@@ -46,33 +37,6 @@
virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY, CachingHint) const = 0;
- virtual GrContext* context() const { return nullptr; }
-
-#if SK_SUPPORT_GPU
- virtual GrSemaphoresSubmitted onFlush(GrContext* context, const GrFlushInfo&) {
- return GrSemaphoresSubmitted::kNo;
- }
-
- // Return the proxy if this image is backed by a single proxy. For YUVA images, this
- // will return nullptr unless the YUVA planes have been converted to RGBA in which case
- // that single backing proxy will be returned.
- virtual GrTextureProxy* peekProxy() const { return nullptr; }
-
- // If it exists, this returns a pointer to the GrSurfaceProxyView of image. The caller does not
- // own the returned view and must copy it if they want to gain a ref to the internal proxy.
- // If the returned view is not null, then it is guaranteed to have a valid proxy. Additionally
- // this call will flatten a SkImage_GpuYUV to a single texture.
- virtual const GrSurfaceProxyView* view(GrRecordingContext*) const { return nullptr; }
-
- virtual GrSurfaceProxyView refView(GrRecordingContext*, GrMipMapped) const = 0;
- virtual GrSurfaceProxyView refPinnedView(GrRecordingContext*, uint32_t* uniqueID) const {
- return {};
- }
- virtual bool isYUVA() const { return false; }
-#endif
- virtual GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
- GrSurfaceOrigin* origin) const;
-
// return a read-only copy of the pixels. We promise to not modify them,
// but only inspect them (or encode them).
virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const = 0;
@@ -97,11 +61,6 @@
fAddedToRasterCache.store(true);
}
- virtual bool onIsValid(GrContext*) const = 0;
-
- virtual bool onPinAsTexture(GrContext*) const { return false; }
- virtual void onUnpinAsTexture(GrContext*) const {}
-
virtual sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) const = 0;
diff --recursive --unified skia/src/image/SkImage.cpp tiny-skia/skia/src/image/SkImage.cpp
@@ -8,12 +8,10 @@
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
-#include "include/core/SkImageEncoder.h"
#include "include/core/SkImageFilter.h"
-#include "include/core/SkImageGenerator.h"
-#include "include/core/SkPicture.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
+#include "include/private/SkImageInfoPriv.h"
#include "src/core/SkBitmapCache.h"
#include "src/core/SkCachedData.h"
#include "src/core/SkColorSpacePriv.h"
@@ -26,12 +24,6 @@
#include "src/image/SkReadPixelsRec.h"
#include "src/shaders/SkImageShader.h"
-#if SK_SUPPORT_GPU
-#include "include/gpu/GrContext.h"
-#include "src/image/SkImage_Gpu.h"
-#endif
-#include "include/gpu/GrBackendSurface.h"
-
SkImage::SkImage(const SkImageInfo& info, uint32_t uniqueID)
: fInfo(info)
, fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID) {
@@ -94,34 +86,6 @@
SkImageShader::FilterEnum(filtering));
}
-sk_sp<SkData> SkImage::encodeToData(SkEncodedImageFormat type, int quality) const {
- SkBitmap bm;
- if (as_IB(this)->getROPixels(&bm)) {
- return SkEncodeBitmap(bm, type, quality);
- }
- return nullptr;
-}
-
-sk_sp<SkData> SkImage::encodeToData() const {
- if (auto encoded = this->refEncodedData()) {
- return encoded;
- }
-
- return this->encodeToData(SkEncodedImageFormat::kPNG, 100);
-}
-
-sk_sp<SkData> SkImage::refEncodedData() const {
- return sk_sp<SkData>(as_IB(this)->onRefEncoded());
-}
-
-sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset) {
- if (nullptr == encoded || 0 == encoded->size()) {
- return nullptr;
- }
- return SkImage::MakeFromGenerator(SkImageGenerator::MakeFromEncoded(std::move(encoded)),
- subset);
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkImage> SkImage::makeSubset(const SkIRect& subset) const {
@@ -140,62 +104,9 @@
}
// CONTEXT TODO: propagate the context parameter to the top-level API
-#if SK_SUPPORT_GPU
- return as_IB(this)->onMakeSubset(as_IB(this)->context(), subset);
-#else
return as_IB(this)->onMakeSubset(nullptr, subset);
-#endif
-}
-
-#if SK_SUPPORT_GPU
-
-bool SkImage::isTextureBacked() const { return as_IB(this)->onIsTextureBacked(); }
-
-GrBackendTexture SkImage::getBackendTexture(bool flushPendingGrContextIO,
- GrSurfaceOrigin* origin) const {
- return as_IB(this)->onGetBackendTexture(flushPendingGrContextIO, origin);
}
-bool SkImage::isValid(GrContext* context) const {
- if (context && context->abandoned()) {
- return false;
- }
- return as_IB(this)->onIsValid(context);
-}
-
-GrSemaphoresSubmitted SkImage::flush(GrContext* context, const GrFlushInfo& flushInfo) {
- return as_IB(this)->onFlush(context, flushInfo);
-}
-
-void SkImage::flushAndSubmit(GrContext* context) {
- this->flush(context, {});
- context->submit();
-}
-
-#else
-
-bool SkImage::isTextureBacked() const { return false; }
-
-GrBackendTexture SkImage::getBackendTexture(bool flushPendingGrContextIO,
- GrSurfaceOrigin* origin) const {
- return GrBackendTexture(); // invalid
-}
-
-bool SkImage::isValid(GrContext* context) const {
- if (context) {
- return false;
- }
- return as_IB(this)->onIsValid(context);
-}
-
-GrSemaphoresSubmitted SkImage::flush(GrContext*, const GrFlushInfo&) {
- return GrSemaphoresSubmitted::kNo;
-}
-
-void SkImage::flushAndSubmit(GrContext*) {}
-
-#endif
-
///////////////////////////////////////////////////////////////////////////////
SkImage_Base::SkImage_Base(const SkImageInfo& info, uint32_t uniqueID)
@@ -207,11 +118,6 @@
}
}
-GrBackendTexture SkImage_Base::onGetBackendTexture(bool flushPendingGrContextIO,
- GrSurfaceOrigin* origin) const {
- return GrBackendTexture(); // invalid
-}
-
bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
}
@@ -251,78 +157,6 @@
return true;
}
-sk_sp<SkImage> SkImage::MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
- const SkMatrix* matrix, const SkPaint* paint,
- BitDepth bitDepth, sk_sp<SkColorSpace> colorSpace) {
- return MakeFromGenerator(SkImageGenerator::MakeFromPicture(dimensions, std::move(picture),
- matrix, paint, bitDepth,
- std::move(colorSpace)));
-}
-
-sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
- const SkIRect& clipBounds, SkIRect* outSubset,
- SkIPoint* offset) const {
- GrContext* context = as_IB(this)->context();
-
- return this->makeWithFilter(context, filter, subset, clipBounds, outSubset, offset);
-}
-
-sk_sp<SkImage> SkImage::makeWithFilter(GrContext* grContext,
- const SkImageFilter* filter, const SkIRect& subset,
- const SkIRect& clipBounds, SkIRect* outSubset,
- SkIPoint* offset) const {
- if (!filter || !outSubset || !offset || !this->bounds().contains(subset)) {
- return nullptr;
- }
- sk_sp<SkSpecialImage> srcSpecialImage =
-#if SK_SUPPORT_GPU
- SkSpecialImage::MakeFromImage(grContext, subset, sk_ref_sp(const_cast<SkImage*>(this)));
-#else
- SkSpecialImage::MakeFromImage(nullptr, subset, sk_ref_sp(const_cast<SkImage*>(this)));
-#endif
- if (!srcSpecialImage) {
- return nullptr;
- }
-
- sk_sp<SkImageFilterCache> cache(
- SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize));
-
- // The filters operate in the local space of the src image, where (0,0) corresponds to the
- // subset's top left corner. But the clip bounds and any crop rects on the filters are in the
- // original coordinate system, so configure the CTM to correct crop rects and explicitly adjust
- // the clip bounds (since it is assumed to already be in image space).
- SkImageFilter_Base::Context context(SkMatrix::Translate(-subset.x(), -subset.y()),
- clipBounds.makeOffset(-subset.topLeft()),
- cache.get(), fInfo.colorType(), fInfo.colorSpace(),
- srcSpecialImage.get());
-
- sk_sp<SkSpecialImage> result = as_IFB(filter)->filterImage(context).imageAndOffset(offset);
- if (!result) {
- return nullptr;
- }
-
- // The output image and offset are relative to the subset rectangle, so the offset needs to
- // be shifted to put it in the correct spot with respect to the original coordinate system
- offset->fX += subset.x();
- offset->fY += subset.y();
-
- // Final clip against the exact clipBounds (the clip provided in the context gets adjusted
- // to account for pixel-moving filters so doesn't always exactly match when finished). The
- // clipBounds are translated into the clippedDstRect coordinate space, including the
- // result->subset() ensures that the result's image pixel origin does not affect results.
- SkIRect dstRect = result->subset();
- SkIRect clippedDstRect = dstRect;
- if (!clippedDstRect.intersect(clipBounds.makeOffset(result->subset().topLeft() - *offset))) {
- return nullptr;
- }
-
- // Adjust the geometric offset if the top-left corner moved as well
- offset->fX += (clippedDstRect.x() - dstRect.x());
- offset->fY += (clippedDstRect.y() - dstRect.y());
- *outSubset = clippedDstRect;
- return result->asImage();
-}
-
bool SkImage::isLazyGenerated() const {
return as_IB(this)->onIsLazyGenerated();
}
@@ -346,11 +180,7 @@
}
// CONTEXT TODO: propagate the context parameter to the top-level API
-#if SK_SUPPORT_GPU
- return as_IB(this)->onMakeColorTypeAndColorSpace(as_IB(this)->context(),
-#else
return as_IB(this)->onMakeColorTypeAndColorSpace(nullptr,
-#endif
this->colorType(), std::move(target));
}
@@ -371,11 +201,7 @@
}
// CONTEXT TODO: propagate the context parameter to the top-level API
-#if SK_SUPPORT_GPU
- return as_IB(this)->onMakeColorTypeAndColorSpace(as_IB(this)->context(),
-#else
return as_IB(this)->onMakeColorTypeAndColorSpace(nullptr,
-#endif
targetColorType, std::move(targetColorSpace));
}
@@ -399,150 +225,5 @@
}
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
- if (!this->isTextureBacked()) {
- return sk_ref_sp(const_cast<SkImage*>(this));
- }
- return this->makeRasterImage();
-}
-
-sk_sp<SkImage> SkImage::makeRasterImage(CachingHint chint) const {
- SkPixmap pm;
- if (this->peekPixels(&pm)) {
- return sk_ref_sp(const_cast<SkImage*>(this));
- }
-
- const size_t rowBytes = fInfo.minRowBytes();
- size_t size = fInfo.computeByteSize(rowBytes);
- if (SkImageInfo::ByteSizeOverflowed(size)) {
- return nullptr;
- }
-
- sk_sp<SkData> data = SkData::MakeUninitialized(size);
- pm = {fInfo.makeColorSpace(nullptr), data->writable_data(), fInfo.minRowBytes()};
- if (!this->readPixels(pm, 0, 0, chint)) {
- return nullptr;
- }
-
- return SkImage::MakeRasterData(fInfo, std::move(data), rowBytes);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-#if !SK_SUPPORT_GPU
-
-sk_sp<SkImage> SkImage::DecodeToTexture(GrContext*, const void*, size_t, const SkIRect*) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx,
- const GrBackendTexture& tex, GrSurfaceOrigin origin,
- SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs,
- TextureReleaseProc releaseP, ReleaseContext releaseC) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrContext* ctx,
- const GrBackendTexture& tex,
- GrSurfaceOrigin origin,
- SkAlphaType at,
- sk_sp<SkColorSpace> cs,
- TextureReleaseProc releaseP,
- ReleaseContext releaseC) {
- return nullptr;
-}
-
-bool SkImage::MakeBackendTextureFromSkImage(GrContext*,
- sk_sp<SkImage>,
- GrBackendTexture*,
- BackendTextureReleaseProc*) {
- return false;
-}
-
-sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx,
- const GrBackendTexture& tex, GrSurfaceOrigin origin,
- SkColorType ct, SkAlphaType at,
- sk_sp<SkColorSpace> cs) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- SkISize imageSize,
- GrSurfaceOrigin imageOrigin,
- sk_sp<SkColorSpace> imageColorSpace) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
- GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- SkISize imageSize,
- GrSurfaceOrigin imageOrigin,
- const GrBackendTexture& backendTexture,
- sk_sp<SkColorSpace> imageColorSpace,
- TextureReleaseProc textureReleaseProc,
- ReleaseContext releaseContext) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace space,
- const GrBackendTexture[3],
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> imageColorSpace) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopyWithExternalBackend(
- GrContext* context, SkYUVColorSpace yuvColorSpace, const GrBackendTexture yuvTextures[3],
- GrSurfaceOrigin surfaceOrigin, const GrBackendTexture& backendTexture,
- sk_sp<SkColorSpace> colorSpace) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace space,
- const GrBackendTexture[2],
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> imageColorSpace) {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::makeTextureImage(GrContext*, GrMipMapped, SkBudgeted) const {
- return nullptr;
-}
-
-sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopyWithExternalBackend(
- GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture nv12Textures[2],
- GrSurfaceOrigin imageOrigin,
- const GrBackendTexture& backendTexture,
- sk_sp<SkColorSpace> imageColorSpace,
- TextureReleaseProc textureReleaseProc,
- ReleaseContext releaseContext) {
- return nullptr;
-}
-
-#endif
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-bool SkImage_pinAsTexture(const SkImage* image, GrContext* ctx) {
- SkASSERT(image);
- SkASSERT(ctx);
- return as_IB(image)->onPinAsTexture(ctx);
-}
-
-void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) {
- SkASSERT(image);
- SkASSERT(ctx);
- as_IB(image)->onUnpinAsTexture(ctx);
-}
-
-SkIRect SkImage_getSubset(const SkImage* image) {
- SkASSERT(image);
- return as_IB(image)->onGetSubset();
+ return sk_ref_sp(const_cast<SkImage*>(this));
}
Only in skia/src/image: SkImage_GpuBase.cpp
Only in skia/src/image: SkImage_GpuBase.h
Only in skia/src/image: SkImage_Gpu.cpp
Only in skia/src/image: SkImage_Gpu.h
Only in skia/src/image: SkImage_GpuYUVA.cpp
Only in skia/src/image: SkImage_GpuYUVA.h
Only in skia/src/image: SkImage_Lazy.cpp
Only in skia/src/image: SkImage_Lazy.h
diff --recursive --unified skia/src/image/SkImage_Raster.cpp tiny-skia/skia/src/image/SkImage_Raster.cpp
@@ -11,19 +11,10 @@
#include "include/core/SkPixelRef.h"
#include "include/core/SkSurface.h"
#include "include/private/SkImageInfoPriv.h"
-#include "src/codec/SkColorTable.h"
-#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkTLazy.h"
#include "src/image/SkImage_Base.h"
-#include "src/shaders/SkBitmapProcShader.h"
-
-#if SK_SUPPORT_GPU
-#include "include/gpu/GrContext.h"
-#include "src/gpu/GrTextureAdjuster.h"
-#include "src/gpu/SkGr.h"
-#endif
// fixes https://bug.skia.org/5096
static bool is_not_subset(const SkBitmap& bm) {
@@ -84,10 +75,6 @@
bool onPeekPixels(SkPixmap*) const override;
const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
-#if SK_SUPPORT_GPU
- GrSurfaceProxyView refView(GrRecordingContext*, GrMipMapped) const override;
-#endif
-
bool getROPixels(SkBitmap*, CachingHint) const override;
sk_sp<SkImage> onMakeSubset(GrRecordingContext*, const SkIRect&) const override;
@@ -107,7 +94,6 @@
sk_sp<SkImage> onReinterpretColorSpace(sk_sp<SkColorSpace>) const override;
- bool onIsValid(GrContext* context) const override { return true; }
void notifyAddedToRasterCache() const override {
// We explicitly DON'T want to call INHERITED::notifyAddedToRasterCache. That ties the
// lifetime of derived/cached resources to the image. In this case, we only want cached
@@ -116,22 +102,9 @@
fBitmap.pixelRef()->notifyAddedToCache();
}
-#if SK_SUPPORT_GPU
- GrSurfaceProxyView refPinnedView(GrRecordingContext* context,
- uint32_t* uniqueID) const override;
- bool onPinAsTexture(GrContext*) const override;
- void onUnpinAsTexture(GrContext*) const override;
-#endif
-
private:
SkBitmap fBitmap;
-#if SK_SUPPORT_GPU
- mutable GrSurfaceProxyView fPinnedView;
- mutable int32_t fPinnedCount = 0;
- mutable uint32_t fPinnedUniqueID = 0;
-#endif
-
typedef SkImage_Base INHERITED;
};
@@ -152,9 +125,6 @@
}
SkImage_Raster::~SkImage_Raster() {
-#if SK_SUPPORT_GPU
- SkASSERT(!fPinnedView); // want the caller to have manually unpinned
-#endif
}
bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
@@ -172,67 +142,6 @@
return true;
}
-#if SK_SUPPORT_GPU
-GrSurfaceProxyView SkImage_Raster::refView(GrRecordingContext* context,
- GrMipMapped mipMapped) const {
- if (!context) {
- return {};
- }
-
- uint32_t uniqueID;
- if (GrSurfaceProxyView view = this->refPinnedView(context, &uniqueID)) {
- GrTextureAdjuster adjuster(context, std::move(view), fBitmap.info().colorInfo(),
- fPinnedUniqueID);
- return adjuster.view(mipMapped);
- }
-
- return GrRefCachedBitmapView(context, fBitmap, mipMapped);
-}
-#endif
-
-#if SK_SUPPORT_GPU
-
-GrSurfaceProxyView SkImage_Raster::refPinnedView(GrRecordingContext*, uint32_t* uniqueID) const {
- if (fPinnedView) {
- SkASSERT(fPinnedCount > 0);
- SkASSERT(fPinnedUniqueID != 0);
- *uniqueID = fPinnedUniqueID;
- return fPinnedView;
- }
- return {};
-}
-
-bool SkImage_Raster::onPinAsTexture(GrContext* ctx) const {
- if (fPinnedView) {
- SkASSERT(fPinnedCount > 0);
- SkASSERT(fPinnedUniqueID != 0);
- } else {
- SkASSERT(fPinnedCount == 0);
- SkASSERT(fPinnedUniqueID == 0);
- fPinnedView = GrRefCachedBitmapView(ctx, fBitmap, GrMipMapped::kNo);
- if (!fPinnedView) {
- return false;
- }
- SkASSERT(fPinnedView.asTextureProxy());
- fPinnedUniqueID = fBitmap.getGenerationID();
- }
- // Note: we only increment if the texture was successfully pinned
- ++fPinnedCount;
- return true;
-}
-
-void SkImage_Raster::onUnpinAsTexture(GrContext* ctx) const {
- // Note: we always decrement, even if fPinnedTexture is null
- SkASSERT(fPinnedCount > 0);
- SkASSERT(fPinnedUniqueID != 0);
-
- if (0 == --fPinnedCount) {
- fPinnedView = GrSurfaceProxyView();
- fPinnedUniqueID = 0;
- }
-}
-#endif
-
sk_sp<SkImage> SkImage_Raster::onMakeSubset(GrRecordingContext*, const SkIRect& subset) const {
SkImageInfo info = fBitmap.info().makeDimensions(subset.size());
SkBitmap bitmap;
@@ -286,39 +195,6 @@
return sk_make_sp<SkImage_Raster>(info, std::move(data), rowBytes);
}
-// TODO: this could be improved to decode and make use of the mipmap
-// levels potentially present in the compressed data. For now, any
-// mipmap levels are discarded.
-sk_sp<SkImage> SkImage::MakeRasterFromCompressed(sk_sp<SkData> data,
- int width, int height,
- CompressionType type) {
- size_t expectedSize = SkCompressedFormatDataSize(type, { width, height }, false);
- if (!data || data->size() < expectedSize) {
- return nullptr;
- }
-
- SkAlphaType at = SkCompressionTypeIsOpaque(type) ? kOpaque_SkAlphaType
- : kPremul_SkAlphaType;
-
- SkImageInfo ii = SkImageInfo::MakeN32(width, height, at);
-
- if (!SkImage_Raster::ValidArgs(ii, ii.minRowBytes(), nullptr)) {
- return nullptr;
- }
-
- SkBitmap bitmap;
- if (!bitmap.tryAllocPixels(ii)) {
- return nullptr;
- }
-
- if (!SkDecompress(std::move(data), { width, height }, type, &bitmap)) {
- return nullptr;
- }
-
- bitmap.setImmutable();
- return MakeFromBitmap(bitmap);
-}
-
sk_sp<SkImage> SkImage::MakeFromRaster(const SkPixmap& pmap, RasterReleaseProc proc,
ReleaseContext ctx) {
size_t size;
diff --recursive --unified skia/src/image/SkSurface_Base.h tiny-skia/skia/src/image/SkSurface_Base.h
@@ -19,15 +19,6 @@
SkSurface_Base(const SkImageInfo&, const SkSurfaceProps*);
virtual ~SkSurface_Base();
- virtual GrContext* onGetContext();
-
- virtual GrBackendTexture onGetBackendTexture(BackendHandleAccess);
- virtual GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess);
- virtual bool onReplaceBackendTexture(const GrBackendTexture&,
- GrSurfaceOrigin,
- ContentChangeMode,
- TextureReleaseProc,
- ReleaseContext);
/**
* Allocate a canvas that will draw into this surface. We will cache this
* canvas, to return the same object to the caller multiple times. We
@@ -52,27 +43,6 @@
virtual void onWritePixels(const SkPixmap&, int x, int y) = 0;
/**
- * Default implementation does a rescale/read and then calls the callback.
- */
- virtual void onAsyncRescaleAndReadPixels(const SkImageInfo&,
- const SkIRect& srcRect,
- RescaleGamma,
- SkFilterQuality,
- ReadPixelsCallback,
- ReadPixelsContext);
- /**
- * Default implementation does a rescale/read/yuv conversion and then calls the callback.
- */
- virtual void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace,
- sk_sp<SkColorSpace> dstColorSpace,
- const SkIRect& srcRect,
- const SkISize& dstSize,
- RescaleGamma,
- SkFilterQuality,
- ReadPixelsCallback,
- ReadPixelsContext);
-
- /**
* Default implementation:
*
* image = this->newImageSnapshot();
@@ -102,27 +72,6 @@
*/
virtual void onRestoreBackingMutability() {}
- /**
- * Issue any pending surface IO to the current backend 3D API and resolve any surface MSAA.
- * Inserts the requested number of semaphores for the gpu to signal when work is complete on the
- * gpu and inits the array of GrBackendSemaphores with the signaled semaphores.
- */
- virtual GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo&,
- const GrBackendSurfaceMutableState*) {
- return GrSemaphoresSubmitted::kNo;
- }
-
- /**
- * Caused the current backend 3D API to wait on the passed in semaphores before executing new
- * commands on the gpu. Any previously submitting commands will not be blocked by these
- * semaphores.
- */
- virtual bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) {
- return false;
- }
-
- virtual bool onCharacterize(SkSurfaceCharacterization*) const { return false; }
- virtual bool onIsCompatible(const SkSurfaceCharacterization&) const { return false; }
virtual bool onDraw(const SkDeferredDisplayList*) { return false; }
inline SkCanvas* getCachedCanvas();
diff --recursive --unified skia/src/image/SkSurface.cpp tiny-skia/skia/src/image/SkSurface.cpp
@@ -8,34 +8,11 @@
#include <atomic>
#include <cmath>
#include "include/core/SkCanvas.h"
-#include "include/core/SkFontLCDConfig.h"
-#include "include/gpu/GrBackendSurface.h"
-#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkImagePriv.h"
#include "src/image/SkSurface_Base.h"
static SkPixelGeometry compute_default_geometry() {
- SkFontLCDConfig::LCDOrder order = SkFontLCDConfig::GetSubpixelOrder();
- if (SkFontLCDConfig::kNONE_LCDOrder == order) {
- return kUnknown_SkPixelGeometry;
- } else {
- // Bit0 is RGB(0), BGR(1)
- // Bit1 is H(0), V(1)
- const SkPixelGeometry gGeo[] = {
- kRGB_H_SkPixelGeometry,
- kBGR_H_SkPixelGeometry,
- kRGB_V_SkPixelGeometry,
- kBGR_V_SkPixelGeometry,
- };
- int index = 0;
- if (SkFontLCDConfig::kBGR_LCDOrder == order) {
- index |= 1;
- }
- if (SkFontLCDConfig::kVertical_LCDOrientation == SkFontLCDConfig::GetSubpixelOrientation()){
- index |= 2;
- }
- return gGeo[index];
- }
+ return kRGB_H_SkPixelGeometry;
}
SkSurfaceProps::SkSurfaceProps() : fFlags(0), fPixelGeometry(kUnknown_SkPixelGeometry) {}
@@ -71,25 +48,6 @@
}
}
-GrContext* SkSurface_Base::onGetContext() {
- return nullptr;
-}
-
-GrBackendTexture SkSurface_Base::onGetBackendTexture(BackendHandleAccess) {
- return GrBackendTexture(); // invalid
-}
-
-GrBackendRenderTarget SkSurface_Base::onGetBackendRenderTarget(BackendHandleAccess) {
- return GrBackendRenderTarget(); // invalid
-}
-
-bool SkSurface_Base::onReplaceBackendTexture(const GrBackendTexture&,
- GrSurfaceOrigin, ContentChangeMode,
- TextureReleaseProc,
- ReleaseContext) {
- return false;
-}
-
void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) {
auto image = this->makeImageSnapshot();
if (image) {
@@ -97,137 +55,6 @@
}
}
-void SkSurface_Base::onAsyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect,
- SkSurface::RescaleGamma rescaleGamma,
- SkFilterQuality rescaleQuality,
- SkSurface::ReadPixelsCallback callback,
- SkSurface::ReadPixelsContext context) {
- int srcW = srcRect.width();
- int srcH = srcRect.height();
- float sx = (float)info.width() / srcW;
- float sy = (float)info.height() / srcH;
- // How many bilerp/bicubic steps to do in X and Y. + means upscaling, - means downscaling.
- int stepsX;
- int stepsY;
- if (rescaleQuality > kNone_SkFilterQuality) {
- stepsX = static_cast<int>((sx > 1.f) ? std::ceil(std::log2f(sx))
- : std::floor(std::log2f(sx)));
- stepsY = static_cast<int>((sy > 1.f) ? std::ceil(std::log2f(sy))
- : std::floor(std::log2f(sy)));
- } else {
- stepsX = sx != 1.f;
- stepsY = sy != 1.f;
- }
-
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc);
- if (stepsX < 0 || stepsY < 0) {
- // Don't trigger MIP generation. We don't currently have a way to trigger bicubic for
- // downscaling draws.
- rescaleQuality = std::min(rescaleQuality, kLow_SkFilterQuality);
- }
- paint.setFilterQuality(rescaleQuality);
- sk_sp<SkSurface> src(SkRef(this));
- int srcX = srcRect.fLeft;
- int srcY = srcRect.fTop;
- SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
- // Assume we should ignore the rescale linear request if the surface has no color space since
- // it's unclear how we'd linearize from an unknown color space.
- if (rescaleGamma == SkSurface::RescaleGamma::kLinear &&
- this->getCanvas()->imageInfo().colorSpace() &&
- !this->getCanvas()->imageInfo().colorSpace()->gammaIsLinear()) {
- auto cs = this->getCanvas()->imageInfo().colorSpace()->makeLinearGamma();
- // Promote to F16 color type to preserve precision.
- auto ii = SkImageInfo::Make(srcW, srcH, kRGBA_F16_SkColorType,
- this->getCanvas()->imageInfo().alphaType(), std::move(cs));
- auto linearSurf = this->makeSurface(ii);
- if (!linearSurf) {
- // Maybe F16 isn't supported? Try again with original color type.
- ii = ii.makeColorType(this->getCanvas()->imageInfo().colorType());
- linearSurf = this->makeSurface(ii);
- if (!linearSurf) {
- callback(context, nullptr);
- return;
- }
- }
- this->draw(linearSurf->getCanvas(), -srcX, -srcY, &paint);
- src = std::move(linearSurf);
- srcX = 0;
- srcY = 0;
- constraint = SkCanvas::kFast_SrcRectConstraint;
- }
- while (stepsX || stepsY) {
- int nextW = info.width();
- int nextH = info.height();
- if (stepsX < 0) {
- nextW = info.width() << (-stepsX - 1);
- stepsX++;
- } else if (stepsX != 0) {
- if (stepsX > 1) {
- nextW = srcW * 2;
- }
- --stepsX;
- }
- if (stepsY < 0) {
- nextH = info.height() << (-stepsY - 1);
- stepsY++;
- } else if (stepsY != 0) {
- if (stepsY > 1) {
- nextH = srcH * 2;
- }
- --stepsY;
- }
- auto ii = src->getCanvas()->imageInfo().makeWH(nextW, nextH);
- if (!stepsX && !stepsY) {
- // Might as well fold conversion to final info in the last step.
- ii = info;
- }
- auto next = this->makeSurface(ii);
- if (!next) {
- callback(context, nullptr);
- return;
- }
- next->getCanvas()->drawImageRect(
- src->makeImageSnapshot(), SkIRect::MakeXYWH(srcX, srcY, srcW, srcH),
- SkRect::MakeWH((float)nextW, (float)nextH), &paint, constraint);
- src = std::move(next);
- srcX = srcY = 0;
- srcW = nextW;
- srcH = nextH;
- constraint = SkCanvas::kFast_SrcRectConstraint;
- }
-
- size_t rowBytes = info.minRowBytes();
- std::unique_ptr<char[]> data(new char[info.height() * rowBytes]);
- SkPixmap pm(info, data.get(), rowBytes);
- if (src->readPixels(pm, srcX, srcY)) {
- class Result : public AsyncReadResult {
- public:
- Result(std::unique_ptr<const char[]> data, size_t rowBytes)
- : fData(std::move(data)), fRowBytes(rowBytes) {}
- int count() const override { return 1; }
- const void* data(int i) const override { return fData.get(); }
- size_t rowBytes(int i) const override { return fRowBytes; }
-
- private:
- std::unique_ptr<const char[]> fData;
- size_t fRowBytes;
- };
- callback(context, std::make_unique<Result>(std::move(data), rowBytes));
- } else {
- callback(context, nullptr);
- }
-}
-
-void SkSurface_Base::onAsyncRescaleAndReadPixelsYUV420(
- SkYUVColorSpace yuvColorSpace, sk_sp<SkColorSpace> dstColorSpace, const SkIRect& srcRect,
- const SkISize& dstSize, RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality,
- ReadPixelsCallback callback, ReadPixelsContext context) {
- // TODO: Call non-YUV asyncRescaleAndReadPixels and then make our callback convert to YUV and
- // call client's callback.
- callback(context, nullptr);
-}
-
bool SkSurface_Base::outstandingImageSnapshot() const {
return fCachedImage && !fCachedImage->unique();
}
@@ -271,10 +98,6 @@
return static_cast<SkSurface_Base*>(surface);
}
-static const SkSurface_Base* asConstSB(const SkSurface* surface) {
- return static_cast<const SkSurface_Base*>(surface);
-}
-
///////////////////////////////////////////////////////////////////////////////
SkSurface::SkSurface(int width, int height, const SkSurfaceProps* props)
@@ -362,44 +185,6 @@
return bitmap.peekPixels(&pm) && this->readPixels(pm, srcX, srcY);
}
-void SkSurface::asyncRescaleAndReadPixels(const SkImageInfo& info,
- const SkIRect& srcRect,
- RescaleGamma rescaleGamma,
- SkFilterQuality rescaleQuality,
- ReadPixelsCallback callback,
- ReadPixelsContext context) {
- if (!SkIRect::MakeWH(this->width(), this->height()).contains(srcRect) ||
- !SkImageInfoIsValid(info)) {
- callback(context, nullptr);
- return;
- }
- asSB(this)->onAsyncRescaleAndReadPixels(
- info, srcRect, rescaleGamma, rescaleQuality, callback, context);
-}
-
-void SkSurface::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
- sk_sp<SkColorSpace> dstColorSpace,
- const SkIRect& srcRect,
- const SkISize& dstSize,
- RescaleGamma rescaleGamma,
- SkFilterQuality rescaleQuality,
- ReadPixelsCallback callback,
- ReadPixelsContext context) {
- if (!SkIRect::MakeWH(this->width(), this->height()).contains(srcRect) || dstSize.isZero() ||
- (dstSize.width() & 0b1) || (dstSize.height() & 0b1)) {
- callback(context, nullptr);
- return;
- }
- asSB(this)->onAsyncRescaleAndReadPixelsYUV420(yuvColorSpace,
- std::move(dstColorSpace),
- srcRect,
- dstSize,
- rescaleGamma,
- rescaleQuality,
- callback,
- context);
-}
-
void SkSurface::writePixels(const SkPixmap& pmap, int x, int y) {
if (pmap.addr() == nullptr || pmap.width() <= 0 || pmap.height() <= 0) {
return;
@@ -423,113 +208,3 @@
this->writePixels(pm, x, y);
}
}
-
-GrContext* SkSurface::getContext() {
- return asSB(this)->onGetContext();
-}
-
-GrBackendTexture SkSurface::getBackendTexture(BackendHandleAccess access) {
- return asSB(this)->onGetBackendTexture(access);
-}
-
-GrBackendRenderTarget SkSurface::getBackendRenderTarget(BackendHandleAccess access) {
- return asSB(this)->onGetBackendRenderTarget(access);
-}
-
-bool SkSurface::replaceBackendTexture(const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin, ContentChangeMode mode,
- TextureReleaseProc textureReleaseProc,
- ReleaseContext releaseContext) {
- return asSB(this)->onReplaceBackendTexture(backendTexture, origin, mode, textureReleaseProc,
- releaseContext);
-}
-
-GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, const GrFlushInfo& flushInfo) {
- return asSB(this)->onFlush(access, flushInfo, nullptr);
-}
-
-GrSemaphoresSubmitted SkSurface::flush(const GrFlushInfo& info,
- const GrBackendSurfaceMutableState* newState) {
- return asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, info, newState);
-}
-
-bool SkSurface::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) {
- return asSB(this)->onWait(numSemaphores, waitSemaphores);
-}
-
-bool SkSurface::characterize(SkSurfaceCharacterization* characterization) const {
- return asConstSB(this)->onCharacterize(characterization);
-}
-
-bool SkSurface::isCompatible(const SkSurfaceCharacterization& characterization) const {
- return asConstSB(this)->onIsCompatible(characterization);
-}
-
-bool SkSurface::draw(SkDeferredDisplayList* ddl) {
- return asSB(this)->onDraw(ddl);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-#include "include/utils/SkNoDrawCanvas.h"
-
-class SkNullSurface : public SkSurface_Base {
-public:
- SkNullSurface(int width, int height) : SkSurface_Base(width, height, nullptr) {}
-
-protected:
- SkCanvas* onNewCanvas() override {
- return new SkNoDrawCanvas(this->width(), this->height());
- }
- sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) override {
- return MakeNull(info.width(), info.height());
- }
- sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subsetOrNull) override { return nullptr; }
- void onWritePixels(const SkPixmap&, int x, int y) override {}
- void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override {}
- void onCopyOnWrite(ContentChangeMode) override {}
-};
-
-sk_sp<SkSurface> SkSurface::MakeNull(int width, int height) {
- if (width < 1 || height < 1) {
- return nullptr;
- }
- return sk_sp<SkSurface>(new SkNullSurface(width, height));
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-#if !SK_SUPPORT_GPU
-
-sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int,
- GrSurfaceOrigin, const SkSurfaceProps*, bool) {
- return nullptr;
-}
-
-sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext*, const SkSurfaceCharacterization&,
- SkBudgeted) {
- return nullptr;
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTexture&,
- GrSurfaceOrigin origin, int sampleCnt,
- SkColorType, sk_sp<SkColorSpace>,
- const SkSurfaceProps*,
- TextureReleaseProc, ReleaseContext) {
- return nullptr;
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
- const GrBackendRenderTarget&,
- GrSurfaceOrigin origin,
- SkColorType,
- sk_sp<SkColorSpace>,
- const SkSurfaceProps*,
- RenderTargetReleaseProc, ReleaseContext) {
- return nullptr;
-}
-
-void SkSurface::flushAndSubmit() {
- this->flush(BackendSurfaceAccess::kNoAccess, GrFlushInfo());
-}
-
-#endif
Only in skia/src/image: SkSurface_Gpu.cpp
Only in skia/src/image: SkSurface_Gpu.h
Only in skia/src/image: SkSurface_GpuMtl.mm
Only in skia/src: images
Only in skia/src: lazy
diff --recursive --unified skia/src/opts/SkOpts_hsw.cpp tiny-skia/skia/src/opts/SkOpts_hsw.cpp
@@ -8,7 +8,6 @@
#include "src/core/SkOpts.h"
#define SK_OPTS_NS hsw
-#include "src/core/SkCubicSolver.h"
#include "src/opts/SkBitmapProcState_opts.h"
#include "src/opts/SkBlitRow_opts.h"
#include "src/opts/SkRasterPipeline_opts.h"
@@ -16,36 +15,36 @@
#include "src/opts/SkUtils_opts.h"
#include "src/opts/SkVM_opts.h"
-namespace SkOpts {
- void Init_hsw() {
- blit_row_color32 = hsw::blit_row_color32;
- blit_row_s32a_opaque = hsw::blit_row_s32a_opaque;
-
- S32_alpha_D32_filter_DX = hsw::S32_alpha_D32_filter_DX;
-
- cubic_solver = SK_OPTS_NS::cubic_solver;
-
- RGBA_to_BGRA = SK_OPTS_NS::RGBA_to_BGRA;
- RGBA_to_rgbA = SK_OPTS_NS::RGBA_to_rgbA;
- RGBA_to_bgrA = SK_OPTS_NS::RGBA_to_bgrA;
- gray_to_RGB1 = SK_OPTS_NS::gray_to_RGB1;
- grayA_to_RGBA = SK_OPTS_NS::grayA_to_RGBA;
- grayA_to_rgbA = SK_OPTS_NS::grayA_to_rgbA;
- inverted_CMYK_to_RGB1 = SK_OPTS_NS::inverted_CMYK_to_RGB1;
- inverted_CMYK_to_BGR1 = SK_OPTS_NS::inverted_CMYK_to_BGR1;
-
- #define M(st) stages_highp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::st;
- SK_RASTER_PIPELINE_STAGES(M)
- just_return_highp = (StageFn)SK_OPTS_NS::just_return;
- start_pipeline_highp = SK_OPTS_NS::start_pipeline;
- #undef M
-
- #define M(st) stages_lowp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::lowp::st;
- SK_RASTER_PIPELINE_STAGES(M)
- just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
- start_pipeline_lowp = SK_OPTS_NS::lowp::start_pipeline;
- #undef M
-
- interpret_skvm = SK_OPTS_NS::interpret_skvm;
- }
-}
+//namespace SkOpts {
+// void Init_hsw() {
+// blit_row_color32 = hsw::blit_row_color32;
+// blit_row_s32a_opaque = hsw::blit_row_s32a_opaque;
+
+// S32_alpha_D32_filter_DX = hsw::S32_alpha_D32_filter_DX;
+
+// cubic_solver = SK_OPTS_NS::cubic_solver;
+
+// RGBA_to_BGRA = SK_OPTS_NS::RGBA_to_BGRA;
+// RGBA_to_rgbA = SK_OPTS_NS::RGBA_to_rgbA;
+// RGBA_to_bgrA = SK_OPTS_NS::RGBA_to_bgrA;
+// gray_to_RGB1 = SK_OPTS_NS::gray_to_RGB1;
+// grayA_to_RGBA = SK_OPTS_NS::grayA_to_RGBA;
+// grayA_to_rgbA = SK_OPTS_NS::grayA_to_rgbA;
+// inverted_CMYK_to_RGB1 = SK_OPTS_NS::inverted_CMYK_to_RGB1;
+// inverted_CMYK_to_BGR1 = SK_OPTS_NS::inverted_CMYK_to_BGR1;
+
+// #define M(st) stages_highp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::st;
+// SK_RASTER_PIPELINE_STAGES(M)
+// just_return_highp = (StageFn)SK_OPTS_NS::just_return;
+// start_pipeline_highp = SK_OPTS_NS::start_pipeline;
+// #undef M
+
+// #define M(st) stages_lowp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::lowp::st;
+// SK_RASTER_PIPELINE_STAGES(M)
+// just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
+// start_pipeline_lowp = SK_OPTS_NS::lowp::start_pipeline;
+// #undef M
+
+// interpret_skvm = SK_OPTS_NS::interpret_skvm;
+// }
+//}
diff --recursive --unified skia/src/opts/SkRasterPipeline_opts.h tiny-skia/skia/src/opts/SkRasterPipeline_opts.h
@@ -11,7 +11,6 @@
#include "include/core/SkData.h"
#include "include/core/SkTypes.h"
#include "src/core/SkUtils.h" // unaligned_{load,store}
-#include "src/sksl/SkSLByteCode.h"
// Every function in this file should be marked static and inline using SI.
#if defined(__clang__)
@@ -2671,37 +2670,37 @@
STAGE(interpreter, SkRasterPipeline_InterpreterCtx* c) {
// If N is less than the interpreter's VecWidth, then we are doing more work than necessary in
// the interpreter. This is a known issue, and will be addressed at some point.
- float xx[N], yy[N],
- rr[N], gg[N], bb[N], aa[N];
+// float xx[N], yy[N],
+// rr[N], gg[N], bb[N], aa[N];
- float* args[] = { xx, yy, rr, gg, bb, aa };
- float** in_args = args;
- int in_count = 6;
-
- if (c->shaderConvention) {
- // our caller must have called seed_shader to set these
- sk_unaligned_store(xx, r);
- sk_unaligned_store(yy, g);
- sk_unaligned_store(rr, F(c->paintColor.fR));
- sk_unaligned_store(gg, F(c->paintColor.fG));
- sk_unaligned_store(bb, F(c->paintColor.fB));
- sk_unaligned_store(aa, F(c->paintColor.fA));
- } else {
- in_args += 2; // skip x,y
- in_count = 4;
- sk_unaligned_store(rr, r);
- sk_unaligned_store(gg, g);
- sk_unaligned_store(bb, b);
- sk_unaligned_store(aa, a);
- }
-
- SkAssertResult(c->byteCode->runStriped(c->fn, tail ? tail : N, in_args, in_count, nullptr, 0,
- (const float*)c->inputs->data(), c->ninputs));
-
- r = sk_unaligned_load<F>(rr);
- g = sk_unaligned_load<F>(gg);
- b = sk_unaligned_load<F>(bb);
- a = sk_unaligned_load<F>(aa);
+// float* args[] = { xx, yy, rr, gg, bb, aa };
+// float** in_args = args;
+// int in_count = 6;
+
+// if (c->shaderConvention) {
+// // our caller must have called seed_shader to set these
+// sk_unaligned_store(xx, r);
+// sk_unaligned_store(yy, g);
+// sk_unaligned_store(rr, F(c->paintColor.fR));
+// sk_unaligned_store(gg, F(c->paintColor.fG));
+// sk_unaligned_store(bb, F(c->paintColor.fB));
+// sk_unaligned_store(aa, F(c->paintColor.fA));
+// } else {
+// in_args += 2; // skip x,y
+// in_count = 4;
+// sk_unaligned_store(rr, r);
+// sk_unaligned_store(gg, g);
+// sk_unaligned_store(bb, b);
+// sk_unaligned_store(aa, a);
+// }
+
+// SkAssertResult(c->byteCode->runStriped(c->fn, tail ? tail : N, in_args, in_count, nullptr, 0,
+// (const float*)c->inputs->data(), c->ninputs));
+
+// r = sk_unaligned_load<F>(rr);
+// g = sk_unaligned_load<F>(gg);
+// b = sk_unaligned_load<F>(bb);
+// a = sk_unaligned_load<F>(aa);
}
STAGE(gauss_a_to_rgba, Ctx::None) {
Only in skia/src/pathops: SkAddIntersections.cpp
Only in skia/src/pathops: SkAddIntersections.h
Only in skia/src/pathops: SkDConicLineIntersection.cpp
diff --recursive --unified skia/src/pathops/SkDCubicLineIntersection.cpp tiny-skia/skia/src/pathops/SkDCubicLineIntersection.cpp
@@ -4,10 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "src/pathops/SkIntersections.h"
#include "src/pathops/SkPathOpsCubic.h"
-#include "src/pathops/SkPathOpsCurve.h"
-#include "src/pathops/SkPathOpsLine.h"
/*
Find the interection of a line and cubic by solving for valid t values.
@@ -77,93 +74,6 @@
class LineCubicIntersections {
public:
- enum PinTPoint {
- kPointUninitialized,
- kPointInitialized
- };
-
- LineCubicIntersections(const SkDCubic& c, const SkDLine& l, SkIntersections* i)
- : fCubic(c)
- , fLine(l)
- , fIntersections(i)
- , fAllowNear(true) {
- i->setMax(4);
- }
-
- void allowNear(bool allow) {
- fAllowNear = allow;
- }
-
- void checkCoincident() {
- int last = fIntersections->used() - 1;
- for (int index = 0; index < last; ) {
- double cubicMidT = ((*fIntersections)[0][index] + (*fIntersections)[0][index + 1]) / 2;
- SkDPoint cubicMidPt = fCubic.ptAtT(cubicMidT);
- double t = fLine.nearPoint(cubicMidPt, nullptr);
- if (t < 0) {
- ++index;
- continue;
- }
- if (fIntersections->isCoincident(index)) {
- fIntersections->removeOne(index);
- --last;
- } else if (fIntersections->isCoincident(index + 1)) {
- fIntersections->removeOne(index + 1);
- --last;
- } else {
- fIntersections->setCoincident(index++);
- }
- fIntersections->setCoincident(index);
- }
- }
-
- // see parallel routine in line quadratic intersections
- int intersectRay(double roots[3]) {
- double adj = fLine[1].fX - fLine[0].fX;
- double opp = fLine[1].fY - fLine[0].fY;
- SkDCubic c;
- SkDEBUGCODE(c.fDebugGlobalState = fIntersections->globalState());
- for (int n = 0; n < 4; ++n) {
- c[n].fX = (fCubic[n].fY - fLine[0].fY) * adj - (fCubic[n].fX - fLine[0].fX) * opp;
- }
- double A, B, C, D;
- SkDCubic::Coefficients(&c[0].fX, &A, &B, &C, &D);
- int count = SkDCubic::RootsValidT(A, B, C, D, roots);
- for (int index = 0; index < count; ++index) {
- SkDPoint calcPt = c.ptAtT(roots[index]);
- if (!approximately_zero(calcPt.fX)) {
- for (int n = 0; n < 4; ++n) {
- c[n].fY = (fCubic[n].fY - fLine[0].fY) * opp
- + (fCubic[n].fX - fLine[0].fX) * adj;
- }
- double extremeTs[6];
- int extrema = SkDCubic::FindExtrema(&c[0].fX, extremeTs);
- count = c.searchRoots(extremeTs, extrema, 0, SkDCubic::kXAxis, roots);
- break;
- }
- }
- return count;
- }
-
- int intersect() {
- addExactEndPoints();
- if (fAllowNear) {
- addNearEndPoints();
- }
- double rootVals[3];
- int roots = intersectRay(rootVals);
- for (int index = 0; index < roots; ++index) {
- double cubicT = rootVals[index];
- double lineT = findLineT(cubicT);
- SkDPoint pt;
- if (pinTs(&cubicT, &lineT, &pt, kPointUninitialized) && uniqueAnswer(cubicT, pt)) {
- fIntersections->insert(cubicT, lineT, pt);
- }
- }
- checkCoincident();
- return fIntersections->used();
- }
-
static int HorizontalIntersect(const SkDCubic& c, double axisIntercept, double roots[3]) {
double A, B, C, D;
SkDCubic::Coefficients(&c[0].fY, &A, &B, &C, &D);
@@ -181,52 +91,6 @@
return count;
}
- int horizontalIntersect(double axisIntercept, double left, double right, bool flipped) {
- addExactHorizontalEndPoints(left, right, axisIntercept);
- if (fAllowNear) {
- addNearHorizontalEndPoints(left, right, axisIntercept);
- }
- double roots[3];
- int count = HorizontalIntersect(fCubic, axisIntercept, roots);
- for (int index = 0; index < count; ++index) {
- double cubicT = roots[index];
- SkDPoint pt = { fCubic.ptAtT(cubicT).fX, axisIntercept };
- double lineT = (pt.fX - left) / (right - left);
- if (pinTs(&cubicT, &lineT, &pt, kPointInitialized) && uniqueAnswer(cubicT, pt)) {
- fIntersections->insert(cubicT, lineT, pt);
- }
- }
- if (flipped) {
- fIntersections->flip();
- }
- checkCoincident();
- return fIntersections->used();
- }
-
- bool uniqueAnswer(double cubicT, const SkDPoint& pt) {
- for (int inner = 0; inner < fIntersections->used(); ++inner) {
- if (fIntersections->pt(inner) != pt) {
- continue;
- }
- double existingCubicT = (*fIntersections)[0][inner];
- if (cubicT == existingCubicT) {
- return false;
- }
- // check if midway on cubic is also same point. If so, discard this
- double cubicMidT = (existingCubicT + cubicT) / 2;
- SkDPoint cubicMidPt = fCubic.ptAtT(cubicMidT);
- if (cubicMidPt.approximatelyEqual(pt)) {
- return false;
- }
- }
-#if ONE_OFF_DEBUG
- SkDPoint cPt = fCubic.ptAtT(cubicT);
- SkDebugf("%s pt=(%1.9g,%1.9g) cPt=(%1.9g,%1.9g)\n", __FUNCTION__, pt.fX, pt.fY,
- cPt.fX, cPt.fY);
-#endif
- return true;
- }
-
static int VerticalIntersect(const SkDCubic& c, double axisIntercept, double roots[3]) {
double A, B, C, D;
SkDCubic::Coefficients(&c[0].fX, &A, &B, &C, &D);
@@ -243,207 +107,8 @@
}
return count;
}
-
- int verticalIntersect(double axisIntercept, double top, double bottom, bool flipped) {
- addExactVerticalEndPoints(top, bottom, axisIntercept);
- if (fAllowNear) {
- addNearVerticalEndPoints(top, bottom, axisIntercept);
- }
- double roots[3];
- int count = VerticalIntersect(fCubic, axisIntercept, roots);
- for (int index = 0; index < count; ++index) {
- double cubicT = roots[index];
- SkDPoint pt = { axisIntercept, fCubic.ptAtT(cubicT).fY };
- double lineT = (pt.fY - top) / (bottom - top);
- if (pinTs(&cubicT, &lineT, &pt, kPointInitialized) && uniqueAnswer(cubicT, pt)) {
- fIntersections->insert(cubicT, lineT, pt);
- }
- }
- if (flipped) {
- fIntersections->flip();
- }
- checkCoincident();
- return fIntersections->used();
- }
-
- protected:
-
- void addExactEndPoints() {
- for (int cIndex = 0; cIndex < 4; cIndex += 3) {
- double lineT = fLine.exactPoint(fCubic[cIndex]);
- if (lineT < 0) {
- continue;
- }
- double cubicT = (double) (cIndex >> 1);
- fIntersections->insert(cubicT, lineT, fCubic[cIndex]);
- }
- }
-
- /* Note that this does not look for endpoints of the line that are near the cubic.
- These points are found later when check ends looks for missing points */
- void addNearEndPoints() {
- for (int cIndex = 0; cIndex < 4; cIndex += 3) {
- double cubicT = (double) (cIndex >> 1);
- if (fIntersections->hasT(cubicT)) {
- continue;
- }
- double lineT = fLine.nearPoint(fCubic[cIndex], nullptr);
- if (lineT < 0) {
- continue;
- }
- fIntersections->insert(cubicT, lineT, fCubic[cIndex]);
- }
- this->addLineNearEndPoints();
- }
-
- void addLineNearEndPoints() {
- for (int lIndex = 0; lIndex < 2; ++lIndex) {
- double lineT = (double) lIndex;
- if (fIntersections->hasOppT(lineT)) {
- continue;
- }
- double cubicT = ((SkDCurve*) &fCubic)->nearPoint(SkPath::kCubic_Verb,
- fLine[lIndex], fLine[!lIndex]);
- if (cubicT < 0) {
- continue;
- }
- fIntersections->insert(cubicT, lineT, fLine[lIndex]);
- }
- }
-
- void addExactHorizontalEndPoints(double left, double right, double y) {
- for (int cIndex = 0; cIndex < 4; cIndex += 3) {
- double lineT = SkDLine::ExactPointH(fCubic[cIndex], left, right, y);
- if (lineT < 0) {
- continue;
- }
- double cubicT = (double) (cIndex >> 1);
- fIntersections->insert(cubicT, lineT, fCubic[cIndex]);
- }
- }
-
- void addNearHorizontalEndPoints(double left, double right, double y) {
- for (int cIndex = 0; cIndex < 4; cIndex += 3) {
- double cubicT = (double) (cIndex >> 1);
- if (fIntersections->hasT(cubicT)) {
- continue;
- }
- double lineT = SkDLine::NearPointH(fCubic[cIndex], left, right, y);
- if (lineT < 0) {
- continue;
- }
- fIntersections->insert(cubicT, lineT, fCubic[cIndex]);
- }
- this->addLineNearEndPoints();
- }
-
- void addExactVerticalEndPoints(double top, double bottom, double x) {
- for (int cIndex = 0; cIndex < 4; cIndex += 3) {
- double lineT = SkDLine::ExactPointV(fCubic[cIndex], top, bottom, x);
- if (lineT < 0) {
- continue;
- }
- double cubicT = (double) (cIndex >> 1);
- fIntersections->insert(cubicT, lineT, fCubic[cIndex]);
- }
- }
-
- void addNearVerticalEndPoints(double top, double bottom, double x) {
- for (int cIndex = 0; cIndex < 4; cIndex += 3) {
- double cubicT = (double) (cIndex >> 1);
- if (fIntersections->hasT(cubicT)) {
- continue;
- }
- double lineT = SkDLine::NearPointV(fCubic[cIndex], top, bottom, x);
- if (lineT < 0) {
- continue;
- }
- fIntersections->insert(cubicT, lineT, fCubic[cIndex]);
- }
- this->addLineNearEndPoints();
- }
-
- double findLineT(double t) {
- SkDPoint xy = fCubic.ptAtT(t);
- double dx = fLine[1].fX - fLine[0].fX;
- double dy = fLine[1].fY - fLine[0].fY;
- if (fabs(dx) > fabs(dy)) {
- return (xy.fX - fLine[0].fX) / dx;
- }
- return (xy.fY - fLine[0].fY) / dy;
- }
-
- bool pinTs(double* cubicT, double* lineT, SkDPoint* pt, PinTPoint ptSet) {
- if (!approximately_one_or_less(*lineT)) {
- return false;
- }
- if (!approximately_zero_or_more(*lineT)) {
- return false;
- }
- double cT = *cubicT = SkPinT(*cubicT);
- double lT = *lineT = SkPinT(*lineT);
- SkDPoint lPt = fLine.ptAtT(lT);
- SkDPoint cPt = fCubic.ptAtT(cT);
- if (!lPt.roughlyEqual(cPt)) {
- return false;
- }
- // FIXME: if points are roughly equal but not approximately equal, need to do
- // a binary search like quad/quad intersection to find more precise t values
- if (lT == 0 || lT == 1 || (ptSet == kPointUninitialized && cT != 0 && cT != 1)) {
- *pt = lPt;
- } else if (ptSet == kPointUninitialized) {
- *pt = cPt;
- }
- SkPoint gridPt = pt->asSkPoint();
- if (gridPt == fLine[0].asSkPoint()) {
- *lineT = 0;
- } else if (gridPt == fLine[1].asSkPoint()) {
- *lineT = 1;
- }
- if (gridPt == fCubic[0].asSkPoint() && approximately_equal(*cubicT, 0)) {
- *cubicT = 0;
- } else if (gridPt == fCubic[3].asSkPoint() && approximately_equal(*cubicT, 1)) {
- *cubicT = 1;
- }
- return true;
- }
-
-private:
- const SkDCubic& fCubic;
- const SkDLine& fLine;
- SkIntersections* fIntersections;
- bool fAllowNear;
};
-int SkIntersections::horizontal(const SkDCubic& cubic, double left, double right, double y,
- bool flipped) {
- SkDLine line = {{{ left, y }, { right, y }}};
- LineCubicIntersections c(cubic, line, this);
- return c.horizontalIntersect(y, left, right, flipped);
-}
-
-int SkIntersections::vertical(const SkDCubic& cubic, double top, double bottom, double x,
- bool flipped) {
- SkDLine line = {{{ x, top }, { x, bottom }}};
- LineCubicIntersections c(cubic, line, this);
- return c.verticalIntersect(x, top, bottom, flipped);
-}
-
-int SkIntersections::intersect(const SkDCubic& cubic, const SkDLine& line) {
- LineCubicIntersections c(cubic, line, this);
- c.allowNear(fAllowNear);
- return c.intersect();
-}
-
-int SkIntersections::intersectRay(const SkDCubic& cubic, const SkDLine& line) {
- LineCubicIntersections c(cubic, line, this);
- fUsed = c.intersectRay(fT[0]);
- for (int index = 0; index < fUsed; ++index) {
- fPt[index] = cubic.ptAtT(fT[0][index]);
- }
- return fUsed;
-}
-
// SkDCubic accessors to Intersection utilities
int SkDCubic::horizontalIntersect(double yIntercept, double roots[3]) const {
Only in skia/src/pathops: SkDCubicToQuads.cpp
Only in skia/src/pathops: SkDLineIntersection.cpp
Only in skia/src/pathops: SkDQuadLineIntersection.cpp
Only in skia/src/pathops: SkIntersectionHelper.h
Only in skia/src/pathops: SkIntersections.cpp
Only in skia/src/pathops: SkIntersections.h
Only in skia/src/pathops: SkLineParameters.h
Only in skia/src/pathops: SkOpAngle.cpp
Only in skia/src/pathops: SkOpAngle.h
Only in skia/src/pathops: SkOpBuilder.cpp
Only in skia/src/pathops: SkOpCoincidence.cpp
Only in skia/src/pathops: SkOpCoincidence.h
Only in skia/src/pathops: SkOpContour.cpp
Only in skia/src/pathops: SkOpContour.h
Only in skia/src/pathops: SkOpCubicHull.cpp
Only in skia/src/pathops: SkOpEdgeBuilder.cpp
Only in skia/src/pathops: SkOpEdgeBuilder.h
Only in skia/src/pathops: SkOpSegment.cpp
Only in skia/src/pathops: SkOpSegment.h
Only in skia/src/pathops: SkOpSpan.cpp
Only in skia/src/pathops: SkOpSpan.h
Only in skia/src/pathops: SkPathOpsAsWinding.cpp
Only in skia/src/pathops: SkPathOpsBounds.h
Only in skia/src/pathops: SkPathOpsCommon.cpp
Only in skia/src/pathops: SkPathOpsCommon.h
Only in skia/src/pathops: SkPathOpsConic.cpp
Only in skia/src/pathops: SkPathOpsConic.h
diff --recursive --unified skia/src/pathops/SkPathOpsCubic.cpp tiny-skia/skia/src/pathops/SkPathOpsCubic.cpp
@@ -6,25 +6,11 @@
*/
#include "src/core/SkGeometry.h"
#include "src/core/SkTSort.h"
-#include "src/pathops/SkLineParameters.h"
-#include "src/pathops/SkPathOpsConic.h"
#include "src/pathops/SkPathOpsCubic.h"
-#include "src/pathops/SkPathOpsCurve.h"
-#include "src/pathops/SkPathOpsLine.h"
#include "src/pathops/SkPathOpsQuad.h"
-#include "src/pathops/SkPathOpsRect.h"
const int SkDCubic::gPrecisionUnit = 256; // FIXME: test different values in test framework
-void SkDCubic::align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const {
- if (fPts[endIndex].fX == fPts[ctrlIndex].fX) {
- dstPt->fX = fPts[endIndex].fX;
- }
- if (fPts[endIndex].fY == fPts[ctrlIndex].fY) {
- dstPt->fY = fPts[endIndex].fY;
- }
-}
-
// give up when changing t no longer moves point
// also, copy point rather than recompute it when it does change
double SkDCubic::binarySearch(double min, double max, double axisIntercept,
@@ -74,13 +60,6 @@
return t;
}
-// get the rough scale of the cubic; used to determine if curvature is extreme
-double SkDCubic::calcPrecision() const {
- return ((fPts[1] - fPts[0]).length()
- + (fPts[2] - fPts[1]).length()
- + (fPts[3] - fPts[2]).length()) / gPrecisionUnit;
-}
-
/* classic one t subdivision */
static void interp_cubic_coords(const double* src, double* dst, double t) {
double ab = SkDInterp(src[0], src[2], t);
@@ -131,213 +110,6 @@
*C -= 3 * *D; // C = -3*a + 3*b
}
-bool SkDCubic::endsAreExtremaInXOrY() const {
- return (between(fPts[0].fX, fPts[1].fX, fPts[3].fX)
- && between(fPts[0].fX, fPts[2].fX, fPts[3].fX))
- || (between(fPts[0].fY, fPts[1].fY, fPts[3].fY)
- && between(fPts[0].fY, fPts[2].fY, fPts[3].fY));
-}
-
-// Do a quick reject by rotating all points relative to a line formed by
-// a pair of one cubic's points. If the 2nd cubic's points
-// are on the line or on the opposite side from the 1st cubic's 'odd man', the
-// curves at most intersect at the endpoints.
-/* if returning true, check contains true if cubic's hull collapsed, making the cubic linear
- if returning false, check contains true if the the cubic pair have only the end point in common
-*/
-bool SkDCubic::hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const {
- bool linear = true;
- char hullOrder[4];
- int hullCount = convexHull(hullOrder);
- int end1 = hullOrder[0];
- int hullIndex = 0;
- const SkDPoint* endPt[2];
- endPt[0] = &fPts[end1];
- do {
- hullIndex = (hullIndex + 1) % hullCount;
- int end2 = hullOrder[hullIndex];
- endPt[1] = &fPts[end2];
- double origX = endPt[0]->fX;
- double origY = endPt[0]->fY;
- double adj = endPt[1]->fX - origX;
- double opp = endPt[1]->fY - origY;
- int oddManMask = other_two(end1, end2);
- int oddMan = end1 ^ oddManMask;
- double sign = (fPts[oddMan].fY - origY) * adj - (fPts[oddMan].fX - origX) * opp;
- int oddMan2 = end2 ^ oddManMask;
- double sign2 = (fPts[oddMan2].fY - origY) * adj - (fPts[oddMan2].fX - origX) * opp;
- if (sign * sign2 < 0) {
- continue;
- }
- if (approximately_zero(sign)) {
- sign = sign2;
- if (approximately_zero(sign)) {
- continue;
- }
- }
- linear = false;
- bool foundOutlier = false;
- for (int n = 0; n < ptCount; ++n) {
- double test = (pts[n].fY - origY) * adj - (pts[n].fX - origX) * opp;
- if (test * sign > 0 && !precisely_zero(test)) {
- foundOutlier = true;
- break;
- }
- }
- if (!foundOutlier) {
- return false;
- }
- endPt[0] = endPt[1];
- end1 = end2;
- } while (hullIndex);
- *isLinear = linear;
- return true;
-}
-
-bool SkDCubic::hullIntersects(const SkDCubic& c2, bool* isLinear) const {
- return hullIntersects(c2.fPts, c2.kPointCount, isLinear);
-}
-
-bool SkDCubic::hullIntersects(const SkDQuad& quad, bool* isLinear) const {
- return hullIntersects(quad.fPts, quad.kPointCount, isLinear);
-}
-
-bool SkDCubic::hullIntersects(const SkDConic& conic, bool* isLinear) const {
-
- return hullIntersects(conic.fPts, isLinear);
-}
-
-bool SkDCubic::isLinear(int startIndex, int endIndex) const {
- if (fPts[0].approximatelyDEqual(fPts[3])) {
- return ((const SkDQuad *) this)->isLinear(0, 2);
- }
- SkLineParameters lineParameters;
- lineParameters.cubicEndPoints(*this, startIndex, endIndex);
- // FIXME: maybe it's possible to avoid this and compare non-normalized
- lineParameters.normalize();
- double tiniest = std::min(std::min(std::min(std::min(std::min(std::min(std::min(fPts[0].fX, fPts[0].fY),
- fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPts[3].fY);
- double largest = std::max(std::max(std::max(std::max(std::max(std::max(std::max(fPts[0].fX, fPts[0].fY),
- fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY), fPts[3].fX), fPts[3].fY);
- largest = std::max(largest, -tiniest);
- double distance = lineParameters.controlPtDistance(*this, 1);
- if (!approximately_zero_when_compared_to(distance, largest)) {
- return false;
- }
- distance = lineParameters.controlPtDistance(*this, 2);
- return approximately_zero_when_compared_to(distance, largest);
-}
-
-// from http://www.cs.sunysb.edu/~qin/courses/geometry/4.pdf
-// c(t) = a(1-t)^3 + 3bt(1-t)^2 + 3c(1-t)t^2 + dt^3
-// c'(t) = -3a(1-t)^2 + 3b((1-t)^2 - 2t(1-t)) + 3c(2t(1-t) - t^2) + 3dt^2
-// = 3(b-a)(1-t)^2 + 6(c-b)t(1-t) + 3(d-c)t^2
-static double derivative_at_t(const double* src, double t) {
- double one_t = 1 - t;
- double a = src[0];
- double b = src[2];
- double c = src[4];
- double d = src[6];
- return 3 * ((b - a) * one_t * one_t + 2 * (c - b) * t * one_t + (d - c) * t * t);
-}
-
-int SkDCubic::ComplexBreak(const SkPoint pointsPtr[4], SkScalar* t) {
- SkDCubic cubic;
- cubic.set(pointsPtr);
- if (cubic.monotonicInX() && cubic.monotonicInY()) {
- return 0;
- }
- double tt[2], ss[2];
- SkCubicType cubicType = SkClassifyCubic(pointsPtr, tt, ss);
- switch (cubicType) {
- case SkCubicType::kLoop: {
- const double &td = tt[0], &te = tt[1], &sd = ss[0], &se = ss[1];
- if (roughly_between(0, td, sd) && roughly_between(0, te, se)) {
- t[0] = static_cast<SkScalar>((td * se + te * sd) / (2 * sd * se));
- return (int) (t[0] > 0 && t[0] < 1);
- }
- }
- [[fallthrough]]; // fall through if no t value found
- case SkCubicType::kSerpentine:
- case SkCubicType::kLocalCusp:
- case SkCubicType::kCuspAtInfinity: {
- double inflectionTs[2];
- int infTCount = cubic.findInflections(inflectionTs);
- double maxCurvature[3];
- int roots = cubic.findMaxCurvature(maxCurvature);
- #if DEBUG_CUBIC_SPLIT
- SkDebugf("%s\n", __FUNCTION__);
- cubic.dump();
- for (int index = 0; index < infTCount; ++index) {
- SkDebugf("inflectionsTs[%d]=%1.9g ", index, inflectionTs[index]);
- SkDPoint pt = cubic.ptAtT(inflectionTs[index]);
- SkDVector dPt = cubic.dxdyAtT(inflectionTs[index]);
- SkDLine perp = {{pt - dPt, pt + dPt}};
- perp.dump();
- }
- for (int index = 0; index < roots; ++index) {
- SkDebugf("maxCurvature[%d]=%1.9g ", index, maxCurvature[index]);
- SkDPoint pt = cubic.ptAtT(maxCurvature[index]);
- SkDVector dPt = cubic.dxdyAtT(maxCurvature[index]);
- SkDLine perp = {{pt - dPt, pt + dPt}};
- perp.dump();
- }
- #endif
- if (infTCount == 2) {
- for (int index = 0; index < roots; ++index) {
- if (between(inflectionTs[0], maxCurvature[index], inflectionTs[1])) {
- t[0] = maxCurvature[index];
- return (int) (t[0] > 0 && t[0] < 1);
- }
- }
- } else {
- int resultCount = 0;
- // FIXME: constant found through experimentation -- maybe there's a better way....
- double precision = cubic.calcPrecision() * 2;
- for (int index = 0; index < roots; ++index) {
- double testT = maxCurvature[index];
- if (0 >= testT || testT >= 1) {
- continue;
- }
- // don't call dxdyAtT since we want (0,0) results
- SkDVector dPt = { derivative_at_t(&cubic.fPts[0].fX, testT),
- derivative_at_t(&cubic.fPts[0].fY, testT) };
- double dPtLen = dPt.length();
- if (dPtLen < precision) {
- t[resultCount++] = testT;
- }
- }
- if (!resultCount && infTCount == 1) {
- t[0] = inflectionTs[0];
- resultCount = (int) (t[0] > 0 && t[0] < 1);
- }
- return resultCount;
- }
- break;
- }
- default:
- break;
- }
- return 0;
-}
-
-bool SkDCubic::monotonicInX() const {
- return precisely_between(fPts[0].fX, fPts[1].fX, fPts[3].fX)
- && precisely_between(fPts[0].fX, fPts[2].fX, fPts[3].fX);
-}
-
-bool SkDCubic::monotonicInY() const {
- return precisely_between(fPts[0].fY, fPts[1].fY, fPts[3].fY)
- && precisely_between(fPts[0].fY, fPts[2].fY, fPts[3].fY);
-}
-
-void SkDCubic::otherPts(int index, const SkDPoint* o1Pts[kPointCount - 1]) const {
- int offset = (int) !SkToBool(index);
- o1Pts[0] = &fPts[offset];
- o1Pts[1] = &fPts[++offset];
- o1Pts[2] = &fPts[++offset];
-}
-
int SkDCubic::searchRoots(double extremeTs[6], int extrema, double axisIntercept,
SearchAxis xAxis, double* validRoots) const {
extrema += findInflections(&extremeTs[extrema]);
@@ -404,9 +176,6 @@
// set print elements 400 # if line doesn't fit
char str[1024];
sk_bzero(str, sizeof(str));
- SK_SNPRINTF(str, sizeof(str), "Solve[%1.19g x^3 + %1.19g x^2 + %1.19g x + %1.19g == 0, x]",
- A, B, C, D);
- SkPathOpsDebug::MathematicaIze(str, sizeof(str));
#if ONE_OFF_DEBUG && ONE_OFF_DEBUG_MATHEMATICA
SkDebugf("%s\n", str);
#endif
@@ -493,25 +262,6 @@
return static_cast<int>(roots - s);
}
-// OPTIMIZE? compute t^2, t(1-t), and (1-t)^2 and pass them to another version of derivative at t?
-SkDVector SkDCubic::dxdyAtT(double t) const {
- SkDVector result = { derivative_at_t(&fPts[0].fX, t), derivative_at_t(&fPts[0].fY, t) };
- if (result.fX == 0 && result.fY == 0) {
- if (t == 0) {
- result = fPts[2] - fPts[0];
- } else if (t == 1) {
- result = fPts[3] - fPts[1];
- } else {
- // incomplete
- SkDebugf("!c");
- }
- if (result.fX == 0 && result.fY == 0 && zero_or_one(t)) {
- result = fPts[3] - fPts[0];
- }
- }
- return result;
-}
-
// OPTIMIZE? share code with formulate_F1DotF2
int SkDCubic::findInflections(double tValues[]) const {
double Ax = fPts[1].fX - fPts[0].fX;
@@ -593,159 +343,3 @@
a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY + d * fPts[3].fY};
return result;
}
-
-/*
- Given a cubic c, t1, and t2, find a small cubic segment.
-
- The new cubic is defined as points A, B, C, and D, where
- s1 = 1 - t1
- s2 = 1 - t2
- A = c[0]*s1*s1*s1 + 3*c[1]*s1*s1*t1 + 3*c[2]*s1*t1*t1 + c[3]*t1*t1*t1
- D = c[0]*s2*s2*s2 + 3*c[1]*s2*s2*t2 + 3*c[2]*s2*t2*t2 + c[3]*t2*t2*t2
-
- We don't have B or C. So We define two equations to isolate them.
- First, compute two reference T values 1/3 and 2/3 from t1 to t2:
-
- c(at (2*t1 + t2)/3) == E
- c(at (t1 + 2*t2)/3) == F
-
- Next, compute where those values must be if we know the values of B and C:
-
- _12 = A*2/3 + B*1/3
- 12_ = A*1/3 + B*2/3
- _23 = B*2/3 + C*1/3
- 23_ = B*1/3 + C*2/3
- _34 = C*2/3 + D*1/3
- 34_ = C*1/3 + D*2/3
- _123 = (A*2/3 + B*1/3)*2/3 + (B*2/3 + C*1/3)*1/3 = A*4/9 + B*4/9 + C*1/9
- 123_ = (A*1/3 + B*2/3)*1/3 + (B*1/3 + C*2/3)*2/3 = A*1/9 + B*4/9 + C*4/9
- _234 = (B*2/3 + C*1/3)*2/3 + (C*2/3 + D*1/3)*1/3 = B*4/9 + C*4/9 + D*1/9
- 234_ = (B*1/3 + C*2/3)*1/3 + (C*1/3 + D*2/3)*2/3 = B*1/9 + C*4/9 + D*4/9
- _1234 = (A*4/9 + B*4/9 + C*1/9)*2/3 + (B*4/9 + C*4/9 + D*1/9)*1/3
- = A*8/27 + B*12/27 + C*6/27 + D*1/27
- = E
- 1234_ = (A*1/9 + B*4/9 + C*4/9)*1/3 + (B*1/9 + C*4/9 + D*4/9)*2/3
- = A*1/27 + B*6/27 + C*12/27 + D*8/27
- = F
- E*27 = A*8 + B*12 + C*6 + D
- F*27 = A + B*6 + C*12 + D*8
-
-Group the known values on one side:
-
- M = E*27 - A*8 - D = B*12 + C* 6
- N = F*27 - A - D*8 = B* 6 + C*12
- M*2 - N = B*18
- N*2 - M = C*18
- B = (M*2 - N)/18
- C = (N*2 - M)/18
- */
-
-static double interp_cubic_coords(const double* src, double t) {
- double ab = SkDInterp(src[0], src[2], t);
- double bc = SkDInterp(src[2], src[4], t);
- double cd = SkDInterp(src[4], src[6], t);
- double abc = SkDInterp(ab, bc, t);
- double bcd = SkDInterp(bc, cd, t);
- double abcd = SkDInterp(abc, bcd, t);
- return abcd;
-}
-
-SkDCubic SkDCubic::subDivide(double t1, double t2) const {
- if (t1 == 0 || t2 == 1) {
- if (t1 == 0 && t2 == 1) {
- return *this;
- }
- SkDCubicPair pair = chopAt(t1 == 0 ? t2 : t1);
- SkDCubic dst = t1 == 0 ? pair.first() : pair.second();
- return dst;
- }
- SkDCubic dst;
- double ax = dst[0].fX = interp_cubic_coords(&fPts[0].fX, t1);
- double ay = dst[0].fY = interp_cubic_coords(&fPts[0].fY, t1);
- double ex = interp_cubic_coords(&fPts[0].fX, (t1*2+t2)/3);
- double ey = interp_cubic_coords(&fPts[0].fY, (t1*2+t2)/3);
- double fx = interp_cubic_coords(&fPts[0].fX, (t1+t2*2)/3);
- double fy = interp_cubic_coords(&fPts[0].fY, (t1+t2*2)/3);
- double dx = dst[3].fX = interp_cubic_coords(&fPts[0].fX, t2);
- double dy = dst[3].fY = interp_cubic_coords(&fPts[0].fY, t2);
- double mx = ex * 27 - ax * 8 - dx;
- double my = ey * 27 - ay * 8 - dy;
- double nx = fx * 27 - ax - dx * 8;
- double ny = fy * 27 - ay - dy * 8;
- /* bx = */ dst[1].fX = (mx * 2 - nx) / 18;
- /* by = */ dst[1].fY = (my * 2 - ny) / 18;
- /* cx = */ dst[2].fX = (nx * 2 - mx) / 18;
- /* cy = */ dst[2].fY = (ny * 2 - my) / 18;
- // FIXME: call align() ?
- return dst;
-}
-
-void SkDCubic::subDivide(const SkDPoint& a, const SkDPoint& d,
- double t1, double t2, SkDPoint dst[2]) const {
- SkASSERT(t1 != t2);
- // this approach assumes that the control points computed directly are accurate enough
- SkDCubic sub = subDivide(t1, t2);
- dst[0] = sub[1] + (a - sub[0]);
- dst[1] = sub[2] + (d - sub[3]);
- if (t1 == 0 || t2 == 0) {
- align(0, 1, t1 == 0 ? &dst[0] : &dst[1]);
- }
- if (t1 == 1 || t2 == 1) {
- align(3, 2, t1 == 1 ? &dst[0] : &dst[1]);
- }
- if (AlmostBequalUlps(dst[0].fX, a.fX)) {
- dst[0].fX = a.fX;
- }
- if (AlmostBequalUlps(dst[0].fY, a.fY)) {
- dst[0].fY = a.fY;
- }
- if (AlmostBequalUlps(dst[1].fX, d.fX)) {
- dst[1].fX = d.fX;
- }
- if (AlmostBequalUlps(dst[1].fY, d.fY)) {
- dst[1].fY = d.fY;
- }
-}
-
-bool SkDCubic::toFloatPoints(SkPoint* pts) const {
- const double* dCubic = &fPts[0].fX;
- SkScalar* cubic = &pts[0].fX;
- for (int index = 0; index < kPointCount * 2; ++index) {
- cubic[index] = SkDoubleToScalar(dCubic[index]);
- if (SkScalarAbs(cubic[index]) < FLT_EPSILON_ORDERABLE_ERR) {
- cubic[index] = 0;
- }
- }
- return SkScalarsAreFinite(&pts->fX, kPointCount * 2);
-}
-
-double SkDCubic::top(const SkDCubic& dCurve, double startT, double endT, SkDPoint*topPt) const {
- double extremeTs[2];
- double topT = -1;
- int roots = SkDCubic::FindExtrema(&fPts[0].fY, extremeTs);
- for (int index = 0; index < roots; ++index) {
- double t = startT + (endT - startT) * extremeTs[index];
- SkDPoint mid = dCurve.ptAtT(t);
- if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) {
- topT = t;
- *topPt = mid;
- }
- }
- return topT;
-}
-
-int SkTCubic::intersectRay(SkIntersections* i, const SkDLine& line) const {
- return i->intersectRay(fCubic, line);
-}
-
-bool SkTCubic::hullIntersects(const SkDQuad& quad, bool* isLinear) const {
- return quad.hullIntersects(fCubic, isLinear);
-}
-
-bool SkTCubic::hullIntersects(const SkDConic& conic, bool* isLinear) const {
- return conic.hullIntersects(fCubic, isLinear);
-}
-
-void SkTCubic::setBounds(SkDRect* rect) const {
- rect->setBounds(fCubic);
-}
diff --recursive --unified skia/src/pathops/SkPathOpsCubic.h tiny-skia/skia/src/pathops/SkPathOpsCubic.h
@@ -10,7 +10,7 @@
#include "include/core/SkPath.h"
#include "src/core/SkArenaAlloc.h"
-#include "src/pathops/SkPathOpsTCurve.h"
+#include "src/pathops/SkPathOpsPoint.h"
struct SkDCubicPair;
@@ -24,43 +24,13 @@
kYAxis
};
- bool collapsed() const {
- return fPts[0].approximatelyEqual(fPts[1]) && fPts[0].approximatelyEqual(fPts[2])
- && fPts[0].approximatelyEqual(fPts[3]);
- }
-
- bool controlsInside() const {
- SkDVector v01 = fPts[0] - fPts[1];
- SkDVector v02 = fPts[0] - fPts[2];
- SkDVector v03 = fPts[0] - fPts[3];
- SkDVector v13 = fPts[1] - fPts[3];
- SkDVector v23 = fPts[2] - fPts[3];
- return v03.dot(v01) > 0 && v03.dot(v02) > 0 && v03.dot(v13) > 0 && v03.dot(v23) > 0;
- }
-
- static bool IsConic() { return false; }
-
const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount); return fPts[n]; }
SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fPts[n]; }
- void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const;
double binarySearch(double min, double max, double axisIntercept, SearchAxis xAxis) const;
- double calcPrecision() const;
SkDCubicPair chopAt(double t) const;
static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D);
- static int ComplexBreak(const SkPoint pts[4], SkScalar* t);
- int convexHull(char order[kPointCount]) const;
- void debugInit() {
- sk_bzero(fPts, sizeof(fPts));
- }
-
- void debugSet(const SkDPoint* pts);
-
- void dump() const; // callable from the debugger when the implementation code is linked in
- void dumpID(int id) const;
- void dumpInner() const;
- SkDVector dxdyAtT(double t) const;
bool endsAreExtremaInXOrY() const;
static int FindExtrema(const double src[], double tValue[2]);
int findInflections(double tValues[2]) const;
@@ -72,19 +42,7 @@
int findMaxCurvature(double tValues[]) const;
-#ifdef SK_DEBUG
- SkOpGlobalState* globalState() const { return fDebugGlobalState; }
-#endif
-
- bool hullIntersects(const SkDCubic& c2, bool* isLinear) const;
- bool hullIntersects(const SkDConic& c, bool* isLinear) const;
- bool hullIntersects(const SkDQuad& c2, bool* isLinear) const;
- bool hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const;
- bool isLinear(int startIndex, int endIndex) const;
static int maxIntersections() { return kMaxIntersections; }
- bool monotonicInX() const;
- bool monotonicInY() const;
- void otherPts(int index, const SkDPoint* o1Pts[kPointCount - 1]) const;
static int pointCount() { return kPointCount; }
static int pointLast() { return kPointLast; }
SkDPoint ptAtT(double t) const;
@@ -94,7 +52,6 @@
int searchRoots(double extremes[6], int extrema, double axisIntercept,
SearchAxis xAxis, double* validRoots) const;
- bool toFloatPoints(SkPoint* ) const;
/**
* Return the number of valid roots (0 < root < 1) for this cubic intersecting the
* specified horizontal line.
@@ -106,39 +63,17 @@
*/
int verticalIntersect(double xIntercept, double roots[3]) const;
-// add debug only global pointer so asserts can be skipped by fuzzers
- const SkDCubic& set(const SkPoint pts[kPointCount]
- SkDEBUGPARAMS(SkOpGlobalState* state = nullptr)) {
+ // add debug only global pointer so asserts can be skipped by fuzzers
+ const SkDCubic& set(const SkPoint pts[kPointCount]) {
fPts[0] = pts[0];
fPts[1] = pts[1];
fPts[2] = pts[2];
fPts[3] = pts[3];
- SkDEBUGCODE(fDebugGlobalState = state);
return *this;
}
- SkDCubic subDivide(double t1, double t2) const;
- void subDivide(double t1, double t2, SkDCubic* c) const { *c = this->subDivide(t1, t2); }
-
- static SkDCubic SubDivide(const SkPoint a[kPointCount], double t1, double t2) {
- SkDCubic cubic;
- return cubic.set(a).subDivide(t1, t2);
- }
-
- void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, SkDPoint p[2]) const;
-
- static void SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a, const SkDPoint& d, double t1,
- double t2, SkDPoint p[2]) {
- SkDCubic cubic;
- cubic.set(pts).subDivide(a, d, t1, t2, p);
- }
-
- double top(const SkDCubic& dCurve, double startT, double endT, SkDPoint*topPt) const;
- SkDQuad toQuad() const;
-
static const int gPrecisionUnit;
SkDPoint fPts[kPointCount];
- SkDEBUGCODE(SkOpGlobalState* fDebugGlobalState);
};
/* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask
@@ -161,80 +96,12 @@
struct SkDCubicPair {
const SkDCubic first() const {
-#ifdef SK_DEBUG
- SkDCubic result;
- result.debugSet(&pts[0]);
- return result;
-#else
return (const SkDCubic&) pts[0];
-#endif
}
const SkDCubic second() const {
-#ifdef SK_DEBUG
- SkDCubic result;
- result.debugSet(&pts[3]);
- return result;
-#else
return (const SkDCubic&) pts[3];
-#endif
}
SkDPoint pts[7];
};
-class SkTCubic : public SkTCurve {
-public:
- SkDCubic fCubic;
-
- SkTCubic() {}
-
- SkTCubic(const SkDCubic& c)
- : fCubic(c) {
- }
-
- ~SkTCubic() override {}
-
- const SkDPoint& operator[](int n) const override { return fCubic[n]; }
- SkDPoint& operator[](int n) override { return fCubic[n]; }
-
- bool collapsed() const override { return fCubic.collapsed(); }
- bool controlsInside() const override { return fCubic.controlsInside(); }
- void debugInit() override { return fCubic.debugInit(); }
-#if DEBUG_T_SECT
- void dumpID(int id) const override { return fCubic.dumpID(id); }
-#endif
- SkDVector dxdyAtT(double t) const override { return fCubic.dxdyAtT(t); }
-#ifdef SK_DEBUG
- SkOpGlobalState* globalState() const override { return fCubic.globalState(); }
-#endif
- bool hullIntersects(const SkDQuad& quad, bool* isLinear) const override;
- bool hullIntersects(const SkDConic& conic, bool* isLinear) const override;
-
- bool hullIntersects(const SkDCubic& cubic, bool* isLinear) const override {
- return cubic.hullIntersects(fCubic, isLinear);
- }
-
- bool hullIntersects(const SkTCurve& curve, bool* isLinear) const override {
- return curve.hullIntersects(fCubic, isLinear);
- }
-
- int intersectRay(SkIntersections* i, const SkDLine& line) const override;
- bool IsConic() const override { return false; }
- SkTCurve* make(SkArenaAlloc& heap) const override { return heap.make<SkTCubic>(); }
-
- int maxIntersections() const override { return SkDCubic::kMaxIntersections; }
-
- void otherPts(int oddMan, const SkDPoint* endPt[2]) const override {
- fCubic.otherPts(oddMan, endPt);
- }
-
- int pointCount() const override { return SkDCubic::kPointCount; }
- int pointLast() const override { return SkDCubic::kPointLast; }
- SkDPoint ptAtT(double t) const override { return fCubic.ptAtT(t); }
- void setBounds(SkDRect* ) const override;
-
- void subDivide(double t1, double t2, SkTCurve* curve) const override {
- ((SkTCubic*) curve)->fCubic = fCubic.subDivide(t1, t2);
- }
-};
-
#endif
Only in skia/src/pathops: SkPathOpsCurve.cpp
Only in skia/src/pathops: SkPathOpsCurve.h
Only in skia/src/pathops: SkPathOpsDebug.cpp
Only in skia/src/pathops: SkPathOpsDebug.h
Only in skia/src/pathops: SkPathOpsLine.cpp
Only in skia/src/pathops: SkPathOpsLine.h
Only in skia/src/pathops: SkPathOpsOp.cpp
diff --recursive --unified skia/src/pathops/SkPathOpsPoint.h tiny-skia/skia/src/pathops/SkPathOpsPoint.h
@@ -192,28 +192,6 @@
return approximatelyEqual(dA);
}
- static bool ApproximatelyEqual(const SkPoint& a, const SkPoint& b) {
- if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY)) {
- return true;
- }
- if (!RoughlyEqualUlps(a.fX, b.fX) || !RoughlyEqualUlps(a.fY, b.fY)) {
- return false;
- }
- SkDPoint dA, dB;
- dA.set(a);
- dB.set(b);
- double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
- float tiniest = std::min(std::min(std::min(a.fX, b.fX), a.fY), b.fY);
- float largest = std::max(std::max(std::max(a.fX, b.fX), a.fY), b.fY);
- largest = std::max(largest, -tiniest);
- return AlmostDequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
- }
-
- // only used by testing
- bool approximatelyZero() const {
- return approximately_zero(fX) && approximately_zero(fY);
- }
-
SkPoint asSkPoint() const {
SkPoint pt = {SkDoubleToScalar(fX), SkDoubleToScalar(fY)};
return pt;
@@ -223,57 +201,6 @@
SkDVector temp = *this - a;
return temp.length();
}
-
- double distanceSquared(const SkDPoint& a) const {
- SkDVector temp = *this - a;
- return temp.lengthSquared();
- }
-
- static SkDPoint Mid(const SkDPoint& a, const SkDPoint& b) {
- SkDPoint result;
- result.fX = (a.fX + b.fX) / 2;
- result.fY = (a.fY + b.fY) / 2;
- return result;
- }
-
- bool roughlyEqual(const SkDPoint& a) const {
- if (roughly_equal(fX, a.fX) && roughly_equal(fY, a.fY)) {
- return true;
- }
- double dist = distance(a); // OPTIMIZATION: can we compare against distSq instead ?
- double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
- double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
- largest = std::max(largest, -tiniest);
- return RoughlyEqualUlps(largest, largest + dist); // is the dist within ULPS tolerance?
- }
-
- static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) {
- if (!RoughlyEqualUlps(a.fX, b.fX) && !RoughlyEqualUlps(a.fY, b.fY)) {
- return false;
- }
- SkDPoint dA, dB;
- dA.set(a);
- dB.set(b);
- double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
- float tiniest = std::min(std::min(std::min(a.fX, b.fX), a.fY), b.fY);
- float largest = std::max(std::max(std::max(a.fX, b.fX), a.fY), b.fY);
- largest = std::max(largest, -tiniest);
- return RoughlyEqualUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
- }
-
- // very light weight check, should only be used for inequality check
- static bool WayRoughlyEqual(const SkPoint& a, const SkPoint& b) {
- float largestNumber = std::max(SkTAbs(a.fX), std::max(SkTAbs(a.fY),
- std::max(SkTAbs(b.fX), SkTAbs(b.fY))));
- SkVector diffs = a - b;
- float largestDiff = std::max(diffs.fX, diffs.fY);
- return roughly_zero_when_compared_to(largestDiff, largestNumber);
- }
-
- // utilities callable by the user from the debugger when the implementation code is linked in
- void dump() const;
- static void Dump(const SkPoint& pt);
- static void DumpHex(const SkPoint& pt);
};
#endif
diff --recursive --unified skia/src/pathops/SkPathOpsQuad.cpp tiny-skia/skia/src/pathops/SkPathOpsQuad.cpp
@@ -4,108 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "src/pathops/SkIntersections.h"
-#include "src/pathops/SkLineParameters.h"
#include "src/pathops/SkPathOpsCubic.h"
-#include "src/pathops/SkPathOpsCurve.h"
#include "src/pathops/SkPathOpsQuad.h"
-#include "src/pathops/SkPathOpsRect.h"
-
-// from blackpawn.com/texts/pointinpoly
-static bool pointInTriangle(const SkDPoint fPts[3], const SkDPoint& test) {
- SkDVector v0 = fPts[2] - fPts[0];
- SkDVector v1 = fPts[1] - fPts[0];
- SkDVector v2 = test - fPts[0];
- double dot00 = v0.dot(v0);
- double dot01 = v0.dot(v1);
- double dot02 = v0.dot(v2);
- double dot11 = v1.dot(v1);
- double dot12 = v1.dot(v2);
- // Compute barycentric coordinates
- double denom = dot00 * dot11 - dot01 * dot01;
- double u = dot11 * dot02 - dot01 * dot12;
- double v = dot00 * dot12 - dot01 * dot02;
- // Check if point is in triangle
- if (denom >= 0) {
- return u >= 0 && v >= 0 && u + v < denom;
- }
- return u <= 0 && v <= 0 && u + v > denom;
-}
-
-static bool matchesEnd(const SkDPoint fPts[3], const SkDPoint& test) {
- return fPts[0] == test || fPts[2] == test;
-}
-
-/* started with at_most_end_pts_in_common from SkDQuadIntersection.cpp */
-// Do a quick reject by rotating all points relative to a line formed by
-// a pair of one quad's points. If the 2nd quad's points
-// are on the line or on the opposite side from the 1st quad's 'odd man', the
-// curves at most intersect at the endpoints.
-/* if returning true, check contains true if quad's hull collapsed, making the cubic linear
- if returning false, check contains true if the the quad pair have only the end point in common
-*/
-bool SkDQuad::hullIntersects(const SkDQuad& q2, bool* isLinear) const {
- bool linear = true;
- for (int oddMan = 0; oddMan < kPointCount; ++oddMan) {
- const SkDPoint* endPt[2];
- this->otherPts(oddMan, endPt);
- double origX = endPt[0]->fX;
- double origY = endPt[0]->fY;
- double adj = endPt[1]->fX - origX;
- double opp = endPt[1]->fY - origY;
- double sign = (fPts[oddMan].fY - origY) * adj - (fPts[oddMan].fX - origX) * opp;
- if (approximately_zero(sign)) {
- continue;
- }
- linear = false;
- bool foundOutlier = false;
- for (int n = 0; n < kPointCount; ++n) {
- double test = (q2[n].fY - origY) * adj - (q2[n].fX - origX) * opp;
- if (test * sign > 0 && !precisely_zero(test)) {
- foundOutlier = true;
- break;
- }
- }
- if (!foundOutlier) {
- return false;
- }
- }
- if (linear && !matchesEnd(fPts, q2.fPts[0]) && !matchesEnd(fPts, q2.fPts[2])) {
- // if the end point of the opposite quad is inside the hull that is nearly a line,
- // then representing the quad as a line may cause the intersection to be missed.
- // Check to see if the endpoint is in the triangle.
- if (pointInTriangle(fPts, q2.fPts[0]) || pointInTriangle(fPts, q2.fPts[2])) {
- linear = false;
- }
- }
- *isLinear = linear;
- return true;
-}
-
-bool SkDQuad::hullIntersects(const SkDConic& conic, bool* isLinear) const {
- return conic.hullIntersects(*this, isLinear);
-}
-
-bool SkDQuad::hullIntersects(const SkDCubic& cubic, bool* isLinear) const {
- return cubic.hullIntersects(*this, isLinear);
-}
-
-/* bit twiddling for finding the off curve index (x&~m is the pair in [0,1,2] excluding oddMan)
-oddMan opp x=oddMan^opp x=x-oddMan m=x>>2 x&~m
- 0 1 1 1 0 1
- 2 2 2 0 2
- 1 1 0 -1 -1 0
- 2 3 2 0 2
- 2 1 3 1 0 1
- 2 0 -2 -1 0
-*/
-void SkDQuad::otherPts(int oddMan, const SkDPoint* endPt[2]) const {
- for (int opp = 1; opp < kPointCount; ++opp) {
- int end = (oddMan ^ opp) - oddMan; // choose a value not equal to oddMan
- end &= ~(end >> 2); // if the value went negative, set it to zero
- endPt[opp - 1] = &fPts[end];
- }
-}
int SkDQuad::AddValidTs(double s[], int realRoots, double* t) {
int foundRoots = 0;
@@ -181,236 +81,3 @@
s[1] = -sqrt_D - p;
return 1 + !AlmostDequalUlps(s[0], s[1]);
}
-
-bool SkDQuad::isLinear(int startIndex, int endIndex) const {
- SkLineParameters lineParameters;
- lineParameters.quadEndPoints(*this, startIndex, endIndex);
- // FIXME: maybe it's possible to avoid this and compare non-normalized
- lineParameters.normalize();
- double distance = lineParameters.controlPtDistance(*this);
- double tiniest = std::min(std::min(std::min(std::min(std::min(fPts[0].fX, fPts[0].fY),
- fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY);
- double largest = std::max(std::max(std::max(std::max(std::max(fPts[0].fX, fPts[0].fY),
- fPts[1].fX), fPts[1].fY), fPts[2].fX), fPts[2].fY);
- largest = std::max(largest, -tiniest);
- return approximately_zero_when_compared_to(distance, largest);
-}
-
-SkDVector SkDQuad::dxdyAtT(double t) const {
- double a = t - 1;
- double b = 1 - 2 * t;
- double c = t;
- SkDVector result = { a * fPts[0].fX + b * fPts[1].fX + c * fPts[2].fX,
- a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY };
- if (result.fX == 0 && result.fY == 0) {
- if (zero_or_one(t)) {
- result = fPts[2] - fPts[0];
- } else {
- // incomplete
- SkDebugf("!q");
- }
- }
- return result;
-}
-
-// OPTIMIZE: assert if caller passes in t == 0 / t == 1 ?
-SkDPoint SkDQuad::ptAtT(double t) const {
- if (0 == t) {
- return fPts[0];
- }
- if (1 == t) {
- return fPts[2];
- }
- double one_t = 1 - t;
- double a = one_t * one_t;
- double b = 2 * one_t * t;
- double c = t * t;
- SkDPoint result = { a * fPts[0].fX + b * fPts[1].fX + c * fPts[2].fX,
- a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY };
- return result;
-}
-
-static double interp_quad_coords(const double* src, double t) {
- if (0 == t) {
- return src[0];
- }
- if (1 == t) {
- return src[4];
- }
- double ab = SkDInterp(src[0], src[2], t);
- double bc = SkDInterp(src[2], src[4], t);
- double abc = SkDInterp(ab, bc, t);
- return abc;
-}
-
-bool SkDQuad::monotonicInX() const {
- return between(fPts[0].fX, fPts[1].fX, fPts[2].fX);
-}
-
-bool SkDQuad::monotonicInY() const {
- return between(fPts[0].fY, fPts[1].fY, fPts[2].fY);
-}
-
-/*
-Given a quadratic q, t1, and t2, find a small quadratic segment.
-
-The new quadratic is defined by A, B, and C, where
- A = c[0]*(1 - t1)*(1 - t1) + 2*c[1]*t1*(1 - t1) + c[2]*t1*t1
- C = c[3]*(1 - t1)*(1 - t1) + 2*c[2]*t1*(1 - t1) + c[1]*t1*t1
-
-To find B, compute the point halfway between t1 and t2:
-
-q(at (t1 + t2)/2) == D
-
-Next, compute where D must be if we know the value of B:
-
-_12 = A/2 + B/2
-12_ = B/2 + C/2
-123 = A/4 + B/2 + C/4
- = D
-
-Group the known values on one side:
-
-B = D*2 - A/2 - C/2
-*/
-
-// OPTIMIZE? : special case t1 = 1 && t2 = 0
-SkDQuad SkDQuad::subDivide(double t1, double t2) const {
- if (0 == t1 && 1 == t2) {
- return *this;
- }
- SkDQuad dst;
- double ax = dst[0].fX = interp_quad_coords(&fPts[0].fX, t1);
- double ay = dst[0].fY = interp_quad_coords(&fPts[0].fY, t1);
- double dx = interp_quad_coords(&fPts[0].fX, (t1 + t2) / 2);
- double dy = interp_quad_coords(&fPts[0].fY, (t1 + t2) / 2);
- double cx = dst[2].fX = interp_quad_coords(&fPts[0].fX, t2);
- double cy = dst[2].fY = interp_quad_coords(&fPts[0].fY, t2);
- /* bx = */ dst[1].fX = 2 * dx - (ax + cx) / 2;
- /* by = */ dst[1].fY = 2 * dy - (ay + cy) / 2;
- return dst;
-}
-
-void SkDQuad::align(int endIndex, SkDPoint* dstPt) const {
- if (fPts[endIndex].fX == fPts[1].fX) {
- dstPt->fX = fPts[endIndex].fX;
- }
- if (fPts[endIndex].fY == fPts[1].fY) {
- dstPt->fY = fPts[endIndex].fY;
- }
-}
-
-SkDPoint SkDQuad::subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t2) const {
- SkASSERT(t1 != t2);
- SkDPoint b;
- SkDQuad sub = subDivide(t1, t2);
- SkDLine b0 = {{a, sub[1] + (a - sub[0])}};
- SkDLine b1 = {{c, sub[1] + (c - sub[2])}};
- SkIntersections i;
- i.intersectRay(b0, b1);
- if (i.used() == 1 && i[0][0] >= 0 && i[1][0] >= 0) {
- b = i.pt(0);
- } else {
- SkASSERT(i.used() <= 2);
- return SkDPoint::Mid(b0[1], b1[1]);
- }
- if (t1 == 0 || t2 == 0) {
- align(0, &b);
- }
- if (t1 == 1 || t2 == 1) {
- align(2, &b);
- }
- if (AlmostBequalUlps(b.fX, a.fX)) {
- b.fX = a.fX;
- } else if (AlmostBequalUlps(b.fX, c.fX)) {
- b.fX = c.fX;
- }
- if (AlmostBequalUlps(b.fY, a.fY)) {
- b.fY = a.fY;
- } else if (AlmostBequalUlps(b.fY, c.fY)) {
- b.fY = c.fY;
- }
- return b;
-}
-
-/* classic one t subdivision */
-static void interp_quad_coords(const double* src, double* dst, double t) {
- double ab = SkDInterp(src[0], src[2], t);
- double bc = SkDInterp(src[2], src[4], t);
- dst[0] = src[0];
- dst[2] = ab;
- dst[4] = SkDInterp(ab, bc, t);
- dst[6] = bc;
- dst[8] = src[4];
-}
-
-SkDQuadPair SkDQuad::chopAt(double t) const
-{
- SkDQuadPair dst;
- interp_quad_coords(&fPts[0].fX, &dst.pts[0].fX, t);
- interp_quad_coords(&fPts[0].fY, &dst.pts[0].fY, t);
- return dst;
-}
-
-static int valid_unit_divide(double numer, double denom, double* ratio)
-{
- if (numer < 0) {
- numer = -numer;
- denom = -denom;
- }
- if (denom == 0 || numer == 0 || numer >= denom) {
- return 0;
- }
- double r = numer / denom;
- if (r == 0) { // catch underflow if numer <<<< denom
- return 0;
- }
- *ratio = r;
- return 1;
-}
-
-/** Quad'(t) = At + B, where
- A = 2(a - 2b + c)
- B = 2(b - a)
- Solve for t, only if it fits between 0 < t < 1
-*/
-int SkDQuad::FindExtrema(const double src[], double tValue[1]) {
- /* At + B == 0
- t = -B / A
- */
- double a = src[0];
- double b = src[2];
- double c = src[4];
- return valid_unit_divide(a - b, a - b - b + c, tValue);
-}
-
-/* Parameterization form, given A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
- *
- * a = A - 2*B + C
- * b = 2*B - 2*C
- * c = C
- */
-void SkDQuad::SetABC(const double* quad, double* a, double* b, double* c) {
- *a = quad[0]; // a = A
- *b = 2 * quad[2]; // b = 2*B
- *c = quad[4]; // c = C
- *b -= *c; // b = 2*B - C
- *a -= *b; // a = A - 2*B + C
- *b -= *c; // b = 2*B - 2*C
-}
-
-int SkTQuad::intersectRay(SkIntersections* i, const SkDLine& line) const {
- return i->intersectRay(fQuad, line);
-}
-
-bool SkTQuad::hullIntersects(const SkDConic& conic, bool* isLinear) const {
- return conic.hullIntersects(fQuad, isLinear);
-}
-
-bool SkTQuad::hullIntersects(const SkDCubic& cubic, bool* isLinear) const {
- return cubic.hullIntersects(fQuad, isLinear);
-}
-
-void SkTQuad::setBounds(SkDRect* rect) const {
- rect->setBounds(fQuad);
-}
diff --recursive --unified skia/src/pathops/SkPathOpsQuad.h tiny-skia/skia/src/pathops/SkPathOpsQuad.h
@@ -9,9 +9,10 @@
#define SkPathOpsQuad_DEFINED
#include "src/core/SkArenaAlloc.h"
-#include "src/pathops/SkPathOpsTCurve.h"
+#include "src/pathops/SkPathOpsPoint.h"
struct SkOpCurve;
+struct SkDQuad;
struct SkDQuadPair {
const SkDQuad& first() const { return (const SkDQuad&) pts[0]; }
@@ -26,36 +27,12 @@
SkDPoint fPts[kPointCount];
- bool collapsed() const {
- return fPts[0].approximatelyEqual(fPts[1]) && fPts[0].approximatelyEqual(fPts[2]);
- }
-
- bool controlsInside() const {
- SkDVector v01 = fPts[0] - fPts[1];
- SkDVector v02 = fPts[0] - fPts[2];
- SkDVector v12 = fPts[1] - fPts[2];
- return v02.dot(v01) > 0 && v02.dot(v12) > 0;
- }
-
- void debugInit() {
- sk_bzero(fPts, sizeof(fPts));
- }
-
- void debugSet(const SkDPoint* pts);
-
- SkDQuad flip() const {
- SkDQuad result = {{fPts[2], fPts[1], fPts[0]} SkDEBUGPARAMS(fDebugGlobalState) };
- return result;
- }
-
static bool IsConic() { return false; }
- const SkDQuad& set(const SkPoint pts[kPointCount]
- SkDEBUGPARAMS(SkOpGlobalState* state = nullptr)) {
+ const SkDQuad& set(const SkPoint pts[kPointCount]) {
fPts[0] = pts[0];
fPts[1] = pts[1];
fPts[2] = pts[2];
- SkDEBUGCODE(fDebugGlobalState = state);
return *this;
}
@@ -63,14 +40,6 @@
SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fPts[n]; }
static int AddValidTs(double s[], int realRoots, double* t);
- void align(int endIndex, SkDPoint* dstPt) const;
- SkDQuadPair chopAt(double t) const;
- SkDVector dxdyAtT(double t) const;
- static int FindExtrema(const double src[], double tValue[1]);
-
-#ifdef SK_DEBUG
- SkOpGlobalState* globalState() const { return fDebugGlobalState; }
-#endif
/**
* Return the number of valid roots (0 < root < 1) for this cubic intersecting the
@@ -78,107 +47,17 @@
*/
int horizontalIntersect(double yIntercept, double roots[2]) const;
- bool hullIntersects(const SkDQuad& , bool* isLinear) const;
- bool hullIntersects(const SkDConic& , bool* isLinear) const;
- bool hullIntersects(const SkDCubic& , bool* isLinear) const;
- bool isLinear(int startIndex, int endIndex) const;
static int maxIntersections() { return kMaxIntersections; }
- bool monotonicInX() const;
- bool monotonicInY() const;
- void otherPts(int oddMan, const SkDPoint* endPt[2]) const;
static int pointCount() { return kPointCount; }
static int pointLast() { return kPointLast; }
- SkDPoint ptAtT(double t) const;
static int RootsReal(double A, double B, double C, double t[2]);
static int RootsValidT(const double A, const double B, const double C, double s[2]);
- static void SetABC(const double* quad, double* a, double* b, double* c);
- SkDQuad subDivide(double t1, double t2) const;
- void subDivide(double t1, double t2, SkDQuad* quad) const { *quad = this->subDivide(t1, t2); }
-
- static SkDQuad SubDivide(const SkPoint a[kPointCount], double t1, double t2) {
- SkDQuad quad;
- quad.set(a);
- return quad.subDivide(t1, t2);
- }
- SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t2) const;
- static SkDPoint SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a, const SkDPoint& c,
- double t1, double t2) {
- SkDQuad quad;
- quad.set(pts);
- return quad.subDivide(a, c, t1, t2);
- }
/**
* Return the number of valid roots (0 < root < 1) for this cubic intersecting the
* specified vertical line.
*/
int verticalIntersect(double xIntercept, double roots[2]) const;
-
- SkDCubic debugToCubic() const;
- // utilities callable by the user from the debugger when the implementation code is linked in
- void dump() const;
- void dumpID(int id) const;
- void dumpInner() const;
-
- SkDEBUGCODE(SkOpGlobalState* fDebugGlobalState);
-};
-
-
-class SkTQuad : public SkTCurve {
-public:
- SkDQuad fQuad;
-
- SkTQuad() {}
-
- SkTQuad(const SkDQuad& q)
- : fQuad(q) {
- }
-
- ~SkTQuad() override {}
-
- const SkDPoint& operator[](int n) const override { return fQuad[n]; }
- SkDPoint& operator[](int n) override { return fQuad[n]; }
-
- bool collapsed() const override { return fQuad.collapsed(); }
- bool controlsInside() const override { return fQuad.controlsInside(); }
- void debugInit() override { return fQuad.debugInit(); }
-#if DEBUG_T_SECT
- void dumpID(int id) const override { return fQuad.dumpID(id); }
-#endif
- SkDVector dxdyAtT(double t) const override { return fQuad.dxdyAtT(t); }
-#ifdef SK_DEBUG
- SkOpGlobalState* globalState() const override { return fQuad.globalState(); }
-#endif
-
- bool hullIntersects(const SkDQuad& quad, bool* isLinear) const override {
- return quad.hullIntersects(fQuad, isLinear);
- }
-
- bool hullIntersects(const SkDConic& conic, bool* isLinear) const override;
- bool hullIntersects(const SkDCubic& cubic, bool* isLinear) const override;
-
- bool hullIntersects(const SkTCurve& curve, bool* isLinear) const override {
- return curve.hullIntersects(fQuad, isLinear);
- }
-
- int intersectRay(SkIntersections* i, const SkDLine& line) const override;
- bool IsConic() const override { return false; }
- SkTCurve* make(SkArenaAlloc& heap) const override { return heap.make<SkTQuad>(); }
-
- int maxIntersections() const override { return SkDQuad::kMaxIntersections; }
-
- void otherPts(int oddMan, const SkDPoint* endPt[2]) const override {
- fQuad.otherPts(oddMan, endPt);
- }
-
- int pointCount() const override { return SkDQuad::kPointCount; }
- int pointLast() const override { return SkDQuad::kPointLast; }
- SkDPoint ptAtT(double t) const override { return fQuad.ptAtT(t); }
- void setBounds(SkDRect* ) const override;
-
- void subDivide(double t1, double t2, SkTCurve* curve) const override {
- ((SkTQuad*) curve)->fQuad = fQuad.subDivide(t1, t2);
- }
};
#endif
Only in skia/src/pathops: SkPathOpsRect.cpp
Only in skia/src/pathops: SkPathOpsRect.h
Only in skia/src/pathops: SkPathOpsSimplify.cpp
Only in skia/src/pathops: SkPathOpsTCurve.h
Only in skia/src/pathops: SkPathOpsTightBounds.cpp
Only in skia/src/pathops: SkPathOpsTSect.cpp
Only in skia/src/pathops: SkPathOpsTSect.h
diff --recursive --unified skia/src/pathops/SkPathOpsTypes.cpp tiny-skia/skia/src/pathops/SkPathOpsTypes.cpp
@@ -6,7 +6,6 @@
*/
#include "include/private/SkFloatBits.h"
#include "src/core/SkArenaAlloc.h"
-#include "src/pathops/SkOpCoincidence.h"
#include "src/pathops/SkPathOpsTypes.h"
static bool arguments_denormalized(float a, float b, int epsilon) {
@@ -227,29 +226,3 @@
}
return result;
}
-
-SkOpGlobalState::SkOpGlobalState(SkOpContourHead* head,
- SkArenaAlloc* allocator
- SkDEBUGPARAMS(bool debugSkipAssert)
- SkDEBUGPARAMS(const char* testName))
- : fAllocator(allocator)
- , fCoincidence(nullptr)
- , fContourHead(head)
- , fNested(0)
- , fWindingFailed(false)
- , fPhase(SkOpPhase::kIntersecting)
- SkDEBUGPARAMS(fDebugTestName(testName))
- SkDEBUGPARAMS(fAngleID(0))
- SkDEBUGPARAMS(fCoinID(0))
- SkDEBUGPARAMS(fContourID(0))
- SkDEBUGPARAMS(fPtTID(0))
- SkDEBUGPARAMS(fSegmentID(0))
- SkDEBUGPARAMS(fSpanID(0))
- SkDEBUGPARAMS(fDebugSkipAssert(debugSkipAssert)) {
-#if DEBUG_T_SECT_LOOP_COUNT
- debugResetLoopCounts();
-#endif
-#if DEBUG_COIN
- fPreviousFuncName = nullptr;
-#endif
-}
diff --recursive --unified skia/src/pathops/SkPathOpsTypes.h tiny-skia/skia/src/pathops/SkPathOpsTypes.h
@@ -14,7 +14,6 @@
#include "include/pathops/SkPathOps.h"
#include "include/private/SkFloatingPoint.h"
#include "include/private/SkSafe_math.h"
-#include "src/pathops/SkPathOpsDebug.h"
enum SkPathOpsMask {
kWinding_PathOpsMask = -1,
@@ -26,7 +25,6 @@
class SkOpCoincidence;
class SkOpContour;
class SkOpContourHead;
-class SkIntersections;
class SkIntersectionHelper;
enum class SkOpPhase : char {
@@ -36,186 +34,6 @@
kFixWinding,
};
-class SkOpGlobalState {
-public:
- SkOpGlobalState(SkOpContourHead* head,
- SkArenaAlloc* allocator SkDEBUGPARAMS(bool debugSkipAssert)
- SkDEBUGPARAMS(const char* testName));
-
- enum {
- kMaxWindingTries = 10
- };
-
- bool allocatedOpSpan() const {
- return fAllocatedOpSpan;
- }
-
- SkArenaAlloc* allocator() {
- return fAllocator;
- }
-
- void bumpNested() {
- ++fNested;
- }
-
- void clearNested() {
- fNested = 0;
- }
-
- SkOpCoincidence* coincidence() {
- return fCoincidence;
- }
-
- SkOpContourHead* contourHead() {
- return fContourHead;
- }
-
-#ifdef SK_DEBUG
- const class SkOpAngle* debugAngle(int id) const;
- const SkOpCoincidence* debugCoincidence() const;
- SkOpContour* debugContour(int id) const;
- const class SkOpPtT* debugPtT(int id) const;
-#endif
-
- static bool DebugRunFail();
-
-#ifdef SK_DEBUG
- const class SkOpSegment* debugSegment(int id) const;
- bool debugSkipAssert() const { return fDebugSkipAssert; }
- const class SkOpSpanBase* debugSpan(int id) const;
- const char* debugTestName() const { return fDebugTestName; }
-#endif
-
-#if DEBUG_T_SECT_LOOP_COUNT
- void debugAddLoopCount(SkIntersections* , const SkIntersectionHelper& ,
- const SkIntersectionHelper& );
- void debugDoYourWorst(SkOpGlobalState* );
- void debugLoopReport();
- void debugResetLoopCounts();
-#endif
-
-#if DEBUG_COINCIDENCE
- void debugSetCheckHealth(bool check) { fDebugCheckHealth = check; }
- bool debugCheckHealth() const { return fDebugCheckHealth; }
-#endif
-
-#if DEBUG_VALIDATE || DEBUG_COIN
- void debugSetPhase(const char* funcName DEBUG_COIN_DECLARE_PARAMS()) const;
-#endif
-
-#if DEBUG_COIN
- void debugAddToCoinChangedDict();
- void debugAddToGlobalCoinDicts();
- SkPathOpsDebug::CoinDict* debugCoinChangedDict() { return &fCoinChangedDict; }
- const SkPathOpsDebug::CoinDictEntry& debugCoinDictEntry() const { return fCoinDictEntry; }
-
- static void DumpCoinDict();
-#endif
-
-
- int nested() const {
- return fNested;
- }
-
-#ifdef SK_DEBUG
- int nextAngleID() {
- return ++fAngleID;
- }
-
- int nextCoinID() {
- return ++fCoinID;
- }
-
- int nextContourID() {
- return ++fContourID;
- }
-
- int nextPtTID() {
- return ++fPtTID;
- }
-
- int nextSegmentID() {
- return ++fSegmentID;
- }
-
- int nextSpanID() {
- return ++fSpanID;
- }
-#endif
-
- SkOpPhase phase() const {
- return fPhase;
- }
-
- void resetAllocatedOpSpan() {
- fAllocatedOpSpan = false;
- }
-
- void setAllocatedOpSpan() {
- fAllocatedOpSpan = true;
- }
-
- void setCoincidence(SkOpCoincidence* coincidence) {
- fCoincidence = coincidence;
- }
-
- void setContourHead(SkOpContourHead* contourHead) {
- fContourHead = contourHead;
- }
-
- void setPhase(SkOpPhase phase) {
- if (SkOpPhase::kNoChange == phase) {
- return;
- }
- SkASSERT(fPhase != phase);
- fPhase = phase;
- }
-
- // called in very rare cases where angles are sorted incorrectly -- signfies op will fail
- void setWindingFailed() {
- fWindingFailed = true;
- }
-
- bool windingFailed() const {
- return fWindingFailed;
- }
-
-private:
- SkArenaAlloc* fAllocator;
- SkOpCoincidence* fCoincidence;
- SkOpContourHead* fContourHead;
- int fNested;
- bool fAllocatedOpSpan;
- bool fWindingFailed;
- SkOpPhase fPhase;
-#ifdef SK_DEBUG
- const char* fDebugTestName;
- void* fDebugReporter;
- int fAngleID;
- int fCoinID;
- int fContourID;
- int fPtTID;
- int fSegmentID;
- int fSpanID;
- bool fDebugSkipAssert;
-#endif
-#if DEBUG_T_SECT_LOOP_COUNT
- int fDebugLoopCount[3];
- SkPath::Verb fDebugWorstVerb[6];
- SkPoint fDebugWorstPts[24];
- float fDebugWorstWeight[6];
-#endif
-#if DEBUG_COIN
- SkPathOpsDebug::CoinDict fCoinChangedDict;
- SkPathOpsDebug::CoinDict fCoinVisitedDict;
- SkPathOpsDebug::CoinDictEntry fCoinDictEntry;
- const char* fPreviousFuncName;
-#endif
-#if DEBUG_COINCIDENCE
- bool fDebugCheckHealth;
-#endif
-};
-
#ifdef SK_DEBUG
#if DEBUG_COINCIDENCE
#define SkOPASSERT(cond) SkASSERT((this->globalState() && \
@@ -559,9 +377,6 @@
struct SkDPoint;
struct SkDVector;
-struct SkDLine;
-struct SkDQuad;
-struct SkDConic;
struct SkDCubic;
struct SkDRect;
@@ -599,26 +414,4 @@
double SkDCubeRoot(double x);
-/* Returns -1 if negative, 0 if zero, 1 if positive
-*/
-inline int SkDSign(double x) {
- return (x > 0) - (x < 0);
-}
-
-/* Returns 0 if negative, 1 if zero, 2 if positive
-*/
-inline int SKDSide(double x) {
- return (x > 0) + (x >= 0);
-}
-
-/* Returns 1 if negative, 2 if zero, 4 if positive
-*/
-inline int SkDSideBit(double x) {
- return 1 << SKDSide(x);
-}
-
-inline double SkPinT(double t) {
- return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 : t;
-}
-
#endif
Only in skia/src/pathops: SkPathOpsWinding.cpp
Only in skia/src/pathops: SkPathWriter.cpp
Only in skia/src/pathops: SkPathWriter.h
Only in skia/src/pathops: SkReduceOrder.cpp
Only in skia/src/pathops: SkReduceOrder.h
Only in skia/src: pdf
Only in skia/src/ports: .directory
Only in skia/src/ports: SkDebug_android.cpp
Only in skia/src/ports: SkDiscardableMemory_none.cpp
Only in skia/src/ports: SkFontConfigInterface.cpp
Only in skia/src/ports: SkFontConfigInterface_direct.cpp
Only in skia/src/ports: SkFontConfigInterface_direct_factory.cpp
Only in skia/src/ports: SkFontConfigInterface_direct.h
Only in skia/src/ports: SkFontConfigTypeface.h
Only in skia/src/ports: SkFontHost_FreeType_common.cpp
Only in skia/src/ports: SkFontHost_FreeType_common.h
Only in skia/src/ports: SkFontHost_FreeType.cpp
Only in skia/src/ports: SkFontHost_win.cpp
Only in skia/src/ports: SkFontMgr_android.cpp
Only in skia/src/ports: SkFontMgr_android_factory.cpp
Only in skia/src/ports: SkFontMgr_android_parser.cpp
Only in skia/src/ports: SkFontMgr_android_parser.h
Only in skia/src/ports: SkFontMgr_custom.cpp
Only in skia/src/ports: SkFontMgr_custom_directory.cpp
Only in skia/src/ports: SkFontMgr_custom_directory_factory.cpp
Only in skia/src/ports: SkFontMgr_custom_embedded.cpp
Only in skia/src/ports: SkFontMgr_custom_embedded_factory.cpp
Only in skia/src/ports: SkFontMgr_custom_empty.cpp
Only in skia/src/ports: SkFontMgr_custom_empty_factory.cpp
Only in skia/src/ports: SkFontMgr_custom.h
Only in skia/src/ports: SkFontMgr_empty_factory.cpp
Only in skia/src/ports: SkFontMgr_fontconfig.cpp
Only in skia/src/ports: SkFontMgr_fontconfig_factory.cpp
Only in skia/src/ports: SkFontMgr_FontConfigInterface.cpp
Only in skia/src/ports: SkFontMgr_FontConfigInterface_factory.cpp
Only in skia/src/ports: SkFontMgr_fuchsia.cpp
Only in skia/src/ports: SkFontMgr_mac_ct.cpp
Only in skia/src/ports: SkFontMgr_mac_ct_factory.cpp
Only in skia/src/ports: SkFontMgr_win_dw.cpp
Only in skia/src/ports: SkFontMgr_win_dw_factory.cpp
Only in skia/src/ports: SkGlobalInitialization_default.cpp
Only in skia/src/ports: SkImageEncoder_CG.cpp
Only in skia/src/ports: SkImageEncoder_WIC.cpp
Only in skia/src/ports: SkImageGeneratorCG.cpp
Only in skia/src/ports: SkImageGenerator_none.cpp
Only in skia/src/ports: SkImageGenerator_skia.cpp
Only in skia/src/ports: SkImageGeneratorWIC.cpp
Only in skia/src/ports: SkMemory_mozalloc.cpp
Only in skia/src/ports: SkOSFile_ios.h
Only in skia/src/ports: SkOSFile_posix.cpp
Only in skia/src/ports: SkOSFile_stdio.cpp
Only in skia/src/ports: SkOSFile_win.cpp
Only in skia/src/ports: SkOSLibrary.h
Only in skia/src/ports: SkOSLibrary_posix.cpp
Only in skia/src/ports: SkOSLibrary_win.cpp
Only in skia/src/ports: SkRemotableFontMgr_win_dw.cpp
Only in skia/src/ports: SkScalerContext_mac_ct.cpp
Only in skia/src/ports: SkScalerContext_mac_ct.h
Only in skia/src/ports: SkScalerContext_win_dw.cpp
Only in skia/src/ports: SkScalerContext_win_dw.h
Only in skia/src/ports: SkTLS_pthread.cpp
Only in skia/src/ports: SkTLS_win.cpp
Only in skia/src/ports: SkTypeface_mac_ct.cpp
Only in skia/src/ports: SkTypeface_mac_ct.h
Only in skia/src/ports: SkTypeface_win_dw.cpp
Only in skia/src/ports: SkTypeface_win_dw.h
Only in skia/src: sfnt
diff --recursive --unified skia/src/shaders/gradients/SkGradientShader.cpp tiny-skia/skia/src/shaders/gradients/SkGradientShader.cpp
@@ -13,9 +13,7 @@
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMatrixProvider.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/gradients/Sk4fLinearGradient.h"
#include "src/shaders/gradients/SkGradientShaderPriv.h"
#include "src/shaders/gradients/SkLinearGradient.h"
@@ -23,105 +21,6 @@
#include "src/shaders/gradients/SkSweepGradient.h"
#include "src/shaders/gradients/SkTwoPointConicalGradient.h"
-enum GradientSerializationFlags {
- // Bits 29:31 used for various boolean flags
- kHasPosition_GSF = 0x80000000,
- kHasLocalMatrix_GSF = 0x40000000,
- kHasColorSpace_GSF = 0x20000000,
-
- // Bits 12:28 unused
-
- // Bits 8:11 for fTileMode
- kTileModeShift_GSF = 8,
- kTileModeMask_GSF = 0xF,
-
- // Bits 0:7 for fGradFlags (note that kForce4fContext_PrivateFlag is 0x80)
- kGradFlagsShift_GSF = 0,
- kGradFlagsMask_GSF = 0xFF,
-};
-
-void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const {
- uint32_t flags = 0;
- if (fPos) {
- flags |= kHasPosition_GSF;
- }
- if (fLocalMatrix) {
- flags |= kHasLocalMatrix_GSF;
- }
- sk_sp<SkData> colorSpaceData = fColorSpace ? fColorSpace->serialize() : nullptr;
- if (colorSpaceData) {
- flags |= kHasColorSpace_GSF;
- }
- SkASSERT(static_cast<uint32_t>(fTileMode) <= kTileModeMask_GSF);
- flags |= ((unsigned)fTileMode << kTileModeShift_GSF);
- SkASSERT(fGradFlags <= kGradFlagsMask_GSF);
- flags |= (fGradFlags << kGradFlagsShift_GSF);
-
- buffer.writeUInt(flags);
-
- buffer.writeColor4fArray(fColors, fCount);
- if (colorSpaceData) {
- buffer.writeDataAsByteArray(colorSpaceData.get());
- }
- if (fPos) {
- buffer.writeScalarArray(fPos, fCount);
- }
- if (fLocalMatrix) {
- buffer.writeMatrix(*fLocalMatrix);
- }
-}
-
-template <int N, typename T, bool MEM_MOVE>
-static bool validate_array(SkReadBuffer& buffer, size_t count, SkSTArray<N, T, MEM_MOVE>* array) {
- if (!buffer.validateCanReadN<T>(count)) {
- return false;
- }
-
- array->resize_back(count);
- return true;
-}
-
-bool SkGradientShaderBase::DescriptorScope::unflatten(SkReadBuffer& buffer) {
- // New gradient format. Includes floating point color, color space, densely packed flags
- uint32_t flags = buffer.readUInt();
-
- fTileMode = (SkTileMode)((flags >> kTileModeShift_GSF) & kTileModeMask_GSF);
- fGradFlags = (flags >> kGradFlagsShift_GSF) & kGradFlagsMask_GSF;
-
- fCount = buffer.getArrayCount();
-
- if (!(validate_array(buffer, fCount, &fColorStorage) &&
- buffer.readColor4fArray(fColorStorage.begin(), fCount))) {
- return false;
- }
- fColors = fColorStorage.begin();
-
- if (SkToBool(flags & kHasColorSpace_GSF)) {
- sk_sp<SkData> data = buffer.readByteArrayAsData();
- fColorSpace = data ? SkColorSpace::Deserialize(data->data(), data->size()) : nullptr;
- } else {
- fColorSpace = nullptr;
- }
- if (SkToBool(flags & kHasPosition_GSF)) {
- if (!(validate_array(buffer, fCount, &fPosStorage) &&
- buffer.readScalarArray(fPosStorage.begin(), fCount))) {
- return false;
- }
- fPos = fPosStorage.begin();
- } else {
- fPos = nullptr;
- }
- if (SkToBool(flags & kHasLocalMatrix_GSF)) {
- fLocalMatrix = &fLocalMatrixStorage;
- buffer.readMatrix(&fLocalMatrixStorage);
- } else {
- fLocalMatrix = nullptr;
- }
- return buffer.isValid();
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////
-
SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatrix& ptsToUnit)
: INHERITED(desc.fLocalMatrix)
, fPtsToUnit(ptsToUnit)
@@ -203,20 +102,6 @@
SkGradientShaderBase::~SkGradientShaderBase() {}
-void SkGradientShaderBase::flatten(SkWriteBuffer& buffer) const {
- Descriptor desc;
- desc.fColors = fOrigColors4f;
- desc.fColorSpace = fColorSpace;
- desc.fPos = fOrigPos;
- desc.fCount = fColorCount;
- desc.fTileMode = fTileMode;
- desc.fGradFlags = fGradFlags;
-
- const SkMatrix& m = this->getLocalMatrix();
- desc.fLocalMatrix = m.isIdentity() ? nullptr : &m;
- desc.flatten(buffer);
-}
-
static void add_stop_color(SkRasterPipeline_GradientCtx* ctx, size_t stop, SkPMColor4f Fs, SkPMColor4f Bs) {
(ctx->fs[0])[stop] = Fs.fR;
(ctx->fs[1])[stop] = Fs.fG;
@@ -1062,10 +947,3 @@
return sk_make_sp<SkSweepGradient>(SkPoint::Make(cx, cy), t0, t1, desc);
}
-
-void SkGradientShader::RegisterFlattenables() {
- SK_REGISTER_FLATTENABLE(SkLinearGradient);
- SK_REGISTER_FLATTENABLE(SkRadialGradient);
- SK_REGISTER_FLATTENABLE(SkSweepGradient);
- SK_REGISTER_FLATTENABLE(SkTwoPointConicalGradient);
-}
diff --recursive --unified skia/src/shaders/gradients/SkGradientShaderPriv.h tiny-skia/skia/src/shaders/gradients/SkGradientShaderPriv.h
@@ -71,7 +71,6 @@
class GradientShaderBase4fContext;
SkGradientShaderBase(SkReadBuffer& );
- void flatten(SkWriteBuffer&) const override;
void commonAsAGradient(GradientInfo*) const;
diff --recursive --unified skia/src/shaders/gradients/SkLinearGradient.cpp tiny-skia/skia/src/shaders/gradients/SkLinearGradient.cpp
@@ -7,8 +7,6 @@
#include "src/shaders/gradients/SkLinearGradient.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/gradients/Sk4fLinearGradient.h"
static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) {
@@ -32,44 +30,6 @@
, fEnd(pts[1]) {
}
-sk_sp<SkFlattenable> SkLinearGradient::CreateProc(SkReadBuffer& buffer) {
- DescriptorScope desc;
- if (!desc.unflatten(buffer)) {
- return nullptr;
- }
- SkPoint pts[2];
- pts[0] = buffer.readPoint();
- pts[1] = buffer.readPoint();
- return SkGradientShader::MakeLinear(pts, desc.fColors, std::move(desc.fColorSpace), desc.fPos,
- desc.fCount, desc.fTileMode, desc.fGradFlags,
- desc.fLocalMatrix);
-}
-
-void SkLinearGradient::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writePoint(fStart);
- buffer.writePoint(fEnd);
-}
-
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
-SkShaderBase::Context* SkLinearGradient::onMakeContext(
- const ContextRec& rec, SkArenaAlloc* alloc) const
-{
- // make sure our colorspaces are compatible with legacy blits
- if (!rec.isLegacyCompatible(fColorSpace.get())) {
- return nullptr;
- }
- // Can't use legacy blit if we can't represent our colors as SkColors
- if (!this->colorsCanConvertToSkColor()) {
- return nullptr;
- }
-
- return fTileMode != SkTileMode::kDecal
- ? CheckedMakeContext<LinearGradient4fContext>(alloc, *this, rec)
- : nullptr;
-}
-#endif
-
void SkLinearGradient::appendGradientStages(SkArenaAlloc*, SkRasterPipeline*,
SkRasterPipeline*) const {
// No extra stage needed for linear gradients.
@@ -89,16 +49,3 @@
}
return kLinear_GradientType;
}
-
-/////////////////////////////////////////////////////////////////////
-
-#if SK_SUPPORT_GPU
-
-#include "src/gpu/gradients/GrGradientShader.h"
-
-std::unique_ptr<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
- const GrFPArgs& args) const {
- return GrGradientShader::MakeLinear(*this, args);
-}
-
-#endif
diff --recursive --unified skia/src/shaders/gradients/SkLinearGradient.h tiny-skia/skia/src/shaders/gradients/SkLinearGradient.h
@@ -15,16 +15,9 @@
SkLinearGradient(const SkPoint pts[2], const Descriptor&);
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
protected:
SkLinearGradient(SkReadBuffer& buffer);
- void flatten(SkWriteBuffer& buffer) const override;
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
-#endif
void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline,
SkRasterPipeline* postPipeline) const final;
@@ -33,8 +26,6 @@
skvm::Coord coord, skvm::I32* mask) const final;
private:
- SK_FLATTENABLE_HOOKS(SkLinearGradient)
-
class LinearGradient4fContext;
friend class SkGradientShader;
diff --recursive --unified skia/src/shaders/gradients/SkRadialGradient.cpp tiny-skia/skia/src/shaders/gradients/SkRadialGradient.cpp
@@ -6,8 +6,6 @@
*/
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/gradients/SkRadialGradient.h"
namespace {
@@ -40,24 +38,6 @@
return kRadial_GradientType;
}
-sk_sp<SkFlattenable> SkRadialGradient::CreateProc(SkReadBuffer& buffer) {
- DescriptorScope desc;
- if (!desc.unflatten(buffer)) {
- return nullptr;
- }
- const SkPoint center = buffer.readPoint();
- const SkScalar radius = buffer.readScalar();
- return SkGradientShader::MakeRadial(center, radius, desc.fColors, std::move(desc.fColorSpace),
- desc.fPos, desc.fCount, desc.fTileMode, desc.fGradFlags,
- desc.fLocalMatrix);
-}
-
-void SkRadialGradient::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writePoint(fCenter);
- buffer.writeScalar(fRadius);
-}
-
void SkRadialGradient::appendGradientStages(SkArenaAlloc*, SkRasterPipeline* p,
SkRasterPipeline*) const {
p->append(SkRasterPipeline::xy_to_radius);
@@ -67,16 +47,3 @@
skvm::Coord coord, skvm::I32* mask) const {
return sqrt(coord.x*coord.x + coord.y*coord.y);
}
-
-/////////////////////////////////////////////////////////////////////
-
-#if SK_SUPPORT_GPU
-
-#include "src/gpu/gradients/GrGradientShader.h"
-
-std::unique_ptr<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
- const GrFPArgs& args) const {
- return GrGradientShader::MakeRadial(*this, args);
-}
-
-#endif
diff --recursive --unified skia/src/shaders/gradients/SkRadialGradient.h tiny-skia/skia/src/shaders/gradients/SkRadialGradient.h
@@ -15,13 +15,9 @@
SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor&);
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
protected:
SkRadialGradient(SkReadBuffer& buffer);
- void flatten(SkWriteBuffer& buffer) const override;
void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline,
SkRasterPipeline* postPipeline) const override;
@@ -30,8 +26,6 @@
skvm::Coord coord, skvm::I32* mask) const final;
private:
- SK_FLATTENABLE_HOOKS(SkRadialGradient)
-
const SkPoint fCenter;
const SkScalar fRadius;
diff --recursive --unified skia/src/shaders/gradients/SkSweepGradient.cpp tiny-skia/skia/src/shaders/gradients/SkSweepGradient.cpp
@@ -7,8 +7,6 @@
#include "include/private/SkFloatingPoint.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/gradients/SkSweepGradient.h"
SkSweepGradient::SkSweepGradient(const SkPoint& center, SkScalar t0, SkScalar t1,
@@ -29,38 +27,6 @@
return kSweep_GradientType;
}
-static std::tuple<SkScalar, SkScalar> angles_from_t_coeff(SkScalar tBias, SkScalar tScale) {
- return std::make_tuple(-tBias * 360, (sk_ieee_float_divide(1, tScale) - tBias) * 360);
-}
-
-sk_sp<SkFlattenable> SkSweepGradient::CreateProc(SkReadBuffer& buffer) {
- DescriptorScope desc;
- if (!desc.unflatten(buffer)) {
- return nullptr;
- }
- const SkPoint center = buffer.readPoint();
-
- SkScalar startAngle = 0,
- endAngle = 360;
- if (!buffer.isVersionLT(SkPicturePriv::kTileInfoInSweepGradient_Version)) {
- const auto tBias = buffer.readScalar(),
- tScale = buffer.readScalar();
- std::tie(startAngle, endAngle) = angles_from_t_coeff(tBias, tScale);
- }
-
- return SkGradientShader::MakeSweep(center.x(), center.y(), desc.fColors,
- std::move(desc.fColorSpace), desc.fPos, desc.fCount,
- desc.fTileMode, startAngle, endAngle,
- desc.fGradFlags, desc.fLocalMatrix);
-}
-
-void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writePoint(fCenter);
- buffer.writeScalar(fTBias);
- buffer.writeScalar(fTScale);
-}
-
void SkSweepGradient::appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* p,
SkRasterPipeline*) const {
p->append(SkRasterPipeline::xy_to_unit_angle);
@@ -95,16 +61,3 @@
}
return t;
}
-
-/////////////////////////////////////////////////////////////////////
-
-#if SK_SUPPORT_GPU
-
-#include "src/gpu/gradients/GrGradientShader.h"
-
-std::unique_ptr<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
- const GrFPArgs& args) const {
- return GrGradientShader::MakeSweep(*this, args);
-}
-
-#endif
diff --recursive --unified skia/src/shaders/gradients/SkSweepGradient.h tiny-skia/skia/src/shaders/gradients/SkSweepGradient.h
@@ -16,25 +16,17 @@
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
SkScalar getTBias() const { return fTBias; }
SkScalar getTScale() const { return fTScale; }
protected:
- void flatten(SkWriteBuffer& buffer) const override;
-
void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline,
SkRasterPipeline* postPipeline) const override;
skvm::F32 transformT(skvm::Builder*, skvm::Uniforms*,
skvm::Coord coord, skvm::I32* mask) const final;
private:
- SK_FLATTENABLE_HOOKS(SkSweepGradient)
-
const SkPoint fCenter;
const SkScalar fTBias,
fTScale;
diff --recursive --unified skia/src/shaders/gradients/SkTwoPointConicalGradient.cpp tiny-skia/skia/src/shaders/gradients/SkTwoPointConicalGradient.cpp
@@ -7,8 +7,6 @@
#include "include/private/SkFloatingPoint.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/gradients/SkTwoPointConicalGradient.h"
#include <utility>
@@ -126,57 +124,6 @@
return kConical_GradientType;
}
-sk_sp<SkFlattenable> SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) {
- DescriptorScope desc;
- if (!desc.unflatten(buffer)) {
- return nullptr;
- }
- SkPoint c1 = buffer.readPoint();
- SkPoint c2 = buffer.readPoint();
- SkScalar r1 = buffer.readScalar();
- SkScalar r2 = buffer.readScalar();
-
- if (buffer.isVersionLT(SkPicturePriv::k2PtConicalNoFlip_Version) && buffer.readBool()) {
- using std::swap;
- // legacy flipped gradient
- swap(c1, c2);
- swap(r1, r2);
-
- SkColor4f* colors = desc.mutableColors();
- SkScalar* pos = desc.mutablePos();
- const int last = desc.fCount - 1;
- const int half = desc.fCount >> 1;
- for (int i = 0; i < half; ++i) {
- swap(colors[i], colors[last - i]);
- if (pos) {
- SkScalar tmp = pos[i];
- pos[i] = SK_Scalar1 - pos[last - i];
- pos[last - i] = SK_Scalar1 - tmp;
- }
- }
- if (pos) {
- if (desc.fCount & 1) {
- pos[half] = SK_Scalar1 - pos[half];
- }
- }
- }
- if (!buffer.isValid()) {
- return nullptr;
- }
- return SkGradientShader::MakeTwoPointConical(c1, r1, c2, r2, desc.fColors,
- std::move(desc.fColorSpace), desc.fPos,
- desc.fCount, desc.fTileMode, desc.fGradFlags,
- desc.fLocalMatrix);
-}
-
-void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writePoint(fCenter1);
- buffer.writePoint(fCenter2);
- buffer.writeScalar(fRadius1);
- buffer.writeScalar(fRadius2);
-}
-
void SkTwoPointConicalGradient::appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* p,
SkRasterPipeline* postPipeline) const {
const auto dRadius = fRadius2 - fRadius1;
@@ -283,16 +230,3 @@
if ( fFocalData.isSwapped()) { t = 1.0f - t; }
return t;
}
-
-/////////////////////////////////////////////////////////////////////
-
-#if SK_SUPPORT_GPU
-
-#include "src/gpu/gradients/GrGradientShader.h"
-
-std::unique_ptr<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
- const GrFPArgs& args) const {
- return GrGradientShader::MakeConical(*this, args);
-}
-
-#endif
diff --recursive --unified skia/src/shaders/gradients/SkTwoPointConicalGradient.h tiny-skia/skia/src/shaders/gradients/SkTwoPointConicalGradient.h
@@ -48,9 +48,6 @@
const Descriptor&);
SkShader::GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
bool isOpaque() const override;
SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
@@ -64,8 +61,6 @@
const FocalData& getFocalData() const { return fFocalData; }
protected:
- void flatten(SkWriteBuffer& buffer) const override;
-
void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline,
SkRasterPipeline* postPipeline) const override;
@@ -73,8 +68,6 @@
skvm::Coord coord, skvm::I32* mask) const final;
private:
- SK_FLATTENABLE_HOOKS(SkTwoPointConicalGradient)
-
SkTwoPointConicalGradient(const SkPoint& c0, SkScalar r0,
const SkPoint& c1, SkScalar r1,
const Descriptor&, Type, const SkMatrix&, const FocalData&);
Only in skia/src/shaders: SkBitmapProcShader.cpp
Only in skia/src/shaders: SkBitmapProcShader.h
diff --recursive --unified skia/src/shaders/SkColorFilterShader.cpp tiny-skia/skia/src/shaders/SkColorFilterShader.cpp
@@ -10,15 +10,9 @@
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkColorFilterBase.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/SkColorFilterShader.h"
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrFragmentProcessor.h"
-#endif
-
SkColorFilterShader::SkColorFilterShader(sk_sp<SkShader> shader,
float alpha,
sk_sp<SkColorFilter> filter)
@@ -30,25 +24,10 @@
SkASSERT(fFilter);
}
-sk_sp<SkFlattenable> SkColorFilterShader::CreateProc(SkReadBuffer& buffer) {
- auto shader = buffer.readShader();
- auto filter = buffer.readColorFilter();
- if (!shader || !filter) {
- return nullptr;
- }
- return sk_make_sp<SkColorFilterShader>(shader, 1.0f, filter);
-}
-
bool SkColorFilterShader::isOpaque() const {
return fShader->isOpaque() && fAlpha == 1.0f && as_CFB(fFilter)->isAlphaUnchanged();
}
-void SkColorFilterShader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeFlattenable(fShader.get());
- SkASSERT(fAlpha == 1.0f); // Not exposed in public API SkShader::makeWithColorFilter().
- buffer.writeFlattenable(fFilter.get());
-}
-
bool SkColorFilterShader::onAppendStages(const SkStageRec& rec) const {
if (!as_SB(fShader)->appendStages(rec)) {
return false;
@@ -86,31 +65,6 @@
return fFilter->program(p,c, dst.colorSpace(), uniforms,alloc);
}
-#if SK_SUPPORT_GPU
-/////////////////////////////////////////////////////////////////////
-
-#include "include/gpu/GrContext.h"
-
-std::unique_ptr<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
- const GrFPArgs& args) const {
- auto fp1 = as_SB(fShader)->asFragmentProcessor(args);
- if (!fp1) {
- return nullptr;
- }
-
- // TODO I guess, but it shouldn't come up as used today.
- SkASSERT(fAlpha == 1.0f);
-
- auto fp2 = fFilter->asFragmentProcessor(args.fContext, *args.fDstColorInfo);
- if (!fp2) {
- return fp1;
- }
-
- std::unique_ptr<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
- return GrFragmentProcessor::RunInSeries(fpSeries, 2);
-}
-#endif
-
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkShader> SkShader::makeWithColorFilter(sk_sp<SkColorFilter> filter) const {
diff --recursive --unified skia/src/shaders/SkColorFilterShader.h tiny-skia/skia/src/shaders/SkColorFilterShader.h
@@ -17,13 +17,8 @@
public:
SkColorFilterShader(sk_sp<SkShader> shader, float alpha, sk_sp<SkColorFilter> filter);
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
private:
bool isOpaque() const override;
- void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
@@ -31,8 +26,6 @@
SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
- SK_FLATTENABLE_HOOKS(SkColorFilterShader)
-
sk_sp<SkShader> fShader;
sk_sp<SkColorFilterBase> fFilter;
float fAlpha;
diff --recursive --unified skia/src/shaders/SkColorShader.cpp tiny-skia/skia/src/shaders/SkColorShader.cpp
@@ -6,11 +6,11 @@
*/
#include "include/core/SkColorSpace.h"
+#include "include/core/SkRefCnt.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkColorSpaceXformSteps.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkUtils.h"
#include "src/core/SkVM.h"
#include "src/shaders/SkColorShader.h"
@@ -21,14 +21,6 @@
return SkColorGetA(fColor) == 255;
}
-sk_sp<SkFlattenable> SkColorShader::CreateProc(SkReadBuffer& buffer) {
- return sk_make_sp<SkColorShader>(buffer.readColor());
-}
-
-void SkColorShader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeColor(fColor);
-}
-
SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
if (info) {
if (info->fColors && info->fColorCount >= 1) {
@@ -45,29 +37,6 @@
, fColor(color)
{}
-sk_sp<SkFlattenable> SkColor4Shader::CreateProc(SkReadBuffer& buffer) {
- SkColor4f color;
- sk_sp<SkColorSpace> colorSpace;
- buffer.readColor4f(&color);
- if (buffer.readBool()) {
- sk_sp<SkData> data = buffer.readByteArrayAsData();
- colorSpace = data ? SkColorSpace::Deserialize(data->data(), data->size()) : nullptr;
- }
- return SkShaders::Color(color, std::move(colorSpace));
-}
-
-void SkColor4Shader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeColor4f(fColor);
- sk_sp<SkData> colorSpaceData = fColorSpace ? fColorSpace->serialize() : nullptr;
- if (colorSpaceData) {
- buffer.writeBool(true);
- buffer.writeDataAsByteArray(colorSpaceData.get());
- } else {
- buffer.writeBool(false);
- }
-}
-
-
sk_sp<SkShader> SkShaders::Color(const SkColor4f& color, sk_sp<SkColorSpace> space) {
if (!SkScalarsAreFinite(color.vec(), 4)) {
return nullptr;
@@ -109,29 +78,3 @@
return p->uniformPremul(fColor, fColorSpace.get(),
uniforms, dst.colorSpace());
}
-
-#if SK_SUPPORT_GPU
-
-#include "src/gpu/GrColorInfo.h"
-#include "src/gpu/GrColorSpaceXform.h"
-#include "src/gpu/SkGr.h"
-#include "src/gpu/effects/generated/GrConstColorProcessor.h"
-
-std::unique_ptr<GrFragmentProcessor> SkColorShader::asFragmentProcessor(
- const GrFPArgs& args) const {
- SkPMColor4f color = SkColorToPMColor4f(fColor, *args.fDstColorInfo);
- return GrConstColorProcessor::Make(/*inputFP=*/nullptr, color,
- GrConstColorProcessor::InputMode::kModulateA);
-}
-
-std::unique_ptr<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(
- const GrFPArgs& args) const {
- SkColorSpaceXformSteps steps{ fColorSpace.get(), kUnpremul_SkAlphaType,
- args.fDstColorInfo->colorSpace(), kUnpremul_SkAlphaType };
- SkColor4f color = fColor;
- steps.apply(color.vec());
- return GrConstColorProcessor::Make(/*inputFP=*/nullptr, color.premul(),
- GrConstColorProcessor::InputMode::kModulateA);
-}
-
-#endif
diff --recursive --unified skia/src/shaders/SkColorShader.h tiny-skia/skia/src/shaders/SkColorShader.h
@@ -28,15 +28,7 @@
GradientType asAGradient(GradientInfo* info) const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
private:
- SK_FLATTENABLE_HOOKS(SkColorShader)
-
- void flatten(SkWriteBuffer&) const override;
-
bool onAsLuminanceColor(SkColor* lum) const override {
*lum = fColor;
return true;
@@ -59,14 +51,7 @@
bool isOpaque() const override { return fColor.isOpaque(); }
bool isConstant() const override { return true; }
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
private:
- SK_FLATTENABLE_HOOKS(SkColor4Shader)
-
- void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
diff --recursive --unified skia/src/shaders/SkComposeShader.cpp tiny-skia/skia/src/shaders/SkComposeShader.cpp
@@ -7,13 +7,12 @@
#include "include/core/SkColorFilter.h"
#include "include/core/SkString.h"
+#include "include/core/SkPaint.h"
#include "include/private/SkColorData.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkBlendModePriv.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/SkColorShader.h"
#include "src/shaders/SkComposeShader.h"
@@ -96,24 +95,6 @@
///////////////////////////////////////////////////////////////////////////////
-sk_sp<SkFlattenable> SkShader_Blend::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkShader> dst(buffer.readShader());
- sk_sp<SkShader> src(buffer.readShader());
- unsigned mode = buffer.read32();
-
- // check for valid mode before we cast to the enum type
- if (!buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode)) {
- return nullptr;
- }
- return SkShaders::Blend(static_cast<SkBlendMode>(mode), std::move(dst), std::move(src));
-}
-
-void SkShader_Blend::flatten(SkWriteBuffer& buffer) const {
- buffer.writeFlattenable(fDst.get());
- buffer.writeFlattenable(fSrc.get());
- buffer.write32((int)fMode);
-}
-
bool SkShader_Blend::onAppendStages(const SkStageRec& orig_rec) const {
const LocalMatrixStageRec rec(orig_rec, this->getLocalMatrix());
@@ -142,19 +123,6 @@
}
-sk_sp<SkFlattenable> SkShader_Lerp::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkShader> dst(buffer.readShader());
- sk_sp<SkShader> src(buffer.readShader());
- float t = buffer.readScalar();
- return buffer.isValid() ? SkShaders::Lerp(t, std::move(dst), std::move(src)) : nullptr;
-}
-
-void SkShader_Lerp::flatten(SkWriteBuffer& buffer) const {
- buffer.writeFlattenable(fDst.get());
- buffer.writeFlattenable(fSrc.get());
- buffer.writeScalar(fWeight);
-}
-
bool SkShader_Lerp::onAppendStages(const SkStageRec& orig_rec) const {
const LocalMatrixStageRec rec(orig_rec, this->getLocalMatrix());
@@ -187,38 +155,3 @@
}
return {};
}
-
-#if SK_SUPPORT_GPU
-
-#include "include/private/GrRecordingContext.h"
-#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
-#include "src/gpu/effects/generated/GrComposeLerpEffect.h"
-#include "src/gpu/effects/generated/GrConstColorProcessor.h"
-
-static std::unique_ptr<GrFragmentProcessor> as_fp(const GrFPArgs& args, SkShader* shader) {
- return shader ? as_SB(shader)->asFragmentProcessor(args) : nullptr;
-}
-
-std::unique_ptr<GrFragmentProcessor> SkShader_Blend::asFragmentProcessor(
- const GrFPArgs& orig_args) const {
- const GrFPArgs::WithPreLocalMatrix args(orig_args, this->getLocalMatrix());
- auto fpA = as_fp(args, fDst.get());
- auto fpB = as_fp(args, fSrc.get());
- if (!fpA) {
- return GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(fpB), fMode);
- }
- if (!fpB) {
- return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(fpA), fMode);
- }
- return GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(fpB),
- std::move(fpA), fMode);
-}
-
-std::unique_ptr<GrFragmentProcessor> SkShader_Lerp::asFragmentProcessor(
- const GrFPArgs& orig_args) const {
- const GrFPArgs::WithPreLocalMatrix args(orig_args, this->getLocalMatrix());
- auto fpA = as_fp(args, fDst.get());
- auto fpB = as_fp(args, fSrc.get());
- return GrComposeLerpEffect::Make(std::move(fpA), std::move(fpB), fWeight);
-}
-#endif
diff --recursive --unified skia/src/shaders/SkComposeShader.h tiny-skia/skia/src/shaders/SkComposeShader.h
@@ -19,13 +19,8 @@
, fMode(mode)
{}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
protected:
SkShader_Blend(SkReadBuffer&);
- void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
const SkMatrixProvider&, const SkMatrix* localM,
@@ -33,8 +28,6 @@
skvm::Uniforms*, SkArenaAlloc*) const override;
private:
- SK_FLATTENABLE_HOOKS(SkShader_Blend)
-
sk_sp<SkShader> fDst;
sk_sp<SkShader> fSrc;
const SkBlendMode fMode;
@@ -52,13 +45,8 @@
SkASSERT(weight >= 0 && weight <= 1);
}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
protected:
SkShader_Lerp(SkReadBuffer&);
- void flatten(SkWriteBuffer&) const override;
bool onAppendStages(const SkStageRec&) const override;
skvm::Color onProgram(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
const SkMatrixProvider&, const SkMatrix* localM,
@@ -66,8 +54,6 @@
skvm::Uniforms*, SkArenaAlloc*) const override;
private:
- SK_FLATTENABLE_HOOKS(SkShader_Lerp)
-
sk_sp<SkShader> fDst;
sk_sp<SkShader> fSrc;
const float fWeight;
diff --recursive --unified skia/src/shaders/SkEmptyShader.h tiny-skia/skia/src/shaders/SkEmptyShader.h
@@ -21,18 +21,6 @@
SkEmptyShader() {}
protected:
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override {
- return nullptr;
- }
-#endif
-
- void flatten(SkWriteBuffer& buffer) const override {
- // Do nothing.
- // We just don't want to fall through to SkShader::flatten(),
- // which will write data we don't care to serialize or decode.
- }
-
bool onAppendStages(const SkStageRec&) const override {
return false;
}
@@ -43,8 +31,6 @@
skvm::Uniforms*, SkArenaAlloc*) const override;
private:
- SK_FLATTENABLE_HOOKS(SkEmptyShader)
-
typedef SkShaderBase INHERITED;
};
diff --recursive --unified skia/src/shaders/SkImageShader.cpp tiny-skia/skia/src/shaders/SkImageShader.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "include/core/SkPaint.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkBitmapController.h"
#include "src/core/SkColorSpacePriv.h"
@@ -12,11 +13,8 @@
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkOpts.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/image/SkImage_Base.h"
-#include "src/shaders/SkBitmapProcShader.h"
#include "src/shaders/SkEmptyShader.h"
#include "src/shaders/SkImageShader.h"
@@ -50,122 +48,11 @@
// fClampAsIfUnpremul is always false when constructed through public APIs,
// so there's no need to read or write it here.
-sk_sp<SkFlattenable> SkImageShader::CreateProc(SkReadBuffer& buffer) {
- auto tmx = buffer.read32LE<SkTileMode>(SkTileMode::kLastTileMode);
- auto tmy = buffer.read32LE<SkTileMode>(SkTileMode::kLastTileMode);
-
- FilterEnum filtering = kInheritFromPaint;
- if (!buffer.isVersionLT(SkPicturePriv::kFilteringInImageShader_Version)) {
- filtering = buffer.read32LE<FilterEnum>(kInheritFromPaint);
- }
-
- SkMatrix localMatrix;
- buffer.readMatrix(&localMatrix);
- sk_sp<SkImage> img = buffer.readImage();
- if (!img) {
- return nullptr;
- }
-
- return SkImageShader::Make(std::move(img), tmx, tmy, &localMatrix, filtering);
-}
-
-void SkImageShader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeUInt((unsigned)fTileModeX);
- buffer.writeUInt((unsigned)fTileModeY);
- buffer.writeUInt((unsigned)fFiltering);
- buffer.writeMatrix(this->getLocalMatrix());
- buffer.writeImage(fImage.get());
- SkASSERT(fClampAsIfUnpremul == false);
-}
-
bool SkImageShader::isOpaque() const {
return fImage->isOpaque() &&
fTileModeX != SkTileMode::kDecal && fTileModeY != SkTileMode::kDecal;
}
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
-static bool legacy_shader_can_handle(const SkMatrix& inv) {
- SkASSERT(!inv.hasPerspective());
-
- // Scale+translate methods are always present, but affine might not be.
- if (!SkOpts::S32_alpha_D32_filter_DXDY && !inv.isScaleTranslate()) {
- return false;
- }
-
- // legacy code uses SkFixed 32.32, so ensure the inverse doesn't map device coordinates
- // out of range.
- const SkScalar max_dev_coord = 32767.0f;
- const SkRect src = inv.mapRect(SkRect::MakeWH(max_dev_coord, max_dev_coord));
-
- // take 1/4 of max signed 32bits so we have room to subtract local values
- const SkScalar max_fixed32dot32 = float(SK_MaxS32) * 0.25f;
- if (!SkRect::MakeLTRB(-max_fixed32dot32, -max_fixed32dot32,
- +max_fixed32dot32, +max_fixed32dot32).contains(src)) {
- return false;
- }
-
- // legacy shader impl should be able to handle these matrices
- return true;
-}
-
-SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec,
- SkArenaAlloc* alloc) const {
- SkFilterQuality quality = this->resolveFiltering(rec.fPaint->getFilterQuality());
-
- if (quality == kHigh_SkFilterQuality) {
- return nullptr;
- }
- if (fImage->alphaType() == kUnpremul_SkAlphaType) {
- return nullptr;
- }
- if (fImage->colorType() != kN32_SkColorType) {
- return nullptr;
- }
- if (fTileModeX != fTileModeY) {
- return nullptr;
- }
- if (fTileModeX == SkTileMode::kDecal || fTileModeY == SkTileMode::kDecal) {
- return nullptr;
- }
-
- // SkBitmapProcShader stores bitmap coordinates in a 16bit buffer,
- // so it can't handle bitmaps larger than 65535.
- //
- // We back off another bit to 32767 to make small amounts of
- // intermediate math safe, e.g. in
- //
- // SkFixed fx = ...;
- // fx = tile(fx + SK_Fixed1);
- //
- // we want to make sure (fx + SK_Fixed1) never overflows.
- if (fImage-> width() > 32767 ||
- fImage->height() > 32767) {
- return nullptr;
- }
-
- SkMatrix inv;
- if (!this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, &inv) ||
- !legacy_shader_can_handle(inv)) {
- return nullptr;
- }
-
- if (!rec.isLegacyCompatible(fImage->colorSpace())) {
- return nullptr;
- }
-
- // Send in a modified paint with different filter-quality if we don't agree with the paint
- SkPaint modifiedPaint;
- ContextRec modifiedRec = rec;
- if (quality != rec.fPaint->getFilterQuality()) {
- modifiedPaint = *rec.fPaint;
- modifiedPaint.setFilterQuality(quality);
- modifiedRec.fPaint = &modifiedPaint;
- }
- return SkBitmapProcLegacyShader::MakeContext(*this, fTileModeX, fTileModeY,
- as_IB(fImage.get()), modifiedRec, alloc);
-}
-#endif
-
SkImage* SkImageShader::onIsAImage(SkMatrix* texM, SkTileMode xy[]) const {
if (texM) {
*texM = this->getLocalMatrix();
@@ -191,74 +78,6 @@
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#if SK_SUPPORT_GPU
-
-#include "include/private/GrRecordingContext.h"
-#include "src/gpu/GrCaps.h"
-#include "src/gpu/GrColorInfo.h"
-#include "src/gpu/GrRecordingContextPriv.h"
-#include "src/gpu/SkGr.h"
-#include "src/gpu/effects/GrBicubicEffect.h"
-#include "src/gpu/effects/GrTextureEffect.h"
-
-std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
- const GrFPArgs& args) const {
- const auto lm = this->totalLocalMatrix(args.fPreLocalMatrix);
- SkMatrix lmInverse;
- if (!lm->invert(&lmInverse)) {
- return nullptr;
- }
-
- GrSamplerState::WrapMode wmX = SkTileModeToWrapMode(fTileModeX),
- wmY = SkTileModeToWrapMode(fTileModeY);
-
- // Must set wrap and filter on the sampler before requesting a texture. In two places below
- // we check the matrix scale factors to determine how to interpret the filter quality setting.
- // This completely ignores the complexity of the drawVertices case where explicit local coords
- // are provided by the caller.
- bool doBicubic;
- GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
- fImage->width(), fImage->height(), this->resolveFiltering(args.fFilterQuality),
- args.fMatrixProvider.localToDevice(), *lm,
- args.fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
- GrMipMapped mipMapped = GrMipMapped::kNo;
- if (textureFilterMode == GrSamplerState::Filter::kMipMap) {
- mipMapped = GrMipMapped::kYes;
- }
- GrSurfaceProxyView view = as_IB(fImage)->refView(args.fContext, mipMapped);
- if (!view) {
- return nullptr;
- }
-
- SkAlphaType srcAlphaType = fImage->alphaType();
-
- const auto& caps = *args.fContext->priv().caps();
-
- std::unique_ptr<GrFragmentProcessor> inner;
- if (doBicubic) {
- static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- inner = GrBicubicEffect::Make(std::move(view), srcAlphaType, lmInverse, wmX, wmY, kDir,
- caps);
- } else {
- GrSamplerState samplerState(wmX, wmY, textureFilterMode);
- inner = GrTextureEffect::Make(std::move(view), srcAlphaType, lmInverse, samplerState, caps);
- }
- inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(), srcAlphaType,
- args.fDstColorInfo->colorSpace());
-
- bool isAlphaOnly = SkColorTypeIsAlphaOnly(fImage->colorType());
- if (isAlphaOnly) {
- return inner;
- } else if (args.fInputColorIsOpaque) {
- return GrFragmentProcessor::OverrideInput(std::move(inner), SK_PMColor4fWHITE, false);
- }
- return GrFragmentProcessor::MulChildByInputAlpha(std::move(inner));
-}
-
-#endif
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
#include "src/core/SkImagePriv.h"
sk_sp<SkShader> SkMakeBitmapShader(const SkBitmap& src, SkTileMode tmx, SkTileMode tmy,
@@ -283,8 +102,6 @@
return s;
}
-void SkShaderBase::RegisterFlattenables() { SK_REGISTER_FLATTENABLE(SkImageShader); }
-
class SkImageStageUpdater : public SkStageUpdater {
public:
SkImageStageUpdater(const SkImageShader* shader, bool usePersp)
diff --recursive --unified skia/src/shaders/SkImageShader.h tiny-skia/skia/src/shaders/SkImageShader.h
@@ -9,7 +9,6 @@
#define SkImageShader_DEFINED
#include "include/core/SkImage.h"
-#include "src/shaders/SkBitmapProcShader.h"
#include "src/shaders/SkShaderBase.h"
// private subclass of SkStageUpdater
@@ -35,13 +34,7 @@
bool isOpaque() const override;
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
private:
- SK_FLATTENABLE_HOOKS(SkImageShader)
-
SkImageShader(sk_sp<SkImage>,
SkTileMode tmx,
SkTileMode tmy,
@@ -49,10 +42,6 @@
FilterEnum,
bool clampAsIfUnpremul);
- void flatten(SkWriteBuffer&) const override;
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override;
-#endif
SkImage* onIsAImage(SkMatrix*, SkTileMode*) const override;
bool onAppendStages(const SkStageRec&) const override;
diff --recursive --unified skia/src/shaders/SkLocalMatrixShader.cpp tiny-skia/skia/src/shaders/SkLocalMatrixShader.cpp
@@ -10,50 +10,6 @@
#include "src/core/SkVM.h"
#include "src/shaders/SkLocalMatrixShader.h"
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrFragmentProcessor.h"
-#include "src/gpu/effects/generated/GrDeviceSpaceEffect.h"
-#endif
-
-#if SK_SUPPORT_GPU
-std::unique_ptr<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(
- const GrFPArgs& args) const {
- return as_SB(fProxyShader)->asFragmentProcessor(
- GrFPArgs::WithPreLocalMatrix(args, this->getLocalMatrix()));
-}
-#endif
-
-sk_sp<SkFlattenable> SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
- SkMatrix lm;
- buffer.readMatrix(&lm);
- auto baseShader(buffer.readShader());
- if (!baseShader) {
- return nullptr;
- }
- return baseShader->makeWithLocalMatrix(lm);
-}
-
-void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeMatrix(this->getLocalMatrix());
- buffer.writeFlattenable(fProxyShader.get());
-}
-
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
-SkShaderBase::Context* SkLocalMatrixShader::onMakeContext(
- const ContextRec& rec, SkArenaAlloc* alloc) const
-{
- SkTCopyOnFirstWrite<SkMatrix> lm(this->getLocalMatrix());
- if (rec.fLocalMatrix) {
- lm.writable()->preConcat(*rec.fLocalMatrix);
- }
-
- ContextRec newRec(rec);
- newRec.fLocalMatrix = lm;
-
- return as_SB(fProxyShader)->makeContext(newRec, alloc);
-}
-#endif
-
SkImage* SkLocalMatrixShader::onIsAImage(SkMatrix* outMatrix, SkTileMode* mode) const {
SkMatrix imageMatrix;
SkImage* image = fProxyShader->isAImage(&imageMatrix, mode);
@@ -131,17 +87,7 @@
return fProxyShader->asAGradient(info);
}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
protected:
- void flatten(SkWriteBuffer&) const override { SkASSERT(false); }
-
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override { return nullptr; }
-#endif
-
bool onAppendStages(const SkStageRec& rec) const override {
SkOverrideDeviceMatrixProvider matrixProvider(rec.fMatrixProvider, fCTM);
SkStageRec newRec = {
@@ -169,43 +115,12 @@
}
private:
- SK_FLATTENABLE_HOOKS(SkCTMShader)
-
sk_sp<SkShader> fProxyShader;
SkMatrix fCTM;
typedef SkShaderBase INHERITED;
};
-
-#if SK_SUPPORT_GPU
-std::unique_ptr<GrFragmentProcessor> SkCTMShader::asFragmentProcessor(
- const GrFPArgs& args) const {
- SkMatrix ctmInv;
- if (!fCTM.invert(&ctmInv)) {
- return nullptr;
- }
-
- auto ctmProvider = SkOverrideDeviceMatrixProvider(args.fMatrixProvider, fCTM);
- auto base = as_SB(fProxyShader)->asFragmentProcessor(
- GrFPArgs::WithPreLocalMatrix(args.withNewMatrixProvider(ctmProvider),
- this->getLocalMatrix()));
- if (!base) {
- return nullptr;
- }
-
- // In order for the shader to be evaluated with the original CTM, we explicitly evaluate it
- // at sk_FragCoord, and pass that through the inverse of the original CTM. This avoids requiring
- // local coords for the shader and mapping from the draw's local to device and then back.
- return GrDeviceSpaceEffect::Make(std::move(base), ctmInv);
-}
-#endif
-
-sk_sp<SkFlattenable> SkCTMShader::CreateProc(SkReadBuffer& buffer) {
- SkASSERT(false);
- return nullptr;
-}
-
sk_sp<SkShader> SkShaderBase::makeWithCTM(const SkMatrix& postM) const {
return sk_sp<SkShader>(new SkCTMShader(sk_ref_sp(this), postM));
}
diff --recursive --unified skia/src/shaders/SkLocalMatrixShader.h tiny-skia/skia/src/shaders/SkLocalMatrixShader.h
@@ -8,11 +8,8 @@
#ifndef SkLocalMatrixShader_DEFINED
#define SkLocalMatrixShader_DEFINED
-#include "src/core/SkReadBuffer.h"
-#include "src/core/SkWriteBuffer.h"
#include "src/shaders/SkShaderBase.h"
-class GrFragmentProcessor;
class SkArenaAlloc;
class SkLocalMatrixShader final : public SkShaderBase {
@@ -26,10 +23,6 @@
return fProxyShader->asAGradient(info);
}
-#if SK_SUPPORT_GPU
- std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
-#endif
-
sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const override {
if (localMatrix) {
*localMatrix = this->getLocalMatrix();
@@ -38,12 +31,6 @@
}
protected:
- void flatten(SkWriteBuffer&) const override;
-
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
-#endif
-
SkImage* onIsAImage(SkMatrix* matrix, SkTileMode* mode) const override;
bool onAppendStages(const SkStageRec&) const override;
@@ -54,8 +41,6 @@
skvm::Uniforms* uniforms, SkArenaAlloc*) const override;
private:
- SK_FLATTENABLE_HOOKS(SkLocalMatrixShader)
-
sk_sp<SkShader> fProxyShader;
typedef SkShaderBase INHERITED;
Only in skia/src/shaders: SkPerlinNoiseShader.cpp
Only in skia/src/shaders: SkPictureShader.cpp
Only in skia/src/shaders: SkPictureShader.h
diff --recursive --unified skia/src/shaders/SkShaderBase.h tiny-skia/skia/src/shaders/SkShaderBase.h
@@ -17,19 +17,12 @@
#include "src/core/SkTLazy.h"
#include "src/core/SkVM_fwd.h"
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrFPArgs.h"
-#endif
-
-class GrContext;
-class GrFragmentProcessor;
class SkArenaAlloc;
class SkColorSpace;
class SkImage;
struct SkImageInfo;
class SkPaint;
class SkRasterPipeline;
-class SkRuntimeEffect;
/**
* Shaders can optionally return a subclass of this when appending their stages.
@@ -139,30 +132,6 @@
};
/**
- * Make a context using the memory provided by the arena.
- *
- * @return pointer to context or nullptr if can't be created
- */
- Context* makeContext(const ContextRec&, SkArenaAlloc*) const;
-
-#if SK_SUPPORT_GPU
- /**
- * Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
- * returned if there is no GPU implementation.
- *
- * The GPU device does not call SkShader::createContext(), instead we pass the view matrix,
- * local matrix, and filter quality directly.
- *
- * The GrContext may be used by the to create textures that are required by the returned
- * processor.
- *
- * The returned GrFragmentProcessor should expect an unpremultiplied input color and
- * produce a premultiplied output.
- */
- virtual std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const;
-#endif
-
- /**
* If the shader can represent its "average" luminance in a single color, return true and
* if color is not NULL, return that color. If it cannot, return false and ignore the color
* parameter.
@@ -189,18 +158,6 @@
return nullptr;
}
- virtual SkRuntimeEffect* asRuntimeEffect() const { return nullptr; }
-
- static Type GetFlattenableType() { return kSkShaderBase_Type; }
- Type getFlattenableType() const override { return GetFlattenableType(); }
-
- static sk_sp<SkShaderBase> Deserialize(const void* data, size_t size,
- const SkDeserialProcs* procs = nullptr) {
- return sk_sp<SkShaderBase>(static_cast<SkShaderBase*>(
- SkFlattenable::Deserialize(GetFlattenableType(), data, size, procs).release()));
- }
- static void RegisterFlattenables();
-
/** DEPRECATED. skbug.com/8941
* If this shader can be represented by another shader + a localMatrix, return that shader and
* the localMatrix. If not, return nullptr and ignore the localMatrix parameter.
@@ -219,18 +176,6 @@
protected:
SkShaderBase(const SkMatrix* localMatrix = nullptr);
- void flatten(SkWriteBuffer&) const override;
-
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- /**
- * Specialize creating a SkShader context using the supplied allocator.
- * @return pointer to context owned by the arena allocator.
- */
- virtual Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const {
- return nullptr;
- }
-#endif
-
virtual bool onAsLuminanceColor(SkColor*) const {
return false;
}
diff --recursive --unified skia/src/shaders/SkShader.cpp tiny-skia/skia/src/shaders/SkShader.cpp
@@ -5,29 +5,22 @@
* found in the LICENSE file.
*/
+#include "include/core/SkColorFilter.h"
#include "include/core/SkMallocPixelRef.h"
#include "include/core/SkPaint.h"
-#include "include/core/SkPicture.h"
#include "include/core/SkScalar.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkColorSpaceXformSteps.h"
+#include "src/core/SkImagePriv.h"
#include "src/core/SkMatrixProvider.h"
#include "src/core/SkRasterPipeline.h"
-#include "src/core/SkReadBuffer.h"
#include "src/core/SkTLazy.h"
#include "src/core/SkVM.h"
-#include "src/core/SkWriteBuffer.h"
-#include "src/shaders/SkBitmapProcShader.h"
#include "src/shaders/SkColorShader.h"
#include "src/shaders/SkEmptyShader.h"
-#include "src/shaders/SkPictureShader.h"
#include "src/shaders/SkShaderBase.h"
-#if SK_SUPPORT_GPU
-#include "src/gpu/GrFragmentProcessor.h"
-#endif
-
SkShaderBase::SkShaderBase(const SkMatrix* localMatrix)
: fLocalMatrix(localMatrix ? *localMatrix : SkMatrix::I()) {
// Pre-cache so future calls to fLocalMatrix.getType() are threadsafe.
@@ -36,15 +29,6 @@
SkShaderBase::~SkShaderBase() {}
-void SkShaderBase::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- bool hasLocalM = !fLocalMatrix.isIdentity();
- buffer.writeBool(hasLocalM);
- if (hasLocalM) {
- buffer.writeMatrix(fLocalMatrix);
- }
-}
-
SkTCopyOnFirstWrite<SkMatrix>
SkShaderBase::totalLocalMatrix(const SkMatrix* preLocalMatrix) const {
SkTCopyOnFirstWrite<SkMatrix> m(fLocalMatrix);
@@ -74,22 +58,6 @@
return false;
}
-SkShaderBase::Context* SkShaderBase::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
-#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
- // We always fall back to raster pipeline when perspective is present.
- if (rec.fMatrix->hasPerspective() ||
- fLocalMatrix.hasPerspective() ||
- (rec.fLocalMatrix && rec.fLocalMatrix->hasPerspective()) ||
- !this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, nullptr)) {
- return nullptr;
- }
-
- return this->onMakeContext(rec, alloc);
-#else
- return nullptr;
-#endif
-}
-
SkShaderBase::Context::Context(const SkShaderBase& shader, const ContextRec& rec)
: fShader(shader), fCTM(*rec.fMatrix)
{
@@ -124,12 +92,6 @@
return kNone_GradientType;
}
-#if SK_SUPPORT_GPU
-std::unique_ptr<GrFragmentProcessor> SkShaderBase::asFragmentProcessor(const GrFPArgs&) const {
- return nullptr;
-}
-#endif
-
sk_sp<SkShader> SkShaderBase::makeAsALocalMatrixShader(SkMatrix*) const {
return nullptr;
}
@@ -170,7 +132,7 @@
};
auto cb = rec.fAlloc->make<CallbackCtx>();
cb->shader = sk_ref_sp(this);
- cb->ctx = as_SB(this)->makeContext(cr, rec.fAlloc);
+ cb->ctx = nullptr;
cb->fn = [](SkRasterPipeline_CallbackCtx* self, int active_pixels) {
auto c = (CallbackCtx*)self;
int x = (int)c->rgba[0],
@@ -273,7 +235,3 @@
skvm::Uniforms*, SkArenaAlloc*) const {
return {}; // signal failure
}
-
-sk_sp<SkFlattenable> SkEmptyShader::CreateProc(SkReadBuffer&) {
- return SkShaders::Empty();
-}
Only in skia/src: sksl
Only in skia/src: svg
Only in skia/src/utils: mac
Only in skia/src/utils: SkAnimCodecPlayer.cpp
Only in skia/src/utils: SkBase64.cpp
Only in skia/src/utils: SkBitSet.h
Only in skia/src/utils: SkCallableTraits.h
Only in skia/src/utils: SkCamera.cpp
Only in skia/src/utils: SkCanvasStack.cpp
Only in skia/src/utils: SkCanvasStack.h
Only in skia/src/utils: SkCanvasStateUtils.cpp
Only in skia/src/utils: SkCharToGlyphCache.cpp
Only in skia/src/utils: SkCharToGlyphCache.h
Only in skia/src/utils: SkClipStackUtils.cpp
Only in skia/src/utils: SkClipStackUtils.h
Only in skia/src/utils: SkCustomTypeface.cpp
Only in skia/src/utils: SkEventTracer.cpp
Only in skia/src/utils: SkFloatToDecimal.cpp
Only in skia/src/utils: SkFloatToDecimal.h
Only in skia/src/utils: SkFloatUtils.h
Only in skia/src/utils: SkInterpolator.cpp
Only in skia/src/utils: SkJSON.cpp
Only in skia/src/utils: SkJSON.h
Only in skia/src/utils: SkJSONWriter.cpp
Only in skia/src/utils: SkJSONWriter.h
Only in skia/src/utils: SkLuaCanvas.cpp
Only in skia/src/utils: SkLua.cpp
Only in skia/src/utils: SkMatrix22.cpp
Only in skia/src/utils: SkMatrix22.h
Only in skia/src/utils: SkMultiPictureDocument.cpp
Only in skia/src/utils: SkMultiPictureDocument.h
Only in skia/src/utils: SkMultiPictureDocumentPriv.h
Only in skia/src/utils: SkNullCanvas.cpp
Only in skia/src/utils: SkNWayCanvas.cpp
Only in skia/src/utils: SkOSPath.cpp
Only in skia/src/utils: SkOSPath.h
Only in skia/src/utils: SkPaintFilterCanvas.cpp
Only in skia/src/utils: SkParseColor.cpp
Only in skia/src/utils: SkParse.cpp
Only in skia/src/utils: SkParsePath.cpp
Only in skia/src/utils: SkPatchUtils.cpp
Only in skia/src/utils: SkPatchUtils.h
Only in skia/src/utils: SkPolyUtils.cpp
Only in skia/src/utils: SkPolyUtils.h
Only in skia/src/utils: SkShadowTessellator.cpp
Only in skia/src/utils: SkShadowTessellator.h
Only in skia/src/utils: SkShadowUtils.cpp
Only in skia/src/utils: SkShaperJSONWriter.cpp
Only in skia/src/utils: SkShaperJSONWriter.h
Only in skia/src/utils: SkTextUtils.cpp
Only in skia/src/utils: SkThreadUtils_pthread.cpp
Only in skia/src/utils: SkThreadUtils_win.cpp
Only in skia/src/utils: SkUTF.cpp
Only in skia/src/utils: SkUTF.h
Only in skia/src/utils: SkWhitelistChecksums.inc
Only in skia/src/utils: SkWhitelistTypefaces.cpp
Only in skia/src/utils: win
Only in skia/src: xml
Only in skia/src: xps
Only in skia: tests
Only in skia/third_party: angle2
Only in skia/third_party: BUILD.gn
Only in skia/third_party: cpu-features
Only in skia/third_party: dng_sdk
Only in skia/third_party: etc1
Only in skia/third_party: expat
Only in skia/third_party: externals
Only in skia/third_party: freetype2
Only in skia/third_party: glslang
Only in skia/third_party: harfbuzz
Only in skia/third_party: icu
Only in skia/third_party: imgui
Only in skia/third_party: libjpeg-turbo
Only in skia/third_party: libmicrohttpd
Only in skia/third_party: libpng
Only in skia/third_party: libsdl
Only in skia/third_party: libwebp
Only in skia/third_party: lua
Only in skia/third_party: native_app_glue
Only in skia/third_party: opencl
Only in skia/third_party: piex
Only in skia/third_party: README
Only in skia/third_party: sfntly
Only in skia/third_party: shaderc
Only in tiny-skia/skia/third_party/skcms: .directory
Only in skia/third_party: spirv-cross
Only in skia/third_party: spirv-headers
Only in skia/third_party: spirv-tools
Only in skia/third_party: third_party.gni
Only in skia/third_party: vulkanmemoryallocator
Only in skia/third_party: wuffs
Only in skia/third_party: zlib
Only in skia: tools
Only in skia: whitespace.txt