mirror of
https://github.com/oven-sh/bun
synced 2026-02-07 09:28:51 +00:00
Compare commits
3 Commits
dylan/pyth
...
jarred/can
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a87508008d | ||
|
|
4a19a3f07f | ||
|
|
e62c7dc9e5 |
9
Makefile
9
Makefile
@@ -195,10 +195,12 @@ MAC_INCLUDE_DIRS := -I$(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders \
|
||||
-Isrc/javascript/jsc/bindings/ \
|
||||
-Isrc/javascript/jsc/bindings/webcore \
|
||||
-I$(WEBKIT_DIR)/Source/bmalloc \
|
||||
-I$(WEBKIT_DIR)/Source
|
||||
-I$(WEBKIT_DIR)/Source \
|
||||
-I$(BUN_DEPS_DIR)/skia
|
||||
|
||||
LINUX_INCLUDE_DIRS := -I$(JSC_INCLUDE_DIR) \
|
||||
-Isrc/javascript/jsc/bindings/
|
||||
-Isrc/javascript/jsc/bindings/ \
|
||||
-I$(BUN_DEPS_DIR)/skia
|
||||
|
||||
UWS_INCLUDE_DIR := -I$(BUN_DEPS_DIR)/uws/uSockets/src -I$(BUN_DEPS_DIR)/uws/src -I$(BUN_DEPS_DIR)
|
||||
|
||||
@@ -295,7 +297,8 @@ ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MIMALLOC_FILE_PATH) \
|
||||
$(BUN_DEPS_OUT_DIR)/picohttpparser.o \
|
||||
$(BUN_DEPS_OUT_DIR)/liblolhtml.a \
|
||||
$(BUN_DEPS_OUT_DIR)/uSockets.a \
|
||||
$(BUN_DEPS_OUT_DIR)/libuwsockets.o
|
||||
$(BUN_DEPS_OUT_DIR)/libuwsockets.o \
|
||||
$(BUN_DEPS_OUT_DIR)/skia.a
|
||||
|
||||
ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO) $(BUN_DEPS_OUT_DIR)/libcrypto.boring.a
|
||||
|
||||
|
||||
20
examples/bun/canvas.ts
Normal file
20
examples/bun/canvas.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// The goal of this stream is for this code to work.
|
||||
// The likelihood of that happening is pretty low.
|
||||
// but it's worth an attempt!
|
||||
const canvas = new OffscreenCanvas(256, 256);
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
const imageData = new ImageData(256, 256);
|
||||
// one red pixel
|
||||
imageData.data[0] = 255;
|
||||
imageData.data[1] = 0;
|
||||
imageData.data[2] = 0;
|
||||
|
||||
console.log(imageData);
|
||||
|
||||
// ctx.drawImage(imageData, 0, 0);
|
||||
|
||||
// const blob = await canvas.convertToBlob({ type: "image/png" });
|
||||
// await Bun.write("hello.png", blob);
|
||||
|
||||
// export {};
|
||||
16
src/deps/skia/include/OWNERS
Normal file
16
src/deps/skia/include/OWNERS
Normal file
@@ -0,0 +1,16 @@
|
||||
set noparent
|
||||
|
||||
# Include one of the following reviewers for CLs that add or change Skia's public API:
|
||||
brianosman@google.com
|
||||
bsalomon@google.com
|
||||
djsollen@google.com
|
||||
hcm@google.com
|
||||
egdaniel@google.com
|
||||
|
||||
# For revert purposes only
|
||||
rubber-stamper@appspot.gserviceaccount.com
|
||||
|
||||
per-file BUILD.bazel=bungeman@google.com
|
||||
per-file BUILD.bazel=jcgregorio@google.com
|
||||
per-file BUILD.bazel=kjlubick@google.com
|
||||
per-file BUILD.bazel=lovisolo@google.com
|
||||
24
src/deps/skia/include/android/BUILD.bazel
Normal file
24
src/deps/skia/include/android/BUILD.bazel
Normal file
@@ -0,0 +1,24 @@
|
||||
load("//bazel:macros.bzl", "generated_cc_atom")
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkAndroidFrameworkUtils_hdr",
|
||||
hdrs = ["SkAndroidFrameworkUtils.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
"//include/core:SkRefCnt_hdr",
|
||||
"//include/core:SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkAnimatedImage_hdr",
|
||||
hdrs = ["SkAnimatedImage.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
"//include/codec:SkCodecAnimation_hdr",
|
||||
"//include/core:SkBitmap_hdr",
|
||||
"//include/core:SkDrawable_hdr",
|
||||
"//include/core:SkMatrix_hdr",
|
||||
"//include/core:SkRect_hdr",
|
||||
],
|
||||
)
|
||||
61
src/deps/skia/include/android/SkAndroidFrameworkUtils.h
Normal file
61
src/deps/skia/include/android/SkAndroidFrameworkUtils.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAndroidFrameworkUtils_DEFINED
|
||||
#define SkAndroidFrameworkUtils_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
|
||||
class SkCanvas;
|
||||
struct SkIRect;
|
||||
struct SkRect;
|
||||
class SkSurface;
|
||||
|
||||
/**
|
||||
* SkAndroidFrameworkUtils expose private APIs used only by Android framework.
|
||||
*/
|
||||
class SkAndroidFrameworkUtils {
|
||||
public:
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* clipWithStencil draws the current clip into a stencil buffer with reference value and mask
|
||||
* set to 0x1. This function works only on a GPU canvas.
|
||||
*
|
||||
* @param canvas A GPU canvas that has a non-empty clip.
|
||||
*
|
||||
* @return true on success or false if clip is empty or not a GPU canvas.
|
||||
*/
|
||||
static bool clipWithStencil(SkCanvas* canvas);
|
||||
#endif //SK_SUPPORT_GPU
|
||||
|
||||
static void SafetyNetLog(const char*);
|
||||
|
||||
static sk_sp<SkSurface> getSurfaceFromCanvas(SkCanvas* canvas);
|
||||
|
||||
static int SaveBehind(SkCanvas* canvas, const SkRect* subset);
|
||||
|
||||
// Operating within the canvas' clip stack, this resets the geometry of the clip to be wide
|
||||
// open modula any device clip restriction that was set outside of the clip stack.
|
||||
static void ResetClip(SkCanvas* canvas);
|
||||
|
||||
/**
|
||||
* Unrolls a chain of nested SkPaintFilterCanvas to return the base wrapped canvas.
|
||||
*
|
||||
* @param canvas A SkPaintFilterCanvas or any other SkCanvas subclass.
|
||||
*
|
||||
* @return SkCanvas that was found in the innermost SkPaintFilterCanvas.
|
||||
*/
|
||||
static SkCanvas* getBaseWrappedCanvas(SkCanvas* canvas);
|
||||
};
|
||||
|
||||
#endif // SK_BUILD_FOR_ANDROID_ANDROID
|
||||
|
||||
#endif // SkAndroidFrameworkUtils_DEFINED
|
||||
179
src/deps/skia/include/android/SkAnimatedImage.h
Normal file
179
src/deps/skia/include/android/SkAnimatedImage.h
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAnimatedImage_DEFINED
|
||||
#define SkAnimatedImage_DEFINED
|
||||
|
||||
#include "include/codec/SkCodecAnimation.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkDrawable.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkRect.h"
|
||||
|
||||
class SkAndroidCodec;
|
||||
class SkImage;
|
||||
class SkPicture;
|
||||
|
||||
/**
|
||||
* Thread unsafe drawable for drawing animated images (e.g. GIF).
|
||||
*/
|
||||
class SK_API SkAnimatedImage : public SkDrawable {
|
||||
public:
|
||||
/**
|
||||
* Create an SkAnimatedImage from the SkAndroidCodec.
|
||||
*
|
||||
* Returns null on failure to allocate pixels. On success, this will
|
||||
* decode the first frame.
|
||||
*
|
||||
* @param info Width and height may require scaling.
|
||||
* @param cropRect Rectangle to crop to after scaling.
|
||||
* @param postProcess Picture to apply after scaling and cropping.
|
||||
*/
|
||||
static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>,
|
||||
const SkImageInfo& info, SkIRect cropRect, sk_sp<SkPicture> postProcess);
|
||||
|
||||
/**
|
||||
* Simpler version that uses the default size, no cropping, and no postProcess.
|
||||
*/
|
||||
static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>);
|
||||
|
||||
~SkAnimatedImage() override;
|
||||
|
||||
/**
|
||||
* Reset the animation to the beginning.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Whether the animation completed.
|
||||
*
|
||||
* Returns true after all repetitions are complete, or an error stops the
|
||||
* animation. Gets reset to false if the animation is restarted.
|
||||
*/
|
||||
bool isFinished() const { return fFinished; }
|
||||
|
||||
/**
|
||||
* Returned by decodeNextFrame and currentFrameDuration if the animation
|
||||
* is not running.
|
||||
*/
|
||||
static constexpr int kFinished = -1;
|
||||
|
||||
/**
|
||||
* Decode the next frame.
|
||||
*
|
||||
* If the animation is on the last frame or has hit an error, returns
|
||||
* kFinished.
|
||||
*/
|
||||
int decodeNextFrame();
|
||||
|
||||
/**
|
||||
* Returns the current frame as an SkImage. The SkImage will not change
|
||||
* after it has been returned.
|
||||
* If there is no current frame, nullptr will be returned.
|
||||
*/
|
||||
sk_sp<SkImage> getCurrentFrame();
|
||||
|
||||
/**
|
||||
* How long to display the current frame.
|
||||
*
|
||||
* Useful for the first frame, for which decodeNextFrame is called
|
||||
* internally.
|
||||
*/
|
||||
int currentFrameDuration() {
|
||||
return fCurrentFrameDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the repetition count.
|
||||
*
|
||||
* By default, the image will repeat the number of times indicated in the
|
||||
* encoded data.
|
||||
*
|
||||
* Use SkCodec::kRepetitionCountInfinite for infinite, and 0 to show all
|
||||
* frames once and then stop.
|
||||
*/
|
||||
void setRepetitionCount(int count);
|
||||
|
||||
/**
|
||||
* Return the currently set repetition count.
|
||||
*/
|
||||
int getRepetitionCount() const {
|
||||
return fRepetitionCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total number of frames in the animation.
|
||||
*/
|
||||
int getFrameCount() const { return fFrameCount; }
|
||||
|
||||
protected:
|
||||
SkRect onGetBounds() override;
|
||||
void onDraw(SkCanvas*) override;
|
||||
|
||||
private:
|
||||
struct Frame {
|
||||
SkBitmap fBitmap;
|
||||
int fIndex;
|
||||
SkCodecAnimation::DisposalMethod fDisposalMethod;
|
||||
|
||||
// init() may have to create a new SkPixelRef, if the
|
||||
// current one is already in use by another owner (e.g.
|
||||
// an SkPicture). This determines whether to copy the
|
||||
// existing one to the new one.
|
||||
enum class OnInit {
|
||||
// Restore the image from the old SkPixelRef to the
|
||||
// new one.
|
||||
kRestoreIfNecessary,
|
||||
// No need to restore.
|
||||
kNoRestore,
|
||||
};
|
||||
|
||||
Frame();
|
||||
bool init(const SkImageInfo& info, OnInit);
|
||||
bool copyTo(Frame*) const;
|
||||
};
|
||||
|
||||
std::unique_ptr<SkAndroidCodec> fCodec;
|
||||
SkImageInfo fDecodeInfo;
|
||||
const SkIRect fCropRect;
|
||||
const sk_sp<SkPicture> fPostProcess;
|
||||
const int fFrameCount;
|
||||
SkMatrix fMatrix;
|
||||
int fSampleSize;
|
||||
|
||||
bool fFinished;
|
||||
int fCurrentFrameDuration;
|
||||
Frame fDisplayFrame;
|
||||
Frame fDecodingFrame;
|
||||
Frame fRestoreFrame;
|
||||
int fRepetitionCount;
|
||||
int fRepetitionsCompleted;
|
||||
|
||||
SkAnimatedImage(std::unique_ptr<SkAndroidCodec>, const SkImageInfo& requestedInfo,
|
||||
SkIRect cropRect, sk_sp<SkPicture> postProcess);
|
||||
|
||||
int computeNextFrame(int current, bool* animationEnded);
|
||||
double finish();
|
||||
|
||||
/**
|
||||
* True if there is no crop, orientation, or post decoding scaling.
|
||||
*/
|
||||
bool simple() const { return fMatrix.isIdentity() && !fPostProcess
|
||||
&& fCropRect == fDecodeInfo.bounds(); }
|
||||
|
||||
/**
|
||||
* Returns the current frame as an SkImage.
|
||||
*
|
||||
* Like getCurrentFrame, but only returns the raw data from the internal SkBitmap. (i.e. no
|
||||
* scaling, orientation-correction or cropping.) If simple(), this is the final output.
|
||||
*/
|
||||
sk_sp<SkImage> getCurrentFrameSimple();
|
||||
|
||||
using INHERITED = SkDrawable;
|
||||
};
|
||||
|
||||
#endif // SkAnimatedImage_DEFINED
|
||||
91
src/deps/skia/include/c/BUILD.bazel
Normal file
91
src/deps/skia/include/c/BUILD.bazel
Normal file
@@ -0,0 +1,91 @@
|
||||
load("//bazel:macros.bzl", "generated_cc_atom")
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_canvas_hdr",
|
||||
hdrs = ["sk_canvas.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_colorspace_hdr",
|
||||
hdrs = ["sk_colorspace.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_data_hdr",
|
||||
hdrs = ["sk_data.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_image_hdr",
|
||||
hdrs = ["sk_image.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_imageinfo_hdr",
|
||||
hdrs = ["sk_imageinfo.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_maskfilter_hdr",
|
||||
hdrs = ["sk_maskfilter.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_matrix_hdr",
|
||||
hdrs = ["sk_matrix.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_paint_hdr",
|
||||
hdrs = ["sk_paint.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_path_hdr",
|
||||
hdrs = ["sk_path.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_picture_hdr",
|
||||
hdrs = ["sk_picture.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_shader_hdr",
|
||||
hdrs = ["sk_shader.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_surface_hdr",
|
||||
hdrs = ["sk_surface.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":sk_types_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "sk_types_hdr",
|
||||
hdrs = ["sk_types.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
159
src/deps/skia/include/c/sk_canvas.h
Normal file
159
src/deps/skia/include/c/sk_canvas.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_canvas_DEFINED
|
||||
#define sk_canvas_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Save the current matrix and clip on the canvas. When the
|
||||
balancing call to sk_canvas_restore() is made, the previous matrix
|
||||
and clip are restored.
|
||||
*/
|
||||
SK_API void sk_canvas_save(sk_canvas_t*);
|
||||
/**
|
||||
This behaves the same as sk_canvas_save(), but in addition it
|
||||
allocates an offscreen surface. All drawing calls are directed
|
||||
there, and only when the balancing call to sk_canvas_restore() is
|
||||
made is that offscreen transfered to the canvas (or the previous
|
||||
layer).
|
||||
|
||||
@param sk_rect_t* (may be null) This rect, if non-null, is used as
|
||||
a hint to limit the size of the offscreen, and
|
||||
thus drawing may be clipped to it, though that
|
||||
clipping is not guaranteed to happen. If exact
|
||||
clipping is desired, use sk_canvas_clip_rect().
|
||||
@param sk_paint_t* (may be null) The paint is copied, and is applied
|
||||
to the offscreen when sk_canvas_restore() is
|
||||
called.
|
||||
*/
|
||||
SK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
This call balances a previous call to sk_canvas_save() or
|
||||
sk_canvas_save_layer(), and is used to remove all modifications to
|
||||
the matrix and clip state since the last save call. It is an
|
||||
error to call sk_canvas_restore() more times than save and
|
||||
save_layer were called.
|
||||
*/
|
||||
SK_API void sk_canvas_restore(sk_canvas_t*);
|
||||
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified translation.
|
||||
*/
|
||||
SK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified scale.
|
||||
*/
|
||||
SK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified rotation in degrees.
|
||||
*/
|
||||
SK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified rotation in radians.
|
||||
*/
|
||||
SK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified skew.
|
||||
*/
|
||||
SK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcat the current coordinate transformation matrix with the
|
||||
specified matrix.
|
||||
*/
|
||||
SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*);
|
||||
|
||||
/**
|
||||
Modify the current clip with the specified rectangle. The new
|
||||
current clip will be the intersection of the old clip and the
|
||||
rectange.
|
||||
*/
|
||||
SK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*);
|
||||
/**
|
||||
Modify the current clip with the specified path. The new
|
||||
current clip will be the intersection of the old clip and the
|
||||
path.
|
||||
*/
|
||||
SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*);
|
||||
|
||||
/**
|
||||
Fill the entire canvas (restricted to the current clip) with the
|
||||
specified paint.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified rectangle using the specified paint. The
|
||||
rectangle will be filled or stroked based on the style in the
|
||||
paint.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
* Draw the circle centered at (cx, cy) with radius rad using the specified paint.
|
||||
* The circle will be filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_circle(sk_canvas_t*, float cx, float cy, float rad, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified oval using the specified paint. The oval will be
|
||||
filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified path using the specified paint. The path will be
|
||||
filled or framed based on the style in the paint
|
||||
*/
|
||||
SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified image, with its top/left corner at (x,y), using
|
||||
the specified paint, transformed by the current matrix.
|
||||
|
||||
@param sk_paint_t* (may be NULL) the paint used to draw the image.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y,
|
||||
const sk_sampling_options_t*, const sk_paint_t*);
|
||||
/**
|
||||
Draw the specified image, scaling and translating so that it fills
|
||||
the specified dst rect. If the src rect is non-null, only that
|
||||
subset of the image is transformed and drawn.
|
||||
|
||||
@param sk_paint_t* (may be NULL) The paint used to draw the image.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*,
|
||||
const sk_rect_t* src, const sk_rect_t* dst,
|
||||
const sk_sampling_options_t*, const sk_paint_t*);
|
||||
|
||||
/**
|
||||
Draw the picture into this canvas (replay the pciture's drawing commands).
|
||||
|
||||
@param sk_matrix_t* If non-null, apply that matrix to the CTM when
|
||||
drawing this picture. This is logically
|
||||
equivalent to: save, concat, draw_picture,
|
||||
restore.
|
||||
|
||||
@param sk_paint_t* If non-null, draw the picture into a temporary
|
||||
buffer, and then apply the paint's alpha,
|
||||
colorfilter, imagefilter, and xfermode to that
|
||||
buffer as it is drawn to the canvas. This is
|
||||
logically equivalent to save_layer(paint),
|
||||
draw_picture, restore.
|
||||
*/
|
||||
SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*,
|
||||
const sk_matrix_t*, const sk_paint_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
25
src/deps/skia/include/c/sk_colorspace.h
Normal file
25
src/deps/skia/include/c/sk_colorspace.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_colorspace_DEFINED
|
||||
#define sk_colorspace_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
SK_API sk_colorspace_t* sk_colorspace_new_srgb();
|
||||
|
||||
SK_API void sk_colorspace_ref(sk_colorspace_t*);
|
||||
SK_API void sk_colorspace_unref(sk_colorspace_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
65
src/deps/skia/include/c/sk_data.h
Normal file
65
src/deps/skia/include/c/sk_data.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_data_DEFINED
|
||||
#define sk_data_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Returns a new sk_data_t by copying the specified source data.
|
||||
This call must be balanced with a call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_with_copy(const void* src, size_t length);
|
||||
/**
|
||||
Pass ownership of the given memory to a new sk_data_t, which will
|
||||
call free() when the refernce count of the data goes to zero. For
|
||||
example:
|
||||
size_t length = 1024;
|
||||
void* buffer = malloc(length);
|
||||
memset(buffer, 'X', length);
|
||||
sk_data_t* data = sk_data_new_from_malloc(buffer, length);
|
||||
This call must be balanced with a call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_from_malloc(const void* memory, size_t length);
|
||||
/**
|
||||
Returns a new sk_data_t using a subset of the data in the
|
||||
specified source sk_data_t. This call must be balanced with a
|
||||
call to sk_data_unref().
|
||||
*/
|
||||
SK_API sk_data_t* sk_data_new_subset(const sk_data_t* src, size_t offset, size_t length);
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_data_t. Must be
|
||||
balanced by a call to sk_data_unref().
|
||||
*/
|
||||
SK_API void sk_data_ref(const sk_data_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the sk_data_t
|
||||
and the memory it is managing. New sk_data_t are created with a
|
||||
reference count of 1.
|
||||
*/
|
||||
SK_API void sk_data_unref(const sk_data_t*);
|
||||
|
||||
/**
|
||||
Returns the number of bytes stored.
|
||||
*/
|
||||
SK_API size_t sk_data_get_size(const sk_data_t*);
|
||||
/**
|
||||
Returns the pointer to the data.
|
||||
*/
|
||||
SK_API const void* sk_data_get_data(const sk_data_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
71
src/deps/skia/include/c/sk_image.h
Normal file
71
src/deps/skia/include/c/sk_image.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_image_DEFINED
|
||||
#define sk_image_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
* Return a new image that has made a copy of the provided pixels, or NULL on failure.
|
||||
* Balance with a call to sk_image_unref().
|
||||
*/
|
||||
SK_API sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* If the specified data can be interpreted as a compressed image (e.g. PNG or JPEG) then this
|
||||
* returns an image. If the encoded data is not supported, returns NULL.
|
||||
*
|
||||
* On success, the encoded data may be processed immediately, or it may be ref()'d for later
|
||||
* use.
|
||||
*/
|
||||
SK_API sk_image_t* sk_image_new_from_encoded(const sk_data_t* encoded);
|
||||
|
||||
/**
|
||||
* Encode the image's pixels and return the result as a new PNG in a
|
||||
* sk_data_t, which the caller must manage: call sk_data_unref() when
|
||||
* they are done.
|
||||
*
|
||||
* If the image type cannot be encoded, this will return NULL.
|
||||
*/
|
||||
SK_API sk_data_t* sk_image_encode(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Increment the reference count on the given sk_image_t. Must be
|
||||
* balanced by a call to sk_image_unref().
|
||||
*/
|
||||
SK_API void sk_image_ref(const sk_image_t*);
|
||||
/**
|
||||
* Decrement the reference count. If the reference count is 1 before
|
||||
* the decrement, then release both the memory holding the sk_image_t
|
||||
* and the memory it is managing. New sk_image_t are created with a
|
||||
reference count of 1.
|
||||
*/
|
||||
SK_API void sk_image_unref(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Return the width of the sk_image_t/
|
||||
*/
|
||||
SK_API int sk_image_get_width(const sk_image_t*);
|
||||
/**
|
||||
* Return the height of the sk_image_t/
|
||||
*/
|
||||
SK_API int sk_image_get_height(const sk_image_t*);
|
||||
|
||||
/**
|
||||
* Returns a non-zero value unique among all images.
|
||||
*/
|
||||
SK_API uint32_t sk_image_get_unique_id(const sk_image_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
62
src/deps/skia/include/c/sk_imageinfo.h
Normal file
62
src/deps/skia/include/c/sk_imageinfo.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_imageinfo_DEFINED
|
||||
#define sk_imageinfo_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN_SK_COLORTYPE,
|
||||
RGBA_8888_SK_COLORTYPE,
|
||||
BGRA_8888_SK_COLORTYPE,
|
||||
ALPHA_8_SK_COLORTYPE,
|
||||
GRAY_8_SK_COLORTYPE,
|
||||
RGBA_F16_SK_COLORTYPE,
|
||||
RGBA_F32_SK_COLORTYPE,
|
||||
} sk_colortype_t;
|
||||
|
||||
typedef enum {
|
||||
OPAQUE_SK_ALPHATYPE,
|
||||
PREMUL_SK_ALPHATYPE,
|
||||
UNPREMUL_SK_ALPHATYPE,
|
||||
} sk_alphatype_t;
|
||||
|
||||
/**
|
||||
* Allocate a new imageinfo object. If colorspace is not null, it's owner-count will be
|
||||
* incremented automatically.
|
||||
*/
|
||||
SK_API sk_imageinfo_t* sk_imageinfo_new(int width, int height, sk_colortype_t ct, sk_alphatype_t at,
|
||||
sk_colorspace_t* cs);
|
||||
|
||||
/**
|
||||
* Free the imageinfo object. If it contains a reference to a colorspace, its owner-count will
|
||||
* be decremented automatically.
|
||||
*/
|
||||
SK_API void sk_imageinfo_delete(sk_imageinfo_t*);
|
||||
|
||||
SK_API int32_t sk_imageinfo_get_width(const sk_imageinfo_t*);
|
||||
SK_API int32_t sk_imageinfo_get_height(const sk_imageinfo_t*);
|
||||
SK_API sk_colortype_t sk_imageinfo_get_colortype(const sk_imageinfo_t*);
|
||||
SK_API sk_alphatype_t sk_imageinfo_get_alphatype(const sk_imageinfo_t*);
|
||||
|
||||
/**
|
||||
* Return the colorspace object reference contained in the imageinfo, or null if there is none.
|
||||
* Note: this does not modify the owner-count on the colorspace object. If the caller needs to
|
||||
* use the colorspace beyond the lifetime of the imageinfo, it should manually call
|
||||
* sk_colorspace_ref() (and then call unref() when it is done).
|
||||
*/
|
||||
SK_API sk_colorspace_t* sk_imageinfo_get_colorspace(const sk_imageinfo_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
47
src/deps/skia/include/c/sk_maskfilter.h
Normal file
47
src/deps/skia/include/c/sk_maskfilter.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_maskfilter_DEFINED
|
||||
#define sk_maskfilter_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
typedef enum {
|
||||
NORMAL_SK_BLUR_STYLE, //!< fuzzy inside and outside
|
||||
SOLID_SK_BLUR_STYLE, //!< solid inside, fuzzy outside
|
||||
OUTER_SK_BLUR_STYLE, //!< nothing inside, fuzzy outside
|
||||
INNER_SK_BLUR_STYLE, //!< fuzzy inside, nothing outside
|
||||
} sk_blurstyle_t;
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_maskfilter_t. Must be
|
||||
balanced by a call to sk_maskfilter_unref().
|
||||
*/
|
||||
SK_API void sk_maskfilter_ref(sk_maskfilter_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_maskfilter_t and any other associated resources. New
|
||||
sk_maskfilter_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_maskfilter_unref(sk_maskfilter_t*);
|
||||
|
||||
/**
|
||||
Create a blur maskfilter.
|
||||
@param sk_blurstyle_t The SkBlurStyle to use
|
||||
@param sigma Standard deviation of the Gaussian blur to apply. Must be > 0.
|
||||
*/
|
||||
SK_API sk_maskfilter_t* sk_maskfilter_new_blur(sk_blurstyle_t, float sigma);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
49
src/deps/skia/include/c/sk_matrix.h
Normal file
49
src/deps/skia/include/c/sk_matrix.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_matrix_DEFINED
|
||||
#define sk_matrix_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/** Set the matrix to identity */
|
||||
void sk_matrix_set_identity(sk_matrix_t*);
|
||||
|
||||
/** Set the matrix to translate by (tx, ty). */
|
||||
void sk_matrix_set_translate(sk_matrix_t*, float tx, float ty);
|
||||
/**
|
||||
Preconcats the matrix with the specified translation.
|
||||
M' = M * T(dx, dy)
|
||||
*/
|
||||
void sk_matrix_pre_translate(sk_matrix_t*, float tx, float ty);
|
||||
/**
|
||||
Postconcats the matrix with the specified translation.
|
||||
M' = T(dx, dy) * M
|
||||
*/
|
||||
void sk_matrix_post_translate(sk_matrix_t*, float tx, float ty);
|
||||
|
||||
/** Set the matrix to scale by sx and sy. */
|
||||
void sk_matrix_set_scale(sk_matrix_t*, float sx, float sy);
|
||||
/**
|
||||
Preconcats the matrix with the specified scale.
|
||||
M' = M * S(sx, sy)
|
||||
*/
|
||||
void sk_matrix_pre_scale(sk_matrix_t*, float sx, float sy);
|
||||
/**
|
||||
Postconcats the matrix with the specified scale.
|
||||
M' = S(sx, sy) * M
|
||||
*/
|
||||
void sk_matrix_post_scale(sk_matrix_t*, float sx, float sy);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
145
src/deps/skia/include/c/sk_paint.h
Normal file
145
src/deps/skia/include/c/sk_paint.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_paint_DEFINED
|
||||
#define sk_paint_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Create a new paint with default settings:
|
||||
antialias : false
|
||||
stroke : false
|
||||
stroke width : 0.0f (hairline)
|
||||
stroke miter : 4.0f
|
||||
stroke cap : BUTT_SK_STROKE_CAP
|
||||
stroke join : MITER_SK_STROKE_JOIN
|
||||
color : opaque black
|
||||
shader : NULL
|
||||
maskfilter : NULL
|
||||
xfermode_mode : SRCOVER_SK_XFERMODE_MODE
|
||||
*/
|
||||
SK_API sk_paint_t* sk_paint_new(void);
|
||||
/**
|
||||
Release the memory storing the sk_paint_t and unref() all
|
||||
associated objects.
|
||||
*/
|
||||
SK_API void sk_paint_delete(sk_paint_t*);
|
||||
|
||||
/**
|
||||
Return true iff the paint has antialiasing enabled.
|
||||
*/
|
||||
SK_API bool sk_paint_is_antialias(const sk_paint_t*);
|
||||
/**
|
||||
Set to true to enable antialiasing, false to disable it on this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
|
||||
|
||||
/**
|
||||
Return the paint's curent drawing color.
|
||||
*/
|
||||
SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's curent drawing color.
|
||||
*/
|
||||
SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
|
||||
|
||||
/* stroke settings */
|
||||
|
||||
/**
|
||||
Return true iff stroking is enabled rather than filling on this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API bool sk_paint_is_stroke(const sk_paint_t*);
|
||||
/**
|
||||
Set to true to enable stroking rather than filling with this
|
||||
sk_paint_t.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
|
||||
|
||||
/**
|
||||
Return the width for stroking. A value of 0 strokes in hairline mode.
|
||||
*/
|
||||
SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
|
||||
/**
|
||||
Set the width for stroking. A value of 0 strokes in hairline mode
|
||||
(always draw 1-pixel wide, regardless of the matrix).
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
|
||||
|
||||
/**
|
||||
Return the paint's stroke miter value. This is used to control the
|
||||
behavior of miter joins when the joins angle is sharp.
|
||||
*/
|
||||
SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke miter value. This is used to control the
|
||||
behavior of miter joins when the joins angle is sharp. This value
|
||||
must be >= 0.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
|
||||
|
||||
typedef enum {
|
||||
BUTT_SK_STROKE_CAP,
|
||||
ROUND_SK_STROKE_CAP,
|
||||
SQUARE_SK_STROKE_CAP
|
||||
} sk_stroke_cap_t;
|
||||
|
||||
/**
|
||||
Return the paint's stroke cap type, controlling how the start and
|
||||
end of stroked lines and paths are treated.
|
||||
*/
|
||||
SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke cap type, controlling how the start and
|
||||
end of stroked lines and paths are treated.
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
|
||||
|
||||
typedef enum {
|
||||
MITER_SK_STROKE_JOIN,
|
||||
ROUND_SK_STROKE_JOIN,
|
||||
BEVEL_SK_STROKE_JOIN
|
||||
} sk_stroke_join_t;
|
||||
|
||||
/**
|
||||
Return the paint's stroke join type, specifies the treatment that
|
||||
is applied to corners in paths and rectangles
|
||||
*/
|
||||
SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
|
||||
/**
|
||||
Set the paint's stroke join type, specifies the treatment that
|
||||
is applied to corners in paths and rectangles
|
||||
*/
|
||||
SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
|
||||
|
||||
/**
|
||||
* Set the paint's shader to the specified parameter. This will automatically call unref() on
|
||||
* any previous value, and call ref() on the new value.
|
||||
*/
|
||||
SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
|
||||
|
||||
/**
|
||||
* Set the paint's maskfilter to the specified parameter. This will automatically call unref() on
|
||||
* any previous value, and call ref() on the new value.
|
||||
*/
|
||||
SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
|
||||
|
||||
/**
|
||||
* Set the paint's xfermode to the specified parameter.
|
||||
*/
|
||||
SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
102
src/deps/skia/include/c/sk_path.h
Normal file
102
src/deps/skia/include/c/sk_path.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_path_DEFINED
|
||||
#define sk_path_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef enum {
|
||||
CW_SK_PATH_DIRECTION,
|
||||
CCW_SK_PATH_DIRECTION,
|
||||
} sk_path_direction_t;
|
||||
|
||||
typedef struct sk_pathbuilder_t sk_pathbuilder_t;
|
||||
|
||||
/** Create a new, empty path. */
|
||||
SK_API sk_pathbuilder_t* sk_pathbuilder_new(void);
|
||||
|
||||
/** Release the memory used by a sk_pathbuilder_t. */
|
||||
SK_API void sk_pathbuilder_delete(sk_pathbuilder_t*);
|
||||
|
||||
/** Set the beginning of the next contour to the point (x,y). */
|
||||
SK_API void sk_pathbuilder_move_to(sk_pathbuilder_t*, float x, float y);
|
||||
/**
|
||||
Add a line from the last point to the specified point (x,y). If no
|
||||
sk_pathbuilder_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_pathbuilder_line_to(sk_pathbuilder_t*, float x, float y);
|
||||
/**
|
||||
Add a quadratic bezier from the last point, approaching control
|
||||
point (x0,y0), and ending at (x1,y1). If no sk_pathbuilder_move_to() call
|
||||
has been made for this contour, the first point is automatically
|
||||
set to (0,0).
|
||||
*/
|
||||
SK_API void sk_pathbuilder_quad_to(sk_pathbuilder_t*, float x0, float y0, float x1, float y1);
|
||||
/**
|
||||
Add a conic curve from the last point, approaching control point
|
||||
(x0,y01), and ending at (x1,y1) with weight w. If no
|
||||
sk_pathbuilder_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_pathbuilder_conic_to(sk_pathbuilder_t*, float x0, float y0, float x1, float y1, float w);
|
||||
/**
|
||||
Add a cubic bezier from the last point, approaching control points
|
||||
(x0,y0) and (x1,y1), and ending at (x2,y2). If no
|
||||
sk_pathbuilder_move_to() call has been made for this contour, the first
|
||||
point is automatically set to (0,0).
|
||||
*/
|
||||
SK_API void sk_pathbuilder_cubic_to(sk_pathbuilder_t*,
|
||||
float x0, float y0,
|
||||
float x1, float y1,
|
||||
float x2, float y2);
|
||||
/**
|
||||
Close the current contour. If the current point is not equal to the
|
||||
first point of the contour, a line segment is automatically added.
|
||||
*/
|
||||
SK_API void sk_pathbuilder_close(sk_pathbuilder_t*);
|
||||
|
||||
/**
|
||||
Add a closed rectangle contour to the path.
|
||||
*/
|
||||
SK_API void sk_pathbuilder_add_rect(sk_pathbuilder_t*, const sk_rect_t*, sk_path_direction_t);
|
||||
/**
|
||||
Add a closed oval contour to the path
|
||||
*/
|
||||
SK_API void sk_pathbuilder_add_oval(sk_pathbuilder_t*, const sk_rect_t*, sk_path_direction_t);
|
||||
|
||||
/**** path *****/
|
||||
|
||||
/**
|
||||
* Return a Path from the builder, resetting the builder to its original empty state.
|
||||
*/
|
||||
SK_API sk_path_t* sk_pathbuilder_detach_path(sk_pathbuilder_t*);
|
||||
|
||||
/**
|
||||
* Return a Path from the builder. The builder reamins in its current state.
|
||||
*/
|
||||
SK_API sk_path_t* sk_pathbuilder_snapshot_path(sk_pathbuilder_t*);
|
||||
|
||||
/** Release the memory used by a sk_path_t. */
|
||||
SK_API void sk_path_delete(sk_path_t*);
|
||||
|
||||
/**
|
||||
* If the path is empty, return false and set the rect parameter to [0, 0, 0, 0].
|
||||
* else return true and set the rect parameter to the bounds of the control-points
|
||||
* of the path.
|
||||
*/
|
||||
SK_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
70
src/deps/skia/include/c/sk_picture.h
Normal file
70
src/deps/skia/include/c/sk_picture.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_picture_DEFINED
|
||||
#define sk_picture_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Create a new sk_picture_recorder_t. Its resources should be
|
||||
released with a call to sk_picture_recorder_delete().
|
||||
*/
|
||||
SK_API sk_picture_recorder_t* sk_picture_recorder_new(void);
|
||||
/**
|
||||
Release the memory and other resources used by this
|
||||
sk_picture_recorder_t.
|
||||
*/
|
||||
SK_API void sk_picture_recorder_delete(sk_picture_recorder_t*);
|
||||
|
||||
/**
|
||||
Returns the canvas that records the drawing commands
|
||||
|
||||
@param sk_rect_t* the cull rect used when recording this
|
||||
picture. Any drawing the falls outside of this
|
||||
rect is undefined, and may be drawn or it may not.
|
||||
*/
|
||||
SK_API sk_canvas_t* sk_picture_recorder_begin_recording(sk_picture_recorder_t*, const sk_rect_t*);
|
||||
/**
|
||||
Signal that the caller is done recording. This invalidates the
|
||||
canvas returned by begin_recording. Ownership of the sk_picture_t
|
||||
is passed to the caller, who must call sk_picture_unref() when
|
||||
they are done using it. The returned picture is immutable.
|
||||
*/
|
||||
SK_API sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t*);
|
||||
|
||||
/**
|
||||
Increment the reference count on the given sk_picture_t. Must be
|
||||
balanced by a call to sk_picture_unref().
|
||||
*/
|
||||
SK_API void sk_picture_ref(sk_picture_t*);
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_picture_t and any resouces it may be managing. New
|
||||
sk_picture_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_picture_unref(sk_picture_t*);
|
||||
|
||||
/**
|
||||
Returns a non-zero value unique among all pictures.
|
||||
*/
|
||||
SK_API uint32_t sk_picture_get_unique_id(sk_picture_t*);
|
||||
|
||||
/**
|
||||
Return the cull rect specified when this picture was recorded.
|
||||
*/
|
||||
SK_API sk_rect_t sk_picture_get_bounds(sk_picture_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
143
src/deps/skia/include/c/sk_shader.h
Normal file
143
src/deps/skia/include/c/sk_shader.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_shader_DEFINED
|
||||
#define sk_shader_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
SK_API void sk_shader_ref(sk_shader_t*);
|
||||
SK_API void sk_shader_unref(sk_shader_t*);
|
||||
|
||||
typedef enum {
|
||||
CLAMP_SK_SHADER_TILEMODE,
|
||||
REPEAT_SK_SHADER_TILEMODE,
|
||||
MIRROR_SK_SHADER_TILEMODE,
|
||||
} sk_shader_tilemode_t;
|
||||
|
||||
/**
|
||||
Returns a shader that generates a linear gradient between the two
|
||||
specified points.
|
||||
|
||||
@param points The start and end points for the gradient.
|
||||
@param colors The array[count] of colors, to be distributed between
|
||||
the two points
|
||||
@param colorPos May be NULL. array[count] of SkScalars, or NULL, of
|
||||
the relative position of each corresponding color
|
||||
in the colors array. If this is NULL, the the
|
||||
colors are distributed evenly between the start
|
||||
and end point. If this is not null, the values
|
||||
must begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param colorCount Must be >=2. The number of colors (and pos if not
|
||||
NULL) entries.
|
||||
@param mode The tiling mode
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2],
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
|
||||
/**
|
||||
Returns a shader that generates a radial gradient given the center
|
||||
and radius.
|
||||
|
||||
@param center The center of the circle for this gradient
|
||||
@param radius Must be positive. The radius of the circle for this
|
||||
gradient
|
||||
@param colors The array[count] of colors, to be distributed
|
||||
between the center and edge of the circle
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the center and edge of
|
||||
the circle. If this is not null, the values must
|
||||
begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param count Must be >= 2. The number of colors (and pos if not
|
||||
NULL) entries
|
||||
@param tileMode The tiling mode
|
||||
@param localMatrix May be NULL
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center,
|
||||
float radius,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
/**
|
||||
Returns a shader that generates a sweep gradient given a center.
|
||||
|
||||
@param center The coordinates of the center of the sweep
|
||||
@param colors The array[count] of colors, to be distributed around
|
||||
the center.
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the center and edge of
|
||||
the circle. If this is not null, the values must
|
||||
begin with 0, end with 1.0, and intermediate
|
||||
values must be strictly increasing.
|
||||
@param colorCount Must be >= 2. The number of colors (and pos if
|
||||
not NULL) entries
|
||||
@param localMatrix May be NULL
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
/**
|
||||
Returns a shader that generates a conical gradient given two circles, or
|
||||
returns NULL if the inputs are invalid. The gradient interprets the
|
||||
two circles according to the following HTML spec.
|
||||
http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
|
||||
|
||||
Returns a shader that generates a sweep gradient given a center.
|
||||
|
||||
@param start, startRadius Defines the first circle.
|
||||
@param end, endRadius Defines the first circle.
|
||||
@param colors The array[count] of colors, to be distributed between
|
||||
the two circles.
|
||||
@param colorPos May be NULL. The array[count] of the relative
|
||||
position of each corresponding color in the colors
|
||||
array. If this is NULL, the the colors are
|
||||
distributed evenly between the two circles. If
|
||||
this is not null, the values must begin with 0,
|
||||
end with 1.0, and intermediate values must be
|
||||
strictly increasing.
|
||||
@param colorCount Must be >= 2. The number of colors (and pos if
|
||||
not NULL) entries
|
||||
@param tileMode The tiling mode
|
||||
@param localMatrix May be NULL
|
||||
|
||||
*/
|
||||
SK_API sk_shader_t* sk_shader_new_two_point_conical_gradient(
|
||||
const sk_point_t* start,
|
||||
float startRadius,
|
||||
const sk_point_t* end,
|
||||
float endRadius,
|
||||
const sk_color_t colors[],
|
||||
const float colorPos[],
|
||||
int colorCount,
|
||||
sk_shader_tilemode_t tileMode,
|
||||
const sk_matrix_t* localMatrix);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
73
src/deps/skia/include/c/sk_surface.h
Normal file
73
src/deps/skia/include/c/sk_surface.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_surface_DEFINED
|
||||
#define sk_surface_DEFINED
|
||||
|
||||
#include "include/c/sk_types.h"
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
/**
|
||||
Return a new surface, with the memory for the pixels automatically
|
||||
allocated. If the requested surface cannot be created, or the
|
||||
request is not a supported configuration, NULL will be returned.
|
||||
|
||||
@param sk_imageinfo_t* Specify the width, height, color type, and
|
||||
alpha type for the surface.
|
||||
|
||||
@param sk_surfaceprops_t* If not NULL, specify additional non-default
|
||||
properties of the surface.
|
||||
*/
|
||||
SK_API sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*, const sk_surfaceprops_t*);
|
||||
|
||||
/**
|
||||
Create a new surface which will draw into the specified pixels
|
||||
with the specified rowbytes. If the requested surface cannot be
|
||||
created, or the request is not a supported configuration, NULL
|
||||
will be returned.
|
||||
|
||||
@param sk_imageinfo_t* Specify the width, height, color type, and
|
||||
alpha type for the surface.
|
||||
@param void* pixels Specify the location in memory where the
|
||||
destination pixels are. This memory must
|
||||
outlast this surface.
|
||||
@param size_t rowBytes Specify the difference, in bytes, between
|
||||
each adjacent row. Should be at least
|
||||
(width * sizeof(one pixel)).
|
||||
@param sk_surfaceprops_t* If not NULL, specify additional non-default
|
||||
properties of the surface.
|
||||
*/
|
||||
SK_API sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*,
|
||||
void* pixels, size_t rowBytes,
|
||||
const sk_surfaceprops_t* props);
|
||||
|
||||
/**
|
||||
Decrement the reference count. If the reference count is 1 before
|
||||
the decrement, then release both the memory holding the
|
||||
sk_surface_t and any pixel memory it may be managing. New
|
||||
sk_surface_t are created with a reference count of 1.
|
||||
*/
|
||||
SK_API void sk_surface_unref(sk_surface_t*);
|
||||
|
||||
/**
|
||||
* Return the canvas associated with this surface. Note: the canvas is owned by the surface,
|
||||
* so the returned object is only valid while the owning surface is valid.
|
||||
*/
|
||||
SK_API sk_canvas_t* sk_surface_get_canvas(sk_surface_t*);
|
||||
|
||||
/**
|
||||
* Call sk_image_unref() when the returned image is no longer used.
|
||||
*/
|
||||
SK_API sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*);
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
278
src/deps/skia/include/c/sk_types.h
Normal file
278
src/deps/skia/include/c/sk_types.h
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
||||
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
||||
|
||||
#ifndef sk_types_DEFINED
|
||||
#define sk_types_DEFINED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define SK_C_PLUS_PLUS_BEGIN_GUARD extern "C" {
|
||||
#define SK_C_PLUS_PLUS_END_GUARD }
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#define SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
#define SK_C_PLUS_PLUS_END_GUARD
|
||||
#endif
|
||||
|
||||
#if !defined(SK_API)
|
||||
#if defined(SKIA_DLL)
|
||||
#if defined(_MSC_VER)
|
||||
#if SKIA_IMPLEMENTATION
|
||||
#define SK_API __declspec(dllexport)
|
||||
#else
|
||||
#define SK_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SK_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
#define SK_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||
|
||||
typedef uint32_t sk_color_t;
|
||||
|
||||
/* This macro assumes all arguments are >=0 and <=255. */
|
||||
#define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define sk_color_get_a(c) (((c) >> 24) & 0xFF)
|
||||
#define sk_color_get_r(c) (((c) >> 16) & 0xFF)
|
||||
#define sk_color_get_g(c) (((c) >> 8) & 0xFF)
|
||||
#define sk_color_get_b(c) (((c) >> 0) & 0xFF)
|
||||
|
||||
typedef enum {
|
||||
INTERSECT_SK_CLIPTYPE,
|
||||
DIFFERENCE_SK_CLIPTYPE,
|
||||
} sk_cliptype_t;
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN_SK_PIXELGEOMETRY,
|
||||
RGB_H_SK_PIXELGEOMETRY,
|
||||
BGR_H_SK_PIXELGEOMETRY,
|
||||
RGB_V_SK_PIXELGEOMETRY,
|
||||
BGR_V_SK_PIXELGEOMETRY,
|
||||
} sk_pixelgeometry_t;
|
||||
|
||||
typedef struct {
|
||||
sk_pixelgeometry_t pixelGeometry;
|
||||
} sk_surfaceprops_t;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} sk_point_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} sk_irect_t;
|
||||
|
||||
typedef struct {
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
} sk_rect_t;
|
||||
|
||||
/**
|
||||
The sk_matrix_t struct holds a 3x3 perspective matrix for
|
||||
transforming coordinates:
|
||||
|
||||
(X,Y) = T[M]((x,y))
|
||||
X = (M[0] * x + M[1] * y + M[2]) / (M[6] * x + M[7] * y + M[8]);
|
||||
Y = (M[3] * x + M[4] * y + M[5]) / (M[6] * x + M[7] * y + M[8]);
|
||||
|
||||
Therefore, the identity matrix is
|
||||
|
||||
sk_matrix_t identity = {{1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1}};
|
||||
|
||||
A matrix that scales by sx and sy is:
|
||||
|
||||
sk_matrix_t scale = {{sx, 0, 0,
|
||||
0, sy, 0,
|
||||
0, 0, 1}};
|
||||
|
||||
A matrix that translates by tx and ty is:
|
||||
|
||||
sk_matrix_t translate = {{1, 0, tx,
|
||||
0, 1, ty,
|
||||
0, 0, 1}};
|
||||
|
||||
A matrix that rotates around the origin by A radians:
|
||||
|
||||
sk_matrix_t rotate = {{cos(A), -sin(A), 0,
|
||||
sin(A), cos(A), 0,
|
||||
0, 0, 1}};
|
||||
|
||||
Two matrixes can be concatinated by:
|
||||
|
||||
void concat_matrices(sk_matrix_t* dst,
|
||||
const sk_matrix_t* matrixU,
|
||||
const sk_matrix_t* matrixV) {
|
||||
const float* u = matrixU->mat;
|
||||
const float* v = matrixV->mat;
|
||||
sk_matrix_t result = {{
|
||||
u[0] * v[0] + u[1] * v[3] + u[2] * v[6],
|
||||
u[0] * v[1] + u[1] * v[4] + u[2] * v[7],
|
||||
u[0] * v[2] + u[1] * v[5] + u[2] * v[8],
|
||||
u[3] * v[0] + u[4] * v[3] + u[5] * v[6],
|
||||
u[3] * v[1] + u[4] * v[4] + u[5] * v[7],
|
||||
u[3] * v[2] + u[4] * v[5] + u[5] * v[8],
|
||||
u[6] * v[0] + u[7] * v[3] + u[8] * v[6],
|
||||
u[6] * v[1] + u[7] * v[4] + u[8] * v[7],
|
||||
u[6] * v[2] + u[7] * v[5] + u[8] * v[8]
|
||||
}};
|
||||
*dst = result;
|
||||
}
|
||||
*/
|
||||
typedef struct {
|
||||
float mat[9];
|
||||
} sk_matrix_t;
|
||||
|
||||
/**
|
||||
A sk_canvas_t encapsulates all of the state about drawing into a
|
||||
destination This includes a reference to the destination itself,
|
||||
and a stack of matrix/clip values.
|
||||
*/
|
||||
typedef struct sk_canvas_t sk_canvas_t;
|
||||
/**
|
||||
A sk_data_ holds an immutable data buffer.
|
||||
*/
|
||||
typedef struct sk_data_t sk_data_t;
|
||||
/**
|
||||
A sk_image_t is an abstraction for drawing a rectagle of pixels.
|
||||
The content of the image is always immutable, though the actual
|
||||
storage may change, if for example that image can be re-created via
|
||||
encoded data or other means.
|
||||
*/
|
||||
typedef struct sk_image_t sk_image_t;
|
||||
|
||||
/**
|
||||
* Describes the color components. See ICC Profiles.
|
||||
*/
|
||||
typedef struct sk_colorspace_t sk_colorspace_t;
|
||||
|
||||
/**
|
||||
* Describes an image buffer : width, height, pixel type, colorspace, etc.
|
||||
*/
|
||||
typedef struct sk_imageinfo_t sk_imageinfo_t;
|
||||
|
||||
/**
|
||||
A sk_maskfilter_t is an object that perform transformations on an
|
||||
alpha-channel mask before drawing it; it may be installed into a
|
||||
sk_paint_t. Each time a primitive is drawn, it is first
|
||||
scan-converted into a alpha mask, which os handed to the
|
||||
maskfilter, which may create a new mask is to render into the
|
||||
destination.
|
||||
*/
|
||||
typedef struct sk_maskfilter_t sk_maskfilter_t;
|
||||
/**
|
||||
A sk_paint_t holds the style and color information about how to
|
||||
draw geometries, text and bitmaps.
|
||||
*/
|
||||
typedef struct sk_paint_t sk_paint_t;
|
||||
/**
|
||||
A sk_path_t encapsulates compound (multiple contour) geometric
|
||||
paths consisting of straight line segments, quadratic curves, and
|
||||
cubic curves.
|
||||
*/
|
||||
typedef struct sk_path_t sk_path_t;
|
||||
/**
|
||||
A sk_picture_t holds recorded canvas drawing commands to be played
|
||||
back at a later time.
|
||||
*/
|
||||
typedef struct sk_picture_t sk_picture_t;
|
||||
/**
|
||||
A sk_picture_recorder_t holds a sk_canvas_t that records commands
|
||||
to create a sk_picture_t.
|
||||
*/
|
||||
typedef struct sk_picture_recorder_t sk_picture_recorder_t;
|
||||
/**
|
||||
A sk_shader_t specifies the source color(s) for what is being drawn. If a
|
||||
paint has no shader, then the paint's color is used. If the paint
|
||||
has a shader, then the shader's color(s) are use instead, but they
|
||||
are modulated by the paint's alpha.
|
||||
*/
|
||||
typedef struct sk_shader_t sk_shader_t;
|
||||
/**
|
||||
A sk_surface_t holds the destination for drawing to a canvas. For
|
||||
raster drawing, the destination is an array of pixels in memory.
|
||||
For GPU drawing, the destination is a texture or a framebuffer.
|
||||
*/
|
||||
typedef struct sk_surface_t sk_surface_t;
|
||||
|
||||
typedef enum {
|
||||
NEAREST_SK_FILTER_MODE,
|
||||
LINEAR_SK_FILTER_MODE,
|
||||
} sk_filter_mode_t;
|
||||
|
||||
typedef enum {
|
||||
NONE_SK_MIPMAP_MODE,
|
||||
NEAREST_SK_MIPMAP_MODE,
|
||||
LINEAR_SK_MIPMAP_MODE,
|
||||
} sk_mipmap_mode_t;
|
||||
|
||||
typedef struct {
|
||||
float B, C;
|
||||
} sk_cubic_resampler_t;
|
||||
|
||||
typedef struct {
|
||||
bool useCubic;
|
||||
sk_cubic_resampler_t cubic;
|
||||
sk_filter_mode_t filter;
|
||||
sk_mipmap_mode_t mipmap;
|
||||
} sk_sampling_options_t;
|
||||
|
||||
typedef enum {
|
||||
CLEAR_SK_XFERMODE_MODE,
|
||||
SRC_SK_XFERMODE_MODE,
|
||||
DST_SK_XFERMODE_MODE,
|
||||
SRCOVER_SK_XFERMODE_MODE,
|
||||
DSTOVER_SK_XFERMODE_MODE,
|
||||
SRCIN_SK_XFERMODE_MODE,
|
||||
DSTIN_SK_XFERMODE_MODE,
|
||||
SRCOUT_SK_XFERMODE_MODE,
|
||||
DSTOUT_SK_XFERMODE_MODE,
|
||||
SRCATOP_SK_XFERMODE_MODE,
|
||||
DSTATOP_SK_XFERMODE_MODE,
|
||||
XOR_SK_XFERMODE_MODE,
|
||||
PLUS_SK_XFERMODE_MODE,
|
||||
MODULATE_SK_XFERMODE_MODE,
|
||||
SCREEN_SK_XFERMODE_MODE,
|
||||
OVERLAY_SK_XFERMODE_MODE,
|
||||
DARKEN_SK_XFERMODE_MODE,
|
||||
LIGHTEN_SK_XFERMODE_MODE,
|
||||
COLORDODGE_SK_XFERMODE_MODE,
|
||||
COLORBURN_SK_XFERMODE_MODE,
|
||||
HARDLIGHT_SK_XFERMODE_MODE,
|
||||
SOFTLIGHT_SK_XFERMODE_MODE,
|
||||
DIFFERENCE_SK_XFERMODE_MODE,
|
||||
EXCLUSION_SK_XFERMODE_MODE,
|
||||
MULTIPLY_SK_XFERMODE_MODE,
|
||||
HUE_SK_XFERMODE_MODE,
|
||||
SATURATION_SK_XFERMODE_MODE,
|
||||
COLOR_SK_XFERMODE_MODE,
|
||||
LUMINOSITY_SK_XFERMODE_MODE,
|
||||
} sk_xfermode_mode_t;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SK_C_PLUS_PLUS_END_GUARD
|
||||
|
||||
#endif
|
||||
47
src/deps/skia/include/codec/BUILD.bazel
Normal file
47
src/deps/skia/include/codec/BUILD.bazel
Normal file
@@ -0,0 +1,47 @@
|
||||
load("//bazel:macros.bzl", "generated_cc_atom")
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkAndroidCodec_hdr",
|
||||
hdrs = ["SkAndroidCodec.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkCodec_hdr",
|
||||
"//include/core:SkEncodedImageFormat_hdr",
|
||||
"//include/core:SkStream_hdr",
|
||||
"//include/core:SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCodecAnimation_hdr",
|
||||
hdrs = ["SkCodecAnimation.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCodec_hdr",
|
||||
hdrs = ["SkCodec.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkCodecAnimation_hdr",
|
||||
":SkEncodedOrigin_hdr",
|
||||
"//include/core:SkColor_hdr",
|
||||
"//include/core:SkEncodedImageFormat_hdr",
|
||||
"//include/core:SkImageInfo_hdr",
|
||||
"//include/core:SkPixmap_hdr",
|
||||
"//include/core:SkSize_hdr",
|
||||
"//include/core:SkStream_hdr",
|
||||
"//include/core:SkTypes_hdr",
|
||||
"//include/core:SkYUVAPixmaps_hdr",
|
||||
"//include/private:SkEncodedInfo_hdr",
|
||||
"//include/private:SkNoncopyable_hdr",
|
||||
"//include/private:SkTemplates_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkEncodedOrigin_hdr",
|
||||
hdrs = ["SkEncodedOrigin.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = ["//include/core:SkMatrix_hdr"],
|
||||
)
|
||||
263
src/deps/skia/include/codec/SkAndroidCodec.h
Normal file
263
src/deps/skia/include/codec/SkAndroidCodec.h
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAndroidCodec_DEFINED
|
||||
#define SkAndroidCodec_DEFINED
|
||||
|
||||
#include "include/codec/SkCodec.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Abstract interface defining image codec functionality that is necessary for
|
||||
* Android.
|
||||
*/
|
||||
class SK_API SkAndroidCodec : SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* Now that SkAndroidCodec supports multiframe images, there are multiple
|
||||
* ways to handle compositing an oriented frame on top of an oriented frame
|
||||
* with different tradeoffs. SkAndroidCodec now ignores the orientation and
|
||||
* forces the client to handle it.
|
||||
*/
|
||||
enum class ExifOrientationBehavior {
|
||||
kIgnore,
|
||||
kRespect,
|
||||
};
|
||||
|
||||
/**
|
||||
* Pass ownership of an SkCodec to a newly-created SkAndroidCodec.
|
||||
*/
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromCodec(std::unique_ptr<SkCodec>);
|
||||
|
||||
/**
|
||||
* If this stream represents an encoded image that we know how to decode,
|
||||
* return an SkAndroidCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* The SkPngChunkReader handles unknown chunks in PNGs.
|
||||
* See SkCodec.h for more details.
|
||||
*
|
||||
* If NULL is returned, the stream is deleted immediately. Otherwise, the
|
||||
* SkCodec takes ownership of it, and will delete it when done with it.
|
||||
*/
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromStream(std::unique_ptr<SkStream>,
|
||||
SkPngChunkReader* = nullptr);
|
||||
|
||||
/**
|
||||
* If this data represents an encoded image that we know how to decode,
|
||||
* return an SkAndroidCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* The SkPngChunkReader handles unknown chunks in PNGs.
|
||||
* See SkCodec.h for more details.
|
||||
*/
|
||||
static std::unique_ptr<SkAndroidCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
|
||||
|
||||
virtual ~SkAndroidCodec();
|
||||
|
||||
// TODO: fInfo is now just a cache of SkCodec's SkImageInfo. No need to
|
||||
// cache and return a reference here, once Android call-sites are updated.
|
||||
const SkImageInfo& getInfo() const { return fInfo; }
|
||||
|
||||
/**
|
||||
* Return the ICC profile of the encoded data.
|
||||
*/
|
||||
const skcms_ICCProfile* getICCProfile() const {
|
||||
return fCodec->getEncodedInfo().profile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format of the encoded data.
|
||||
*/
|
||||
SkEncodedImageFormat getEncodedFormat() const { return fCodec->getEncodedFormat(); }
|
||||
|
||||
/**
|
||||
* @param requestedColorType Color type requested by the client
|
||||
*
|
||||
* |requestedColorType| may be overriden. We will default to kF16
|
||||
* for high precision images.
|
||||
*
|
||||
* In the general case, if it is possible to decode to
|
||||
* |requestedColorType|, this returns |requestedColorType|.
|
||||
* Otherwise, this returns a color type that is an appropriate
|
||||
* match for the the encoded data.
|
||||
*/
|
||||
SkColorType computeOutputColorType(SkColorType requestedColorType);
|
||||
|
||||
/**
|
||||
* @param requestedUnpremul Indicates if the client requested
|
||||
* unpremultiplied output
|
||||
*
|
||||
* Returns the appropriate alpha type to decode to. If the image
|
||||
* has alpha, the value of requestedUnpremul will be honored.
|
||||
*/
|
||||
SkAlphaType computeOutputAlphaType(bool requestedUnpremul);
|
||||
|
||||
/**
|
||||
* @param outputColorType Color type that the client will decode to.
|
||||
* @param prefColorSpace Preferred color space to decode to.
|
||||
* This may not return |prefColorSpace| for a couple reasons.
|
||||
* (1) Android Principles: 565 must be sRGB, F16 must be
|
||||
* linear sRGB, transfer function must be parametric.
|
||||
* (2) Codec Limitations: F16 requires a linear color space.
|
||||
*
|
||||
* Returns the appropriate color space to decode to.
|
||||
*/
|
||||
sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
|
||||
sk_sp<SkColorSpace> prefColorSpace = nullptr);
|
||||
|
||||
/**
|
||||
* Compute the appropriate sample size to get to |size|.
|
||||
*
|
||||
* @param size As an input parameter, the desired output size of
|
||||
* the decode. As an output parameter, the smallest sampled size
|
||||
* larger than the input.
|
||||
* @return the sample size to set AndroidOptions::fSampleSize to decode
|
||||
* to the output |size|.
|
||||
*/
|
||||
int computeSampleSize(SkISize* size) const;
|
||||
|
||||
/**
|
||||
* Returns the dimensions of the scaled output image, for an input
|
||||
* sampleSize.
|
||||
*
|
||||
* When the sample size divides evenly into the original dimensions, the
|
||||
* scaled output dimensions will simply be equal to the original
|
||||
* dimensions divided by the sample size.
|
||||
*
|
||||
* When the sample size does not divide even into the original
|
||||
* dimensions, the codec may round up or down, depending on what is most
|
||||
* efficient to decode.
|
||||
*
|
||||
* Finally, the codec will always recommend a non-zero output, so the output
|
||||
* dimension will always be one if the sampleSize is greater than the
|
||||
* original dimension.
|
||||
*/
|
||||
SkISize getSampledDimensions(int sampleSize) const;
|
||||
|
||||
/**
|
||||
* Return (via desiredSubset) a subset which can decoded from this codec,
|
||||
* or false if the input subset is invalid.
|
||||
*
|
||||
* @param desiredSubset in/out parameter
|
||||
* As input, a desired subset of the original bounds
|
||||
* (as specified by getInfo).
|
||||
* As output, if true is returned, desiredSubset may
|
||||
* have been modified to a subset which is
|
||||
* supported. Although a particular change may have
|
||||
* been made to desiredSubset to create something
|
||||
* supported, it is possible other changes could
|
||||
* result in a valid subset. If false is returned,
|
||||
* desiredSubset's value is undefined.
|
||||
* @return true If the input desiredSubset is valid.
|
||||
* desiredSubset may be modified to a subset
|
||||
* supported by the codec.
|
||||
* false If desiredSubset is invalid (NULL or not fully
|
||||
* contained within the image).
|
||||
*/
|
||||
bool getSupportedSubset(SkIRect* desiredSubset) const;
|
||||
// TODO: Rename SkCodec::getValidSubset() to getSupportedSubset()
|
||||
|
||||
/**
|
||||
* Returns the dimensions of the scaled, partial output image, for an
|
||||
* input sampleSize and subset.
|
||||
*
|
||||
* @param sampleSize Factor to scale down by.
|
||||
* @param subset Must be a valid subset of the original image
|
||||
* dimensions and a subset supported by SkAndroidCodec.
|
||||
* getSubset() can be used to obtain a subset supported
|
||||
* by SkAndroidCodec.
|
||||
* @return Size of the scaled partial image. Or zero size
|
||||
* if either of the inputs is invalid.
|
||||
*/
|
||||
SkISize getSampledSubsetDimensions(int sampleSize, const SkIRect& subset) const;
|
||||
|
||||
/**
|
||||
* Additional options to pass to getAndroidPixels().
|
||||
*/
|
||||
// FIXME: It's a bit redundant to name these AndroidOptions when this class is already
|
||||
// called SkAndroidCodec. On the other hand, it's may be a bit confusing to call
|
||||
// these Options when SkCodec has a slightly different set of Options. Maybe these
|
||||
// should be DecodeOptions or SamplingOptions?
|
||||
struct AndroidOptions : public SkCodec::Options {
|
||||
AndroidOptions()
|
||||
: SkCodec::Options()
|
||||
, fSampleSize(1)
|
||||
{}
|
||||
|
||||
/**
|
||||
* The client may provide an integer downscale factor for the decode.
|
||||
* The codec may implement this downscaling by sampling or another
|
||||
* method if it is more efficient.
|
||||
*
|
||||
* The default is 1, representing no downscaling.
|
||||
*/
|
||||
int fSampleSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode into the given pixels, a block of memory of size at
|
||||
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
|
||||
* bytesPerPixel)
|
||||
*
|
||||
* Repeated calls to this function should give the same results,
|
||||
* allowing the PixelRef to be immutable.
|
||||
*
|
||||
* @param info A description of the format (config, size)
|
||||
* expected by the caller. This can simply be identical
|
||||
* to the info returned by getInfo().
|
||||
*
|
||||
* This contract also allows the caller to specify
|
||||
* different output-configs, which the implementation can
|
||||
* decide to support or not.
|
||||
*
|
||||
* A size that does not match getInfo() implies a request
|
||||
* to scale or subset. If the codec cannot perform this
|
||||
* scaling or subsetting, it will return an error code.
|
||||
*
|
||||
* The AndroidOptions object is also used to specify any requested scaling or subsetting
|
||||
* using options->fSampleSize and options->fSubset. If NULL, the defaults (as specified above
|
||||
* for AndroidOptions) are used.
|
||||
*
|
||||
* @return Result kSuccess, or another value explaining the type of failure.
|
||||
*/
|
||||
// FIXME: It's a bit redundant to name this getAndroidPixels() when this class is already
|
||||
// called SkAndroidCodec. On the other hand, it's may be a bit confusing to call
|
||||
// this getPixels() when it is a slightly different API than SkCodec's getPixels().
|
||||
// Maybe this should be decode() or decodeSubset()?
|
||||
SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
||||
const AndroidOptions* options);
|
||||
|
||||
/**
|
||||
* Simplified version of getAndroidPixels() where we supply the default AndroidOptions as
|
||||
* specified above for AndroidOptions. It will not perform any scaling or subsetting.
|
||||
*/
|
||||
SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
|
||||
|
||||
SkCodec::Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
|
||||
return this->getAndroidPixels(info, pixels, rowBytes);
|
||||
}
|
||||
|
||||
SkCodec* codec() const { return fCodec.get(); }
|
||||
|
||||
protected:
|
||||
SkAndroidCodec(SkCodec*);
|
||||
|
||||
virtual SkISize onGetSampledDimensions(int sampleSize) const = 0;
|
||||
|
||||
virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0;
|
||||
|
||||
virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels,
|
||||
size_t rowBytes, const AndroidOptions& options) = 0;
|
||||
|
||||
private:
|
||||
const SkImageInfo fInfo;
|
||||
std::unique_ptr<SkCodec> fCodec;
|
||||
};
|
||||
#endif // SkAndroidCodec_DEFINED
|
||||
992
src/deps/skia/include/codec/SkCodec.h
Normal file
992
src/deps/skia/include/codec/SkCodec.h
Normal file
@@ -0,0 +1,992 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCodec_DEFINED
|
||||
#define SkCodec_DEFINED
|
||||
|
||||
#include "include/codec/SkCodecAnimation.h"
|
||||
#include "include/codec/SkEncodedOrigin.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkYUVAPixmaps.h"
|
||||
#include "include/private/SkEncodedInfo.h"
|
||||
#include "include/private/SkNoncopyable.h"
|
||||
#include "include/private/SkTemplates.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class SkAndroidCodec;
|
||||
class SkColorSpace;
|
||||
class SkData;
|
||||
class SkFrameHolder;
|
||||
class SkImage;
|
||||
class SkPngChunkReader;
|
||||
class SkSampler;
|
||||
|
||||
namespace DM {
|
||||
class CodecSrc;
|
||||
class ColorCodecSrc;
|
||||
} // namespace DM
|
||||
|
||||
/**
|
||||
* Abstraction layer directly on top of an image codec.
|
||||
*/
|
||||
class SK_API SkCodec : SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Minimum number of bytes that must be buffered in SkStream input.
|
||||
*
|
||||
* An SkStream passed to NewFromStream must be able to use this many
|
||||
* bytes to determine the image type. Then the same SkStream must be
|
||||
* passed to the correct decoder to read from the beginning.
|
||||
*
|
||||
* This can be accomplished by implementing peek() to support peeking
|
||||
* this many bytes, or by implementing rewind() to be able to rewind()
|
||||
* after reading this many bytes.
|
||||
*/
|
||||
static constexpr size_t MinBufferedBytesNeeded() { return 32; }
|
||||
|
||||
/**
|
||||
* Error codes for various SkCodec methods.
|
||||
*/
|
||||
enum Result {
|
||||
/**
|
||||
* General return value for success.
|
||||
*/
|
||||
kSuccess,
|
||||
/**
|
||||
* The input is incomplete. A partial image was generated.
|
||||
*/
|
||||
kIncompleteInput,
|
||||
/**
|
||||
* Like kIncompleteInput, except the input had an error.
|
||||
*
|
||||
* If returned from an incremental decode, decoding cannot continue,
|
||||
* even with more data.
|
||||
*/
|
||||
kErrorInInput,
|
||||
/**
|
||||
* The generator cannot convert to match the request, ignoring
|
||||
* dimensions.
|
||||
*/
|
||||
kInvalidConversion,
|
||||
/**
|
||||
* The generator cannot scale to requested size.
|
||||
*/
|
||||
kInvalidScale,
|
||||
/**
|
||||
* Parameters (besides info) are invalid. e.g. NULL pixels, rowBytes
|
||||
* too small, etc.
|
||||
*/
|
||||
kInvalidParameters,
|
||||
/**
|
||||
* The input did not contain a valid image.
|
||||
*/
|
||||
kInvalidInput,
|
||||
/**
|
||||
* Fulfilling this request requires rewinding the input, which is not
|
||||
* supported for this input.
|
||||
*/
|
||||
kCouldNotRewind,
|
||||
/**
|
||||
* An internal error, such as OOM.
|
||||
*/
|
||||
kInternalError,
|
||||
/**
|
||||
* This method is not implemented by this codec.
|
||||
* FIXME: Perhaps this should be kUnsupported?
|
||||
*/
|
||||
kUnimplemented,
|
||||
};
|
||||
|
||||
/**
|
||||
* Readable string representing the error code.
|
||||
*/
|
||||
static const char* ResultToString(Result);
|
||||
|
||||
/**
|
||||
* For container formats that contain both still images and image sequences,
|
||||
* instruct the decoder how the output should be selected. (Refer to comments
|
||||
* for each value for more details.)
|
||||
*/
|
||||
enum class SelectionPolicy {
|
||||
/**
|
||||
* If the container format contains both still images and image sequences,
|
||||
* SkCodec should choose one of the still images. This is the default.
|
||||
*/
|
||||
kPreferStillImage,
|
||||
/**
|
||||
* If the container format contains both still images and image sequences,
|
||||
* SkCodec should choose one of the image sequences for animation.
|
||||
*/
|
||||
kPreferAnimation,
|
||||
};
|
||||
|
||||
/**
|
||||
* If this stream represents an encoded image that we know how to decode,
|
||||
* return an SkCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* As stated above, this call must be able to peek or read
|
||||
* MinBufferedBytesNeeded to determine the correct format, and then start
|
||||
* reading from the beginning. First it will attempt to peek, and it
|
||||
* assumes that if less than MinBufferedBytesNeeded bytes (but more than
|
||||
* zero) are returned, this is because the stream is shorter than this,
|
||||
* so falling back to reading would not provide more data. If peek()
|
||||
* returns zero bytes, this call will instead attempt to read(). This
|
||||
* will require that the stream can be rewind()ed.
|
||||
*
|
||||
* If Result is not NULL, it will be set to either kSuccess if an SkCodec
|
||||
* is returned or a reason for the failure if NULL is returned.
|
||||
*
|
||||
* If SkPngChunkReader is not NULL, take a ref and pass it to libpng if
|
||||
* the image is a png.
|
||||
*
|
||||
* If the SkPngChunkReader is not NULL then:
|
||||
* If the image is not a PNG, the SkPngChunkReader will be ignored.
|
||||
* If the image is a PNG, the SkPngChunkReader will be reffed.
|
||||
* If the PNG has unknown chunks, the SkPngChunkReader will be used
|
||||
* to handle these chunks. SkPngChunkReader will be called to read
|
||||
* any unknown chunk at any point during the creation of the codec
|
||||
* or the decode. Note that if SkPngChunkReader fails to read a
|
||||
* chunk, this could result in a failure to create the codec or a
|
||||
* failure to decode the image.
|
||||
* If the PNG does not contain unknown chunks, the SkPngChunkReader
|
||||
* will not be used or modified.
|
||||
*
|
||||
* If NULL is returned, the stream is deleted immediately. Otherwise, the
|
||||
* SkCodec takes ownership of it, and will delete it when done with it.
|
||||
*/
|
||||
static std::unique_ptr<SkCodec> MakeFromStream(
|
||||
std::unique_ptr<SkStream>, Result* = nullptr,
|
||||
SkPngChunkReader* = nullptr,
|
||||
SelectionPolicy selectionPolicy = SelectionPolicy::kPreferStillImage);
|
||||
|
||||
/**
|
||||
* If this data represents an encoded image that we know how to decode,
|
||||
* return an SkCodec that can decode it. Otherwise return NULL.
|
||||
*
|
||||
* If the SkPngChunkReader is not NULL then:
|
||||
* If the image is not a PNG, the SkPngChunkReader will be ignored.
|
||||
* If the image is a PNG, the SkPngChunkReader will be reffed.
|
||||
* If the PNG has unknown chunks, the SkPngChunkReader will be used
|
||||
* to handle these chunks. SkPngChunkReader will be called to read
|
||||
* any unknown chunk at any point during the creation of the codec
|
||||
* or the decode. Note that if SkPngChunkReader fails to read a
|
||||
* chunk, this could result in a failure to create the codec or a
|
||||
* failure to decode the image.
|
||||
* If the PNG does not contain unknown chunks, the SkPngChunkReader
|
||||
* will not be used or modified.
|
||||
*/
|
||||
static std::unique_ptr<SkCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
|
||||
|
||||
virtual ~SkCodec();
|
||||
|
||||
/**
|
||||
* Return a reasonable SkImageInfo to decode into.
|
||||
*
|
||||
* If the image has an ICC profile that does not map to an SkColorSpace,
|
||||
* the returned SkImageInfo will use SRGB.
|
||||
*/
|
||||
SkImageInfo getInfo() const { return fEncodedInfo.makeImageInfo(); }
|
||||
|
||||
SkISize dimensions() const { return {fEncodedInfo.width(), fEncodedInfo.height()}; }
|
||||
SkIRect bounds() const {
|
||||
return SkIRect::MakeWH(fEncodedInfo.width(), fEncodedInfo.height());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ICC profile of the encoded data.
|
||||
*/
|
||||
const skcms_ICCProfile* getICCProfile() const {
|
||||
return this->getEncodedInfo().profile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image orientation stored in the EXIF data.
|
||||
* If there is no EXIF data, or if we cannot read the EXIF data, returns kTopLeft.
|
||||
*/
|
||||
SkEncodedOrigin getOrigin() const { return fOrigin; }
|
||||
|
||||
/**
|
||||
* Return a size that approximately supports the desired scale factor.
|
||||
* The codec may not be able to scale efficiently to the exact scale
|
||||
* factor requested, so return a size that approximates that scale.
|
||||
* The returned value is the codec's suggestion for the closest valid
|
||||
* scale that it can natively support
|
||||
*/
|
||||
SkISize getScaledDimensions(float desiredScale) const {
|
||||
// Negative and zero scales are errors.
|
||||
SkASSERT(desiredScale > 0.0f);
|
||||
if (desiredScale <= 0.0f) {
|
||||
return SkISize::Make(0, 0);
|
||||
}
|
||||
|
||||
// Upscaling is not supported. Return the original size if the client
|
||||
// requests an upscale.
|
||||
if (desiredScale >= 1.0f) {
|
||||
return this->dimensions();
|
||||
}
|
||||
return this->onGetScaledDimensions(desiredScale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return (via desiredSubset) a subset which can decoded from this codec,
|
||||
* or false if this codec cannot decode subsets or anything similar to
|
||||
* desiredSubset.
|
||||
*
|
||||
* @param desiredSubset In/out parameter. As input, a desired subset of
|
||||
* the original bounds (as specified by getInfo). If true is returned,
|
||||
* desiredSubset may have been modified to a subset which is
|
||||
* supported. Although a particular change may have been made to
|
||||
* desiredSubset to create something supported, it is possible other
|
||||
* changes could result in a valid subset.
|
||||
* If false is returned, desiredSubset's value is undefined.
|
||||
* @return true if this codec supports decoding desiredSubset (as
|
||||
* returned, potentially modified)
|
||||
*/
|
||||
bool getValidSubset(SkIRect* desiredSubset) const {
|
||||
return this->onGetValidSubset(desiredSubset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format of the encoded data.
|
||||
*/
|
||||
SkEncodedImageFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
|
||||
|
||||
/**
|
||||
* Whether or not the memory passed to getPixels is zero initialized.
|
||||
*/
|
||||
enum ZeroInitialized {
|
||||
/**
|
||||
* The memory passed to getPixels is zero initialized. The SkCodec
|
||||
* may take advantage of this by skipping writing zeroes.
|
||||
*/
|
||||
kYes_ZeroInitialized,
|
||||
/**
|
||||
* The memory passed to getPixels has not been initialized to zero,
|
||||
* so the SkCodec must write all zeroes to memory.
|
||||
*
|
||||
* This is the default. It will be used if no Options struct is used.
|
||||
*/
|
||||
kNo_ZeroInitialized,
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional options to pass to getPixels.
|
||||
*/
|
||||
struct Options {
|
||||
Options()
|
||||
: fZeroInitialized(kNo_ZeroInitialized)
|
||||
, fSubset(nullptr)
|
||||
, fFrameIndex(0)
|
||||
, fPriorFrame(kNoFrame)
|
||||
{}
|
||||
|
||||
ZeroInitialized fZeroInitialized;
|
||||
/**
|
||||
* If not NULL, represents a subset of the original image to decode.
|
||||
* Must be within the bounds returned by getInfo().
|
||||
* If the EncodedFormat is SkEncodedImageFormat::kWEBP (the only one which
|
||||
* currently supports subsets), the top and left values must be even.
|
||||
*
|
||||
* In getPixels and incremental decode, we will attempt to decode the
|
||||
* exact rectangular subset specified by fSubset.
|
||||
*
|
||||
* In a scanline decode, it does not make sense to specify a subset
|
||||
* top or subset height, since the client already controls which rows
|
||||
* to get and which rows to skip. During scanline decodes, we will
|
||||
* require that the subset top be zero and the subset height be equal
|
||||
* to the full height. We will, however, use the values of
|
||||
* subset left and subset width to decode partial scanlines on calls
|
||||
* to getScanlines().
|
||||
*/
|
||||
const SkIRect* fSubset;
|
||||
|
||||
/**
|
||||
* The frame to decode.
|
||||
*
|
||||
* Only meaningful for multi-frame images.
|
||||
*/
|
||||
int fFrameIndex;
|
||||
|
||||
/**
|
||||
* If not kNoFrame, the dst already contains the prior frame at this index.
|
||||
*
|
||||
* Only meaningful for multi-frame images.
|
||||
*
|
||||
* If fFrameIndex needs to be blended with a prior frame (as reported by
|
||||
* getFrameInfo[fFrameIndex].fRequiredFrame), the client can set this to
|
||||
* any non-kRestorePrevious frame in [fRequiredFrame, fFrameIndex) to
|
||||
* indicate that that frame is already in the dst. Options.fZeroInitialized
|
||||
* is ignored in this case.
|
||||
*
|
||||
* If set to kNoFrame, the codec will decode any necessary required frame(s) first.
|
||||
*/
|
||||
int fPriorFrame;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode into the given pixels, a block of memory of size at
|
||||
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
|
||||
* bytesPerPixel)
|
||||
*
|
||||
* Repeated calls to this function should give the same results,
|
||||
* allowing the PixelRef to be immutable.
|
||||
*
|
||||
* @param info A description of the format (config, size)
|
||||
* expected by the caller. This can simply be identical
|
||||
* to the info returned by getInfo().
|
||||
*
|
||||
* This contract also allows the caller to specify
|
||||
* different output-configs, which the implementation can
|
||||
* decide to support or not.
|
||||
*
|
||||
* A size that does not match getInfo() implies a request
|
||||
* to scale. If the generator cannot perform this scale,
|
||||
* it will return kInvalidScale.
|
||||
*
|
||||
* If the info contains a non-null SkColorSpace, the codec
|
||||
* will perform the appropriate color space transformation.
|
||||
*
|
||||
* If the caller passes in the SkColorSpace that maps to the
|
||||
* ICC profile reported by getICCProfile(), the color space
|
||||
* transformation is a no-op.
|
||||
*
|
||||
* If the caller passes a null SkColorSpace, no color space
|
||||
* transformation will be done.
|
||||
*
|
||||
* If a scanline decode is in progress, scanline mode will end, requiring the client to call
|
||||
* startScanlineDecode() in order to return to decoding scanlines.
|
||||
*
|
||||
* @return Result kSuccess, or another value explaining the type of failure.
|
||||
*/
|
||||
Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*);
|
||||
|
||||
/**
|
||||
* Simplified version of getPixels() that uses the default Options.
|
||||
*/
|
||||
Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
|
||||
return this->getPixels(info, pixels, rowBytes, nullptr);
|
||||
}
|
||||
|
||||
Result getPixels(const SkPixmap& pm, const Options* opts = nullptr) {
|
||||
return this->getPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an image containing the pixels.
|
||||
*/
|
||||
std::tuple<sk_sp<SkImage>, SkCodec::Result> getImage(const SkImageInfo& info,
|
||||
const Options* opts = nullptr);
|
||||
std::tuple<sk_sp<SkImage>, SkCodec::Result> getImage();
|
||||
|
||||
/**
|
||||
* If decoding to YUV is supported, this returns true. Otherwise, this
|
||||
* returns false and the caller will ignore output parameter yuvaPixmapInfo.
|
||||
*
|
||||
* @param supportedDataTypes Indicates the data type/planar config combinations that are
|
||||
* supported by the caller. If the generator supports decoding to
|
||||
* YUV(A), but not as a type in supportedDataTypes, this method
|
||||
* returns false.
|
||||
* @param yuvaPixmapInfo Output parameter that specifies the planar configuration, subsampling,
|
||||
* orientation, chroma siting, plane color types, and row bytes.
|
||||
*/
|
||||
bool queryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes& supportedDataTypes,
|
||||
SkYUVAPixmapInfo* yuvaPixmapInfo) const;
|
||||
|
||||
/**
|
||||
* Returns kSuccess, or another value explaining the type of failure.
|
||||
* This always attempts to perform a full decode. To get the planar
|
||||
* configuration without decoding use queryYUVAInfo().
|
||||
*
|
||||
* @param yuvaPixmaps Contains preallocated pixmaps configured according to a successful call
|
||||
* to queryYUVAInfo().
|
||||
*/
|
||||
Result getYUVAPlanes(const SkYUVAPixmaps& yuvaPixmaps);
|
||||
|
||||
/**
|
||||
* Prepare for an incremental decode with the specified options.
|
||||
*
|
||||
* This may require a rewind.
|
||||
*
|
||||
* If kIncompleteInput is returned, may be called again after more data has
|
||||
* been provided to the source SkStream.
|
||||
*
|
||||
* @param dstInfo Info of the destination. If the dimensions do not match
|
||||
* those of getInfo, this implies a scale.
|
||||
* @param dst Memory to write to. Needs to be large enough to hold the subset,
|
||||
* if present, or the full image as described in dstInfo.
|
||||
* @param options Contains decoding options, including if memory is zero
|
||||
* initialized and whether to decode a subset.
|
||||
* @return Enum representing success or reason for failure.
|
||||
*/
|
||||
Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
|
||||
const Options*);
|
||||
|
||||
Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes) {
|
||||
return this->startIncrementalDecode(dstInfo, dst, rowBytes, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start/continue the incremental decode.
|
||||
*
|
||||
* Not valid to call before a call to startIncrementalDecode() returns
|
||||
* kSuccess.
|
||||
*
|
||||
* If kIncompleteInput is returned, may be called again after more data has
|
||||
* been provided to the source SkStream.
|
||||
*
|
||||
* Unlike getPixels and getScanlines, this does not do any filling. This is
|
||||
* left up to the caller, since they may be skipping lines or continuing the
|
||||
* decode later. In the latter case, they may choose to initialize all lines
|
||||
* first, or only initialize the remaining lines after the first call.
|
||||
*
|
||||
* @param rowsDecoded Optional output variable returning the total number of
|
||||
* lines initialized. Only meaningful if this method returns kIncompleteInput.
|
||||
* Otherwise the implementation may not set it.
|
||||
* Note that some implementations may have initialized this many rows, but
|
||||
* not necessarily finished those rows (e.g. interlaced PNG). This may be
|
||||
* useful for determining what rows the client needs to initialize.
|
||||
* @return kSuccess if all lines requested in startIncrementalDecode have
|
||||
* been completely decoded. kIncompleteInput otherwise.
|
||||
*/
|
||||
Result incrementalDecode(int* rowsDecoded = nullptr) {
|
||||
if (!fStartedIncrementalDecode) {
|
||||
return kInvalidParameters;
|
||||
}
|
||||
return this->onIncrementalDecode(rowsDecoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* The remaining functions revolve around decoding scanlines.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare for a scanline decode with the specified options.
|
||||
*
|
||||
* After this call, this class will be ready to decode the first scanline.
|
||||
*
|
||||
* This must be called in order to call getScanlines or skipScanlines.
|
||||
*
|
||||
* This may require rewinding the stream.
|
||||
*
|
||||
* Not all SkCodecs support this.
|
||||
*
|
||||
* @param dstInfo Info of the destination. If the dimensions do not match
|
||||
* those of getInfo, this implies a scale.
|
||||
* @param options Contains decoding options, including if memory is zero
|
||||
* initialized.
|
||||
* @return Enum representing success or reason for failure.
|
||||
*/
|
||||
Result startScanlineDecode(const SkImageInfo& dstInfo, const Options* options);
|
||||
|
||||
/**
|
||||
* Simplified version of startScanlineDecode() that uses the default Options.
|
||||
*/
|
||||
Result startScanlineDecode(const SkImageInfo& dstInfo) {
|
||||
return this->startScanlineDecode(dstInfo, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the next countLines scanlines into dst.
|
||||
*
|
||||
* Not valid to call before calling startScanlineDecode().
|
||||
*
|
||||
* @param dst Must be non-null, and large enough to hold countLines
|
||||
* scanlines of size rowBytes.
|
||||
* @param countLines Number of lines to write.
|
||||
* @param rowBytes Number of bytes per row. Must be large enough to hold
|
||||
* a scanline based on the SkImageInfo used to create this object.
|
||||
* @return the number of lines successfully decoded. If this value is
|
||||
* less than countLines, this will fill the remaining lines with a
|
||||
* default value.
|
||||
*/
|
||||
int getScanlines(void* dst, int countLines, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* Skip count scanlines.
|
||||
*
|
||||
* Not valid to call before calling startScanlineDecode().
|
||||
*
|
||||
* The default version just calls onGetScanlines and discards the dst.
|
||||
* NOTE: If skipped lines are the only lines with alpha, this default
|
||||
* will make reallyHasAlpha return true, when it could have returned
|
||||
* false.
|
||||
*
|
||||
* @return true if the scanlines were successfully skipped
|
||||
* false on failure, possible reasons for failure include:
|
||||
* An incomplete input image stream.
|
||||
* Calling this function before calling startScanlineDecode().
|
||||
* If countLines is less than zero or so large that it moves
|
||||
* the current scanline past the end of the image.
|
||||
*/
|
||||
bool skipScanlines(int countLines);
|
||||
|
||||
/**
|
||||
* The order in which rows are output from the scanline decoder is not the
|
||||
* same for all variations of all image types. This explains the possible
|
||||
* output row orderings.
|
||||
*/
|
||||
enum SkScanlineOrder {
|
||||
/*
|
||||
* By far the most common, this indicates that the image can be decoded
|
||||
* reliably using the scanline decoder, and that rows will be output in
|
||||
* the logical order.
|
||||
*/
|
||||
kTopDown_SkScanlineOrder,
|
||||
|
||||
/*
|
||||
* This indicates that the scanline decoder reliably outputs rows, but
|
||||
* they will be returned in reverse order. If the scanline format is
|
||||
* kBottomUp, the nextScanline() API can be used to determine the actual
|
||||
* y-coordinate of the next output row, but the client is not forced
|
||||
* to take advantage of this, given that it's not too tough to keep
|
||||
* track independently.
|
||||
*
|
||||
* For full image decodes, it is safe to get all of the scanlines at
|
||||
* once, since the decoder will handle inverting the rows as it
|
||||
* decodes.
|
||||
*
|
||||
* For subset decodes and sampling, it is simplest to get and skip
|
||||
* scanlines one at a time, using the nextScanline() API. It is
|
||||
* possible to ask for larger chunks at a time, but this should be used
|
||||
* with caution. As with full image decodes, the decoder will handle
|
||||
* inverting the requested rows, but rows will still be delivered
|
||||
* starting from the bottom of the image.
|
||||
*
|
||||
* Upside down bmps are an example.
|
||||
*/
|
||||
kBottomUp_SkScanlineOrder,
|
||||
};
|
||||
|
||||
/**
|
||||
* An enum representing the order in which scanlines will be returned by
|
||||
* the scanline decoder.
|
||||
*
|
||||
* This is undefined before startScanlineDecode() is called.
|
||||
*/
|
||||
SkScanlineOrder getScanlineOrder() const { return this->onGetScanlineOrder(); }
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate of the next row to be returned by the scanline
|
||||
* decoder.
|
||||
*
|
||||
* This will equal fCurrScanline, except in the case of strangely
|
||||
* encoded image types (bottom-up bmps).
|
||||
*
|
||||
* Results are undefined when not in scanline decoding mode.
|
||||
*/
|
||||
int nextScanline() const { return this->outputScanline(fCurrScanline); }
|
||||
|
||||
/**
|
||||
* Returns the output y-coordinate of the row that corresponds to an input
|
||||
* y-coordinate. The input y-coordinate represents where the scanline
|
||||
* is located in the encoded data.
|
||||
*
|
||||
* This will equal inputScanline, except in the case of strangely
|
||||
* encoded image types (bottom-up bmps, interlaced gifs).
|
||||
*/
|
||||
int outputScanline(int inputScanline) const;
|
||||
|
||||
/**
|
||||
* Return the number of frames in the image.
|
||||
*
|
||||
* May require reading through the stream.
|
||||
*/
|
||||
int getFrameCount() {
|
||||
return this->onGetFrameCount();
|
||||
}
|
||||
|
||||
// Sentinel value used when a frame index implies "no frame":
|
||||
// - FrameInfo::fRequiredFrame set to this value means the frame
|
||||
// is independent.
|
||||
// - Options::fPriorFrame set to this value means no (relevant) prior frame
|
||||
// is residing in dst's memory.
|
||||
static constexpr int kNoFrame = -1;
|
||||
|
||||
// This transitional definition was added in August 2018, and will eventually be removed.
|
||||
#ifdef SK_LEGACY_SKCODEC_NONE_ENUM
|
||||
static constexpr int kNone = kNoFrame;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Information about individual frames in a multi-framed image.
|
||||
*/
|
||||
struct FrameInfo {
|
||||
/**
|
||||
* The frame that this frame needs to be blended with, or
|
||||
* kNoFrame if this frame is independent (so it can be
|
||||
* drawn over an uninitialized buffer).
|
||||
*
|
||||
* Note that this is the *earliest* frame that can be used
|
||||
* for blending. Any frame from [fRequiredFrame, i) can be
|
||||
* used, unless its fDisposalMethod is kRestorePrevious.
|
||||
*/
|
||||
int fRequiredFrame;
|
||||
|
||||
/**
|
||||
* Number of milliseconds to show this frame.
|
||||
*/
|
||||
int fDuration;
|
||||
|
||||
/**
|
||||
* Whether the end marker for this frame is contained in the stream.
|
||||
*
|
||||
* Note: this does not guarantee that an attempt to decode will be complete.
|
||||
* There could be an error in the stream.
|
||||
*/
|
||||
bool fFullyReceived;
|
||||
|
||||
/**
|
||||
* This is conservative; it will still return non-opaque if e.g. a
|
||||
* color index-based frame has a color with alpha but does not use it.
|
||||
*/
|
||||
SkAlphaType fAlphaType;
|
||||
|
||||
/**
|
||||
* Whether the updated rectangle contains alpha.
|
||||
*
|
||||
* This is conservative; it will still be set to true if e.g. a color
|
||||
* index-based frame has a color with alpha but does not use it. In
|
||||
* addition, it may be set to true, even if the final frame, after
|
||||
* blending, is opaque.
|
||||
*/
|
||||
bool fHasAlphaWithinBounds;
|
||||
|
||||
/**
|
||||
* How this frame should be modified before decoding the next one.
|
||||
*/
|
||||
SkCodecAnimation::DisposalMethod fDisposalMethod;
|
||||
|
||||
/**
|
||||
* How this frame should blend with the prior frame.
|
||||
*/
|
||||
SkCodecAnimation::Blend fBlend;
|
||||
|
||||
/**
|
||||
* The rectangle updated by this frame.
|
||||
*
|
||||
* It may be empty, if the frame does not change the image. It will
|
||||
* always be contained by SkCodec::dimensions().
|
||||
*/
|
||||
SkIRect fFrameRect;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return info about a single frame.
|
||||
*
|
||||
* Does not read through the stream, so it should be called after
|
||||
* getFrameCount() to parse any frames that have not already been parsed.
|
||||
*
|
||||
* Only supported by animated (multi-frame) codecs. Note that this is a
|
||||
* property of the codec (the SkCodec subclass), not the image.
|
||||
*
|
||||
* To elaborate, some codecs support animation (e.g. GIF). Others do not
|
||||
* (e.g. BMP). Animated codecs can still represent single frame images.
|
||||
* Calling getFrameInfo(0, etc) will return true for a single frame GIF
|
||||
* even if the overall image is not animated (in that the pixels on screen
|
||||
* do not change over time). When incrementally decoding a GIF image, we
|
||||
* might only know that there's a single frame *so far*.
|
||||
*
|
||||
* For non-animated SkCodec subclasses, it's sufficient but not necessary
|
||||
* for this method to always return false.
|
||||
*/
|
||||
bool getFrameInfo(int index, FrameInfo* info) const {
|
||||
if (index < 0) {
|
||||
return false;
|
||||
}
|
||||
return this->onGetFrameInfo(index, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return info about all the frames in the image.
|
||||
*
|
||||
* May require reading through the stream to determine info about the
|
||||
* frames (including the count).
|
||||
*
|
||||
* As such, future decoding calls may require a rewind.
|
||||
*
|
||||
* This may return an empty vector for non-animated codecs. See the
|
||||
* getFrameInfo(int, FrameInfo*) comment.
|
||||
*/
|
||||
std::vector<FrameInfo> getFrameInfo();
|
||||
|
||||
static constexpr int kRepetitionCountInfinite = -1;
|
||||
|
||||
/**
|
||||
* Return the number of times to repeat, if this image is animated. This number does not
|
||||
* include the first play through of each frame. For example, a repetition count of 4 means
|
||||
* that each frame is played 5 times and then the animation stops.
|
||||
*
|
||||
* It can return kRepetitionCountInfinite, a negative number, meaning that the animation
|
||||
* should loop forever.
|
||||
*
|
||||
* May require reading the stream to find the repetition count.
|
||||
*
|
||||
* As such, future decoding calls may require a rewind.
|
||||
*
|
||||
* For still (non-animated) image codecs, this will return 0.
|
||||
*/
|
||||
int getRepetitionCount() {
|
||||
return this->onGetRepetitionCount();
|
||||
}
|
||||
|
||||
// Register a decoder at runtime by passing two function pointers:
|
||||
// - peek() to return true if the span of bytes appears to be your encoded format;
|
||||
// - make() to attempt to create an SkCodec from the given stream.
|
||||
// Not thread safe.
|
||||
static void Register(
|
||||
bool (*peek)(const void*, size_t),
|
||||
std::unique_ptr<SkCodec> (*make)(std::unique_ptr<SkStream>, SkCodec::Result*));
|
||||
|
||||
protected:
|
||||
const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
|
||||
|
||||
using XformFormat = skcms_PixelFormat;
|
||||
|
||||
SkCodec(SkEncodedInfo&&,
|
||||
XformFormat srcFormat,
|
||||
std::unique_ptr<SkStream>,
|
||||
SkEncodedOrigin = kTopLeft_SkEncodedOrigin);
|
||||
|
||||
virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
|
||||
// By default, scaling is not supported.
|
||||
return this->dimensions();
|
||||
}
|
||||
|
||||
// FIXME: What to do about subsets??
|
||||
/**
|
||||
* Subclasses should override if they support dimensions other than the
|
||||
* srcInfo's.
|
||||
*/
|
||||
virtual bool onDimensionsSupported(const SkISize&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual SkEncodedImageFormat onGetEncodedFormat() const = 0;
|
||||
|
||||
/**
|
||||
* @param rowsDecoded When the encoded image stream is incomplete, this function
|
||||
* will return kIncompleteInput and rowsDecoded will be set to
|
||||
* the number of scanlines that were successfully decoded.
|
||||
* This will allow getPixels() to fill the uninitialized memory.
|
||||
*/
|
||||
virtual Result onGetPixels(const SkImageInfo& info,
|
||||
void* pixels, size_t rowBytes, const Options&,
|
||||
int* rowsDecoded) = 0;
|
||||
|
||||
virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes&,
|
||||
SkYUVAPixmapInfo*) const { return false; }
|
||||
|
||||
virtual Result onGetYUVAPlanes(const SkYUVAPixmaps&) { return kUnimplemented; }
|
||||
|
||||
virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
|
||||
// By default, subsets are not supported.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the stream was previously read, attempt to rewind.
|
||||
*
|
||||
* If the stream needed to be rewound, call onRewind.
|
||||
* @returns true if the codec is at the right position and can be used.
|
||||
* false if there was a failure to rewind.
|
||||
*
|
||||
* This is called by getPixels(), getYUV8Planes(), startIncrementalDecode() and
|
||||
* startScanlineDecode(). Subclasses may call if they need to rewind at another time.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT rewindIfNeeded();
|
||||
|
||||
/**
|
||||
* Called by rewindIfNeeded, if the stream needed to be rewound.
|
||||
*
|
||||
* Subclasses should do any set up needed after a rewind.
|
||||
*/
|
||||
virtual bool onRewind() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get method for the input stream
|
||||
*/
|
||||
SkStream* stream() {
|
||||
return fStream.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* The remaining functions revolve around decoding scanlines.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Most images types will be kTopDown and will not need to override this function.
|
||||
*/
|
||||
virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; }
|
||||
|
||||
const SkImageInfo& dstInfo() const { return fDstInfo; }
|
||||
|
||||
const Options& options() const { return fOptions; }
|
||||
|
||||
/**
|
||||
* Returns the number of scanlines that have been decoded so far.
|
||||
* This is unaffected by the SkScanlineOrder.
|
||||
*
|
||||
* Returns -1 if we have not started a scanline decode.
|
||||
*/
|
||||
int currScanline() const { return fCurrScanline; }
|
||||
|
||||
virtual int onOutputScanline(int inputScanline) const;
|
||||
|
||||
/**
|
||||
* Return whether we can convert to dst.
|
||||
*
|
||||
* Will be called for the appropriate frame, prior to initializing the colorXform.
|
||||
*/
|
||||
virtual bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
|
||||
bool needsColorXform);
|
||||
|
||||
// Some classes never need a colorXform e.g.
|
||||
// - ICO uses its embedded codec's colorXform
|
||||
// - WBMP is just Black/White
|
||||
virtual bool usesColorXform() const { return true; }
|
||||
void applyColorXform(void* dst, const void* src, int count) const;
|
||||
|
||||
bool colorXform() const { return fXformTime != kNo_XformTime; }
|
||||
bool xformOnDecode() const { return fXformTime == kDecodeRow_XformTime; }
|
||||
|
||||
virtual int onGetFrameCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual bool onGetFrameInfo(int, FrameInfo*) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int onGetRepetitionCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const SkEncodedInfo fEncodedInfo;
|
||||
const XformFormat fSrcXformFormat;
|
||||
std::unique_ptr<SkStream> fStream;
|
||||
bool fNeedsRewind;
|
||||
const SkEncodedOrigin fOrigin;
|
||||
|
||||
SkImageInfo fDstInfo;
|
||||
Options fOptions;
|
||||
|
||||
enum XformTime {
|
||||
kNo_XformTime,
|
||||
kPalette_XformTime,
|
||||
kDecodeRow_XformTime,
|
||||
};
|
||||
XformTime fXformTime;
|
||||
XformFormat fDstXformFormat; // Based on fDstInfo.
|
||||
skcms_ICCProfile fDstProfile;
|
||||
skcms_AlphaFormat fDstXformAlphaFormat;
|
||||
|
||||
// Only meaningful during scanline decodes.
|
||||
int fCurrScanline;
|
||||
|
||||
bool fStartedIncrementalDecode;
|
||||
|
||||
// Allows SkAndroidCodec to call handleFrameIndex (potentially decoding a prior frame and
|
||||
// clearing to transparent) without SkCodec calling it, too.
|
||||
bool fAndroidCodecHandlesFrameIndex;
|
||||
|
||||
bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
|
||||
|
||||
/**
|
||||
* Return whether these dimensions are supported as a scale.
|
||||
*
|
||||
* The codec may choose to cache the information about scale and subset.
|
||||
* Either way, the same information will be passed to onGetPixels/onStart
|
||||
* on success.
|
||||
*
|
||||
* This must return true for a size returned from getScaledDimensions.
|
||||
*/
|
||||
bool dimensionsSupported(const SkISize& dim) {
|
||||
return dim == this->dimensions() || this->onDimensionsSupported(dim);
|
||||
}
|
||||
|
||||
/**
|
||||
* For multi-framed images, return the object with information about the frames.
|
||||
*/
|
||||
virtual const SkFrameHolder* getFrameHolder() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for a valid Options.fFrameIndex, and decode prior frames if necessary.
|
||||
*
|
||||
* If androidCodec is not null, that means this SkCodec is owned by an SkAndroidCodec. In that
|
||||
* case, the Options will be treated as an AndroidOptions, and SkAndroidCodec will be used to
|
||||
* decode a prior frame, if a prior frame is needed. When such an owned SkCodec calls
|
||||
* handleFrameIndex, it will immediately return kSuccess, since SkAndroidCodec already handled
|
||||
* it.
|
||||
*/
|
||||
Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&,
|
||||
SkAndroidCodec* androidCodec = nullptr);
|
||||
|
||||
// Methods for scanline decoding.
|
||||
virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
|
||||
const Options& /*options*/) {
|
||||
return kUnimplemented;
|
||||
}
|
||||
|
||||
virtual Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
|
||||
const Options&) {
|
||||
return kUnimplemented;
|
||||
}
|
||||
|
||||
virtual Result onIncrementalDecode(int*) {
|
||||
return kUnimplemented;
|
||||
}
|
||||
|
||||
|
||||
virtual bool onSkipScanlines(int /*countLines*/) { return false; }
|
||||
|
||||
virtual int onGetScanlines(void* /*dst*/, int /*countLines*/, size_t /*rowBytes*/) { return 0; }
|
||||
|
||||
/**
|
||||
* On an incomplete decode, getPixels() and getScanlines() will call this function
|
||||
* to fill any uinitialized memory.
|
||||
*
|
||||
* @param dstInfo Contains the destination color type
|
||||
* Contains the destination alpha type
|
||||
* Contains the destination width
|
||||
* The height stored in this info is unused
|
||||
* @param dst Pointer to the start of destination pixel memory
|
||||
* @param rowBytes Stride length in destination pixel memory
|
||||
* @param zeroInit Indicates if memory is zero initialized
|
||||
* @param linesRequested Number of lines that the client requested
|
||||
* @param linesDecoded Number of lines that were successfully decoded
|
||||
*/
|
||||
void fillIncompleteImage(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
|
||||
ZeroInitialized zeroInit, int linesRequested, int linesDecoded);
|
||||
|
||||
/**
|
||||
* Return an object which will allow forcing scanline decodes to sample in X.
|
||||
*
|
||||
* May create a sampler, if one is not currently being used. Otherwise, does
|
||||
* not affect ownership.
|
||||
*
|
||||
* Only valid during scanline decoding or incremental decoding.
|
||||
*/
|
||||
virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
|
||||
|
||||
friend class DM::CodecSrc; // for fillIncompleteImage
|
||||
friend class SkSampledCodec;
|
||||
friend class SkIcoCodec;
|
||||
friend class SkAndroidCodec; // for fEncodedInfo
|
||||
};
|
||||
#endif // SkCodec_DEFINED
|
||||
61
src/deps/skia/include/codec/SkCodecAnimation.h
Normal file
61
src/deps/skia/include/codec/SkCodecAnimation.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCodecAnimation_DEFINED
|
||||
#define SkCodecAnimation_DEFINED
|
||||
|
||||
namespace SkCodecAnimation {
|
||||
/**
|
||||
* This specifies how the next frame is based on this frame.
|
||||
*
|
||||
* Names are based on the GIF 89a spec.
|
||||
*
|
||||
* The numbers correspond to values in a GIF.
|
||||
*/
|
||||
enum class DisposalMethod {
|
||||
/**
|
||||
* The next frame should be drawn on top of this one.
|
||||
*
|
||||
* In a GIF, a value of 0 (not specified) is also treated as Keep.
|
||||
*/
|
||||
kKeep = 1,
|
||||
|
||||
/**
|
||||
* Similar to Keep, except the area inside this frame's rectangle
|
||||
* should be cleared to the BackGround color (transparent) before
|
||||
* drawing the next frame.
|
||||
*/
|
||||
kRestoreBGColor = 2,
|
||||
|
||||
/**
|
||||
* The next frame should be drawn on top of the previous frame - i.e.
|
||||
* disregarding this one.
|
||||
*
|
||||
* In a GIF, a value of 4 is also treated as RestorePrevious.
|
||||
*/
|
||||
kRestorePrevious = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* How to blend the current frame.
|
||||
*/
|
||||
enum class Blend {
|
||||
/**
|
||||
* Blend with the prior frame as if using SkBlendMode::kSrcOver.
|
||||
*/
|
||||
kSrcOver,
|
||||
|
||||
/**
|
||||
* Blend with the prior frame as if using SkBlendMode::kSrc.
|
||||
*
|
||||
* This frame's pixels replace the destination pixels.
|
||||
*/
|
||||
kSrc,
|
||||
};
|
||||
|
||||
} // namespace SkCodecAnimation
|
||||
#endif // SkCodecAnimation_DEFINED
|
||||
54
src/deps/skia/include/codec/SkEncodedOrigin.h
Normal file
54
src/deps/skia/include/codec/SkEncodedOrigin.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkEncodedOrigin_DEFINED
|
||||
#define SkEncodedOrigin_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
|
||||
// These values match the orientation www.exif.org/Exif2-2.PDF.
|
||||
enum SkEncodedOrigin {
|
||||
kTopLeft_SkEncodedOrigin = 1, // Default
|
||||
kTopRight_SkEncodedOrigin = 2, // Reflected across y-axis
|
||||
kBottomRight_SkEncodedOrigin = 3, // Rotated 180
|
||||
kBottomLeft_SkEncodedOrigin = 4, // Reflected across x-axis
|
||||
kLeftTop_SkEncodedOrigin = 5, // Reflected across x-axis, Rotated 90 CCW
|
||||
kRightTop_SkEncodedOrigin = 6, // Rotated 90 CW
|
||||
kRightBottom_SkEncodedOrigin = 7, // Reflected across x-axis, Rotated 90 CW
|
||||
kLeftBottom_SkEncodedOrigin = 8, // Rotated 90 CCW
|
||||
kDefault_SkEncodedOrigin = kTopLeft_SkEncodedOrigin,
|
||||
kLast_SkEncodedOrigin = kLeftBottom_SkEncodedOrigin,
|
||||
};
|
||||
|
||||
/**
|
||||
* Given an encoded origin and the width and height of the source data, returns a matrix
|
||||
* that transforms the source rectangle with upper left corner at [0, 0] and origin to a correctly
|
||||
* oriented destination rectangle of [0, 0, w, h].
|
||||
*/
|
||||
static inline SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h) {
|
||||
switch (origin) {
|
||||
case kTopLeft_SkEncodedOrigin: return SkMatrix::I();
|
||||
case kTopRight_SkEncodedOrigin: return SkMatrix::MakeAll(-1, 0, w, 0, 1, 0, 0, 0, 1);
|
||||
case kBottomRight_SkEncodedOrigin: return SkMatrix::MakeAll(-1, 0, w, 0, -1, h, 0, 0, 1);
|
||||
case kBottomLeft_SkEncodedOrigin: return SkMatrix::MakeAll( 1, 0, 0, 0, -1, h, 0, 0, 1);
|
||||
case kLeftTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, 1, 0, 0, 0, 0, 1);
|
||||
case kRightTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, w, 1, 0, 0, 0, 0, 1);
|
||||
case kRightBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, w, -1, 0, h, 0, 0, 1);
|
||||
case kLeftBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, -1, 0, h, 0, 0, 1);
|
||||
}
|
||||
SK_ABORT("Unexpected origin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the encoded origin includes a 90 degree rotation, in which case the width
|
||||
* and height of the source data are swapped relative to a correctly oriented destination.
|
||||
*/
|
||||
static inline bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin) {
|
||||
return origin >= kLeftTop_SkEncodedOrigin;
|
||||
}
|
||||
|
||||
#endif // SkEncodedOrigin_DEFINED
|
||||
7
src/deps/skia/include/config/BUILD.bazel
Normal file
7
src/deps/skia/include/config/BUILD.bazel
Normal file
@@ -0,0 +1,7 @@
|
||||
load("//bazel:macros.bzl", "generated_cc_atom")
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkUserConfig_hdr",
|
||||
hdrs = ["SkUserConfig.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
89
src/deps/skia/include/config/SkUserConfig.h
Normal file
89
src/deps/skia/include/config/SkUserConfig.h
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkUserConfig_DEFINED
|
||||
#define SkUserConfig_DEFINED
|
||||
|
||||
/* SkTypes.h, the root of the public header files, includes this file
|
||||
SkUserConfig.h after first initializing certain Skia defines, letting
|
||||
this file change or augment those flags.
|
||||
|
||||
Below are optional defines that add, subtract, or change default behavior
|
||||
in Skia. Your port can locally edit this file to enable/disable flags as
|
||||
you choose, or these can be delared on your command line (i.e. -Dfoo).
|
||||
|
||||
By default, this include file will always default to having all of the flags
|
||||
commented out, so including it will have no effect.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Skia has lots of debug-only code. Often this is just null checks or other
|
||||
parameter checking, but sometimes it can be quite intrusive (e.g. check that
|
||||
each 32bit pixel is in premultiplied form). This code can be very useful
|
||||
during development, but will slow things down in a shipping product.
|
||||
|
||||
By default, these mutually exclusive flags are defined in SkTypes.h,
|
||||
based on the presence or absence of NDEBUG, but that decision can be changed
|
||||
here.
|
||||
*/
|
||||
//#define SK_DEBUG
|
||||
//#define SK_RELEASE
|
||||
|
||||
/* To write debug messages to a console, skia will call SkDebugf(...) following
|
||||
printf conventions (e.g. const char* format, ...). If you want to redirect
|
||||
this to something other than printf, define yours here
|
||||
*/
|
||||
//#define SkDebugf(...) MyFunction(__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* To specify a different default font cache limit, define this. If this is
|
||||
* undefined, skia will use a built-in value.
|
||||
*/
|
||||
//#define SK_DEFAULT_FONT_CACHE_LIMIT (1024 * 1024)
|
||||
|
||||
/*
|
||||
* To specify the default size of the image cache, undefine this and set it to
|
||||
* the desired value (in bytes). SkGraphics.h as a runtime API to set this
|
||||
* value as well. If this is undefined, a built-in value will be used.
|
||||
*/
|
||||
//#define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024)
|
||||
|
||||
/* Define this to set the upper limit for text to support LCD. Values that
|
||||
are very large increase the cost in the font cache and draw slower, without
|
||||
improving readability. If this is undefined, Skia will use its default
|
||||
value (e.g. 48)
|
||||
*/
|
||||
//#define SK_MAX_SIZE_FOR_LCDTEXT 48
|
||||
|
||||
/* Change the kN32_SkColorType ordering to BGRA to work in X windows.
|
||||
*/
|
||||
//#define SK_R32_SHIFT 16
|
||||
|
||||
|
||||
/* Determines whether to build code that supports the GPU backend. Some classes
|
||||
that are not GPU-specific, such as SkShader subclasses, have optional code
|
||||
that is used allows them to interact with the GPU backend. If you'd like to
|
||||
omit this code set SK_SUPPORT_GPU to 0. This also allows you to omit the gpu
|
||||
directories from your include search path when you're not building the GPU
|
||||
backend. Defaults to 1 (build the GPU code).
|
||||
*/
|
||||
//#define SK_SUPPORT_GPU 1
|
||||
|
||||
/* Skia makes use of histogram logging macros to trace the frequency of
|
||||
* events. By default, Skia provides no-op versions of these macros.
|
||||
* Skia consumers can provide their own definitions of these macros to
|
||||
* integrate with their histogram collection backend.
|
||||
*/
|
||||
//#define SK_HISTOGRAM_BOOLEAN(name, sample)
|
||||
//#define SK_HISTOGRAM_ENUMERATION(name, sample, enum_size)
|
||||
//#define SK_HISTOGRAM_EXACT_LINEAR(name, sample, value_max)
|
||||
//#define SK_HISTOGRAM_MEMORY_KB(name, sample)
|
||||
|
||||
#endif
|
||||
951
src/deps/skia/include/core/BUILD.bazel
Normal file
951
src/deps/skia/include/core/BUILD.bazel
Normal file
@@ -0,0 +1,951 @@
|
||||
load("//bazel:macros.bzl", "generated_cc_atom")
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkAnnotation_hdr",
|
||||
hdrs = ["SkAnnotation.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkBBHFactory_hdr",
|
||||
hdrs = ["SkBBHFactory.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkBitmap_hdr",
|
||||
hdrs = ["SkBitmap.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColor_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkMatrix_hdr",
|
||||
":SkPixmap_hdr",
|
||||
":SkPoint_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkShader_hdr",
|
||||
":SkTileMode_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkBlendMode_hdr",
|
||||
hdrs = ["SkBlendMode.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkBlender_hdr",
|
||||
hdrs = ["SkBlender.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlendMode_hdr",
|
||||
":SkFlattenable_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkBlurTypes_hdr",
|
||||
hdrs = ["SkBlurTypes.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCanvasVirtualEnforcer_hdr",
|
||||
hdrs = ["SkCanvasVirtualEnforcer.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkCanvas_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCanvas_hdr",
|
||||
hdrs = ["SkCanvas.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlendMode_hdr",
|
||||
":SkClipOp_hdr",
|
||||
":SkColor_hdr",
|
||||
":SkFontTypes_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkM44_hdr",
|
||||
":SkMatrix_hdr",
|
||||
":SkPaint_hdr",
|
||||
":SkPoint_hdr",
|
||||
":SkRasterHandleAllocator_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSamplingOptions_hdr",
|
||||
":SkScalar_hdr",
|
||||
":SkSize_hdr",
|
||||
":SkString_hdr",
|
||||
":SkSurfaceProps_hdr",
|
||||
":SkTypes_hdr",
|
||||
"//include/private:SkDeque_hdr",
|
||||
"//include/private:SkMacros_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkClipOp_hdr",
|
||||
hdrs = ["SkClipOp.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkColorFilter_hdr",
|
||||
hdrs = ["SkColorFilter.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlendMode_hdr",
|
||||
":SkColor_hdr",
|
||||
":SkFlattenable_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkColorPriv_hdr",
|
||||
hdrs = ["SkColorPriv.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColor_hdr",
|
||||
":SkMath_hdr",
|
||||
"//include/private:SkTPin_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkColorSpace_hdr",
|
||||
hdrs = ["SkColorSpace.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRefCnt_hdr",
|
||||
"//include/private:SkFixed_hdr",
|
||||
"//include/private:SkOnce_hdr",
|
||||
"//include/third_party/skcms:skcms_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkColor_hdr",
|
||||
hdrs = ["SkColor.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkImageInfo_hdr",
|
||||
":SkScalar_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkContourMeasure_hdr",
|
||||
hdrs = ["SkContourMeasure.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkPath_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
"//include/private:SkTDArray_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCoverageMode_hdr",
|
||||
hdrs = ["SkCoverageMode.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCubicMap_hdr",
|
||||
hdrs = ["SkCubicMap.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkPoint_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkDataTable_hdr",
|
||||
hdrs = ["SkDataTable.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkData_hdr",
|
||||
"//include/private:SkTDArray_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkData_hdr",
|
||||
hdrs = ["SkData.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkRefCnt_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkDeferredDisplayListRecorder_hdr",
|
||||
hdrs = ["SkDeferredDisplayListRecorder.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkDeferredDisplayList_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkImage_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSurfaceCharacterization_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkDeferredDisplayList_hdr",
|
||||
hdrs = ["SkDeferredDisplayList.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRefCnt_hdr",
|
||||
":SkSurfaceCharacterization_hdr",
|
||||
":SkTypes_hdr",
|
||||
"//include/gpu:GrRecordingContext_hdr",
|
||||
"//include/private:SkTArray_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkDocument_hdr",
|
||||
hdrs = ["SkDocument.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRefCnt_hdr",
|
||||
":SkScalar_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkDrawLooper_hdr",
|
||||
hdrs = ["SkDrawLooper.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlurTypes_hdr",
|
||||
":SkColor_hdr",
|
||||
":SkFlattenable_hdr",
|
||||
":SkPoint_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkDrawable_hdr",
|
||||
hdrs = ["SkDrawable.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFlattenable_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkScalar_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkEncodedImageFormat_hdr",
|
||||
hdrs = ["SkEncodedImageFormat.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkExecutor_hdr",
|
||||
hdrs = ["SkExecutor.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFlattenable_hdr",
|
||||
hdrs = ["SkFlattenable.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkRefCnt_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFontArguments_hdr",
|
||||
hdrs = ["SkFontArguments.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkScalar_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFontMetrics_hdr",
|
||||
hdrs = ["SkFontMetrics.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkScalar_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFontMgr_hdr",
|
||||
hdrs = ["SkFontMgr.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFontArguments_hdr",
|
||||
":SkFontStyle_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFontParameters_hdr",
|
||||
hdrs = ["SkFontParameters.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkScalar_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFontStyle_hdr",
|
||||
hdrs = ["SkFontStyle.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkTypes_hdr",
|
||||
"//include/private:SkTPin_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFontTypes_hdr",
|
||||
hdrs = ["SkFontTypes.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkFont_hdr",
|
||||
hdrs = ["SkFont.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFontTypes_hdr",
|
||||
":SkScalar_hdr",
|
||||
":SkTypeface_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkGraphics_hdr",
|
||||
hdrs = ["SkGraphics.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkRefCnt_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkICC_hdr",
|
||||
hdrs = ["SkICC.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkData_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkImageEncoder_hdr",
|
||||
hdrs = ["SkImageEncoder.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBitmap_hdr",
|
||||
":SkData_hdr",
|
||||
":SkEncodedImageFormat_hdr",
|
||||
":SkPixmap_hdr",
|
||||
":SkStream_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkImageFilter_hdr",
|
||||
hdrs = ["SkImageFilter.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFlattenable_hdr",
|
||||
":SkMatrix_hdr",
|
||||
":SkRect_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkImageGenerator_hdr",
|
||||
hdrs = ["SkImageGenerator.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBitmap_hdr",
|
||||
":SkColor_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkImage_hdr",
|
||||
":SkYUVAPixmaps_hdr",
|
||||
"//include/private:SkTOptional_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkImageInfo_hdr",
|
||||
hdrs = ["SkImageInfo.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColorSpace_hdr",
|
||||
":SkMath_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkSize_hdr",
|
||||
"//include/private:SkTFitsIn_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkImage_hdr",
|
||||
hdrs = ["SkImage.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkImageEncoder_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSamplingOptions_hdr",
|
||||
":SkScalar_hdr",
|
||||
":SkShader_hdr",
|
||||
":SkTileMode_hdr",
|
||||
"//include/gpu:GrTypes_hdr",
|
||||
"//include/private:SkTOptional_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkM44_hdr",
|
||||
hdrs = ["SkM44.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkMatrix_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkScalar_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkMallocPixelRef_hdr",
|
||||
hdrs = ["SkMallocPixelRef.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkPixelRef_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkMaskFilter_hdr",
|
||||
hdrs = ["SkMaskFilter.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlurTypes_hdr",
|
||||
":SkCoverageMode_hdr",
|
||||
":SkFlattenable_hdr",
|
||||
":SkScalar_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkMath_hdr",
|
||||
hdrs = ["SkMath.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkMatrix_hdr",
|
||||
hdrs = ["SkMatrix.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRect_hdr",
|
||||
"//include/private:SkMacros_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkMilestone_hdr",
|
||||
hdrs = ["SkMilestone.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkOverdrawCanvas_hdr",
|
||||
hdrs = ["SkOverdrawCanvas.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkCanvasVirtualEnforcer_hdr",
|
||||
"//include/utils:SkNWayCanvas_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPaint_hdr",
|
||||
hdrs = ["SkPaint.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlendMode_hdr",
|
||||
":SkColor_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
"//include/private:SkTOptional_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPathBuilder_hdr",
|
||||
hdrs = ["SkPathBuilder.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkMatrix_hdr",
|
||||
":SkPathTypes_hdr",
|
||||
":SkPath_hdr",
|
||||
"//include/private:SkTDArray_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPathEffect_hdr",
|
||||
hdrs = ["SkPathEffect.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFlattenable_hdr",
|
||||
":SkPath_hdr",
|
||||
":SkScalar_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPathMeasure_hdr",
|
||||
hdrs = ["SkPathMeasure.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkContourMeasure_hdr",
|
||||
":SkPath_hdr",
|
||||
"//include/private:SkTDArray_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPathTypes_hdr",
|
||||
hdrs = ["SkPathTypes.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPath_hdr",
|
||||
hdrs = ["SkPath.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkMatrix_hdr",
|
||||
":SkPathTypes_hdr",
|
||||
"//include/private:SkPathRef_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPictureRecorder_hdr",
|
||||
hdrs = ["SkPictureRecorder.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBBHFactory_hdr",
|
||||
":SkPicture_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPicture_hdr",
|
||||
hdrs = ["SkPicture.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSamplingOptions_hdr",
|
||||
":SkShader_hdr",
|
||||
":SkTileMode_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPixelRef_hdr",
|
||||
hdrs = ["SkPixelRef.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBitmap_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkPixmap_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSize_hdr",
|
||||
"//include/private:SkIDChangeListener_hdr",
|
||||
"//include/private:SkMutex_hdr",
|
||||
"//include/private:SkTDArray_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPixmap_hdr",
|
||||
hdrs = ["SkPixmap.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColor_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkSamplingOptions_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPngChunkReader_hdr",
|
||||
hdrs = ["SkPngChunkReader.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRefCnt_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPoint3_hdr",
|
||||
hdrs = ["SkPoint3.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkPoint_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPoint_hdr",
|
||||
hdrs = ["SkPoint.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkMath_hdr",
|
||||
":SkScalar_hdr",
|
||||
"//include/private:SkSafe32_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkPromiseImageTexture_hdr",
|
||||
hdrs = ["SkPromiseImageTexture.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRefCnt_hdr",
|
||||
":SkTypes_hdr",
|
||||
"//include/gpu:GrBackendSurface_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkRRect_hdr",
|
||||
hdrs = ["SkRRect.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkPoint_hdr",
|
||||
":SkRect_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkRSXform_hdr",
|
||||
hdrs = ["SkRSXform.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkPoint_hdr",
|
||||
":SkSize_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkRasterHandleAllocator_hdr",
|
||||
hdrs = ["SkRasterHandleAllocator.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkImageInfo_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkRect_hdr",
|
||||
hdrs = ["SkRect.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkPoint_hdr",
|
||||
":SkSize_hdr",
|
||||
"//include/private:SkSafe32_hdr",
|
||||
"//include/private:SkTFitsIn_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkRefCnt_hdr",
|
||||
hdrs = ["SkRefCnt.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkRegion_hdr",
|
||||
hdrs = ["SkRegion.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkRect_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSamplingOptions_hdr",
|
||||
hdrs = ["SkSamplingOptions.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkScalar_hdr",
|
||||
hdrs = ["SkScalar.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = ["//include/private:SkFloatingPoint_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSerialProcs_hdr",
|
||||
hdrs = ["SkSerialProcs.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkImage_hdr",
|
||||
":SkPicture_hdr",
|
||||
":SkTypeface_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkShader_hdr",
|
||||
hdrs = ["SkShader.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkBlendMode_hdr",
|
||||
":SkColor_hdr",
|
||||
":SkFlattenable_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkMatrix_hdr",
|
||||
":SkTileMode_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSize_hdr",
|
||||
hdrs = ["SkSize.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkScalar_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSpan_hdr",
|
||||
hdrs = ["SkSpan.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = ["//include/private:SkTLogic_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkStream_hdr",
|
||||
hdrs = ["SkStream.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkData_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkScalar_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkStringView_hdr",
|
||||
hdrs = ["SkStringView.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkString_hdr",
|
||||
hdrs = ["SkString.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkRefCnt_hdr",
|
||||
":SkScalar_hdr",
|
||||
":SkTypes_hdr",
|
||||
"//include/private:SkMalloc_hdr",
|
||||
"//include/private:SkTArray_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkStrokeRec_hdr",
|
||||
hdrs = ["SkStrokeRec.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkPaint_hdr",
|
||||
"//include/private:SkMacros_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSurfaceCharacterization_hdr",
|
||||
hdrs = ["SkSurfaceCharacterization.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColorSpace_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSurfaceProps_hdr",
|
||||
"//include/gpu:GrBackendSurface_hdr",
|
||||
"//include/gpu:GrContextThreadSafeProxy_hdr",
|
||||
"//include/gpu:GrTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSurfaceProps_hdr",
|
||||
hdrs = ["SkSurfaceProps.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSurface_hdr",
|
||||
hdrs = ["SkSurface.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkImage_hdr",
|
||||
":SkPixmap_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSurfaceProps_hdr",
|
||||
"//include/gpu:GrTypes_hdr",
|
||||
"//include/gpu/mtl:GrMtlTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkSwizzle_hdr",
|
||||
hdrs = ["SkSwizzle.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkTextBlob_hdr",
|
||||
hdrs = ["SkTextBlob.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFont_hdr",
|
||||
":SkPaint_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkString_hdr",
|
||||
"//include/private:SkTemplates_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkTileMode_hdr",
|
||||
hdrs = ["SkTileMode.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkTime_hdr",
|
||||
hdrs = ["SkTime.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkTypes_hdr",
|
||||
"//include/private:SkMacros_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkTraceMemoryDump_hdr",
|
||||
hdrs = ["SkTraceMemoryDump.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkTypes_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkTypeface_hdr",
|
||||
hdrs = ["SkTypeface.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkFontArguments_hdr",
|
||||
":SkFontParameters_hdr",
|
||||
":SkFontStyle_hdr",
|
||||
":SkFontTypes_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkString_hdr",
|
||||
"//include/private:SkOnce_hdr",
|
||||
"//include/private:SkWeakRefCnt_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkTypes_hdr",
|
||||
hdrs = ["SkTypes.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = ["//include/config:SkUserConfig_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkUnPreMultiply_hdr",
|
||||
hdrs = ["SkUnPreMultiply.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [":SkColor_hdr"],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkVertices_hdr",
|
||||
hdrs = ["SkVertices.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColor_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkYUVAInfo_hdr",
|
||||
hdrs = ["SkYUVAInfo.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkImageInfo_hdr",
|
||||
":SkSize_hdr",
|
||||
"//include/codec:SkEncodedOrigin_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkYUVAPixmaps_hdr",
|
||||
hdrs = ["SkYUVAPixmaps.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkData_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkPixmap_hdr",
|
||||
":SkYUVAInfo_hdr",
|
||||
"//include/private:SkTo_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCustomMesh_hdr",
|
||||
hdrs = ["SkCustomMesh.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkColorSpace_hdr",
|
||||
":SkImageInfo_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSpan_hdr",
|
||||
":SkString_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
50
src/deps/skia/include/core/SkAnnotation.h
Normal file
50
src/deps/skia/include/core/SkAnnotation.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAnnotation_DEFINED
|
||||
#define SkAnnotation_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkData;
|
||||
struct SkPoint;
|
||||
struct SkRect;
|
||||
class SkCanvas;
|
||||
|
||||
/**
|
||||
* Annotate the canvas by associating the specified URL with the
|
||||
* specified rectangle (in local coordinates, just like drawRect).
|
||||
*
|
||||
* If the backend of this canvas does not support annotations, this call is
|
||||
* safely ignored.
|
||||
*
|
||||
* The caller is responsible for managing its ownership of the SkData.
|
||||
*/
|
||||
SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*);
|
||||
|
||||
/**
|
||||
* Annotate the canvas by associating a name with the specified point.
|
||||
*
|
||||
* If the backend of this canvas does not support annotations, this call is
|
||||
* safely ignored.
|
||||
*
|
||||
* The caller is responsible for managing its ownership of the SkData.
|
||||
*/
|
||||
SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*);
|
||||
|
||||
/**
|
||||
* Annotate the canvas by making the specified rectangle link to a named
|
||||
* destination.
|
||||
*
|
||||
* If the backend of this canvas does not support annotations, this call is
|
||||
* safely ignored.
|
||||
*
|
||||
* The caller is responsible for managing its ownership of the SkData.
|
||||
*/
|
||||
SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*);
|
||||
|
||||
#endif
|
||||
63
src/deps/skia/include/core/SkBBHFactory.h
Normal file
63
src/deps/skia/include/core/SkBBHFactory.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBBHFactory_DEFINED
|
||||
#define SkBBHFactory_DEFINED
|
||||
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include <vector>
|
||||
|
||||
class SkBBoxHierarchy : public SkRefCnt {
|
||||
public:
|
||||
struct Metadata {
|
||||
bool isDraw; // The corresponding SkRect bounds a draw command, not a pure state change.
|
||||
};
|
||||
|
||||
/**
|
||||
* Insert N bounding boxes into the hierarchy.
|
||||
*/
|
||||
virtual void insert(const SkRect[], int N) = 0;
|
||||
virtual void insert(const SkRect[], const Metadata[], int N);
|
||||
|
||||
/**
|
||||
* Populate results with the indices of bounding boxes intersecting that query.
|
||||
*/
|
||||
virtual void search(const SkRect& query, std::vector<int>* results) const = 0;
|
||||
|
||||
/**
|
||||
* Return approximate size in memory of *this.
|
||||
*/
|
||||
virtual size_t bytesUsed() const = 0;
|
||||
|
||||
protected:
|
||||
SkBBoxHierarchy() = default;
|
||||
SkBBoxHierarchy(const SkBBoxHierarchy&) = delete;
|
||||
SkBBoxHierarchy& operator=(const SkBBoxHierarchy&) = delete;
|
||||
};
|
||||
|
||||
class SK_API SkBBHFactory {
|
||||
public:
|
||||
/**
|
||||
* Allocate a new SkBBoxHierarchy. Return NULL on failure.
|
||||
*/
|
||||
virtual sk_sp<SkBBoxHierarchy> operator()() const = 0;
|
||||
virtual ~SkBBHFactory() {}
|
||||
|
||||
protected:
|
||||
SkBBHFactory() = default;
|
||||
SkBBHFactory(const SkBBHFactory&) = delete;
|
||||
SkBBHFactory& operator=(const SkBBHFactory&) = delete;
|
||||
};
|
||||
|
||||
class SK_API SkRTreeFactory : public SkBBHFactory {
|
||||
public:
|
||||
sk_sp<SkBBoxHierarchy> operator()() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
1212
src/deps/skia/include/core/SkBitmap.h
Normal file
1212
src/deps/skia/include/core/SkBitmap.h
Normal file
File diff suppressed because it is too large
Load Diff
110
src/deps/skia/include/core/SkBlendMode.h
Normal file
110
src/deps/skia/include/core/SkBlendMode.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBlendMode_DEFINED
|
||||
#define SkBlendMode_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Blends are operators that take in two colors (source, destination) and return a new color.
|
||||
* Many of these operate the same on all 4 components: red, green, blue, alpha. For these,
|
||||
* we just document what happens to one component, rather than naming each one separately.
|
||||
*
|
||||
* Different SkColorTypes have different representations for color components:
|
||||
* 8-bit: 0..255
|
||||
* 6-bit: 0..63
|
||||
* 5-bit: 0..31
|
||||
* 4-bit: 0..15
|
||||
* floats: 0...1
|
||||
*
|
||||
* The documentation is expressed as if the component values are always 0..1 (floats).
|
||||
*
|
||||
* For brevity, the documentation uses the following abbreviations
|
||||
* s : source
|
||||
* d : destination
|
||||
* sa : source alpha
|
||||
* da : destination alpha
|
||||
*
|
||||
* Results are abbreviated
|
||||
* r : if all 4 components are computed in the same manner
|
||||
* ra : result alpha component
|
||||
* rc : result "color": red, green, blue components
|
||||
*/
|
||||
enum class SkBlendMode {
|
||||
kClear, //!< r = 0
|
||||
kSrc, //!< r = s
|
||||
kDst, //!< r = d
|
||||
kSrcOver, //!< r = s + (1-sa)*d
|
||||
kDstOver, //!< r = d + (1-da)*s
|
||||
kSrcIn, //!< r = s * da
|
||||
kDstIn, //!< r = d * sa
|
||||
kSrcOut, //!< r = s * (1-da)
|
||||
kDstOut, //!< r = d * (1-sa)
|
||||
kSrcATop, //!< r = s*da + d*(1-sa)
|
||||
kDstATop, //!< r = d*sa + s*(1-da)
|
||||
kXor, //!< r = s*(1-da) + d*(1-sa)
|
||||
kPlus, //!< r = min(s + d, 1)
|
||||
kModulate, //!< r = s*d
|
||||
kScreen, //!< r = s + d - s*d
|
||||
|
||||
kOverlay, //!< multiply or screen, depending on destination
|
||||
kDarken, //!< rc = s + d - max(s*da, d*sa), ra = kSrcOver
|
||||
kLighten, //!< rc = s + d - min(s*da, d*sa), ra = kSrcOver
|
||||
kColorDodge, //!< brighten destination to reflect source
|
||||
kColorBurn, //!< darken destination to reflect source
|
||||
kHardLight, //!< multiply or screen, depending on source
|
||||
kSoftLight, //!< lighten or darken, depending on source
|
||||
kDifference, //!< rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
|
||||
kExclusion, //!< rc = s + d - two(s*d), ra = kSrcOver
|
||||
kMultiply, //!< r = s*(1-da) + d*(1-sa) + s*d
|
||||
|
||||
kHue, //!< hue of source with saturation and luminosity of destination
|
||||
kSaturation, //!< saturation of source with hue and luminosity of destination
|
||||
kColor, //!< hue and saturation of source with luminosity of destination
|
||||
kLuminosity, //!< luminosity of source with hue and saturation of destination
|
||||
|
||||
kLastCoeffMode = kScreen, //!< last porter duff blend mode
|
||||
kLastSeparableMode = kMultiply, //!< last blend mode operating separately on components
|
||||
kLastMode = kLuminosity, //!< last valid value
|
||||
};
|
||||
|
||||
/**
|
||||
* For Porter-Duff SkBlendModes (those <= kLastCoeffMode), these coefficients describe the blend
|
||||
* equation used. Coefficient-based blend modes specify an equation:
|
||||
* ('dstCoeff' * dst + 'srcCoeff' * src), where the coefficient values are constants, functions of
|
||||
* the src or dst alpha, or functions of the src or dst color.
|
||||
*/
|
||||
enum class SkBlendModeCoeff {
|
||||
kZero, /** 0 */
|
||||
kOne, /** 1 */
|
||||
kSC, /** src color */
|
||||
kISC, /** inverse src color (i.e. 1 - sc) */
|
||||
kDC, /** dst color */
|
||||
kIDC, /** inverse dst color (i.e. 1 - dc) */
|
||||
kSA, /** src alpha */
|
||||
kISA, /** inverse src alpha (i.e. 1 - sa) */
|
||||
kDA, /** dst alpha */
|
||||
kIDA, /** inverse dst alpha (i.e. 1 - da) */
|
||||
|
||||
kCoeffCount
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if 'mode' is a coefficient-based blend mode (<= kLastCoeffMode). If true is
|
||||
* returned, the mode's src and dst coefficient functions are set in 'src' and 'dst'.
|
||||
*/
|
||||
SK_API bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff* src, SkBlendModeCoeff* dst);
|
||||
|
||||
|
||||
/** Returns name of blendMode as null-terminated C string.
|
||||
|
||||
@return C string
|
||||
*/
|
||||
SK_API const char* SkBlendMode_Name(SkBlendMode blendMode);
|
||||
|
||||
#endif
|
||||
33
src/deps/skia/include/core/SkBlender.h
Normal file
33
src/deps/skia/include/core/SkBlender.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBlender_DEFINED
|
||||
#define SkBlender_DEFINED
|
||||
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
|
||||
/**
|
||||
* SkBlender represents a custom blend function in the Skia pipeline. When an SkBlender is
|
||||
* present in a paint, the SkBlendMode is ignored. A blender combines a source color (the
|
||||
* result of our paint) and destination color (from the canvas) into a final color.
|
||||
*/
|
||||
class SK_API SkBlender : public SkFlattenable {
|
||||
public:
|
||||
/**
|
||||
* Create a blender that implements the specified BlendMode.
|
||||
*/
|
||||
static sk_sp<SkBlender> Mode(SkBlendMode mode);
|
||||
|
||||
private:
|
||||
SkBlender() = default;
|
||||
friend class SkBlenderBase;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
#endif
|
||||
22
src/deps/skia/include/core/SkBlurTypes.h
Normal file
22
src/deps/skia/include/core/SkBlurTypes.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBlurTypes_DEFINED
|
||||
#define SkBlurTypes_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
enum SkBlurStyle : int {
|
||||
kNormal_SkBlurStyle, //!< fuzzy inside and outside
|
||||
kSolid_SkBlurStyle, //!< solid inside, fuzzy outside
|
||||
kOuter_SkBlurStyle, //!< nothing inside, fuzzy outside
|
||||
kInner_SkBlurStyle, //!< fuzzy inside, nothing outside
|
||||
|
||||
kLastEnum_SkBlurStyle = kInner_SkBlurStyle,
|
||||
};
|
||||
|
||||
#endif
|
||||
2583
src/deps/skia/include/core/SkCanvas.h
Normal file
2583
src/deps/skia/include/core/SkCanvas.h
Normal file
File diff suppressed because it is too large
Load Diff
61
src/deps/skia/include/core/SkCanvasVirtualEnforcer.h
Normal file
61
src/deps/skia/include/core/SkCanvasVirtualEnforcer.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCanvasVirtualEnforcer_DEFINED
|
||||
#define SkCanvasVirtualEnforcer_DEFINED
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
|
||||
// If you would ordinarily want to inherit from Base (eg SkCanvas, SkNWayCanvas), instead
|
||||
// inherit from SkCanvasVirtualEnforcer<Base>, which will make the build fail if you forget
|
||||
// to override one of SkCanvas' key virtual hooks.
|
||||
template <typename Base>
|
||||
class SkCanvasVirtualEnforcer : public Base {
|
||||
public:
|
||||
using Base::Base;
|
||||
|
||||
protected:
|
||||
void onDrawPaint(const SkPaint& paint) override = 0;
|
||||
void onDrawBehind(const SkPaint&) override {} // make zero after android updates
|
||||
void onDrawRect(const SkRect& rect, const SkPaint& paint) override = 0;
|
||||
void onDrawRRect(const SkRRect& rrect, const SkPaint& paint) override = 0;
|
||||
void onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
|
||||
const SkPaint& paint) override = 0;
|
||||
void onDrawOval(const SkRect& rect, const SkPaint& paint) override = 0;
|
||||
void onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint& paint) override = 0;
|
||||
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;
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
// This is under active development for Chrome and not used in Android. Hold off on adding
|
||||
// implementations in Android's SkCanvas subclasses until this stabilizes.
|
||||
void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
||||
SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color, SkBlendMode mode) override {}
|
||||
#else
|
||||
void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
||||
SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color, SkBlendMode mode) override = 0;
|
||||
#endif
|
||||
|
||||
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
|
||||
19
src/deps/skia/include/core/SkClipOp.h
Normal file
19
src/deps/skia/include/core/SkClipOp.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkClipOp_DEFINED
|
||||
#define SkClipOp_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
enum class SkClipOp {
|
||||
kDifference = 0,
|
||||
kIntersect = 1,
|
||||
kMax_EnumValue = kIntersect
|
||||
};
|
||||
|
||||
#endif
|
||||
438
src/deps/skia/include/core/SkColor.h
Normal file
438
src/deps/skia/include/core/SkColor.h
Normal file
@@ -0,0 +1,438 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkColor_DEFINED
|
||||
#define SkColor_DEFINED
|
||||
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
/** \file SkColor.h
|
||||
|
||||
Types, consts, functions, and macros for colors.
|
||||
*/
|
||||
|
||||
/** 8-bit type for an alpha value. 255 is 100% opaque, zero is 100% transparent.
|
||||
*/
|
||||
typedef uint8_t SkAlpha;
|
||||
|
||||
/** 32-bit ARGB color value, unpremultiplied. Color components are always in
|
||||
a known order. This is different from SkPMColor, which has its bytes in a configuration
|
||||
dependent order, to match the format of kBGRA_8888_SkColorType bitmaps. SkColor
|
||||
is the type used to specify colors in SkPaint and in gradients.
|
||||
|
||||
Color that is premultiplied has the same component values as color
|
||||
that is unpremultiplied if alpha is 255, fully opaque, although may have the
|
||||
component values in a different order.
|
||||
*/
|
||||
typedef uint32_t SkColor;
|
||||
|
||||
/** Returns color value from 8-bit component values. Asserts if SK_DEBUG is defined
|
||||
if a, r, g, or b exceed 255. Since color is unpremultiplied, a may be smaller
|
||||
than the largest of r, g, and b.
|
||||
|
||||
@param a amount of alpha, from fully transparent (0) to fully opaque (255)
|
||||
@param r amount of red, from no red (0) to full red (255)
|
||||
@param g amount of green, from no green (0) to full green (255)
|
||||
@param b amount of blue, from no blue (0) to full blue (255)
|
||||
@return color and alpha, unpremultiplied
|
||||
*/
|
||||
static constexpr inline SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
||||
return SkASSERT(a <= 255 && r <= 255 && g <= 255 && b <= 255),
|
||||
(a << 24) | (r << 16) | (g << 8) | (b << 0);
|
||||
}
|
||||
|
||||
/** Returns color value from 8-bit component values, with alpha set
|
||||
fully opaque to 255.
|
||||
*/
|
||||
#define SkColorSetRGB(r, g, b) SkColorSetARGB(0xFF, r, g, b)
|
||||
|
||||
/** Returns alpha byte from color value.
|
||||
*/
|
||||
#define SkColorGetA(color) (((color) >> 24) & 0xFF)
|
||||
|
||||
/** Returns red component of color, from zero to 255.
|
||||
*/
|
||||
#define SkColorGetR(color) (((color) >> 16) & 0xFF)
|
||||
|
||||
/** Returns green component of color, from zero to 255.
|
||||
*/
|
||||
#define SkColorGetG(color) (((color) >> 8) & 0xFF)
|
||||
|
||||
/** Returns blue component of color, from zero to 255.
|
||||
*/
|
||||
#define SkColorGetB(color) (((color) >> 0) & 0xFF)
|
||||
|
||||
/** Returns unpremultiplied color with red, blue, and green set from c; and alpha set
|
||||
from a. Alpha component of c is ignored and is replaced by a in result.
|
||||
|
||||
@param c packed RGB, eight bits per component
|
||||
@param a alpha: transparent at zero, fully opaque at 255
|
||||
@return color with transparency
|
||||
*/
|
||||
static constexpr inline SkColor SK_WARN_UNUSED_RESULT SkColorSetA(SkColor c, U8CPU a) {
|
||||
return (c & 0x00FFFFFF) | (a << 24);
|
||||
}
|
||||
|
||||
/** Represents fully transparent SkAlpha value. SkAlpha ranges from zero,
|
||||
fully transparent; to 255, fully opaque.
|
||||
*/
|
||||
constexpr SkAlpha SK_AlphaTRANSPARENT = 0x00;
|
||||
|
||||
/** Represents fully opaque SkAlpha value. SkAlpha ranges from zero,
|
||||
fully transparent; to 255, fully opaque.
|
||||
*/
|
||||
constexpr SkAlpha SK_AlphaOPAQUE = 0xFF;
|
||||
|
||||
/** Represents fully transparent SkColor. May be used to initialize a destination
|
||||
containing a mask or a non-rectangular image.
|
||||
*/
|
||||
constexpr SkColor SK_ColorTRANSPARENT = SkColorSetARGB(0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
/** Represents fully opaque black.
|
||||
*/
|
||||
constexpr SkColor SK_ColorBLACK = SkColorSetARGB(0xFF, 0x00, 0x00, 0x00);
|
||||
|
||||
/** Represents fully opaque dark gray.
|
||||
Note that SVG dark gray is equivalent to 0xFFA9A9A9.
|
||||
*/
|
||||
constexpr SkColor SK_ColorDKGRAY = SkColorSetARGB(0xFF, 0x44, 0x44, 0x44);
|
||||
|
||||
/** Represents fully opaque gray.
|
||||
Note that HTML gray is equivalent to 0xFF808080.
|
||||
*/
|
||||
constexpr SkColor SK_ColorGRAY = SkColorSetARGB(0xFF, 0x88, 0x88, 0x88);
|
||||
|
||||
/** Represents fully opaque light gray. HTML silver is equivalent to 0xFFC0C0C0.
|
||||
Note that SVG light gray is equivalent to 0xFFD3D3D3.
|
||||
*/
|
||||
constexpr SkColor SK_ColorLTGRAY = SkColorSetARGB(0xFF, 0xCC, 0xCC, 0xCC);
|
||||
|
||||
/** Represents fully opaque white.
|
||||
*/
|
||||
constexpr SkColor SK_ColorWHITE = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
/** Represents fully opaque red.
|
||||
*/
|
||||
constexpr SkColor SK_ColorRED = SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00);
|
||||
|
||||
/** Represents fully opaque green. HTML lime is equivalent.
|
||||
Note that HTML green is equivalent to 0xFF008000.
|
||||
*/
|
||||
constexpr SkColor SK_ColorGREEN = SkColorSetARGB(0xFF, 0x00, 0xFF, 0x00);
|
||||
|
||||
/** Represents fully opaque blue.
|
||||
*/
|
||||
constexpr SkColor SK_ColorBLUE = SkColorSetARGB(0xFF, 0x00, 0x00, 0xFF);
|
||||
|
||||
/** Represents fully opaque yellow.
|
||||
*/
|
||||
constexpr SkColor SK_ColorYELLOW = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0x00);
|
||||
|
||||
/** Represents fully opaque cyan. HTML aqua is equivalent.
|
||||
*/
|
||||
constexpr SkColor SK_ColorCYAN = SkColorSetARGB(0xFF, 0x00, 0xFF, 0xFF);
|
||||
|
||||
/** Represents fully opaque magenta. HTML fuchsia is equivalent.
|
||||
*/
|
||||
constexpr SkColor SK_ColorMAGENTA = SkColorSetARGB(0xFF, 0xFF, 0x00, 0xFF);
|
||||
|
||||
/** Converts RGB to its HSV components.
|
||||
hsv[0] contains hsv hue, a value from zero to less than 360.
|
||||
hsv[1] contains hsv saturation, a value from zero to one.
|
||||
hsv[2] contains hsv value, a value from zero to one.
|
||||
|
||||
@param red red component value from zero to 255
|
||||
@param green green component value from zero to 255
|
||||
@param blue blue component value from zero to 255
|
||||
@param hsv three element array which holds the resulting HSV components
|
||||
*/
|
||||
SK_API void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]);
|
||||
|
||||
/** Converts ARGB to its HSV components. Alpha in ARGB is ignored.
|
||||
hsv[0] contains hsv hue, and is assigned a value from zero to less than 360.
|
||||
hsv[1] contains hsv saturation, a value from zero to one.
|
||||
hsv[2] contains hsv value, a value from zero to one.
|
||||
|
||||
@param color ARGB color to convert
|
||||
@param hsv three element array which holds the resulting HSV components
|
||||
*/
|
||||
static inline void SkColorToHSV(SkColor color, SkScalar hsv[3]) {
|
||||
SkRGBToHSV(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color), hsv);
|
||||
}
|
||||
|
||||
/** Converts HSV components to an ARGB color. Alpha is passed through unchanged.
|
||||
hsv[0] represents hsv hue, an angle from zero to less than 360.
|
||||
hsv[1] represents hsv saturation, and varies from zero to one.
|
||||
hsv[2] represents hsv value, and varies from zero to one.
|
||||
|
||||
Out of range hsv values are pinned.
|
||||
|
||||
@param alpha alpha component of the returned ARGB color
|
||||
@param hsv three element array which holds the input HSV components
|
||||
@return ARGB equivalent to HSV
|
||||
*/
|
||||
SK_API SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3]);
|
||||
|
||||
/** Converts HSV components to an ARGB color. Alpha is set to 255.
|
||||
hsv[0] represents hsv hue, an angle from zero to less than 360.
|
||||
hsv[1] represents hsv saturation, and varies from zero to one.
|
||||
hsv[2] represents hsv value, and varies from zero to one.
|
||||
|
||||
Out of range hsv values are pinned.
|
||||
|
||||
@param hsv three element array which holds the input HSV components
|
||||
@return RGB equivalent to HSV
|
||||
*/
|
||||
static inline SkColor SkHSVToColor(const SkScalar hsv[3]) {
|
||||
return SkHSVToColor(0xFF, hsv);
|
||||
}
|
||||
|
||||
/** 32-bit ARGB color value, premultiplied. The byte order for this value is
|
||||
configuration dependent, matching the format of kBGRA_8888_SkColorType bitmaps.
|
||||
This is different from SkColor, which is unpremultiplied, and is always in the
|
||||
same byte order.
|
||||
*/
|
||||
typedef uint32_t SkPMColor;
|
||||
|
||||
/** Returns a SkPMColor value from unpremultiplied 8-bit component values.
|
||||
|
||||
@param a amount of alpha, from fully transparent (0) to fully opaque (255)
|
||||
@param r amount of red, from no red (0) to full red (255)
|
||||
@param g amount of green, from no green (0) to full green (255)
|
||||
@param b amount of blue, from no blue (0) to full blue (255)
|
||||
@return premultiplied color
|
||||
*/
|
||||
SK_API SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
|
||||
|
||||
/** Returns pmcolor closest to color c. Multiplies c RGB components by the c alpha,
|
||||
and arranges the bytes to match the format of kN32_SkColorType.
|
||||
|
||||
@param c unpremultiplied ARGB color
|
||||
@return premultiplied color
|
||||
*/
|
||||
SK_API SkPMColor SkPreMultiplyColor(SkColor c);
|
||||
|
||||
/** \enum SkColorChannel
|
||||
Describes different color channels one can manipulate
|
||||
*/
|
||||
enum class SkColorChannel {
|
||||
kR, // the red channel
|
||||
kG, // the green channel
|
||||
kB, // the blue channel
|
||||
kA, // the alpha channel
|
||||
|
||||
kLastEnum = kA,
|
||||
};
|
||||
|
||||
/** Used to represent the channels available in a color type or texture format as a mask. */
|
||||
enum SkColorChannelFlag : uint32_t {
|
||||
kRed_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kR),
|
||||
kGreen_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kG),
|
||||
kBlue_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kB),
|
||||
kAlpha_SkColorChannelFlag = 1 << static_cast<uint32_t>(SkColorChannel::kA),
|
||||
kGray_SkColorChannelFlag = 0x10,
|
||||
// Convenience values
|
||||
kGrayAlpha_SkColorChannelFlags = kGray_SkColorChannelFlag | kAlpha_SkColorChannelFlag,
|
||||
kRG_SkColorChannelFlags = kRed_SkColorChannelFlag | kGreen_SkColorChannelFlag,
|
||||
kRGB_SkColorChannelFlags = kRG_SkColorChannelFlags | kBlue_SkColorChannelFlag,
|
||||
kRGBA_SkColorChannelFlags = kRGB_SkColorChannelFlags | kAlpha_SkColorChannelFlag,
|
||||
};
|
||||
static_assert(0 == (kGray_SkColorChannelFlag & kRGBA_SkColorChannelFlags), "bitfield conflict");
|
||||
|
||||
/** \struct SkRGBA4f
|
||||
RGBA color value, holding four floating point components. Color components are always in
|
||||
a known order. kAT determines if the SkRGBA4f's R, G, and B components are premultiplied
|
||||
by alpha or not.
|
||||
|
||||
Skia's public API always uses unpremultiplied colors, which can be stored as
|
||||
SkRGBA4f<kUnpremul_SkAlphaType>. For convenience, this type can also be referred to
|
||||
as SkColor4f.
|
||||
*/
|
||||
template <SkAlphaType kAT>
|
||||
struct SkRGBA4f {
|
||||
float fR; //!< red component
|
||||
float fG; //!< green component
|
||||
float fB; //!< blue component
|
||||
float fA; //!< alpha component
|
||||
|
||||
/** Compares SkRGBA4f with other, and returns true if all components are equal.
|
||||
|
||||
@param other SkRGBA4f to compare
|
||||
@return true if SkRGBA4f equals other
|
||||
*/
|
||||
bool operator==(const SkRGBA4f& other) const {
|
||||
return fA == other.fA && fR == other.fR && fG == other.fG && fB == other.fB;
|
||||
}
|
||||
|
||||
/** Compares SkRGBA4f with other, and returns true if not all components are equal.
|
||||
|
||||
@param other SkRGBA4f to compare
|
||||
@return true if SkRGBA4f is not equal to other
|
||||
*/
|
||||
bool operator!=(const SkRGBA4f& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/** Returns SkRGBA4f multiplied by scale.
|
||||
|
||||
@param scale value to multiply by
|
||||
@return SkRGBA4f as (fR * scale, fG * scale, fB * scale, fA * scale)
|
||||
*/
|
||||
SkRGBA4f operator*(float scale) const {
|
||||
return { fR * scale, fG * scale, fB * scale, fA * scale };
|
||||
}
|
||||
|
||||
/** Returns SkRGBA4f multiplied component-wise by scale.
|
||||
|
||||
@param scale SkRGBA4f to multiply by
|
||||
@return SkRGBA4f as (fR * scale.fR, fG * scale.fG, fB * scale.fB, fA * scale.fA)
|
||||
*/
|
||||
SkRGBA4f operator*(const SkRGBA4f& scale) const {
|
||||
return { fR * scale.fR, fG * scale.fG, fB * scale.fB, fA * scale.fA };
|
||||
}
|
||||
|
||||
/** Returns a pointer to components of SkRGBA4f, for array access.
|
||||
|
||||
@return pointer to array [fR, fG, fB, fA]
|
||||
*/
|
||||
const float* vec() const { return &fR; }
|
||||
|
||||
/** Returns a pointer to components of SkRGBA4f, for array access.
|
||||
|
||||
@return pointer to array [fR, fG, fB, fA]
|
||||
*/
|
||||
float* vec() { return &fR; }
|
||||
|
||||
/** As a std::array<float, 4> */
|
||||
std::array<float, 4> array() const { return {fR, fG, fB, fA}; }
|
||||
|
||||
/** Returns one component. Asserts if index is out of range and SK_DEBUG is defined.
|
||||
|
||||
@param index one of: 0 (fR), 1 (fG), 2 (fB), 3 (fA)
|
||||
@return value corresponding to index
|
||||
*/
|
||||
float operator[](int index) const {
|
||||
SkASSERT(index >= 0 && index < 4);
|
||||
return this->vec()[index];
|
||||
}
|
||||
|
||||
/** Returns one component. Asserts if index is out of range and SK_DEBUG is defined.
|
||||
|
||||
@param index one of: 0 (fR), 1 (fG), 2 (fB), 3 (fA)
|
||||
@return value corresponding to index
|
||||
*/
|
||||
float& operator[](int index) {
|
||||
SkASSERT(index >= 0 && index < 4);
|
||||
return this->vec()[index];
|
||||
}
|
||||
|
||||
/** Returns true if SkRGBA4f is an opaque color. Asserts if fA is out of range and
|
||||
SK_DEBUG is defined.
|
||||
|
||||
@return true if SkRGBA4f is opaque
|
||||
*/
|
||||
bool isOpaque() const {
|
||||
SkASSERT(fA <= 1.0f && fA >= 0.0f);
|
||||
return fA == 1.0f;
|
||||
}
|
||||
|
||||
/** Returns true if all channels are in [0, 1]. */
|
||||
bool fitsInBytes() const {
|
||||
SkASSERT(fA >= 0.0f && fA <= 1.0f);
|
||||
return fR >= 0.0f && fR <= 1.0f &&
|
||||
fG >= 0.0f && fG <= 1.0f &&
|
||||
fB >= 0.0f && fB <= 1.0f;
|
||||
}
|
||||
|
||||
/** Returns closest SkRGBA4f to SkColor. Only allowed if SkRGBA4f is unpremultiplied.
|
||||
|
||||
@param color Color with Alpha, red, blue, and green components
|
||||
@return SkColor as SkRGBA4f
|
||||
|
||||
example: https://fiddle.skia.org/c/@RGBA4f_FromColor
|
||||
*/
|
||||
static SkRGBA4f FromColor(SkColor color); // impl. depends on kAT
|
||||
|
||||
/** Returns closest SkColor to SkRGBA4f. Only allowed if SkRGBA4f is unpremultiplied.
|
||||
|
||||
@return color as SkColor
|
||||
|
||||
example: https://fiddle.skia.org/c/@RGBA4f_toSkColor
|
||||
*/
|
||||
SkColor toSkColor() const; // impl. depends on kAT
|
||||
|
||||
/** Returns closest SkRGBA4f to SkPMColor. Only allowed if SkRGBA4f is premultiplied.
|
||||
|
||||
@return SkPMColor as SkRGBA4f
|
||||
*/
|
||||
static SkRGBA4f FromPMColor(SkPMColor); // impl. depends on kAT
|
||||
|
||||
/** Returns SkRGBA4f premultiplied by alpha. Asserts at compile time if SkRGBA4f is
|
||||
already premultiplied.
|
||||
|
||||
@return premultiplied color
|
||||
*/
|
||||
SkRGBA4f<kPremul_SkAlphaType> premul() const {
|
||||
static_assert(kAT == kUnpremul_SkAlphaType, "");
|
||||
return { fR * fA, fG * fA, fB * fA, fA };
|
||||
}
|
||||
|
||||
/** Returns SkRGBA4f unpremultiplied by alpha. Asserts at compile time if SkRGBA4f is
|
||||
already unpremultiplied.
|
||||
|
||||
@return unpremultiplied color
|
||||
*/
|
||||
SkRGBA4f<kUnpremul_SkAlphaType> unpremul() const {
|
||||
static_assert(kAT == kPremul_SkAlphaType, "");
|
||||
|
||||
if (fA == 0.0f) {
|
||||
return { 0, 0, 0, 0 };
|
||||
} else {
|
||||
float invAlpha = 1 / fA;
|
||||
return { fR * invAlpha, fG * invAlpha, fB * invAlpha, fA };
|
||||
}
|
||||
}
|
||||
|
||||
// This produces bytes in RGBA order (eg GrColor). Impl. is the same, regardless of kAT
|
||||
uint32_t toBytes_RGBA() const;
|
||||
static SkRGBA4f FromBytes_RGBA(uint32_t color);
|
||||
|
||||
SkRGBA4f makeOpaque() const {
|
||||
return { fR, fG, fB, 1.0f };
|
||||
}
|
||||
};
|
||||
|
||||
/** \struct SkColor4f
|
||||
RGBA color value, holding four floating point components. Color components are always in
|
||||
a known order, and are unpremultiplied.
|
||||
|
||||
This is a specialization of SkRGBA4f. For details, @see SkRGBA4f.
|
||||
*/
|
||||
using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>;
|
||||
|
||||
template <> SK_API SkColor4f SkColor4f::FromColor(SkColor);
|
||||
template <> SK_API SkColor SkColor4f::toSkColor() const;
|
||||
|
||||
namespace SkColors {
|
||||
constexpr SkColor4f kTransparent = {0, 0, 0, 0};
|
||||
constexpr SkColor4f kBlack = {0, 0, 0, 1};
|
||||
constexpr SkColor4f kDkGray = {0.25f, 0.25f, 0.25f, 1};
|
||||
constexpr SkColor4f kGray = {0.50f, 0.50f, 0.50f, 1};
|
||||
constexpr SkColor4f kLtGray = {0.75f, 0.75f, 0.75f, 1};
|
||||
constexpr SkColor4f kWhite = {1, 1, 1, 1};
|
||||
constexpr SkColor4f kRed = {1, 0, 0, 1};
|
||||
constexpr SkColor4f kGreen = {0, 1, 0, 1};
|
||||
constexpr SkColor4f kBlue = {0, 0, 1, 1};
|
||||
constexpr SkColor4f kYellow = {1, 1, 0, 1};
|
||||
constexpr SkColor4f kCyan = {0, 1, 1, 1};
|
||||
constexpr SkColor4f kMagenta = {1, 0, 1, 1};
|
||||
} // namespace SkColors
|
||||
#endif
|
||||
90
src/deps/skia/include/core/SkColorFilter.h
Normal file
90
src/deps/skia/include/core/SkColorFilter.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkColorFilter_DEFINED
|
||||
#define SkColorFilter_DEFINED
|
||||
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
|
||||
class SkColorMatrix;
|
||||
|
||||
/**
|
||||
* ColorFilters are optional objects in the drawing pipeline. When present in
|
||||
* a paint, they are called with the "src" colors, and return new colors, which
|
||||
* are then passed onto the next stage (either ImageFilter or Xfermode).
|
||||
*
|
||||
* All subclasses are required to be reentrant-safe : it must be legal to share
|
||||
* the same instance between several threads.
|
||||
*/
|
||||
class SK_API SkColorFilter : public SkFlattenable {
|
||||
public:
|
||||
/** If the filter can be represented by a source color plus Mode, this
|
||||
* returns true, and sets (if not NULL) the color and mode appropriately.
|
||||
* If not, this returns false and ignores the parameters.
|
||||
*/
|
||||
bool asAColorMode(SkColor* color, SkBlendMode* mode) const;
|
||||
|
||||
/** If the filter can be represented by a 5x4 matrix, this
|
||||
* returns true, and sets the matrix appropriately.
|
||||
* If not, this returns false and ignores the parameter.
|
||||
*/
|
||||
bool asAColorMatrix(float matrix[20]) const;
|
||||
|
||||
// Returns true if the filter is guaranteed to never change the alpha of a color it filters.
|
||||
bool isAlphaUnchanged() const;
|
||||
|
||||
SkColor filterColor(SkColor) const;
|
||||
|
||||
/**
|
||||
* Converts the src color (in src colorspace), into the dst colorspace,
|
||||
* then applies this filter to it, returning the filtered color in the dst colorspace.
|
||||
*/
|
||||
SkColor4f filterColor4f(const SkColor4f& srcColor, SkColorSpace* srcCS,
|
||||
SkColorSpace* dstCS) const;
|
||||
|
||||
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
|
||||
* this filter, applied to the output of the inner filter.
|
||||
*
|
||||
* result = this(inner(...))
|
||||
*/
|
||||
sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter> inner) const;
|
||||
|
||||
static sk_sp<SkColorFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
private:
|
||||
SkColorFilter() = default;
|
||||
friend class SkColorFilterBase;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
class SK_API SkColorFilters {
|
||||
public:
|
||||
static sk_sp<SkColorFilter> Compose(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner) {
|
||||
return outer ? outer->makeComposed(inner) : inner;
|
||||
}
|
||||
static sk_sp<SkColorFilter> Blend(SkColor c, SkBlendMode mode);
|
||||
static sk_sp<SkColorFilter> Matrix(const SkColorMatrix&);
|
||||
static sk_sp<SkColorFilter> Matrix(const float rowMajor[20]);
|
||||
|
||||
// A version of Matrix which operates in HSLA space instead of RGBA.
|
||||
// I.e. HSLA-to-RGBA(Matrix(RGBA-to-HSLA(input))).
|
||||
static sk_sp<SkColorFilter> HSLAMatrix(const SkColorMatrix&);
|
||||
static sk_sp<SkColorFilter> HSLAMatrix(const float rowMajor[20]);
|
||||
|
||||
static sk_sp<SkColorFilter> LinearToSRGBGamma();
|
||||
static sk_sp<SkColorFilter> SRGBToLinearGamma();
|
||||
static sk_sp<SkColorFilter> Lerp(float t, sk_sp<SkColorFilter> dst, sk_sp<SkColorFilter> src);
|
||||
|
||||
private:
|
||||
SkColorFilters() = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
152
src/deps/skia/include/core/SkColorPriv.h
Normal file
152
src/deps/skia/include/core/SkColorPriv.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkColorPriv_DEFINED
|
||||
#define SkColorPriv_DEFINED
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkMath.h"
|
||||
#include "include/private/SkTPin.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
/** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a
|
||||
byte into a scale value, so that we can say scale * value >> 8 instead of
|
||||
alpha * value / 255.
|
||||
|
||||
In debugging, asserts that alpha is 0..255
|
||||
*/
|
||||
static inline unsigned SkAlpha255To256(U8CPU alpha) {
|
||||
SkASSERT(SkToU8(alpha) == alpha);
|
||||
// this one assues that blending on top of an opaque dst keeps it that way
|
||||
// even though it is less accurate than a+(a>>7) for non-opaque dsts
|
||||
return alpha + 1;
|
||||
}
|
||||
|
||||
/** Multiplify value by 0..256, and shift the result down 8
|
||||
(i.e. return (value * alpha256) >> 8)
|
||||
*/
|
||||
#define SkAlphaMul(value, alpha256) (((value) * (alpha256)) >> 8)
|
||||
|
||||
static inline U8CPU SkUnitScalarClampToByte(SkScalar x) {
|
||||
return static_cast<U8CPU>(SkTPin(x, 0.0f, 1.0f) * 255 + 0.5);
|
||||
}
|
||||
|
||||
#define SK_A32_BITS 8
|
||||
#define SK_R32_BITS 8
|
||||
#define SK_G32_BITS 8
|
||||
#define SK_B32_BITS 8
|
||||
|
||||
#define SK_A32_MASK ((1 << SK_A32_BITS) - 1)
|
||||
#define SK_R32_MASK ((1 << SK_R32_BITS) - 1)
|
||||
#define SK_G32_MASK ((1 << SK_G32_BITS) - 1)
|
||||
#define SK_B32_MASK ((1 << SK_B32_BITS) - 1)
|
||||
|
||||
/*
|
||||
* Skia's 32bit backend only supports 1 swizzle order at a time (compile-time).
|
||||
* This is specified by SK_R32_SHIFT=0 or SK_R32_SHIFT=16.
|
||||
*
|
||||
* For easier compatibility with Skia's GPU backend, we further restrict these
|
||||
* to either (in memory-byte-order) RGBA or BGRA. Note that this "order" does
|
||||
* not directly correspond to the same shift-order, since we have to take endianess
|
||||
* into account.
|
||||
*
|
||||
* Here we enforce this constraint.
|
||||
*/
|
||||
|
||||
#define SK_RGBA_R32_SHIFT 0
|
||||
#define SK_RGBA_G32_SHIFT 8
|
||||
#define SK_RGBA_B32_SHIFT 16
|
||||
#define SK_RGBA_A32_SHIFT 24
|
||||
|
||||
#define SK_BGRA_B32_SHIFT 0
|
||||
#define SK_BGRA_G32_SHIFT 8
|
||||
#define SK_BGRA_R32_SHIFT 16
|
||||
#define SK_BGRA_A32_SHIFT 24
|
||||
|
||||
#if defined(SK_PMCOLOR_IS_RGBA) || defined(SK_PMCOLOR_IS_BGRA)
|
||||
#error "Configure PMCOLOR by setting SK_R32_SHIFT."
|
||||
#endif
|
||||
|
||||
// Deduce which SK_PMCOLOR_IS_ to define from the _SHIFT defines
|
||||
|
||||
#if (SK_A32_SHIFT == SK_RGBA_A32_SHIFT && \
|
||||
SK_R32_SHIFT == SK_RGBA_R32_SHIFT && \
|
||||
SK_G32_SHIFT == SK_RGBA_G32_SHIFT && \
|
||||
SK_B32_SHIFT == SK_RGBA_B32_SHIFT)
|
||||
#define SK_PMCOLOR_IS_RGBA
|
||||
#elif (SK_A32_SHIFT == SK_BGRA_A32_SHIFT && \
|
||||
SK_R32_SHIFT == SK_BGRA_R32_SHIFT && \
|
||||
SK_G32_SHIFT == SK_BGRA_G32_SHIFT && \
|
||||
SK_B32_SHIFT == SK_BGRA_B32_SHIFT)
|
||||
#define SK_PMCOLOR_IS_BGRA
|
||||
#else
|
||||
#error "need 32bit packing to be either RGBA or BGRA"
|
||||
#endif
|
||||
|
||||
#define SkGetPackedA32(packed) ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
|
||||
#define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
|
||||
#define SkGetPackedG32(packed) ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
|
||||
#define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
|
||||
|
||||
#define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK)
|
||||
#define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK)
|
||||
#define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK)
|
||||
#define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK)
|
||||
|
||||
/**
|
||||
* Pack the components into a SkPMColor, checking (in the debug version) that
|
||||
* the components are 0..255, and are already premultiplied (i.e. alpha >= color)
|
||||
*/
|
||||
static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
||||
SkA32Assert(a);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
|
||||
return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
|
||||
(g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as SkPackARGB32, but this version guarantees to not check that the
|
||||
* values are premultiplied in the debug version.
|
||||
*/
|
||||
static inline SkPMColor SkPackARGB32NoCheck(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
||||
return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
|
||||
(g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
|
||||
}
|
||||
|
||||
static inline
|
||||
SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
||||
SkA32Assert(a);
|
||||
SkR32Assert(r);
|
||||
SkG32Assert(g);
|
||||
SkB32Assert(b);
|
||||
|
||||
if (a != 255) {
|
||||
r = SkMulDiv255Round(r, a);
|
||||
g = SkMulDiv255Round(g, a);
|
||||
b = SkMulDiv255Round(b, a);
|
||||
}
|
||||
return SkPackARGB32(a, r, g, b);
|
||||
}
|
||||
|
||||
// When Android is compiled optimizing for size, SkAlphaMulQ doesn't get
|
||||
// inlined; forcing inlining significantly improves performance.
|
||||
static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) {
|
||||
uint32_t mask = 0xFF00FF;
|
||||
|
||||
uint32_t rb = ((c & mask) * scale) >> 8;
|
||||
uint32_t ag = ((c >> 8) & mask) * scale;
|
||||
return (rb & mask) | (ag & ~mask);
|
||||
}
|
||||
|
||||
static inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst) {
|
||||
return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
|
||||
}
|
||||
|
||||
#endif
|
||||
245
src/deps/skia/include/core/SkColorSpace.h
Normal file
245
src/deps/skia/include/core/SkColorSpace.h
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkColorSpace_DEFINED
|
||||
#define SkColorSpace_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.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.
|
||||
*/
|
||||
struct SK_API SkColorSpacePrimaries {
|
||||
float fRX;
|
||||
float fRY;
|
||||
float fGX;
|
||||
float fGY;
|
||||
float fBX;
|
||||
float fBY;
|
||||
float fWX;
|
||||
float fWY;
|
||||
|
||||
/**
|
||||
* Convert primaries and a white point to a toXYZD50 matrix, the preferred color gamut
|
||||
* representation of SkColorSpace.
|
||||
*/
|
||||
bool toXYZD50(skcms_Matrix3x3* toXYZD50) const;
|
||||
};
|
||||
|
||||
namespace SkNamedTransferFn {
|
||||
|
||||
// Like SkNamedGamut::kSRGB, keeping this bitwise exactly the same as skcms makes things fastest.
|
||||
static constexpr skcms_TransferFunction kSRGB =
|
||||
{ 2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0.0f, 0.0f };
|
||||
|
||||
static constexpr skcms_TransferFunction k2Dot2 =
|
||||
{ 2.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
static constexpr skcms_TransferFunction kLinear =
|
||||
{ 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
static constexpr skcms_TransferFunction kRec2020 =
|
||||
{2.22222f, 0.909672f, 0.0903276f, 0.222222f, 0.0812429f, 0, 0};
|
||||
|
||||
static constexpr skcms_TransferFunction kPQ =
|
||||
{-2.0f, -107/128.0f, 1.0f, 32/2523.0f, 2413/128.0f, -2392/128.0f, 8192/1305.0f };
|
||||
|
||||
static constexpr skcms_TransferFunction kHLG =
|
||||
{-3.0f, 2.0f, 2.0f, 1/0.17883277f, 0.28466892f, 0.55991073f, 0.0f };
|
||||
|
||||
} // namespace SkNamedTransferFn
|
||||
|
||||
namespace SkNamedGamut {
|
||||
|
||||
static constexpr skcms_Matrix3x3 kSRGB = {{
|
||||
// ICC fixed-point (16.16) representation, taken from skcms. Please keep them exactly in sync.
|
||||
// 0.436065674f, 0.385147095f, 0.143066406f,
|
||||
// 0.222488403f, 0.716873169f, 0.060607910f,
|
||||
// 0.013916016f, 0.097076416f, 0.714096069f,
|
||||
{ SkFixedToFloat(0x6FA2), SkFixedToFloat(0x6299), SkFixedToFloat(0x24A0) },
|
||||
{ SkFixedToFloat(0x38F5), SkFixedToFloat(0xB785), SkFixedToFloat(0x0F84) },
|
||||
{ SkFixedToFloat(0x0390), SkFixedToFloat(0x18DA), SkFixedToFloat(0xB6CF) },
|
||||
}};
|
||||
|
||||
static constexpr skcms_Matrix3x3 kAdobeRGB = {{
|
||||
// ICC fixed-point (16.16) repesentation of:
|
||||
// 0.60974, 0.20528, 0.14919,
|
||||
// 0.31111, 0.62567, 0.06322,
|
||||
// 0.01947, 0.06087, 0.74457,
|
||||
{ SkFixedToFloat(0x9c18), SkFixedToFloat(0x348d), SkFixedToFloat(0x2631) },
|
||||
{ SkFixedToFloat(0x4fa5), SkFixedToFloat(0xa02c), SkFixedToFloat(0x102f) },
|
||||
{ SkFixedToFloat(0x04fc), SkFixedToFloat(0x0f95), SkFixedToFloat(0xbe9c) },
|
||||
}};
|
||||
|
||||
static constexpr skcms_Matrix3x3 kDisplayP3 = {{
|
||||
{ 0.515102f, 0.291965f, 0.157153f },
|
||||
{ 0.241182f, 0.692236f, 0.0665819f },
|
||||
{ -0.00104941f, 0.0418818f, 0.784378f },
|
||||
}};
|
||||
|
||||
static constexpr skcms_Matrix3x3 kRec2020 = {{
|
||||
{ 0.673459f, 0.165661f, 0.125100f },
|
||||
{ 0.279033f, 0.675338f, 0.0456288f },
|
||||
{ -0.00193139f, 0.0299794f, 0.797162f },
|
||||
}};
|
||||
|
||||
static constexpr skcms_Matrix3x3 kXYZ = {{
|
||||
{ 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f },
|
||||
}};
|
||||
|
||||
} // namespace SkNamedGamut
|
||||
|
||||
class SK_API SkColorSpace : public SkNVRefCnt<SkColorSpace> {
|
||||
public:
|
||||
/**
|
||||
* Create the sRGB color space.
|
||||
*/
|
||||
static sk_sp<SkColorSpace> MakeSRGB();
|
||||
|
||||
/**
|
||||
* Colorspace with the sRGB primaries, but a linear (1.0) gamma.
|
||||
*/
|
||||
static sk_sp<SkColorSpace> MakeSRGBLinear();
|
||||
|
||||
/**
|
||||
* Create an SkColorSpace from a transfer function and a row-major 3x3 transformation to XYZ.
|
||||
*/
|
||||
static sk_sp<SkColorSpace> MakeRGB(const skcms_TransferFunction& transferFn,
|
||||
const skcms_Matrix3x3& toXYZ);
|
||||
|
||||
/**
|
||||
* Create an SkColorSpace from a parsed (skcms) ICC profile.
|
||||
*/
|
||||
static sk_sp<SkColorSpace> Make(const skcms_ICCProfile&);
|
||||
|
||||
/**
|
||||
* Convert this color space to an skcms ICC profile struct.
|
||||
*/
|
||||
void toProfile(skcms_ICCProfile*) const;
|
||||
|
||||
/**
|
||||
* Returns true if the color space gamma is near enough to be approximated as sRGB.
|
||||
*/
|
||||
bool gammaCloseToSRGB() const;
|
||||
|
||||
/**
|
||||
* Returns true if the color space gamma is linear.
|
||||
*/
|
||||
bool gammaIsLinear() const;
|
||||
|
||||
/**
|
||||
* Sets |fn| to the transfer function from this color space. Returns true if the transfer
|
||||
* function can be represented as coefficients to the standard ICC 7-parameter equation.
|
||||
* Returns false otherwise (eg, PQ, HLG).
|
||||
*/
|
||||
bool isNumericalTransferFn(skcms_TransferFunction* fn) const;
|
||||
|
||||
/**
|
||||
* Returns true and sets |toXYZD50| if the color gamut can be described as a matrix.
|
||||
* Returns false otherwise.
|
||||
*/
|
||||
bool toXYZD50(skcms_Matrix3x3* toXYZD50) const;
|
||||
|
||||
/**
|
||||
* Returns a hash of the gamut transformation to XYZ D50. Allows for fast equality checking
|
||||
* of gamuts, at the (very small) risk of collision.
|
||||
*/
|
||||
uint32_t toXYZD50Hash() const { return fToXYZD50Hash; }
|
||||
|
||||
/**
|
||||
* Returns a color space with the same gamut as this one, but with a linear gamma.
|
||||
* For color spaces whose gamut can not be described in terms of XYZ D50, returns
|
||||
* linear sRGB.
|
||||
*/
|
||||
sk_sp<SkColorSpace> makeLinearGamma() const;
|
||||
|
||||
/**
|
||||
* Returns a color space with the same gamut as this one, with with the sRGB transfer
|
||||
* function. For color spaces whose gamut can not be described in terms of XYZ D50, returns
|
||||
* sRGB.
|
||||
*/
|
||||
sk_sp<SkColorSpace> makeSRGBGamma() const;
|
||||
|
||||
/**
|
||||
* Returns a color space with the same transfer function as this one, but with the primary
|
||||
* colors rotated. For any XYZ space, this produces a new color space that maps RGB to GBR
|
||||
* (when applied to a source), and maps RGB to BRG (when applied to a destination). For other
|
||||
* types of color spaces, returns nullptr.
|
||||
*
|
||||
* This is used for testing, to construct color spaces that have severe and testable behavior.
|
||||
*/
|
||||
sk_sp<SkColorSpace> makeColorSpin() const;
|
||||
|
||||
/**
|
||||
* Returns true if the color space is sRGB.
|
||||
* Returns false otherwise.
|
||||
*
|
||||
* This allows a little bit of tolerance, given that we might see small numerical error
|
||||
* in some cases: converting ICC fixed point to float, converting white point to D50,
|
||||
* rounding decisions on transfer function and matrix.
|
||||
*
|
||||
* This does not consider a 2.2f exponential transfer function to be sRGB. While these
|
||||
* functions are similar (and it is sometimes useful to consider them together), this
|
||||
* function checks for logical equality.
|
||||
*/
|
||||
bool isSRGB() const;
|
||||
|
||||
/**
|
||||
* Returns nullptr on failure. Fails when we fallback to serializing ICC data and
|
||||
* the data is too large to serialize.
|
||||
*/
|
||||
sk_sp<SkData> serialize() const;
|
||||
|
||||
/**
|
||||
* If |memory| is nullptr, returns the size required to serialize.
|
||||
* Otherwise, serializes into |memory| and returns the size.
|
||||
*/
|
||||
size_t writeToMemory(void* memory) const;
|
||||
|
||||
static sk_sp<SkColorSpace> Deserialize(const void* data, size_t length);
|
||||
|
||||
/**
|
||||
* If both are null, we return true. If one is null and the other is not, we return false.
|
||||
* If both are non-null, we do a deeper compare.
|
||||
*/
|
||||
static bool Equals(const SkColorSpace*, const SkColorSpace*);
|
||||
|
||||
void transferFn(float gabcdef[7]) const; // DEPRECATED: Remove when webview usage is gone
|
||||
void transferFn(skcms_TransferFunction* fn) const;
|
||||
void invTransferFn(skcms_TransferFunction* fn) const;
|
||||
void gamutTransformTo(const SkColorSpace* dst, skcms_Matrix3x3* src_to_dst) const;
|
||||
|
||||
uint32_t transferFnHash() const { return fTransferFnHash; }
|
||||
uint64_t hash() const { return (uint64_t)fTransferFnHash << 32 | fToXYZD50Hash; }
|
||||
|
||||
private:
|
||||
friend class SkColorSpaceSingletonFactory;
|
||||
|
||||
SkColorSpace(const skcms_TransferFunction& transferFn, const skcms_Matrix3x3& toXYZ);
|
||||
|
||||
void computeLazyDstFields() const;
|
||||
|
||||
uint32_t fTransferFnHash;
|
||||
uint32_t fToXYZD50Hash;
|
||||
|
||||
skcms_TransferFunction fTransferFn;
|
||||
skcms_Matrix3x3 fToXYZD50;
|
||||
|
||||
mutable skcms_TransferFunction fInvTransferFn;
|
||||
mutable skcms_Matrix3x3 fFromXYZD50;
|
||||
mutable SkOnce fLazyDstFieldsOnce;
|
||||
};
|
||||
|
||||
#endif
|
||||
131
src/deps/skia/include/core/SkContourMeasure.h
Normal file
131
src/deps/skia/include/core/SkContourMeasure.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkContourMeasure_DEFINED
|
||||
#define SkContourMeasure_DEFINED
|
||||
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
struct SkConic;
|
||||
|
||||
class SK_API SkContourMeasure : public SkRefCnt {
|
||||
public:
|
||||
/** Return the length of the contour.
|
||||
*/
|
||||
SkScalar length() const { return fLength; }
|
||||
|
||||
/** Pins distance to 0 <= distance <= length(), and then computes the corresponding
|
||||
* position and tangent.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT getPosTan(SkScalar distance, SkPoint* position,
|
||||
SkVector* tangent) const;
|
||||
|
||||
enum MatrixFlags {
|
||||
kGetPosition_MatrixFlag = 0x01,
|
||||
kGetTangent_MatrixFlag = 0x02,
|
||||
kGetPosAndTan_MatrixFlag = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
|
||||
};
|
||||
|
||||
/** Pins distance to 0 <= distance <= getLength(), and then computes
|
||||
the corresponding matrix (by calling getPosTan).
|
||||
Returns false if there is no path, or a zero-length path was specified, in which case
|
||||
matrix is unchanged.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT getMatrix(SkScalar distance, SkMatrix* matrix,
|
||||
MatrixFlags flags = kGetPosAndTan_MatrixFlag) const;
|
||||
|
||||
/** Given a start and stop distance, return in dst the intervening segment(s).
|
||||
If the segment is zero-length, return false, else return true.
|
||||
startD and stopD are pinned to legal values (0..getLength()). If startD > stopD
|
||||
then return false (and leave dst untouched).
|
||||
Begin the segment with a moveTo if startWithMoveTo is true
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT getSegment(SkScalar startD, SkScalar stopD, SkPath* dst,
|
||||
bool startWithMoveTo) const;
|
||||
|
||||
/** Return true if the contour is closed()
|
||||
*/
|
||||
bool isClosed() const { return fIsClosed; }
|
||||
|
||||
private:
|
||||
struct Segment {
|
||||
SkScalar fDistance; // total distance up to this point
|
||||
unsigned fPtIndex; // index into the fPts array
|
||||
unsigned fTValue : 30;
|
||||
unsigned fType : 2; // actually the enum SkSegType
|
||||
// See SkPathMeasurePriv.h
|
||||
|
||||
SkScalar getScalarT() const;
|
||||
|
||||
static const Segment* Next(const Segment* seg) {
|
||||
unsigned ptIndex = seg->fPtIndex;
|
||||
do {
|
||||
++seg;
|
||||
} while (seg->fPtIndex == ptIndex);
|
||||
return seg;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const SkTDArray<Segment> fSegments;
|
||||
const SkTDArray<SkPoint> fPts; // Points used to define the segments
|
||||
|
||||
const SkScalar fLength;
|
||||
const bool fIsClosed;
|
||||
|
||||
SkContourMeasure(SkTDArray<Segment>&& segs, SkTDArray<SkPoint>&& pts,
|
||||
SkScalar length, bool isClosed);
|
||||
~SkContourMeasure() override {}
|
||||
|
||||
const Segment* distanceToSegment(SkScalar distance, SkScalar* t) const;
|
||||
|
||||
friend class SkContourMeasureIter;
|
||||
};
|
||||
|
||||
class SK_API SkContourMeasureIter {
|
||||
public:
|
||||
SkContourMeasureIter();
|
||||
/**
|
||||
* Initialize the Iter with a path.
|
||||
* The parts of the path that are needed are copied, so the client is free to modify/delete
|
||||
* the path after this call.
|
||||
*
|
||||
* resScale controls the precision of the measure. values > 1 increase the
|
||||
* precision (and possibly slow down the computation).
|
||||
*/
|
||||
SkContourMeasureIter(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
|
||||
~SkContourMeasureIter();
|
||||
|
||||
/**
|
||||
* Reset the Iter with a path.
|
||||
* The parts of the path that are needed are copied, so the client is free to modify/delete
|
||||
* the path after this call.
|
||||
*/
|
||||
void reset(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
|
||||
|
||||
/**
|
||||
* Iterates through contours in path, returning a contour-measure object for each contour
|
||||
* in the path. Returns null when it is done.
|
||||
*
|
||||
* This only returns non-zero length contours, where a contour is the segments between
|
||||
* a kMove_Verb and either ...
|
||||
* - the next kMove_Verb
|
||||
* - kClose_Verb (1 or more)
|
||||
* - kDone_Verb
|
||||
* If it encounters a zero-length contour, it is skipped.
|
||||
*/
|
||||
sk_sp<SkContourMeasure> next();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
std::unique_ptr<Impl> fImpl;
|
||||
};
|
||||
|
||||
#endif
|
||||
30
src/deps/skia/include/core/SkCoverageMode.h
Normal file
30
src/deps/skia/include/core/SkCoverageMode.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCoverageMode_DEFINED
|
||||
#define SkCoverageMode_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* Describes geometric operations (ala SkRegion::Op) that can be applied to coverage bytes.
|
||||
* These can be thought of as variants of porter-duff (SkBlendMode) modes, but only applied
|
||||
* to the alpha channel.
|
||||
*
|
||||
* See SkMaskFilter for ways to use these when combining two different masks.
|
||||
*/
|
||||
enum class SkCoverageMode {
|
||||
kUnion, // A ∪ B A+B-A*B
|
||||
kIntersect, // A ∩ B A*B
|
||||
kDifference, // A - B A*(1-B)
|
||||
kReverseDifference, // B - A B*(1-A)
|
||||
kXor, // A ⊕ B A+B-2*A*B
|
||||
|
||||
kLast = kXor,
|
||||
};
|
||||
|
||||
#endif
|
||||
45
src/deps/skia/include/core/SkCubicMap.h
Normal file
45
src/deps/skia/include/core/SkCubicMap.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCubicMap_DEFINED
|
||||
#define SkCubicMap_DEFINED
|
||||
|
||||
#include "include/core/SkPoint.h"
|
||||
|
||||
/**
|
||||
* Fast evaluation of a cubic ease-in / ease-out curve. This is defined as a parametric cubic
|
||||
* curve inside the unit square.
|
||||
*
|
||||
* pt[0] is implicitly { 0, 0 }
|
||||
* pt[3] is implicitly { 1, 1 }
|
||||
* pts[1,2].X are inside the unit [0..1]
|
||||
*/
|
||||
class SK_API SkCubicMap {
|
||||
public:
|
||||
SkCubicMap(SkPoint p1, SkPoint p2);
|
||||
|
||||
static bool IsLinear(SkPoint p1, SkPoint p2) {
|
||||
return SkScalarNearlyEqual(p1.fX, p1.fY) && SkScalarNearlyEqual(p2.fX, p2.fY);
|
||||
}
|
||||
|
||||
float computeYFromX(float x) const;
|
||||
|
||||
SkPoint computeFromT(float t) const;
|
||||
|
||||
private:
|
||||
enum Type {
|
||||
kLine_Type, // x == y
|
||||
kCubeRoot_Type, // At^3 == x
|
||||
kSolver_Type, // general monotonic cubic solver
|
||||
};
|
||||
|
||||
SkPoint fCoeff[3];
|
||||
Type fType;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
202
src/deps/skia/include/core/SkCustomMesh.h
Normal file
202
src/deps/skia/include/core/SkCustomMesh.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCustomMesh_DEFINED
|
||||
#define SkCustomMesh_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSpan.h"
|
||||
#include "include/core/SkString.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace SkSL { struct Program; }
|
||||
|
||||
/**
|
||||
* A specification for custom meshes. Specifies the vertex buffer attributes and stride, the
|
||||
* vertex program that produces a user-defined set of varyings, a fragment program that ingests
|
||||
* the interpolated varyings and produces local coordinates and optionally a color.
|
||||
*
|
||||
* The signature of the vertex program must be:
|
||||
* float2 main(Attributes, out Varyings)
|
||||
* where the return value is a local position that will be transformed by SkCanvas's matrix.
|
||||
*
|
||||
* The signature of the fragment program must be either:
|
||||
* (float2|void) main(Varyings)
|
||||
* or
|
||||
* (float2|void) main(Varyings, out (half4|float4) color)
|
||||
*
|
||||
* where the return value is the local coordinates that will be used to access SkShader. If the
|
||||
* return type is void then the interpolated position from vertex shader return is used as the local
|
||||
* coordinate. If the color variant is used it will be blended with SkShader (or SkPaint color in
|
||||
* absence of a shader) using the SkBlender provided to the SkCanvas draw call.
|
||||
*/
|
||||
class SkCustomMeshSpecification : public SkNVRefCnt<SkCustomMeshSpecification> {
|
||||
public:
|
||||
/** These values are enforced when creating a specification. */
|
||||
static constexpr size_t kMaxStride = 1024;
|
||||
static constexpr size_t kMaxAttributes = 8;
|
||||
static constexpr size_t kStrideAlignment = 4;
|
||||
static constexpr size_t kOffsetAlignment = 4;
|
||||
static constexpr size_t kMaxVaryings = 6;
|
||||
|
||||
struct Attribute {
|
||||
enum class Type : uint32_t { // CPU representation Shader Type
|
||||
kFloat, // float float
|
||||
kFloat2, // two floats float2
|
||||
kFloat3, // three floats float3
|
||||
kFloat4, // four floats float4
|
||||
kUByte4_unorm, // four bytes half4
|
||||
|
||||
kLast = kUByte4_unorm
|
||||
};
|
||||
Type type;
|
||||
size_t offset;
|
||||
SkString name;
|
||||
};
|
||||
|
||||
struct Varying {
|
||||
enum class Type : uint32_t {
|
||||
kFloat, // "float"
|
||||
kFloat2, // "float2"
|
||||
kFloat3, // "float3"
|
||||
kFloat4, // "float4"
|
||||
kHalf, // "half"
|
||||
kHalf2, // "half2"
|
||||
kHalf3, // "half3"
|
||||
kHalf4, // "half4"
|
||||
|
||||
kLast = kHalf4
|
||||
};
|
||||
Type type;
|
||||
SkString name;
|
||||
};
|
||||
|
||||
~SkCustomMeshSpecification();
|
||||
|
||||
struct Result {
|
||||
sk_sp<SkCustomMeshSpecification> specification;
|
||||
SkString error;
|
||||
};
|
||||
|
||||
/**
|
||||
* If successful the return is a specification and an empty error string. Otherwise, it is a
|
||||
* null specification a non-empty error string.
|
||||
*
|
||||
* @param attributes The vertex attributes that will be consumed by 'vs'. Attributes need
|
||||
* not be tightly packed but attribute offsets must be aligned to
|
||||
* kOffsetAlignment and offset + size may not be greater than
|
||||
* 'vertexStride'. At least one attribute is required.
|
||||
* @param vertexStride The offset between successive attribute values. This must be aligned to
|
||||
* kStrideAlignment.
|
||||
* @param varyings The varyings that will be written by 'vs' and read by 'fs'. This may
|
||||
* be empty.
|
||||
* @param vs The vertex shader code that computes a vertex position and the varyings
|
||||
* from the attributes.
|
||||
* @param fs The fragment code that computes a local coordinate and optionally a
|
||||
* color from the varyings. The local coordinate is used to sample
|
||||
* SkShader.
|
||||
* @param cs The colorspace of the color produced by 'fs'. Ignored if 'fs's main()
|
||||
* function does not have a color out param.
|
||||
* @param at The alpha type of the color produced by 'fs'. Ignored if 'fs's main()
|
||||
* function does not have a color out param. Cannot be kUnknown.
|
||||
*/
|
||||
static Result Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs = SkColorSpace::MakeSRGB(),
|
||||
SkAlphaType at = kPremul_SkAlphaType);
|
||||
|
||||
SkSpan<const Attribute> attributes() const { return SkMakeSpan(fAttributes); }
|
||||
|
||||
size_t stride() const { return fStride; }
|
||||
|
||||
private:
|
||||
friend struct SkCustomMeshSpecificationPriv;
|
||||
|
||||
enum class ColorType {
|
||||
kNone,
|
||||
kHalf4,
|
||||
kFloat4,
|
||||
};
|
||||
|
||||
static Result MakeFromSourceWithStructs(SkSpan<const Attribute> attributes,
|
||||
size_t stride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at);
|
||||
|
||||
SkCustomMeshSpecification(SkSpan<const Attribute>,
|
||||
size_t,
|
||||
SkSpan<const Varying>,
|
||||
std::unique_ptr<SkSL::Program>,
|
||||
std::unique_ptr<SkSL::Program>,
|
||||
ColorType,
|
||||
bool hasLocalCoords,
|
||||
sk_sp<SkColorSpace>,
|
||||
SkAlphaType);
|
||||
|
||||
SkCustomMeshSpecification(const SkCustomMeshSpecification&) = delete;
|
||||
SkCustomMeshSpecification(SkCustomMeshSpecification&&) = delete;
|
||||
|
||||
SkCustomMeshSpecification& operator=(const SkCustomMeshSpecification&) = delete;
|
||||
SkCustomMeshSpecification& operator=(SkCustomMeshSpecification&&) = delete;
|
||||
|
||||
const std::vector<Attribute> fAttributes;
|
||||
const std::vector<Varying> fVaryings;
|
||||
std::unique_ptr<SkSL::Program> fVS;
|
||||
std::unique_ptr<SkSL::Program> fFS;
|
||||
size_t fStride;
|
||||
uint32_t fHash;
|
||||
ColorType fColorType;
|
||||
bool fHasLocalCoords;
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
SkAlphaType fAlphaType;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a placeholder object. We will want something that allows the client to incrementally
|
||||
* update the mesh that can be synchronized with the GPU backend without requiring extra copies.
|
||||
*
|
||||
* A buffer of vertices, a topology, optionally indices, and a compatible SkCustomMeshSpecification.
|
||||
* The data in 'vb' is expected to contain the attributes described in 'spec' for 'vcount' vertices.
|
||||
* The size of the buffer must be at least spec->stride()*vcount (even if vertex attributes contains
|
||||
* pad at the end of the stride). If 'bounds' does not contain all points output by 'spec''s vertex
|
||||
* program when applied to the vertices in 'vb' a draw of the custom mesh produces undefined
|
||||
* results.
|
||||
*
|
||||
* If indices is null then then 'icount' must be <= 0. 'vcount' vertices will be selected from 'vb'
|
||||
* to create the topology indicated by 'mode'.
|
||||
*
|
||||
* If indices is not null then icount must be >= 3. 'vb' will be indexed by 'icount' successive
|
||||
* values in 'indices' to create the topology indicated by 'mode'. The values in 'indices' must be
|
||||
* less than 'vcount'
|
||||
*/
|
||||
struct SkCustomMesh {
|
||||
enum class Mode { kTriangles, kTriangleStrip };
|
||||
sk_sp<SkCustomMeshSpecification> spec;
|
||||
Mode mode = Mode::kTriangles;
|
||||
SkRect bounds = SkRect::MakeEmpty();
|
||||
const void* vb = nullptr;
|
||||
int vcount = 0;
|
||||
const uint16_t* indices = nullptr;
|
||||
int icount = 0;
|
||||
};
|
||||
|
||||
#endif // SK_ENABLE_SKSL
|
||||
|
||||
#endif
|
||||
188
src/deps/skia/include/core/SkData.h
Normal file
188
src/deps/skia/include/core/SkData.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkData_DEFINED
|
||||
#define SkData_DEFINED
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
class SkStream;
|
||||
|
||||
/**
|
||||
* SkData holds an immutable data buffer. Not only is the data immutable,
|
||||
* but the actual ptr that is returned (by data() or bytes()) is guaranteed
|
||||
* to always be the same for the life of this instance.
|
||||
*/
|
||||
class SK_API SkData final : public SkNVRefCnt<SkData> {
|
||||
public:
|
||||
/**
|
||||
* Returns the number of bytes stored.
|
||||
*/
|
||||
size_t size() const { return fSize; }
|
||||
|
||||
bool isEmpty() const { return 0 == fSize; }
|
||||
|
||||
/**
|
||||
* Returns the ptr to the data.
|
||||
*/
|
||||
const void* data() const { return fPtr; }
|
||||
|
||||
/**
|
||||
* Like data(), returns a read-only ptr into the data, but in this case
|
||||
* it is cast to uint8_t*, to make it easy to add an offset to it.
|
||||
*/
|
||||
const uint8_t* bytes() const {
|
||||
return reinterpret_cast<const uint8_t*>(fPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* USE WITH CAUTION.
|
||||
* This call will assert that the refcnt is 1, as a precaution against modifying the
|
||||
* contents when another client/thread has access to the data.
|
||||
*/
|
||||
void* writable_data() {
|
||||
if (fSize) {
|
||||
// only assert we're unique if we're not empty
|
||||
SkASSERT(this->unique());
|
||||
}
|
||||
return const_cast<void*>(fPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to copy a range of the data into a caller-provided buffer.
|
||||
* Returns the actual number of bytes copied, after clamping offset and
|
||||
* length to the size of the data. If buffer is NULL, it is ignored, and
|
||||
* only the computed number of bytes is returned.
|
||||
*/
|
||||
size_t copyRange(size_t offset, size_t length, void* buffer) const;
|
||||
|
||||
/**
|
||||
* Returns true if these two objects have the same length and contents,
|
||||
* effectively returning 0 == memcmp(...)
|
||||
*/
|
||||
bool equals(const SkData* other) const;
|
||||
|
||||
/**
|
||||
* Function that, if provided, will be called when the SkData goes out
|
||||
* of scope, allowing for custom allocation/freeing of the data's contents.
|
||||
*/
|
||||
typedef void (*ReleaseProc)(const void* ptr, void* context);
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified data
|
||||
*/
|
||||
static sk_sp<SkData> MakeWithCopy(const void* data, size_t length);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new data with uninitialized contents. The caller should call writable_data()
|
||||
* to write into the buffer, but this must be done before another ref() is made.
|
||||
*/
|
||||
static sk_sp<SkData> MakeUninitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new data with zero-initialized contents. The caller should call writable_data()
|
||||
* to write into the buffer, but this must be done before another ref() is made.
|
||||
*/
|
||||
static sk_sp<SkData> MakeZeroInitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified c-string
|
||||
* (a null-terminated array of bytes). The returned SkData will have size()
|
||||
* equal to strlen(cstr) + 1. If cstr is NULL, it will be treated the same
|
||||
* as "".
|
||||
*/
|
||||
static sk_sp<SkData> MakeWithCString(const char cstr[]);
|
||||
|
||||
/**
|
||||
* Create a new dataref, taking the ptr as is, and using the
|
||||
* releaseproc to free it. The proc may be NULL.
|
||||
*/
|
||||
static sk_sp<SkData> MakeWithProc(const void* ptr, size_t length, ReleaseProc proc, void* ctx);
|
||||
|
||||
/**
|
||||
* Call this when the data parameter is already const and will outlive the lifetime of the
|
||||
* SkData. Suitable for with const globals.
|
||||
*/
|
||||
static sk_sp<SkData> MakeWithoutCopy(const void* data, size_t length) {
|
||||
return MakeWithProc(data, length, NoopReleaseProc, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new dataref from a pointer allocated by malloc. The Data object
|
||||
* takes ownership of that allocation, and will handling calling sk_free.
|
||||
*/
|
||||
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().
|
||||
*/
|
||||
static sk_sp<SkData> MakeFromStream(SkStream*, size_t size);
|
||||
|
||||
/**
|
||||
* Create a new dataref using a subset of the data in the specified
|
||||
* src dataref.
|
||||
*/
|
||||
static sk_sp<SkData> MakeSubset(const SkData* src, size_t offset, size_t length);
|
||||
|
||||
/**
|
||||
* Returns a new empty dataref (or a reference to a shared empty dataref).
|
||||
* New or shared, the caller must see that unref() is eventually called.
|
||||
*/
|
||||
static sk_sp<SkData> MakeEmpty();
|
||||
|
||||
private:
|
||||
friend class SkNVRefCnt<SkData>;
|
||||
ReleaseProc fReleaseProc;
|
||||
void* fReleaseProcContext;
|
||||
const void* fPtr;
|
||||
size_t fSize;
|
||||
|
||||
SkData(const void* ptr, size_t size, ReleaseProc, void* context);
|
||||
explicit SkData(size_t size); // inplace new/delete
|
||||
~SkData();
|
||||
|
||||
// Ensure the unsized delete is called.
|
||||
void operator delete(void* p);
|
||||
|
||||
// shared internal factory
|
||||
static sk_sp<SkData> PrivateNewWithCopy(const void* srcOrNull, size_t length);
|
||||
|
||||
static void NoopReleaseProc(const void*, void*); // {}
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
#endif
|
||||
118
src/deps/skia/include/core/SkDataTable.h
Normal file
118
src/deps/skia/include/core/SkDataTable.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDataTable_DEFINED
|
||||
#define SkDataTable_DEFINED
|
||||
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
/**
|
||||
* Like SkData, SkDataTable holds an immutable data buffer. The data buffer is
|
||||
* organized into a table of entries, each with a length, so the entries are
|
||||
* not required to all be the same size.
|
||||
*/
|
||||
class SK_API SkDataTable : public SkRefCnt {
|
||||
public:
|
||||
/**
|
||||
* Returns true if the table is empty (i.e. has no entries).
|
||||
*/
|
||||
bool isEmpty() const { return 0 == fCount; }
|
||||
|
||||
/**
|
||||
* Return the number of entries in the table. 0 for an empty table
|
||||
*/
|
||||
int count() const { return fCount; }
|
||||
|
||||
/**
|
||||
* Return the size of the index'th entry in the table. The caller must
|
||||
* ensure that index is valid for this table.
|
||||
*/
|
||||
size_t atSize(int index) const;
|
||||
|
||||
/**
|
||||
* Return a pointer to the data of the index'th entry in the table.
|
||||
* The caller must ensure that index is valid for this table.
|
||||
*
|
||||
* @param size If non-null, this returns the byte size of this entry. This
|
||||
* will be the same value that atSize(index) would return.
|
||||
*/
|
||||
const void* at(int index, size_t* size = nullptr) const;
|
||||
|
||||
template <typename T>
|
||||
const T* atT(int index, size_t* size = nullptr) const {
|
||||
return reinterpret_cast<const T*>(this->at(index, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index'th entry as a c-string, and assumes that the trailing
|
||||
* null byte had been copied into the table as well.
|
||||
*/
|
||||
const char* atStr(int index) const {
|
||||
size_t size;
|
||||
const char* str = this->atT<const char>(index, &size);
|
||||
SkASSERT(strlen(str) + 1 == size);
|
||||
return str;
|
||||
}
|
||||
|
||||
typedef void (*FreeProc)(void* context);
|
||||
|
||||
static sk_sp<SkDataTable> MakeEmpty();
|
||||
|
||||
/**
|
||||
* Return a new DataTable that contains a copy of the data stored in each
|
||||
* "array".
|
||||
*
|
||||
* @param ptrs array of points to each element to be copied into the table.
|
||||
* @param sizes array of byte-lengths for each entry in the corresponding
|
||||
* ptrs[] array.
|
||||
* @param count the number of array elements in ptrs[] and sizes[] to copy.
|
||||
*/
|
||||
static sk_sp<SkDataTable> MakeCopyArrays(const void * const * ptrs,
|
||||
const size_t sizes[], int count);
|
||||
|
||||
/**
|
||||
* Return a new table that contains a copy of the data in array.
|
||||
*
|
||||
* @param array contiguous array of data for all elements to be copied.
|
||||
* @param elemSize byte-length for a given element.
|
||||
* @param count the number of entries to be copied out of array. The number
|
||||
* of bytes that will be copied is count * elemSize.
|
||||
*/
|
||||
static sk_sp<SkDataTable> MakeCopyArray(const void* array, size_t elemSize, int count);
|
||||
|
||||
static sk_sp<SkDataTable> MakeArrayProc(const void* array, size_t elemSize, int count,
|
||||
FreeProc proc, void* context);
|
||||
|
||||
private:
|
||||
struct Dir {
|
||||
const void* fPtr;
|
||||
uintptr_t fSize;
|
||||
};
|
||||
|
||||
int fCount;
|
||||
size_t fElemSize;
|
||||
union {
|
||||
const Dir* fDir;
|
||||
const char* fElems;
|
||||
} fU;
|
||||
|
||||
FreeProc fFreeProc;
|
||||
void* fFreeProcContext;
|
||||
|
||||
SkDataTable();
|
||||
SkDataTable(const void* array, size_t elemSize, int count,
|
||||
FreeProc, void* context);
|
||||
SkDataTable(const Dir*, int count, FreeProc, void* context);
|
||||
~SkDataTable() override;
|
||||
|
||||
friend class SkDataTableBuilder; // access to Dir
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
#endif
|
||||
110
src/deps/skia/include/core/SkDeferredDisplayList.h
Normal file
110
src/deps/skia/include/core/SkDeferredDisplayList.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDeferredDisplayList_DEFINED
|
||||
#define SkDeferredDisplayList_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSurfaceCharacterization.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkDeferredDisplayListPriv;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "include/private/SkTArray.h"
|
||||
#include <map>
|
||||
class GrRenderTask;
|
||||
class GrRenderTargetProxy;
|
||||
#else
|
||||
using GrRenderTargetProxy = SkRefCnt;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This class contains pre-processed gpu operations that can be replayed into
|
||||
* an SkSurface via SkSurface::draw(SkDeferredDisplayList*).
|
||||
*/
|
||||
class SkDeferredDisplayList : public SkNVRefCnt<SkDeferredDisplayList> {
|
||||
public:
|
||||
SK_API ~SkDeferredDisplayList();
|
||||
|
||||
SK_API const SkSurfaceCharacterization& characterization() const {
|
||||
return fCharacterization;
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* Iterate through the programs required by the DDL.
|
||||
*/
|
||||
class SK_API ProgramIterator {
|
||||
public:
|
||||
ProgramIterator(GrDirectContext*, SkDeferredDisplayList*);
|
||||
~ProgramIterator();
|
||||
|
||||
// This returns true if any work was done. Getting a cache hit does not count as work.
|
||||
bool compile();
|
||||
bool done() const;
|
||||
void next();
|
||||
|
||||
private:
|
||||
GrDirectContext* fDContext;
|
||||
const SkTArray<GrRecordingContext::ProgramData>& fProgramData;
|
||||
int fIndex;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Provides access to functions that aren't part of the public API.
|
||||
SkDeferredDisplayListPriv priv();
|
||||
const SkDeferredDisplayListPriv priv() const; // NOLINT(readability-const-return-type)
|
||||
|
||||
private:
|
||||
friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fArenas'
|
||||
friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
|
||||
friend class SkDeferredDisplayListPriv;
|
||||
|
||||
// This object is the source from which the lazy proxy backing the DDL will pull its backing
|
||||
// texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
|
||||
// can outlive the DDL.
|
||||
class LazyProxyData : public SkRefCnt {
|
||||
#if SK_SUPPORT_GPU
|
||||
public:
|
||||
// Upon being replayed - this field will be filled in (by the DrawingManager) with the
|
||||
// proxy backing the destination SkSurface. Note that, since there is no good place to
|
||||
// clear it, it can become a dangling pointer. Additionally, since the renderTargetProxy
|
||||
// doesn't get a ref here, the SkSurface that owns it must remain alive until the DDL
|
||||
// is flushed.
|
||||
// TODO: the drawing manager could ref the renderTargetProxy for the DDL and then add
|
||||
// a renderingTask to unref it after the DDL's ops have been executed.
|
||||
GrRenderTargetProxy* fReplayDest = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
|
||||
sk_sp<GrRenderTargetProxy> fTargetProxy,
|
||||
sk_sp<LazyProxyData>);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
const SkTArray<GrRecordingContext::ProgramData>& programData() const {
|
||||
return fProgramData;
|
||||
}
|
||||
#endif
|
||||
|
||||
const SkSurfaceCharacterization fCharacterization;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
// These are ordered such that the destructor cleans op tasks up first (which may refer back
|
||||
// to the arena and memory pool in their destructors).
|
||||
GrRecordingContext::OwnedArenas fArenas;
|
||||
SkTArray<sk_sp<GrRenderTask>> fRenderTasks;
|
||||
|
||||
SkTArray<GrRecordingContext::ProgramData> fProgramData;
|
||||
sk_sp<GrRenderTargetProxy> fTargetProxy;
|
||||
sk_sp<LazyProxyData> fLazyProxyData;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
97
src/deps/skia/include/core/SkDeferredDisplayListRecorder.h
Normal file
97
src/deps/skia/include/core/SkDeferredDisplayListRecorder.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDeferredDisplayListRecorder_DEFINED
|
||||
#define SkDeferredDisplayListRecorder_DEFINED
|
||||
|
||||
#include "include/core/SkDeferredDisplayList.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSurfaceCharacterization.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class GrBackendFormat;
|
||||
class GrBackendTexture;
|
||||
class GrRecordingContext;
|
||||
class GrYUVABackendTextureInfo;
|
||||
class SkCanvas;
|
||||
class SkSurface;
|
||||
|
||||
/*
|
||||
* This class is intended to be used as:
|
||||
* Get an SkSurfaceCharacterization representing the intended gpu-backed destination SkSurface
|
||||
* Create one of these (an SkDeferredDisplayListRecorder) on the stack
|
||||
* Get the canvas and render into it
|
||||
* Snap off and hold on to an SkDeferredDisplayList
|
||||
* Once your app actually needs the pixels, call SkSurface::draw(SkDeferredDisplayList*)
|
||||
*
|
||||
* This class never accesses the GPU but performs all the cpu work it can. It
|
||||
* is thread-safe (i.e., one can break a scene into tiles and perform their cpu-side
|
||||
* work in parallel ahead of time).
|
||||
*/
|
||||
class SK_API SkDeferredDisplayListRecorder {
|
||||
public:
|
||||
SkDeferredDisplayListRecorder(const SkSurfaceCharacterization&);
|
||||
~SkDeferredDisplayListRecorder();
|
||||
|
||||
const SkSurfaceCharacterization& characterization() const {
|
||||
return fCharacterization;
|
||||
}
|
||||
|
||||
// The backing canvas will become invalid (and this entry point will return
|
||||
// null) once 'detach' is called.
|
||||
// Note: ownership of the SkCanvas is not transferred via this call.
|
||||
SkCanvas* getCanvas();
|
||||
|
||||
sk_sp<SkDeferredDisplayList> detach();
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
using PromiseImageTextureContext = SkImage::PromiseImageTextureContext;
|
||||
using PromiseImageTextureFulfillProc = SkImage::PromiseImageTextureFulfillProc;
|
||||
using PromiseImageTextureReleaseProc = SkImage::PromiseImageTextureReleaseProc;
|
||||
|
||||
#ifndef SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
|
||||
/** Deprecated: Use SkImage::MakePromiseTexture instead. */
|
||||
sk_sp<SkImage> makePromiseTexture(const GrBackendFormat& backendFormat,
|
||||
int width,
|
||||
int height,
|
||||
GrMipmapped mipMapped,
|
||||
GrSurfaceOrigin origin,
|
||||
SkColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureContext textureContext);
|
||||
|
||||
/** Deprecated: Use SkImage::MakePromiseYUVATexture instead. */
|
||||
sk_sp<SkImage> makeYUVAPromiseTexture(const GrYUVABackendTextureInfo& yuvaBackendTextureInfo,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureContext textureContexts[]);
|
||||
#endif // SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
private:
|
||||
SkDeferredDisplayListRecorder(const SkDeferredDisplayListRecorder&) = delete;
|
||||
SkDeferredDisplayListRecorder& operator=(const SkDeferredDisplayListRecorder&) = delete;
|
||||
|
||||
bool init();
|
||||
|
||||
const SkSurfaceCharacterization fCharacterization;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrRecordingContext> fContext;
|
||||
sk_sp<GrRenderTargetProxy> fTargetProxy;
|
||||
sk_sp<SkDeferredDisplayList::LazyProxyData> fLazyProxyData;
|
||||
sk_sp<SkSurface> fSurface;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
91
src/deps/skia/include/core/SkDocument.h
Normal file
91
src/deps/skia/include/core/SkDocument.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDocument_DEFINED
|
||||
#define SkDocument_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
class SkCanvas;
|
||||
class SkWStream;
|
||||
struct SkRect;
|
||||
|
||||
/** SK_ScalarDefaultDPI is 72 dots per inch. */
|
||||
static constexpr SkScalar SK_ScalarDefaultRasterDPI = 72.0f;
|
||||
|
||||
/**
|
||||
* High-level API for creating a document-based canvas. To use..
|
||||
*
|
||||
* 1. Create a document, specifying a stream to store the output.
|
||||
* 2. For each "page" of content:
|
||||
* a. canvas = doc->beginPage(...)
|
||||
* b. draw_my_content(canvas);
|
||||
* c. doc->endPage();
|
||||
* 3. Close the document with doc->close().
|
||||
*/
|
||||
class SK_API SkDocument : public SkRefCnt {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Begin a new page for the document, returning the canvas that will draw
|
||||
* into the page. The document owns this canvas, and it will go out of
|
||||
* scope when endPage() or close() is called, or the document is deleted.
|
||||
*/
|
||||
SkCanvas* beginPage(SkScalar width, SkScalar height, const SkRect* content = nullptr);
|
||||
|
||||
/**
|
||||
* Call endPage() when the content for the current page has been drawn
|
||||
* (into the canvas returned by beginPage()). After this call the canvas
|
||||
* returned by beginPage() will be out-of-scope.
|
||||
*/
|
||||
void endPage();
|
||||
|
||||
/**
|
||||
* Call close() when all pages have been drawn. This will close the file
|
||||
* or stream holding the document's contents. After close() the document
|
||||
* can no longer add new pages. Deleting the document will automatically
|
||||
* call close() if need be.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Call abort() to stop producing the document immediately.
|
||||
* The stream output must be ignored, and should not be trusted.
|
||||
*/
|
||||
void abort();
|
||||
|
||||
protected:
|
||||
SkDocument(SkWStream*);
|
||||
|
||||
// note: subclasses must call close() in their destructor, as the base class
|
||||
// cannot do this for them.
|
||||
~SkDocument() override;
|
||||
|
||||
virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height) = 0;
|
||||
virtual void onEndPage() = 0;
|
||||
virtual void onClose(SkWStream*) = 0;
|
||||
virtual void onAbort() = 0;
|
||||
|
||||
// Allows subclasses to write to the stream as pages are written.
|
||||
SkWStream* getStream() { return fStream; }
|
||||
|
||||
enum State {
|
||||
kBetweenPages_State,
|
||||
kInPage_State,
|
||||
kClosed_State
|
||||
};
|
||||
State getState() const { return fState; }
|
||||
|
||||
private:
|
||||
SkWStream* fStream;
|
||||
State fState;
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
#endif
|
||||
135
src/deps/skia/include/core/SkDrawLooper.h
Normal file
135
src/deps/skia/include/core/SkDrawLooper.h
Normal file
@@ -0,0 +1,135 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkDrawLooper_DEFINED
|
||||
#define SkDrawLooper_DEFINED
|
||||
|
||||
#include "include/core/SkBlurTypes.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include <functional> // std::function
|
||||
|
||||
#ifndef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
#error "SkDrawLooper is unsupported"
|
||||
#endif
|
||||
|
||||
class SkArenaAlloc;
|
||||
class SkCanvas;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
struct SkRect;
|
||||
|
||||
/** \class SkDrawLooper
|
||||
DEPRECATED: No longer supported in Skia.
|
||||
*/
|
||||
class SK_API SkDrawLooper : public SkFlattenable {
|
||||
public:
|
||||
/**
|
||||
* Holds state during a draw. Users call next() until it returns false.
|
||||
*
|
||||
* Subclasses of SkDrawLooper should create a subclass of this object to
|
||||
* hold state specific to their subclass.
|
||||
*/
|
||||
class SK_API Context {
|
||||
public:
|
||||
Context() {}
|
||||
virtual ~Context() {}
|
||||
|
||||
struct Info {
|
||||
SkVector fTranslate;
|
||||
bool fApplyPostCTM;
|
||||
|
||||
void applyToCTM(SkMatrix* ctm) const;
|
||||
void applyToCanvas(SkCanvas*) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called in a loop on objects returned by SkDrawLooper::createContext().
|
||||
* Each time true is returned, the object is drawn (possibly with a modified
|
||||
* canvas and/or paint). When false is finally returned, drawing for the object
|
||||
* stops.
|
||||
*
|
||||
* On each call, the paint will be in its original state, but the
|
||||
* canvas will be as it was following the previous call to next() or
|
||||
* createContext().
|
||||
*
|
||||
* The implementation must ensure that, when next() finally returns
|
||||
* false, the canvas has been restored to the state it was
|
||||
* initially, before createContext() was first called.
|
||||
*/
|
||||
virtual bool next(Info*, SkPaint*) = 0;
|
||||
|
||||
private:
|
||||
Context(const Context&) = delete;
|
||||
Context& operator=(const Context&) = delete;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called right before something is being drawn. Returns a Context
|
||||
* whose next() method should be called until it returns false.
|
||||
*/
|
||||
virtual Context* makeContext(SkArenaAlloc*) const = 0;
|
||||
|
||||
/**
|
||||
* The fast bounds functions are used to enable the paint to be culled early
|
||||
* in the drawing pipeline. If a subclass can support this feature it must
|
||||
* return true for the canComputeFastBounds() function. If that function
|
||||
* returns false then computeFastBounds behavior is undefined otherwise it
|
||||
* is expected to have the following behavior. Given the parent paint and
|
||||
* the parent's bounding rect the subclass must fill in and return the
|
||||
* storage rect, where the storage rect is with the union of the src rect
|
||||
* and the looper's bounding rect.
|
||||
*/
|
||||
bool canComputeFastBounds(const SkPaint& paint) const;
|
||||
void computeFastBounds(const SkPaint& paint, const SkRect& src, SkRect* dst) const;
|
||||
|
||||
struct BlurShadowRec {
|
||||
SkScalar fSigma;
|
||||
SkVector fOffset;
|
||||
SkColor fColor;
|
||||
SkBlurStyle fStyle;
|
||||
};
|
||||
/**
|
||||
* If this looper can be interpreted as having two layers, such that
|
||||
* 1. The first layer (bottom most) just has a blur and translate
|
||||
* 2. The second layer has no modifications to either paint or canvas
|
||||
* 3. No other layers.
|
||||
* then return true, and if not null, fill out the BlurShadowRec).
|
||||
*
|
||||
* If any of the above are not met, return false and ignore the BlurShadowRec parameter.
|
||||
*/
|
||||
virtual bool asABlurShadow(BlurShadowRec*) const;
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkDrawLooper_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkDrawLooper_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkDrawLooper> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkDrawLooper>(static_cast<SkDrawLooper*>(
|
||||
SkFlattenable::Deserialize(
|
||||
kSkDrawLooper_Type, data, size, procs).release()));
|
||||
}
|
||||
|
||||
void apply(SkCanvas* canvas, const SkPaint& paint,
|
||||
std::function<void(SkCanvas*, const SkPaint&)>);
|
||||
|
||||
protected:
|
||||
SkDrawLooper() {}
|
||||
|
||||
private:
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
#endif
|
||||
160
src/deps/skia/include/core/SkDrawable.h
Normal file
160
src/deps/skia/include/core/SkDrawable.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkDrawable_DEFINED
|
||||
#define SkDrawable_DEFINED
|
||||
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
class GrBackendDrawableInfo;
|
||||
class SkCanvas;
|
||||
class SkMatrix;
|
||||
class SkPicture;
|
||||
enum class GrBackendApi : unsigned;
|
||||
struct SkRect;
|
||||
|
||||
/**
|
||||
* Base-class for objects that draw into SkCanvas.
|
||||
*
|
||||
* The object has a generation ID, which is guaranteed to be unique across all drawables. To
|
||||
* allow for clients of the drawable that may want to cache the results, the drawable must
|
||||
* change its generation ID whenever its internal state changes such that it will draw differently.
|
||||
*/
|
||||
class SK_API SkDrawable : public SkFlattenable {
|
||||
public:
|
||||
/**
|
||||
* Draws into the specified content. The drawing sequence will be balanced upon return
|
||||
* (i.e. the saveLevel() on the canvas will match what it was when draw() was called,
|
||||
* and the current matrix and clip settings will not be changed.
|
||||
*/
|
||||
void draw(SkCanvas*, const SkMatrix* = nullptr);
|
||||
void draw(SkCanvas*, SkScalar x, SkScalar y);
|
||||
|
||||
/**
|
||||
* When using the GPU backend it is possible for a drawable to execute using the underlying 3D
|
||||
* API rather than the SkCanvas API. It does so by creating a GpuDrawHandler. The GPU backend
|
||||
* is deferred so the handler will be given access to the 3D API at the correct point in the
|
||||
* drawing stream as the GPU backend flushes. Since the drawable may mutate, each time it is
|
||||
* drawn to a GPU-backed canvas a new handler is snapped, representing the drawable's state at
|
||||
* the time of the snap.
|
||||
*
|
||||
* When the GPU backend flushes to the 3D API it will call the draw method on the
|
||||
* GpuDrawHandler. At this time the drawable may add commands to the stream of GPU commands for
|
||||
* the unerlying 3D API. The draw function takes a GrBackendDrawableInfo which contains
|
||||
* information about the current state of 3D API which the caller must respect. See
|
||||
* GrBackendDrawableInfo for more specific details on what information is sent and the
|
||||
* requirements for different 3D APIs.
|
||||
*
|
||||
* Additionaly there may be a slight delay from when the drawable adds its commands to when
|
||||
* those commands are actually submitted to the GPU. Thus the drawable or GpuDrawHandler is
|
||||
* required to keep any resources that are used by its added commands alive and valid until
|
||||
* those commands are submitted to the GPU. The GpuDrawHandler will be kept alive and then
|
||||
* deleted once the commands are submitted to the GPU. The dtor of the GpuDrawHandler is the
|
||||
* signal to the drawable that the commands have all been submitted. Different 3D APIs may have
|
||||
* additional requirements for certain resources which require waiting for the GPU to finish
|
||||
* all work on those resources before reusing or deleting them. In this case, the drawable can
|
||||
* use the dtor call of the GpuDrawHandler to add a fence to the GPU to track when the GPU work
|
||||
* has completed.
|
||||
*
|
||||
* Currently this is only supported for the GPU Vulkan backend.
|
||||
*/
|
||||
|
||||
class GpuDrawHandler {
|
||||
public:
|
||||
virtual ~GpuDrawHandler() {}
|
||||
|
||||
virtual void draw(const GrBackendDrawableInfo&) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Snaps off a GpuDrawHandler to represent the state of the SkDrawable at the time the snap is
|
||||
* called. This is used for executing GPU backend specific draws intermixed with normal Skia GPU
|
||||
* draws. The GPU API, which will be used for the draw, as well as the full matrix, device clip
|
||||
* bounds and imageInfo of the target buffer are passed in as inputs.
|
||||
*/
|
||||
std::unique_ptr<GpuDrawHandler> snapGpuDrawHandler(GrBackendApi backendApi,
|
||||
const SkMatrix& matrix,
|
||||
const SkIRect& clipBounds,
|
||||
const SkImageInfo& bufferInfo) {
|
||||
return this->onSnapGpuDrawHandler(backendApi, matrix, clipBounds, bufferInfo);
|
||||
}
|
||||
|
||||
SkPicture* newPictureSnapshot();
|
||||
|
||||
/**
|
||||
* Return a unique value for this instance. If two calls to this return the same value,
|
||||
* it is presumed that calling the draw() method will render the same thing as well.
|
||||
*
|
||||
* Subclasses that change their state should call notifyDrawingChanged() to ensure that
|
||||
* a new value will be returned the next time it is called.
|
||||
*/
|
||||
uint32_t getGenerationID();
|
||||
|
||||
/**
|
||||
* Return the (conservative) bounds of what the drawable will draw. If the drawable can
|
||||
* change what it draws (e.g. animation or in response to some external change), then this
|
||||
* must return a bounds that is always valid for all possible states.
|
||||
*/
|
||||
SkRect getBounds();
|
||||
|
||||
/**
|
||||
* Calling this invalidates the previous generation ID, and causes a new one to be computed
|
||||
* the next time getGenerationID() is called. Typically this is called by the object itself,
|
||||
* in response to its internal state changing.
|
||||
*/
|
||||
void notifyDrawingChanged();
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkDrawable_Type;
|
||||
}
|
||||
|
||||
SkFlattenable::Type getFlattenableType() const override {
|
||||
return kSkDrawable_Type;
|
||||
}
|
||||
|
||||
static sk_sp<SkDrawable> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr) {
|
||||
return sk_sp<SkDrawable>(static_cast<SkDrawable*>(
|
||||
SkFlattenable::Deserialize(
|
||||
kSkDrawable_Type, data, size, procs).release()));
|
||||
}
|
||||
|
||||
Factory getFactory() const override { return nullptr; }
|
||||
const char* getTypeName() const override { return nullptr; }
|
||||
|
||||
protected:
|
||||
SkDrawable();
|
||||
|
||||
virtual SkRect onGetBounds() = 0;
|
||||
virtual void onDraw(SkCanvas*) = 0;
|
||||
|
||||
virtual std::unique_ptr<GpuDrawHandler> onSnapGpuDrawHandler(GrBackendApi, const SkMatrix&,
|
||||
const SkIRect& /*clipBounds*/,
|
||||
const SkImageInfo&) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// TODO: Delete this once Android gets updated to take the clipBounds version above.
|
||||
virtual std::unique_ptr<GpuDrawHandler> onSnapGpuDrawHandler(GrBackendApi, const SkMatrix&) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation calls onDraw() with a canvas that records into a picture. Subclasses
|
||||
* may override if they have a more efficient way to return a picture for the current state
|
||||
* of their drawable. Note: this picture must draw the same as what would be drawn from
|
||||
* onDraw().
|
||||
*/
|
||||
virtual SkPicture* onNewPictureSnapshot();
|
||||
|
||||
private:
|
||||
int32_t fGenerationID;
|
||||
};
|
||||
|
||||
#endif
|
||||
35
src/deps/skia/include/core/SkEncodedImageFormat.h
Normal file
35
src/deps/skia/include/core/SkEncodedImageFormat.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkEncodedImageFormat_DEFINED
|
||||
#define SkEncodedImageFormat_DEFINED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Enum describing format of encoded data.
|
||||
*/
|
||||
enum class SkEncodedImageFormat {
|
||||
#ifdef SK_BUILD_FOR_GOOGLE3
|
||||
kUnknown,
|
||||
#endif
|
||||
kBMP,
|
||||
kGIF,
|
||||
kICO,
|
||||
kJPEG,
|
||||
kPNG,
|
||||
kWBMP,
|
||||
kWEBP,
|
||||
kPKM,
|
||||
kKTX,
|
||||
kASTC,
|
||||
kDNG,
|
||||
kHEIF,
|
||||
kAVIF,
|
||||
};
|
||||
|
||||
#endif // SkEncodedImageFormat_DEFINED
|
||||
41
src/deps/skia/include/core/SkExecutor.h
Normal file
41
src/deps/skia/include/core/SkExecutor.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkExecutor_DEFINED
|
||||
#define SkExecutor_DEFINED
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SK_API SkExecutor {
|
||||
public:
|
||||
virtual ~SkExecutor();
|
||||
|
||||
// Create a thread pool SkExecutor with a fixed thread count, by default the number of cores.
|
||||
static std::unique_ptr<SkExecutor> MakeFIFOThreadPool(int threads = 0,
|
||||
bool allowBorrowing = true);
|
||||
static std::unique_ptr<SkExecutor> MakeLIFOThreadPool(int threads = 0,
|
||||
bool allowBorrowing = true);
|
||||
|
||||
// There is always a default SkExecutor available by calling SkExecutor::GetDefault().
|
||||
static SkExecutor& GetDefault();
|
||||
static void SetDefault(SkExecutor*); // Does not take ownership. Not thread safe.
|
||||
|
||||
// Add work to execute.
|
||||
virtual void add(std::function<void(void)>) = 0;
|
||||
|
||||
// If it makes sense for this executor, use this thread to execute work for a little while.
|
||||
virtual void borrow() {}
|
||||
|
||||
protected:
|
||||
SkExecutor() = default;
|
||||
SkExecutor(const SkExecutor&) = delete;
|
||||
SkExecutor& operator=(const SkExecutor&) = delete;
|
||||
};
|
||||
|
||||
#endif//SkExecutor_DEFINED
|
||||
113
src/deps/skia/include/core/SkFlattenable.h
Normal file
113
src/deps/skia/include/core/SkFlattenable.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFlattenable_DEFINED
|
||||
#define SkFlattenable_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
class SkData;
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
|
||||
struct SkSerialProcs;
|
||||
struct SkDeserialProcs;
|
||||
|
||||
/** \class SkFlattenable
|
||||
|
||||
SkFlattenable is the base class for objects that need to be flattened
|
||||
into a data stream for either transport or as part of the key to the
|
||||
font cache.
|
||||
*/
|
||||
class SK_API SkFlattenable : public SkRefCnt {
|
||||
public:
|
||||
enum Type {
|
||||
kSkColorFilter_Type,
|
||||
kSkBlender_Type,
|
||||
kSkDrawable_Type,
|
||||
kSkDrawLooper_Type, // no longer used internally by Skia
|
||||
kSkImageFilter_Type,
|
||||
kSkMaskFilter_Type,
|
||||
kSkPathEffect_Type,
|
||||
kSkShader_Type,
|
||||
};
|
||||
|
||||
typedef sk_sp<SkFlattenable> (*Factory)(SkReadBuffer&);
|
||||
|
||||
SkFlattenable() {}
|
||||
|
||||
/** Implement this to return a factory function pointer that can be called
|
||||
to recreate your class given a buffer (previously written to by your
|
||||
override of flatten().
|
||||
*/
|
||||
virtual Factory getFactory() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the name of the object's class.
|
||||
*/
|
||||
virtual const char* getTypeName() const = 0;
|
||||
|
||||
static Factory NameToFactory(const char name[]);
|
||||
static const char* FactoryToName(Factory);
|
||||
|
||||
static void Register(const char name[], Factory);
|
||||
|
||||
/**
|
||||
* Override this if your subclass needs to record data that it will need to recreate itself
|
||||
* from its CreateProc (returned by getFactory()).
|
||||
*
|
||||
* DEPRECATED public : will move to protected ... use serialize() instead
|
||||
*/
|
||||
virtual void flatten(SkWriteBuffer&) const {}
|
||||
|
||||
virtual Type getFlattenableType() const = 0;
|
||||
|
||||
//
|
||||
// public ways to serialize / deserialize
|
||||
//
|
||||
sk_sp<SkData> serialize(const SkSerialProcs* = nullptr) const;
|
||||
size_t serialize(void* memory, size_t memory_size,
|
||||
const SkSerialProcs* = nullptr) const;
|
||||
static sk_sp<SkFlattenable> Deserialize(Type, const void* data, size_t length,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
protected:
|
||||
class PrivateInitializer {
|
||||
public:
|
||||
static void InitEffects();
|
||||
static void InitImageFilters();
|
||||
};
|
||||
|
||||
private:
|
||||
static void RegisterFlattenablesIfNeeded();
|
||||
static void Finalize();
|
||||
|
||||
friend class SkGraphics;
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
#if defined(SK_DISABLE_EFFECT_DESERIALIZATION)
|
||||
#define SK_REGISTER_FLATTENABLE(type) do{}while(false)
|
||||
|
||||
#define SK_FLATTENABLE_HOOKS(type) \
|
||||
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
|
||||
friend class SkFlattenable::PrivateInitializer; \
|
||||
Factory getFactory() const override { return nullptr; } \
|
||||
const char* getTypeName() const override { return #type; }
|
||||
#else
|
||||
#define SK_REGISTER_FLATTENABLE(type) \
|
||||
SkFlattenable::Register(#type, type::CreateProc)
|
||||
|
||||
#define SK_FLATTENABLE_HOOKS(type) \
|
||||
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); \
|
||||
friend class SkFlattenable::PrivateInitializer; \
|
||||
Factory getFactory() const override { return type::CreateProc; } \
|
||||
const char* getTypeName() const override { return #type; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
534
src/deps/skia/include/core/SkFont.h
Normal file
534
src/deps/skia/include/core/SkFont.h
Normal file
@@ -0,0 +1,534 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFont_DEFINED
|
||||
#define SkFont_DEFINED
|
||||
|
||||
#include "include/core/SkFontTypes.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
class SkPath;
|
||||
struct SkFontMetrics;
|
||||
|
||||
/** \class SkFont
|
||||
SkFont controls options applied when drawing and measuring text.
|
||||
*/
|
||||
class SK_API SkFont {
|
||||
public:
|
||||
/** Whether edge pixels draw opaque or with partial transparency.
|
||||
*/
|
||||
enum class Edging {
|
||||
kAlias, //!< no transparent pixels on glyph edges
|
||||
kAntiAlias, //!< may have transparent pixels on glyph edges
|
||||
kSubpixelAntiAlias, //!< glyph positioned in pixel using transparency
|
||||
};
|
||||
|
||||
/** Constructs SkFont with default values.
|
||||
|
||||
@return default initialized SkFont
|
||||
*/
|
||||
SkFont();
|
||||
|
||||
/** Constructs SkFont with default values with SkTypeface and size in points.
|
||||
|
||||
@param typeface font and style used to draw and measure text
|
||||
@param size typographic height of text
|
||||
@return initialized SkFont
|
||||
*/
|
||||
SkFont(sk_sp<SkTypeface> typeface, SkScalar size);
|
||||
|
||||
/** Constructs SkFont with default values with SkTypeface.
|
||||
|
||||
@param typeface font and style used to draw and measure text
|
||||
@return initialized SkFont
|
||||
*/
|
||||
explicit SkFont(sk_sp<SkTypeface> typeface);
|
||||
|
||||
|
||||
/** Constructs SkFont with default values with SkTypeface and size in points,
|
||||
horizontal scale, and horizontal skew. Horizontal scale emulates condensed
|
||||
and expanded fonts. Horizontal skew emulates oblique fonts.
|
||||
|
||||
@param typeface font and style used to draw and measure text
|
||||
@param size typographic height of text
|
||||
@param scaleX text horizontal scale
|
||||
@param skewX additional shear on x-axis relative to y-axis
|
||||
@return initialized SkFont
|
||||
*/
|
||||
SkFont(sk_sp<SkTypeface> typeface, SkScalar size, SkScalar scaleX, SkScalar skewX);
|
||||
|
||||
|
||||
/** Compares SkFont and font, and returns true if they are equivalent.
|
||||
May return false if SkTypeface has identical contents but different pointers.
|
||||
|
||||
@param font font to compare
|
||||
@return true if SkFont pair are equivalent
|
||||
*/
|
||||
bool operator==(const SkFont& font) const;
|
||||
|
||||
/** Compares SkFont and font, and returns true if they are not equivalent.
|
||||
May return true if SkTypeface has identical contents but different pointers.
|
||||
|
||||
@param font font to compare
|
||||
@return true if SkFont pair are not equivalent
|
||||
*/
|
||||
bool operator!=(const SkFont& font) const { return !(*this == font); }
|
||||
|
||||
/** If true, instructs the font manager to always hint glyphs.
|
||||
Returned value is only meaningful if platform uses FreeType as the font manager.
|
||||
|
||||
@return true if all glyphs are hinted
|
||||
*/
|
||||
bool isForceAutoHinting() const { return SkToBool(fFlags & kForceAutoHinting_PrivFlag); }
|
||||
|
||||
/** Returns true if font engine may return glyphs from font bitmaps instead of from outlines.
|
||||
|
||||
@return true if glyphs may be font bitmaps
|
||||
*/
|
||||
bool isEmbeddedBitmaps() const { return SkToBool(fFlags & kEmbeddedBitmaps_PrivFlag); }
|
||||
|
||||
/** Returns true if glyphs may be drawn at sub-pixel offsets.
|
||||
|
||||
@return true if glyphs may be drawn at sub-pixel offsets.
|
||||
*/
|
||||
bool isSubpixel() const { return SkToBool(fFlags & kSubpixel_PrivFlag); }
|
||||
|
||||
/** Returns true if font and glyph metrics are requested to be linearly scalable.
|
||||
|
||||
@return true if font and glyph metrics are requested to be linearly scalable.
|
||||
*/
|
||||
bool isLinearMetrics() const { return SkToBool(fFlags & kLinearMetrics_PrivFlag); }
|
||||
|
||||
/** Returns true if bold is approximated by increasing the stroke width when creating glyph
|
||||
bitmaps from outlines.
|
||||
|
||||
@return bold is approximated through stroke width
|
||||
*/
|
||||
bool isEmbolden() const { return SkToBool(fFlags & kEmbolden_PrivFlag); }
|
||||
|
||||
/** Returns true if baselines will be snapped to pixel positions when the current transformation
|
||||
matrix is axis aligned.
|
||||
|
||||
@return baselines may be snapped to pixels
|
||||
*/
|
||||
bool isBaselineSnap() const { return SkToBool(fFlags & kBaselineSnap_PrivFlag); }
|
||||
|
||||
/** Sets whether to always hint glyphs.
|
||||
If forceAutoHinting is set, instructs the font manager to always hint glyphs.
|
||||
|
||||
Only affects platforms that use FreeType as the font manager.
|
||||
|
||||
@param forceAutoHinting setting to always hint glyphs
|
||||
*/
|
||||
void setForceAutoHinting(bool forceAutoHinting);
|
||||
|
||||
/** Requests, but does not require, to use bitmaps in fonts instead of outlines.
|
||||
|
||||
@param embeddedBitmaps setting to use bitmaps in fonts
|
||||
*/
|
||||
void setEmbeddedBitmaps(bool embeddedBitmaps);
|
||||
|
||||
/** Requests, but does not require, that glyphs respect sub-pixel positioning.
|
||||
|
||||
@param subpixel setting for sub-pixel positioning
|
||||
*/
|
||||
void setSubpixel(bool subpixel);
|
||||
|
||||
/** Requests, but does not require, linearly scalable font and glyph metrics.
|
||||
|
||||
For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding.
|
||||
Note that some bitmap formats may not be able to scale linearly and will ignore this flag.
|
||||
|
||||
@param linearMetrics setting for linearly scalable font and glyph metrics.
|
||||
*/
|
||||
void setLinearMetrics(bool linearMetrics);
|
||||
|
||||
/** Increases stroke width when creating glyph bitmaps to approximate a bold typeface.
|
||||
|
||||
@param embolden setting for bold approximation
|
||||
*/
|
||||
void setEmbolden(bool embolden);
|
||||
|
||||
/** Requests that baselines be snapped to pixels when the current transformation matrix is axis
|
||||
aligned.
|
||||
|
||||
@param baselineSnap setting for baseline snapping to pixels
|
||||
*/
|
||||
void setBaselineSnap(bool baselineSnap);
|
||||
|
||||
/** Whether edge pixels draw opaque or with partial transparency.
|
||||
*/
|
||||
Edging getEdging() const { return (Edging)fEdging; }
|
||||
|
||||
/** Requests, but does not require, that edge pixels draw opaque or with
|
||||
partial transparency.
|
||||
*/
|
||||
void setEdging(Edging edging);
|
||||
|
||||
/** Sets level of glyph outline adjustment.
|
||||
Does not check for valid values of hintingLevel.
|
||||
*/
|
||||
void setHinting(SkFontHinting hintingLevel);
|
||||
|
||||
/** Returns level of glyph outline adjustment.
|
||||
*/
|
||||
SkFontHinting getHinting() const { return (SkFontHinting)fHinting; }
|
||||
|
||||
/** Returns a font with the same attributes of this font, but with the specified size.
|
||||
Returns nullptr if size is less than zero, infinite, or NaN.
|
||||
|
||||
@param size typographic height of text
|
||||
@return initialized SkFont
|
||||
*/
|
||||
SkFont makeWithSize(SkScalar size) const;
|
||||
|
||||
/** Returns SkTypeface if set, or nullptr.
|
||||
Does not alter SkTypeface SkRefCnt.
|
||||
|
||||
@return SkTypeface if previously set, nullptr otherwise
|
||||
*/
|
||||
SkTypeface* getTypeface() const {return fTypeface.get(); }
|
||||
|
||||
/** Returns SkTypeface if set, or the default typeface.
|
||||
Does not alter SkTypeface SkRefCnt.
|
||||
|
||||
@return SkTypeface if previously set or, a pointer to the default typeface if not
|
||||
previously set.
|
||||
*/
|
||||
SkTypeface* getTypefaceOrDefault() const;
|
||||
|
||||
/** Returns text size in points.
|
||||
|
||||
@return typographic height of text
|
||||
*/
|
||||
SkScalar getSize() const { return fSize; }
|
||||
|
||||
/** Returns text scale on x-axis.
|
||||
Default value is 1.
|
||||
|
||||
@return text horizontal scale
|
||||
*/
|
||||
SkScalar getScaleX() const { return fScaleX; }
|
||||
|
||||
/** Returns text skew on x-axis.
|
||||
Default value is zero.
|
||||
|
||||
@return additional shear on x-axis relative to y-axis
|
||||
*/
|
||||
SkScalar getSkewX() const { return fSkewX; }
|
||||
|
||||
/** Increases SkTypeface SkRefCnt by one.
|
||||
|
||||
@return SkTypeface if previously set, nullptr otherwise
|
||||
*/
|
||||
sk_sp<SkTypeface> refTypeface() const { return fTypeface; }
|
||||
|
||||
/** Increases SkTypeface SkRefCnt by one.
|
||||
|
||||
@return SkTypeface if previously set or, a pointer to the default typeface if not
|
||||
previously set.
|
||||
*/
|
||||
sk_sp<SkTypeface> refTypefaceOrDefault() const;
|
||||
|
||||
/** Sets SkTypeface to typeface, decreasing SkRefCnt of the previous SkTypeface.
|
||||
Pass nullptr to clear SkTypeface and use the default typeface. Increments
|
||||
tf SkRefCnt by one.
|
||||
|
||||
@param tf font and style used to draw text
|
||||
*/
|
||||
void setTypeface(sk_sp<SkTypeface> tf) { fTypeface = tf; }
|
||||
|
||||
/** Sets text size in points.
|
||||
Has no effect if textSize is not greater than or equal to zero.
|
||||
|
||||
@param textSize typographic height of text
|
||||
*/
|
||||
void setSize(SkScalar textSize);
|
||||
|
||||
/** Sets text scale on x-axis.
|
||||
Default value is 1.
|
||||
|
||||
@param scaleX text horizontal scale
|
||||
*/
|
||||
void setScaleX(SkScalar scaleX);
|
||||
|
||||
/** Sets text skew on x-axis.
|
||||
Default value is zero.
|
||||
|
||||
@param skewX additional shear on x-axis relative to y-axis
|
||||
*/
|
||||
void setSkewX(SkScalar skewX);
|
||||
|
||||
/** Converts text into glyph indices.
|
||||
Returns the number of glyph indices represented by text.
|
||||
SkTextEncoding specifies how text represents characters or glyphs.
|
||||
glyphs may be nullptr, to compute the glyph count.
|
||||
|
||||
Does not check text for valid character codes or valid glyph indices.
|
||||
|
||||
If byteLength equals zero, returns zero.
|
||||
If byteLength includes a partial character, the partial character is ignored.
|
||||
|
||||
If encoding is SkTextEncoding::kUTF8 and text contains an invalid UTF-8 sequence,
|
||||
zero is returned.
|
||||
|
||||
When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or
|
||||
SkTextEncoding::kUTF32; then each Unicode codepoint is mapped to a
|
||||
single glyph. This function uses the default character-to-glyph
|
||||
mapping from the SkTypeface and maps characters not found in the
|
||||
SkTypeface to zero.
|
||||
|
||||
If maxGlyphCount is not sufficient to store all the glyphs, no glyphs are copied.
|
||||
The total glyph count is returned for subsequent buffer reallocation.
|
||||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param glyphs storage for glyph indices; may be nullptr
|
||||
@param maxGlyphCount storage capacity
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||
SkGlyphID glyphs[], int maxGlyphCount) const;
|
||||
|
||||
/** Returns glyph index for Unicode character.
|
||||
|
||||
If the character is not supported by the SkTypeface, returns 0.
|
||||
|
||||
@param uni Unicode character
|
||||
@return glyph index
|
||||
*/
|
||||
SkGlyphID unicharToGlyph(SkUnichar uni) const;
|
||||
|
||||
void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const;
|
||||
|
||||
/** Returns number of glyphs represented by text.
|
||||
|
||||
If encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or
|
||||
SkTextEncoding::kUTF32; then each Unicode codepoint is mapped to a
|
||||
single glyph.
|
||||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
int countText(const void* text, size_t byteLength, SkTextEncoding encoding) const {
|
||||
return this->textToGlyphs(text, byteLength, encoding, nullptr, 0);
|
||||
}
|
||||
|
||||
/** Returns the advance width of text.
|
||||
The advance is the normal distance to move before drawing additional text.
|
||||
Returns the bounding box of text if bounds is not nullptr.
|
||||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param bounds returns bounding box relative to (0, 0) if not nullptr
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||
SkRect* bounds = nullptr) const {
|
||||
return this->measureText(text, byteLength, encoding, bounds, nullptr);
|
||||
}
|
||||
|
||||
/** Returns the advance width of text.
|
||||
The advance is the normal distance to move before drawing additional text.
|
||||
Returns the bounding box of text if bounds is not nullptr. The paint
|
||||
stroke settings, mask filter, or path effect may modify the bounds.
|
||||
|
||||
@param text character storage encoded with SkTextEncoding
|
||||
@param byteLength length of character storage in bytes
|
||||
@param bounds returns bounding box relative to (0, 0) if not nullptr
|
||||
@param paint optional; may be nullptr
|
||||
@return number of glyphs represented by text of length byteLength
|
||||
*/
|
||||
SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||
SkRect* bounds, const SkPaint* paint) const;
|
||||
|
||||
/** DEPRECATED
|
||||
Retrieves the advance and bounds for each glyph in glyphs.
|
||||
Both widths and bounds may be nullptr.
|
||||
If widths is not nullptr, widths must be an array of count entries.
|
||||
if bounds is not nullptr, bounds must be an array of count entries.
|
||||
|
||||
@param glyphs array of glyph indices to be measured
|
||||
@param count number of glyphs
|
||||
@param widths returns text advances for each glyph; may be nullptr
|
||||
@param bounds returns bounds for each glyph relative to (0, 0); may be nullptr
|
||||
*/
|
||||
void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[]) const {
|
||||
this->getWidthsBounds(glyphs, count, widths, bounds, nullptr);
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[], std::nullptr_t) const {
|
||||
this->getWidths(glyphs, count, widths);
|
||||
}
|
||||
|
||||
/** Retrieves the advance and bounds for each glyph in glyphs.
|
||||
Both widths and bounds may be nullptr.
|
||||
If widths is not nullptr, widths must be an array of count entries.
|
||||
if bounds is not nullptr, bounds must be an array of count entries.
|
||||
|
||||
@param glyphs array of glyph indices to be measured
|
||||
@param count number of glyphs
|
||||
@param widths returns text advances for each glyph
|
||||
*/
|
||||
void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[]) const {
|
||||
this->getWidthsBounds(glyphs, count, widths, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/** Retrieves the advance and bounds for each glyph in glyphs.
|
||||
Both widths and bounds may be nullptr.
|
||||
If widths is not nullptr, widths must be an array of count entries.
|
||||
if bounds is not nullptr, bounds must be an array of count entries.
|
||||
|
||||
@param glyphs array of glyph indices to be measured
|
||||
@param count number of glyphs
|
||||
@param widths returns text advances for each glyph; may be nullptr
|
||||
@param bounds returns bounds for each glyph relative to (0, 0); may be nullptr
|
||||
@param paint optional, specifies stroking, SkPathEffect and SkMaskFilter
|
||||
*/
|
||||
void getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[],
|
||||
const SkPaint* paint) const;
|
||||
|
||||
|
||||
/** Retrieves the bounds for each glyph in glyphs.
|
||||
bounds must be an array of count entries.
|
||||
If paint is not nullptr, its stroking, SkPathEffect, and SkMaskFilter fields are respected.
|
||||
|
||||
@param glyphs array of glyph indices to be measured
|
||||
@param count number of glyphs
|
||||
@param bounds returns bounds for each glyph relative to (0, 0); may be nullptr
|
||||
@param paint optional, specifies stroking, SkPathEffect, and SkMaskFilter
|
||||
*/
|
||||
void getBounds(const SkGlyphID glyphs[], int count, SkRect bounds[],
|
||||
const SkPaint* paint) const {
|
||||
this->getWidthsBounds(glyphs, count, nullptr, bounds, paint);
|
||||
}
|
||||
|
||||
/** Retrieves the positions for each glyph, beginning at the specified origin. The caller
|
||||
must allocated at least count number of elements in the pos[] array.
|
||||
|
||||
@param glyphs array of glyph indices to be positioned
|
||||
@param count number of glyphs
|
||||
@param pos returns glyphs positions
|
||||
@param origin location of the first glyph. Defaults to {0, 0}.
|
||||
*/
|
||||
void getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin = {0, 0}) const;
|
||||
|
||||
/** Retrieves the x-positions for each glyph, beginning at the specified origin. The caller
|
||||
must allocated at least count number of elements in the xpos[] array.
|
||||
|
||||
@param glyphs array of glyph indices to be positioned
|
||||
@param count number of glyphs
|
||||
@param xpos returns glyphs x-positions
|
||||
@param origin x-position of the first glyph. Defaults to 0.
|
||||
*/
|
||||
void getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const;
|
||||
|
||||
/** Returns intervals [start, end] describing lines parallel to the advance that intersect
|
||||
* with the glyphs.
|
||||
*
|
||||
* @param glyphs the glyphs to intersect
|
||||
* @param count the number of glyphs and positions
|
||||
* @param pos the position of each glyph
|
||||
* @param top the top of the line intersecting
|
||||
* @param bottom the bottom of the line intersecting
|
||||
@return array of pairs of x values [start, end]. May be empty.
|
||||
*/
|
||||
std::vector<SkScalar> getIntercepts(const SkGlyphID glyphs[], int count, const SkPoint pos[],
|
||||
SkScalar top, SkScalar bottom,
|
||||
const SkPaint* = nullptr) const;
|
||||
|
||||
/** Modifies path to be the outline of the glyph.
|
||||
If the glyph has an outline, modifies path to be the glyph's outline and returns true.
|
||||
The glyph outline may be empty. Degenerate contours in the glyph outline will be skipped.
|
||||
If glyph is described by a bitmap, returns false and ignores path parameter.
|
||||
|
||||
@param glyphID index of glyph
|
||||
@param path pointer to existing SkPath
|
||||
@return true if glyphID is described by path
|
||||
*/
|
||||
bool getPath(SkGlyphID glyphID, SkPath* path) const;
|
||||
|
||||
/** Returns path corresponding to glyph array.
|
||||
|
||||
@param glyphIDs array of glyph indices
|
||||
@param count number of glyphs
|
||||
@param glyphPathProc function returning one glyph description as path
|
||||
@param ctx function context
|
||||
*/
|
||||
void getPaths(const SkGlyphID glyphIDs[], int count,
|
||||
void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx),
|
||||
void* ctx) const;
|
||||
|
||||
/** Returns SkFontMetrics associated with SkTypeface.
|
||||
The return value is the recommended spacing between lines: the sum of metrics
|
||||
descent, ascent, and leading.
|
||||
If metrics is not nullptr, SkFontMetrics is copied to metrics.
|
||||
Results are scaled by text size but does not take into account
|
||||
dimensions required by text scale, text skew, fake bold,
|
||||
style stroke, and SkPathEffect.
|
||||
|
||||
@param metrics storage for SkFontMetrics; may be nullptr
|
||||
@return recommended spacing between lines
|
||||
*/
|
||||
SkScalar getMetrics(SkFontMetrics* metrics) const;
|
||||
|
||||
/** Returns the recommended spacing between lines: the sum of metrics
|
||||
descent, ascent, and leading.
|
||||
Result is scaled by text size but does not take into account
|
||||
dimensions required by stroking and SkPathEffect.
|
||||
Returns the same result as getMetrics().
|
||||
|
||||
@return recommended spacing between lines
|
||||
*/
|
||||
SkScalar getSpacing() const { return this->getMetrics(nullptr); }
|
||||
|
||||
/** Dumps fields of the font to SkDebugf. May change its output over time, so clients should
|
||||
* not rely on this for anything specific. Used to aid in debugging.
|
||||
*/
|
||||
void dump() const;
|
||||
|
||||
private:
|
||||
enum PrivFlags {
|
||||
kForceAutoHinting_PrivFlag = 1 << 0,
|
||||
kEmbeddedBitmaps_PrivFlag = 1 << 1,
|
||||
kSubpixel_PrivFlag = 1 << 2,
|
||||
kLinearMetrics_PrivFlag = 1 << 3,
|
||||
kEmbolden_PrivFlag = 1 << 4,
|
||||
kBaselineSnap_PrivFlag = 1 << 5,
|
||||
};
|
||||
|
||||
static constexpr unsigned kAllFlags = kForceAutoHinting_PrivFlag
|
||||
| kEmbeddedBitmaps_PrivFlag
|
||||
| kSubpixel_PrivFlag
|
||||
| kLinearMetrics_PrivFlag
|
||||
| kEmbolden_PrivFlag
|
||||
| kBaselineSnap_PrivFlag;
|
||||
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
SkScalar fSize;
|
||||
SkScalar fScaleX;
|
||||
SkScalar fSkewX;
|
||||
uint8_t fFlags;
|
||||
uint8_t fEdging;
|
||||
uint8_t fHinting;
|
||||
|
||||
SkScalar setupForAsPaths(SkPaint*);
|
||||
bool hasSomeAntiAliasing() const;
|
||||
|
||||
friend class SkFontPriv;
|
||||
friend class SkGlyphRunListPainter;
|
||||
friend class SkStrikeSpec;
|
||||
};
|
||||
|
||||
#endif
|
||||
62
src/deps/skia/include/core/SkFontArguments.h
Normal file
62
src/deps/skia/include/core/SkFontArguments.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontArguments_DEFINED
|
||||
#define SkFontArguments_DEFINED
|
||||
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/** Represents a set of actual arguments for a font. */
|
||||
struct SkFontArguments {
|
||||
struct VariationPosition {
|
||||
struct Coordinate {
|
||||
SkFourByteTag axis;
|
||||
float value;
|
||||
};
|
||||
const Coordinate* coordinates;
|
||||
int coordinateCount;
|
||||
};
|
||||
|
||||
SkFontArguments() : fCollectionIndex(0), fVariationDesignPosition{nullptr, 0} {}
|
||||
|
||||
/** Specify the index of the desired font.
|
||||
*
|
||||
* Font formats like ttc, dfont, cff, cid, pfr, t42, t1, and fon may actually be indexed
|
||||
* collections of fonts.
|
||||
*/
|
||||
SkFontArguments& setCollectionIndex(int collectionIndex) {
|
||||
fCollectionIndex = collectionIndex;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Specify a position in the variation design space.
|
||||
*
|
||||
* Any axis not specified will use the default value.
|
||||
* Any specified axis not actually present in the font will be ignored.
|
||||
*
|
||||
* @param position not copied. The value must remain valid for life of SkFontArguments.
|
||||
*/
|
||||
SkFontArguments& setVariationDesignPosition(VariationPosition position) {
|
||||
fVariationDesignPosition.coordinates = position.coordinates;
|
||||
fVariationDesignPosition.coordinateCount = position.coordinateCount;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int getCollectionIndex() const {
|
||||
return fCollectionIndex;
|
||||
}
|
||||
|
||||
VariationPosition getVariationDesignPosition() const {
|
||||
return fVariationDesignPosition;
|
||||
}
|
||||
private:
|
||||
int fCollectionIndex;
|
||||
VariationPosition fVariationDesignPosition;
|
||||
};
|
||||
|
||||
#endif
|
||||
138
src/deps/skia/include/core/SkFontMetrics.h
Normal file
138
src/deps/skia/include/core/SkFontMetrics.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontMetrics_DEFINED
|
||||
#define SkFontMetrics_DEFINED
|
||||
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
/** \class SkFontMetrics
|
||||
The metrics of an SkFont.
|
||||
The metric values are consistent with the Skia y-down coordinate system.
|
||||
*/
|
||||
struct SK_API SkFontMetrics {
|
||||
bool operator==(const SkFontMetrics& that) {
|
||||
return
|
||||
this->fFlags == that.fFlags &&
|
||||
this->fTop == that.fTop &&
|
||||
this->fAscent == that.fAscent &&
|
||||
this->fDescent == that.fDescent &&
|
||||
this->fBottom == that.fBottom &&
|
||||
this->fLeading == that.fLeading &&
|
||||
this->fAvgCharWidth == that.fAvgCharWidth &&
|
||||
this->fMaxCharWidth == that.fMaxCharWidth &&
|
||||
this->fXMin == that.fXMin &&
|
||||
this->fXMax == that.fXMax &&
|
||||
this->fXHeight == that.fXHeight &&
|
||||
this->fCapHeight == that.fCapHeight &&
|
||||
this->fUnderlineThickness == that.fUnderlineThickness &&
|
||||
this->fUnderlinePosition == that.fUnderlinePosition &&
|
||||
this->fStrikeoutThickness == that.fStrikeoutThickness &&
|
||||
this->fStrikeoutPosition == that.fStrikeoutPosition;
|
||||
}
|
||||
|
||||
/** \enum FontMetricsFlags
|
||||
FontMetricsFlags indicate when certain metrics are valid;
|
||||
the underline or strikeout metrics may be valid and zero.
|
||||
Fonts with embedded bitmaps may not have valid underline or strikeout metrics.
|
||||
*/
|
||||
enum FontMetricsFlags {
|
||||
kUnderlineThicknessIsValid_Flag = 1 << 0, //!< set if fUnderlineThickness is valid
|
||||
kUnderlinePositionIsValid_Flag = 1 << 1, //!< set if fUnderlinePosition is valid
|
||||
kStrikeoutThicknessIsValid_Flag = 1 << 2, //!< set if fStrikeoutThickness is valid
|
||||
kStrikeoutPositionIsValid_Flag = 1 << 3, //!< set if fStrikeoutPosition is valid
|
||||
kBoundsInvalid_Flag = 1 << 4, //!< set if fTop, fBottom, fXMin, fXMax invalid
|
||||
};
|
||||
|
||||
uint32_t fFlags; //!< FontMetricsFlags indicating which metrics are valid
|
||||
SkScalar fTop; //!< greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable fonts
|
||||
SkScalar fAscent; //!< distance to reserve above baseline, typically negative
|
||||
SkScalar fDescent; //!< distance to reserve below baseline, typically positive
|
||||
SkScalar fBottom; //!< greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable fonts
|
||||
SkScalar fLeading; //!< distance to add between lines, typically positive or zero
|
||||
SkScalar fAvgCharWidth; //!< average character width, zero if unknown
|
||||
SkScalar fMaxCharWidth; //!< maximum character width, zero if unknown
|
||||
SkScalar fXMin; //!< greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with variable fonts
|
||||
SkScalar fXMax; //!< greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with variable fonts
|
||||
SkScalar fXHeight; //!< height of lower-case 'x', zero if unknown, typically negative
|
||||
SkScalar fCapHeight; //!< height of an upper-case letter, zero if unknown, typically negative
|
||||
SkScalar fUnderlineThickness; //!< underline thickness
|
||||
SkScalar fUnderlinePosition; //!< distance from baseline to top of stroke, typically positive
|
||||
SkScalar fStrikeoutThickness; //!< strikeout thickness
|
||||
SkScalar fStrikeoutPosition; //!< distance from baseline to bottom of stroke, typically negative
|
||||
|
||||
/** Returns true if SkFontMetrics has a valid underline thickness, and sets
|
||||
thickness to that value. If the underline thickness is not valid,
|
||||
return false, and ignore thickness.
|
||||
|
||||
@param thickness storage for underline width
|
||||
@return true if font specifies underline width
|
||||
*/
|
||||
bool hasUnderlineThickness(SkScalar* thickness) const {
|
||||
if (SkToBool(fFlags & kUnderlineThicknessIsValid_Flag)) {
|
||||
*thickness = fUnderlineThickness;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if SkFontMetrics has a valid underline position, and sets
|
||||
position to that value. If the underline position is not valid,
|
||||
return false, and ignore position.
|
||||
|
||||
@param position storage for underline position
|
||||
@return true if font specifies underline position
|
||||
*/
|
||||
bool hasUnderlinePosition(SkScalar* position) const {
|
||||
if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) {
|
||||
*position = fUnderlinePosition;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if SkFontMetrics has a valid strikeout thickness, and sets
|
||||
thickness to that value. If the underline thickness is not valid,
|
||||
return false, and ignore thickness.
|
||||
|
||||
@param thickness storage for strikeout width
|
||||
@return true if font specifies strikeout width
|
||||
*/
|
||||
bool hasStrikeoutThickness(SkScalar* thickness) const {
|
||||
if (SkToBool(fFlags & kStrikeoutThicknessIsValid_Flag)) {
|
||||
*thickness = fStrikeoutThickness;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if SkFontMetrics has a valid strikeout position, and sets
|
||||
position to that value. If the underline position is not valid,
|
||||
return false, and ignore position.
|
||||
|
||||
@param position storage for strikeout position
|
||||
@return true if font specifies strikeout position
|
||||
*/
|
||||
bool hasStrikeoutPosition(SkScalar* position) const {
|
||||
if (SkToBool(fFlags & kStrikeoutPositionIsValid_Flag)) {
|
||||
*position = fStrikeoutPosition;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if SkFontMetrics has a valid fTop, fBottom, fXMin, and fXMax.
|
||||
If the bounds are not valid, return false.
|
||||
|
||||
@return true if font specifies maximum glyph bounds
|
||||
*/
|
||||
bool hasBounds() const {
|
||||
return !SkToBool(fFlags & kBoundsInvalid_Flag);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
157
src/deps/skia/include/core/SkFontMgr.h
Normal file
157
src/deps/skia/include/core/SkFontMgr.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontMgr_DEFINED
|
||||
#define SkFontMgr_DEFINED
|
||||
|
||||
#include "include/core/SkFontArguments.h"
|
||||
#include "include/core/SkFontStyle.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkData;
|
||||
class SkFontData;
|
||||
class SkStreamAsset;
|
||||
class SkString;
|
||||
class SkTypeface;
|
||||
|
||||
class SK_API SkFontStyleSet : public SkRefCnt {
|
||||
public:
|
||||
virtual int count() = 0;
|
||||
virtual void getStyle(int index, SkFontStyle*, SkString* style) = 0;
|
||||
virtual SkTypeface* createTypeface(int index) = 0;
|
||||
virtual SkTypeface* matchStyle(const SkFontStyle& pattern) = 0;
|
||||
|
||||
static SkFontStyleSet* CreateEmpty();
|
||||
|
||||
protected:
|
||||
SkTypeface* matchStyleCSS3(const SkFontStyle& pattern);
|
||||
|
||||
private:
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
class SK_API SkFontMgr : public SkRefCnt {
|
||||
public:
|
||||
int countFamilies() const;
|
||||
void getFamilyName(int index, SkString* familyName) const;
|
||||
SkFontStyleSet* createStyleSet(int index) const;
|
||||
|
||||
/**
|
||||
* The caller must call unref() on the returned object.
|
||||
* Never returns NULL; will return an empty set if the name is not found.
|
||||
*
|
||||
* Passing nullptr as the parameter will return the default system family.
|
||||
* Note that most systems don't have a default system family, so passing nullptr will often
|
||||
* result in the empty set.
|
||||
*
|
||||
* It is possible that this will return a style set not accessible from
|
||||
* createStyleSet(int) due to hidden or auto-activated fonts.
|
||||
*/
|
||||
SkFontStyleSet* matchFamily(const char familyName[]) const;
|
||||
|
||||
/**
|
||||
* Find the closest matching typeface to the specified familyName and style
|
||||
* and return a ref to it. The caller must call unref() on the returned
|
||||
* object. Will return nullptr if no 'good' match is found.
|
||||
*
|
||||
* Passing |nullptr| as the parameter for |familyName| will return the
|
||||
* default system font.
|
||||
*
|
||||
* It is possible that this will return a style set not accessible from
|
||||
* createStyleSet(int) or matchFamily(const char[]) due to hidden or
|
||||
* auto-activated fonts.
|
||||
*/
|
||||
SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&) const;
|
||||
|
||||
/**
|
||||
* Use the system fallback to find a typeface for the given character.
|
||||
* Note that bcp47 is a combination of ISO 639, 15924, and 3166-1 codes,
|
||||
* so it is fine to just pass a ISO 639 here.
|
||||
*
|
||||
* Will return NULL if no family can be found for the character
|
||||
* in the system fallback.
|
||||
*
|
||||
* Passing |nullptr| as the parameter for |familyName| will return the
|
||||
* default system font.
|
||||
*
|
||||
* bcp47[0] is the least significant fallback, bcp47[bcp47Count-1] is the
|
||||
* most significant. If no specified bcp47 codes match, any font with the
|
||||
* requested character will be matched.
|
||||
*/
|
||||
SkTypeface* matchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
|
||||
const char* bcp47[], int bcp47Count,
|
||||
SkUnichar character) const;
|
||||
|
||||
/**
|
||||
* Create a typeface for the specified data and TTC index (pass 0 for none)
|
||||
* or NULL if the data is not recognized. The caller must call unref() on
|
||||
* the returned object if it is not null.
|
||||
*/
|
||||
sk_sp<SkTypeface> makeFromData(sk_sp<SkData>, int ttcIndex = 0) const;
|
||||
|
||||
/**
|
||||
* Create a typeface for the specified stream and TTC index
|
||||
* (pass 0 for none) or NULL if the stream is not recognized. The caller
|
||||
* must call unref() on the returned object if it is not null.
|
||||
*/
|
||||
sk_sp<SkTypeface> makeFromStream(std::unique_ptr<SkStreamAsset>, int ttcIndex = 0) const;
|
||||
|
||||
/* Experimental, API subject to change. */
|
||||
sk_sp<SkTypeface> makeFromStream(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const;
|
||||
|
||||
/**
|
||||
* Create a typeface for the specified fileName and TTC index
|
||||
* (pass 0 for none) or NULL if the file is not found, or its contents are
|
||||
* not recognized. The caller must call unref() on the returned object
|
||||
* if it is not null.
|
||||
*/
|
||||
sk_sp<SkTypeface> makeFromFile(const char path[], int ttcIndex = 0) const;
|
||||
|
||||
sk_sp<SkTypeface> legacyMakeTypeface(const char familyName[], SkFontStyle style) const;
|
||||
|
||||
/** Return the default fontmgr. */
|
||||
static sk_sp<SkFontMgr> RefDefault();
|
||||
|
||||
protected:
|
||||
virtual int onCountFamilies() const = 0;
|
||||
virtual void onGetFamilyName(int index, SkString* familyName) const = 0;
|
||||
virtual SkFontStyleSet* onCreateStyleSet(int index)const = 0;
|
||||
|
||||
/** May return NULL if the name is not found. */
|
||||
virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const = 0;
|
||||
|
||||
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
|
||||
const SkFontStyle&) const = 0;
|
||||
virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
|
||||
const char* bcp47[], int bcp47Count,
|
||||
SkUnichar character) const = 0;
|
||||
|
||||
virtual sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const = 0;
|
||||
virtual sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>,
|
||||
int ttcIndex) const = 0;
|
||||
virtual sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
|
||||
const SkFontArguments&) const = 0;
|
||||
virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const = 0;
|
||||
|
||||
virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const = 0;
|
||||
|
||||
// this method is never called -- will be removed
|
||||
virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
|
||||
const SkFontStyle&) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Implemented by porting layer to return the default factory. */
|
||||
static sk_sp<SkFontMgr> Factory();
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
#endif
|
||||
42
src/deps/skia/include/core/SkFontParameters.h
Normal file
42
src/deps/skia/include/core/SkFontParameters.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontParameters_DEFINED
|
||||
#define SkFontParameters_DEFINED
|
||||
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
struct SkFontParameters {
|
||||
struct Variation {
|
||||
// Parameters in a variation font axis.
|
||||
struct Axis {
|
||||
constexpr Axis() : tag(0), min(0), def(0), max(0), flags(0) {}
|
||||
constexpr Axis(SkFourByteTag tag, float min, float def, float max, bool hidden) :
|
||||
tag(tag), min(min), def(def), max(max), flags(hidden ? HIDDEN : 0) {}
|
||||
|
||||
// Four character identifier of the font axis (weight, width, slant, italic...).
|
||||
SkFourByteTag tag;
|
||||
// Minimum value supported by this axis.
|
||||
float min;
|
||||
// Default value set by this axis.
|
||||
float def;
|
||||
// Maximum value supported by this axis. The maximum can equal the minimum.
|
||||
float max;
|
||||
// Return whether this axis is recommended to be remain hidden in user interfaces.
|
||||
bool isHidden() const { return flags & HIDDEN; }
|
||||
// Set this axis to be remain hidden in user interfaces.
|
||||
void setHidden(bool hidden) { flags = hidden ? (flags | HIDDEN) : (flags & ~HIDDEN); }
|
||||
private:
|
||||
static constexpr uint16_t HIDDEN = 0x0001;
|
||||
// Attributes for a font axis.
|
||||
uint16_t flags;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
81
src/deps/skia/include/core/SkFontStyle.h
Normal file
81
src/deps/skia/include/core/SkFontStyle.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontStyle_DEFINED
|
||||
#define SkFontStyle_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/private/SkTPin.h"
|
||||
|
||||
class SK_API SkFontStyle {
|
||||
public:
|
||||
enum Weight {
|
||||
kInvisible_Weight = 0,
|
||||
kThin_Weight = 100,
|
||||
kExtraLight_Weight = 200,
|
||||
kLight_Weight = 300,
|
||||
kNormal_Weight = 400,
|
||||
kMedium_Weight = 500,
|
||||
kSemiBold_Weight = 600,
|
||||
kBold_Weight = 700,
|
||||
kExtraBold_Weight = 800,
|
||||
kBlack_Weight = 900,
|
||||
kExtraBlack_Weight = 1000,
|
||||
};
|
||||
|
||||
enum Width {
|
||||
kUltraCondensed_Width = 1,
|
||||
kExtraCondensed_Width = 2,
|
||||
kCondensed_Width = 3,
|
||||
kSemiCondensed_Width = 4,
|
||||
kNormal_Width = 5,
|
||||
kSemiExpanded_Width = 6,
|
||||
kExpanded_Width = 7,
|
||||
kExtraExpanded_Width = 8,
|
||||
kUltraExpanded_Width = 9,
|
||||
};
|
||||
|
||||
enum Slant {
|
||||
kUpright_Slant,
|
||||
kItalic_Slant,
|
||||
kOblique_Slant,
|
||||
};
|
||||
|
||||
constexpr SkFontStyle(int weight, int width, Slant slant) : fValue(
|
||||
(SkTPin<int>(weight, kInvisible_Weight, kExtraBlack_Weight)) +
|
||||
(SkTPin<int>(width, kUltraCondensed_Width, kUltraExpanded_Width) << 16) +
|
||||
(SkTPin<int>(slant, kUpright_Slant, kOblique_Slant) << 24)
|
||||
) { }
|
||||
|
||||
constexpr SkFontStyle() : SkFontStyle{kNormal_Weight, kNormal_Width, kUpright_Slant} { }
|
||||
|
||||
bool operator==(const SkFontStyle& rhs) const {
|
||||
return fValue == rhs.fValue;
|
||||
}
|
||||
|
||||
int weight() const { return fValue & 0xFFFF; }
|
||||
int width() const { return (fValue >> 16) & 0xFF; }
|
||||
Slant slant() const { return (Slant)((fValue >> 24) & 0xFF); }
|
||||
|
||||
static constexpr SkFontStyle Normal() {
|
||||
return SkFontStyle(kNormal_Weight, kNormal_Width, kUpright_Slant);
|
||||
}
|
||||
static constexpr SkFontStyle Bold() {
|
||||
return SkFontStyle(kBold_Weight, kNormal_Width, kUpright_Slant);
|
||||
}
|
||||
static constexpr SkFontStyle Italic() {
|
||||
return SkFontStyle(kNormal_Weight, kNormal_Width, kItalic_Slant );
|
||||
}
|
||||
static constexpr SkFontStyle BoldItalic() {
|
||||
return SkFontStyle(kBold_Weight, kNormal_Width, kItalic_Slant );
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t fValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
25
src/deps/skia/include/core/SkFontTypes.h
Normal file
25
src/deps/skia/include/core/SkFontTypes.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkFontTypes_DEFINED
|
||||
#define SkFontTypes_DEFINED
|
||||
|
||||
enum class SkTextEncoding {
|
||||
kUTF8, //!< uses bytes to represent UTF-8 or ASCII
|
||||
kUTF16, //!< uses two byte words to represent most of Unicode
|
||||
kUTF32, //!< uses four byte words to represent all of Unicode
|
||||
kGlyphID, //!< uses two byte words to represent glyph indices
|
||||
};
|
||||
|
||||
enum class SkFontHinting {
|
||||
kNone, //!< glyph outlines unchanged
|
||||
kSlight, //!< minimal modification to improve constrast
|
||||
kNormal, //!< glyph outlines modified to improve constrast
|
||||
kFull, //!< modifies glyph outlines for maximum constrast
|
||||
};
|
||||
|
||||
#endif
|
||||
153
src/deps/skia/include/core/SkGraphics.h
Normal file
153
src/deps/skia/include/core/SkGraphics.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkGraphics_DEFINED
|
||||
#define SkGraphics_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
class SkData;
|
||||
class SkImageGenerator;
|
||||
class SkTraceMemoryDump;
|
||||
|
||||
class SK_API SkGraphics {
|
||||
public:
|
||||
/**
|
||||
* Call this at process initialization time if your environment does not
|
||||
* permit static global initializers that execute code.
|
||||
* Init() is thread-safe and idempotent.
|
||||
*/
|
||||
static void Init();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* This function returns the memory used for temporary images and other resources.
|
||||
*/
|
||||
static size_t GetResourceCacheTotalBytesUsed();
|
||||
|
||||
/**
|
||||
* These functions get/set the memory usage limit for the resource cache, used for temporary
|
||||
* bitmaps and other resources. Entries are purged from the cache when the memory useage
|
||||
* exceeds this limit.
|
||||
*/
|
||||
static size_t GetResourceCacheTotalByteLimit();
|
||||
static size_t SetResourceCacheTotalByteLimit(size_t newLimit);
|
||||
|
||||
/**
|
||||
* For debugging purposes, this will attempt to purge the resource cache. It
|
||||
* does not change the limit.
|
||||
*/
|
||||
static void PurgeResourceCache();
|
||||
|
||||
/**
|
||||
* When the cachable entry is very lage (e.g. a large scaled bitmap), adding it to the cache
|
||||
* can cause most/all of the existing entries to be purged. To avoid the, the client can set
|
||||
* a limit for a single allocation. If a cacheable entry would have been cached, but its size
|
||||
* exceeds this limit, then we do not attempt to cache it at all.
|
||||
*
|
||||
* Zero is the default value, meaning we always attempt to cache entries.
|
||||
*/
|
||||
static size_t GetResourceCacheSingleAllocationByteLimit();
|
||||
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);
|
||||
|
||||
/**
|
||||
* Call early in main() to allow Skia to use a JIT to accelerate CPU-bound operations.
|
||||
*/
|
||||
static void AllowJIT();
|
||||
};
|
||||
|
||||
class SkAutoGraphics {
|
||||
public:
|
||||
SkAutoGraphics() {
|
||||
SkGraphics::Init();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
19
src/deps/skia/include/core/SkICC.h
Normal file
19
src/deps/skia/include/core/SkICC.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkICC_DEFINED
|
||||
#define SkICC_DEFINED
|
||||
|
||||
#include "include/core/SkData.h"
|
||||
|
||||
struct skcms_Matrix3x3;
|
||||
struct skcms_TransferFunction;
|
||||
|
||||
SK_API sk_sp<SkData> SkWriteICCProfile(const skcms_TransferFunction&,
|
||||
const skcms_Matrix3x3& toXYZD50);
|
||||
|
||||
#endif//SkICC_DEFINED
|
||||
1302
src/deps/skia/include/core/SkImage.h
Normal file
1302
src/deps/skia/include/core/SkImage.h
Normal file
File diff suppressed because it is too large
Load Diff
72
src/deps/skia/include/core/SkImageEncoder.h
Normal file
72
src/deps/skia/include/core/SkImageEncoder.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkImageEncoder_DEFINED
|
||||
#define SkImageEncoder_DEFINED
|
||||
|
||||
// TODO: update clients so we can remove this include, they should IWYU
|
||||
#include "include/core/SkBitmap.h"
|
||||
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkEncodedImageFormat.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
#include "include/core/SkStream.h"
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
/**
|
||||
* Encode SkPixmap in the given binary image format.
|
||||
*
|
||||
* @param dst results are written to this stream.
|
||||
* @param src source pixels.
|
||||
* @param format image format, not all formats are supported.
|
||||
* @param quality range from 0-100, this is supported by jpeg and webp.
|
||||
* higher values correspond to improved visual quality, but less compression.
|
||||
*
|
||||
* @return false iff input is bad or format is unsupported.
|
||||
*
|
||||
* Will always return false if Skia is compiled without image
|
||||
* encoders.
|
||||
*
|
||||
* For SkEncodedImageFormat::kWEBP, if quality is 100, it will use lossless compression. Otherwise
|
||||
* it will use lossy.
|
||||
*
|
||||
* For examples of encoding an image to a file or to a block of memory,
|
||||
* see tools/ToolUtils.h.
|
||||
*/
|
||||
SK_API bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
|
||||
SkEncodedImageFormat format, int quality);
|
||||
|
||||
/**
|
||||
* The following helper function wraps SkEncodeImage().
|
||||
*/
|
||||
SK_API bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFormat f, int q);
|
||||
|
||||
/**
|
||||
* Encode SkPixmap in the given binary image format.
|
||||
*
|
||||
* @param src source pixels.
|
||||
* @param format image format, not all formats are supported.
|
||||
* @param quality range from 0-100, this is supported by jpeg and webp.
|
||||
* higher values correspond to improved visual quality, but less compression.
|
||||
*
|
||||
* @return encoded data or nullptr if input is bad or format is unsupported.
|
||||
*
|
||||
* Will always return nullptr if Skia is compiled without image
|
||||
* encoders.
|
||||
*
|
||||
* For SkEncodedImageFormat::kWEBP, if quality is 100, it will use lossless compression. Otherwise
|
||||
* it will use lossy.
|
||||
*/
|
||||
SK_API sk_sp<SkData> SkEncodePixmap(const SkPixmap& src, SkEncodedImageFormat format, int quality);
|
||||
|
||||
/**
|
||||
* Helper that extracts the pixmap from the bitmap, and then calls SkEncodePixmap()
|
||||
*/
|
||||
SK_API sk_sp<SkData> SkEncodeBitmap(const SkBitmap& src, SkEncodedImageFormat format, int quality);
|
||||
|
||||
#endif // SkImageEncoder_DEFINED
|
||||
114
src/deps/skia/include/core/SkImageFilter.h
Normal file
114
src/deps/skia/include/core/SkImageFilter.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkImageFilter_DEFINED
|
||||
#define SkImageFilter_DEFINED
|
||||
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkRect.h"
|
||||
|
||||
class SkColorFilter;
|
||||
|
||||
/**
|
||||
* Base class for image filters. If one is installed in the paint, then all drawing occurs as
|
||||
* usual, but it is as if the drawing happened into an offscreen (before the xfermode is applied).
|
||||
* This offscreen bitmap will then be handed to the imagefilter, who in turn creates a new bitmap
|
||||
* which is what will finally be drawn to the device (using the original xfermode).
|
||||
*
|
||||
* The local space of image filters matches the local space of the drawn geometry. For instance if
|
||||
* there is rotation on the canvas, the blur will be computed along those rotated axes and not in
|
||||
* the device space. In order to achieve this result, the actual drawing of the geometry may happen
|
||||
* in an unrotated coordinate system so that the filtered image can be computed more easily, and
|
||||
* 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 {
|
||||
public:
|
||||
enum MapDirection {
|
||||
kForward_MapDirection,
|
||||
kReverse_MapDirection,
|
||||
};
|
||||
/**
|
||||
* Map a device-space rect recursively forward or backward through the filter DAG.
|
||||
* kForward_MapDirection is used to determine which pixels of the destination canvas a source
|
||||
* image rect would touch after filtering. kReverse_MapDirection is used to determine which rect
|
||||
* of the source image would be required to fill the given rect (typically, clip bounds). Used
|
||||
* for clipping and temp-buffer allocations, so the result need not be exact, but should never
|
||||
* be smaller than the real answer. The default implementation recursively unions all input
|
||||
* bounds, or returns the source rect if no inputs.
|
||||
*
|
||||
* In kReverse mode, 'inputRect' is the device-space bounds of the input pixels. In kForward
|
||||
* mode it should always be null. If 'inputRect' is null in kReverse mode the resulting answer
|
||||
* may be incorrect.
|
||||
*/
|
||||
SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm,
|
||||
MapDirection, const SkIRect* inputRect = nullptr) const;
|
||||
|
||||
/**
|
||||
* Returns whether this image filter is a color filter and puts the color filter into the
|
||||
* "filterPtr" parameter if it can. Does nothing otherwise.
|
||||
* If this returns false, then the filterPtr is unchanged.
|
||||
* If this returns true, then if filterPtr is not null, it must be set to a ref'd colorfitler
|
||||
* (i.e. it may not be set to NULL).
|
||||
*/
|
||||
bool isColorFilterNode(SkColorFilter** filterPtr) const;
|
||||
|
||||
// DEPRECATED : use isColorFilterNode() instead
|
||||
bool asColorFilter(SkColorFilter** filterPtr) const {
|
||||
return this->isColorFilterNode(filterPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely
|
||||
* replaced by the returned colorfilter. i.e. the two effects will affect drawing in the same
|
||||
* way.
|
||||
*/
|
||||
bool asAColorFilter(SkColorFilter** filterPtr) const;
|
||||
|
||||
/**
|
||||
* Returns the number of inputs this filter will accept (some inputs can be NULL).
|
||||
*/
|
||||
int countInputs() const;
|
||||
|
||||
/**
|
||||
* Returns the input filter at a given index, or NULL if no input is connected. The indices
|
||||
* used are filter-specific.
|
||||
*/
|
||||
const SkImageFilter* getInput(int i) const;
|
||||
|
||||
// Default impl returns union of all input bounds.
|
||||
virtual SkRect computeFastBounds(const SkRect& bounds) const;
|
||||
|
||||
// Can this filter DAG compute the resulting bounds of an object-space rectangle?
|
||||
bool canComputeFastBounds() const;
|
||||
|
||||
/**
|
||||
* If this filter can be represented by another filter + a localMatrix, return that filter,
|
||||
* else return null.
|
||||
*/
|
||||
sk_sp<SkImageFilter> makeWithLocalMatrix(const SkMatrix& matrix) const;
|
||||
|
||||
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 {
|
||||
return sk_ref_sp(const_cast<SkImageFilter*>(this));
|
||||
}
|
||||
|
||||
private:
|
||||
friend class SkImageFilter_Base;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
#endif
|
||||
215
src/deps/skia/include/core/SkImageGenerator.h
Normal file
215
src/deps/skia/include/core/SkImageGenerator.h
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkImageGenerator_DEFINED
|
||||
#define SkImageGenerator_DEFINED
|
||||
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkYUVAPixmaps.h"
|
||||
#include "include/private/SkTOptional.h"
|
||||
|
||||
class GrRecordingContext;
|
||||
class GrSurfaceProxyView;
|
||||
class GrSamplerState;
|
||||
class SkBitmap;
|
||||
class SkData;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
class SkPicture;
|
||||
|
||||
enum class GrImageTexGenPolicy : int;
|
||||
|
||||
class SK_API SkImageGenerator {
|
||||
public:
|
||||
/**
|
||||
* The PixelRef which takes ownership of this SkImageGenerator
|
||||
* will call the image generator's destructor.
|
||||
*/
|
||||
virtual ~SkImageGenerator() { }
|
||||
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
/**
|
||||
* Return a ref to the encoded (i.e. compressed) representation
|
||||
* of this data.
|
||||
*
|
||||
* If non-NULL is returned, the caller is responsible for calling
|
||||
* unref() on the data when it is finished.
|
||||
*/
|
||||
sk_sp<SkData> refEncodedData() {
|
||||
return this->onRefEncodedData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ImageInfo associated with this generator.
|
||||
*/
|
||||
const SkImageInfo& getInfo() const { return fInfo; }
|
||||
|
||||
/**
|
||||
* Can this generator be used to produce images that will be drawable to the specified context
|
||||
* (or to CPU, if context is nullptr)?
|
||||
*/
|
||||
bool isValid(GrRecordingContext* context) const {
|
||||
return this->onIsValid(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode into the given pixels, a block of memory of size at
|
||||
* least (info.fHeight - 1) * rowBytes + (info.fWidth *
|
||||
* bytesPerPixel)
|
||||
*
|
||||
* Repeated calls to this function should give the same results,
|
||||
* allowing the PixelRef to be immutable.
|
||||
*
|
||||
* @param info A description of the format
|
||||
* expected by the caller. This can simply be identical
|
||||
* to the info returned by getInfo().
|
||||
*
|
||||
* This contract also allows the caller to specify
|
||||
* different output-configs, which the implementation can
|
||||
* decide to support or not.
|
||||
*
|
||||
* A size that does not match getInfo() implies a request
|
||||
* to scale. If the generator cannot perform this scale,
|
||||
* it will return false.
|
||||
*
|
||||
* @return true on success.
|
||||
*/
|
||||
bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
|
||||
|
||||
bool getPixels(const SkPixmap& pm) {
|
||||
return this->getPixels(pm.info(), pm.writable_addr(), pm.rowBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* If decoding to YUV is supported, this returns true. Otherwise, this
|
||||
* returns false and the caller will ignore output parameter yuvaPixmapInfo.
|
||||
*
|
||||
* @param supportedDataTypes Indicates the data type/planar config combinations that are
|
||||
* supported by the caller. If the generator supports decoding to
|
||||
* YUV(A), but not as a type in supportedDataTypes, this method
|
||||
* returns false.
|
||||
* @param yuvaPixmapInfo Output parameter that specifies the planar configuration, subsampling,
|
||||
* orientation, chroma siting, plane color types, and row bytes.
|
||||
*/
|
||||
bool queryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes& supportedDataTypes,
|
||||
SkYUVAPixmapInfo* yuvaPixmapInfo) const;
|
||||
|
||||
/**
|
||||
* Returns true on success and false on failure.
|
||||
* This always attempts to perform a full decode. To get the planar
|
||||
* configuration without decoding use queryYUVAInfo().
|
||||
*
|
||||
* @param yuvaPixmaps Contains preallocated pixmaps configured according to a successful call
|
||||
* to queryYUVAInfo().
|
||||
*/
|
||||
bool getYUVAPlanes(const SkYUVAPixmaps& yuvaPixmaps);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/**
|
||||
* If the generator can natively/efficiently return its pixels as a GPU image (backed by a
|
||||
* texture) this will return that image. If not, this will return NULL.
|
||||
*
|
||||
* This routine also supports retrieving only a subset of the pixels. That subset is specified
|
||||
* by the following rectangle:
|
||||
*
|
||||
* subset = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height())
|
||||
*
|
||||
* If subset is not contained inside the generator's bounds, this returns false.
|
||||
*
|
||||
* whole = SkIRect::MakeWH(getInfo().width(), getInfo().height())
|
||||
* if (!whole.contains(subset)) {
|
||||
* return false;
|
||||
* }
|
||||
*
|
||||
* Regarding the GrRecordingContext parameter:
|
||||
*
|
||||
* It must be non-NULL. The generator should only succeed if:
|
||||
* - its internal context is the same
|
||||
* - it can somehow convert its texture into one that is valid for the provided context.
|
||||
*
|
||||
* If the willNeedMipMaps flag is true, the generator should try to create a TextureProxy that
|
||||
* at least has the mip levels allocated and the base layer filled in. If this is not possible,
|
||||
* the generator is allowed to return a non mipped proxy, but this will have some additional
|
||||
* overhead in later allocating mips and copying of the base layer.
|
||||
*
|
||||
* GrImageTexGenPolicy determines whether or not a new texture must be created (and its budget
|
||||
* status) or whether this may (but is not required to) return a pre-existing texture that is
|
||||
* retained by the generator (kDraw).
|
||||
*/
|
||||
GrSurfaceProxyView generateTexture(GrRecordingContext*, const SkImageInfo& info,
|
||||
const SkIPoint& origin, GrMipmapped, GrImageTexGenPolicy);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If the default image decoder system can interpret the specified (encoded) data, then
|
||||
* this returns a new ImageGenerator for it. Otherwise this returns NULL. Either way
|
||||
* the caller is still responsible for managing their ownership of the data.
|
||||
* By default, images will be converted to premultiplied pixels. The alpha type can be
|
||||
* overridden by specifying kPremul_SkAlphaType or kUnpremul_SkAlphaType. Specifying
|
||||
* kOpaque_SkAlphaType is not supported, and will return NULL.
|
||||
*/
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromEncoded(
|
||||
sk_sp<SkData>, skstd::optional<SkAlphaType> = skstd::nullopt);
|
||||
|
||||
/** Return a new image generator backed by the specified picture. If the size is empty or
|
||||
* the picture is NULL, this returns NULL.
|
||||
* The optional matrix and paint arguments are passed to drawPicture() at rasterization
|
||||
* time.
|
||||
*/
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromPicture(const SkISize&, sk_sp<SkPicture>,
|
||||
const SkMatrix*, const SkPaint*,
|
||||
SkImage::BitDepth,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
||||
protected:
|
||||
static constexpr int kNeedNewImageUniqueID = 0;
|
||||
|
||||
SkImageGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID);
|
||||
|
||||
virtual sk_sp<SkData> onRefEncodedData() { return nullptr; }
|
||||
struct Options {};
|
||||
virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; }
|
||||
virtual bool onIsValid(GrRecordingContext*) const { return true; }
|
||||
virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes&,
|
||||
SkYUVAPixmapInfo*) const { return false; }
|
||||
virtual bool onGetYUVAPlanes(const SkYUVAPixmaps&) { return false; }
|
||||
#if SK_SUPPORT_GPU
|
||||
// returns nullptr
|
||||
virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
|
||||
const SkIPoint&, GrMipmapped, GrImageTexGenPolicy);
|
||||
|
||||
// Most internal SkImageGenerators produce textures and views that use kTopLeft_GrSurfaceOrigin.
|
||||
// If the generator may produce textures with different origins (e.g.
|
||||
// GrAHardwareBufferImageGenerator) it should override this function to return the correct
|
||||
// origin.
|
||||
virtual GrSurfaceOrigin origin() const { return kTopLeft_GrSurfaceOrigin; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
const SkImageInfo fInfo;
|
||||
const uint32_t fUniqueID;
|
||||
|
||||
friend class SkImage_Lazy;
|
||||
|
||||
// This is our default impl, which may be different on different platforms.
|
||||
// It is called from NewFromEncoded() after it has checked for any runtime factory.
|
||||
// The SkData will never be NULL, as that will have been checked by NewFromEncoded.
|
||||
static std::unique_ptr<SkImageGenerator> MakeFromEncodedImpl(sk_sp<SkData>,
|
||||
skstd::optional<SkAlphaType>);
|
||||
|
||||
SkImageGenerator(SkImageGenerator&&) = delete;
|
||||
SkImageGenerator(const SkImageGenerator&) = delete;
|
||||
SkImageGenerator& operator=(SkImageGenerator&&) = delete;
|
||||
SkImageGenerator& operator=(const SkImageGenerator&) = delete;
|
||||
};
|
||||
|
||||
#endif // SkImageGenerator_DEFINED
|
||||
721
src/deps/skia/include/core/SkImageInfo.h
Normal file
721
src/deps/skia/include/core/SkImageInfo.h
Normal file
@@ -0,0 +1,721 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkImageInfo_DEFINED
|
||||
#define SkImageInfo_DEFINED
|
||||
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkMath.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkSize.h"
|
||||
|
||||
#include "include/private/SkTFitsIn.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
class SkReadBuffer;
|
||||
class SkWriteBuffer;
|
||||
|
||||
/** \enum SkImageInfo::SkAlphaType
|
||||
Describes how to interpret the alpha component of a pixel. A pixel may
|
||||
be opaque, or alpha, describing multiple levels of transparency.
|
||||
|
||||
In simple blending, alpha weights the draw color and the destination
|
||||
color to create a new color. If alpha describes a weight from zero to one:
|
||||
|
||||
new color = draw color * alpha + destination color * (1 - alpha)
|
||||
|
||||
In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
|
||||
|
||||
RGB may have alpha included in each component value; the stored
|
||||
value is the original RGB multiplied by alpha. Premultiplied color
|
||||
components improve performance.
|
||||
*/
|
||||
enum SkAlphaType : int {
|
||||
kUnknown_SkAlphaType, //!< uninitialized
|
||||
kOpaque_SkAlphaType, //!< pixel is opaque
|
||||
kPremul_SkAlphaType, //!< pixel components are premultiplied by alpha
|
||||
kUnpremul_SkAlphaType, //!< pixel components are independent of alpha
|
||||
kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, //!< last valid value
|
||||
};
|
||||
|
||||
/** Returns true if SkAlphaType equals kOpaque_SkAlphaType.
|
||||
|
||||
kOpaque_SkAlphaType is a hint that the SkColorType is opaque, or that all
|
||||
alpha values are set to their 1.0 equivalent. If SkAlphaType is
|
||||
kOpaque_SkAlphaType, and SkColorType is not opaque, then the result of
|
||||
drawing any pixel with a alpha value less than 1.0 is undefined.
|
||||
*/
|
||||
static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
|
||||
return kOpaque_SkAlphaType == at;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** \enum SkImageInfo::SkColorType
|
||||
Describes how pixel bits encode color. A pixel may be an alpha mask, a grayscale, RGB, or ARGB.
|
||||
|
||||
kN32_SkColorType selects the native 32-bit ARGB format for the current configuration. This can
|
||||
lead to inconsistent results across platforms, so use with caution.
|
||||
*/
|
||||
enum SkColorType : int {
|
||||
kUnknown_SkColorType, //!< uninitialized
|
||||
kAlpha_8_SkColorType, //!< pixel with alpha in 8-bit byte
|
||||
kRGB_565_SkColorType, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
|
||||
kARGB_4444_SkColorType, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word
|
||||
kRGBA_8888_SkColorType, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word
|
||||
kRGB_888x_SkColorType, //!< pixel with 8 bits each for red, green, blue; in 32-bit word
|
||||
kBGRA_8888_SkColorType, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
|
||||
kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
|
||||
kBGRA_1010102_SkColorType, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
|
||||
kRGB_101010x_SkColorType, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
|
||||
kBGR_101010x_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word
|
||||
kGray_8_SkColorType, //!< pixel with grayscale level in 8-bit byte
|
||||
kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha;
|
||||
// in 64-bit word
|
||||
kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha;
|
||||
// in 64-bit word
|
||||
kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
|
||||
|
||||
// The following 6 colortypes are just for reading from - not for rendering to
|
||||
kR8G8_unorm_SkColorType, //!< pixel with a uint8_t for red and green
|
||||
|
||||
kA16_float_SkColorType, //!< pixel with a half float for alpha
|
||||
kR16G16_float_SkColorType, //!< pixel with a half float for red and green
|
||||
|
||||
kA16_unorm_SkColorType, //!< pixel with a little endian uint16_t for alpha
|
||||
kR16G16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red and green
|
||||
kR16G16B16A16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red, green, blue
|
||||
// and alpha
|
||||
|
||||
kSRGBA_8888_SkColorType,
|
||||
|
||||
kLastEnum_SkColorType = kSRGBA_8888_SkColorType, //!< last valid value
|
||||
|
||||
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
|
||||
kN32_SkColorType = kBGRA_8888_SkColorType,//!< native 32-bit BGRA encoding
|
||||
|
||||
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
||||
kN32_SkColorType = kRGBA_8888_SkColorType,//!< native 32-bit RGBA encoding
|
||||
|
||||
#else
|
||||
#error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order"
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Returns the number of bytes required to store a pixel, including unused padding.
|
||||
Returns zero if ct is kUnknown_SkColorType or invalid.
|
||||
|
||||
@return bytes per pixel
|
||||
*/
|
||||
SK_API int SkColorTypeBytesPerPixel(SkColorType ct);
|
||||
|
||||
/** Returns true if SkColorType always decodes alpha to 1.0, making the pixel
|
||||
fully opaque. If true, SkColorType does not reserve bits to encode alpha.
|
||||
|
||||
@return true if alpha is always set to 1.0
|
||||
*/
|
||||
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct);
|
||||
|
||||
/** Returns true if canonical can be set to a valid SkAlphaType for colorType. If
|
||||
there is more than one valid canonical SkAlphaType, set to alphaType, if valid.
|
||||
If true is returned and canonical is not nullptr, store valid SkAlphaType.
|
||||
|
||||
Returns false only if alphaType is kUnknown_SkAlphaType, color type is not
|
||||
kUnknown_SkColorType, and SkColorType is not always opaque. If false is returned,
|
||||
canonical is ignored.
|
||||
|
||||
@param canonical storage for SkAlphaType
|
||||
@return true if valid SkAlphaType can be associated with colorType
|
||||
*/
|
||||
SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
|
||||
SkAlphaType* canonical = nullptr);
|
||||
|
||||
/** \enum SkImageInfo::SkYUVColorSpace
|
||||
Describes color range of YUV pixels. The color mapping from YUV to RGB varies
|
||||
depending on the source. YUV pixels may be generated by JPEG images, standard
|
||||
video streams, or high definition video streams. Each has its own mapping from
|
||||
YUV to RGB.
|
||||
|
||||
JPEG YUV values encode the full range of 0 to 255 for all three components.
|
||||
Video YUV values often range from 16 to 235 for Y and from 16 to 240 for U and V (limited).
|
||||
Details of encoding and conversion to RGB are described in YCbCr color space.
|
||||
|
||||
The identity colorspace exists to provide a utility mapping from Y to R, U to G and V to B.
|
||||
It can be used to visualize the YUV planes or to explicitly post process the YUV channels.
|
||||
*/
|
||||
enum SkYUVColorSpace : int {
|
||||
kJPEG_Full_SkYUVColorSpace, //!< describes full range
|
||||
kRec601_Limited_SkYUVColorSpace, //!< describes SDTV range
|
||||
kRec709_Full_SkYUVColorSpace, //!< describes HDTV range
|
||||
kRec709_Limited_SkYUVColorSpace,
|
||||
kBT2020_8bit_Full_SkYUVColorSpace, //!< describes UHDTV range, non-constant-luminance
|
||||
kBT2020_8bit_Limited_SkYUVColorSpace,
|
||||
kBT2020_10bit_Full_SkYUVColorSpace,
|
||||
kBT2020_10bit_Limited_SkYUVColorSpace,
|
||||
kBT2020_12bit_Full_SkYUVColorSpace,
|
||||
kBT2020_12bit_Limited_SkYUVColorSpace,
|
||||
kIdentity_SkYUVColorSpace, //!< maps Y->R, U->G, V->B
|
||||
|
||||
kLastEnum_SkYUVColorSpace = kIdentity_SkYUVColorSpace, //!< last valid value
|
||||
|
||||
// Legacy (deprecated) names:
|
||||
kJPEG_SkYUVColorSpace = kJPEG_Full_SkYUVColorSpace,
|
||||
kRec601_SkYUVColorSpace = kRec601_Limited_SkYUVColorSpace,
|
||||
kRec709_SkYUVColorSpace = kRec709_Limited_SkYUVColorSpace,
|
||||
kBT2020_SkYUVColorSpace = kBT2020_8bit_Limited_SkYUVColorSpace,
|
||||
};
|
||||
|
||||
/** \struct SkColorInfo
|
||||
Describes pixel and encoding. SkImageInfo can be created from SkColorInfo by
|
||||
providing dimensions.
|
||||
|
||||
It encodes how pixel bits describe alpha, transparency; color components red, blue,
|
||||
and green; and SkColorSpace, the range and linearity of colors.
|
||||
*/
|
||||
class SK_API SkColorInfo {
|
||||
public:
|
||||
/** Creates an SkColorInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
||||
and no SkColorSpace.
|
||||
|
||||
@return empty SkImageInfo
|
||||
*/
|
||||
SkColorInfo() = default;
|
||||
|
||||
/** Creates SkColorInfo from SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.
|
||||
|
||||
If SkColorSpace cs is nullptr and SkColorInfo is part of drawing source: SkColorSpace
|
||||
defaults to sRGB, mapping into SkSurface SkColorSpace.
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
@return created SkColorInfo
|
||||
*/
|
||||
SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs)
|
||||
: fColorSpace(std::move(cs)), fColorType(ct), fAlphaType(at) {}
|
||||
|
||||
SkColorInfo(const SkColorInfo&) = default;
|
||||
SkColorInfo(SkColorInfo&&) = default;
|
||||
|
||||
SkColorInfo& operator=(const SkColorInfo&) = default;
|
||||
SkColorInfo& operator=(SkColorInfo&&) = default;
|
||||
|
||||
SkColorSpace* colorSpace() const { return fColorSpace.get(); }
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
|
||||
SkColorType colorType() const { return fColorType; }
|
||||
SkAlphaType alphaType() const { return fAlphaType; }
|
||||
|
||||
bool isOpaque() const {
|
||||
return SkAlphaTypeIsOpaque(fAlphaType)
|
||||
|| SkColorTypeIsAlwaysOpaque(fColorType);
|
||||
}
|
||||
|
||||
bool gammaCloseToSRGB() const { return fColorSpace && fColorSpace->gammaCloseToSRGB(); }
|
||||
|
||||
/** Does other represent the same color type, alpha type, and color space? */
|
||||
bool operator==(const SkColorInfo& other) const {
|
||||
return fColorType == other.fColorType && fAlphaType == other.fAlphaType &&
|
||||
SkColorSpace::Equals(fColorSpace.get(), other.fColorSpace.get());
|
||||
}
|
||||
|
||||
/** Does other represent a different color type, alpha type, or color space? */
|
||||
bool operator!=(const SkColorInfo& other) const { return !(*this == other); }
|
||||
|
||||
/** Creates SkColorInfo with same SkColorType, SkColorSpace, with SkAlphaType set
|
||||
to newAlphaType.
|
||||
|
||||
Created SkColorInfo contains newAlphaType even if it is incompatible with
|
||||
SkColorType, in which case SkAlphaType in SkColorInfo is ignored.
|
||||
*/
|
||||
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const {
|
||||
return SkColorInfo(this->colorType(), newAlphaType, this->refColorSpace());
|
||||
}
|
||||
|
||||
/** Creates new SkColorInfo with same SkAlphaType, SkColorSpace, with SkColorType
|
||||
set to newColorType.
|
||||
*/
|
||||
SkColorInfo makeColorType(SkColorType newColorType) const {
|
||||
return SkColorInfo(newColorType, this->alphaType(), this->refColorSpace());
|
||||
}
|
||||
|
||||
/** Creates SkColorInfo with same SkAlphaType, SkColorType, with SkColorSpace
|
||||
set to cs. cs may be nullptr.
|
||||
*/
|
||||
SkColorInfo makeColorSpace(sk_sp<SkColorSpace> cs) const {
|
||||
return SkColorInfo(this->colorType(), this->alphaType(), std::move(cs));
|
||||
}
|
||||
|
||||
/** Returns number of bytes per pixel required by SkColorType.
|
||||
Returns zero if colorType() is kUnknown_SkColorType.
|
||||
|
||||
@return bytes in pixel
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_bytesPerPixel
|
||||
*/
|
||||
int bytesPerPixel() const;
|
||||
|
||||
/** Returns bit shift converting row bytes to row pixels.
|
||||
Returns zero for kUnknown_SkColorType.
|
||||
|
||||
@return one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_shiftPerPixel
|
||||
*/
|
||||
int shiftPerPixel() const;
|
||||
|
||||
private:
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
SkColorType fColorType = kUnknown_SkColorType;
|
||||
SkAlphaType fAlphaType = kUnknown_SkAlphaType;
|
||||
};
|
||||
|
||||
/** \struct SkImageInfo
|
||||
Describes pixel dimensions and encoding. SkBitmap, SkImage, PixMap, and SkSurface
|
||||
can be created from SkImageInfo. SkImageInfo can be retrieved from SkBitmap and
|
||||
SkPixmap, but not from SkImage and SkSurface. For example, SkImage and SkSurface
|
||||
implementations may defer pixel depth, so may not completely specify SkImageInfo.
|
||||
|
||||
SkImageInfo contains dimensions, the pixel integral width and height. It encodes
|
||||
how pixel bits describe alpha, transparency; color components red, blue,
|
||||
and green; and SkColorSpace, the range and linearity of colors.
|
||||
*/
|
||||
struct SK_API SkImageInfo {
|
||||
public:
|
||||
|
||||
/** Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
||||
a width and height of zero, and no SkColorSpace.
|
||||
|
||||
@return empty SkImageInfo
|
||||
*/
|
||||
SkImageInfo() = default;
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, SkColorType ct,
|
||||
SkAlphaType at, and optionally SkColorSpace cs.
|
||||
|
||||
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace
|
||||
defaults to sRGB, mapping into SkSurface SkColorSpace.
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
|
||||
sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return SkImageInfo({width, height}, {ct, at, std::move(cs)});
|
||||
}
|
||||
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at,
|
||||
sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return SkImageInfo(dimensions, {ct, at, std::move(cs)});
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param dimensions pixel column and row count; must be zeros or greater
|
||||
@param SkColorInfo the pixel encoding consisting of SkColorType, SkAlphaType, and
|
||||
SkColorSpace (which may be nullptr)
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo Make(SkISize dimensions, const SkColorInfo& colorInfo) {
|
||||
return SkImageInfo(dimensions, colorInfo);
|
||||
}
|
||||
static SkImageInfo Make(SkISize dimensions, SkColorInfo&& colorInfo) {
|
||||
return SkImageInfo(dimensions, std::move(colorInfo));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
||||
SkAlphaType at, and optionally SkColorSpace cs. kN32_SkColorType will equal either
|
||||
kBGRA_8888_SkColorType or kRGBA_8888_SkColorType, whichever is optimal.
|
||||
|
||||
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace
|
||||
defaults to sRGB, mapping into SkSurface SkColorSpace.
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
|
||||
sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return Make({width, height}, kN32_SkColorType, at, std::move(cs));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
||||
SkAlphaType at, with sRGB SkColorSpace.
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_MakeS32
|
||||
*/
|
||||
static SkImageInfo MakeS32(int width, int height, SkAlphaType at);
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
||||
kPremul_SkAlphaType, with optional SkColorSpace.
|
||||
|
||||
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace
|
||||
defaults to sRGB, mapping into SkSurface SkColorSpace.
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return Make({width, height}, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
||||
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
||||
If SkImageInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping
|
||||
into SkSurface SkColorSpace.
|
||||
|
||||
Parameters are not validated to see if their values are legal, or that the
|
||||
combination is supported.
|
||||
|
||||
@param dimensions width and height, each must be zero or greater
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeN32Premul(SkISize dimensions, sk_sp<SkColorSpace> cs = nullptr) {
|
||||
return Make(dimensions, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType,
|
||||
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeA8(int width, int height) {
|
||||
return Make({width, height}, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
}
|
||||
/** Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType,
|
||||
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
||||
@param dimensions pixel row and column count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeA8(SkISize dimensions) {
|
||||
return Make(dimensions, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType,
|
||||
kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
||||
Returned SkImageInfo as part of source does not draw, and as part of destination
|
||||
can not be drawn to.
|
||||
|
||||
@param width pixel column count; must be zero or greater
|
||||
@param height pixel row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeUnknown(int width, int height) {
|
||||
return Make({width, height}, kUnknown_SkColorType, kUnknown_SkAlphaType, nullptr);
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo from integral dimensions width and height set to zero,
|
||||
kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
|
||||
|
||||
Returned SkImageInfo as part of source does not draw, and as part of destination
|
||||
can not be drawn to.
|
||||
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
static SkImageInfo MakeUnknown() {
|
||||
return MakeUnknown(0, 0);
|
||||
}
|
||||
|
||||
/** Returns pixel count in each row.
|
||||
|
||||
@return pixel width
|
||||
*/
|
||||
int width() const { return fDimensions.width(); }
|
||||
|
||||
/** Returns pixel row count.
|
||||
|
||||
@return pixel height
|
||||
*/
|
||||
int height() const { return fDimensions.height(); }
|
||||
|
||||
SkColorType colorType() const { return fColorInfo.colorType(); }
|
||||
|
||||
SkAlphaType alphaType() const { return fColorInfo.alphaType(); }
|
||||
|
||||
/** Returns SkColorSpace, the range of colors. The reference count of
|
||||
SkColorSpace is unchanged. The returned SkColorSpace is immutable.
|
||||
|
||||
@return SkColorSpace, or nullptr
|
||||
*/
|
||||
SkColorSpace* colorSpace() const { return fColorInfo.colorSpace(); }
|
||||
|
||||
/** Returns smart pointer to SkColorSpace, the range of colors. The smart pointer
|
||||
tracks the number of objects sharing this SkColorSpace reference so the memory
|
||||
is released when the owners destruct.
|
||||
|
||||
The returned SkColorSpace is immutable.
|
||||
|
||||
@return SkColorSpace wrapped in a smart pointer
|
||||
*/
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fColorInfo.refColorSpace(); }
|
||||
|
||||
/** Returns if SkImageInfo describes an empty area of pixels by checking if either
|
||||
width or height is zero or smaller.
|
||||
|
||||
@return true if either dimension is zero or smaller
|
||||
*/
|
||||
bool isEmpty() const { return fDimensions.isEmpty(); }
|
||||
|
||||
/** Returns the dimensionless SkColorInfo that represents the same color type,
|
||||
alpha type, and color space as this SkImageInfo.
|
||||
*/
|
||||
const SkColorInfo& colorInfo() const { return fColorInfo; }
|
||||
|
||||
/** Returns true if SkAlphaType is set to hint that all pixels are opaque; their
|
||||
alpha value is implicitly or explicitly 1.0. If true, and all pixels are
|
||||
not opaque, Skia may draw incorrectly.
|
||||
|
||||
Does not check if SkColorType allows alpha, or if any pixel value has
|
||||
transparency.
|
||||
|
||||
@return true if SkAlphaType is kOpaque_SkAlphaType
|
||||
*/
|
||||
bool isOpaque() const { return fColorInfo.isOpaque(); }
|
||||
|
||||
/** Returns SkISize { width(), height() }.
|
||||
|
||||
@return integral size of width() and height()
|
||||
*/
|
||||
SkISize dimensions() const { return fDimensions; }
|
||||
|
||||
/** Returns SkIRect { 0, 0, width(), height() }.
|
||||
|
||||
@return integral rectangle from origin to width() and height()
|
||||
*/
|
||||
SkIRect bounds() const { return SkIRect::MakeSize(fDimensions); }
|
||||
|
||||
/** Returns true if associated SkColorSpace is not nullptr, and SkColorSpace gamma
|
||||
is approximately the same as sRGB.
|
||||
This includes the
|
||||
|
||||
@return true if SkColorSpace gamma is approximately the same as sRGB
|
||||
*/
|
||||
bool gammaCloseToSRGB() const { return fColorInfo.gammaCloseToSRGB(); }
|
||||
|
||||
/** Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType,
|
||||
with dimensions set to width and height.
|
||||
|
||||
@param newWidth pixel column count; must be zero or greater
|
||||
@param newHeight pixel row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeWH(int newWidth, int newHeight) const {
|
||||
return Make({newWidth, newHeight}, fColorInfo);
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType,
|
||||
with dimensions set to newDimensions.
|
||||
|
||||
@param newSize pixel column and row count; must be zero or greater
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeDimensions(SkISize newSize) const {
|
||||
return Make(newSize, fColorInfo);
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo with same SkColorType, SkColorSpace, width, and height,
|
||||
with SkAlphaType set to newAlphaType.
|
||||
|
||||
Created SkImageInfo contains newAlphaType even if it is incompatible with
|
||||
SkColorType, in which case SkAlphaType in SkImageInfo is ignored.
|
||||
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const {
|
||||
return Make(fDimensions, fColorInfo.makeAlphaType(newAlphaType));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height,
|
||||
with SkColorType set to newColorType.
|
||||
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeColorType(SkColorType newColorType) const {
|
||||
return Make(fDimensions, fColorInfo.makeColorType(newColorType));
|
||||
}
|
||||
|
||||
/** Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height,
|
||||
with SkColorSpace set to cs.
|
||||
|
||||
@param cs range of colors; may be nullptr
|
||||
@return created SkImageInfo
|
||||
*/
|
||||
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const {
|
||||
return Make(fDimensions, fColorInfo.makeColorSpace(std::move(cs)));
|
||||
}
|
||||
|
||||
/** Returns number of bytes per pixel required by SkColorType.
|
||||
Returns zero if colorType( is kUnknown_SkColorType.
|
||||
|
||||
@return bytes in pixel
|
||||
*/
|
||||
int bytesPerPixel() const { return fColorInfo.bytesPerPixel(); }
|
||||
|
||||
/** Returns bit shift converting row bytes to row pixels.
|
||||
Returns zero for kUnknown_SkColorType.
|
||||
|
||||
@return one of: 0, 1, 2, 3; left shift to convert pixels to bytes
|
||||
*/
|
||||
int shiftPerPixel() const { return fColorInfo.shiftPerPixel(); }
|
||||
|
||||
/** Returns minimum bytes per row, computed from pixel width() and SkColorType, which
|
||||
specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit
|
||||
in 31 bits.
|
||||
|
||||
@return width() times bytesPerPixel() as unsigned 64-bit integer
|
||||
*/
|
||||
uint64_t minRowBytes64() const {
|
||||
return (uint64_t)sk_64_mul(this->width(), this->bytesPerPixel());
|
||||
}
|
||||
|
||||
/** Returns minimum bytes per row, computed from pixel width() and SkColorType, which
|
||||
specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit
|
||||
in 31 bits.
|
||||
|
||||
@return width() times bytesPerPixel() as size_t
|
||||
*/
|
||||
size_t minRowBytes() const {
|
||||
uint64_t minRowBytes = this->minRowBytes64();
|
||||
if (!SkTFitsIn<int32_t>(minRowBytes)) {
|
||||
return 0;
|
||||
}
|
||||
return (size_t)minRowBytes;
|
||||
}
|
||||
|
||||
/** Returns byte offset of pixel from pixel base address.
|
||||
|
||||
Asserts in debug build if x or y is outside of bounds. Does not assert if
|
||||
rowBytes is smaller than minRowBytes(), even though result may be incorrect.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@param rowBytes size of pixel row or larger
|
||||
@return offset within pixel array
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_computeOffset
|
||||
*/
|
||||
size_t computeOffset(int x, int y, size_t rowBytes) const;
|
||||
|
||||
/** Compares SkImageInfo with other, and returns true if width, height, SkColorType,
|
||||
SkAlphaType, and SkColorSpace are equivalent.
|
||||
|
||||
@param other SkImageInfo to compare
|
||||
@return true if SkImageInfo equals other
|
||||
*/
|
||||
bool operator==(const SkImageInfo& other) const {
|
||||
return fDimensions == other.fDimensions && fColorInfo == other.fColorInfo;
|
||||
}
|
||||
|
||||
/** Compares SkImageInfo with other, and returns true if width, height, SkColorType,
|
||||
SkAlphaType, and SkColorSpace are not equivalent.
|
||||
|
||||
@param other SkImageInfo to compare
|
||||
@return true if SkImageInfo is not equal to other
|
||||
*/
|
||||
bool operator!=(const SkImageInfo& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/** Returns storage required by pixel array, given SkImageInfo dimensions, SkColorType,
|
||||
and rowBytes. rowBytes is assumed to be at least as large as minRowBytes().
|
||||
|
||||
Returns zero if height is zero.
|
||||
Returns SIZE_MAX if answer exceeds the range of size_t.
|
||||
|
||||
@param rowBytes size of pixel row or larger
|
||||
@return memory required by pixel buffer
|
||||
|
||||
example: https://fiddle.skia.org/c/@ImageInfo_computeByteSize
|
||||
*/
|
||||
size_t computeByteSize(size_t rowBytes) const;
|
||||
|
||||
/** Returns storage required by pixel array, given SkImageInfo dimensions, and
|
||||
SkColorType. Uses minRowBytes() to compute bytes for pixel row.
|
||||
|
||||
Returns zero if height is zero.
|
||||
Returns SIZE_MAX if answer exceeds the range of size_t.
|
||||
|
||||
@return least memory required by pixel buffer
|
||||
*/
|
||||
size_t computeMinByteSize() const {
|
||||
return this->computeByteSize(this->minRowBytes());
|
||||
}
|
||||
|
||||
/** Returns true if byteSize equals SIZE_MAX. computeByteSize() and
|
||||
computeMinByteSize() return SIZE_MAX if size_t can not hold buffer size.
|
||||
|
||||
@param byteSize result of computeByteSize() or computeMinByteSize()
|
||||
@return true if computeByteSize() or computeMinByteSize() result exceeds size_t
|
||||
*/
|
||||
static bool ByteSizeOverflowed(size_t byteSize) {
|
||||
return SIZE_MAX == byteSize;
|
||||
}
|
||||
|
||||
/** Returns true if rowBytes is valid for this SkImageInfo.
|
||||
|
||||
@param rowBytes size of pixel row including padding
|
||||
@return true if rowBytes is large enough to contain pixel row and is properly
|
||||
aligned
|
||||
*/
|
||||
bool validRowBytes(size_t rowBytes) const {
|
||||
if (rowBytes < this->minRowBytes64()) {
|
||||
return false;
|
||||
}
|
||||
int shift = this->shiftPerPixel();
|
||||
size_t alignedRowBytes = rowBytes >> shift << shift;
|
||||
return alignedRowBytes == rowBytes;
|
||||
}
|
||||
|
||||
/** Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
||||
a width and height of zero, and no SkColorSpace.
|
||||
*/
|
||||
void reset() { *this = {}; }
|
||||
|
||||
/** Asserts if internal values are illegal or inconsistent. Only available if
|
||||
SK_DEBUG is defined at compile time.
|
||||
*/
|
||||
SkDEBUGCODE(void validate() const;)
|
||||
|
||||
private:
|
||||
SkColorInfo fColorInfo;
|
||||
SkISize fDimensions = {0, 0};
|
||||
|
||||
SkImageInfo(SkISize dimensions, const SkColorInfo& colorInfo)
|
||||
: fColorInfo(colorInfo), fDimensions(dimensions) {}
|
||||
|
||||
SkImageInfo(SkISize dimensions, SkColorInfo&& colorInfo)
|
||||
: fColorInfo(std::move(colorInfo)), fDimensions(dimensions) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
426
src/deps/skia/include/core/SkM44.h
Normal file
426
src/deps/skia/include/core/SkM44.h
Normal file
@@ -0,0 +1,426 @@
|
||||
/*
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkM44_DEFINED
|
||||
#define SkM44_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
struct SK_API SkV2 {
|
||||
float x, y;
|
||||
|
||||
bool operator==(const SkV2 v) const { return x == v.x && y == v.y; }
|
||||
bool operator!=(const SkV2 v) const { return !(*this == v); }
|
||||
|
||||
static SkScalar Dot(SkV2 a, SkV2 b) { return a.x * b.x + a.y * b.y; }
|
||||
static SkScalar Cross(SkV2 a, SkV2 b) { return a.x * b.y - a.y * b.x; }
|
||||
static SkV2 Normalize(SkV2 v) { return v * (1.0f / v.length()); }
|
||||
|
||||
SkV2 operator-() const { return {-x, -y}; }
|
||||
SkV2 operator+(SkV2 v) const { return {x+v.x, y+v.y}; }
|
||||
SkV2 operator-(SkV2 v) const { return {x-v.x, y-v.y}; }
|
||||
|
||||
SkV2 operator*(SkV2 v) const { return {x*v.x, y*v.y}; }
|
||||
friend SkV2 operator*(SkV2 v, SkScalar s) { return {v.x*s, v.y*s}; }
|
||||
friend SkV2 operator*(SkScalar s, SkV2 v) { return {v.x*s, v.y*s}; }
|
||||
friend SkV2 operator/(SkV2 v, SkScalar s) { return {v.x/s, v.y/s}; }
|
||||
|
||||
void operator+=(SkV2 v) { *this = *this + v; }
|
||||
void operator-=(SkV2 v) { *this = *this - v; }
|
||||
void operator*=(SkV2 v) { *this = *this * v; }
|
||||
void operator*=(SkScalar s) { *this = *this * s; }
|
||||
void operator/=(SkScalar s) { *this = *this / s; }
|
||||
|
||||
SkScalar lengthSquared() const { return Dot(*this, *this); }
|
||||
SkScalar length() const { return SkScalarSqrt(this->lengthSquared()); }
|
||||
|
||||
SkScalar dot(SkV2 v) const { return Dot(*this, v); }
|
||||
SkScalar cross(SkV2 v) const { return Cross(*this, v); }
|
||||
SkV2 normalize() const { return Normalize(*this); }
|
||||
|
||||
const float* ptr() const { return &x; }
|
||||
float* ptr() { return &x; }
|
||||
};
|
||||
|
||||
struct SK_API SkV3 {
|
||||
float x, y, z;
|
||||
|
||||
bool operator==(const SkV3& v) const {
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
}
|
||||
bool operator!=(const SkV3& v) const { return !(*this == v); }
|
||||
|
||||
static SkScalar Dot(const SkV3& a, const SkV3& b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
|
||||
static SkV3 Cross(const SkV3& a, const SkV3& b) {
|
||||
return { a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x };
|
||||
}
|
||||
static SkV3 Normalize(const SkV3& v) { return v * (1.0f / v.length()); }
|
||||
|
||||
SkV3 operator-() const { return {-x, -y, -z}; }
|
||||
SkV3 operator+(const SkV3& v) const { return { x + v.x, y + v.y, z + v.z }; }
|
||||
SkV3 operator-(const SkV3& v) const { return { x - v.x, y - v.y, z - v.z }; }
|
||||
|
||||
SkV3 operator*(const SkV3& v) const {
|
||||
return { x*v.x, y*v.y, z*v.z };
|
||||
}
|
||||
friend SkV3 operator*(const SkV3& v, SkScalar s) {
|
||||
return { v.x*s, v.y*s, v.z*s };
|
||||
}
|
||||
friend SkV3 operator*(SkScalar s, const SkV3& v) { return v*s; }
|
||||
|
||||
void operator+=(SkV3 v) { *this = *this + v; }
|
||||
void operator-=(SkV3 v) { *this = *this - v; }
|
||||
void operator*=(SkV3 v) { *this = *this * v; }
|
||||
void operator*=(SkScalar s) { *this = *this * s; }
|
||||
|
||||
SkScalar lengthSquared() const { return Dot(*this, *this); }
|
||||
SkScalar length() const { return SkScalarSqrt(Dot(*this, *this)); }
|
||||
|
||||
SkScalar dot(const SkV3& v) const { return Dot(*this, v); }
|
||||
SkV3 cross(const SkV3& v) const { return Cross(*this, v); }
|
||||
SkV3 normalize() const { return Normalize(*this); }
|
||||
|
||||
const float* ptr() const { return &x; }
|
||||
float* ptr() { return &x; }
|
||||
};
|
||||
|
||||
struct SK_API SkV4 {
|
||||
float x, y, z, w;
|
||||
|
||||
bool operator==(const SkV4& v) const {
|
||||
return x == v.x && y == v.y && z == v.z && w == v.w;
|
||||
}
|
||||
bool operator!=(const SkV4& v) const { return !(*this == v); }
|
||||
|
||||
SkV4 operator-() const { return {-x, -y, -z, -w}; }
|
||||
SkV4 operator+(const SkV4& v) const { return { x + v.x, y + v.y, z + v.z, w + v.w }; }
|
||||
SkV4 operator-(const SkV4& v) const { return { x - v.x, y - v.y, z - v.z, w - v.w }; }
|
||||
|
||||
SkV4 operator*(const SkV4& v) const {
|
||||
return { x*v.x, y*v.y, z*v.z, w*v.w };
|
||||
}
|
||||
friend SkV4 operator*(const SkV4& v, SkScalar s) {
|
||||
return { v.x*s, v.y*s, v.z*s, v.w*s };
|
||||
}
|
||||
friend SkV4 operator*(SkScalar s, const SkV4& v) { return v*s; }
|
||||
|
||||
const float* ptr() const { return &x; }
|
||||
float* ptr() { return &x; }
|
||||
|
||||
float operator[](int i) const {
|
||||
SkASSERT(i >= 0 && i < 4);
|
||||
return this->ptr()[i];
|
||||
}
|
||||
float& operator[](int i) {
|
||||
SkASSERT(i >= 0 && i < 4);
|
||||
return this->ptr()[i];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 4x4 matrix used by SkCanvas and other parts of Skia.
|
||||
*
|
||||
* Skia assumes a right-handed coordinate system:
|
||||
* +X goes to the right
|
||||
* +Y goes down
|
||||
* +Z goes into the screen (away from the viewer)
|
||||
*/
|
||||
class SK_API SkM44 {
|
||||
public:
|
||||
SkM44(const SkM44& src) = default;
|
||||
SkM44& operator=(const SkM44& src) = default;
|
||||
|
||||
constexpr SkM44()
|
||||
: fMat{1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1}
|
||||
{}
|
||||
|
||||
SkM44(const SkM44& a, const SkM44& b) {
|
||||
this->setConcat(a, b);
|
||||
}
|
||||
|
||||
enum Uninitialized_Constructor {
|
||||
kUninitialized_Constructor
|
||||
};
|
||||
SkM44(Uninitialized_Constructor) {}
|
||||
|
||||
enum NaN_Constructor {
|
||||
kNaN_Constructor
|
||||
};
|
||||
constexpr SkM44(NaN_Constructor)
|
||||
: fMat{SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN}
|
||||
{}
|
||||
|
||||
/**
|
||||
* The constructor parameters are in row-major order.
|
||||
*/
|
||||
constexpr SkM44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12,
|
||||
SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13,
|
||||
SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14,
|
||||
SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15)
|
||||
// fMat is column-major order in memory.
|
||||
: fMat{m0, m1, m2, m3,
|
||||
m4, m5, m6, m7,
|
||||
m8, m9, m10, m11,
|
||||
m12, m13, m14, m15}
|
||||
{}
|
||||
|
||||
static SkM44 Rows(const SkV4& r0, const SkV4& r1, const SkV4& r2, const SkV4& r3) {
|
||||
SkM44 m(kUninitialized_Constructor);
|
||||
m.setRow(0, r0);
|
||||
m.setRow(1, r1);
|
||||
m.setRow(2, r2);
|
||||
m.setRow(3, r3);
|
||||
return m;
|
||||
}
|
||||
static SkM44 Cols(const SkV4& c0, const SkV4& c1, const SkV4& c2, const SkV4& c3) {
|
||||
SkM44 m(kUninitialized_Constructor);
|
||||
m.setCol(0, c0);
|
||||
m.setCol(1, c1);
|
||||
m.setCol(2, c2);
|
||||
m.setCol(3, c3);
|
||||
return m;
|
||||
}
|
||||
|
||||
static SkM44 RowMajor(const SkScalar r[16]) {
|
||||
return SkM44(r[ 0], r[ 1], r[ 2], r[ 3],
|
||||
r[ 4], r[ 5], r[ 6], r[ 7],
|
||||
r[ 8], r[ 9], r[10], r[11],
|
||||
r[12], r[13], r[14], r[15]);
|
||||
}
|
||||
static SkM44 ColMajor(const SkScalar c[16]) {
|
||||
return SkM44(c[0], c[4], c[ 8], c[12],
|
||||
c[1], c[5], c[ 9], c[13],
|
||||
c[2], c[6], c[10], c[14],
|
||||
c[3], c[7], c[11], c[15]);
|
||||
}
|
||||
|
||||
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z = 0) {
|
||||
return SkM44(1, 0, 0, x,
|
||||
0, 1, 0, y,
|
||||
0, 0, 1, z,
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z = 1) {
|
||||
return SkM44(x, 0, 0, 0,
|
||||
0, y, 0, 0,
|
||||
0, 0, z, 0,
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
static SkM44 Rotate(SkV3 axis, SkScalar radians) {
|
||||
SkM44 m(kUninitialized_Constructor);
|
||||
m.setRotate(axis, radians);
|
||||
return m;
|
||||
}
|
||||
|
||||
// Scales and translates 'src' to fill 'dst' exactly.
|
||||
static SkM44 RectToRect(const SkRect& src, const SkRect& dst);
|
||||
|
||||
static SkM44 LookAt(const SkV3& eye, const SkV3& center, const SkV3& up);
|
||||
static SkM44 Perspective(float near, float far, float angle);
|
||||
|
||||
bool operator==(const SkM44& other) const;
|
||||
bool operator!=(const SkM44& other) const {
|
||||
return !(other == *this);
|
||||
}
|
||||
|
||||
void getColMajor(SkScalar v[]) const {
|
||||
memcpy(v, fMat, sizeof(fMat));
|
||||
}
|
||||
void getRowMajor(SkScalar v[]) const;
|
||||
|
||||
SkScalar rc(int r, int c) const {
|
||||
SkASSERT(r >= 0 && r <= 3);
|
||||
SkASSERT(c >= 0 && c <= 3);
|
||||
return fMat[c*4 + r];
|
||||
}
|
||||
void setRC(int r, int c, SkScalar value) {
|
||||
SkASSERT(r >= 0 && r <= 3);
|
||||
SkASSERT(c >= 0 && c <= 3);
|
||||
fMat[c*4 + r] = value;
|
||||
}
|
||||
|
||||
SkV4 row(int i) const {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
return {fMat[i + 0], fMat[i + 4], fMat[i + 8], fMat[i + 12]};
|
||||
}
|
||||
SkV4 col(int i) const {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
return {fMat[i*4 + 0], fMat[i*4 + 1], fMat[i*4 + 2], fMat[i*4 + 3]};
|
||||
}
|
||||
|
||||
void setRow(int i, const SkV4& v) {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
fMat[i + 0] = v.x;
|
||||
fMat[i + 4] = v.y;
|
||||
fMat[i + 8] = v.z;
|
||||
fMat[i + 12] = v.w;
|
||||
}
|
||||
void setCol(int i, const SkV4& v) {
|
||||
SkASSERT(i >= 0 && i <= 3);
|
||||
memcpy(&fMat[i*4], v.ptr(), sizeof(v));
|
||||
}
|
||||
|
||||
SkM44& setIdentity() {
|
||||
*this = { 1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1 };
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkM44& setTranslate(SkScalar x, SkScalar y, SkScalar z = 0) {
|
||||
*this = { 1, 0, 0, x,
|
||||
0, 1, 0, y,
|
||||
0, 0, 1, z,
|
||||
0, 0, 0, 1 };
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkM44& setScale(SkScalar x, SkScalar y, SkScalar z = 1) {
|
||||
*this = { x, 0, 0, 0,
|
||||
0, y, 0, 0,
|
||||
0, 0, z, 0,
|
||||
0, 0, 0, 1 };
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this matrix to rotate about the specified unit-length axis vector,
|
||||
* by an angle specified by its sin() and cos().
|
||||
*
|
||||
* This does not attempt to verify that axis.length() == 1 or that the sin,cos values
|
||||
* are correct.
|
||||
*/
|
||||
SkM44& setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle);
|
||||
|
||||
/**
|
||||
* Set this matrix to rotate about the specified unit-length axis vector,
|
||||
* by an angle specified in radians.
|
||||
*
|
||||
* This does not attempt to verify that axis.length() == 1.
|
||||
*/
|
||||
SkM44& setRotateUnit(SkV3 axis, SkScalar radians) {
|
||||
return this->setRotateUnitSinCos(axis, SkScalarSin(radians), SkScalarCos(radians));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this matrix to rotate about the specified axis vector,
|
||||
* by an angle specified in radians.
|
||||
*
|
||||
* Note: axis is not assumed to be unit-length, so it will be normalized internally.
|
||||
* If axis is already unit-length, call setRotateAboutUnitRadians() instead.
|
||||
*/
|
||||
SkM44& setRotate(SkV3 axis, SkScalar radians);
|
||||
|
||||
SkM44& setConcat(const SkM44& a, const SkM44& b);
|
||||
|
||||
friend SkM44 operator*(const SkM44& a, const SkM44& b) {
|
||||
return SkM44(a, b);
|
||||
}
|
||||
|
||||
SkM44& preConcat(const SkM44& m) {
|
||||
return this->setConcat(*this, m);
|
||||
}
|
||||
|
||||
SkM44& postConcat(const SkM44& m) {
|
||||
return this->setConcat(m, *this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 0, 1].
|
||||
* For most uses, a bottom row of [0, 0, 0, X] behaves like a non-perspective matrix, though
|
||||
* it will be categorized as perspective. Calling normalizePerspective() will change the
|
||||
* matrix such that, if its bottom row was [0, 0, 0, X], it will be changed to [0, 0, 0, 1]
|
||||
* by scaling the rest of the matrix by 1/X.
|
||||
*
|
||||
* | A B C D | | A/X B/X C/X D/X |
|
||||
* | E F G H | -> | E/X F/X G/X H/X | for X != 0
|
||||
* | I J K L | | I/X J/X K/X L/X |
|
||||
* | 0 0 0 X | | 0 0 0 1 |
|
||||
*/
|
||||
void normalizePerspective();
|
||||
|
||||
/** Returns true if all elements of the matrix are finite. Returns false if any
|
||||
element is infinity, or NaN.
|
||||
|
||||
@return true if matrix has only finite elements
|
||||
*/
|
||||
bool isFinite() const { return SkScalarsAreFinite(fMat, 16); }
|
||||
|
||||
/** If this is invertible, return that in inverse and return true. If it is
|
||||
* not invertible, return false and leave the inverse parameter unchanged.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT invert(SkM44* inverse) const;
|
||||
|
||||
SkM44 SK_WARN_UNUSED_RESULT transpose() const;
|
||||
|
||||
void dump() const;
|
||||
|
||||
////////////
|
||||
|
||||
SkV4 map(float x, float y, float z, float w) const;
|
||||
SkV4 operator*(const SkV4& v) const {
|
||||
return this->map(v.x, v.y, v.z, v.w);
|
||||
}
|
||||
SkV3 operator*(SkV3 v) const {
|
||||
auto v4 = this->map(v.x, v.y, v.z, 0);
|
||||
return {v4.x, v4.y, v4.z};
|
||||
}
|
||||
////////////////////// Converting to/from SkMatrix
|
||||
|
||||
/* When converting from SkM44 to SkMatrix, the third row and
|
||||
* column is dropped. When converting from SkMatrix to SkM44
|
||||
* the third row and column remain as identity:
|
||||
* [ a b c ] [ a b 0 c ]
|
||||
* [ d e f ] -> [ d e 0 f ]
|
||||
* [ g h i ] [ 0 0 1 0 ]
|
||||
* [ g h 0 i ]
|
||||
*/
|
||||
SkMatrix asM33() const {
|
||||
return SkMatrix::MakeAll(fMat[0], fMat[4], fMat[12],
|
||||
fMat[1], fMat[5], fMat[13],
|
||||
fMat[3], fMat[7], fMat[15]);
|
||||
}
|
||||
|
||||
explicit SkM44(const SkMatrix& src)
|
||||
: SkM44(src[SkMatrix::kMScaleX], src[SkMatrix::kMSkewX], 0, src[SkMatrix::kMTransX],
|
||||
src[SkMatrix::kMSkewY], src[SkMatrix::kMScaleY], 0, src[SkMatrix::kMTransY],
|
||||
0, 0, 1, 0,
|
||||
src[SkMatrix::kMPersp0], src[SkMatrix::kMPersp1], 0, src[SkMatrix::kMPersp2])
|
||||
{}
|
||||
|
||||
SkM44& preTranslate(SkScalar x, SkScalar y, SkScalar z = 0);
|
||||
SkM44& postTranslate(SkScalar x, SkScalar y, SkScalar z = 0);
|
||||
|
||||
SkM44& preScale(SkScalar x, SkScalar y);
|
||||
SkM44& preScale(SkScalar x, SkScalar y, SkScalar z);
|
||||
SkM44& preConcat(const SkMatrix&);
|
||||
|
||||
private:
|
||||
/* Stored in column-major.
|
||||
* Indices
|
||||
* 0 4 8 12 1 0 0 trans_x
|
||||
* 1 5 9 13 e.g. 0 1 0 trans_y
|
||||
* 2 6 10 14 0 0 1 trans_z
|
||||
* 3 7 11 15 0 0 0 1
|
||||
*/
|
||||
SkScalar fMat[16];
|
||||
|
||||
friend class SkMatrixPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
42
src/deps/skia/include/core/SkMallocPixelRef.h
Normal file
42
src/deps/skia/include/core/SkMallocPixelRef.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2008 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkMallocPixelRef_DEFINED
|
||||
#define SkMallocPixelRef_DEFINED
|
||||
|
||||
#include "include/core/SkPixelRef.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
class SkData;
|
||||
struct SkImageInfo;
|
||||
|
||||
/** We explicitly use the same allocator for our pixels that SkMask does,
|
||||
so that we can freely assign memory allocated by one class to the other.
|
||||
*/
|
||||
namespace SkMallocPixelRef {
|
||||
/**
|
||||
* Return a new SkMallocPixelRef, automatically allocating storage for the
|
||||
* pixels. If rowBytes are 0, an optimal value will be chosen automatically.
|
||||
* If rowBytes is > 0, then it will be respected, or NULL will be returned
|
||||
* if rowBytes is invalid for the specified info.
|
||||
*
|
||||
* All pixel bytes are zeroed.
|
||||
*
|
||||
* Returns NULL on failure.
|
||||
*/
|
||||
SK_API sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* Return a new SkMallocPixelRef that will use the provided SkData and
|
||||
* rowBytes as pixel storage. The SkData will be ref()ed and on
|
||||
* destruction of the PixelRef, the SkData will be unref()ed.
|
||||
*
|
||||
* Returns NULL on failure.
|
||||
*/
|
||||
SK_API sk_sp<SkPixelRef> MakeWithData(const SkImageInfo&, size_t rowBytes, sk_sp<SkData> data);
|
||||
} // namespace SkMallocPixelRef
|
||||
#endif
|
||||
50
src/deps/skia/include/core/SkMaskFilter.h
Normal file
50
src/deps/skia/include/core/SkMaskFilter.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkMaskFilter_DEFINED
|
||||
#define SkMaskFilter_DEFINED
|
||||
|
||||
#include "include/core/SkBlurTypes.h"
|
||||
#include "include/core/SkCoverageMode.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
class SkMatrix;
|
||||
struct SkRect;
|
||||
|
||||
/** \class SkMaskFilter
|
||||
|
||||
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 {
|
||||
public:
|
||||
/** Create a blur maskfilter.
|
||||
* @param style The SkBlurStyle to use
|
||||
* @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0.
|
||||
* @param respectCTM if true the blur's sigma is modified by the CTM.
|
||||
* @return The new blur maskfilter
|
||||
*/
|
||||
static sk_sp<SkMaskFilter> MakeBlur(SkBlurStyle style, SkScalar sigma,
|
||||
bool respectCTM = true);
|
||||
|
||||
/**
|
||||
* Returns the approximate bounds that would result from filtering the src rect.
|
||||
* The actual result may be different, but it should be contained within the
|
||||
* returned bounds.
|
||||
*/
|
||||
SkRect approximateFilteredBounds(const SkRect& src) const;
|
||||
|
||||
static sk_sp<SkMaskFilter> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
private:
|
||||
static void RegisterFlattenables();
|
||||
friend class SkFlattenable;
|
||||
};
|
||||
|
||||
#endif
|
||||
54
src/deps/skia/include/core/SkMath.h
Normal file
54
src/deps/skia/include/core/SkMath.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkMath_DEFINED
|
||||
#define SkMath_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
// 64bit -> 32bit utilities
|
||||
|
||||
// Handy util that can be passed two ints, and will automatically promote to
|
||||
// 64bits before the multiply, so the caller doesn't have to remember to cast
|
||||
// e.g. (int64_t)a * b;
|
||||
static inline int64_t sk_64_mul(int64_t a, int64_t b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Returns true if value is a power of 2. Does not explicitly check for
|
||||
* value <= 0.
|
||||
*/
|
||||
template <typename T> constexpr inline bool SkIsPow2(T value) {
|
||||
return (value & (value - 1)) == 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Return a*b/((1 << shift) - 1), rounding any fractional bits.
|
||||
* Only valid if a and b are unsigned and <= 32767 and shift is > 0 and <= 8
|
||||
*/
|
||||
static inline unsigned SkMul16ShiftRound(U16CPU a, U16CPU b, int shift) {
|
||||
SkASSERT(a <= 32767);
|
||||
SkASSERT(b <= 32767);
|
||||
SkASSERT(shift > 0 && shift <= 8);
|
||||
unsigned prod = a*b + (1 << (shift - 1));
|
||||
return (prod + (prod >> shift)) >> shift;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a*b/255, rounding any fractional bits.
|
||||
* Only valid if a and b are unsigned and <= 32767.
|
||||
*/
|
||||
static inline U8CPU SkMulDiv255Round(U16CPU a, U16CPU b) {
|
||||
return SkMul16ShiftRound(a,b,8);
|
||||
}
|
||||
|
||||
#endif
|
||||
1986
src/deps/skia/include/core/SkMatrix.h
Normal file
1986
src/deps/skia/include/core/SkMatrix.h
Normal file
File diff suppressed because it is too large
Load Diff
9
src/deps/skia/include/core/SkMilestone.h
Normal file
9
src/deps/skia/include/core/SkMilestone.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#ifndef SK_MILESTONE
|
||||
#define SK_MILESTONE 99
|
||||
#endif
|
||||
68
src/deps/skia/include/core/SkOverdrawCanvas.h
Normal file
68
src/deps/skia/include/core/SkOverdrawCanvas.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkOverdrawCanvas_DEFINED
|
||||
#define SkOverdrawCanvas_DEFINED
|
||||
|
||||
#include "include/core/SkCanvasVirtualEnforcer.h"
|
||||
#include "include/utils/SkNWayCanvas.h"
|
||||
|
||||
/**
|
||||
* Captures all drawing commands. Rather than draw the actual content, this device
|
||||
* increments the alpha channel of each pixel every time it would have been touched
|
||||
* by a draw call. This is useful for detecting overdraw.
|
||||
*/
|
||||
class SK_API SkOverdrawCanvas : public SkCanvasVirtualEnforcer<SkNWayCanvas> {
|
||||
public:
|
||||
/* Does not take ownership of canvas */
|
||||
SkOverdrawCanvas(SkCanvas*);
|
||||
|
||||
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
|
||||
void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
|
||||
void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
|
||||
const SkPaint&) override;
|
||||
void onDrawPaint(const SkPaint&) override;
|
||||
void onDrawBehind(const SkPaint& paint) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawRegion(const SkRegion&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override;
|
||||
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
|
||||
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
|
||||
|
||||
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
|
||||
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
|
||||
|
||||
void onDrawAnnotation(const SkRect&, const char key[], SkData* value) override;
|
||||
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
|
||||
|
||||
void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], SkCanvas::QuadAAFlags, const SkColor4f&,
|
||||
SkBlendMode) override;
|
||||
void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override;
|
||||
|
||||
private:
|
||||
inline SkPaint overdrawPaint(const SkPaint& paint);
|
||||
|
||||
SkPaint fPaint;
|
||||
|
||||
using INHERITED = SkCanvasVirtualEnforcer<SkNWayCanvas>;
|
||||
};
|
||||
|
||||
#endif
|
||||
720
src/deps/skia/include/core/SkPaint.h
Normal file
720
src/deps/skia/include/core/SkPaint.h
Normal file
@@ -0,0 +1,720 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPaint_DEFINED
|
||||
#define SkPaint_DEFINED
|
||||
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/private/SkTOptional.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
class SkBlender;
|
||||
class SkColorFilter;
|
||||
class SkColorSpace;
|
||||
struct SkRect;
|
||||
class SkImageFilter;
|
||||
class SkMaskFilter;
|
||||
class SkMatrix;
|
||||
class SkPath;
|
||||
class SkPathEffect;
|
||||
class SkShader;
|
||||
|
||||
/** \class SkPaint
|
||||
SkPaint controls options applied when drawing. SkPaint collects all
|
||||
options outside of the SkCanvas clip and SkCanvas matrix.
|
||||
|
||||
Various options apply to strokes and fills, and images.
|
||||
|
||||
SkPaint collects effects and filters that describe single-pass and multiple-pass
|
||||
algorithms that alter the drawing geometry, color, and transparency. For instance,
|
||||
SkPaint does not directly implement dashing or blur, but contains the objects that do so.
|
||||
*/
|
||||
class SK_API SkPaint {
|
||||
public:
|
||||
|
||||
/** Constructs SkPaint with default values.
|
||||
|
||||
@return default initialized SkPaint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_empty_constructor
|
||||
*/
|
||||
SkPaint();
|
||||
|
||||
/** Constructs SkPaint with default values and the given color.
|
||||
|
||||
Sets alpha and RGB used when stroking and filling. The color is four floating
|
||||
point values, unpremultiplied. The color values are interpreted as being in
|
||||
the colorSpace. If colorSpace is nullptr, then color is assumed to be in the
|
||||
sRGB color space.
|
||||
|
||||
@param color unpremultiplied RGBA
|
||||
@param colorSpace SkColorSpace describing the encoding of color
|
||||
@return SkPaint with the given color
|
||||
*/
|
||||
explicit SkPaint(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
|
||||
|
||||
/** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
|
||||
SkMaskFilter, SkColorFilter, and SkImageFilter are shared
|
||||
between the original paint and the copy. Objects containing SkRefCnt increment
|
||||
their references by one.
|
||||
|
||||
The referenced objects SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
||||
and SkImageFilter cannot be modified after they are created.
|
||||
This prevents objects with SkRefCnt from being modified once SkPaint refers to them.
|
||||
|
||||
@param paint original to copy
|
||||
@return shallow copy of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_copy_const_SkPaint
|
||||
*/
|
||||
SkPaint(const SkPaint& paint);
|
||||
|
||||
/** Implements a move constructor to avoid increasing the reference counts
|
||||
of objects referenced by the paint.
|
||||
|
||||
After the call, paint is undefined, and can be safely destructed.
|
||||
|
||||
@param paint original to move
|
||||
@return content of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_move_SkPaint
|
||||
*/
|
||||
SkPaint(SkPaint&& paint);
|
||||
|
||||
/** Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader,
|
||||
SkMaskFilter, SkColorFilter, and SkImageFilter. If the
|
||||
objects containing SkRefCnt go to zero, they are deleted.
|
||||
*/
|
||||
~SkPaint();
|
||||
|
||||
/** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
|
||||
SkMaskFilter, SkColorFilter, and SkImageFilter are shared
|
||||
between the original paint and the copy. Objects containing SkRefCnt in the
|
||||
prior destination are decreased by one, and the referenced objects are deleted if the
|
||||
resulting count is zero. Objects containing SkRefCnt in the parameter paint
|
||||
are increased by one. paint is unmodified.
|
||||
|
||||
@param paint original to copy
|
||||
@return content of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_copy_operator
|
||||
*/
|
||||
SkPaint& operator=(const SkPaint& paint);
|
||||
|
||||
/** Moves the paint to avoid increasing the reference counts
|
||||
of objects referenced by the paint parameter. Objects containing SkRefCnt in the
|
||||
prior destination are decreased by one; those objects are deleted if the resulting count
|
||||
is zero.
|
||||
|
||||
After the call, paint is undefined, and can be safely destructed.
|
||||
|
||||
@param paint original to move
|
||||
@return content of paint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_move_operator
|
||||
*/
|
||||
SkPaint& operator=(SkPaint&& paint);
|
||||
|
||||
/** Compares a and b, and returns true if a and b are equivalent. May return false
|
||||
if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
||||
or SkImageFilter have identical contents but different pointers.
|
||||
|
||||
@param a SkPaint to compare
|
||||
@param b SkPaint to compare
|
||||
@return true if SkPaint pair are equivalent
|
||||
*/
|
||||
SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
|
||||
|
||||
/** Compares a and b, and returns true if a and b are not equivalent. May return true
|
||||
if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
||||
or SkImageFilter have identical contents but different pointers.
|
||||
|
||||
@param a SkPaint to compare
|
||||
@param b SkPaint to compare
|
||||
@return true if SkPaint pair are not equivalent
|
||||
*/
|
||||
friend bool operator!=(const SkPaint& a, const SkPaint& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/** Sets all SkPaint contents to their initial values. This is equivalent to replacing
|
||||
SkPaint with the result of SkPaint().
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_reset
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/** Returns true if pixels on the active edges of SkPath may be drawn with partial transparency.
|
||||
@return antialiasing state
|
||||
*/
|
||||
bool isAntiAlias() const {
|
||||
return SkToBool(fBitfields.fAntiAlias);
|
||||
}
|
||||
|
||||
/** Requests, but does not require, that edge pixels draw opaque or with
|
||||
partial transparency.
|
||||
@param aa setting for antialiasing
|
||||
*/
|
||||
void setAntiAlias(bool aa) { fBitfields.fAntiAlias = static_cast<unsigned>(aa); }
|
||||
|
||||
/** Returns true if color error may be distributed to smooth color transition.
|
||||
@return dithering state
|
||||
*/
|
||||
bool isDither() const {
|
||||
return SkToBool(fBitfields.fDither);
|
||||
}
|
||||
|
||||
/** Requests, but does not require, to distribute color error.
|
||||
@param dither setting for ditering
|
||||
*/
|
||||
void setDither(bool dither) { fBitfields.fDither = static_cast<unsigned>(dither); }
|
||||
|
||||
/** \enum SkPaint::Style
|
||||
Set Style to fill, stroke, or both fill and stroke geometry.
|
||||
The stroke and fill
|
||||
share all paint attributes; for instance, they are drawn with the same color.
|
||||
|
||||
Use kStrokeAndFill_Style to avoid hitting the same pixels twice with a stroke draw and
|
||||
a fill draw.
|
||||
*/
|
||||
enum Style : uint8_t {
|
||||
kFill_Style, //!< set to fill geometry
|
||||
kStroke_Style, //!< set to stroke geometry
|
||||
kStrokeAndFill_Style, //!< sets to stroke and fill geometry
|
||||
};
|
||||
|
||||
/** May be used to verify that SkPaint::Style is a legal value.
|
||||
*/
|
||||
static constexpr int kStyleCount = kStrokeAndFill_Style + 1;
|
||||
|
||||
/** Returns whether the geometry is filled, stroked, or filled and stroked.
|
||||
*/
|
||||
Style getStyle() const { return (Style)fBitfields.fStyle; }
|
||||
|
||||
/** Sets whether the geometry is filled, stroked, or filled and stroked.
|
||||
Has no effect if style is not a legal SkPaint::Style value.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStyle
|
||||
example: https://fiddle.skia.org/c/@Stroke_Width
|
||||
*/
|
||||
void setStyle(Style style);
|
||||
|
||||
/**
|
||||
* Set paint's style to kStroke if true, or kFill if false.
|
||||
*/
|
||||
void setStroke(bool);
|
||||
|
||||
/** Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
|
||||
Use helpers SkColorGetA(), SkColorGetR(), SkColorGetG(), and SkColorGetB() to extract
|
||||
a color component.
|
||||
|
||||
@return unpremultiplied ARGB
|
||||
*/
|
||||
SkColor getColor() const { return fColor4f.toSkColor(); }
|
||||
|
||||
/** Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are
|
||||
extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
|
||||
|
||||
@return unpremultiplied RGBA
|
||||
*/
|
||||
SkColor4f getColor4f() const { return fColor4f; }
|
||||
|
||||
/** Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
|
||||
unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
|
||||
|
||||
@param color unpremultiplied ARGB
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setColor
|
||||
*/
|
||||
void setColor(SkColor color);
|
||||
|
||||
/** Sets alpha and RGB used when stroking and filling. The color is four floating
|
||||
point values, unpremultiplied. The color values are interpreted as being in
|
||||
the colorSpace. If colorSpace is nullptr, then color is assumed to be in the
|
||||
sRGB color space.
|
||||
|
||||
@param color unpremultiplied RGBA
|
||||
@param colorSpace SkColorSpace describing the encoding of color
|
||||
*/
|
||||
void setColor(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
|
||||
|
||||
void setColor4f(const SkColor4f& color, SkColorSpace* colorSpace = nullptr) {
|
||||
this->setColor(color, colorSpace);
|
||||
}
|
||||
|
||||
/** Retrieves alpha from the color used when stroking and filling.
|
||||
|
||||
@return alpha ranging from zero, fully transparent, to 255, fully opaque
|
||||
*/
|
||||
float getAlphaf() const { return fColor4f.fA; }
|
||||
|
||||
// Helper that scales the alpha by 255.
|
||||
uint8_t getAlpha() const { return sk_float_round2int(this->getAlphaf() * 255); }
|
||||
|
||||
/** Replaces alpha, leaving RGB
|
||||
unchanged. An out of range value triggers an assert in the debug
|
||||
build. a is a value from 0.0 to 1.0.
|
||||
a set to zero makes color fully transparent; a set to 1.0 makes color
|
||||
fully opaque.
|
||||
|
||||
@param a alpha component of color
|
||||
*/
|
||||
void setAlphaf(float a);
|
||||
|
||||
// Helper that accepts an int between 0 and 255, and divides it by 255.0
|
||||
void setAlpha(U8CPU a) {
|
||||
this->setAlphaf(a * (1.0f / 255));
|
||||
}
|
||||
|
||||
/** Sets color used when drawing solid fills. The color components range from 0 to 255.
|
||||
The color is unpremultiplied; alpha sets the transparency independent of RGB.
|
||||
|
||||
@param a amount of alpha, from fully transparent (0) to fully opaque (255)
|
||||
@param r amount of red, from no red (0) to full red (255)
|
||||
@param g amount of green, from no green (0) to full green (255)
|
||||
@param b amount of blue, from no blue (0) to full blue (255)
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setARGB
|
||||
*/
|
||||
void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
|
||||
|
||||
/** Returns the thickness of the pen used by SkPaint to
|
||||
outline the shape.
|
||||
|
||||
@return zero for hairline, greater than zero for pen thickness
|
||||
*/
|
||||
SkScalar getStrokeWidth() const { return fWidth; }
|
||||
|
||||
/** Sets the thickness of the pen used by the paint to outline the shape.
|
||||
A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one
|
||||
pixel wide in device space (their thickness does not change as the canvas is scaled).
|
||||
Negative stroke-widths are invalid; setting a negative width will have no effect.
|
||||
|
||||
@param width zero thickness for hairline; greater than zero for pen thickness
|
||||
|
||||
example: https://fiddle.skia.org/c/@Miter_Limit
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeWidth
|
||||
*/
|
||||
void setStrokeWidth(SkScalar width);
|
||||
|
||||
/** Returns the limit at which a sharp corner is drawn beveled.
|
||||
|
||||
@return zero and greater miter limit
|
||||
*/
|
||||
SkScalar getStrokeMiter() const { return fMiterLimit; }
|
||||
|
||||
/** Sets the limit at which a sharp corner is drawn beveled.
|
||||
Valid values are zero and greater.
|
||||
Has no effect if miter is less than zero.
|
||||
|
||||
@param miter zero and greater miter limit
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeMiter
|
||||
*/
|
||||
void setStrokeMiter(SkScalar miter);
|
||||
|
||||
/** \enum SkPaint::Cap
|
||||
Cap draws at the beginning and end of an open path contour.
|
||||
*/
|
||||
enum Cap {
|
||||
kButt_Cap, //!< no stroke extension
|
||||
kRound_Cap, //!< adds circle
|
||||
kSquare_Cap, //!< adds square
|
||||
kLast_Cap = kSquare_Cap, //!< largest Cap value
|
||||
kDefault_Cap = kButt_Cap, //!< equivalent to kButt_Cap
|
||||
};
|
||||
|
||||
/** May be used to verify that SkPaint::Cap is a legal value.
|
||||
*/
|
||||
static constexpr int kCapCount = kLast_Cap + 1;
|
||||
|
||||
/** \enum SkPaint::Join
|
||||
Join specifies how corners are drawn when a shape is stroked. Join
|
||||
affects the four corners of a stroked rectangle, and the connected segments in a
|
||||
stroked path.
|
||||
|
||||
Choose miter join to draw sharp corners. Choose round join to draw a circle with a
|
||||
radius equal to the stroke width on top of the corner. Choose bevel join to minimally
|
||||
connect the thick strokes.
|
||||
|
||||
The fill path constructed to describe the stroked path respects the join setting but may
|
||||
not contain the actual join. For instance, a fill path constructed with round joins does
|
||||
not necessarily include circles at each connected segment.
|
||||
*/
|
||||
enum Join : uint8_t {
|
||||
kMiter_Join, //!< extends to miter limit
|
||||
kRound_Join, //!< adds circle
|
||||
kBevel_Join, //!< connects outside edges
|
||||
kLast_Join = kBevel_Join, //!< equivalent to the largest value for Join
|
||||
kDefault_Join = kMiter_Join, //!< equivalent to kMiter_Join
|
||||
};
|
||||
|
||||
/** May be used to verify that SkPaint::Join is a legal value.
|
||||
*/
|
||||
static constexpr int kJoinCount = kLast_Join + 1;
|
||||
|
||||
/** Returns the geometry drawn at the beginning and end of strokes.
|
||||
*/
|
||||
Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
|
||||
|
||||
/** Sets the geometry drawn at the beginning and end of strokes.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeCap_a
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeCap_b
|
||||
*/
|
||||
void setStrokeCap(Cap cap);
|
||||
|
||||
/** Returns the geometry drawn at the corners of strokes.
|
||||
*/
|
||||
Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
|
||||
|
||||
/** Sets the geometry drawn at the corners of strokes.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setStrokeJoin
|
||||
*/
|
||||
void setStrokeJoin(Join join);
|
||||
|
||||
/** Returns the filled equivalent of the stroked path.
|
||||
|
||||
@param src SkPath read to create a filled version
|
||||
@param dst resulting SkPath; may be the same as src, but may not be nullptr
|
||||
@param cullRect optional limit passed to SkPathEffect
|
||||
@param resScale if > 1, increase precision, else if (0 < resScale < 1) reduce precision
|
||||
to favor speed and size
|
||||
@return true if the path represents style fill, or false if it represents hairline
|
||||
*/
|
||||
bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
|
||||
SkScalar resScale = 1) const;
|
||||
|
||||
bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
|
||||
const SkMatrix& ctm) const;
|
||||
|
||||
/** Returns the filled equivalent of the stroked path.
|
||||
|
||||
Replaces dst with the src path modified by SkPathEffect and style stroke.
|
||||
SkPathEffect, if any, is not culled. stroke width is created with default precision.
|
||||
|
||||
@param src SkPath read to create a filled version
|
||||
@param dst resulting SkPath dst may be the same as src, but may not be nullptr
|
||||
@return true if the path represents style fill, or false if it represents hairline
|
||||
*/
|
||||
bool getFillPath(const SkPath& src, SkPath* dst) const {
|
||||
return this->getFillPath(src, dst, nullptr, 1);
|
||||
}
|
||||
|
||||
/** Returns optional colors used when filling a path, such as a gradient.
|
||||
|
||||
Does not alter SkShader SkRefCnt.
|
||||
|
||||
@return SkShader if previously set, nullptr otherwise
|
||||
*/
|
||||
SkShader* getShader() const { return fShader.get(); }
|
||||
|
||||
/** Returns optional colors used when filling a path, such as a gradient.
|
||||
|
||||
Increases SkShader SkRefCnt by one.
|
||||
|
||||
@return SkShader if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refShader
|
||||
*/
|
||||
sk_sp<SkShader> refShader() const;
|
||||
|
||||
/** Sets optional colors used when filling a path, such as a gradient.
|
||||
|
||||
Sets SkShader to shader, decreasing SkRefCnt of the previous SkShader.
|
||||
Increments shader SkRefCnt by one.
|
||||
|
||||
@param shader how geometry is filled with color; if nullptr, color is used instead
|
||||
|
||||
example: https://fiddle.skia.org/c/@Color_Filter_Methods
|
||||
example: https://fiddle.skia.org/c/@Paint_setShader
|
||||
*/
|
||||
void setShader(sk_sp<SkShader> shader);
|
||||
|
||||
/** Returns SkColorFilter if set, or nullptr.
|
||||
Does not alter SkColorFilter SkRefCnt.
|
||||
|
||||
@return SkColorFilter if previously set, nullptr otherwise
|
||||
*/
|
||||
SkColorFilter* getColorFilter() const { return fColorFilter.get(); }
|
||||
|
||||
/** Returns SkColorFilter if set, or nullptr.
|
||||
Increases SkColorFilter SkRefCnt by one.
|
||||
|
||||
@return SkColorFilter if set, or nullptr
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refColorFilter
|
||||
*/
|
||||
sk_sp<SkColorFilter> refColorFilter() const;
|
||||
|
||||
/** Sets SkColorFilter to filter, decreasing SkRefCnt of the previous
|
||||
SkColorFilter. Pass nullptr to clear SkColorFilter.
|
||||
|
||||
Increments filter SkRefCnt by one.
|
||||
|
||||
@param colorFilter SkColorFilter to apply to subsequent draw
|
||||
|
||||
example: https://fiddle.skia.org/c/@Blend_Mode_Methods
|
||||
example: https://fiddle.skia.org/c/@Paint_setColorFilter
|
||||
*/
|
||||
void setColorFilter(sk_sp<SkColorFilter> colorFilter);
|
||||
|
||||
/** If the current blender can be represented as a SkBlendMode enum, this returns that
|
||||
* enum in the optional's value(). If it cannot, then the returned optional does not
|
||||
* contain a value.
|
||||
*/
|
||||
skstd::optional<SkBlendMode> asBlendMode() const;
|
||||
|
||||
/**
|
||||
* Queries the blender, and if it can be represented as a SkBlendMode, return that mode,
|
||||
* else return the defaultMode provided.
|
||||
*/
|
||||
SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const;
|
||||
|
||||
/** Returns true iff the current blender claims to be equivalent to SkBlendMode::kSrcOver.
|
||||
*
|
||||
* Also returns true of the current blender is nullptr.
|
||||
*/
|
||||
bool isSrcOver() const;
|
||||
|
||||
/** Helper method for calling setBlender().
|
||||
*
|
||||
* This sets a blender that implements the specified blendmode enum.
|
||||
*/
|
||||
void setBlendMode(SkBlendMode mode);
|
||||
|
||||
/** Returns the user-supplied blend function, if one has been set.
|
||||
* Does not alter SkBlender's SkRefCnt.
|
||||
*
|
||||
* A nullptr blender signifies the default SrcOver behavior.
|
||||
*
|
||||
* @return the SkBlender assigned to this paint, otherwise nullptr
|
||||
*/
|
||||
SkBlender* getBlender() const { return fBlender.get(); }
|
||||
|
||||
/** Returns the user-supplied blend function, if one has been set.
|
||||
* Increments the SkBlender's SkRefCnt by one.
|
||||
*
|
||||
* A nullptr blender signifies the default SrcOver behavior.
|
||||
*
|
||||
* @return the SkBlender assigned to this paint, otherwise nullptr
|
||||
*/
|
||||
sk_sp<SkBlender> refBlender() const;
|
||||
|
||||
/** Sets the current blender, increasing its refcnt, and if a blender is already
|
||||
* present, decreasing that object's refcnt.
|
||||
*
|
||||
* A nullptr blender signifies the default SrcOver behavior.
|
||||
*
|
||||
* For convenience, you can call setBlendMode() if the blend effect can be expressed
|
||||
* as one of those values.
|
||||
*/
|
||||
void setBlender(sk_sp<SkBlender> blender);
|
||||
|
||||
/** Returns SkPathEffect if set, or nullptr.
|
||||
Does not alter SkPathEffect SkRefCnt.
|
||||
|
||||
@return SkPathEffect if previously set, nullptr otherwise
|
||||
*/
|
||||
SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
|
||||
|
||||
/** Returns SkPathEffect if set, or nullptr.
|
||||
Increases SkPathEffect SkRefCnt by one.
|
||||
|
||||
@return SkPathEffect if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refPathEffect
|
||||
*/
|
||||
sk_sp<SkPathEffect> refPathEffect() const;
|
||||
|
||||
/** Sets SkPathEffect to pathEffect, decreasing SkRefCnt of the previous
|
||||
SkPathEffect. Pass nullptr to leave the path geometry unaltered.
|
||||
|
||||
Increments pathEffect SkRefCnt by one.
|
||||
|
||||
@param pathEffect replace SkPath with a modification when drawn
|
||||
|
||||
example: https://fiddle.skia.org/c/@Mask_Filter_Methods
|
||||
example: https://fiddle.skia.org/c/@Paint_setPathEffect
|
||||
*/
|
||||
void setPathEffect(sk_sp<SkPathEffect> pathEffect);
|
||||
|
||||
/** Returns SkMaskFilter if set, or nullptr.
|
||||
Does not alter SkMaskFilter SkRefCnt.
|
||||
|
||||
@return SkMaskFilter if previously set, nullptr otherwise
|
||||
*/
|
||||
SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); }
|
||||
|
||||
/** Returns SkMaskFilter if set, or nullptr.
|
||||
|
||||
Increases SkMaskFilter SkRefCnt by one.
|
||||
|
||||
@return SkMaskFilter if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refMaskFilter
|
||||
*/
|
||||
sk_sp<SkMaskFilter> refMaskFilter() const;
|
||||
|
||||
/** Sets SkMaskFilter to maskFilter, decreasing SkRefCnt of the previous
|
||||
SkMaskFilter. Pass nullptr to clear SkMaskFilter and leave SkMaskFilter effect on
|
||||
mask alpha unaltered.
|
||||
|
||||
Increments maskFilter SkRefCnt by one.
|
||||
|
||||
@param maskFilter modifies clipping mask generated from drawn geometry
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setMaskFilter
|
||||
example: https://fiddle.skia.org/c/@Typeface_Methods
|
||||
*/
|
||||
void setMaskFilter(sk_sp<SkMaskFilter> maskFilter);
|
||||
|
||||
/** Returns SkImageFilter if set, or nullptr.
|
||||
Does not alter SkImageFilter SkRefCnt.
|
||||
|
||||
@return SkImageFilter if previously set, nullptr otherwise
|
||||
*/
|
||||
SkImageFilter* getImageFilter() const { return fImageFilter.get(); }
|
||||
|
||||
/** Returns SkImageFilter if set, or nullptr.
|
||||
Increases SkImageFilter SkRefCnt by one.
|
||||
|
||||
@return SkImageFilter if previously set, nullptr otherwise
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_refImageFilter
|
||||
*/
|
||||
sk_sp<SkImageFilter> refImageFilter() const;
|
||||
|
||||
/** Sets SkImageFilter to imageFilter, decreasing SkRefCnt of the previous
|
||||
SkImageFilter. Pass nullptr to clear SkImageFilter, and remove SkImageFilter effect
|
||||
on drawing.
|
||||
|
||||
Increments imageFilter SkRefCnt by one.
|
||||
|
||||
@param imageFilter how SkImage is sampled when transformed
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_setImageFilter
|
||||
*/
|
||||
void setImageFilter(sk_sp<SkImageFilter> imageFilter);
|
||||
|
||||
/** Returns true if SkPaint prevents all drawing;
|
||||
otherwise, the SkPaint may or may not allow drawing.
|
||||
|
||||
Returns true if, for example, SkBlendMode combined with alpha computes a
|
||||
new alpha of zero.
|
||||
|
||||
@return true if SkPaint prevents all drawing
|
||||
|
||||
example: https://fiddle.skia.org/c/@Paint_nothingToDraw
|
||||
*/
|
||||
bool nothingToDraw() const;
|
||||
|
||||
/** (to be made private)
|
||||
Returns true if SkPaint does not include elements requiring extensive computation
|
||||
to compute SkBaseDevice bounds of drawn geometry. For instance, SkPaint with SkPathEffect
|
||||
always returns false.
|
||||
|
||||
@return true if SkPaint allows for fast computation of bounds
|
||||
*/
|
||||
bool canComputeFastBounds() const;
|
||||
|
||||
/** (to be made private)
|
||||
Only call this if canComputeFastBounds() returned true. This takes a
|
||||
raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
|
||||
effects in the paint (e.g. stroking). If needed, it uses the storage
|
||||
parameter. It returns the adjusted bounds that can then be used
|
||||
for SkCanvas::quickReject tests.
|
||||
|
||||
The returned SkRect will either be orig or storage, thus the caller
|
||||
should not rely on storage being set to the result, but should always
|
||||
use the returned value. It is legal for orig and storage to be the same
|
||||
SkRect.
|
||||
For example:
|
||||
if (!path.isInverseFillType() && paint.canComputeFastBounds()) {
|
||||
SkRect storage;
|
||||
if (canvas->quickReject(paint.computeFastBounds(path.getBounds(), &storage))) {
|
||||
return; // do not draw the path
|
||||
}
|
||||
}
|
||||
// draw the path
|
||||
|
||||
@param orig geometry modified by SkPaint when drawn
|
||||
@param storage computed bounds of geometry; may not be nullptr
|
||||
@return fast computed bounds
|
||||
*/
|
||||
const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
|
||||
// Things like stroking, etc... will do math on the bounds rect, assuming that it's sorted.
|
||||
SkASSERT(orig.isSorted());
|
||||
SkPaint::Style style = this->getStyle();
|
||||
// ultra fast-case: filling with no effects that affect geometry
|
||||
if (kFill_Style == style) {
|
||||
uintptr_t effects = 0;
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
|
||||
if (!effects) {
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
|
||||
return this->doComputeFastBounds(orig, storage, style);
|
||||
}
|
||||
|
||||
/** (to be made private)
|
||||
|
||||
@param orig geometry modified by SkPaint when drawn
|
||||
@param storage computed bounds of geometry
|
||||
@return fast computed bounds
|
||||
*/
|
||||
const SkRect& computeFastStrokeBounds(const SkRect& orig,
|
||||
SkRect* storage) const {
|
||||
return this->doComputeFastBounds(orig, storage, kStroke_Style);
|
||||
}
|
||||
|
||||
/** (to be made private)
|
||||
Computes the bounds, overriding the SkPaint SkPaint::Style. This can be used to
|
||||
account for additional width required by stroking orig, without
|
||||
altering SkPaint::Style set to fill.
|
||||
|
||||
@param orig geometry modified by SkPaint when drawn
|
||||
@param storage computed bounds of geometry
|
||||
@param style overrides SkPaint::Style
|
||||
@return fast computed bounds
|
||||
*/
|
||||
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
|
||||
Style style) const;
|
||||
|
||||
private:
|
||||
sk_sp<SkPathEffect> fPathEffect;
|
||||
sk_sp<SkShader> fShader;
|
||||
sk_sp<SkMaskFilter> fMaskFilter;
|
||||
sk_sp<SkColorFilter> fColorFilter;
|
||||
sk_sp<SkImageFilter> fImageFilter;
|
||||
sk_sp<SkBlender> fBlender;
|
||||
|
||||
SkColor4f fColor4f;
|
||||
SkScalar fWidth;
|
||||
SkScalar fMiterLimit;
|
||||
union {
|
||||
struct {
|
||||
unsigned fAntiAlias : 1;
|
||||
unsigned fDither : 1;
|
||||
unsigned fCapType : 2;
|
||||
unsigned fJoinType : 2;
|
||||
unsigned fStyle : 2;
|
||||
unsigned fPadding : 24; // 24 == 32 -1-1-2-2-2
|
||||
} fBitfields;
|
||||
uint32_t fBitfieldsUInt;
|
||||
};
|
||||
|
||||
friend class SkPaintPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
1891
src/deps/skia/include/core/SkPath.h
Normal file
1891
src/deps/skia/include/core/SkPath.h
Normal file
File diff suppressed because it is too large
Load Diff
268
src/deps/skia/include/core/SkPathBuilder.h
Normal file
268
src/deps/skia/include/core/SkPathBuilder.h
Normal file
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPathBuilder_DEFINED
|
||||
#define SkPathBuilder_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkPathTypes.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
class SK_API SkPathBuilder {
|
||||
public:
|
||||
SkPathBuilder();
|
||||
SkPathBuilder(SkPathFillType);
|
||||
SkPathBuilder(const SkPath&);
|
||||
SkPathBuilder(const SkPathBuilder&) = default;
|
||||
~SkPathBuilder();
|
||||
|
||||
SkPathBuilder& operator=(const SkPath&);
|
||||
SkPathBuilder& operator=(const SkPathBuilder&) = default;
|
||||
|
||||
SkPathFillType fillType() const { return fFillType; }
|
||||
SkRect computeBounds() const;
|
||||
|
||||
SkPath snapshot() const; // the builder is unchanged after returning this path
|
||||
SkPath detach(); // the builder is reset to empty after returning this path
|
||||
|
||||
SkPathBuilder& setFillType(SkPathFillType ft) { fFillType = ft; return *this; }
|
||||
SkPathBuilder& setIsVolatile(bool isVolatile) { fIsVolatile = isVolatile; return *this; }
|
||||
|
||||
SkPathBuilder& reset();
|
||||
|
||||
SkPathBuilder& moveTo(SkPoint pt);
|
||||
SkPathBuilder& moveTo(SkScalar x, SkScalar y) { return this->moveTo(SkPoint::Make(x, y)); }
|
||||
|
||||
SkPathBuilder& lineTo(SkPoint pt);
|
||||
SkPathBuilder& lineTo(SkScalar x, SkScalar y) { return this->lineTo(SkPoint::Make(x, y)); }
|
||||
|
||||
SkPathBuilder& quadTo(SkPoint pt1, SkPoint pt2);
|
||||
SkPathBuilder& quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
|
||||
return this->quadTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2));
|
||||
}
|
||||
SkPathBuilder& quadTo(const SkPoint pts[2]) { return this->quadTo(pts[0], pts[1]); }
|
||||
|
||||
SkPathBuilder& conicTo(SkPoint pt1, SkPoint pt2, SkScalar w);
|
||||
SkPathBuilder& conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
|
||||
return this->conicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), w);
|
||||
}
|
||||
SkPathBuilder& conicTo(const SkPoint pts[2], SkScalar w) {
|
||||
return this->conicTo(pts[0], pts[1], w);
|
||||
}
|
||||
|
||||
SkPathBuilder& cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
|
||||
SkPathBuilder& cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
|
||||
return this->cubicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), SkPoint::Make(x3, y3));
|
||||
}
|
||||
SkPathBuilder& cubicTo(const SkPoint pts[3]) {
|
||||
return this->cubicTo(pts[0], pts[1], pts[2]);
|
||||
}
|
||||
|
||||
SkPathBuilder& close();
|
||||
|
||||
// Append a series of lineTo(...)
|
||||
SkPathBuilder& polylineTo(const SkPoint pts[], int count);
|
||||
SkPathBuilder& polylineTo(const std::initializer_list<SkPoint>& list) {
|
||||
return this->polylineTo(list.begin(), SkToInt(list.size()));
|
||||
}
|
||||
|
||||
// Relative versions of segments, relative to the previous position.
|
||||
|
||||
SkPathBuilder& rLineTo(SkPoint pt);
|
||||
SkPathBuilder& rLineTo(SkScalar x, SkScalar y) { return this->rLineTo({x, y}); }
|
||||
SkPathBuilder& rQuadTo(SkPoint pt1, SkPoint pt2);
|
||||
SkPathBuilder& rQuadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
|
||||
return this->rQuadTo({x1, y1}, {x2, y2});
|
||||
}
|
||||
SkPathBuilder& rConicTo(SkPoint p1, SkPoint p2, SkScalar w);
|
||||
SkPathBuilder& rConicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
|
||||
return this->rConicTo({x1, y1}, {x2, y2}, w);
|
||||
}
|
||||
SkPathBuilder& rCubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
|
||||
SkPathBuilder& rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
|
||||
return this->rCubicTo({x1, y1}, {x2, y2}, {x3, y3});
|
||||
}
|
||||
|
||||
// Arcs
|
||||
|
||||
/** Appends arc to the builder. Arc added is part of ellipse
|
||||
bounded by oval, from startAngle through sweepAngle. Both startAngle and
|
||||
sweepAngle are measured in degrees, where zero degrees is aligned with the
|
||||
positive x-axis, and positive sweeps extends arc clockwise.
|
||||
|
||||
arcTo() adds line connecting the builder's last point to initial arc point if forceMoveTo
|
||||
is false and the builder is not empty. Otherwise, added contour begins with first point
|
||||
of arc. Angles greater than -360 and less than 360 are treated modulo 360.
|
||||
|
||||
@param oval bounds of ellipse containing arc
|
||||
@param startAngleDeg starting angle of arc in degrees
|
||||
@param sweepAngleDeg sweep, in degrees. Positive is clockwise; treated modulo 360
|
||||
@param forceMoveTo true to start a new contour with arc
|
||||
@return reference to the builder
|
||||
*/
|
||||
SkPathBuilder& arcTo(const SkRect& oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg,
|
||||
bool forceMoveTo);
|
||||
|
||||
/** Appends arc to SkPath, after appending line if needed. Arc is implemented by conic
|
||||
weighted to describe part of circle. Arc is contained by tangent from
|
||||
last SkPath point to p1, and tangent from p1 to p2. Arc
|
||||
is part of circle sized to radius, positioned so it touches both tangent lines.
|
||||
|
||||
If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath.
|
||||
The length of vector from p1 to p2 does not affect arc.
|
||||
|
||||
Arc sweep is always less than 180 degrees. If radius is zero, or if
|
||||
tangents are nearly parallel, arcTo() appends line from last SkPath SkPoint to p1.
|
||||
|
||||
arcTo() appends at most one line and one conic.
|
||||
arcTo() implements the functionality of PostScript arct and HTML Canvas arcTo.
|
||||
|
||||
@param p1 SkPoint common to pair of tangents
|
||||
@param p2 end of second tangent
|
||||
@param radius distance from arc to circle center
|
||||
@return reference to SkPath
|
||||
*/
|
||||
SkPathBuilder& arcTo(SkPoint p1, SkPoint p2, SkScalar radius);
|
||||
|
||||
enum ArcSize {
|
||||
kSmall_ArcSize, //!< smaller of arc pair
|
||||
kLarge_ArcSize, //!< larger of arc pair
|
||||
};
|
||||
|
||||
/** Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe
|
||||
part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves
|
||||
from last SkPath SkPoint to (xy.fX, xy.fY), choosing one of four possible routes:
|
||||
clockwise or counterclockwise,
|
||||
and smaller or larger.
|
||||
|
||||
Arc sweep is always less than 360 degrees. arcTo() appends line to xy if either
|
||||
radii are zero, or if last SkPath SkPoint equals (xy.fX, xy.fY). arcTo() scales radii r to
|
||||
fit last SkPath SkPoint and xy if both are greater than zero but too small to describe
|
||||
an arc.
|
||||
|
||||
arcTo() appends up to four conic curves.
|
||||
arcTo() implements the functionality of SVG arc, although SVG sweep-flag value is
|
||||
opposite the integer value of sweep; SVG sweep-flag uses 1 for clockwise, while
|
||||
kCW_Direction cast to int is zero.
|
||||
|
||||
@param r radii on axes before x-axis rotation
|
||||
@param xAxisRotate x-axis rotation in degrees; positive values are clockwise
|
||||
@param largeArc chooses smaller or larger arc
|
||||
@param sweep chooses clockwise or counterclockwise arc
|
||||
@param xy end of arc
|
||||
@return reference to SkPath
|
||||
*/
|
||||
SkPathBuilder& arcTo(SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep,
|
||||
SkPoint xy);
|
||||
|
||||
/** Appends arc to the builder, as the start of new contour. Arc added is part of ellipse
|
||||
bounded by oval, from startAngle through sweepAngle. Both startAngle and
|
||||
sweepAngle are measured in degrees, where zero degrees is aligned with the
|
||||
positive x-axis, and positive sweeps extends arc clockwise.
|
||||
|
||||
If sweepAngle <= -360, or sweepAngle >= 360; and startAngle modulo 90 is nearly
|
||||
zero, append oval instead of arc. Otherwise, sweepAngle values are treated
|
||||
modulo 360, and arc may or may not draw depending on numeric rounding.
|
||||
|
||||
@param oval bounds of ellipse containing arc
|
||||
@param startAngleDeg starting angle of arc in degrees
|
||||
@param sweepAngleDeg sweep, in degrees. Positive is clockwise; treated modulo 360
|
||||
@return reference to this builder
|
||||
*/
|
||||
SkPathBuilder& addArc(const SkRect& oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg);
|
||||
|
||||
// Add a new contour
|
||||
|
||||
SkPathBuilder& addRect(const SkRect&, SkPathDirection, unsigned startIndex);
|
||||
SkPathBuilder& addOval(const SkRect&, SkPathDirection, unsigned startIndex);
|
||||
SkPathBuilder& addRRect(const SkRRect&, SkPathDirection, unsigned startIndex);
|
||||
|
||||
SkPathBuilder& addRect(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
|
||||
return this->addRect(rect, dir, 0);
|
||||
}
|
||||
SkPathBuilder& addOval(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
|
||||
// legacy start index: 1
|
||||
return this->addOval(rect, dir, 1);
|
||||
}
|
||||
SkPathBuilder& addRRect(const SkRRect& rrect, SkPathDirection dir = SkPathDirection::kCW) {
|
||||
// legacy start indices: 6 (CW) and 7 (CCW)
|
||||
return this->addRRect(rrect, dir, dir == SkPathDirection::kCW ? 6 : 7);
|
||||
}
|
||||
|
||||
SkPathBuilder& addCircle(SkScalar center_x, SkScalar center_y, SkScalar radius,
|
||||
SkPathDirection dir = SkPathDirection::kCW);
|
||||
|
||||
SkPathBuilder& addPolygon(const SkPoint pts[], int count, bool isClosed);
|
||||
SkPathBuilder& addPolygon(const std::initializer_list<SkPoint>& list, bool isClosed) {
|
||||
return this->addPolygon(list.begin(), SkToInt(list.size()), isClosed);
|
||||
}
|
||||
|
||||
SkPathBuilder& addPath(const SkPath&);
|
||||
|
||||
// Performance hint, to reserve extra storage for subsequent calls to lineTo, quadTo, etc.
|
||||
|
||||
void incReserve(int extraPtCount, int extraVerbCount);
|
||||
void incReserve(int extraPtCount) {
|
||||
this->incReserve(extraPtCount, extraPtCount);
|
||||
}
|
||||
|
||||
SkPathBuilder& offset(SkScalar dx, SkScalar dy);
|
||||
|
||||
SkPathBuilder& toggleInverseFillType() {
|
||||
fFillType = (SkPathFillType)((unsigned)fFillType ^ 2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
SkTDArray<SkPoint> fPts;
|
||||
SkTDArray<uint8_t> fVerbs;
|
||||
SkTDArray<SkScalar> fConicWeights;
|
||||
|
||||
SkPathFillType fFillType;
|
||||
bool fIsVolatile;
|
||||
|
||||
unsigned fSegmentMask;
|
||||
SkPoint fLastMovePoint;
|
||||
int fLastMoveIndex; // only needed until SkPath is immutable
|
||||
bool fNeedsMoveVerb;
|
||||
|
||||
enum IsA {
|
||||
kIsA_JustMoves, // we only have 0 or more moves
|
||||
kIsA_MoreThanMoves, // we have verbs other than just move
|
||||
kIsA_Oval, // we are 0 or more moves followed by an oval
|
||||
kIsA_RRect, // we are 0 or more moves followed by a rrect
|
||||
};
|
||||
IsA fIsA = kIsA_JustMoves;
|
||||
int fIsAStart = -1; // tracks direction iff fIsA is not unknown
|
||||
bool fIsACCW = false; // tracks direction iff fIsA is not unknown
|
||||
|
||||
// for testing
|
||||
SkPathConvexity fOverrideConvexity = SkPathConvexity::kUnknown;
|
||||
|
||||
int countVerbs() const { return fVerbs.count(); }
|
||||
|
||||
// called right before we add a (non-move) verb
|
||||
void ensureMove() {
|
||||
fIsA = kIsA_MoreThanMoves;
|
||||
if (fNeedsMoveVerb) {
|
||||
this->moveTo(fLastMovePoint);
|
||||
}
|
||||
}
|
||||
|
||||
SkPath make(sk_sp<SkPathRef>) const;
|
||||
|
||||
SkPathBuilder& privateReverseAddPath(const SkPath&);
|
||||
|
||||
// For testing
|
||||
void privateSetConvexity(SkPathConvexity c) { fOverrideConvexity = c; }
|
||||
|
||||
friend class SkPathPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
106
src/deps/skia/include/core/SkPathEffect.h
Normal file
106
src/deps/skia/include/core/SkPathEffect.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPathEffect_DEFINED
|
||||
#define SkPathEffect_DEFINED
|
||||
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
// not needed, but some of our clients need it (they don't IWYU)
|
||||
#include "include/core/SkPath.h"
|
||||
|
||||
class SkPath;
|
||||
struct SkRect;
|
||||
class SkStrokeRec;
|
||||
|
||||
/** \class SkPathEffect
|
||||
|
||||
SkPathEffect is the base class for objects in the SkPaint that affect
|
||||
the geometry of a drawing primitive before it is transformed by the
|
||||
canvas' matrix and drawn.
|
||||
|
||||
Dashing is implemented as a subclass of SkPathEffect.
|
||||
*/
|
||||
class SK_API SkPathEffect : public SkFlattenable {
|
||||
public:
|
||||
/**
|
||||
* Returns a patheffect that apples each effect (first and second) to the original path,
|
||||
* and returns a path with the sum of these.
|
||||
*
|
||||
* result = first(path) + second(path)
|
||||
*
|
||||
*/
|
||||
static sk_sp<SkPathEffect> MakeSum(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second);
|
||||
|
||||
/**
|
||||
* Returns a patheffect that applies the inner effect to the path, and then applies the
|
||||
* outer effect to the result of the inner's.
|
||||
*
|
||||
* result = outer(inner(path))
|
||||
*/
|
||||
static sk_sp<SkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner);
|
||||
|
||||
static SkFlattenable::Type GetFlattenableType() {
|
||||
return kSkPathEffect_Type;
|
||||
}
|
||||
|
||||
// move to base?
|
||||
|
||||
enum DashType {
|
||||
kNone_DashType, //!< ignores the info parameter
|
||||
kDash_DashType, //!< fills in all of the info parameter
|
||||
};
|
||||
|
||||
struct DashInfo {
|
||||
DashInfo() : fIntervals(nullptr), fCount(0), fPhase(0) {}
|
||||
DashInfo(SkScalar* intervals, int32_t count, SkScalar phase)
|
||||
: fIntervals(intervals), fCount(count), fPhase(phase) {}
|
||||
|
||||
SkScalar* fIntervals; //!< Length of on/off intervals for dashed lines
|
||||
// Even values represent ons, and odds offs
|
||||
int32_t fCount; //!< Number of intervals in the dash. Should be even number
|
||||
SkScalar fPhase; //!< Offset into the dashed interval pattern
|
||||
// mod the sum of all intervals
|
||||
};
|
||||
|
||||
DashType asADash(DashInfo* info) const;
|
||||
|
||||
/**
|
||||
* Given a src path (input) and a stroke-rec (input and output), apply
|
||||
* this effect to the src path, returning the new path in dst, and return
|
||||
* true. If this effect cannot be applied, return false and ignore dst
|
||||
* and stroke-rec.
|
||||
*
|
||||
* The stroke-rec specifies the initial request for stroking (if any).
|
||||
* The effect can treat this as input only, or it can choose to change
|
||||
* the rec as well. For example, the effect can decide to change the
|
||||
* stroke's width or join, or the effect can change the rec from stroke
|
||||
* to fill (or fill to stroke) in addition to returning a new (dst) path.
|
||||
*
|
||||
* If this method returns true, the caller will apply (as needed) the
|
||||
* resulting stroke-rec to dst and then draw.
|
||||
*/
|
||||
bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR) const;
|
||||
|
||||
/** Version of filterPath that can be called when the CTM is known. */
|
||||
bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR,
|
||||
const SkMatrix& ctm) const;
|
||||
|
||||
/** True if this path effect requires a valid CTM */
|
||||
bool needsCTM() const;
|
||||
|
||||
static sk_sp<SkPathEffect> Deserialize(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
private:
|
||||
SkPathEffect() = default;
|
||||
friend class SkPathEffectBase;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
#endif
|
||||
88
src/deps/skia/include/core/SkPathMeasure.h
Normal file
88
src/deps/skia/include/core/SkPathMeasure.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPathMeasure_DEFINED
|
||||
#define SkPathMeasure_DEFINED
|
||||
|
||||
#include "include/core/SkContourMeasure.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
class SK_API SkPathMeasure {
|
||||
public:
|
||||
SkPathMeasure();
|
||||
/** Initialize the pathmeasure with the specified path. The parts of the path that are needed
|
||||
* are copied, so the client is free to modify/delete the path after this call.
|
||||
*
|
||||
* resScale controls the precision of the measure. values > 1 increase the
|
||||
* precision (and possibly slow down the computation).
|
||||
*/
|
||||
SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
|
||||
~SkPathMeasure();
|
||||
|
||||
/** Reset the pathmeasure with the specified path. The parts of the path that are needed
|
||||
* are copied, so the client is free to modify/delete the path after this call..
|
||||
*/
|
||||
void setPath(const SkPath*, bool forceClosed);
|
||||
|
||||
/** Return the total length of the current contour, or 0 if no path
|
||||
is associated (e.g. resetPath(null))
|
||||
*/
|
||||
SkScalar getLength();
|
||||
|
||||
/** Pins distance to 0 <= distance <= getLength(), and then computes
|
||||
the corresponding position and tangent.
|
||||
Returns false if there is no path, or a zero-length path was specified, in which case
|
||||
position and tangent are unchanged.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT getPosTan(SkScalar distance, SkPoint* position,
|
||||
SkVector* tangent);
|
||||
|
||||
enum MatrixFlags {
|
||||
kGetPosition_MatrixFlag = 0x01,
|
||||
kGetTangent_MatrixFlag = 0x02,
|
||||
kGetPosAndTan_MatrixFlag = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
|
||||
};
|
||||
|
||||
/** Pins distance to 0 <= distance <= getLength(), and then computes
|
||||
the corresponding matrix (by calling getPosTan).
|
||||
Returns false if there is no path, or a zero-length path was specified, in which case
|
||||
matrix is unchanged.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT getMatrix(SkScalar distance, SkMatrix* matrix,
|
||||
MatrixFlags flags = kGetPosAndTan_MatrixFlag);
|
||||
|
||||
/** Given a start and stop distance, return in dst the intervening segment(s).
|
||||
If the segment is zero-length, return false, else return true.
|
||||
startD and stopD are pinned to legal values (0..getLength()). If startD > stopD
|
||||
then return false (and leave dst untouched).
|
||||
Begin the segment with a moveTo if startWithMoveTo is true
|
||||
*/
|
||||
bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo);
|
||||
|
||||
/** Return true if the current contour is closed()
|
||||
*/
|
||||
bool isClosed();
|
||||
|
||||
/** Move to the next contour in the path. Return true if one exists, or false if
|
||||
we're done with the path.
|
||||
*/
|
||||
bool nextContour();
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void dump();
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkContourMeasureIter fIter;
|
||||
sk_sp<SkContourMeasure> fContour;
|
||||
|
||||
SkPathMeasure(const SkPathMeasure&) = delete;
|
||||
SkPathMeasure& operator=(const SkPathMeasure&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
59
src/deps/skia/include/core/SkPathTypes.h
Normal file
59
src/deps/skia/include/core/SkPathTypes.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2019 Google LLC.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPathTypes_DEFINED
|
||||
#define SkPathTypes_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
enum class SkPathFillType {
|
||||
/** Specifies that "inside" is computed by a non-zero sum of signed edge crossings */
|
||||
kWinding,
|
||||
/** Specifies that "inside" is computed by an odd number of edge crossings */
|
||||
kEvenOdd,
|
||||
/** Same as Winding, but draws outside of the path, rather than inside */
|
||||
kInverseWinding,
|
||||
/** Same as EvenOdd, but draws outside of the path, rather than inside */
|
||||
kInverseEvenOdd
|
||||
};
|
||||
|
||||
static inline bool SkPathFillType_IsEvenOdd(SkPathFillType ft) {
|
||||
return (static_cast<int>(ft) & 1) != 0;
|
||||
}
|
||||
|
||||
static inline bool SkPathFillType_IsInverse(SkPathFillType ft) {
|
||||
return (static_cast<int>(ft) & 2) != 0;
|
||||
}
|
||||
|
||||
static inline SkPathFillType SkPathFillType_ConvertToNonInverse(SkPathFillType ft) {
|
||||
return static_cast<SkPathFillType>(static_cast<int>(ft) & 1);
|
||||
}
|
||||
|
||||
enum class SkPathDirection {
|
||||
/** clockwise direction for adding closed contours */
|
||||
kCW,
|
||||
/** counter-clockwise direction for adding closed contours */
|
||||
kCCW,
|
||||
};
|
||||
|
||||
enum SkPathSegmentMask {
|
||||
kLine_SkPathSegmentMask = 1 << 0,
|
||||
kQuad_SkPathSegmentMask = 1 << 1,
|
||||
kConic_SkPathSegmentMask = 1 << 2,
|
||||
kCubic_SkPathSegmentMask = 1 << 3,
|
||||
};
|
||||
|
||||
enum class SkPathVerb {
|
||||
kMove, //!< SkPath::RawIter returns 1 point
|
||||
kLine, //!< SkPath::RawIter returns 2 points
|
||||
kQuad, //!< SkPath::RawIter returns 3 points
|
||||
kConic, //!< SkPath::RawIter returns 3 points + 1 weight
|
||||
kCubic, //!< SkPath::RawIter returns 4 points
|
||||
kClose //!< SkPath::RawIter returns 0 points
|
||||
};
|
||||
|
||||
#endif
|
||||
280
src/deps/skia/include/core/SkPicture.h
Normal file
280
src/deps/skia/include/core/SkPicture.h
Normal file
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* Copyright 2007 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPicture_DEFINED
|
||||
#define SkPicture_DEFINED
|
||||
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSamplingOptions.h"
|
||||
#include "include/core/SkShader.h"
|
||||
#include "include/core/SkTileMode.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
class SkCanvas;
|
||||
class SkData;
|
||||
struct SkDeserialProcs;
|
||||
class SkImage;
|
||||
class SkMatrix;
|
||||
struct SkSerialProcs;
|
||||
class SkStream;
|
||||
class SkWStream;
|
||||
|
||||
/** \class SkPicture
|
||||
SkPicture records drawing commands made to SkCanvas. The command stream may be
|
||||
played in whole or in part at a later time.
|
||||
|
||||
SkPicture is an abstract class. SkPicture may be generated by SkPictureRecorder
|
||||
or SkDrawable, or from SkPicture previously saved to SkData or SkStream.
|
||||
|
||||
SkPicture may contain any SkCanvas drawing command, as well as one or more
|
||||
SkCanvas matrix or SkCanvas clip. SkPicture has a cull SkRect, which is used as
|
||||
a bounding box hint. To limit SkPicture bounds, use SkCanvas clip when
|
||||
recording or drawing SkPicture.
|
||||
*/
|
||||
class SK_API SkPicture : public SkRefCnt {
|
||||
public:
|
||||
~SkPicture() override;
|
||||
|
||||
/** Recreates SkPicture that was serialized into a stream. Returns constructed SkPicture
|
||||
if successful; otherwise, returns nullptr. Fails if data does not permit
|
||||
constructing valid SkPicture.
|
||||
|
||||
procs->fPictureProc permits supplying a custom function to decode SkPicture.
|
||||
If procs->fPictureProc is nullptr, default decoding is used. procs->fPictureCtx
|
||||
may be used to provide user context to procs->fPictureProc; procs->fPictureProc
|
||||
is called with a pointer to data, data byte length, and user context.
|
||||
|
||||
@param stream container for serial data
|
||||
@param procs custom serial data decoders; may be nullptr
|
||||
@return SkPicture constructed from stream data
|
||||
*/
|
||||
static sk_sp<SkPicture> MakeFromStream(SkStream* stream,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
/** Recreates SkPicture that was serialized into data. Returns constructed SkPicture
|
||||
if successful; otherwise, returns nullptr. Fails if data does not permit
|
||||
constructing valid SkPicture.
|
||||
|
||||
procs->fPictureProc permits supplying a custom function to decode SkPicture.
|
||||
If procs->fPictureProc is nullptr, default decoding is used. procs->fPictureCtx
|
||||
may be used to provide user context to procs->fPictureProc; procs->fPictureProc
|
||||
is called with a pointer to data, data byte length, and user context.
|
||||
|
||||
@param data container for serial data
|
||||
@param procs custom serial data decoders; may be nullptr
|
||||
@return SkPicture constructed from data
|
||||
*/
|
||||
static sk_sp<SkPicture> MakeFromData(const SkData* data,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
/**
|
||||
|
||||
@param data pointer to serial data
|
||||
@param size size of data
|
||||
@param procs custom serial data decoders; may be nullptr
|
||||
@return SkPicture constructed from data
|
||||
*/
|
||||
static sk_sp<SkPicture> MakeFromData(const void* data, size_t size,
|
||||
const SkDeserialProcs* procs = nullptr);
|
||||
|
||||
/** \class SkPicture::AbortCallback
|
||||
AbortCallback is an abstract class. An implementation of AbortCallback may
|
||||
passed as a parameter to SkPicture::playback, to stop it before all drawing
|
||||
commands have been processed.
|
||||
|
||||
If AbortCallback::abort returns true, SkPicture::playback is interrupted.
|
||||
*/
|
||||
class SK_API AbortCallback {
|
||||
public:
|
||||
/** Has no effect.
|
||||
*/
|
||||
virtual ~AbortCallback() = default;
|
||||
|
||||
/** Stops SkPicture playback when some condition is met. A subclass of
|
||||
AbortCallback provides an override for abort() that can stop SkPicture::playback.
|
||||
|
||||
The part of SkPicture drawn when aborted is undefined. SkPicture instantiations are
|
||||
free to stop drawing at different points during playback.
|
||||
|
||||
If the abort happens inside one or more calls to SkCanvas::save(), stack
|
||||
of SkCanvas matrix and SkCanvas clip values is restored to its state before
|
||||
SkPicture::playback was called.
|
||||
|
||||
@return true to stop playback
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_AbortCallback_abort
|
||||
*/
|
||||
virtual bool abort() = 0;
|
||||
|
||||
protected:
|
||||
AbortCallback() = default;
|
||||
AbortCallback(const AbortCallback&) = delete;
|
||||
AbortCallback& operator=(const AbortCallback&) = delete;
|
||||
};
|
||||
|
||||
/** Replays the drawing commands on the specified canvas. In the case that the
|
||||
commands are recorded, each command in the SkPicture is sent separately to canvas.
|
||||
|
||||
To add a single command to draw SkPicture to recording canvas, call
|
||||
SkCanvas::drawPicture instead.
|
||||
|
||||
@param canvas receiver of drawing commands
|
||||
@param callback allows interruption of playback
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_playback
|
||||
*/
|
||||
virtual void playback(SkCanvas* canvas, AbortCallback* callback = nullptr) const = 0;
|
||||
|
||||
/** Returns cull SkRect for this picture, passed in when SkPicture was created.
|
||||
Returned SkRect does not specify clipping SkRect for SkPicture; cull is hint
|
||||
of SkPicture bounds.
|
||||
|
||||
SkPicture is free to discard recorded drawing commands that fall outside
|
||||
cull.
|
||||
|
||||
@return bounds passed when SkPicture was created
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_cullRect
|
||||
*/
|
||||
virtual SkRect cullRect() const = 0;
|
||||
|
||||
/** Returns a non-zero value unique among SkPicture in Skia process.
|
||||
|
||||
@return identifier for SkPicture
|
||||
*/
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
/** Returns storage containing SkData describing SkPicture, using optional custom
|
||||
encoders.
|
||||
|
||||
procs->fPictureProc permits supplying a custom function to encode SkPicture.
|
||||
If procs->fPictureProc is nullptr, default encoding is used. procs->fPictureCtx
|
||||
may be used to provide user context to procs->fPictureProc; procs->fPictureProc
|
||||
is called with a pointer to SkPicture and user context.
|
||||
|
||||
@param procs custom serial data encoders; may be nullptr
|
||||
@return storage containing serialized SkPicture
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_serialize
|
||||
*/
|
||||
sk_sp<SkData> serialize(const SkSerialProcs* procs = nullptr) const;
|
||||
|
||||
/** Writes picture to stream, using optional custom encoders.
|
||||
|
||||
procs->fPictureProc permits supplying a custom function to encode SkPicture.
|
||||
If procs->fPictureProc is nullptr, default encoding is used. procs->fPictureCtx
|
||||
may be used to provide user context to procs->fPictureProc; procs->fPictureProc
|
||||
is called with a pointer to SkPicture and user context.
|
||||
|
||||
@param stream writable serial data stream
|
||||
@param procs custom serial data encoders; may be nullptr
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_serialize_2
|
||||
*/
|
||||
void serialize(SkWStream* stream, const SkSerialProcs* procs = nullptr) const;
|
||||
|
||||
/** Returns a placeholder SkPicture. Result does not draw, and contains only
|
||||
cull SkRect, a hint of its bounds. Result is immutable; it cannot be changed
|
||||
later. Result identifier is unique.
|
||||
|
||||
Returned placeholder can be intercepted during playback to insert other
|
||||
commands into SkCanvas draw stream.
|
||||
|
||||
@param cull placeholder dimensions
|
||||
@return placeholder with unique identifier
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_MakePlaceholder
|
||||
*/
|
||||
static sk_sp<SkPicture> MakePlaceholder(SkRect cull);
|
||||
|
||||
/** Returns the approximate number of operations in SkPicture. Returned value
|
||||
may be greater or less than the number of SkCanvas calls
|
||||
recorded: some calls may be recorded as more than one operation, other
|
||||
calls may be optimized away.
|
||||
|
||||
@param nested if true, include the op-counts of nested pictures as well, else
|
||||
just return count the ops in the top-level picture.
|
||||
@return approximate operation count
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_approximateOpCount
|
||||
*/
|
||||
virtual int approximateOpCount(bool nested = false) const = 0;
|
||||
|
||||
/** Returns the approximate byte size of SkPicture. Does not include large objects
|
||||
referenced by SkPicture.
|
||||
|
||||
@return approximate size
|
||||
|
||||
example: https://fiddle.skia.org/c/@Picture_approximateBytesUsed
|
||||
*/
|
||||
virtual size_t approximateBytesUsed() const = 0;
|
||||
|
||||
/** Return a new shader that will draw with this picture.
|
||||
*
|
||||
* @param tmx The tiling mode to use when sampling in the x-direction.
|
||||
* @param tmy The tiling mode to use when sampling in the y-direction.
|
||||
* @param mode How to filter the tiles
|
||||
* @param localMatrix Optional matrix used when sampling
|
||||
* @param tile The tile rectangle in picture coordinates: this represents the subset
|
||||
* (or superset) of the picture used when building a tile. It is not
|
||||
* affected by localMatrix and does not imply scaling (only translation
|
||||
* and cropping). If null, the tile rect is considered equal to the picture
|
||||
* bounds.
|
||||
* @return Returns a new shader object. Note: this function never returns null.
|
||||
*/
|
||||
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode,
|
||||
const SkMatrix* localMatrix, const SkRect* tileRect) const;
|
||||
|
||||
sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode) const {
|
||||
return this->makeShader(tmx, tmy, mode, nullptr, nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
// Allowed subclasses.
|
||||
SkPicture();
|
||||
friend class SkBigPicture;
|
||||
friend class SkEmptyPicture;
|
||||
friend class SkPicturePriv;
|
||||
template <typename> friend class SkMiniPicture;
|
||||
|
||||
void serialize(SkWStream*, const SkSerialProcs*, class SkRefCntSet* typefaces,
|
||||
bool textBlobsOnly=false) const;
|
||||
static sk_sp<SkPicture> MakeFromStream(SkStream*, const SkDeserialProcs*,
|
||||
class SkTypefacePlayback*);
|
||||
friend class SkPictureData;
|
||||
|
||||
/** Return true if the SkStream/Buffer represents a serialized picture, and
|
||||
fills out SkPictInfo. After this function returns, the data source is not
|
||||
rewound so it will have to be manually reset before passing to
|
||||
MakeFromStream or MakeFromBuffer. Note, MakeFromStream and
|
||||
MakeFromBuffer perform this check internally so these entry points are
|
||||
intended for stand alone tools.
|
||||
If false is returned, SkPictInfo is unmodified.
|
||||
*/
|
||||
static bool StreamIsSKP(SkStream*, struct SkPictInfo*);
|
||||
static bool BufferIsSKP(class SkReadBuffer*, struct SkPictInfo*);
|
||||
friend bool SkPicture_StreamIsSKP(SkStream*, struct SkPictInfo*);
|
||||
|
||||
// Returns NULL if this is not an SkBigPicture.
|
||||
virtual const class SkBigPicture* asSkBigPicture() const { return nullptr; }
|
||||
|
||||
friend struct SkPathCounter;
|
||||
|
||||
static bool IsValidPictInfo(const struct SkPictInfo& info);
|
||||
static sk_sp<SkPicture> Forwardport(const struct SkPictInfo&,
|
||||
const class SkPictureData*,
|
||||
class SkReadBuffer* buffer);
|
||||
|
||||
struct SkPictInfo createHeader() const;
|
||||
class SkPictureData* backport() const;
|
||||
|
||||
uint32_t fUniqueID;
|
||||
mutable std::atomic<bool> fAddedToCache{false};
|
||||
};
|
||||
|
||||
#endif
|
||||
115
src/deps/skia/include/core/SkPictureRecorder.h
Normal file
115
src/deps/skia/include/core/SkPictureRecorder.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPictureRecorder_DEFINED
|
||||
#define SkPictureRecorder_DEFINED
|
||||
|
||||
#include "include/core/SkBBHFactory.h"
|
||||
#include "include/core/SkPicture.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
namespace android {
|
||||
class Picture;
|
||||
};
|
||||
#endif
|
||||
|
||||
class SkCanvas;
|
||||
class SkDrawable;
|
||||
class SkMiniRecorder;
|
||||
class SkPictureRecord;
|
||||
class SkRecord;
|
||||
class SkRecorder;
|
||||
|
||||
class SK_API SkPictureRecorder {
|
||||
public:
|
||||
SkPictureRecorder();
|
||||
~SkPictureRecorder();
|
||||
|
||||
enum FinishFlags {
|
||||
};
|
||||
|
||||
/** Returns the canvas that records the drawing commands.
|
||||
@param bounds the cull rect used when recording this picture. Any drawing the falls outside
|
||||
of this rect is undefined, and may be drawn or it may not.
|
||||
@param bbh optional acceleration structure
|
||||
@param recordFlags optional flags that control recording.
|
||||
@return the canvas.
|
||||
*/
|
||||
SkCanvas* beginRecording(const SkRect& bounds, sk_sp<SkBBoxHierarchy> bbh);
|
||||
|
||||
SkCanvas* beginRecording(const SkRect& bounds, SkBBHFactory* bbhFactory = nullptr);
|
||||
|
||||
SkCanvas* beginRecording(SkScalar width, SkScalar height,
|
||||
SkBBHFactory* bbhFactory = nullptr) {
|
||||
return this->beginRecording(SkRect::MakeWH(width, height), bbhFactory);
|
||||
}
|
||||
|
||||
/** Returns the recording canvas if one is active, or NULL if recording is
|
||||
not active. This does not alter the refcnt on the canvas (if present).
|
||||
*/
|
||||
SkCanvas* getRecordingCanvas();
|
||||
|
||||
/**
|
||||
* Signal that the caller is done recording. This invalidates the canvas returned by
|
||||
* beginRecording/getRecordingCanvas. Ownership of the object is passed to the caller, who
|
||||
* must call unref() when they are done using it.
|
||||
*
|
||||
* The returned picture is immutable. If during recording drawables were added to the canvas,
|
||||
* these will have been "drawn" into a recording canvas, so that this resulting picture will
|
||||
* reflect their current state, but will not contain a live reference to the drawables
|
||||
* themselves.
|
||||
*/
|
||||
sk_sp<SkPicture> finishRecordingAsPicture();
|
||||
|
||||
/**
|
||||
* Signal that the caller is done recording, and update the cull rect to use for bounding
|
||||
* box hierarchy (BBH) generation. The behavior is the same as calling
|
||||
* finishRecordingAsPicture(), except that this method updates the cull rect initially passed
|
||||
* into beginRecording.
|
||||
* @param cullRect the new culling rectangle to use as the overall bound for BBH generation
|
||||
* and subsequent culling operations.
|
||||
* @return the picture containing the recorded content.
|
||||
*/
|
||||
sk_sp<SkPicture> finishRecordingAsPictureWithCull(const SkRect& cullRect);
|
||||
|
||||
/**
|
||||
* Signal that the caller is done recording. This invalidates the canvas returned by
|
||||
* beginRecording/getRecordingCanvas. Ownership of the object is passed to the caller, who
|
||||
* must call unref() when they are done using it.
|
||||
*
|
||||
* Unlike finishRecordingAsPicture(), which returns an immutable picture, the returned drawable
|
||||
* may contain live references to other drawables (if they were added to the recording canvas)
|
||||
* and therefore this drawable will reflect the current state of those nested drawables anytime
|
||||
* it is drawn or a new picture is snapped from it (by calling drawable->newPictureSnapshot()).
|
||||
*/
|
||||
sk_sp<SkDrawable> finishRecordingAsDrawable();
|
||||
|
||||
private:
|
||||
void reset();
|
||||
|
||||
/** Replay the current (partially recorded) operation stream into
|
||||
canvas. This call doesn't close the current recording.
|
||||
*/
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
friend class android::Picture;
|
||||
#endif
|
||||
friend class SkPictureRecorderReplayTester; // for unit testing
|
||||
void partialReplay(SkCanvas* canvas) const;
|
||||
|
||||
bool fActivelyRecording;
|
||||
SkRect fCullRect;
|
||||
sk_sp<SkBBoxHierarchy> fBBH;
|
||||
std::unique_ptr<SkRecorder> fRecorder;
|
||||
sk_sp<SkRecord> fRecord;
|
||||
std::unique_ptr<SkMiniRecorder> fMiniRecorder;
|
||||
|
||||
SkPictureRecorder(SkPictureRecorder&&) = delete;
|
||||
SkPictureRecorder& operator=(SkPictureRecorder&&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
123
src/deps/skia/include/core/SkPixelRef.h
Normal file
123
src/deps/skia/include/core/SkPixelRef.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2008 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPixelRef_DEFINED
|
||||
#define SkPixelRef_DEFINED
|
||||
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/private/SkIDChangeListener.h"
|
||||
#include "include/private/SkMutex.h"
|
||||
#include "include/private/SkTDArray.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
struct SkIRect;
|
||||
|
||||
class GrTexture;
|
||||
class SkDiscardableMemory;
|
||||
|
||||
/** \class SkPixelRef
|
||||
|
||||
This class is the smart container for pixel memory, and is used with SkBitmap.
|
||||
This class can be shared/accessed between multiple threads.
|
||||
*/
|
||||
class SK_API SkPixelRef : public SkRefCnt {
|
||||
public:
|
||||
SkPixelRef(int width, int height, void* addr, size_t rowBytes);
|
||||
~SkPixelRef() override;
|
||||
|
||||
SkISize dimensions() const { return {fWidth, fHeight}; }
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
void* pixels() const { return fPixels; }
|
||||
size_t rowBytes() const { return fRowBytes; }
|
||||
|
||||
/** Returns a non-zero, unique value corresponding to the pixels in this
|
||||
pixelref. Each time the pixels are changed (and notifyPixelsChanged is
|
||||
called), a different generation ID will be returned.
|
||||
*/
|
||||
uint32_t getGenerationID() const;
|
||||
|
||||
/**
|
||||
* Call this if you have changed the contents of the pixels. This will in-
|
||||
* turn cause a different generation ID value to be returned from
|
||||
* getGenerationID().
|
||||
*/
|
||||
void notifyPixelsChanged();
|
||||
|
||||
/** Returns true if this pixelref is marked as immutable, meaning that the
|
||||
contents of its pixels will not change for the lifetime of the pixelref.
|
||||
*/
|
||||
bool isImmutable() const { return fMutability != kMutable; }
|
||||
|
||||
/** Marks this pixelref is immutable, meaning that the contents of its
|
||||
pixels will not change for the lifetime of the pixelref. This state can
|
||||
be set on a pixelref, but it cannot be cleared once it is set.
|
||||
*/
|
||||
void setImmutable();
|
||||
|
||||
// Register a listener that may be called the next time our generation ID changes.
|
||||
//
|
||||
// We'll only call the listener if we're confident that we are the only SkPixelRef with this
|
||||
// generation ID. If our generation ID changes and we decide not to call the listener, we'll
|
||||
// never call it: you must add a new listener for each generation ID change. We also won't call
|
||||
// the listener when we're certain no one knows what our generation ID is.
|
||||
//
|
||||
// This can be used to invalidate caches keyed by SkPixelRef generation ID.
|
||||
// Takes ownership of listener. Threadsafe.
|
||||
void addGenIDChangeListener(sk_sp<SkIDChangeListener> listener);
|
||||
|
||||
// Call when this pixelref is part of the key to a resourcecache entry. This allows the cache
|
||||
// to know automatically those entries can be purged when this pixelref is changed or deleted.
|
||||
void notifyAddedToCache() {
|
||||
fAddedToCache.store(true);
|
||||
}
|
||||
|
||||
virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return nullptr; }
|
||||
|
||||
protected:
|
||||
void android_only_reset(int width, int height, size_t rowBytes);
|
||||
|
||||
private:
|
||||
int fWidth;
|
||||
int fHeight;
|
||||
void* fPixels;
|
||||
size_t fRowBytes;
|
||||
|
||||
// Bottom bit indicates the Gen ID is unique.
|
||||
bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); }
|
||||
mutable std::atomic<uint32_t> fTaggedGenID;
|
||||
|
||||
SkIDChangeListener::List fGenIDChangeListeners;
|
||||
|
||||
// Set true by caches when they cache content that's derived from the current pixels.
|
||||
std::atomic<bool> fAddedToCache;
|
||||
|
||||
enum Mutability {
|
||||
kMutable, // PixelRefs begin mutable.
|
||||
kTemporarilyImmutable, // Considered immutable, but can revert to mutable.
|
||||
kImmutable, // Once set to this state, it never leaves.
|
||||
} fMutability : 8; // easily fits inside a byte
|
||||
|
||||
void needsNewGenID();
|
||||
void callGenIDChangeListeners();
|
||||
|
||||
void setTemporarilyImmutable();
|
||||
void restoreMutability();
|
||||
friend class SkSurface_Raster; // For the two methods above.
|
||||
|
||||
void setImmutableWithID(uint32_t genID);
|
||||
friend void SkBitmapCache_setImmutableWithID(SkPixelRef*, uint32_t);
|
||||
|
||||
using INHERITED = SkRefCnt;
|
||||
};
|
||||
|
||||
#endif
|
||||
720
src/deps/skia/include/core/SkPixmap.h
Normal file
720
src/deps/skia/include/core/SkPixmap.h
Normal file
@@ -0,0 +1,720 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPixmap_DEFINED
|
||||
#define SkPixmap_DEFINED
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkSamplingOptions.h"
|
||||
|
||||
class SkData;
|
||||
struct SkMask;
|
||||
|
||||
/** \class SkPixmap
|
||||
SkPixmap provides a utility to pair SkImageInfo with pixels and row bytes.
|
||||
SkPixmap is a low level class which provides convenience functions to access
|
||||
raster destinations. SkCanvas can not draw SkPixmap, nor does SkPixmap provide
|
||||
a direct drawing destination.
|
||||
|
||||
Use SkBitmap to draw pixels referenced by SkPixmap; use SkSurface to draw into
|
||||
pixels referenced by SkPixmap.
|
||||
|
||||
SkPixmap does not try to manage the lifetime of the pixel memory. Use SkPixelRef
|
||||
to manage pixel memory; SkPixelRef is safe across threads.
|
||||
*/
|
||||
class SK_API SkPixmap {
|
||||
public:
|
||||
|
||||
/** Creates an empty SkPixmap without pixels, with kUnknown_SkColorType, with
|
||||
kUnknown_SkAlphaType, and with a width and height of zero. Use
|
||||
reset() to associate pixels, SkColorType, SkAlphaType, width, and height
|
||||
after SkPixmap has been created.
|
||||
|
||||
@return empty SkPixmap
|
||||
*/
|
||||
SkPixmap()
|
||||
: fPixels(nullptr), fRowBytes(0), fInfo(SkImageInfo::MakeUnknown(0, 0))
|
||||
{}
|
||||
|
||||
/** Creates SkPixmap from info width, height, SkAlphaType, and SkColorType.
|
||||
addr points to pixels, or nullptr. rowBytes should be info.width() times
|
||||
info.bytesPerPixel(), or larger.
|
||||
|
||||
No parameter checking is performed; it is up to the caller to ensure that
|
||||
addr and rowBytes agree with info.
|
||||
|
||||
The memory lifetime of pixels is managed by the caller. When SkPixmap goes
|
||||
out of scope, addr is unaffected.
|
||||
|
||||
SkPixmap may be later modified by reset() to change its size, pixel type, or
|
||||
storage.
|
||||
|
||||
@param info width, height, SkAlphaType, SkColorType of SkImageInfo
|
||||
@param addr pointer to pixels allocated by caller; may be nullptr
|
||||
@param rowBytes size of one row of addr; width times pixel size, or larger
|
||||
@return initialized SkPixmap
|
||||
*/
|
||||
SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes)
|
||||
: fPixels(addr), fRowBytes(rowBytes), fInfo(info)
|
||||
{}
|
||||
|
||||
/** Sets width, height, row bytes to zero; pixel address to nullptr; SkColorType to
|
||||
kUnknown_SkColorType; and SkAlphaType to kUnknown_SkAlphaType.
|
||||
|
||||
The prior pixels are unaffected; it is up to the caller to release pixels
|
||||
memory if desired.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_reset
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/** Sets width, height, SkAlphaType, and SkColorType from info.
|
||||
Sets pixel address from addr, which may be nullptr.
|
||||
Sets row bytes from rowBytes, which should be info.width() times
|
||||
info.bytesPerPixel(), or larger.
|
||||
|
||||
Does not check addr. Asserts if built with SK_DEBUG defined and if rowBytes is
|
||||
too small to hold one row of pixels.
|
||||
|
||||
The memory lifetime pixels are managed by the caller. When SkPixmap goes
|
||||
out of scope, addr is unaffected.
|
||||
|
||||
@param info width, height, SkAlphaType, SkColorType of SkImageInfo
|
||||
@param addr pointer to pixels allocated by caller; may be nullptr
|
||||
@param rowBytes size of one row of addr; width times pixel size, or larger
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_reset_2
|
||||
*/
|
||||
void reset(const SkImageInfo& info, const void* addr, size_t rowBytes);
|
||||
|
||||
/** Changes SkColorSpace in SkImageInfo; preserves width, height, SkAlphaType, and
|
||||
SkColorType in SkImage, and leaves pixel address and row bytes unchanged.
|
||||
SkColorSpace reference count is incremented.
|
||||
|
||||
@param colorSpace SkColorSpace moved to SkImageInfo
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_setColorSpace
|
||||
*/
|
||||
void setColorSpace(sk_sp<SkColorSpace> colorSpace);
|
||||
|
||||
/** Deprecated.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT reset(const SkMask& mask);
|
||||
|
||||
/** Sets subset width, height, pixel address to intersection of SkPixmap with area,
|
||||
if intersection is not empty; and return true. Otherwise, leave subset unchanged
|
||||
and return false.
|
||||
|
||||
Failing to read the return value generates a compile time warning.
|
||||
|
||||
@param subset storage for width, height, pixel address of intersection
|
||||
@param area bounds to intersect with SkPixmap
|
||||
@return true if intersection of SkPixmap and area is not empty
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT extractSubset(SkPixmap* subset, const SkIRect& area) const;
|
||||
|
||||
/** Returns width, height, SkAlphaType, SkColorType, and SkColorSpace.
|
||||
|
||||
@return reference to SkImageInfo
|
||||
*/
|
||||
const SkImageInfo& info() const { return fInfo; }
|
||||
|
||||
/** Returns row bytes, the interval from one pixel row to the next. Row bytes
|
||||
is at least as large as: width() * info().bytesPerPixel().
|
||||
|
||||
Returns zero if colorType() is kUnknown_SkColorType.
|
||||
It is up to the SkBitmap creator to ensure that row bytes is a useful value.
|
||||
|
||||
@return byte length of pixel row
|
||||
*/
|
||||
size_t rowBytes() const { return fRowBytes; }
|
||||
|
||||
/** Returns pixel address, the base address corresponding to the pixel origin.
|
||||
|
||||
It is up to the SkPixmap creator to ensure that pixel address is a useful value.
|
||||
|
||||
@return pixel address
|
||||
*/
|
||||
const void* addr() const { return fPixels; }
|
||||
|
||||
/** Returns pixel count in each pixel row. Should be equal or less than:
|
||||
rowBytes() / info().bytesPerPixel().
|
||||
|
||||
@return pixel width in SkImageInfo
|
||||
*/
|
||||
int width() const { return fInfo.width(); }
|
||||
|
||||
/** Returns pixel row count.
|
||||
|
||||
@return pixel height in SkImageInfo
|
||||
*/
|
||||
int height() const { return fInfo.height(); }
|
||||
|
||||
/**
|
||||
* Return the dimensions of the pixmap (from its ImageInfo)
|
||||
*/
|
||||
SkISize dimensions() const { return fInfo.dimensions(); }
|
||||
|
||||
SkColorType colorType() const { return fInfo.colorType(); }
|
||||
|
||||
SkAlphaType alphaType() const { return fInfo.alphaType(); }
|
||||
|
||||
/** Returns SkColorSpace, the range of colors, associated with SkImageInfo. The
|
||||
reference count of SkColorSpace is unchanged. The returned SkColorSpace is
|
||||
immutable.
|
||||
|
||||
@return SkColorSpace in SkImageInfo, or nullptr
|
||||
*/
|
||||
SkColorSpace* colorSpace() const { return fInfo.colorSpace(); }
|
||||
|
||||
/** Returns smart pointer to SkColorSpace, the range of colors, associated with
|
||||
SkImageInfo. The smart pointer tracks the number of objects sharing this
|
||||
SkColorSpace reference so the memory is released when the owners destruct.
|
||||
|
||||
The returned SkColorSpace is immutable.
|
||||
|
||||
@return SkColorSpace in SkImageInfo wrapped in a smart pointer
|
||||
*/
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fInfo.refColorSpace(); }
|
||||
|
||||
/** Returns true if SkAlphaType is kOpaque_SkAlphaType.
|
||||
Does not check if SkColorType allows alpha, or if any pixel value has
|
||||
transparency.
|
||||
|
||||
@return true if SkImageInfo has opaque SkAlphaType
|
||||
*/
|
||||
bool isOpaque() const { return fInfo.isOpaque(); }
|
||||
|
||||
/** Returns SkIRect { 0, 0, width(), height() }.
|
||||
|
||||
@return integral rectangle from origin to width() and height()
|
||||
*/
|
||||
SkIRect bounds() const { return SkIRect::MakeWH(this->width(), this->height()); }
|
||||
|
||||
/** Returns number of pixels that fit on row. Should be greater than or equal to
|
||||
width().
|
||||
|
||||
@return maximum pixels per row
|
||||
*/
|
||||
int rowBytesAsPixels() const { return int(fRowBytes >> this->shiftPerPixel()); }
|
||||
|
||||
/** Returns bit shift converting row bytes to row pixels.
|
||||
Returns zero for kUnknown_SkColorType.
|
||||
|
||||
@return one of: 0, 1, 2, 3; left shift to convert pixels to bytes
|
||||
*/
|
||||
int shiftPerPixel() const { return fInfo.shiftPerPixel(); }
|
||||
|
||||
/** Returns minimum memory required for pixel storage.
|
||||
Does not include unused memory on last row when rowBytesAsPixels() exceeds width().
|
||||
Returns SIZE_MAX if result does not fit in size_t.
|
||||
Returns zero if height() or width() is 0.
|
||||
Returns height() times rowBytes() if colorType() is kUnknown_SkColorType.
|
||||
|
||||
@return size in bytes of image buffer
|
||||
*/
|
||||
size_t computeByteSize() const { return fInfo.computeByteSize(fRowBytes); }
|
||||
|
||||
/** Returns true if all pixels are opaque. SkColorType determines how pixels
|
||||
are encoded, and whether pixel describes alpha. Returns true for SkColorType
|
||||
without alpha in each pixel; for other SkColorType, returns true if all
|
||||
pixels have alpha values equivalent to 1.0 or greater.
|
||||
|
||||
For SkColorType kRGB_565_SkColorType or kGray_8_SkColorType: always
|
||||
returns true. For SkColorType kAlpha_8_SkColorType, kBGRA_8888_SkColorType,
|
||||
kRGBA_8888_SkColorType: returns true if all pixel alpha values are 255.
|
||||
For SkColorType kARGB_4444_SkColorType: returns true if all pixel alpha values are 15.
|
||||
For kRGBA_F16_SkColorType: returns true if all pixel alpha values are 1.0 or
|
||||
greater.
|
||||
|
||||
Returns false for kUnknown_SkColorType.
|
||||
|
||||
@return true if all pixels have opaque values or SkColorType is opaque
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_computeIsOpaque
|
||||
*/
|
||||
bool computeIsOpaque() const;
|
||||
|
||||
/** Returns pixel at (x, y) as unpremultiplied color.
|
||||
Returns black with alpha if SkColorType is kAlpha_8_SkColorType.
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined; and returns undefined values or may crash if
|
||||
SK_RELEASE is defined. Fails if SkColorType is kUnknown_SkColorType or
|
||||
pixel address is nullptr.
|
||||
|
||||
SkColorSpace in SkImageInfo is ignored. Some color precision may be lost in the
|
||||
conversion to unpremultiplied color; original pixel data may have additional
|
||||
precision.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return pixel converted to unpremultiplied color
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_getColor
|
||||
*/
|
||||
SkColor getColor(int x, int y) const;
|
||||
|
||||
/** Look up the pixel at (x,y) and return its alpha component, normalized to [0..1].
|
||||
This is roughly equivalent to SkGetColorA(getColor()), but can be more efficent
|
||||
(and more precise if the pixels store more than 8 bits per component).
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return alpha converted to normalized float
|
||||
*/
|
||||
float getAlphaf(int x, int y) const;
|
||||
|
||||
/** Returns readable pixel address at (x, y). Returns nullptr if SkPixelRef is nullptr.
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined. Returns nullptr if SkColorType is kUnknown_SkColorType.
|
||||
|
||||
Performs a lookup of pixel size; for better performance, call
|
||||
one of: addr8, addr16, addr32, addr64, or addrF16().
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return readable generic pointer to pixel
|
||||
*/
|
||||
const void* addr(int x, int y) const {
|
||||
return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes);
|
||||
}
|
||||
|
||||
/** Returns readable base pixel address. Result is addressable as unsigned 8-bit bytes.
|
||||
Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or
|
||||
kGray_8_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
One byte corresponds to one pixel.
|
||||
|
||||
@return readable unsigned 8-bit pointer to pixels
|
||||
*/
|
||||
const uint8_t* addr8() const {
|
||||
SkASSERT(1 == fInfo.bytesPerPixel());
|
||||
return reinterpret_cast<const uint8_t*>(fPixels);
|
||||
}
|
||||
|
||||
/** Returns readable base pixel address. Result is addressable as unsigned 16-bit words.
|
||||
Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or
|
||||
kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
One word corresponds to one pixel.
|
||||
|
||||
@return readable unsigned 16-bit pointer to pixels
|
||||
*/
|
||||
const uint16_t* addr16() const {
|
||||
SkASSERT(2 == fInfo.bytesPerPixel());
|
||||
return reinterpret_cast<const uint16_t*>(fPixels);
|
||||
}
|
||||
|
||||
/** Returns readable base pixel address. Result is addressable as unsigned 32-bit words.
|
||||
Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or
|
||||
kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
One word corresponds to one pixel.
|
||||
|
||||
@return readable unsigned 32-bit pointer to pixels
|
||||
*/
|
||||
const uint32_t* addr32() const {
|
||||
SkASSERT(4 == fInfo.bytesPerPixel());
|
||||
return reinterpret_cast<const uint32_t*>(fPixels);
|
||||
}
|
||||
|
||||
/** Returns readable base pixel address. Result is addressable as unsigned 64-bit words.
|
||||
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
|
||||
with SK_DEBUG defined.
|
||||
|
||||
One word corresponds to one pixel.
|
||||
|
||||
@return readable unsigned 64-bit pointer to pixels
|
||||
*/
|
||||
const uint64_t* addr64() const {
|
||||
SkASSERT(8 == fInfo.bytesPerPixel());
|
||||
return reinterpret_cast<const uint64_t*>(fPixels);
|
||||
}
|
||||
|
||||
/** Returns readable base pixel address. Result is addressable as unsigned 16-bit words.
|
||||
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
|
||||
with SK_DEBUG defined.
|
||||
|
||||
Each word represents one color component encoded as a half float.
|
||||
Four words correspond to one pixel.
|
||||
|
||||
@return readable unsigned 16-bit pointer to first component of pixels
|
||||
*/
|
||||
const uint16_t* addrF16() const {
|
||||
SkASSERT(8 == fInfo.bytesPerPixel());
|
||||
SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType() ||
|
||||
kRGBA_F16Norm_SkColorType == fInfo.colorType());
|
||||
return reinterpret_cast<const uint16_t*>(fPixels);
|
||||
}
|
||||
|
||||
/** Returns readable pixel address at (x, y).
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined.
|
||||
|
||||
Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or
|
||||
kGray_8_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return readable unsigned 8-bit pointer to pixel at (x, y)
|
||||
*/
|
||||
const uint8_t* addr8(int x, int y) const {
|
||||
SkASSERT((unsigned)x < (unsigned)fInfo.width());
|
||||
SkASSERT((unsigned)y < (unsigned)fInfo.height());
|
||||
return (const uint8_t*)((const char*)this->addr8() + (size_t)y * fRowBytes + (x << 0));
|
||||
}
|
||||
|
||||
/** Returns readable pixel address at (x, y).
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined.
|
||||
|
||||
Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or
|
||||
kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return readable unsigned 16-bit pointer to pixel at (x, y)
|
||||
*/
|
||||
const uint16_t* addr16(int x, int y) const {
|
||||
SkASSERT((unsigned)x < (unsigned)fInfo.width());
|
||||
SkASSERT((unsigned)y < (unsigned)fInfo.height());
|
||||
return (const uint16_t*)((const char*)this->addr16() + (size_t)y * fRowBytes + (x << 1));
|
||||
}
|
||||
|
||||
/** Returns readable pixel address at (x, y).
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined.
|
||||
|
||||
Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or
|
||||
kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return readable unsigned 32-bit pointer to pixel at (x, y)
|
||||
*/
|
||||
const uint32_t* addr32(int x, int y) const {
|
||||
SkASSERT((unsigned)x < (unsigned)fInfo.width());
|
||||
SkASSERT((unsigned)y < (unsigned)fInfo.height());
|
||||
return (const uint32_t*)((const char*)this->addr32() + (size_t)y * fRowBytes + (x << 2));
|
||||
}
|
||||
|
||||
/** Returns readable pixel address at (x, y).
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined.
|
||||
|
||||
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
|
||||
with SK_DEBUG defined.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return readable unsigned 64-bit pointer to pixel at (x, y)
|
||||
*/
|
||||
const uint64_t* addr64(int x, int y) const {
|
||||
SkASSERT((unsigned)x < (unsigned)fInfo.width());
|
||||
SkASSERT((unsigned)y < (unsigned)fInfo.height());
|
||||
return (const uint64_t*)((const char*)this->addr64() + (size_t)y * fRowBytes + (x << 3));
|
||||
}
|
||||
|
||||
/** Returns readable pixel address at (x, y).
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined.
|
||||
|
||||
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built
|
||||
with SK_DEBUG defined.
|
||||
|
||||
Each unsigned 16-bit word represents one color component encoded as a half float.
|
||||
Four words correspond to one pixel.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return readable unsigned 16-bit pointer to pixel component at (x, y)
|
||||
*/
|
||||
const uint16_t* addrF16(int x, int y) const {
|
||||
SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType() ||
|
||||
kRGBA_F16Norm_SkColorType == fInfo.colorType());
|
||||
return reinterpret_cast<const uint16_t*>(this->addr64(x, y));
|
||||
}
|
||||
|
||||
/** Returns writable base pixel address.
|
||||
|
||||
@return writable generic base pointer to pixels
|
||||
*/
|
||||
void* writable_addr() const { return const_cast<void*>(fPixels); }
|
||||
|
||||
/** Returns writable pixel address at (x, y).
|
||||
|
||||
Input is not validated: out of bounds values of x or y trigger an assert() if
|
||||
built with SK_DEBUG defined. Returns zero if SkColorType is kUnknown_SkColorType.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return writable generic pointer to pixel
|
||||
*/
|
||||
void* writable_addr(int x, int y) const {
|
||||
return const_cast<void*>(this->addr(x, y));
|
||||
}
|
||||
|
||||
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
|
||||
8-bit bytes. Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType
|
||||
or kGray_8_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
One byte corresponds to one pixel.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return writable unsigned 8-bit pointer to pixels
|
||||
*/
|
||||
uint8_t* writable_addr8(int x, int y) const {
|
||||
return const_cast<uint8_t*>(this->addr8(x, y));
|
||||
}
|
||||
|
||||
/** Returns writable_addr pixel address at (x, y). Result is addressable as unsigned
|
||||
16-bit words. Will trigger an assert() if SkColorType is not kRGB_565_SkColorType
|
||||
or kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
|
||||
|
||||
One word corresponds to one pixel.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return writable unsigned 16-bit pointer to pixel
|
||||
*/
|
||||
uint16_t* writable_addr16(int x, int y) const {
|
||||
return const_cast<uint16_t*>(this->addr16(x, y));
|
||||
}
|
||||
|
||||
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
|
||||
32-bit words. Will trigger an assert() if SkColorType is not
|
||||
kRGBA_8888_SkColorType or kBGRA_8888_SkColorType, and is built with SK_DEBUG
|
||||
defined.
|
||||
|
||||
One word corresponds to one pixel.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return writable unsigned 32-bit pointer to pixel
|
||||
*/
|
||||
uint32_t* writable_addr32(int x, int y) const {
|
||||
return const_cast<uint32_t*>(this->addr32(x, y));
|
||||
}
|
||||
|
||||
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
|
||||
64-bit words. Will trigger an assert() if SkColorType is not
|
||||
kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
|
||||
|
||||
One word corresponds to one pixel.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return writable unsigned 64-bit pointer to pixel
|
||||
*/
|
||||
uint64_t* writable_addr64(int x, int y) const {
|
||||
return const_cast<uint64_t*>(this->addr64(x, y));
|
||||
}
|
||||
|
||||
/** Returns writable pixel address at (x, y). Result is addressable as unsigned
|
||||
16-bit words. Will trigger an assert() if SkColorType is not
|
||||
kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
|
||||
|
||||
Each word represents one color component encoded as a half float.
|
||||
Four words correspond to one pixel.
|
||||
|
||||
@param x column index, zero or greater, and less than width()
|
||||
@param y row index, zero or greater, and less than height()
|
||||
@return writable unsigned 16-bit pointer to first component of pixel
|
||||
*/
|
||||
uint16_t* writable_addrF16(int x, int y) const {
|
||||
return reinterpret_cast<uint16_t*>(writable_addr64(x, y));
|
||||
}
|
||||
|
||||
/** Copies a SkRect of pixels to dstPixels. Copy starts at (0, 0), and does not
|
||||
exceed SkPixmap (width(), height()).
|
||||
|
||||
dstInfo specifies width, height, SkColorType, SkAlphaType, and
|
||||
SkColorSpace of destination. dstRowBytes specifics the gap from one destination
|
||||
row to the next. Returns true if pixels are copied. Returns false if
|
||||
dstInfo address equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes().
|
||||
|
||||
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is
|
||||
kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType() must match.
|
||||
If SkPixmap colorType() is kGray_8_SkColorType, dstInfo.colorSpace() must match.
|
||||
If SkPixmap alphaType() is kOpaque_SkAlphaType, dstInfo.alphaType() must
|
||||
match. If SkPixmap colorSpace() is nullptr, dstInfo.colorSpace() must match. Returns
|
||||
false if pixel conversion is not possible.
|
||||
|
||||
Returns false if SkPixmap width() or height() is zero or negative.
|
||||
|
||||
@param dstInfo destination width, height, SkColorType, SkAlphaType, SkColorSpace
|
||||
@param dstPixels destination pixel storage
|
||||
@param dstRowBytes destination row length
|
||||
@return true if pixels are copied to dstPixels
|
||||
*/
|
||||
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes) const {
|
||||
return this->readPixels(dstInfo, dstPixels, dstRowBytes, 0, 0);
|
||||
}
|
||||
|
||||
/** Copies a SkRect of pixels to dstPixels. Copy starts at (srcX, srcY), and does not
|
||||
exceed SkPixmap (width(), height()).
|
||||
|
||||
dstInfo specifies width, height, SkColorType, SkAlphaType, and
|
||||
SkColorSpace of destination. dstRowBytes specifics the gap from one destination
|
||||
row to the next. Returns true if pixels are copied. Returns false if
|
||||
dstInfo address equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes().
|
||||
|
||||
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is
|
||||
kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType() must match.
|
||||
If SkPixmap colorType() is kGray_8_SkColorType, dstInfo.colorSpace() must match.
|
||||
If SkPixmap alphaType() is kOpaque_SkAlphaType, dstInfo.alphaType() must
|
||||
match. If SkPixmap colorSpace() is nullptr, dstInfo.colorSpace() must match. Returns
|
||||
false if pixel conversion is not possible.
|
||||
|
||||
srcX and srcY may be negative to copy only top or left of source. Returns
|
||||
false if SkPixmap width() or height() is zero or negative. Returns false if:
|
||||
abs(srcX) >= Pixmap width(), or if abs(srcY) >= Pixmap height().
|
||||
|
||||
@param dstInfo destination width, height, SkColorType, SkAlphaType, SkColorSpace
|
||||
@param dstPixels destination pixel storage
|
||||
@param dstRowBytes destination row length
|
||||
@param srcX column index whose absolute value is less than width()
|
||||
@param srcY row index whose absolute value is less than height()
|
||||
@return true if pixels are copied to dstPixels
|
||||
*/
|
||||
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX,
|
||||
int srcY) const;
|
||||
|
||||
/** Copies a SkRect of pixels to dst. Copy starts at (srcX, srcY), and does not
|
||||
exceed SkPixmap (width(), height()). dst specifies width, height, SkColorType,
|
||||
SkAlphaType, and SkColorSpace of destination. Returns true if pixels are copied.
|
||||
Returns false if dst address equals nullptr, or dst.rowBytes() is less than
|
||||
dst SkImageInfo::minRowBytes.
|
||||
|
||||
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is
|
||||
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst.info().colorType must match.
|
||||
If SkPixmap colorType() is kGray_8_SkColorType, dst.info().colorSpace must match.
|
||||
If SkPixmap alphaType() is kOpaque_SkAlphaType, dst.info().alphaType must
|
||||
match. If SkPixmap colorSpace() is nullptr, dst.info().colorSpace must match. Returns
|
||||
false if pixel conversion is not possible.
|
||||
|
||||
srcX and srcY may be negative to copy only top or left of source. Returns
|
||||
false SkPixmap width() or height() is zero or negative. Returns false if:
|
||||
abs(srcX) >= Pixmap width(), or if abs(srcY) >= Pixmap height().
|
||||
|
||||
@param dst SkImageInfo and pixel address to write to
|
||||
@param srcX column index whose absolute value is less than width()
|
||||
@param srcY row index whose absolute value is less than height()
|
||||
@return true if pixels are copied to dst
|
||||
*/
|
||||
bool readPixels(const SkPixmap& dst, int srcX, int srcY) const {
|
||||
return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), srcX, srcY);
|
||||
}
|
||||
|
||||
/** Copies pixels inside bounds() to dst. dst specifies width, height, SkColorType,
|
||||
SkAlphaType, and SkColorSpace of destination. Returns true if pixels are copied.
|
||||
Returns false if dst address equals nullptr, or dst.rowBytes() is less than
|
||||
dst SkImageInfo::minRowBytes.
|
||||
|
||||
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is
|
||||
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst SkColorType must match.
|
||||
If SkPixmap colorType() is kGray_8_SkColorType, dst SkColorSpace must match.
|
||||
If SkPixmap alphaType() is kOpaque_SkAlphaType, dst SkAlphaType must
|
||||
match. If SkPixmap colorSpace() is nullptr, dst SkColorSpace must match. Returns
|
||||
false if pixel conversion is not possible.
|
||||
|
||||
Returns false if SkPixmap width() or height() is zero or negative.
|
||||
|
||||
@param dst SkImageInfo and pixel address to write to
|
||||
@return true if pixels are copied to dst
|
||||
*/
|
||||
bool readPixels(const SkPixmap& dst) const {
|
||||
return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), 0, 0);
|
||||
}
|
||||
|
||||
/** Copies SkBitmap to dst, scaling pixels to fit dst.width() and dst.height(), and
|
||||
converting pixels to match dst.colorType() and dst.alphaType(). Returns true if
|
||||
pixels are copied. Returns false if dst address is nullptr, or dst.rowBytes() is
|
||||
less than dst SkImageInfo::minRowBytes.
|
||||
|
||||
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is
|
||||
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst SkColorType must match.
|
||||
If SkPixmap colorType() is kGray_8_SkColorType, dst SkColorSpace must match.
|
||||
If SkPixmap alphaType() is kOpaque_SkAlphaType, dst SkAlphaType must
|
||||
match. If SkPixmap colorSpace() is nullptr, dst SkColorSpace must match. Returns
|
||||
false if pixel conversion is not possible.
|
||||
|
||||
Returns false if SkBitmap width() or height() is zero or negative.
|
||||
|
||||
@param dst SkImageInfo and pixel address to write to
|
||||
@return true if pixels are scaled to fit dst
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_scalePixels
|
||||
*/
|
||||
bool scalePixels(const SkPixmap& dst, const SkSamplingOptions&) const;
|
||||
|
||||
/** Writes color to pixels bounded by subset; returns true on success.
|
||||
Returns false if colorType() is kUnknown_SkColorType, or if subset does
|
||||
not intersect bounds().
|
||||
|
||||
@param color sRGB unpremultiplied color to write
|
||||
@param subset bounding integer SkRect of written pixels
|
||||
@return true if pixels are changed
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_erase
|
||||
*/
|
||||
bool erase(SkColor color, const SkIRect& subset) const;
|
||||
|
||||
/** Writes color to pixels inside bounds(); returns true on success.
|
||||
Returns false if colorType() is kUnknown_SkColorType, or if bounds()
|
||||
is empty.
|
||||
|
||||
@param color sRGB unpremultiplied color to write
|
||||
@return true if pixels are changed
|
||||
*/
|
||||
bool erase(SkColor color) const { return this->erase(color, this->bounds()); }
|
||||
|
||||
/** Writes color to pixels bounded by subset; returns true on success.
|
||||
if subset is nullptr, writes colors pixels inside bounds(). Returns false if
|
||||
colorType() is kUnknown_SkColorType, if subset is not nullptr and does
|
||||
not intersect bounds(), or if subset is nullptr and bounds() is empty.
|
||||
|
||||
@param color sRGB unpremultiplied color to write
|
||||
@param subset bounding integer SkRect of pixels to write; may be nullptr
|
||||
@return true if pixels are changed
|
||||
|
||||
example: https://fiddle.skia.org/c/@Pixmap_erase_3
|
||||
*/
|
||||
bool erase(const SkColor4f& color, const SkIRect* subset = nullptr) const {
|
||||
return this->erase(color, nullptr, subset);
|
||||
}
|
||||
|
||||
/** Writes color to pixels bounded by subset; returns true on success.
|
||||
if subset is nullptr, writes colors pixels inside bounds(). Returns false if
|
||||
colorType() is kUnknown_SkColorType, if subset is not nullptr and does
|
||||
not intersect bounds(), or if subset is nullptr and bounds() is empty.
|
||||
|
||||
@param color unpremultiplied color to write
|
||||
@param cs SkColorSpace of color
|
||||
@param subset bounding integer SkRect of pixels to write; may be nullptr
|
||||
@return true if pixels are changed
|
||||
*/
|
||||
bool erase(const SkColor4f& color, SkColorSpace* cs, const SkIRect* subset = nullptr) const;
|
||||
|
||||
private:
|
||||
const void* fPixels;
|
||||
size_t fRowBytes;
|
||||
SkImageInfo fInfo;
|
||||
|
||||
friend class SkPixmapPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
45
src/deps/skia/include/core/SkPngChunkReader.h
Normal file
45
src/deps/skia/include/core/SkPngChunkReader.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPngChunkReader_DEFINED
|
||||
#define SkPngChunkReader_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
/**
|
||||
* SkPngChunkReader
|
||||
*
|
||||
* Base class for optional callbacks to retrieve meta/chunk data out of a PNG
|
||||
* encoded image as it is being decoded.
|
||||
* Used by SkCodec.
|
||||
*/
|
||||
class SkPngChunkReader : public SkRefCnt {
|
||||
public:
|
||||
/**
|
||||
* This will be called by the decoder when it sees an unknown chunk.
|
||||
*
|
||||
* Use by SkCodec:
|
||||
* Depending on the location of the unknown chunks, this callback may be
|
||||
* called by
|
||||
* - the factory (NewFromStream/NewFromData)
|
||||
* - getPixels
|
||||
* - startScanlineDecode
|
||||
* - the first call to getScanlines/skipScanlines
|
||||
* The callback may be called from a different thread (e.g. if the SkCodec
|
||||
* is passed to another thread), and it may be called multiple times, if
|
||||
* the SkCodec is used multiple times.
|
||||
*
|
||||
* @param tag Name for this type of chunk.
|
||||
* @param data Data to be interpreted by the subclass.
|
||||
* @param length Number of bytes of data in the chunk.
|
||||
* @return true to continue decoding, or false to indicate an error, which
|
||||
* will cause the decoder to not return the image.
|
||||
*/
|
||||
virtual bool readChunk(const char tag[], const void* data, size_t length) = 0;
|
||||
};
|
||||
#endif // SkPngChunkReader_DEFINED
|
||||
566
src/deps/skia/include/core/SkPoint.h
Normal file
566
src/deps/skia/include/core/SkPoint.h
Normal file
@@ -0,0 +1,566 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPoint_DEFINED
|
||||
#define SkPoint_DEFINED
|
||||
|
||||
#include "include/core/SkMath.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/private/SkSafe32.h"
|
||||
|
||||
struct SkIPoint;
|
||||
|
||||
/** SkIVector provides an alternative name for SkIPoint. SkIVector and SkIPoint
|
||||
can be used interchangeably for all purposes.
|
||||
*/
|
||||
typedef SkIPoint SkIVector;
|
||||
|
||||
/** \struct SkIPoint
|
||||
SkIPoint holds two 32-bit integer coordinates.
|
||||
*/
|
||||
struct SkIPoint {
|
||||
int32_t fX; //!< x-axis value
|
||||
int32_t fY; //!< y-axis value
|
||||
|
||||
/** Sets fX to x, fY to y.
|
||||
|
||||
@param x integer x-axis value of constructed SkIPoint
|
||||
@param y integer y-axis value of constructed SkIPoint
|
||||
@return SkIPoint (x, y)
|
||||
*/
|
||||
static constexpr SkIPoint Make(int32_t x, int32_t y) {
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
/** Returns x-axis value of SkIPoint.
|
||||
|
||||
@return fX
|
||||
*/
|
||||
constexpr int32_t x() const { return fX; }
|
||||
|
||||
/** Returns y-axis value of SkIPoint.
|
||||
|
||||
@return fY
|
||||
*/
|
||||
constexpr int32_t y() const { return fY; }
|
||||
|
||||
/** Returns true if fX and fY are both zero.
|
||||
|
||||
@return true if fX is zero and fY is zero
|
||||
*/
|
||||
bool isZero() const { return (fX | fY) == 0; }
|
||||
|
||||
/** Sets fX to x and fY to y.
|
||||
|
||||
@param x new value for fX
|
||||
@param y new value for fY
|
||||
*/
|
||||
void set(int32_t x, int32_t y) {
|
||||
fX = x;
|
||||
fY = y;
|
||||
}
|
||||
|
||||
/** Returns SkIPoint changing the signs of fX and fY.
|
||||
|
||||
@return SkIPoint as (-fX, -fY)
|
||||
*/
|
||||
SkIPoint operator-() const {
|
||||
return {-fX, -fY};
|
||||
}
|
||||
|
||||
/** Offsets SkIPoint by ivector v. Sets SkIPoint to (fX + v.fX, fY + v.fY).
|
||||
|
||||
@param v ivector to add
|
||||
*/
|
||||
void operator+=(const SkIVector& v) {
|
||||
fX = Sk32_sat_add(fX, v.fX);
|
||||
fY = Sk32_sat_add(fY, v.fY);
|
||||
}
|
||||
|
||||
/** Subtracts ivector v from SkIPoint. Sets SkIPoint to: (fX - v.fX, fY - v.fY).
|
||||
|
||||
@param v ivector to subtract
|
||||
*/
|
||||
void operator-=(const SkIVector& v) {
|
||||
fX = Sk32_sat_sub(fX, v.fX);
|
||||
fY = Sk32_sat_sub(fY, v.fY);
|
||||
}
|
||||
|
||||
/** Returns true if SkIPoint is equivalent to SkIPoint constructed from (x, y).
|
||||
|
||||
@param x value compared with fX
|
||||
@param y value compared with fY
|
||||
@return true if SkIPoint equals (x, y)
|
||||
*/
|
||||
bool equals(int32_t x, int32_t y) const {
|
||||
return fX == x && fY == y;
|
||||
}
|
||||
|
||||
/** Returns true if a is equivalent to b.
|
||||
|
||||
@param a SkIPoint to compare
|
||||
@param b SkIPoint to compare
|
||||
@return true if a.fX == b.fX and a.fY == b.fY
|
||||
*/
|
||||
friend bool operator==(const SkIPoint& a, const SkIPoint& b) {
|
||||
return a.fX == b.fX && a.fY == b.fY;
|
||||
}
|
||||
|
||||
/** Returns true if a is not equivalent to b.
|
||||
|
||||
@param a SkIPoint to compare
|
||||
@param b SkIPoint to compare
|
||||
@return true if a.fX != b.fX or a.fY != b.fY
|
||||
*/
|
||||
friend bool operator!=(const SkIPoint& a, const SkIPoint& b) {
|
||||
return a.fX != b.fX || a.fY != b.fY;
|
||||
}
|
||||
|
||||
/** Returns ivector from b to a; computed as (a.fX - b.fX, a.fY - b.fY).
|
||||
|
||||
Can also be used to subtract ivector from ivector, returning ivector.
|
||||
|
||||
@param a SkIPoint or ivector to subtract from
|
||||
@param b ivector to subtract
|
||||
@return ivector from b to a
|
||||
*/
|
||||
friend SkIVector operator-(const SkIPoint& a, const SkIPoint& b) {
|
||||
return { Sk32_sat_sub(a.fX, b.fX), Sk32_sat_sub(a.fY, b.fY) };
|
||||
}
|
||||
|
||||
/** Returns SkIPoint resulting from SkIPoint a offset by ivector b, computed as:
|
||||
(a.fX + b.fX, a.fY + b.fY).
|
||||
|
||||
Can also be used to offset SkIPoint b by ivector a, returning SkIPoint.
|
||||
Can also be used to add ivector to ivector, returning ivector.
|
||||
|
||||
@param a SkIPoint or ivector to add to
|
||||
@param b SkIPoint or ivector to add
|
||||
@return SkIPoint equal to a offset by b
|
||||
*/
|
||||
friend SkIPoint operator+(const SkIPoint& a, const SkIVector& b) {
|
||||
return { Sk32_sat_add(a.fX, b.fX), Sk32_sat_add(a.fY, b.fY) };
|
||||
}
|
||||
};
|
||||
|
||||
struct SkPoint;
|
||||
|
||||
/** SkVector provides an alternative name for SkPoint. SkVector and SkPoint can
|
||||
be used interchangeably for all purposes.
|
||||
*/
|
||||
typedef SkPoint SkVector;
|
||||
|
||||
/** \struct SkPoint
|
||||
SkPoint holds two 32-bit floating point coordinates.
|
||||
*/
|
||||
struct SK_API SkPoint {
|
||||
SkScalar fX; //!< x-axis value
|
||||
SkScalar fY; //!< y-axis value
|
||||
|
||||
/** Sets fX to x, fY to y. Used both to set SkPoint and vector.
|
||||
|
||||
@param x SkScalar x-axis value of constructed SkPoint or vector
|
||||
@param y SkScalar y-axis value of constructed SkPoint or vector
|
||||
@return SkPoint (x, y)
|
||||
*/
|
||||
static constexpr SkPoint Make(SkScalar x, SkScalar y) {
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
/** Returns x-axis value of SkPoint or vector.
|
||||
|
||||
@return fX
|
||||
*/
|
||||
constexpr SkScalar x() const { return fX; }
|
||||
|
||||
/** Returns y-axis value of SkPoint or vector.
|
||||
|
||||
@return fY
|
||||
*/
|
||||
constexpr SkScalar y() const { return fY; }
|
||||
|
||||
/** Returns true if fX and fY are both zero.
|
||||
|
||||
@return true if fX is zero and fY is zero
|
||||
*/
|
||||
bool isZero() const { return (0 == fX) & (0 == fY); }
|
||||
|
||||
/** Sets fX to x and fY to y.
|
||||
|
||||
@param x new value for fX
|
||||
@param y new value for fY
|
||||
*/
|
||||
void set(SkScalar x, SkScalar y) {
|
||||
fX = x;
|
||||
fY = y;
|
||||
}
|
||||
|
||||
/** Sets fX to x and fY to y, promoting integers to SkScalar values.
|
||||
|
||||
Assigning a large integer value directly to fX or fY may cause a compiler
|
||||
error, triggered by narrowing conversion of int to SkScalar. This safely
|
||||
casts x and y to avoid the error.
|
||||
|
||||
@param x new value for fX
|
||||
@param y new value for fY
|
||||
*/
|
||||
void iset(int32_t x, int32_t y) {
|
||||
fX = SkIntToScalar(x);
|
||||
fY = SkIntToScalar(y);
|
||||
}
|
||||
|
||||
/** Sets fX to p.fX and fY to p.fY, promoting integers to SkScalar values.
|
||||
|
||||
Assigning an SkIPoint containing a large integer value directly to fX or fY may
|
||||
cause a compiler error, triggered by narrowing conversion of int to SkScalar.
|
||||
This safely casts p.fX and p.fY to avoid the error.
|
||||
|
||||
@param p SkIPoint members promoted to SkScalar
|
||||
*/
|
||||
void iset(const SkIPoint& p) {
|
||||
fX = SkIntToScalar(p.fX);
|
||||
fY = SkIntToScalar(p.fY);
|
||||
}
|
||||
|
||||
/** Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.
|
||||
|
||||
@param pt members providing magnitude for fX and fY
|
||||
*/
|
||||
void setAbs(const SkPoint& pt) {
|
||||
fX = SkScalarAbs(pt.fX);
|
||||
fY = SkScalarAbs(pt.fY);
|
||||
}
|
||||
|
||||
/** Adds offset to each SkPoint in points array with count entries.
|
||||
|
||||
@param points SkPoint array
|
||||
@param count entries in array
|
||||
@param offset vector added to points
|
||||
*/
|
||||
static void Offset(SkPoint points[], int count, const SkVector& offset) {
|
||||
Offset(points, count, offset.fX, offset.fY);
|
||||
}
|
||||
|
||||
/** Adds offset (dx, dy) to each SkPoint in points array of length count.
|
||||
|
||||
@param points SkPoint array
|
||||
@param count entries in array
|
||||
@param dx added to fX in points
|
||||
@param dy added to fY in points
|
||||
*/
|
||||
static void Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
points[i].offset(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds offset (dx, dy) to SkPoint.
|
||||
|
||||
@param dx added to fX
|
||||
@param dy added to fY
|
||||
*/
|
||||
void offset(SkScalar dx, SkScalar dy) {
|
||||
fX += dx;
|
||||
fY += dy;
|
||||
}
|
||||
|
||||
/** Returns the Euclidean distance from origin, computed as:
|
||||
|
||||
sqrt(fX * fX + fY * fY)
|
||||
|
||||
.
|
||||
|
||||
@return straight-line distance to origin
|
||||
*/
|
||||
SkScalar length() const { return SkPoint::Length(fX, fY); }
|
||||
|
||||
/** Returns the Euclidean distance from origin, computed as:
|
||||
|
||||
sqrt(fX * fX + fY * fY)
|
||||
|
||||
.
|
||||
|
||||
@return straight-line distance to origin
|
||||
*/
|
||||
SkScalar distanceToOrigin() const { return this->length(); }
|
||||
|
||||
/** Scales (fX, fY) so that length() returns one, while preserving ratio of fX to fY,
|
||||
if possible. If prior length is nearly zero, sets vector to (0, 0) and returns
|
||||
false; otherwise returns true.
|
||||
|
||||
@return true if former length is not zero or nearly zero
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_normalize_2
|
||||
*/
|
||||
bool normalize();
|
||||
|
||||
/** Sets vector to (x, y) scaled so length() returns one, and so that
|
||||
(fX, fY) is proportional to (x, y). If (x, y) length is nearly zero,
|
||||
sets vector to (0, 0) and returns false; otherwise returns true.
|
||||
|
||||
@param x proportional value for fX
|
||||
@param y proportional value for fY
|
||||
@return true if (x, y) length is not zero or nearly zero
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_setNormalize
|
||||
*/
|
||||
bool setNormalize(SkScalar x, SkScalar y);
|
||||
|
||||
/** Scales vector so that distanceToOrigin() returns length, if possible. If former
|
||||
length is nearly zero, sets vector to (0, 0) and return false; otherwise returns
|
||||
true.
|
||||
|
||||
@param length straight-line distance to origin
|
||||
@return true if former length is not zero or nearly zero
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_setLength
|
||||
*/
|
||||
bool setLength(SkScalar length);
|
||||
|
||||
/** Sets vector to (x, y) scaled to length, if possible. If former
|
||||
length is nearly zero, sets vector to (0, 0) and return false; otherwise returns
|
||||
true.
|
||||
|
||||
@param x proportional value for fX
|
||||
@param y proportional value for fY
|
||||
@param length straight-line distance to origin
|
||||
@return true if (x, y) length is not zero or nearly zero
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_setLength_2
|
||||
*/
|
||||
bool setLength(SkScalar x, SkScalar y, SkScalar length);
|
||||
|
||||
/** Sets dst to SkPoint times scale. dst may be SkPoint to modify SkPoint in place.
|
||||
|
||||
@param scale factor to multiply SkPoint by
|
||||
@param dst storage for scaled SkPoint
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_scale
|
||||
*/
|
||||
void scale(SkScalar scale, SkPoint* dst) const;
|
||||
|
||||
/** Scales SkPoint in place by scale.
|
||||
|
||||
@param value factor to multiply SkPoint by
|
||||
*/
|
||||
void scale(SkScalar value) { this->scale(value, this); }
|
||||
|
||||
/** Changes the sign of fX and fY.
|
||||
*/
|
||||
void negate() {
|
||||
fX = -fX;
|
||||
fY = -fY;
|
||||
}
|
||||
|
||||
/** Returns SkPoint changing the signs of fX and fY.
|
||||
|
||||
@return SkPoint as (-fX, -fY)
|
||||
*/
|
||||
SkPoint operator-() const {
|
||||
return {-fX, -fY};
|
||||
}
|
||||
|
||||
/** Adds vector v to SkPoint. Sets SkPoint to: (fX + v.fX, fY + v.fY).
|
||||
|
||||
@param v vector to add
|
||||
*/
|
||||
void operator+=(const SkVector& v) {
|
||||
fX += v.fX;
|
||||
fY += v.fY;
|
||||
}
|
||||
|
||||
/** Subtracts vector v from SkPoint. Sets SkPoint to: (fX - v.fX, fY - v.fY).
|
||||
|
||||
@param v vector to subtract
|
||||
*/
|
||||
void operator-=(const SkVector& v) {
|
||||
fX -= v.fX;
|
||||
fY -= v.fY;
|
||||
}
|
||||
|
||||
/** Returns SkPoint multiplied by scale.
|
||||
|
||||
@param scale scalar to multiply by
|
||||
@return SkPoint as (fX * scale, fY * scale)
|
||||
*/
|
||||
SkPoint operator*(SkScalar scale) const {
|
||||
return {fX * scale, fY * scale};
|
||||
}
|
||||
|
||||
/** Multiplies SkPoint by scale. Sets SkPoint to: (fX * scale, fY * scale).
|
||||
|
||||
@param scale scalar to multiply by
|
||||
@return reference to SkPoint
|
||||
*/
|
||||
SkPoint& operator*=(SkScalar scale) {
|
||||
fX *= scale;
|
||||
fY *= scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Returns true if both fX and fY are measurable values.
|
||||
|
||||
@return true for values other than infinities and NaN
|
||||
*/
|
||||
bool isFinite() const {
|
||||
SkScalar accum = 0;
|
||||
accum *= fX;
|
||||
accum *= fY;
|
||||
|
||||
// accum is either NaN or it is finite (zero).
|
||||
SkASSERT(0 == accum || SkScalarIsNaN(accum));
|
||||
|
||||
// value==value will be true iff value is not NaN
|
||||
// TODO: is it faster to say !accum or accum==accum?
|
||||
return !SkScalarIsNaN(accum);
|
||||
}
|
||||
|
||||
/** Returns true if SkPoint is equivalent to SkPoint constructed from (x, y).
|
||||
|
||||
@param x value compared with fX
|
||||
@param y value compared with fY
|
||||
@return true if SkPoint equals (x, y)
|
||||
*/
|
||||
bool equals(SkScalar x, SkScalar y) const {
|
||||
return fX == x && fY == y;
|
||||
}
|
||||
|
||||
/** Returns true if a is equivalent to b.
|
||||
|
||||
@param a SkPoint to compare
|
||||
@param b SkPoint to compare
|
||||
@return true if a.fX == b.fX and a.fY == b.fY
|
||||
*/
|
||||
friend bool operator==(const SkPoint& a, const SkPoint& b) {
|
||||
return a.fX == b.fX && a.fY == b.fY;
|
||||
}
|
||||
|
||||
/** Returns true if a is not equivalent to b.
|
||||
|
||||
@param a SkPoint to compare
|
||||
@param b SkPoint to compare
|
||||
@return true if a.fX != b.fX or a.fY != b.fY
|
||||
*/
|
||||
friend bool operator!=(const SkPoint& a, const SkPoint& b) {
|
||||
return a.fX != b.fX || a.fY != b.fY;
|
||||
}
|
||||
|
||||
/** Returns vector from b to a, computed as (a.fX - b.fX, a.fY - b.fY).
|
||||
|
||||
Can also be used to subtract vector from SkPoint, returning SkPoint.
|
||||
Can also be used to subtract vector from vector, returning vector.
|
||||
|
||||
@param a SkPoint to subtract from
|
||||
@param b SkPoint to subtract
|
||||
@return vector from b to a
|
||||
*/
|
||||
friend SkVector operator-(const SkPoint& a, const SkPoint& b) {
|
||||
return {a.fX - b.fX, a.fY - b.fY};
|
||||
}
|
||||
|
||||
/** Returns SkPoint resulting from SkPoint a offset by vector b, computed as:
|
||||
(a.fX + b.fX, a.fY + b.fY).
|
||||
|
||||
Can also be used to offset SkPoint b by vector a, returning SkPoint.
|
||||
Can also be used to add vector to vector, returning vector.
|
||||
|
||||
@param a SkPoint or vector to add to
|
||||
@param b SkPoint or vector to add
|
||||
@return SkPoint equal to a offset by b
|
||||
*/
|
||||
friend SkPoint operator+(const SkPoint& a, const SkVector& b) {
|
||||
return {a.fX + b.fX, a.fY + b.fY};
|
||||
}
|
||||
|
||||
/** Returns the Euclidean distance from origin, computed as:
|
||||
|
||||
sqrt(x * x + y * y)
|
||||
|
||||
.
|
||||
|
||||
@param x component of length
|
||||
@param y component of length
|
||||
@return straight-line distance to origin
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_Length
|
||||
*/
|
||||
static SkScalar Length(SkScalar x, SkScalar y);
|
||||
|
||||
/** Scales (vec->fX, vec->fY) so that length() returns one, while preserving ratio of vec->fX
|
||||
to vec->fY, if possible. If original length is nearly zero, sets vec to (0, 0) and returns
|
||||
zero; otherwise, returns length of vec before vec is scaled.
|
||||
|
||||
Returned prior length may be SK_ScalarInfinity if it can not be represented by SkScalar.
|
||||
|
||||
Note that normalize() is faster if prior length is not required.
|
||||
|
||||
@param vec normalized to unit length
|
||||
@return original vec length
|
||||
|
||||
example: https://fiddle.skia.org/c/@Point_Normalize
|
||||
*/
|
||||
static SkScalar Normalize(SkVector* vec);
|
||||
|
||||
/** Returns the Euclidean distance between a and b.
|
||||
|
||||
@param a line end point
|
||||
@param b line end point
|
||||
@return straight-line distance from a to b
|
||||
*/
|
||||
static SkScalar Distance(const SkPoint& a, const SkPoint& b) {
|
||||
return Length(a.fX - b.fX, a.fY - b.fY);
|
||||
}
|
||||
|
||||
/** Returns the dot product of vector a and vector b.
|
||||
|
||||
@param a left side of dot product
|
||||
@param b right side of dot product
|
||||
@return product of input magnitudes and cosine of the angle between them
|
||||
*/
|
||||
static SkScalar DotProduct(const SkVector& a, const SkVector& b) {
|
||||
return a.fX * b.fX + a.fY * b.fY;
|
||||
}
|
||||
|
||||
/** Returns the cross product of vector a and vector b.
|
||||
|
||||
a and b form three-dimensional vectors with z-axis value equal to zero. The
|
||||
cross product is a three-dimensional vector with x-axis and y-axis values equal
|
||||
to zero. The cross product z-axis component is returned.
|
||||
|
||||
@param a left side of cross product
|
||||
@param b right side of cross product
|
||||
@return area spanned by vectors signed by angle direction
|
||||
*/
|
||||
static SkScalar CrossProduct(const SkVector& a, const SkVector& b) {
|
||||
return a.fX * b.fY - a.fY * b.fX;
|
||||
}
|
||||
|
||||
/** Returns the cross product of vector and vec.
|
||||
|
||||
Vector and vec form three-dimensional vectors with z-axis value equal to zero.
|
||||
The cross product is a three-dimensional vector with x-axis and y-axis values
|
||||
equal to zero. The cross product z-axis component is returned.
|
||||
|
||||
@param vec right side of cross product
|
||||
@return area spanned by vectors signed by angle direction
|
||||
*/
|
||||
SkScalar cross(const SkVector& vec) const {
|
||||
return CrossProduct(*this, vec);
|
||||
}
|
||||
|
||||
/** Returns the dot product of vector and vector vec.
|
||||
|
||||
@param vec right side of dot product
|
||||
@return product of input magnitudes and cosine of the angle between them
|
||||
*/
|
||||
SkScalar dot(const SkVector& vec) const {
|
||||
return DotProduct(*this, vec);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
157
src/deps/skia/include/core/SkPoint3.h
Normal file
157
src/deps/skia/include/core/SkPoint3.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPoint3_DEFINED
|
||||
#define SkPoint3_DEFINED
|
||||
|
||||
#include "include/core/SkPoint.h"
|
||||
|
||||
struct SK_API SkPoint3 {
|
||||
SkScalar fX, fY, fZ;
|
||||
|
||||
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z) {
|
||||
SkPoint3 pt;
|
||||
pt.set(x, y, z);
|
||||
return pt;
|
||||
}
|
||||
|
||||
SkScalar x() const { return fX; }
|
||||
SkScalar y() const { return fY; }
|
||||
SkScalar z() const { return fZ; }
|
||||
|
||||
void set(SkScalar x, SkScalar y, SkScalar z) { fX = x; fY = y; fZ = z; }
|
||||
|
||||
friend bool operator==(const SkPoint3& a, const SkPoint3& b) {
|
||||
return a.fX == b.fX && a.fY == b.fY && a.fZ == b.fZ;
|
||||
}
|
||||
|
||||
friend bool operator!=(const SkPoint3& a, const SkPoint3& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/** Returns the Euclidian distance from (0,0,0) to (x,y,z)
|
||||
*/
|
||||
static SkScalar Length(SkScalar x, SkScalar y, SkScalar z);
|
||||
|
||||
/** Return the Euclidian distance from (0,0,0) to the point
|
||||
*/
|
||||
SkScalar length() const { return SkPoint3::Length(fX, fY, fZ); }
|
||||
|
||||
/** Set the point (vector) to be unit-length in the same direction as it
|
||||
already points. If the point has a degenerate length (i.e., nearly 0)
|
||||
then set it to (0,0,0) and return false; otherwise return true.
|
||||
*/
|
||||
bool normalize();
|
||||
|
||||
/** Return a new point whose X, Y and Z coordinates are scaled.
|
||||
*/
|
||||
SkPoint3 makeScale(SkScalar scale) const {
|
||||
SkPoint3 p;
|
||||
p.set(scale * fX, scale * fY, scale * fZ);
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Scale the point's coordinates by scale.
|
||||
*/
|
||||
void scale(SkScalar value) {
|
||||
fX *= value;
|
||||
fY *= value;
|
||||
fZ *= value;
|
||||
}
|
||||
|
||||
/** Return a new point whose X, Y and Z coordinates are the negative of the
|
||||
original point's
|
||||
*/
|
||||
SkPoint3 operator-() const {
|
||||
SkPoint3 neg;
|
||||
neg.fX = -fX;
|
||||
neg.fY = -fY;
|
||||
neg.fZ = -fZ;
|
||||
return neg;
|
||||
}
|
||||
|
||||
/** Returns a new point whose coordinates are the difference between
|
||||
a and b (i.e., a - b)
|
||||
*/
|
||||
friend SkPoint3 operator-(const SkPoint3& a, const SkPoint3& b) {
|
||||
return { a.fX - b.fX, a.fY - b.fY, a.fZ - b.fZ };
|
||||
}
|
||||
|
||||
/** Returns a new point whose coordinates are the sum of a and b (a + b)
|
||||
*/
|
||||
friend SkPoint3 operator+(const SkPoint3& a, const SkPoint3& b) {
|
||||
return { a.fX + b.fX, a.fY + b.fY, a.fZ + b.fZ };
|
||||
}
|
||||
|
||||
/** Add v's coordinates to the point's
|
||||
*/
|
||||
void operator+=(const SkPoint3& v) {
|
||||
fX += v.fX;
|
||||
fY += v.fY;
|
||||
fZ += v.fZ;
|
||||
}
|
||||
|
||||
/** Subtract v's coordinates from the point's
|
||||
*/
|
||||
void operator-=(const SkPoint3& v) {
|
||||
fX -= v.fX;
|
||||
fY -= v.fY;
|
||||
fZ -= v.fZ;
|
||||
}
|
||||
|
||||
friend SkPoint3 operator*(SkScalar t, SkPoint3 p) {
|
||||
return { t * p.fX, t * p.fY, t * p.fZ };
|
||||
}
|
||||
|
||||
/** Returns true if fX, fY, and fZ are measurable values.
|
||||
|
||||
@return true for values other than infinities and NaN
|
||||
*/
|
||||
bool isFinite() const {
|
||||
SkScalar accum = 0;
|
||||
accum *= fX;
|
||||
accum *= fY;
|
||||
accum *= fZ;
|
||||
|
||||
// accum is either NaN or it is finite (zero).
|
||||
SkASSERT(0 == accum || SkScalarIsNaN(accum));
|
||||
|
||||
// value==value will be true iff value is not NaN
|
||||
// TODO: is it faster to say !accum or accum==accum?
|
||||
return !SkScalarIsNaN(accum);
|
||||
}
|
||||
|
||||
/** Returns the dot product of a and b, treating them as 3D vectors
|
||||
*/
|
||||
static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) {
|
||||
return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ;
|
||||
}
|
||||
|
||||
SkScalar dot(const SkPoint3& vec) const {
|
||||
return DotProduct(*this, vec);
|
||||
}
|
||||
|
||||
/** Returns the cross product of a and b, treating them as 3D vectors
|
||||
*/
|
||||
static SkPoint3 CrossProduct(const SkPoint3& a, const SkPoint3& b) {
|
||||
SkPoint3 result;
|
||||
result.fX = a.fY*b.fZ - a.fZ*b.fY;
|
||||
result.fY = a.fZ*b.fX - a.fX*b.fZ;
|
||||
result.fZ = a.fX*b.fY - a.fY*b.fX;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SkPoint3 cross(const SkPoint3& vec) const {
|
||||
return CrossProduct(*this, vec);
|
||||
}
|
||||
};
|
||||
|
||||
typedef SkPoint3 SkVector3;
|
||||
typedef SkPoint3 SkColor3f;
|
||||
|
||||
#endif
|
||||
46
src/deps/skia/include/core/SkPromiseImageTexture.h
Normal file
46
src/deps/skia/include/core/SkPromiseImageTexture.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkPromiseImageTexture_DEFINED
|
||||
#define SkPromiseImageTexture_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
/**
|
||||
* This type is used to fulfill textures for PromiseImages. Once an instance is returned from a
|
||||
* PromiseImageTextureFulfillProc the GrBackendTexture it wraps must remain valid until the
|
||||
* corresponding PromiseImageTextureReleaseProc is called.
|
||||
*/
|
||||
class SK_API SkPromiseImageTexture : public SkNVRefCnt<SkPromiseImageTexture> {
|
||||
public:
|
||||
SkPromiseImageTexture() = delete;
|
||||
SkPromiseImageTexture(const SkPromiseImageTexture&) = delete;
|
||||
SkPromiseImageTexture(SkPromiseImageTexture&&) = delete;
|
||||
~SkPromiseImageTexture();
|
||||
SkPromiseImageTexture& operator=(const SkPromiseImageTexture&) = delete;
|
||||
SkPromiseImageTexture& operator=(SkPromiseImageTexture&&) = delete;
|
||||
|
||||
static sk_sp<SkPromiseImageTexture> Make(const GrBackendTexture& backendTexture) {
|
||||
if (!backendTexture.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_sp<SkPromiseImageTexture>(new SkPromiseImageTexture(backendTexture));
|
||||
}
|
||||
|
||||
GrBackendTexture backendTexture() const { return fBackendTexture; }
|
||||
|
||||
private:
|
||||
explicit SkPromiseImageTexture(const GrBackendTexture& backendTexture);
|
||||
|
||||
GrBackendTexture fBackendTexture;
|
||||
};
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
#endif // SkPromiseImageTexture_DEFINED
|
||||
512
src/deps/skia/include/core/SkRRect.h
Normal file
512
src/deps/skia/include/core/SkRRect.h
Normal file
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkRRect_DEFINED
|
||||
#define SkRRect_DEFINED
|
||||
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
|
||||
class SkPath;
|
||||
class SkMatrix;
|
||||
class SkString;
|
||||
|
||||
/** \class SkRRect
|
||||
SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner.
|
||||
The bounds and radii can be set so that SkRRect describes: a rectangle with sharp corners;
|
||||
a circle; an oval; or a rectangle with one or more rounded corners.
|
||||
|
||||
SkRRect allows implementing CSS properties that describe rounded corners.
|
||||
SkRRect may have up to eight different radii, one for each axis on each of its four
|
||||
corners.
|
||||
|
||||
SkRRect may modify the provided parameters when initializing bounds and radii.
|
||||
If either axis radii is zero or less: radii are stored as zero; corner is square.
|
||||
If corner curves overlap, radii are proportionally reduced to fit within bounds.
|
||||
*/
|
||||
class SK_API SkRRect {
|
||||
public:
|
||||
|
||||
/** Initializes bounds at (0, 0), the origin, with zero width and height.
|
||||
Initializes corner radii to (0, 0), and sets type of kEmpty_Type.
|
||||
|
||||
@return empty SkRRect
|
||||
*/
|
||||
SkRRect() = default;
|
||||
|
||||
/** Initializes to copy of rrect bounds and corner radii.
|
||||
|
||||
@param rrect bounds and corner to copy
|
||||
@return copy of rrect
|
||||
*/
|
||||
SkRRect(const SkRRect& rrect) = default;
|
||||
|
||||
/** Copies rrect bounds and corner radii.
|
||||
|
||||
@param rrect bounds and corner to copy
|
||||
@return copy of rrect
|
||||
*/
|
||||
SkRRect& operator=(const SkRRect& rrect) = default;
|
||||
|
||||
/** \enum SkRRect::Type
|
||||
Type describes possible specializations of SkRRect. Each Type is
|
||||
exclusive; a SkRRect may only have one type.
|
||||
|
||||
Type members become progressively less restrictive; larger values of
|
||||
Type have more degrees of freedom than smaller values.
|
||||
*/
|
||||
enum Type {
|
||||
kEmpty_Type, //!< zero width or height
|
||||
kRect_Type, //!< non-zero width and height, and zeroed radii
|
||||
kOval_Type, //!< non-zero width and height filled with radii
|
||||
kSimple_Type, //!< non-zero width and height with equal radii
|
||||
kNinePatch_Type, //!< non-zero width and height with axis-aligned radii
|
||||
kComplex_Type, //!< non-zero width and height with arbitrary radii
|
||||
kLastType = kComplex_Type, //!< largest Type value
|
||||
};
|
||||
|
||||
Type getType() const {
|
||||
SkASSERT(this->isValid());
|
||||
return static_cast<Type>(fType);
|
||||
}
|
||||
|
||||
Type type() const { return this->getType(); }
|
||||
|
||||
inline bool isEmpty() const { return kEmpty_Type == this->getType(); }
|
||||
inline bool isRect() const { return kRect_Type == this->getType(); }
|
||||
inline bool isOval() const { return kOval_Type == this->getType(); }
|
||||
inline bool isSimple() const { return kSimple_Type == this->getType(); }
|
||||
inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); }
|
||||
inline bool isComplex() const { return kComplex_Type == this->getType(); }
|
||||
|
||||
/** Returns span on the x-axis. This does not check if result fits in 32-bit float;
|
||||
result may be infinity.
|
||||
|
||||
@return rect().fRight minus rect().fLeft
|
||||
*/
|
||||
SkScalar width() const { return fRect.width(); }
|
||||
|
||||
/** Returns span on the y-axis. This does not check if result fits in 32-bit float;
|
||||
result may be infinity.
|
||||
|
||||
@return rect().fBottom minus rect().fTop
|
||||
*/
|
||||
SkScalar height() const { return fRect.height(); }
|
||||
|
||||
/** Returns top-left corner radii. If type() returns kEmpty_Type, kRect_Type,
|
||||
kOval_Type, or kSimple_Type, returns a value representative of all corner radii.
|
||||
If type() returns kNinePatch_Type or kComplex_Type, at least one of the
|
||||
remaining three corners has a different value.
|
||||
|
||||
@return corner radii for simple types
|
||||
*/
|
||||
SkVector getSimpleRadii() const {
|
||||
return fRadii[0];
|
||||
}
|
||||
|
||||
/** Sets bounds to zero width and height at (0, 0), the origin. Sets
|
||||
corner radii to zero and sets type to kEmpty_Type.
|
||||
*/
|
||||
void setEmpty() { *this = SkRRect(); }
|
||||
|
||||
/** Sets bounds to sorted rect, and sets corner radii to zero.
|
||||
If set bounds has width and height, and sets type to kRect_Type;
|
||||
otherwise, sets type to kEmpty_Type.
|
||||
|
||||
@param rect bounds to set
|
||||
*/
|
||||
void setRect(const SkRect& rect) {
|
||||
if (!this->initializeRect(rect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(fRadii, 0, sizeof(fRadii));
|
||||
fType = kRect_Type;
|
||||
|
||||
SkASSERT(this->isValid());
|
||||
}
|
||||
|
||||
/** Initializes bounds at (0, 0), the origin, with zero width and height.
|
||||
Initializes corner radii to (0, 0), and sets type of kEmpty_Type.
|
||||
|
||||
@return empty SkRRect
|
||||
*/
|
||||
static SkRRect MakeEmpty() { return SkRRect(); }
|
||||
|
||||
/** Initializes to copy of r bounds and zeroes corner radii.
|
||||
|
||||
@param r bounds to copy
|
||||
@return copy of r
|
||||
*/
|
||||
static SkRRect MakeRect(const SkRect& r) {
|
||||
SkRRect rr;
|
||||
rr.setRect(r);
|
||||
return rr;
|
||||
}
|
||||
|
||||
/** Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii
|
||||
to half oval.height(). If oval bounds is empty, sets to kEmpty_Type.
|
||||
Otherwise, sets to kOval_Type.
|
||||
|
||||
@param oval bounds of oval
|
||||
@return oval
|
||||
*/
|
||||
static SkRRect MakeOval(const SkRect& oval) {
|
||||
SkRRect rr;
|
||||
rr.setOval(oval);
|
||||
return rr;
|
||||
}
|
||||
|
||||
/** Sets to rounded rectangle with the same radii for all four corners.
|
||||
If rect is empty, sets to kEmpty_Type.
|
||||
Otherwise, if xRad and yRad are zero, sets to kRect_Type.
|
||||
Otherwise, if xRad is at least half rect.width() and yRad is at least half
|
||||
rect.height(), sets to kOval_Type.
|
||||
Otherwise, sets to kSimple_Type.
|
||||
|
||||
@param rect bounds of rounded rectangle
|
||||
@param xRad x-axis radius of corners
|
||||
@param yRad y-axis radius of corners
|
||||
@return rounded rectangle
|
||||
*/
|
||||
static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) {
|
||||
SkRRect rr;
|
||||
rr.setRectXY(rect, xRad, yRad);
|
||||
return rr;
|
||||
}
|
||||
|
||||
/** Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii
|
||||
to half oval.height(). If oval bounds is empty, sets to kEmpty_Type.
|
||||
Otherwise, sets to kOval_Type.
|
||||
|
||||
@param oval bounds of oval
|
||||
*/
|
||||
void setOval(const SkRect& oval);
|
||||
|
||||
/** Sets to rounded rectangle with the same radii for all four corners.
|
||||
If rect is empty, sets to kEmpty_Type.
|
||||
Otherwise, if xRad or yRad is zero, sets to kRect_Type.
|
||||
Otherwise, if xRad is at least half rect.width() and yRad is at least half
|
||||
rect.height(), sets to kOval_Type.
|
||||
Otherwise, sets to kSimple_Type.
|
||||
|
||||
@param rect bounds of rounded rectangle
|
||||
@param xRad x-axis radius of corners
|
||||
@param yRad y-axis radius of corners
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_setRectXY
|
||||
*/
|
||||
void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
|
||||
|
||||
/** Sets bounds to rect. Sets radii to (leftRad, topRad), (rightRad, topRad),
|
||||
(rightRad, bottomRad), (leftRad, bottomRad).
|
||||
|
||||
If rect is empty, sets to kEmpty_Type.
|
||||
Otherwise, if leftRad and rightRad are zero, sets to kRect_Type.
|
||||
Otherwise, if topRad and bottomRad are zero, sets to kRect_Type.
|
||||
Otherwise, if leftRad and rightRad are equal and at least half rect.width(), and
|
||||
topRad and bottomRad are equal at least half rect.height(), sets to kOval_Type.
|
||||
Otherwise, if leftRad and rightRad are equal, and topRad and bottomRad are equal,
|
||||
sets to kSimple_Type. Otherwise, sets to kNinePatch_Type.
|
||||
|
||||
Nine patch refers to the nine parts defined by the radii: one center rectangle,
|
||||
four edge patches, and four corner patches.
|
||||
|
||||
@param rect bounds of rounded rectangle
|
||||
@param leftRad left-top and left-bottom x-axis radius
|
||||
@param topRad left-top and right-top y-axis radius
|
||||
@param rightRad right-top and right-bottom x-axis radius
|
||||
@param bottomRad left-bottom and right-bottom y-axis radius
|
||||
*/
|
||||
void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
|
||||
SkScalar rightRad, SkScalar bottomRad);
|
||||
|
||||
/** Sets bounds to rect. Sets radii array for individual control of all for corners.
|
||||
|
||||
If rect is empty, sets to kEmpty_Type.
|
||||
Otherwise, if one of each corner radii are zero, sets to kRect_Type.
|
||||
Otherwise, if all x-axis radii are equal and at least half rect.width(), and
|
||||
all y-axis radii are equal at least half rect.height(), sets to kOval_Type.
|
||||
Otherwise, if all x-axis radii are equal, and all y-axis radii are equal,
|
||||
sets to kSimple_Type. Otherwise, sets to kNinePatch_Type.
|
||||
|
||||
@param rect bounds of rounded rectangle
|
||||
@param radii corner x-axis and y-axis radii
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_setRectRadii
|
||||
*/
|
||||
void setRectRadii(const SkRect& rect, const SkVector radii[4]);
|
||||
|
||||
/** \enum SkRRect::Corner
|
||||
The radii are stored: top-left, top-right, bottom-right, bottom-left.
|
||||
*/
|
||||
enum Corner {
|
||||
kUpperLeft_Corner, //!< index of top-left corner radii
|
||||
kUpperRight_Corner, //!< index of top-right corner radii
|
||||
kLowerRight_Corner, //!< index of bottom-right corner radii
|
||||
kLowerLeft_Corner, //!< index of bottom-left corner radii
|
||||
};
|
||||
|
||||
/** Returns bounds. Bounds may have zero width or zero height. Bounds right is
|
||||
greater than or equal to left; bounds bottom is greater than or equal to top.
|
||||
Result is identical to getBounds().
|
||||
|
||||
@return bounding box
|
||||
*/
|
||||
const SkRect& rect() const { return fRect; }
|
||||
|
||||
/** Returns scalar pair for radius of curve on x-axis and y-axis for one corner.
|
||||
Both radii may be zero. If not zero, both are positive and finite.
|
||||
|
||||
@return x-axis and y-axis radii for one corner
|
||||
*/
|
||||
SkVector radii(Corner corner) const { return fRadii[corner]; }
|
||||
|
||||
/** Returns bounds. Bounds may have zero width or zero height. Bounds right is
|
||||
greater than or equal to left; bounds bottom is greater than or equal to top.
|
||||
Result is identical to rect().
|
||||
|
||||
@return bounding box
|
||||
*/
|
||||
const SkRect& getBounds() const { return fRect; }
|
||||
|
||||
/** Returns true if bounds and radii in a are equal to bounds and radii in b.
|
||||
|
||||
a and b are not equal if either contain NaN. a and b are equal if members
|
||||
contain zeroes with different signs.
|
||||
|
||||
@param a SkRect bounds and radii to compare
|
||||
@param b SkRect bounds and radii to compare
|
||||
@return true if members are equal
|
||||
*/
|
||||
friend bool operator==(const SkRRect& a, const SkRRect& b) {
|
||||
return a.fRect == b.fRect && SkScalarsEqual(&a.fRadii[0].fX, &b.fRadii[0].fX, 8);
|
||||
}
|
||||
|
||||
/** Returns true if bounds and radii in a are not equal to bounds and radii in b.
|
||||
|
||||
a and b are not equal if either contain NaN. a and b are equal if members
|
||||
contain zeroes with different signs.
|
||||
|
||||
@param a SkRect bounds and radii to compare
|
||||
@param b SkRect bounds and radii to compare
|
||||
@return true if members are not equal
|
||||
*/
|
||||
friend bool operator!=(const SkRRect& a, const SkRRect& b) {
|
||||
return a.fRect != b.fRect || !SkScalarsEqual(&a.fRadii[0].fX, &b.fRadii[0].fX, 8);
|
||||
}
|
||||
|
||||
/** Copies SkRRect to dst, then insets dst bounds by dx and dy, and adjusts dst
|
||||
radii by dx and dy. dx and dy may be positive, negative, or zero. dst may be
|
||||
SkRRect.
|
||||
|
||||
If either corner radius is zero, the corner has no curvature and is unchanged.
|
||||
Otherwise, if adjusted radius becomes negative, pins radius to zero.
|
||||
If dx exceeds half dst bounds width, dst bounds left and right are set to
|
||||
bounds x-axis center. If dy exceeds half dst bounds height, dst bounds top and
|
||||
bottom are set to bounds y-axis center.
|
||||
|
||||
If dx or dy cause the bounds to become infinite, dst bounds is zeroed.
|
||||
|
||||
@param dx added to rect().fLeft, and subtracted from rect().fRight
|
||||
@param dy added to rect().fTop, and subtracted from rect().fBottom
|
||||
@param dst insets bounds and radii
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_inset
|
||||
*/
|
||||
void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const;
|
||||
|
||||
/** Insets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be
|
||||
positive, negative, or zero.
|
||||
|
||||
If either corner radius is zero, the corner has no curvature and is unchanged.
|
||||
Otherwise, if adjusted radius becomes negative, pins radius to zero.
|
||||
If dx exceeds half bounds width, bounds left and right are set to
|
||||
bounds x-axis center. If dy exceeds half bounds height, bounds top and
|
||||
bottom are set to bounds y-axis center.
|
||||
|
||||
If dx or dy cause the bounds to become infinite, bounds is zeroed.
|
||||
|
||||
@param dx added to rect().fLeft, and subtracted from rect().fRight
|
||||
@param dy added to rect().fTop, and subtracted from rect().fBottom
|
||||
*/
|
||||
void inset(SkScalar dx, SkScalar dy) {
|
||||
this->inset(dx, dy, this);
|
||||
}
|
||||
|
||||
/** Outsets dst bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be
|
||||
positive, negative, or zero.
|
||||
|
||||
If either corner radius is zero, the corner has no curvature and is unchanged.
|
||||
Otherwise, if adjusted radius becomes negative, pins radius to zero.
|
||||
If dx exceeds half dst bounds width, dst bounds left and right are set to
|
||||
bounds x-axis center. If dy exceeds half dst bounds height, dst bounds top and
|
||||
bottom are set to bounds y-axis center.
|
||||
|
||||
If dx or dy cause the bounds to become infinite, dst bounds is zeroed.
|
||||
|
||||
@param dx subtracted from rect().fLeft, and added to rect().fRight
|
||||
@param dy subtracted from rect().fTop, and added to rect().fBottom
|
||||
@param dst outset bounds and radii
|
||||
*/
|
||||
void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const {
|
||||
this->inset(-dx, -dy, dst);
|
||||
}
|
||||
|
||||
/** Outsets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be
|
||||
positive, negative, or zero.
|
||||
|
||||
If either corner radius is zero, the corner has no curvature and is unchanged.
|
||||
Otherwise, if adjusted radius becomes negative, pins radius to zero.
|
||||
If dx exceeds half bounds width, bounds left and right are set to
|
||||
bounds x-axis center. If dy exceeds half bounds height, bounds top and
|
||||
bottom are set to bounds y-axis center.
|
||||
|
||||
If dx or dy cause the bounds to become infinite, bounds is zeroed.
|
||||
|
||||
@param dx subtracted from rect().fLeft, and added to rect().fRight
|
||||
@param dy subtracted from rect().fTop, and added to rect().fBottom
|
||||
*/
|
||||
void outset(SkScalar dx, SkScalar dy) {
|
||||
this->inset(-dx, -dy, this);
|
||||
}
|
||||
|
||||
/** Translates SkRRect by (dx, dy).
|
||||
|
||||
@param dx offset added to rect().fLeft and rect().fRight
|
||||
@param dy offset added to rect().fTop and rect().fBottom
|
||||
*/
|
||||
void offset(SkScalar dx, SkScalar dy) {
|
||||
fRect.offset(dx, dy);
|
||||
}
|
||||
|
||||
/** Returns SkRRect translated by (dx, dy).
|
||||
|
||||
@param dx offset added to rect().fLeft and rect().fRight
|
||||
@param dy offset added to rect().fTop and rect().fBottom
|
||||
@return SkRRect bounds offset by (dx, dy), with unchanged corner radii
|
||||
*/
|
||||
SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy) const {
|
||||
return SkRRect(fRect.makeOffset(dx, dy), fRadii, fType);
|
||||
}
|
||||
|
||||
/** Returns true if rect is inside the bounds and corner radii, and if
|
||||
SkRRect and rect are not empty.
|
||||
|
||||
@param rect area tested for containment
|
||||
@return true if SkRRect contains rect
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_contains
|
||||
*/
|
||||
bool contains(const SkRect& rect) const;
|
||||
|
||||
/** Returns true if bounds and radii values are finite and describe a SkRRect
|
||||
SkRRect::Type that matches getType(). All SkRRect methods construct valid types,
|
||||
even if the input values are not valid. Invalid SkRRect data can only
|
||||
be generated by corrupting memory.
|
||||
|
||||
@return true if bounds and radii match type()
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_isValid
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
static constexpr size_t kSizeInMemory = 12 * sizeof(SkScalar);
|
||||
|
||||
/** Writes SkRRect to buffer. Writes kSizeInMemory bytes, and returns
|
||||
kSizeInMemory, the number of bytes written.
|
||||
|
||||
@param buffer storage for SkRRect
|
||||
@return bytes written, kSizeInMemory
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_writeToMemory
|
||||
*/
|
||||
size_t writeToMemory(void* buffer) const;
|
||||
|
||||
/** Reads SkRRect from buffer, reading kSizeInMemory bytes.
|
||||
Returns kSizeInMemory, bytes read if length is at least kSizeInMemory.
|
||||
Otherwise, returns zero.
|
||||
|
||||
@param buffer memory to read from
|
||||
@param length size of buffer
|
||||
@return bytes read, or 0 if length is less than kSizeInMemory
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_readFromMemory
|
||||
*/
|
||||
size_t readFromMemory(const void* buffer, size_t length);
|
||||
|
||||
/** Transforms by SkRRect by matrix, storing result in dst.
|
||||
Returns true if SkRRect transformed can be represented by another SkRRect.
|
||||
Returns false if matrix contains transformations that are not axis aligned.
|
||||
|
||||
Asserts in debug builds if SkRRect equals dst.
|
||||
|
||||
@param matrix SkMatrix specifying the transform
|
||||
@param dst SkRRect to store the result
|
||||
@return true if transformation succeeded.
|
||||
|
||||
example: https://fiddle.skia.org/c/@RRect_transform
|
||||
*/
|
||||
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;
|
||||
SkString dumpToString(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]);
|
||||
|
||||
SkRRect(const SkRect& rect, const SkVector radii[4], int32_t type)
|
||||
: fRect(rect)
|
||||
, fRadii{radii[0], radii[1], radii[2], radii[3]}
|
||||
, fType(type) {}
|
||||
|
||||
/**
|
||||
* Initializes fRect. If the passed in rect is not finite or empty the rrect will be fully
|
||||
* initialized and false is returned. Otherwise, just fRect is initialized and true is returned.
|
||||
*/
|
||||
bool initializeRect(const SkRect&);
|
||||
|
||||
void computeType();
|
||||
bool checkCornerContainment(SkScalar x, SkScalar y) const;
|
||||
// Returns true if the radii had to be scaled to fit rect
|
||||
bool scaleRadii();
|
||||
|
||||
SkRect fRect = SkRect::MakeEmpty();
|
||||
// Radii order is UL, UR, LR, LL. Use Corner enum to index into fRadii[]
|
||||
SkVector fRadii[4] = {{0, 0}, {0, 0}, {0,0}, {0,0}};
|
||||
// use an explicitly sized type so we're sure the class is dense (no uninitialized bytes)
|
||||
int32_t fType = kEmpty_Type;
|
||||
// TODO: add padding so we can use memcpy for flattening and not copy uninitialized data
|
||||
|
||||
// to access fRadii directly
|
||||
friend class SkPath;
|
||||
friend class SkRRectPriv;
|
||||
};
|
||||
|
||||
#endif
|
||||
69
src/deps/skia/include/core/SkRSXform.h
Normal file
69
src/deps/skia/include/core/SkRSXform.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkRSXform_DEFINED
|
||||
#define SkRSXform_DEFINED
|
||||
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkSize.h"
|
||||
|
||||
/**
|
||||
* A compressed form of a rotation+scale matrix.
|
||||
*
|
||||
* [ fSCos -fSSin fTx ]
|
||||
* [ fSSin fSCos fTy ]
|
||||
* [ 0 0 1 ]
|
||||
*/
|
||||
struct SkRSXform {
|
||||
static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) {
|
||||
SkRSXform xform = { scos, ssin, tx, ty };
|
||||
return xform;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a new xform based on the scale, rotation (in radians), final tx,ty location
|
||||
* and anchor-point ax,ay within the src quad.
|
||||
*
|
||||
* Note: the anchor point is not normalized (e.g. 0...1) but is in pixels of the src image.
|
||||
*/
|
||||
static SkRSXform MakeFromRadians(SkScalar scale, SkScalar radians, SkScalar tx, SkScalar ty,
|
||||
SkScalar ax, SkScalar ay) {
|
||||
const SkScalar s = SkScalarSin(radians) * scale;
|
||||
const SkScalar c = SkScalarCos(radians) * scale;
|
||||
return Make(c, s, tx + -c * ax + s * ay, ty + -s * ax - c * ay);
|
||||
}
|
||||
|
||||
SkScalar fSCos;
|
||||
SkScalar fSSin;
|
||||
SkScalar fTx;
|
||||
SkScalar fTy;
|
||||
|
||||
bool rectStaysRect() const {
|
||||
return 0 == fSCos || 0 == fSSin;
|
||||
}
|
||||
|
||||
void setIdentity() {
|
||||
fSCos = 1;
|
||||
fSSin = fTx = fTy = 0;
|
||||
}
|
||||
|
||||
void set(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) {
|
||||
fSCos = scos;
|
||||
fSSin = ssin;
|
||||
fTx = tx;
|
||||
fTy = ty;
|
||||
}
|
||||
|
||||
void toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const;
|
||||
void toQuad(const SkSize& size, SkPoint quad[4]) const {
|
||||
this->toQuad(size.width(), size.height(), quad);
|
||||
}
|
||||
void toTriStrip(SkScalar width, SkScalar height, SkPoint strip[4]) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
92
src/deps/skia/include/core/SkRasterHandleAllocator.h
Normal file
92
src/deps/skia/include/core/SkRasterHandleAllocator.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkRasterHandleAllocator_DEFINED
|
||||
#define SkRasterHandleAllocator_DEFINED
|
||||
|
||||
#include "include/core/SkImageInfo.h"
|
||||
|
||||
class SkBitmap;
|
||||
class SkCanvas;
|
||||
class SkMatrix;
|
||||
|
||||
/**
|
||||
* If a client wants to control the allocation of raster layers in a canvas, it should subclass
|
||||
* SkRasterHandleAllocator. This allocator performs two tasks:
|
||||
* 1. controls how the memory for the pixels is allocated
|
||||
* 2. associates a "handle" to a private object that can track the matrix/clip of the SkCanvas
|
||||
*
|
||||
* This example allocates a canvas, and defers to the allocator to create the base layer.
|
||||
*
|
||||
* std::unique_ptr<SkCanvas> canvas = SkRasterHandleAllocator::MakeCanvas(
|
||||
* SkImageInfo::Make(...),
|
||||
* std::make_unique<MySubclassRasterHandleAllocator>(...),
|
||||
* nullptr);
|
||||
*
|
||||
* If you have already allocated the base layer (and its handle, release-proc etc.) then you
|
||||
* can pass those in using the last parameter to MakeCanvas().
|
||||
*
|
||||
* Regardless of how the base layer is allocated, each time canvas->saveLayer() is called,
|
||||
* your allocator's allocHandle() will be called.
|
||||
*/
|
||||
class SK_API SkRasterHandleAllocator {
|
||||
public:
|
||||
virtual ~SkRasterHandleAllocator() = default;
|
||||
|
||||
// The value that is returned to clients of the canvas that has this allocator installed.
|
||||
typedef void* Handle;
|
||||
|
||||
struct Rec {
|
||||
// When the allocation goes out of scope, this proc is called to free everything associated
|
||||
// with it: the pixels, the "handle", etc. This is passed the pixel address and fReleaseCtx.
|
||||
void (*fReleaseProc)(void* pixels, void* ctx);
|
||||
void* fReleaseCtx; // context passed to fReleaseProc
|
||||
void* fPixels; // pixels for this allocation
|
||||
size_t fRowBytes; // rowbytes for these pixels
|
||||
Handle fHandle; // public handle returned by SkCanvas::accessTopRasterHandle()
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a requested info, allocate the corresponding pixels/rowbytes, and whatever handle
|
||||
* is desired to give clients access to those pixels. The rec also contains a proc and context
|
||||
* which will be called when this allocation goes out of scope.
|
||||
*
|
||||
* e.g.
|
||||
* when canvas->saveLayer() is called, the allocator will be called to allocate the pixels
|
||||
* for the layer. When canvas->restore() is called, the fReleaseProc will be called.
|
||||
*/
|
||||
virtual bool allocHandle(const SkImageInfo&, Rec*) = 0;
|
||||
|
||||
/**
|
||||
* Clients access the handle for a given layer by calling SkCanvas::accessTopRasterHandle().
|
||||
* To allow the handle to reflect the current matrix/clip in the canvs, updateHandle() is
|
||||
* is called. The subclass is responsible to update the handle as it sees fit.
|
||||
*/
|
||||
virtual void updateHandle(Handle, const SkMatrix&, const SkIRect&) = 0;
|
||||
|
||||
/**
|
||||
* This creates a canvas which will use the allocator to manage pixel allocations, including
|
||||
* all calls to saveLayer().
|
||||
*
|
||||
* If rec is non-null, then it will be used as the base-layer of pixels/handle.
|
||||
* If rec is null, then the allocator will be called for the base-layer as well.
|
||||
*/
|
||||
static std::unique_ptr<SkCanvas> MakeCanvas(std::unique_ptr<SkRasterHandleAllocator>,
|
||||
const SkImageInfo&, const Rec* rec = nullptr);
|
||||
|
||||
protected:
|
||||
SkRasterHandleAllocator() = default;
|
||||
SkRasterHandleAllocator(const SkRasterHandleAllocator&) = delete;
|
||||
SkRasterHandleAllocator& operator=(const SkRasterHandleAllocator&) = delete;
|
||||
|
||||
private:
|
||||
friend class SkBitmapDevice;
|
||||
|
||||
Handle allocBitmap(const SkImageInfo&, SkBitmap*);
|
||||
};
|
||||
|
||||
#endif
|
||||
1378
src/deps/skia/include/core/SkRect.h
Normal file
1378
src/deps/skia/include/core/SkRect.h
Normal file
File diff suppressed because it is too large
Load Diff
382
src/deps/skia/include/core/SkRefCnt.h
Normal file
382
src/deps/skia/include/core/SkRefCnt.h
Normal file
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkRefCnt_DEFINED
|
||||
#define SkRefCnt_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include <atomic> // std::atomic, std::memory_order_*
|
||||
#include <cstddef> // std::nullptr_t
|
||||
#include <iosfwd> // std::basic_ostream
|
||||
#include <memory> // TODO: unused
|
||||
#include <type_traits> // std::enable_if, std::is_convertible
|
||||
#include <utility> // std::forward, std::swap
|
||||
|
||||
/** \class SkRefCntBase
|
||||
|
||||
SkRefCntBase is the base class for objects that may be shared by multiple
|
||||
objects. When an existing owner wants to share a reference, it calls ref().
|
||||
When an owner wants to release its reference, it calls unref(). When the
|
||||
shared object's reference count goes to zero as the result of an unref()
|
||||
call, its (virtual) destructor is called. It is an error for the
|
||||
destructor to be called explicitly (or via the object going out of scope on
|
||||
the stack or calling delete) if getRefCnt() > 1.
|
||||
*/
|
||||
class SK_API SkRefCntBase {
|
||||
public:
|
||||
/** Default construct, initializing the reference count to 1.
|
||||
*/
|
||||
SkRefCntBase() : fRefCnt(1) {}
|
||||
|
||||
/** Destruct, asserting that the reference count is 1.
|
||||
*/
|
||||
virtual ~SkRefCntBase() {
|
||||
#ifdef SK_DEBUG
|
||||
SkASSERTF(this->getRefCnt() == 1, "fRefCnt was %d", this->getRefCnt());
|
||||
// illegal value, to catch us if we reuse after delete
|
||||
fRefCnt.store(0, std::memory_order_relaxed);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** May return true if the caller is the only owner.
|
||||
* Ensures that all previous owner's actions are complete.
|
||||
*/
|
||||
bool unique() const {
|
||||
if (1 == fRefCnt.load(std::memory_order_acquire)) {
|
||||
// The acquire barrier is only really needed if we return true. It
|
||||
// prevents code conditioned on the result of unique() from running
|
||||
// until previous owners are all totally done calling unref().
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Increment the reference count. Must be balanced by a call to unref().
|
||||
*/
|
||||
void ref() const {
|
||||
SkASSERT(this->getRefCnt() > 0);
|
||||
// No barrier required.
|
||||
(void)fRefCnt.fetch_add(+1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
/** Decrement the reference count. If the reference count is 1 before the
|
||||
decrement, then delete the object. Note that if this is the case, then
|
||||
the object needs to have been allocated via new, and not on the stack.
|
||||
*/
|
||||
void unref() const {
|
||||
SkASSERT(this->getRefCnt() > 0);
|
||||
// A release here acts in place of all releases we "should" have been doing in ref().
|
||||
if (1 == fRefCnt.fetch_add(-1, std::memory_order_acq_rel)) {
|
||||
// Like unique(), the acquire is only needed on success, to make sure
|
||||
// code in internal_dispose() doesn't happen before the decrement.
|
||||
this->internal_dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
/** Return the reference count. Use only for debugging. */
|
||||
int32_t getRefCnt() const {
|
||||
return fRefCnt.load(std::memory_order_relaxed);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Called when the ref count goes to 0.
|
||||
*/
|
||||
virtual void internal_dispose() const {
|
||||
#ifdef SK_DEBUG
|
||||
SkASSERT(0 == this->getRefCnt());
|
||||
fRefCnt.store(1, std::memory_order_relaxed);
|
||||
#endif
|
||||
delete this;
|
||||
}
|
||||
|
||||
// The following friends are those which override internal_dispose()
|
||||
// and conditionally call SkRefCnt::internal_dispose().
|
||||
friend class SkWeakRefCnt;
|
||||
|
||||
mutable std::atomic<int32_t> fRefCnt;
|
||||
|
||||
SkRefCntBase(SkRefCntBase&&) = delete;
|
||||
SkRefCntBase(const SkRefCntBase&) = delete;
|
||||
SkRefCntBase& operator=(SkRefCntBase&&) = delete;
|
||||
SkRefCntBase& operator=(const SkRefCntBase&) = delete;
|
||||
};
|
||||
|
||||
#ifdef SK_REF_CNT_MIXIN_INCLUDE
|
||||
// It is the responsibility of the following include to define the type SkRefCnt.
|
||||
// This SkRefCnt should normally derive from SkRefCntBase.
|
||||
#include SK_REF_CNT_MIXIN_INCLUDE
|
||||
#else
|
||||
class SK_API SkRefCnt : public SkRefCntBase {
|
||||
// "#include SK_REF_CNT_MIXIN_INCLUDE" doesn't work with this build system.
|
||||
#if defined(SK_BUILD_FOR_GOOGLE3)
|
||||
public:
|
||||
void deref() const { this->unref(); }
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Call obj->ref() and return obj. The obj must not be nullptr.
|
||||
*/
|
||||
template <typename T> static inline T* SkRef(T* obj) {
|
||||
SkASSERT(obj);
|
||||
obj->ref();
|
||||
return obj;
|
||||
}
|
||||
|
||||
/** Check if the argument is non-null, and if so, call obj->ref() and return obj.
|
||||
*/
|
||||
template <typename T> static inline T* SkSafeRef(T* obj) {
|
||||
if (obj) {
|
||||
obj->ref();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/** Check if the argument is non-null, and if so, call obj->unref()
|
||||
*/
|
||||
template <typename T> static inline void SkSafeUnref(T* obj) {
|
||||
if (obj) {
|
||||
obj->unref();
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This is a variant of SkRefCnt that's Not Virtual, so weighs 4 bytes instead of 8 or 16.
|
||||
// There's only benefit to using this if the deriving class does not otherwise need a vtable.
|
||||
template <typename Derived>
|
||||
class SkNVRefCnt {
|
||||
public:
|
||||
SkNVRefCnt() : fRefCnt(1) {}
|
||||
~SkNVRefCnt() {
|
||||
#ifdef SK_DEBUG
|
||||
int rc = fRefCnt.load(std::memory_order_relaxed);
|
||||
SkASSERTF(rc == 1, "NVRefCnt was %d", rc);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Implementation is pretty much the same as SkRefCntBase. All required barriers are the same:
|
||||
// - unique() needs acquire when it returns true, and no barrier if it returns false;
|
||||
// - ref() doesn't need any barrier;
|
||||
// - unref() needs a release barrier, and an acquire if it's going to call delete.
|
||||
|
||||
bool unique() const { return 1 == fRefCnt.load(std::memory_order_acquire); }
|
||||
void ref() const { (void)fRefCnt.fetch_add(+1, std::memory_order_relaxed); }
|
||||
void unref() const {
|
||||
if (1 == fRefCnt.fetch_add(-1, std::memory_order_acq_rel)) {
|
||||
// restore the 1 for our destructor's assert
|
||||
SkDEBUGCODE(fRefCnt.store(1, std::memory_order_relaxed));
|
||||
delete (const Derived*)this;
|
||||
}
|
||||
}
|
||||
void deref() const { this->unref(); }
|
||||
|
||||
// This must be used with caution. It is only valid to call this when 'threadIsolatedTestCnt'
|
||||
// refs are known to be isolated to the current thread. That is, it is known that there are at
|
||||
// least 'threadIsolatedTestCnt' refs for which no other thread may make a balancing unref()
|
||||
// call. Assuming the contract is followed, if this returns false then no other thread has
|
||||
// ownership of this. If it returns true then another thread *may* have ownership.
|
||||
bool refCntGreaterThan(int32_t threadIsolatedTestCnt) const {
|
||||
int cnt = fRefCnt.load(std::memory_order_acquire);
|
||||
// If this fails then the above contract has been violated.
|
||||
SkASSERT(cnt >= threadIsolatedTestCnt);
|
||||
return cnt > threadIsolatedTestCnt;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::atomic<int32_t> fRefCnt;
|
||||
|
||||
SkNVRefCnt(SkNVRefCnt&&) = delete;
|
||||
SkNVRefCnt(const SkNVRefCnt&) = delete;
|
||||
SkNVRefCnt& operator=(SkNVRefCnt&&) = delete;
|
||||
SkNVRefCnt& operator=(const SkNVRefCnt&) = delete;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Shared pointer class to wrap classes that support a ref()/unref() interface.
|
||||
*
|
||||
* This can be used for classes inheriting from SkRefCnt, but it also works for other
|
||||
* classes that match the interface, but have different internal choices: e.g. the hosted class
|
||||
* may have its ref/unref be thread-safe, but that is not assumed/imposed by sk_sp.
|
||||
*/
|
||||
template <typename T> class sk_sp {
|
||||
public:
|
||||
using element_type = T;
|
||||
|
||||
constexpr sk_sp() : fPtr(nullptr) {}
|
||||
constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {}
|
||||
|
||||
/**
|
||||
* Shares the underlying object by calling ref(), so that both the argument and the newly
|
||||
* created sk_sp both have a reference to it.
|
||||
*/
|
||||
sk_sp(const sk_sp<T>& that) : fPtr(SkSafeRef(that.get())) {}
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<std::is_convertible<U*, T*>::value>::type>
|
||||
sk_sp(const sk_sp<U>& that) : fPtr(SkSafeRef(that.get())) {}
|
||||
|
||||
/**
|
||||
* Move the underlying object from the argument to the newly created sk_sp. Afterwards only
|
||||
* the new sk_sp will have a reference to the object, and the argument will point to null.
|
||||
* No call to ref() or unref() will be made.
|
||||
*/
|
||||
sk_sp(sk_sp<T>&& that) : fPtr(that.release()) {}
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<std::is_convertible<U*, T*>::value>::type>
|
||||
sk_sp(sk_sp<U>&& that) : fPtr(that.release()) {}
|
||||
|
||||
/**
|
||||
* Adopt the bare pointer into the newly created sk_sp.
|
||||
* No call to ref() or unref() will be made.
|
||||
*/
|
||||
explicit sk_sp(T* obj) : fPtr(obj) {}
|
||||
|
||||
/**
|
||||
* Calls unref() on the underlying object pointer.
|
||||
*/
|
||||
~sk_sp() {
|
||||
SkSafeUnref(fPtr);
|
||||
SkDEBUGCODE(fPtr = nullptr);
|
||||
}
|
||||
|
||||
sk_sp<T>& operator=(std::nullptr_t) { this->reset(); return *this; }
|
||||
|
||||
/**
|
||||
* Shares the underlying object referenced by the argument by calling ref() on it. If this
|
||||
* sk_sp previously had a reference to an object (i.e. not null) it will call unref() on that
|
||||
* object.
|
||||
*/
|
||||
sk_sp<T>& operator=(const sk_sp<T>& that) {
|
||||
if (this != &that) {
|
||||
this->reset(SkSafeRef(that.get()));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<std::is_convertible<U*, T*>::value>::type>
|
||||
sk_sp<T>& operator=(const sk_sp<U>& that) {
|
||||
this->reset(SkSafeRef(that.get()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the underlying object from the argument to the sk_sp. If the sk_sp previously held
|
||||
* a reference to another object, unref() will be called on that object. No call to ref()
|
||||
* will be made.
|
||||
*/
|
||||
sk_sp<T>& operator=(sk_sp<T>&& that) {
|
||||
this->reset(that.release());
|
||||
return *this;
|
||||
}
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<std::is_convertible<U*, T*>::value>::type>
|
||||
sk_sp<T>& operator=(sk_sp<U>&& that) {
|
||||
this->reset(that.release());
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& operator*() const {
|
||||
SkASSERT(this->get() != nullptr);
|
||||
return *this->get();
|
||||
}
|
||||
|
||||
explicit operator bool() const { return this->get() != nullptr; }
|
||||
|
||||
T* get() const { return fPtr; }
|
||||
T* operator->() const { return fPtr; }
|
||||
|
||||
/**
|
||||
* Adopt the new bare pointer, and call unref() on any previously held object (if not null).
|
||||
* No call to ref() will be made.
|
||||
*/
|
||||
void reset(T* ptr = nullptr) {
|
||||
// Calling fPtr->unref() may call this->~() or this->reset(T*).
|
||||
// http://wg21.cmeerw.net/lwg/issue998
|
||||
// http://wg21.cmeerw.net/lwg/issue2262
|
||||
T* oldPtr = fPtr;
|
||||
fPtr = ptr;
|
||||
SkSafeUnref(oldPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bare pointer, and set the internal object pointer to nullptr.
|
||||
* The caller must assume ownership of the object, and manage its reference count directly.
|
||||
* No call to unref() will be made.
|
||||
*/
|
||||
T* SK_WARN_UNUSED_RESULT release() {
|
||||
T* ptr = fPtr;
|
||||
fPtr = nullptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void swap(sk_sp<T>& that) /*noexcept*/ {
|
||||
using std::swap;
|
||||
swap(fPtr, that.fPtr);
|
||||
}
|
||||
|
||||
private:
|
||||
T* fPtr;
|
||||
};
|
||||
|
||||
template <typename T> inline void swap(sk_sp<T>& a, sk_sp<T>& b) /*noexcept*/ {
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
template <typename T, typename U> inline bool operator==(const sk_sp<T>& a, const sk_sp<U>& b) {
|
||||
return a.get() == b.get();
|
||||
}
|
||||
template <typename T> inline bool operator==(const sk_sp<T>& a, std::nullptr_t) /*noexcept*/ {
|
||||
return !a;
|
||||
}
|
||||
template <typename T> inline bool operator==(std::nullptr_t, const sk_sp<T>& b) /*noexcept*/ {
|
||||
return !b;
|
||||
}
|
||||
|
||||
template <typename T, typename U> inline bool operator!=(const sk_sp<T>& a, const sk_sp<U>& b) {
|
||||
return a.get() != b.get();
|
||||
}
|
||||
template <typename T> inline bool operator!=(const sk_sp<T>& a, std::nullptr_t) /*noexcept*/ {
|
||||
return static_cast<bool>(a);
|
||||
}
|
||||
template <typename T> inline bool operator!=(std::nullptr_t, const sk_sp<T>& b) /*noexcept*/ {
|
||||
return static_cast<bool>(b);
|
||||
}
|
||||
|
||||
template <typename C, typename CT, typename T>
|
||||
auto operator<<(std::basic_ostream<C, CT>& os, const sk_sp<T>& sp) -> decltype(os << sp.get()) {
|
||||
return os << sp.get();
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
sk_sp<T> sk_make_sp(Args&&... args) {
|
||||
return sk_sp<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a sk_sp wrapping the provided ptr AND calls ref on it (if not null).
|
||||
*
|
||||
* This is different than the semantics of the constructor for sk_sp, which just wraps the ptr,
|
||||
* effectively "adopting" it.
|
||||
*/
|
||||
template <typename T> sk_sp<T> sk_ref_sp(T* obj) {
|
||||
return sk_sp<T>(SkSafeRef(obj));
|
||||
}
|
||||
|
||||
template <typename T> sk_sp<T> sk_ref_sp(const T* obj) {
|
||||
return sk_sp<T>(const_cast<T*>(SkSafeRef(obj)));
|
||||
}
|
||||
|
||||
#endif
|
||||
672
src/deps/skia/include/core/SkRegion.h
Normal file
672
src/deps/skia/include/core/SkRegion.h
Normal file
@@ -0,0 +1,672 @@
|
||||
/*
|
||||
* Copyright 2005 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkRegion_DEFINED
|
||||
#define SkRegion_DEFINED
|
||||
|
||||
#include "include/core/SkRect.h"
|
||||
|
||||
class SkPath;
|
||||
class SkRgnBuilder;
|
||||
|
||||
/** \class SkRegion
|
||||
SkRegion describes the set of pixels used to clip SkCanvas. SkRegion is compact,
|
||||
efficiently storing a single integer rectangle, or a run length encoded array
|
||||
of rectangles. SkRegion may reduce the current SkCanvas clip, or may be drawn as
|
||||
one or more integer rectangles. SkRegion iterator returns the scan lines or
|
||||
rectangles contained by it, optionally intersecting a bounding rectangle.
|
||||
*/
|
||||
class SK_API SkRegion {
|
||||
typedef int32_t RunType;
|
||||
public:
|
||||
|
||||
/** Constructs an empty SkRegion. SkRegion is set to empty bounds
|
||||
at (0, 0) with zero width and height.
|
||||
|
||||
@return empty SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_empty_constructor
|
||||
*/
|
||||
SkRegion();
|
||||
|
||||
/** Constructs a copy of an existing region.
|
||||
Copy constructor makes two regions identical by value. Internally, region and
|
||||
the returned result share pointer values. The underlying SkRect array is
|
||||
copied when modified.
|
||||
|
||||
Creating a SkRegion copy is very efficient and never allocates memory.
|
||||
SkRegion are always copied by value from the interface; the underlying shared
|
||||
pointers are not exposed.
|
||||
|
||||
@param region SkRegion to copy by value
|
||||
@return copy of SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_copy_const_SkRegion
|
||||
*/
|
||||
SkRegion(const SkRegion& region);
|
||||
|
||||
/** Constructs a rectangular SkRegion matching the bounds of rect.
|
||||
|
||||
@param rect bounds of constructed SkRegion
|
||||
@return rectangular SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_copy_const_SkIRect
|
||||
*/
|
||||
explicit SkRegion(const SkIRect& rect);
|
||||
|
||||
/** Releases ownership of any shared data and deletes data if SkRegion is sole owner.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_destructor
|
||||
*/
|
||||
~SkRegion();
|
||||
|
||||
/** Constructs a copy of an existing region.
|
||||
Makes two regions identical by value. Internally, region and
|
||||
the returned result share pointer values. The underlying SkRect array is
|
||||
copied when modified.
|
||||
|
||||
Creating a SkRegion copy is very efficient and never allocates memory.
|
||||
SkRegion are always copied by value from the interface; the underlying shared
|
||||
pointers are not exposed.
|
||||
|
||||
@param region SkRegion to copy by value
|
||||
@return SkRegion to copy by value
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_copy_operator
|
||||
*/
|
||||
SkRegion& operator=(const SkRegion& region);
|
||||
|
||||
/** Compares SkRegion and other; returns true if they enclose exactly
|
||||
the same area.
|
||||
|
||||
@param other SkRegion to compare
|
||||
@return true if SkRegion pair are equivalent
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_equal1_operator
|
||||
*/
|
||||
bool operator==(const SkRegion& other) const;
|
||||
|
||||
/** Compares SkRegion and other; returns true if they do not enclose the same area.
|
||||
|
||||
@param other SkRegion to compare
|
||||
@return true if SkRegion pair are not equivalent
|
||||
*/
|
||||
bool operator!=(const SkRegion& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/** Sets SkRegion to src, and returns true if src bounds is not empty.
|
||||
This makes SkRegion and src identical by value. Internally,
|
||||
SkRegion and src share pointer values. The underlying SkRect array is
|
||||
copied when modified.
|
||||
|
||||
Creating a SkRegion copy is very efficient and never allocates memory.
|
||||
SkRegion are always copied by value from the interface; the underlying shared
|
||||
pointers are not exposed.
|
||||
|
||||
@param src SkRegion to copy
|
||||
@return copy of src
|
||||
*/
|
||||
bool set(const SkRegion& src) {
|
||||
*this = src;
|
||||
return !this->isEmpty();
|
||||
}
|
||||
|
||||
/** Exchanges SkIRect array of SkRegion and other. swap() internally exchanges pointers,
|
||||
so it is lightweight and does not allocate memory.
|
||||
|
||||
swap() usage has largely been replaced by operator=(const SkRegion& region).
|
||||
SkPath do not copy their content on assignment until they are written to,
|
||||
making assignment as efficient as swap().
|
||||
|
||||
@param other operator=(const SkRegion& region) set
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_swap
|
||||
*/
|
||||
void swap(SkRegion& other);
|
||||
|
||||
/** Returns true if SkRegion is empty.
|
||||
Empty SkRegion has bounds width or height less than or equal to zero.
|
||||
SkRegion() constructs empty SkRegion; setEmpty()
|
||||
and setRect() with dimensionless data make SkRegion empty.
|
||||
|
||||
@return true if bounds has no width or height
|
||||
*/
|
||||
bool isEmpty() const { return fRunHead == emptyRunHeadPtr(); }
|
||||
|
||||
/** Returns true if SkRegion is one SkIRect with positive dimensions.
|
||||
|
||||
@return true if SkRegion contains one SkIRect
|
||||
*/
|
||||
bool isRect() const { return fRunHead == kRectRunHeadPtr; }
|
||||
|
||||
/** Returns true if SkRegion is described by more than one rectangle.
|
||||
|
||||
@return true if SkRegion contains more than one SkIRect
|
||||
*/
|
||||
bool isComplex() const { return !this->isEmpty() && !this->isRect(); }
|
||||
|
||||
/** Returns minimum and maximum axes values of SkIRect array.
|
||||
Returns (0, 0, 0, 0) if SkRegion is empty.
|
||||
|
||||
@return combined bounds of all SkIRect elements
|
||||
*/
|
||||
const SkIRect& getBounds() const { return fBounds; }
|
||||
|
||||
/** Returns a value that increases with the number of
|
||||
elements in SkRegion. Returns zero if SkRegion is empty.
|
||||
Returns one if SkRegion equals SkIRect; otherwise, returns
|
||||
value greater than one indicating that SkRegion is complex.
|
||||
|
||||
Call to compare SkRegion for relative complexity.
|
||||
|
||||
@return relative complexity
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_computeRegionComplexity
|
||||
*/
|
||||
int computeRegionComplexity() const;
|
||||
|
||||
/** Appends outline of SkRegion to path.
|
||||
Returns true if SkRegion is not empty; otherwise, returns false, and leaves path
|
||||
unmodified.
|
||||
|
||||
@param path SkPath to append to
|
||||
@return true if path changed
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_getBoundaryPath
|
||||
*/
|
||||
bool getBoundaryPath(SkPath* path) const;
|
||||
|
||||
/** Constructs an empty SkRegion. SkRegion is set to empty bounds
|
||||
at (0, 0) with zero width and height. Always returns false.
|
||||
|
||||
@return false
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_setEmpty
|
||||
*/
|
||||
bool setEmpty();
|
||||
|
||||
/** Constructs a rectangular SkRegion matching the bounds of rect.
|
||||
If rect is empty, constructs empty and returns false.
|
||||
|
||||
@param rect bounds of constructed SkRegion
|
||||
@return true if rect is not empty
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_setRect
|
||||
*/
|
||||
bool setRect(const SkIRect& rect);
|
||||
|
||||
/** Constructs SkRegion as the union of SkIRect in rects array. If count is
|
||||
zero, constructs empty SkRegion. Returns false if constructed SkRegion is empty.
|
||||
|
||||
May be faster than repeated calls to op().
|
||||
|
||||
@param rects array of SkIRect
|
||||
@param count array size
|
||||
@return true if constructed SkRegion is not empty
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_setRects
|
||||
*/
|
||||
bool setRects(const SkIRect rects[], int count);
|
||||
|
||||
/** Constructs a copy of an existing region.
|
||||
Makes two regions identical by value. Internally, region and
|
||||
the returned result share pointer values. The underlying SkRect array is
|
||||
copied when modified.
|
||||
|
||||
Creating a SkRegion copy is very efficient and never allocates memory.
|
||||
SkRegion are always copied by value from the interface; the underlying shared
|
||||
pointers are not exposed.
|
||||
|
||||
@param region SkRegion to copy by value
|
||||
@return SkRegion to copy by value
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_setRegion
|
||||
*/
|
||||
bool setRegion(const SkRegion& region);
|
||||
|
||||
/** Constructs SkRegion to match outline of path within clip.
|
||||
Returns false if constructed SkRegion is empty.
|
||||
|
||||
Constructed SkRegion draws the same pixels as path through clip when
|
||||
anti-aliasing is disabled.
|
||||
|
||||
@param path SkPath providing outline
|
||||
@param clip SkRegion containing path
|
||||
@return true if constructed SkRegion is not empty
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_setPath
|
||||
*/
|
||||
bool setPath(const SkPath& path, const SkRegion& clip);
|
||||
|
||||
/** Returns true if SkRegion intersects rect.
|
||||
Returns false if either rect or SkRegion is empty, or do not intersect.
|
||||
|
||||
@param rect SkIRect to intersect
|
||||
@return true if rect and SkRegion have area in common
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_intersects
|
||||
*/
|
||||
bool intersects(const SkIRect& rect) const;
|
||||
|
||||
/** Returns true if SkRegion intersects other.
|
||||
Returns false if either other or SkRegion is empty, or do not intersect.
|
||||
|
||||
@param other SkRegion to intersect
|
||||
@return true if other and SkRegion have area in common
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_intersects_2
|
||||
*/
|
||||
bool intersects(const SkRegion& other) const;
|
||||
|
||||
/** Returns true if SkIPoint (x, y) is inside SkRegion.
|
||||
Returns false if SkRegion is empty.
|
||||
|
||||
@param x test SkIPoint x-coordinate
|
||||
@param y test SkIPoint y-coordinate
|
||||
@return true if (x, y) is inside SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_contains
|
||||
*/
|
||||
bool contains(int32_t x, int32_t y) const;
|
||||
|
||||
/** Returns true if other is completely inside SkRegion.
|
||||
Returns false if SkRegion or other is empty.
|
||||
|
||||
@param other SkIRect to contain
|
||||
@return true if other is inside SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_contains_2
|
||||
*/
|
||||
bool contains(const SkIRect& other) const;
|
||||
|
||||
/** Returns true if other is completely inside SkRegion.
|
||||
Returns false if SkRegion or other is empty.
|
||||
|
||||
@param other SkRegion to contain
|
||||
@return true if other is inside SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_contains_3
|
||||
*/
|
||||
bool contains(const SkRegion& other) const;
|
||||
|
||||
/** Returns true if SkRegion is a single rectangle and contains r.
|
||||
May return false even though SkRegion contains r.
|
||||
|
||||
@param r SkIRect to contain
|
||||
@return true quickly if r points are equal or inside
|
||||
*/
|
||||
bool quickContains(const SkIRect& r) const {
|
||||
SkASSERT(this->isEmpty() == fBounds.isEmpty()); // valid region
|
||||
|
||||
return r.fLeft < r.fRight && r.fTop < r.fBottom &&
|
||||
fRunHead == kRectRunHeadPtr && // this->isRect()
|
||||
/* fBounds.contains(left, top, right, bottom); */
|
||||
fBounds.fLeft <= r.fLeft && fBounds.fTop <= r.fTop &&
|
||||
fBounds.fRight >= r.fRight && fBounds.fBottom >= r.fBottom;
|
||||
}
|
||||
|
||||
/** Returns true if SkRegion does not intersect rect.
|
||||
Returns true if rect is empty or SkRegion is empty.
|
||||
May return false even though SkRegion does not intersect rect.
|
||||
|
||||
@param rect SkIRect to intersect
|
||||
@return true if rect does not intersect
|
||||
*/
|
||||
bool quickReject(const SkIRect& rect) const {
|
||||
return this->isEmpty() || rect.isEmpty() ||
|
||||
!SkIRect::Intersects(fBounds, rect);
|
||||
}
|
||||
|
||||
/** Returns true if SkRegion does not intersect rgn.
|
||||
Returns true if rgn is empty or SkRegion is empty.
|
||||
May return false even though SkRegion does not intersect rgn.
|
||||
|
||||
@param rgn SkRegion to intersect
|
||||
@return true if rgn does not intersect
|
||||
*/
|
||||
bool quickReject(const SkRegion& rgn) const {
|
||||
return this->isEmpty() || rgn.isEmpty() ||
|
||||
!SkIRect::Intersects(fBounds, rgn.fBounds);
|
||||
}
|
||||
|
||||
/** Offsets SkRegion by ivector (dx, dy). Has no effect if SkRegion is empty.
|
||||
|
||||
@param dx x-axis offset
|
||||
@param dy y-axis offset
|
||||
*/
|
||||
void translate(int dx, int dy) { this->translate(dx, dy, this); }
|
||||
|
||||
/** Offsets SkRegion by ivector (dx, dy), writing result to dst. SkRegion may be passed
|
||||
as dst parameter, translating SkRegion in place. Has no effect if dst is nullptr.
|
||||
If SkRegion is empty, sets dst to empty.
|
||||
|
||||
@param dx x-axis offset
|
||||
@param dy y-axis offset
|
||||
@param dst translated result
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_translate_2
|
||||
*/
|
||||
void translate(int dx, int dy, SkRegion* dst) const;
|
||||
|
||||
/** \enum SkRegion::Op
|
||||
The logical operations that can be performed when combining two SkRegion.
|
||||
*/
|
||||
enum Op {
|
||||
kDifference_Op, //!< target minus operand
|
||||
kIntersect_Op, //!< target intersected with operand
|
||||
kUnion_Op, //!< target unioned with operand
|
||||
kXOR_Op, //!< target exclusive or with operand
|
||||
kReverseDifference_Op, //!< operand minus target
|
||||
kReplace_Op, //!< replace target with operand
|
||||
kLastOp = kReplace_Op, //!< last operator
|
||||
};
|
||||
|
||||
static const int kOpCnt = kLastOp + 1;
|
||||
|
||||
/** Replaces SkRegion with the result of SkRegion op rect.
|
||||
Returns true if replaced SkRegion is not empty.
|
||||
|
||||
@param rect SkIRect operand
|
||||
@return false if result is empty
|
||||
*/
|
||||
bool op(const SkIRect& rect, Op op) {
|
||||
if (this->isRect() && kIntersect_Op == op) {
|
||||
if (!fBounds.intersect(rect)) {
|
||||
return this->setEmpty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return this->op(*this, rect, op);
|
||||
}
|
||||
|
||||
/** Replaces SkRegion with the result of SkRegion op rgn.
|
||||
Returns true if replaced SkRegion is not empty.
|
||||
|
||||
@param rgn SkRegion operand
|
||||
@return false if result is empty
|
||||
*/
|
||||
bool op(const SkRegion& rgn, Op op) { return this->op(*this, rgn, op); }
|
||||
|
||||
/** Replaces SkRegion with the result of rect op rgn.
|
||||
Returns true if replaced SkRegion is not empty.
|
||||
|
||||
@param rect SkIRect operand
|
||||
@param rgn SkRegion operand
|
||||
@return false if result is empty
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_op_4
|
||||
*/
|
||||
bool op(const SkIRect& rect, const SkRegion& rgn, Op op);
|
||||
|
||||
/** Replaces SkRegion with the result of rgn op rect.
|
||||
Returns true if replaced SkRegion is not empty.
|
||||
|
||||
@param rgn SkRegion operand
|
||||
@param rect SkIRect operand
|
||||
@return false if result is empty
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_op_5
|
||||
*/
|
||||
bool op(const SkRegion& rgn, const SkIRect& rect, Op op);
|
||||
|
||||
/** Replaces SkRegion with the result of rgna op rgnb.
|
||||
Returns true if replaced SkRegion is not empty.
|
||||
|
||||
@param rgna SkRegion operand
|
||||
@param rgnb SkRegion operand
|
||||
@return false if result is empty
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_op_6
|
||||
*/
|
||||
bool op(const SkRegion& rgna, const SkRegion& rgnb, Op op);
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
/** Private. Android framework only.
|
||||
|
||||
@return string representation of SkRegion
|
||||
*/
|
||||
char* toString();
|
||||
#endif
|
||||
|
||||
/** \class SkRegion::Iterator
|
||||
Returns sequence of rectangles, sorted along y-axis, then x-axis, that make
|
||||
up SkRegion.
|
||||
*/
|
||||
class SK_API Iterator {
|
||||
public:
|
||||
|
||||
/** Initializes SkRegion::Iterator with an empty SkRegion. done() on SkRegion::Iterator
|
||||
returns true.
|
||||
Call reset() to initialized SkRegion::Iterator at a later time.
|
||||
|
||||
@return empty SkRegion iterator
|
||||
*/
|
||||
Iterator() : fRgn(nullptr), fDone(true) {}
|
||||
|
||||
/** Sets SkRegion::Iterator to return elements of SkIRect array in region.
|
||||
|
||||
@param region SkRegion to iterate
|
||||
@return SkRegion iterator
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Iterator_copy_const_SkRegion
|
||||
*/
|
||||
Iterator(const SkRegion& region);
|
||||
|
||||
/** SkPoint SkRegion::Iterator to start of SkRegion.
|
||||
Returns true if SkRegion was set; otherwise, returns false.
|
||||
|
||||
@return true if SkRegion was set
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Iterator_rewind
|
||||
*/
|
||||
bool rewind();
|
||||
|
||||
/** Resets iterator, using the new SkRegion.
|
||||
|
||||
@param region SkRegion to iterate
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Iterator_reset
|
||||
*/
|
||||
void reset(const SkRegion& region);
|
||||
|
||||
/** Returns true if SkRegion::Iterator is pointing to final SkIRect in SkRegion.
|
||||
|
||||
@return true if data parsing is complete
|
||||
*/
|
||||
bool done() const { return fDone; }
|
||||
|
||||
/** Advances SkRegion::Iterator to next SkIRect in SkRegion if it is not done.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Iterator_next
|
||||
*/
|
||||
void next();
|
||||
|
||||
/** Returns SkIRect element in SkRegion. Does not return predictable results if SkRegion
|
||||
is empty.
|
||||
|
||||
@return part of SkRegion as SkIRect
|
||||
*/
|
||||
const SkIRect& rect() const { return fRect; }
|
||||
|
||||
/** Returns SkRegion if set; otherwise, returns nullptr.
|
||||
|
||||
@return iterated SkRegion
|
||||
*/
|
||||
const SkRegion* rgn() const { return fRgn; }
|
||||
|
||||
private:
|
||||
const SkRegion* fRgn;
|
||||
const SkRegion::RunType* fRuns;
|
||||
SkIRect fRect = {0, 0, 0, 0};
|
||||
bool fDone;
|
||||
};
|
||||
|
||||
/** \class SkRegion::Cliperator
|
||||
Returns the sequence of rectangles, sorted along y-axis, then x-axis, that make
|
||||
up SkRegion intersected with the specified clip rectangle.
|
||||
*/
|
||||
class SK_API Cliperator {
|
||||
public:
|
||||
|
||||
/** Sets SkRegion::Cliperator to return elements of SkIRect array in SkRegion within clip.
|
||||
|
||||
@param region SkRegion to iterate
|
||||
@param clip bounds of iteration
|
||||
@return SkRegion iterator
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Cliperator_const_SkRegion_const_SkIRect
|
||||
*/
|
||||
Cliperator(const SkRegion& region, const SkIRect& clip);
|
||||
|
||||
/** Returns true if SkRegion::Cliperator is pointing to final SkIRect in SkRegion.
|
||||
|
||||
@return true if data parsing is complete
|
||||
*/
|
||||
bool done() { return fDone; }
|
||||
|
||||
/** Advances iterator to next SkIRect in SkRegion contained by clip.
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Cliperator_next
|
||||
*/
|
||||
void next();
|
||||
|
||||
/** Returns SkIRect element in SkRegion, intersected with clip passed to
|
||||
SkRegion::Cliperator constructor. Does not return predictable results if SkRegion
|
||||
is empty.
|
||||
|
||||
@return part of SkRegion inside clip as SkIRect
|
||||
*/
|
||||
const SkIRect& rect() const { return fRect; }
|
||||
|
||||
private:
|
||||
Iterator fIter;
|
||||
SkIRect fClip;
|
||||
SkIRect fRect = {0, 0, 0, 0};
|
||||
bool fDone;
|
||||
};
|
||||
|
||||
/** \class SkRegion::Spanerator
|
||||
Returns the line segment ends within SkRegion that intersect a horizontal line.
|
||||
*/
|
||||
class Spanerator {
|
||||
public:
|
||||
|
||||
/** Sets SkRegion::Spanerator to return line segments in SkRegion on scan line.
|
||||
|
||||
@param region SkRegion to iterate
|
||||
@param y horizontal line to intersect
|
||||
@param left bounds of iteration
|
||||
@param right bounds of iteration
|
||||
@return SkRegion iterator
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Spanerator_const_SkRegion_int_int_int
|
||||
*/
|
||||
Spanerator(const SkRegion& region, int y, int left, int right);
|
||||
|
||||
/** Advances iterator to next span intersecting SkRegion within line segment provided
|
||||
in constructor. Returns true if interval was found.
|
||||
|
||||
@param left pointer to span start; may be nullptr
|
||||
@param right pointer to span end; may be nullptr
|
||||
@return true if interval was found
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_Spanerator_next
|
||||
*/
|
||||
bool next(int* left, int* right);
|
||||
|
||||
private:
|
||||
const SkRegion::RunType* fRuns;
|
||||
int fLeft, fRight;
|
||||
bool fDone;
|
||||
};
|
||||
|
||||
/** Writes SkRegion to buffer, and returns number of bytes written.
|
||||
If buffer is nullptr, returns number number of bytes that would be written.
|
||||
|
||||
@param buffer storage for binary data
|
||||
@return size of SkRegion
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_writeToMemory
|
||||
*/
|
||||
size_t writeToMemory(void* buffer) const;
|
||||
|
||||
/** Constructs SkRegion from buffer of size length. Returns bytes read.
|
||||
Returned value will be multiple of four or zero if length was too small.
|
||||
|
||||
@param buffer storage for binary data
|
||||
@param length size of buffer
|
||||
@return bytes read
|
||||
|
||||
example: https://fiddle.skia.org/c/@Region_readFromMemory
|
||||
*/
|
||||
size_t readFromMemory(const void* buffer, size_t length);
|
||||
|
||||
private:
|
||||
static constexpr int kOpCount = kReplace_Op + 1;
|
||||
|
||||
// T
|
||||
// [B N L R S]
|
||||
// S
|
||||
static constexpr int kRectRegionRuns = 7;
|
||||
|
||||
struct RunHead;
|
||||
|
||||
static RunHead* emptyRunHeadPtr() { return (SkRegion::RunHead*) -1; }
|
||||
static constexpr RunHead* kRectRunHeadPtr = nullptr;
|
||||
|
||||
// allocate space for count runs
|
||||
void allocateRuns(int count);
|
||||
void allocateRuns(int count, int ySpanCount, int intervalCount);
|
||||
void allocateRuns(const RunHead& src);
|
||||
|
||||
SkDEBUGCODE(void dump() const;)
|
||||
|
||||
SkIRect fBounds;
|
||||
RunHead* fRunHead;
|
||||
|
||||
void freeRuns();
|
||||
|
||||
/**
|
||||
* Return the runs from this region, consing up fake runs if the region
|
||||
* is empty or a rect. In those 2 cases, we use tmpStorage to hold the
|
||||
* run data.
|
||||
*/
|
||||
const RunType* getRuns(RunType tmpStorage[], int* intervals) const;
|
||||
|
||||
// This is called with runs[] that do not yet have their interval-count
|
||||
// field set on each scanline. That is computed as part of this call
|
||||
// (inside ComputeRunBounds).
|
||||
bool setRuns(RunType runs[], int count);
|
||||
|
||||
int count_runtype_values(int* itop, int* ibot) const;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
static void BuildRectRuns(const SkIRect& bounds,
|
||||
RunType runs[kRectRegionRuns]);
|
||||
|
||||
// If the runs define a simple rect, return true and set bounds to that
|
||||
// rect. If not, return false and ignore bounds.
|
||||
static bool RunsAreARect(const SkRegion::RunType runs[], int count,
|
||||
SkIRect* bounds);
|
||||
|
||||
/**
|
||||
* If the last arg is null, just return if the result is non-empty,
|
||||
* else store the result in the last arg.
|
||||
*/
|
||||
static bool Oper(const SkRegion&, const SkRegion&, SkRegion::Op, SkRegion*);
|
||||
|
||||
friend struct RunHead;
|
||||
friend class Iterator;
|
||||
friend class Spanerator;
|
||||
friend class SkRegionPriv;
|
||||
friend class SkRgnBuilder;
|
||||
friend class SkFlatRegion;
|
||||
};
|
||||
|
||||
#endif
|
||||
92
src/deps/skia/include/core/SkSamplingOptions.h
Normal file
92
src/deps/skia/include/core/SkSamplingOptions.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkImageSampling_DEFINED
|
||||
#define SkImageSampling_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
#include <new>
|
||||
|
||||
enum class SkFilterMode {
|
||||
kNearest, // single sample point (nearest neighbor)
|
||||
kLinear, // interporate between 2x2 sample points (bilinear interpolation)
|
||||
|
||||
kLast = kLinear,
|
||||
};
|
||||
|
||||
enum class SkMipmapMode {
|
||||
kNone, // ignore mipmap levels, sample from the "base"
|
||||
kNearest, // sample from the nearest level
|
||||
kLinear, // interpolate between the two nearest levels
|
||||
|
||||
kLast = kLinear,
|
||||
};
|
||||
|
||||
/*
|
||||
* Specify B and C (each between 0...1) to create a shader that applies the corresponding
|
||||
* cubic reconstruction filter to the image.
|
||||
*
|
||||
* Example values:
|
||||
* B = 1/3, C = 1/3 "Mitchell" filter
|
||||
* B = 0, C = 1/2 "Catmull-Rom" filter
|
||||
*
|
||||
* See "Reconstruction Filters in Computer Graphics"
|
||||
* Don P. Mitchell
|
||||
* Arun N. Netravali
|
||||
* 1988
|
||||
* https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf
|
||||
*
|
||||
* Desmos worksheet https://www.desmos.com/calculator/aghdpicrvr
|
||||
* Nice overview https://entropymine.com/imageworsener/bicubic/
|
||||
*/
|
||||
struct SkCubicResampler {
|
||||
float B, C;
|
||||
|
||||
// Historic default for kHigh_SkFilterQuality
|
||||
static constexpr SkCubicResampler Mitchell() { return {1/3.0f, 1/3.0f}; }
|
||||
static constexpr SkCubicResampler CatmullRom() { return {0.0f, 1/2.0f}; }
|
||||
};
|
||||
|
||||
struct SK_API SkSamplingOptions {
|
||||
const bool useCubic = false;
|
||||
const SkCubicResampler cubic = {0, 0};
|
||||
const SkFilterMode filter = SkFilterMode::kNearest;
|
||||
const SkMipmapMode mipmap = SkMipmapMode::kNone;
|
||||
|
||||
SkSamplingOptions() = default;
|
||||
SkSamplingOptions(const SkSamplingOptions&) = default;
|
||||
SkSamplingOptions& operator=(const SkSamplingOptions& that) {
|
||||
this->~SkSamplingOptions(); // A pedantic no-op.
|
||||
new (this) SkSamplingOptions(that);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkSamplingOptions(SkFilterMode fm, SkMipmapMode mm)
|
||||
: useCubic(false)
|
||||
, filter(fm)
|
||||
, mipmap(mm) {}
|
||||
|
||||
explicit SkSamplingOptions(SkFilterMode fm)
|
||||
: useCubic(false)
|
||||
, filter(fm)
|
||||
, mipmap(SkMipmapMode::kNone) {}
|
||||
|
||||
explicit SkSamplingOptions(const SkCubicResampler& c)
|
||||
: useCubic(true)
|
||||
, cubic(c) {}
|
||||
|
||||
bool operator==(const SkSamplingOptions& other) const {
|
||||
return useCubic == other.useCubic
|
||||
&& cubic.B == other.cubic.B
|
||||
&& cubic.C == other.cubic.C
|
||||
&& filter == other.filter
|
||||
&& mipmap == other.mipmap;
|
||||
}
|
||||
bool operator!=(const SkSamplingOptions& other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
#endif
|
||||
194
src/deps/skia/include/core/SkScalar.h
Normal file
194
src/deps/skia/include/core/SkScalar.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkScalar_DEFINED
|
||||
#define SkScalar_DEFINED
|
||||
|
||||
#include "include/private/SkFloatingPoint.h"
|
||||
|
||||
#undef SK_SCALAR_IS_FLOAT
|
||||
#define SK_SCALAR_IS_FLOAT 1
|
||||
|
||||
typedef float SkScalar;
|
||||
|
||||
#define SK_Scalar1 1.0f
|
||||
#define SK_ScalarHalf 0.5f
|
||||
#define SK_ScalarSqrt2 SK_FloatSqrt2
|
||||
#define SK_ScalarPI SK_FloatPI
|
||||
#define SK_ScalarTanPIOver8 0.414213562f
|
||||
#define SK_ScalarRoot2Over2 0.707106781f
|
||||
#define SK_ScalarMax 3.402823466e+38f
|
||||
#define SK_ScalarInfinity SK_FloatInfinity
|
||||
#define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity
|
||||
#define SK_ScalarNaN SK_FloatNaN
|
||||
|
||||
#define SkScalarFloorToScalar(x) sk_float_floor(x)
|
||||
#define SkScalarCeilToScalar(x) sk_float_ceil(x)
|
||||
#define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f)
|
||||
#define SkScalarTruncToScalar(x) sk_float_trunc(x)
|
||||
|
||||
#define SkScalarFloorToInt(x) sk_float_floor2int(x)
|
||||
#define SkScalarCeilToInt(x) sk_float_ceil2int(x)
|
||||
#define SkScalarRoundToInt(x) sk_float_round2int(x)
|
||||
|
||||
#define SkScalarAbs(x) sk_float_abs(x)
|
||||
#define SkScalarCopySign(x, y) sk_float_copysign(x, y)
|
||||
#define SkScalarMod(x, y) sk_float_mod(x,y)
|
||||
#define SkScalarSqrt(x) sk_float_sqrt(x)
|
||||
#define SkScalarPow(b, e) sk_float_pow(b, e)
|
||||
|
||||
#define SkScalarSin(radians) (float)sk_float_sin(radians)
|
||||
#define SkScalarCos(radians) (float)sk_float_cos(radians)
|
||||
#define SkScalarTan(radians) (float)sk_float_tan(radians)
|
||||
#define SkScalarASin(val) (float)sk_float_asin(val)
|
||||
#define SkScalarACos(val) (float)sk_float_acos(val)
|
||||
#define SkScalarATan2(y, x) (float)sk_float_atan2(y,x)
|
||||
#define SkScalarExp(x) (float)sk_float_exp(x)
|
||||
#define SkScalarLog(x) (float)sk_float_log(x)
|
||||
#define SkScalarLog2(x) (float)sk_float_log2(x)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SkIntToScalar(x) static_cast<SkScalar>(x)
|
||||
#define SkIntToFloat(x) static_cast<float>(x)
|
||||
#define SkScalarTruncToInt(x) sk_float_saturate2int(x)
|
||||
|
||||
#define SkScalarToFloat(x) static_cast<float>(x)
|
||||
#define SkFloatToScalar(x) static_cast<SkScalar>(x)
|
||||
#define SkScalarToDouble(x) static_cast<double>(x)
|
||||
#define SkDoubleToScalar(x) sk_double_to_float(x)
|
||||
|
||||
#define SK_ScalarMin (-SK_ScalarMax)
|
||||
|
||||
static inline bool SkScalarIsNaN(SkScalar x) { return x != x; }
|
||||
|
||||
/** Returns true if x is not NaN and not infinite
|
||||
*/
|
||||
static inline bool SkScalarIsFinite(SkScalar x) { return sk_float_isfinite(x); }
|
||||
|
||||
static inline bool SkScalarsAreFinite(SkScalar a, SkScalar b) {
|
||||
return sk_floats_are_finite(a, b);
|
||||
}
|
||||
|
||||
static inline bool SkScalarsAreFinite(const SkScalar array[], int count) {
|
||||
return sk_floats_are_finite(array, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Variant of SkScalarRoundToInt, that performs the rounding step (adding 0.5) explicitly using
|
||||
* double, to avoid possibly losing the low bit(s) of the answer before calling floor().
|
||||
*
|
||||
* This routine will likely be slower than SkScalarRoundToInt(), and should only be used when the
|
||||
* extra precision is known to be valuable.
|
||||
*
|
||||
* In particular, this catches the following case:
|
||||
* SkScalar x = 0.49999997;
|
||||
* int ix = SkScalarRoundToInt(x);
|
||||
* SkASSERT(0 == ix); // <--- fails
|
||||
* ix = SkDScalarRoundToInt(x);
|
||||
* SkASSERT(0 == ix); // <--- succeeds
|
||||
*/
|
||||
static inline int SkDScalarRoundToInt(SkScalar x) {
|
||||
double xx = x;
|
||||
xx += 0.5;
|
||||
return (int)floor(xx);
|
||||
}
|
||||
|
||||
/** Returns the fractional part of the scalar. */
|
||||
static inline SkScalar SkScalarFraction(SkScalar x) {
|
||||
return x - SkScalarTruncToScalar(x);
|
||||
}
|
||||
|
||||
static inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
|
||||
|
||||
#define SkScalarInvert(x) sk_ieee_float_divide_TODO_IS_DIVIDE_BY_ZERO_SAFE_HERE(SK_Scalar1, (x))
|
||||
#define SkScalarAve(a, b) (((a) + (b)) * SK_ScalarHalf)
|
||||
#define SkScalarHalf(a) ((a) * SK_ScalarHalf)
|
||||
|
||||
#define SkDegreesToRadians(degrees) ((degrees) * (SK_ScalarPI / 180))
|
||||
#define SkRadiansToDegrees(radians) ((radians) * (180 / SK_ScalarPI))
|
||||
|
||||
static inline bool SkScalarIsInt(SkScalar x) {
|
||||
return x == SkScalarFloorToScalar(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns -1 || 0 || 1 depending on the sign of value:
|
||||
* -1 if x < 0
|
||||
* 0 if x == 0
|
||||
* 1 if x > 0
|
||||
*/
|
||||
static inline int SkScalarSignAsInt(SkScalar x) {
|
||||
return x < 0 ? -1 : (x > 0);
|
||||
}
|
||||
|
||||
// Scalar result version of above
|
||||
static inline SkScalar SkScalarSignAsScalar(SkScalar x) {
|
||||
return x < 0 ? -SK_Scalar1 : ((x > 0) ? SK_Scalar1 : 0);
|
||||
}
|
||||
|
||||
#define SK_ScalarNearlyZero (SK_Scalar1 / (1 << 12))
|
||||
|
||||
static inline bool SkScalarNearlyZero(SkScalar x,
|
||||
SkScalar tolerance = SK_ScalarNearlyZero) {
|
||||
SkASSERT(tolerance >= 0);
|
||||
return SkScalarAbs(x) <= tolerance;
|
||||
}
|
||||
|
||||
static inline bool SkScalarNearlyEqual(SkScalar x, SkScalar y,
|
||||
SkScalar tolerance = SK_ScalarNearlyZero) {
|
||||
SkASSERT(tolerance >= 0);
|
||||
return SkScalarAbs(x-y) <= tolerance;
|
||||
}
|
||||
|
||||
static inline float SkScalarSinSnapToZero(SkScalar radians) {
|
||||
float v = SkScalarSin(radians);
|
||||
return SkScalarNearlyZero(v) ? 0.0f : v;
|
||||
}
|
||||
|
||||
static inline float SkScalarCosSnapToZero(SkScalar radians) {
|
||||
float v = SkScalarCos(radians);
|
||||
return SkScalarNearlyZero(v) ? 0.0f : v;
|
||||
}
|
||||
|
||||
/** Linearly interpolate between A and B, based on t.
|
||||
If t is 0, return A
|
||||
If t is 1, return B
|
||||
else interpolate.
|
||||
t must be [0..SK_Scalar1]
|
||||
*/
|
||||
static inline SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t) {
|
||||
SkASSERT(t >= 0 && t <= SK_Scalar1);
|
||||
return A + (B - A) * t;
|
||||
}
|
||||
|
||||
/** Interpolate along the function described by (keys[length], values[length])
|
||||
for the passed searchKey. SearchKeys outside the range keys[0]-keys[Length]
|
||||
clamp to the min or max value. This function assumes the number of pairs
|
||||
(length) will be small and a linear search is used.
|
||||
|
||||
Repeated keys are allowed for discontinuous functions (so long as keys is
|
||||
monotonically increasing). If key is the value of a repeated scalar in
|
||||
keys the first one will be used.
|
||||
*/
|
||||
SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
|
||||
const SkScalar values[], int length);
|
||||
|
||||
/*
|
||||
* Helper to compare an array of scalars.
|
||||
*/
|
||||
static inline bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n) {
|
||||
SkASSERT(n >= 0);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (a[i] != b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
73
src/deps/skia/include/core/SkSerialProcs.h
Normal file
73
src/deps/skia/include/core/SkSerialProcs.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkSerialProcs_DEFINED
|
||||
#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).
|
||||
* If a data object is returned, it will be used (even if it is zero-length).
|
||||
* If null is returned, then Skia will take its default action.
|
||||
*
|
||||
* The default action for pictures is to use Skia's internal format.
|
||||
* The default action for images is to encode either in its native format or PNG.
|
||||
* The default action for typefaces is to use Skia's internal format.
|
||||
*/
|
||||
|
||||
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
|
||||
* SkSerialPictureProc proc). Return a picture object, or nullptr indicating failure.
|
||||
*/
|
||||
typedef sk_sp<SkPicture> (*SkDeserialPictureProc)(const void* data, size_t length, void* ctx);
|
||||
|
||||
/**
|
||||
* Called with the encoded from of an image. The proc can return an image object, or if it
|
||||
* returns nullptr, then Skia will take its default action to try to create an image from the data.
|
||||
*
|
||||
* Note that unlike SkDeserialPictureProc and SkDeserialTypefaceProc, return nullptr from this
|
||||
* does not indicate failure, but is a signal for Skia to take its default action.
|
||||
*/
|
||||
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;
|
||||
|
||||
SkSerialImageProc fImageProc = nullptr;
|
||||
void* fImageCtx = nullptr;
|
||||
|
||||
SkSerialTypefaceProc fTypefaceProc = nullptr;
|
||||
void* fTypefaceCtx = nullptr;
|
||||
};
|
||||
|
||||
struct SK_API SkDeserialProcs {
|
||||
SkDeserialPictureProc fPictureProc = nullptr;
|
||||
void* fPictureCtx = nullptr;
|
||||
|
||||
SkDeserialImageProc fImageProc = nullptr;
|
||||
void* fImageCtx = nullptr;
|
||||
|
||||
SkDeserialTypefaceProc fTypefaceProc = nullptr;
|
||||
void* fTypefaceCtx = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
148
src/deps/skia/include/core/SkShader.h
Normal file
148
src/deps/skia/include/core/SkShader.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkShader_DEFINED
|
||||
#define SkShader_DEFINED
|
||||
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkFlattenable.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkTileMode.h"
|
||||
|
||||
class SkArenaAlloc;
|
||||
class SkBitmap;
|
||||
class SkBlender;
|
||||
class SkColorFilter;
|
||||
class SkColorSpace;
|
||||
class SkImage;
|
||||
class SkPath;
|
||||
class SkPicture;
|
||||
class SkRasterPipeline;
|
||||
class GrFragmentProcessor;
|
||||
|
||||
/** \class SkShader
|
||||
*
|
||||
* Shaders specify the source color(s) for what is being drawn. If a paint
|
||||
* has no shader, then the paint's color is used. If the paint has a
|
||||
* shader, then the shader's color(s) are use instead, but they are
|
||||
* modulated by the paint's alpha. This makes it easy to create a shader
|
||||
* once (e.g. bitmap tiling or gradient) and then change its transparency
|
||||
* w/o having to modify the original shader... only the paint's alpha needs
|
||||
* to be modified.
|
||||
*/
|
||||
class SK_API SkShader : public SkFlattenable {
|
||||
public:
|
||||
/**
|
||||
* Returns true if the shader is guaranteed to produce only opaque
|
||||
* colors, subject to the SkPaint using the shader to apply an opaque
|
||||
* alpha value. Subclasses should override this to allow some
|
||||
* optimizations.
|
||||
*/
|
||||
virtual bool isOpaque() const { return false; }
|
||||
|
||||
/**
|
||||
* Iff this shader is backed by a single SkImage, return its ptr (the caller must ref this
|
||||
* if they want to keep it longer than the lifetime of the shader). If not, return nullptr.
|
||||
*/
|
||||
SkImage* isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const;
|
||||
|
||||
bool isAImage() const {
|
||||
return this->isAImage(nullptr, (SkTileMode*)nullptr) != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the shader subclass can be represented as a gradient, asAGradient
|
||||
* returns the matching GradientType enum (or kNone_GradientType if it
|
||||
* cannot). Also, if info is not null, asAGradient populates info with
|
||||
* the relevant (see below) parameters for the gradient. fColorCount
|
||||
* is both an input and output parameter. On input, it indicates how
|
||||
* many entries in fColors and fColorOffsets can be used, if they are
|
||||
* non-NULL. After asAGradient has run, fColorCount indicates how
|
||||
* many color-offset pairs there are in the gradient. If there is
|
||||
* insufficient space to store all of the color-offset pairs, fColors
|
||||
* and fColorOffsets will not be altered. fColorOffsets specifies
|
||||
* where on the range of 0 to 1 to transition to the given color.
|
||||
* The meaning of fPoint and fRadius is dependant on the type of gradient.
|
||||
*
|
||||
* None:
|
||||
* info is ignored.
|
||||
* Color:
|
||||
* fColorOffsets[0] is meaningless.
|
||||
* Linear:
|
||||
* fPoint[0] and fPoint[1] are the end-points of the gradient
|
||||
* Radial:
|
||||
* fPoint[0] and fRadius[0] are the center and radius
|
||||
* Conical:
|
||||
* fPoint[0] and fRadius[0] are the center and radius of the 1st circle
|
||||
* fPoint[1] and fRadius[1] are the center and radius of the 2nd circle
|
||||
* Sweep:
|
||||
* fPoint[0] is the center of the sweep.
|
||||
*/
|
||||
|
||||
enum GradientType {
|
||||
kNone_GradientType,
|
||||
kColor_GradientType,
|
||||
kLinear_GradientType,
|
||||
kRadial_GradientType,
|
||||
kSweep_GradientType,
|
||||
kConical_GradientType,
|
||||
kLast_GradientType = kConical_GradientType,
|
||||
};
|
||||
|
||||
struct GradientInfo {
|
||||
int fColorCount; //!< In-out parameter, specifies passed size
|
||||
// of fColors/fColorOffsets on input, and
|
||||
// actual number of colors/offsets on
|
||||
// output.
|
||||
SkColor* fColors; //!< The colors in the gradient.
|
||||
SkScalar* fColorOffsets; //!< The unit offset for color transitions.
|
||||
SkPoint fPoint[2]; //!< Type specific, see above.
|
||||
SkScalar fRadius[2]; //!< Type specific, see above.
|
||||
SkTileMode fTileMode;
|
||||
uint32_t fGradientFlags; //!< see SkGradientShader::Flags
|
||||
};
|
||||
|
||||
// DEPRECATED. skbug.com/8941
|
||||
virtual GradientType asAGradient(GradientInfo* info) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Methods to create combinations or variants of shaders
|
||||
|
||||
/**
|
||||
* Return a shader that will apply the specified localMatrix to this shader.
|
||||
* The specified matrix will be applied before any matrix associated with this shader.
|
||||
*/
|
||||
sk_sp<SkShader> makeWithLocalMatrix(const SkMatrix&) const;
|
||||
|
||||
/**
|
||||
* Create a new shader that produces the same colors as invoking this shader and then applying
|
||||
* the colorfilter.
|
||||
*/
|
||||
sk_sp<SkShader> makeWithColorFilter(sk_sp<SkColorFilter>) const;
|
||||
|
||||
private:
|
||||
SkShader() = default;
|
||||
friend class SkShaderBase;
|
||||
|
||||
using INHERITED = SkFlattenable;
|
||||
};
|
||||
|
||||
class SK_API SkShaders {
|
||||
public:
|
||||
static sk_sp<SkShader> Empty();
|
||||
static sk_sp<SkShader> Color(SkColor);
|
||||
static sk_sp<SkShader> Color(const SkColor4f&, sk_sp<SkColorSpace>);
|
||||
static sk_sp<SkShader> Blend(SkBlendMode mode, sk_sp<SkShader> dst, sk_sp<SkShader> src);
|
||||
static sk_sp<SkShader> Blend(sk_sp<SkBlender>, sk_sp<SkShader> dst, sk_sp<SkShader> src);
|
||||
|
||||
private:
|
||||
SkShaders() = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user