remove unused SkRasterizer

Bug: skia:7500
Change-Id: Iaa683cf8f0b18887cce4ec676631d1e1efee1712
Reviewed-on: https://skia-review.googlesource.com/97400
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-01-19 19:09:32 -05:00 committed by Skia Commit-Bot
parent 07853659fa
commit 8ad91a9bf8
41 changed files with 67 additions and 1565 deletions

View File

@ -3095,7 +3095,7 @@ any cached data is deleted when owning Surface or Device is deleted.
#Method void drawPaint(const SkPaint& paint)
Fill Clip with Paint paint. Paint components Rasterizer, Mask_Filter, Shader,
Fill Clip with Paint paint. Paint components Mask_Filter, Shader,
Color_Filter, Image_Filter, and Blend_Mode affect drawing;
Path_Effect in paint is ignored.
@ -4985,7 +4985,7 @@ x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
text draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5041,7 +5041,7 @@ x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5074,7 +5074,7 @@ x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5110,7 +5110,7 @@ by default each glyph left side bearing is positioned at x and its
baseline is positioned at y. Text size is affected by Matrix and
Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5153,7 +5153,7 @@ by default each glyph left side bearing is positioned at an xpos element and
its baseline is positioned at constY. Text size is affected by Matrix and
Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5198,7 +5198,7 @@ UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5246,7 +5246,7 @@ UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5296,7 +5296,7 @@ each glyph.
Optional Rect cullRect is a conservative bounds of text, taking into account
RSXform and paint. If cullRect is outside of Clip, canvas can skip drawing.
All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.
@ -5346,7 +5346,7 @@ Subpixel_Text, and Paint_Vertical_Text.
Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter,
Elements of paint: Path_Effect, Mask_Filter, Shader, Color_Filter,
Image_Filter, and Draw_Looper; apply to blob.
#Param blob Glyphs, positions, and their paints' text size, typeface, and so on ##
@ -5399,7 +5399,7 @@ Subpixel_Text, and Paint_Vertical_Text.
Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter,
Elements of paint: Path_Effect, Mask_Filter, Shader, Color_Filter,
Image_Filter, and Draw_Looper; apply to blob.
#Param blob Glyphs, positions, and their paints' text size, typeface, and so on ##

View File

@ -65,7 +65,6 @@ Shader attached to Paint.
# Path_Effect_Methods # Get and set Path_Effect. ##
# Mask_Filter_Methods # Get and set Mask_Filter. ##
# Typeface_Methods # Get and set Typeface. ##
# Rasterizer_Methods # Get and set Rasterizer. ##
# Image_Filter_Methods # Get and set Image_Filter. ##
# Draw_Looper_Methods # Get and set Draw_Looper. ##
# Text_Align # Text placement relative to position. ##
@ -162,8 +161,7 @@ Shader attached to Paint.
# getPosTextPath # Returns Path equivalent to positioned text. ##
# getPosTextIntercepts # Returns where lines intersect positioned text; underlines. ##
# getPosTextHIntercepts # Returns where lines intersect horizontally positioned text; underlines. ##
# getRasterizer # Returns Rasterizer, Mask_Alpha generation from Path. ##
# getShader # Returns Shader, multiple drawing colors; gradients. ##
# getShader # Returns Shader, multiple drawing colors; gradients. ##
# getStrokeCap # Returns Cap, the area drawn at path ends. ##
# getStrokeJoin # Returns Join, geometry on path corners. ##
# getStrokeMiter # Returns Miter_Limit, angles with sharp corners. ##
@ -197,8 +195,7 @@ Shader attached to Paint.
# refImageFilter # References Image_Filter, alter pixels; blur. ##
# refMaskFilter # References Mask_Filter, alterations to Mask_Alpha. ##
# refPathEffect # References Path_Effect, modifications to path geometry; dashing. ##
# refRasterizer # References Rasterizer, mask generation from path. ##
# refShader # References Shader, multiple drawing colors; gradients. ##
# refShader # References Shader, multiple drawing colors; gradients. ##
# refTypeface # References Typeface, font description. ##
# reset() # Sets to default values. ##
# setAlpha # Sets Color_Alpha, color opacity. ##
@ -219,7 +216,6 @@ Shader attached to Paint.
# setLCDRenderText # Sets or clears LCD_Text. ##
# setMaskFilter # Sets Mask_Filter, alterations to Mask_Alpha. ##
# setPathEffect # Sets Path_Effect, modifications to path geometry; dashing. ##
# setRasterizer # Sets Rasterizer, Mask_Alpha generation from Path. ##
# setImageFilter # Sets Image_Filter, alter pixels; blur. ##
# setShader # Sets Shader, multiple drawing colors; gradients. ##
# setStrokeCap # Sets Cap, the area drawn at path ends. ##
@ -273,7 +269,6 @@ Constructs Paint with default values.
# Miter_Limit # 4 ##
# Mask_Filter # nullptr ##
# Path_Effect # nullptr ##
# Rasterizer # nullptr ##
# Shader # nullptr ##
# Style # kFill_Style ##
# Text_Align # kLeft_Align ##
@ -317,11 +312,11 @@ $$$# # restore original markup character
#Method SkPaint(const SkPaint& paint)
Makes a shallow copy of Paint. Typeface, Path_Effect, Shader,
Mask_Filter, Color_Filter, Rasterizer, Draw_Looper, and Image_Filter are shared
Mask_Filter, Color_Filter, Draw_Looper, and Image_Filter are shared
between the original paint and the copy. Objects containing Reference_Count increment
their references by one.
The referenced objects Path_Effect, Shader, Mask_Filter, Color_Filter, Rasterizer,
The referenced objects Path_Effect, Shader, Mask_Filter, Color_Filter,
Draw_Looper, and Image_Filter cannot be modified after they are created.
This prevents objects with Reference_Count from being modified once Paint refers to them.
@ -399,7 +394,7 @@ Paint with the result of SkPaint().
#Method ~SkPaint()
Decreases Paint Reference_Count of owned objects: Typeface, Path_Effect, Shader,
Mask_Filter, Color_Filter, Rasterizer, Draw_Looper, and Image_Filter. If the
Mask_Filter, Color_Filter, Draw_Looper, and Image_Filter. If the
objects containing Reference_Count go to zero, they are deleted.
#NoExample
@ -414,7 +409,7 @@ objects containing Reference_Count go to zero, they are deleted.
#Method SkPaint& operator=(const SkPaint& paint)
Makes a shallow copy of Paint. Typeface, Path_Effect, Shader,
Mask_Filter, Color_Filter, Rasterizer, Draw_Looper, and Image_Filter are shared
Mask_Filter, Color_Filter, Draw_Looper, and Image_Filter are shared
between the original paint and the copy. Objects containing Reference_Count in the
prior destination are decreased by one, and the referenced objects are deleted if the
resulting count is zero. Objects containing Reference_Count in the parameter paint
@ -472,7 +467,7 @@ After the call, paint is undefined, and can be safely destructed.
#Method bool operator==(const SkPaint& a, const SkPaint& b)
Compares a and b, and returns true if a and b are equivalent. May return false
if Typeface, Path_Effect, Shader, Mask_Filter, Color_Filter, Rasterizer,
if Typeface, Path_Effect, Shader, Mask_Filter, Color_Filter,
Draw_Looper, or Image_Filter have identical contents but different pointers.
#Param a Paint to compare ##
@ -503,7 +498,7 @@ After the call, paint is undefined, and can be safely destructed.
#Method 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 Typeface, Path_Effect, Shader, Mask_Filter, Color_Filter, Rasterizer,
if Typeface, Path_Effect, Shader, Mask_Filter, Color_Filter,
Draw_Looper, or Image_Filter have identical contents but different pointers.
#Param a Paint to compare ##
@ -3114,8 +3109,7 @@ Increments pathEffect Reference_Count by one.
#Topic Mask_Filter_Methods
Mask_Filter uses coverage of the shape drawn to create Mask_Alpha.
Mask_Filter operates at a lower level than Rasterizer; Mask_Filter takes a Mask,
and returns a Mask.
Mask_Filter takes a Mask, and returns a Mask.
Mask_Filter may change the geometry and transparency of the shape, such as
creating a blur effect. Set Mask_Filter to nullptr to prevent Mask_Filter from
@ -3183,7 +3177,6 @@ Sets Mask_Filter to maskFilter, decreasing Reference_Count of the previous
Mask_Filter. Pass nullptr to clear Mask_Filter and leave Mask_Filter effect on
Mask_Alpha unaltered.
Does not affect Rasterizer.
Increments maskFilter Reference_Count by one.
#Param maskFilter modifies clipping mask generated from drawn geometry ##
@ -3294,132 +3287,6 @@ typeface Reference_Count by one.
##
#Topic ##
# ------------------------------------------------------------------------------
#Topic Rasterizer_Methods
Rasterizer controls how shapes are converted to Mask_Alpha.
Rasterizer operates at a higher level than Mask_Filter; Rasterizer takes a Path,
and returns a Mask.
Rasterizer may change the geometry and transparency of the shape, such as
creating a shadow effect. Rasterizer forms the base of Rasterizer_Layer, which
creates effects like embossing and outlining.
Rasterizer applies to Rect, Region, Round_Rect, Arcs, Circles, Ovals,
Path, and Text.
#Example
#Height 64
void draw(SkCanvas* canvas) {
SkLayerRasterizer::Builder layerBuilder;
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(1);
layerBuilder.addLayer(paint);
paint.setAlpha(0x10);
paint.setStyle(SkPaint::kFill_Style);
paint.setBlendMode(SkBlendMode::kSrc);
layerBuilder.addLayer(paint);
paint.reset();
paint.setAntiAlias(true);
paint.setTextSize(50);
paint.setRasterizer(layerBuilder.detach());
canvas->drawString("outline", 10, 50, paint);
}
##
#Method SkRasterizer* getRasterizer() const
Returns Rasterizer if set, or nullptr.
Does not alter Rasterizer Reference_Count.
#Return Rasterizer if previously set, nullptr otherwise ##
#Example
#Function
class DummyRasterizer : public SkRasterizer {
public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyRasterizer)
};
sk_sp<SkFlattenable> DummyRasterizer::CreateProc(SkReadBuffer&) {
return sk_make_sp<DummyRasterizer>();
}
#Function ##
void draw(SkCanvas* canvas) {
SkPaint paint;
DummyRasterizer dummy;
SkDebugf("nullptr %c= rasterizer\n", paint.getRasterizer() ? '!' : '=');
paint.setRasterizer(sk_make_sp<DummyRasterizer>());
SkDebugf("nullptr %c= rasterizer\n", paint.getRasterizer() ? '!' : '=');
}
#StdOut
nullptr == rasterizer
nullptr != rasterizer
##
##
##
#Method sk_sp<SkRasterizer> refRasterizer() const
Returns Rasterizer if set, or nullptr.
Increases Rasterizer Reference_Count by one.
#Return Rasterizer if previously set, nullptr otherwise ##
#Example
void draw(SkCanvas* canvas) {
SkLayerRasterizer::Builder layerBuilder;
SkPaint paint1, paint2;
layerBuilder.addLayer(paint2);
paint1.setRasterizer(layerBuilder.detach());
SkDebugf("rasterizer unique: %s\n", paint1.getRasterizer()->unique() ? "true" : "false");
paint2.setRasterizer(paint1.refRasterizer());
SkDebugf("rasterizer unique: %s\n", paint1.getRasterizer()->unique() ? "true" : "false");
}
#StdOut
rasterizer unique: true
rasterizer unique: false
##
##
##
#Method void setRasterizer(sk_sp<SkRasterizer> rasterizer)
Sets Rasterizer to rasterizer, decreasing Reference_Count of the previous
Rasterizer. Pass nullptr to clear Rasterizer and leave Rasterizer effect on
Mask_Alpha unaltered.
Does not affect Mask_Filter.
Increments rasterizer Reference_Count by one.
#Param rasterizer how geometry is converted to Mask_Alpha ##
#Example
#Height 64
SkLayerRasterizer::Builder layerBuilder;
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(2);
layerBuilder.addLayer(paint);
paint.reset();
paint.setAntiAlias(true);
paint.setTextSize(50);
paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 3));
paint.setRasterizer(layerBuilder.detach());
canvas->drawString("blurry out", 0, 50, paint);
##
##
#Topic ##
# ------------------------------------------------------------------------------
#Topic Image_Filter_Methods
@ -3431,7 +3298,7 @@ which is drawn to the device using the set Blend_Mode.
Image_Filter is higher level than Mask_Filter; for instance, an Image_Filter
can operate on all channels of Color, while Mask_Filter generates Alpha only.
Image_Filter operates independently of and can be used in combination with
Mask_Filter and Rasterizer.
Mask_Filter.
#Example
#ToDo explain why the two draws are so different ##
@ -3504,7 +3371,6 @@ Sets Image_Filter to imageFilter, decreasing Reference_Count of the previous
Image_Filter. Pass nullptr to clear Image_Filter, and remove Image_Filter effect
on drawing.
Does not affect Rasterizer or Mask_Filter.
Increments imageFilter Reference_Count by one.
#Param imageFilter how Image is sampled when transformed ##

View File

@ -9,7 +9,6 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkImage.h"
#include "SkLayerRasterizer.h"
#include "SkPath.h"
#include "SkSurface.h"
#include "SkTypeface.h"
@ -300,18 +299,6 @@ static void fuzz_drawPaint(Fuzz* fuzz) {
sk_sp<SkSurface> surface;
init_surface(fuzz, &surface);
// add layers
uint8_t x;
fuzz->nextRange(&x, 1, 3); // max 3 layers
SkLayerRasterizer::Builder builder;
for (int i = 0; i < x; i++) {
init_paint(fuzz, &l);
builder.addLayer(l);
}
sk_sp<SkLayerRasterizer> raster(builder.detach());
p.setRasterizer(raster);
surface->getCanvas()->drawPaint(p);
}

View File

@ -12,190 +12,9 @@
#include "SkReadBuffer.h"
#include "SkTextBlob.h"
#include "SkWriteBuffer.h"
#include "SkLayerRasterizer.h"
static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))));
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setMaskFilter(nullptr);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
p.setAlpha(0x11);
p.setStyle(SkPaint::kFill_Style);
p.setBlendMode(SkBlendMode::kSrc);
rastBuilder->addLayer(p);
}
static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
p.setAlpha(0x40);
p.setBlendMode(SkBlendMode::kSrc);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*2);
rastBuilder->addLayer(p);
}
static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setStyle(SkPaint::kStrokeAndFill_Style);
p.setStrokeWidth(SK_Scalar1*4);
rastBuilder->addLayer(p);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*3/2);
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
}
static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*3);
rastBuilder->addLayer(p);
p.setAlpha(0x20);
p.setStyle(SkPaint::kFill_Style);
p.setBlendMode(SkBlendMode::kSrc);
rastBuilder->addLayer(p);
}
static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setAlpha(0x60);
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setAlpha(0xFF);
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
p.setBlendMode(SkBlendMode::kSrcOver);
rastBuilder->addLayer(p);
}
#include "SkDiscretePathEffect.h"
static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
p.setBlendMode(SkBlendMode::kSrcOut);
rastBuilder->addLayer(p);
}
static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
p.setAntiAlias(false);
SkLayerRasterizer::Builder rastBuilder2;
r5(&rastBuilder2, p);
p.setRasterizer(rastBuilder2.detach());
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
}
#include "Sk2DPathEffect.h"
static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path;
path.addCircle(0, 0, radius);
return SkPath2DPathEffect::Make(matrix, path);
}
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice));
rastBuilder->addLayer(p);
}
static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setBlendMode(SkBlendMode::kSrcOver);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setBlendMode(SkBlendMode::kSrcOver);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&);
constexpr raster_proc gRastProcs[] = {
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
};
static void apply_shader(SkPaint* paint, int index) {
raster_proc proc = gRastProcs[index];
if (proc) {
SkPaint p;
SkLayerRasterizer::Builder rastBuilder;
p.setAntiAlias(true);
proc(&rastBuilder, p);
paint->setRasterizer(rastBuilder.detach());
}
#if 0
SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 };
paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir, SK_Scalar1/4, SkIntToScalar(4), SkIntToScalar(3)))->unref();
#endif
paint->setColor(SK_ColorBLUE);
}
DEF_SIMPLE_GM(texteffects, canvas, 460, 680) {
canvas->save();
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(SkIntToScalar(56));
SkScalar x = SkIntToScalar(20);
SkScalar y = paint.getTextSize();
SkString str("Hamburgefons");
for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(gRastProcs)); i++) {
apply_shader(&paint, i);
// paint.setMaskFilter(nullptr);
// paint.setColor(SK_ColorBLACK);
canvas->drawString(str, x, y, paint);
y += paint.getFontSpacing();
}
canvas->restore();
}
static SkPath create_underline(const SkTDArray<SkScalar>& intersections,
SkScalar last, SkScalar finalPos,
SkScalar uPos, SkScalar uWidth, SkScalar textSize) {

View File

@ -240,7 +240,6 @@ skia_core_sources = [
"$_src/core/SkRasterClip.cpp",
"$_src/core/SkRasterPipeline.cpp",
"$_src/core/SkRasterPipelineBlitter.cpp",
"$_src/core/SkRasterizer.cpp",
"$_src/core/SkReadBuffer.h",
"$_src/core/SkReadBuffer.cpp",
"$_src/core/SkReader32.h",
@ -414,7 +413,6 @@ skia_core_sources = [
"$_include/core/SkPoint.h",
"$_include/core/SkPoint3.h",
"$_include/core/SkPreConfig.h",
"$_include/core/SkRasterizer.h",
"$_include/core/SkRect.h",
"$_include/core/SkRefCnt.h",
"$_include/core/SkRegion.h",

View File

@ -37,7 +37,6 @@ skia_effects_sources = [
"$_src/effects/SkImageSource.cpp",
"$_src/effects/SkHighContrastFilter.cpp",
"$_src/effects/SkLayerDrawLooper.cpp",
"$_src/effects/SkLayerRasterizer.cpp",
"$_src/effects/SkLightingImageFilter.cpp",
"$_src/effects/SkLumaColorFilter.cpp",
"$_src/effects/SkMagnifierImageFilter.cpp",
@ -98,7 +97,6 @@ skia_effects_sources = [
"$_include/effects/SkGradientShader.h",
"$_include/effects/SkImageSource.h",
"$_include/effects/SkLayerDrawLooper.h",
"$_include/effects/SkLayerRasterizer.h",
"$_include/effects/SkLightingImageFilter.h",
"$_include/effects/SkLumaColorFilter.h",
"$_include/effects/SkMagnifierImageFilter.h",

View File

@ -126,7 +126,6 @@ tests_sources = [
"$_tests/InvalidIndexedPngTest.cpp",
"$_tests/IsClosedSingleContourTest.cpp",
"$_tests/LayerDrawLooperTest.cpp",
"$_tests/LayerRasterizerTest.cpp",
"$_tests/LazyProxyTest.cpp",
"$_tests/LListTest.cpp",
"$_tests/LRUCacheTest.cpp",

View File

@ -1098,7 +1098,7 @@ public:
*/
void discard() { this->onDiscard(); }
/** Fill clip with SkPaint paint. SkPaint components SkRasterizer, SkMaskFilter, SkShader,
/** Fill clip with SkPaint paint. SkPaint components SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;
SkPathEffect in paint is ignored.
@ -1890,7 +1890,7 @@ public:
text draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -1914,7 +1914,7 @@ public:
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -1942,7 +1942,7 @@ public:
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -1964,7 +1964,7 @@ public:
baseline is positioned at y. Text size is affected by SkMatrix and
SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -1989,7 +1989,7 @@ public:
its baseline is positioned at constY. Text size is affected by SkMatrix and
SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -2019,7 +2019,7 @@ public:
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -2046,7 +2046,7 @@ public:
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by SkMatrix and SkPaint text size.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -2069,7 +2069,7 @@ public:
Optional SkRect cullRect is a conservative bounds of text, taking into account
SkRSXform and paint. If cullRect is outside of clip, canvas can skip drawing.
All elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader,
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws
filled 12 point black glyphs.
@ -2092,7 +2092,7 @@ public:
SkPaint::TextEncoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader, SkColorFilter,
Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter,
SkImageFilter, and SkDrawLooper; apply to blob.
@param blob glyphs, positions, and their paints' text size, typeface, and so on
@ -2112,7 +2112,7 @@ public:
SkPaint::TextEncoding must be set to SkPaint::kGlyphID_TextEncoding.
Elements of paint: SkPathEffect, SkRasterizer, SkMaskFilter, SkShader, SkColorFilter,
Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter,
SkImageFilter, and SkDrawLooper; apply to blob.
@param blob glyphs, positions, and their paints' text size, typeface, and so on

View File

@ -88,7 +88,7 @@ public:
kSkMaskFilter_Type,
kSkPathEffect_Type,
kSkPixelRef_Type,
kSkRasterizer_Type,
kSkUnused_Type4, // used to be SkRasterizer
kSkShaderBase_Type,
kSkUnused_Type, // used to be SkUnitMapper
kSkUnused_Type2,

View File

@ -30,7 +30,6 @@ class SkMaskFilter;
class SkPath;
class SkPathEffect;
struct SkPoint;
class SkRasterizer;
struct SkScalerContextEffects;
class SkShader;
class SkSurfaceProps;
@ -74,11 +73,11 @@ public:
SkPaint();
/** Makes a shallow copy of SkPaint. SkTypeface, SkPathEffect, SkShader,
SkMaskFilter, SkColorFilter, SkRasterizer, SkDrawLooper, and SkImageFilter are shared
SkMaskFilter, SkColorFilter, SkDrawLooper, 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, SkRasterizer,
The referenced objects SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
SkDrawLooper, and SkImageFilter cannot be modified after they are created.
This prevents objects with SkRefCnt from being modified once SkPaint refers to them.
@ -98,13 +97,13 @@ public:
SkPaint(SkPaint&& paint);
/** Decreases SkPaint SkRefCnt of owned objects: SkTypeface, SkPathEffect, SkShader,
SkMaskFilter, SkColorFilter, SkRasterizer, SkDrawLooper, and SkImageFilter. If the
SkMaskFilter, SkColorFilter, SkDrawLooper, and SkImageFilter. If the
objects containing SkRefCnt go to zero, they are deleted.
*/
~SkPaint();
/** Makes a shallow copy of SkPaint. SkTypeface, SkPathEffect, SkShader,
SkMaskFilter, SkColorFilter, SkRasterizer, SkDrawLooper, and SkImageFilter are shared
SkMaskFilter, SkColorFilter, SkDrawLooper, 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
@ -128,7 +127,7 @@ public:
SkPaint& operator=(SkPaint&& paint);
/** Compares a and b, and returns true if a and b are equivalent. May return false
if SkTypeface, SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, SkRasterizer,
if SkTypeface, SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
SkDrawLooper, or SkImageFilter have identical contents but different pointers.
@param a SkPaint to compare
@ -138,7 +137,7 @@ public:
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 SkTypeface, SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, SkRasterizer,
if SkTypeface, SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
SkDrawLooper, or SkImageFilter have identical contents but different pointers.
@param a SkPaint to compare
@ -854,9 +853,6 @@ public:
SkMaskFilter. Pass nullptr to clear SkMaskFilter and leave SkMaskFilter effect on
mask alpha unaltered.
Does not affect SkRasterizer.
Increments maskFilter SkRefCnt by one.
@param maskFilter modifies clipping mask generated from drawn geometry
*/
void setMaskFilter(sk_sp<SkMaskFilter> maskFilter);
@ -882,31 +878,6 @@ public:
*/
void setTypeface(sk_sp<SkTypeface> typeface);
/** Returns SkRasterizer if set, or nullptr.
Does not alter SkRasterizer SkRefCnt.
@return SkRasterizer if previously set, nullptr otherwise
*/
SkRasterizer* getRasterizer() const { return fRasterizer.get(); }
/** Returns SkRasterizer if set, or nullptr.
Increases SkRasterizer SkRefCnt by one.
@return SkRasterizer if previously set, nullptr otherwise
*/
sk_sp<SkRasterizer> refRasterizer() const;
/** Sets SkRasterizer to rasterizer, decreasing SkRefCnt of the previous
SkRasterizer. Pass nullptr to clear SkRasterizer and leave SkRasterizer effect on
mask alpha unaltered.
Does not affect SkMaskFilter.
Increments rasterizer SkRefCnt by one.
@param rasterizer how geometry is converted to mask alpha
*/
void setRasterizer(sk_sp<SkRasterizer> rasterizer);
/** Returns SkImageFilter if set, or nullptr.
Does not alter SkImageFilter SkRefCnt.
@ -925,9 +896,6 @@ public:
SkImageFilter. Pass nullptr to clear SkImageFilter, and remove SkImageFilter effect
on drawing.
Does not affect SkRasterizer or SkMaskFilter.
Increments imageFilter SkRefCnt by one.
@param imageFilter how SkImage is sampled when transformed
*/
void setImageFilter(sk_sp<SkImageFilter> imageFilter);
@ -1678,7 +1646,6 @@ private:
sk_sp<SkShader> fShader;
sk_sp<SkMaskFilter> fMaskFilter;
sk_sp<SkColorFilter> fColorFilter;
sk_sp<SkRasterizer> fRasterizer;
sk_sp<SkDrawLooper> fDrawLooper;
sk_sp<SkImageFilter> fImageFilter;

View File

@ -1,41 +0,0 @@
/*
* 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 SkRasterizer_DEFINED
#define SkRasterizer_DEFINED
#include "SkFlattenable.h"
#include "SkMask.h"
class SkMaskFilter;
class SkMatrix;
class SkPath;
struct SkIRect;
class SK_API SkRasterizer : public SkFlattenable {
public:
/** Turn the path into a mask, respecting the specified local->device matrix.
*/
bool rasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds, SkMaskFilter* filter,
SkMask* mask, SkMask::CreateMode mode) const;
SK_DEFINE_FLATTENABLE_TYPE(SkRasterizer)
protected:
SkRasterizer() {}
virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds,
SkMask* mask, SkMask::CreateMode mode) const;
private:
typedef SkFlattenable INHERITED;
};
#endif

View File

@ -1,87 +0,0 @@
/*
* 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 SkLayerRasterizer_DEFINED
#define SkLayerRasterizer_DEFINED
#include "SkRasterizer.h"
#include "SkDeque.h"
#include "SkScalar.h"
class SkPaint;
class SK_API SkLayerRasterizer : public SkRasterizer {
public:
~SkLayerRasterizer() override;
class SK_API Builder {
public:
Builder();
~Builder();
void addLayer(const SkPaint& paint) {
this->addLayer(paint, 0, 0);
}
/**
* Add a new layer (above any previous layers) to the rasterizer.
* The layer will extract those fields that affect the mask from
* the specified paint, but will not retain a reference to the paint
* object itself, so it may be reused without danger of side-effects.
*/
void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
/**
* Pass queue of layers on to newly created layer rasterizer and return it. The builder
* *cannot* be used any more after calling this function. If no layers have been added,
* returns NULL.
*
* The caller is responsible for calling unref() on the returned object, if non NULL.
*/
sk_sp<SkLayerRasterizer> detach();
/**
* Create and return a new immutable SkLayerRasterizer that contains a shapshot of the
* layers that were added to the Builder, without modifying the Builder. The Builder
* *may* be used after calling this function. It will continue to hold any layers
* previously added, so consecutive calls to this function will return identical objects,
* and objects returned by future calls to this function contain all the layers in
* previously returned objects. If no layers have been added, returns NULL.
*
* Future calls to addLayer will not affect rasterizers previously returned by this call.
*
* The caller is responsible for calling unref() on the returned object, if non NULL.
*/
sk_sp<SkLayerRasterizer> snapshot() const;
private:
SkDeque* fLayers;
};
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer)
protected:
SkLayerRasterizer();
SkLayerRasterizer(SkDeque* layers);
void flatten(SkWriteBuffer&) const override;
// override from SkRasterizer
virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds,
SkMask* mask, SkMask::CreateMode mode) const override;
private:
const SkDeque* const fLayers;
static SkDeque* ReadLayers(SkReadBuffer& buffer);
friend class LayerRasterizerTester;
typedef SkRasterizer INHERITED;
};
#endif

View File

@ -20,7 +20,6 @@
#include "SkTypeface.h"
#include "SkGradientShader.h"
#include "SkLayerRasterizer.h"
#include "SkBlurMaskFilter.h"
#include "Sk2DPathEffect.h"
@ -110,31 +109,6 @@ static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) {
return sk_make_sp<Dot2DPathEffect>(rad, lattice, pts);
}
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar interp) {
p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr));
rastBuilder->addLayer(p);
#if 0
p.setPathEffect(new InverseFillPE())->unref();
p.setXfermodeMode(SkXfermode::kSrcIn_Mode);
p.setXfermodeMode(SkXfermode::kClear_Mode);
p.setAlpha((1 - interp) * 255);
rastBuilder->addLayer(p);
#endif
}
typedef void (*raster_proc)(SkLayerRasterizer*, SkPaint&);
static void apply_shader(SkPaint* paint, float scale) {
SkPaint p;
SkLayerRasterizer::Builder rastBuilder;
p.setAntiAlias(true);
r7(&rastBuilder, p, scale);
paint->setRasterizer(rastBuilder.detach());
paint->setColor(SK_ColorBLUE);
}
class ClockFaceView : public SkView {
sk_sp<SkTypeface> fFace;
SkScalar fInterp;
@ -193,7 +167,6 @@ protected:
paint.setTypeface(fFace);
apply_shader(&paint, SkScalarToFloat(fInterp));
canvas->drawString(str, x, y, paint);
// drawdots(canvas, paint);

View File

@ -20,7 +20,6 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h"
#include "SkLayerRasterizer.h"
#include "SkMath.h"
#include "SkPath.h"
#include "SkPictureRecorder.h"
@ -36,86 +35,6 @@
#include <math.h>
#include "DecodeFile.h"
static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)),
SkBlurMaskFilter::kNone_BlurFlag));
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setMaskFilter(nullptr);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
p.setAlpha(0x11);
p.setStyle(SkPaint::kFill_Style);
p.setBlendMode(SkBlendMode::kSrc);
rastBuilder->addLayer(p);
}
static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
p.setAlpha(0x40);
p.setBlendMode(SkBlendMode::kSrc);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*2);
rastBuilder->addLayer(p);
}
static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setStyle(SkPaint::kStrokeAndFill_Style);
p.setStrokeWidth(SK_Scalar1*4);
rastBuilder->addLayer(p);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*3/2);
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
}
static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*3);
rastBuilder->addLayer(p);
p.setAlpha(0x20);
p.setStyle(SkPaint::kFill_Style);
p.setBlendMode(SkBlendMode::kSrc);
rastBuilder->addLayer(p);
}
static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
p.setAlpha(0x60);
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setAlpha(0xFF);
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
p.setBlendMode(SkBlendMode::kSrcOver);
rastBuilder->addLayer(p);
}
static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
p.setBlendMode(SkBlendMode::kSrcOut);
rastBuilder->addLayer(p);
}
static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
p.setAntiAlias(false);
SkLayerRasterizer::Builder rastBuilder2;
r5(&rastBuilder2, p);
p.setRasterizer(rastBuilder2.detach());
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
}
class Dot2DPathEffect : public Sk2DPathEffect {
public:
Dot2DPathEffect(SkScalar radius, const SkMatrix& matrix)
@ -139,81 +58,6 @@ private:
typedef Sk2DPathEffect INHERITED;
};
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
p.setPathEffect(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*4, lattice));
rastBuilder->addLayer(p);
}
static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
p.setPathEffect(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*2, lattice));
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setBlendMode(SkBlendMode::kSrcOver);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setBlendMode(SkBlendMode::kSrcOver);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&);
static const raster_proc gRastProcs[] = {
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
};
static const struct {
SkColor fMul, fAdd;
} gLightingColors[] = {
{ 0x808080, 0x800000 }, // general case
{ 0x707070, 0x707070 }, // no-pin case
{ 0xFFFFFF, 0x800000 }, // just-add case
{ 0x808080, 0x000000 }, // just-mul case
{ 0xFFFFFF, 0x000000 } // identity case
};
static void apply_shader(SkPaint* paint, int index) {
raster_proc proc = gRastProcs[index];
if (proc) {
SkPaint p;
SkLayerRasterizer::Builder rastBuilder;
p.setAntiAlias(true);
proc(&rastBuilder, p);
paint->setRasterizer(rastBuilder.detach());
}
paint->setMaskFilter(SkEmbossMaskFilter::Make(
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)),
{ { SK_Scalar1, SK_Scalar1, SK_Scalar1 }, 0, 128, 16*2 }));
paint->setColor(SK_ColorBLUE);
}
class DemoView : public SampleView {
public:
DemoView() {}
@ -469,49 +313,6 @@ protected:
decode_file("/Users/caryclark/Desktop/05psp04.gif", &fTx);
}
void drawRaster(SkCanvas* canvas) {
for (size_t index = 0; index < SK_ARRAY_COUNT(gRastProcs); index++)
drawOneRaster(canvas);
}
void drawOneRaster(SkCanvas* canvas) {
canvas->save();
SkScalar x = SkIntToScalar(20);
SkScalar y = SkIntToScalar(40);
SkPaint paint;
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(48));
paint.setTypeface(SkTypeface::MakeFromName("sans-serif", SkFontStyle::Bold()));
SkString str("GOOGLE");
for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
apply_shader(&paint, (int)i);
// paint.setMaskFilter(nullptr);
// paint.setColor(SK_ColorBLACK);
#if 01
int index = i % SK_ARRAY_COUNT(gLightingColors);
paint.setColorFilter(SkColorMatrixFilter::MakeLightingFilter(
gLightingColors[index].fMul,
gLightingColors[index].fAdd));
#endif
canvas->drawString(str, x, y, paint);
SkRect oval = { x, y - SkIntToScalar(40), x + SkIntToScalar(40), y };
paint.setStyle(SkPaint::kStroke_Style);
canvas->drawOval(oval, paint);
paint.setStyle(SkPaint::kFill_Style);
y += paint.getFontSpacing();
}
canvas->restore();
}
private:
SkPoint fClickPt;
SkBitmap fBug, fTb, fTx;

View File

@ -13,7 +13,6 @@
#include "SkCornerPathEffect.h"
#include "SkDrawable.h"
#include "SkGradientShader.h"
#include "SkLayerRasterizer.h"
#include "SkPath.h"
#include "SkPathMeasure.h"
#include "SkPictureRecorder.h"

View File

@ -24,7 +24,6 @@
#include "SkEmbossMaskFilter.h"
#include "SkFlattenableSerialization.h"
#include "SkImageSource.h"
#include "SkLayerRasterizer.h"
#include "SkLightingImageFilter.h"
#include "SkLumaColorFilter.h"
#include "SkMagnifierImageFilter.h"
@ -512,13 +511,6 @@ static SkPaint make_paint() {
make_typeface_style()));
}
SkLayerRasterizer::Builder rasterizerBuilder;
SkPaint paintForRasterizer;
if (R(2) == 1) {
paintForRasterizer = make_paint();
}
rasterizerBuilder.addLayer(paintForRasterizer);
paint.setRasterizer(rasterizerBuilder.detach());
paint.setImageFilter(make_image_filter());
sk_sp<SkData> data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
paint.setTextAlign(make_paint_align());

View File

@ -67,21 +67,6 @@ static sk_sp<SkPathEffect> make_warp_pe(SkScalar phase) {
///////////////////////////////////////////////////////////
#include "SkColorFilter.h"
#include "SkLayerRasterizer.h"
class TestRastBuilder : public SkLayerRasterizer::Builder {
public:
TestRastBuilder() {
SkPaint paint;
paint.setAntiAlias(true);
paint.setAlpha(0x66);
this->addLayer(paint, SkIntToScalar(4), SkIntToScalar(4));
paint.setAlpha(0xFF);
this->addLayer(paint);
}
};
class PathEffectView : public SampleView {
SkPath fPath;
@ -151,8 +136,6 @@ protected:
paint.setARGB(0xFF, 0, 0, 0);
paint.setPathEffect(make_warp_pe(fPhase));
TestRastBuilder testRastBuilder;
paint.setRasterizer(testRastBuilder.detach());
canvas->drawPath(fPath, paint);
}

View File

@ -11,7 +11,6 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h"
#include "SkLayerRasterizer.h"
#include "SkPaint.h"
#include "SkVertices.h"
#include "SkView.h"
@ -458,187 +457,8 @@ static void mesh_slide(SkCanvas* canvas) {
///////////////////////////////////////////////////////////////////////////////
static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(3)));
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setMaskFilter(nullptr);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
p.setAlpha(0x11);
p.setStyle(SkPaint::kFill_Style);
p.setBlendMode(SkBlendMode::kSrc);
rastBuilder->addLayer(p);
}
static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
rastBuilder->addLayer(p);
p.setAlpha(0x40);
p.setBlendMode(SkBlendMode::kSrc);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*2);
rastBuilder->addLayer(p);
}
static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
p.setStyle(SkPaint::kStrokeAndFill_Style);
p.setStrokeWidth(SK_Scalar1*4);
rastBuilder->addLayer(p);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*3/2);
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
}
static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1*3);
rastBuilder->addLayer(p);
p.setAlpha(0x20);
p.setStyle(SkPaint::kFill_Style);
p.setBlendMode(SkBlendMode::kSrc);
rastBuilder->addLayer(p);
}
static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
p.setAlpha(0x60);
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setAlpha(0xFF);
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
p.setBlendMode(SkBlendMode::kSrcOver);
rastBuilder->addLayer(p);
}
#include "SkDiscretePathEffect.h"
static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
rastBuilder->addLayer(p);
p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
p.setBlendMode(SkBlendMode::kSrcOut);
rastBuilder->addLayer(p);
}
static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
rastBuilder->addLayer(p);
p.setAntiAlias(false);
SkLayerRasterizer::Builder rastBuilder2;
r5(&rastBuilder2, p);
p.setRasterizer(rastBuilder2.detach());
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
}
#include "Sk2DPathEffect.h"
static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path;
path.addCircle(0, 0, radius);
return SkPath2DPathEffect::Make(matrix, path);
}
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice));
rastBuilder->addLayer(p);
}
static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setBlendMode(SkBlendMode::kSrcOver);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
{
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
p.setBlendMode(SkBlendMode::kClear);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setBlendMode(SkBlendMode::kSrcOver);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&);
static const raster_proc gRastProcs[] = {
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
};
static void apply_shader(SkPaint* paint, int index) {
raster_proc proc = gRastProcs[index];
SkPaint p;
SkLayerRasterizer::Builder rastBuilder;
p.setAntiAlias(true);
proc(&rastBuilder, p);
paint->setRasterizer(rastBuilder.detach());
paint->setColor(SK_ColorBLUE);
}
#include "SkTypeface.h"
static void texteffect_slide(SkCanvas* canvas) {
const char* str = "Google";
size_t len = strlen(str);
SkScalar x = 20;
SkScalar y = 80;
SkPaint paint;
paint.setTypeface(SkTypeface::MakeFromName("Georgia", SkFontStyle::Italic()));
paint.setTextSize(75);
paint.setAntiAlias(true);
paint.setColor(SK_ColorBLUE);
for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
apply_shader(&paint, (int)i);
canvas->drawText(str, len, x, y, paint);
y += 80;
if (i == 4) {
x += 320;
y = 80;
}
}
}
///////////////////////////////////////////////////////////////////////////////
#include "SkImageEncoder.h"
@ -648,7 +468,6 @@ static const SlideProc gProc[] = {
gradient_slide,
textonpath_slide,
mesh_slide,
texteffect_slide
};
class SlideView : public SampleView {

View File

@ -522,7 +522,6 @@ SkImageFilterCache* SkBitmapDevice::getImageFilterCache() {
bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const {
if (kN32_SkColorType != fBitmap.colorType() ||
paint.getRasterizer() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style ||

View File

@ -24,7 +24,6 @@
#include "SkPaint.h"
#include "SkPathEffect.h"
#include "SkRasterClip.h"
#include "SkRasterizer.h"
#include "SkRectPriv.h"
#include "SkRRect.h"
#include "SkScan.h"
@ -699,8 +698,7 @@ SkDraw::RectType SkDraw::ComputeRectType(const SkPaint& paint,
}
if (paint.getPathEffect() || paint.getMaskFilter() ||
paint.getRasterizer() || !matrix.rectStaysRect() ||
SkPaint::kStrokeAndFill_Style == style) {
!matrix.rectStaysRect() || SkPaint::kStrokeAndFill_Style == style) {
rtype = kPath_RectType;
} else if (SkPaint::kFill_Style == style) {
rtype = kFill_RectType;
@ -916,10 +914,6 @@ void SkDraw::drawRRect(const SkRRect& rrect, const SkPaint& paint) const {
if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) {
goto DRAW_PATH;
}
if (paint.getRasterizer()) {
goto DRAW_PATH;
}
}
if (paint.getMaskFilter()) {
@ -1055,8 +1049,7 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
tmpPath.setIsVolatile(true);
if (prePathMatrix) {
if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_Style ||
origPaint.getRasterizer()) {
if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_Style) {
SkPath* result = pathPtr;
if (!pathIsMutable) {
@ -1110,17 +1103,6 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
pathPtr = &tmpPath;
}
if (paint->getRasterizer()) {
SkMask mask;
if (paint->getRasterizer()->rasterize(*pathPtr, *matrix,
&fRC->getBounds(), paint->getMaskFilter(), &mask,
SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
this->drawDevMask(mask, *paint);
SkMask::FreeImage(mask.fImage);
}
return;
}
// avoid possibly allocating a new path in transform if we can
SkPath* devPathPtr = pathIsMutable ? pathPtr : &tmpPath;
@ -1340,7 +1322,6 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& ori
matrix.reset();
draw.fMatrix = &matrix;
// call ourself with a rect
// is this OK if paint has a rasterizer?
draw.drawRect(r, paintWithShader);
}

View File

@ -23,7 +23,6 @@
#include "SkOpts.h"
#include "SkPaintDefaults.h"
#include "SkPathEffect.h"
#include "SkRasterizer.h"
#include "SkSafeRange.h"
#include "SkScalar.h"
#include "SkScalerContext.h"
@ -75,7 +74,6 @@ SkPaint::SkPaint(const SkPaint& src)
, COPY(fShader)
, COPY(fMaskFilter)
, COPY(fColorFilter)
, COPY(fRasterizer)
, COPY(fDrawLooper)
, COPY(fImageFilter)
, COPY(fTextSize)
@ -96,7 +94,6 @@ SkPaint::SkPaint(SkPaint&& src) {
MOVE(fShader);
MOVE(fMaskFilter);
MOVE(fColorFilter);
MOVE(fRasterizer);
MOVE(fDrawLooper);
MOVE(fImageFilter);
MOVE(fTextSize);
@ -123,7 +120,6 @@ SkPaint& SkPaint::operator=(const SkPaint& src) {
ASSIGN(fShader);
ASSIGN(fMaskFilter);
ASSIGN(fColorFilter);
ASSIGN(fRasterizer);
ASSIGN(fDrawLooper);
ASSIGN(fImageFilter);
ASSIGN(fTextSize);
@ -150,7 +146,6 @@ SkPaint& SkPaint::operator=(SkPaint&& src) {
MOVE(fShader);
MOVE(fMaskFilter);
MOVE(fColorFilter);
MOVE(fRasterizer);
MOVE(fDrawLooper);
MOVE(fImageFilter);
MOVE(fTextSize);
@ -173,7 +168,6 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
&& EQUAL(fShader)
&& EQUAL(fMaskFilter)
&& EQUAL(fColorFilter)
&& EQUAL(fRasterizer)
&& EQUAL(fDrawLooper)
&& EQUAL(fImageFilter)
&& EQUAL(fTextSize)
@ -194,7 +188,6 @@ DEFINE_REF_FOO(DrawLooper)
DEFINE_REF_FOO(ImageFilter)
DEFINE_REF_FOO(MaskFilter)
DEFINE_REF_FOO(PathEffect)
DEFINE_REF_FOO(Rasterizer)
DEFINE_REF_FOO(Shader)
DEFINE_REF_FOO(Typeface)
#undef DEFINE_REF_FOO
@ -363,7 +356,6 @@ void SkPaint::setTextEncoding(TextEncoding encoding) {
#define MOVE_FIELD(Field) void SkPaint::set##Field(sk_sp<Sk##Field> f) { f##Field = std::move(f); }
MOVE_FIELD(Typeface)
MOVE_FIELD(Rasterizer)
MOVE_FIELD(ImageFilter)
MOVE_FIELD(Shader)
MOVE_FIELD(ColorFilter)
@ -1557,7 +1549,6 @@ void SkScalerContext::PostMakeRec(const SkPaint&, SkScalerContextRec* rec) {
static void write_out_descriptor(SkDescriptor* desc, const SkScalerContextRec& rec,
const SkPathEffect* pe, SkBinaryWriteBuffer* peBuffer,
const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer,
const SkRasterizer* ra, SkBinaryWriteBuffer* raBuffer,
size_t descSize) {
desc->init();
desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
@ -1568,9 +1559,6 @@ static void write_out_descriptor(SkDescriptor* desc, const SkScalerContextRec& r
if (mf) {
add_flattenable(desc, kMaskFilter_SkDescriptorTag, mfBuffer);
}
if (ra) {
add_flattenable(desc, kRasterizer_SkDescriptorTag, raBuffer);
}
desc->computeChecksum();
}
@ -1580,8 +1568,7 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContextRec* rec,
bool fakeGamma, bool boostContrast,
const SkMatrix* deviceMatrix,
const SkPathEffect* pe, SkBinaryWriteBuffer* peBuffer,
const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer,
const SkRasterizer* ra, SkBinaryWriteBuffer* raBuffer) {
const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer) {
SkScalerContext::MakeRec(paint, surfaceProps, deviceMatrix, rec);
if (!fakeGamma) {
rec->ignoreGamma();
@ -1611,12 +1598,6 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContextRec* rec,
Also, all existing users of blur have calibrated for linear. */
rec->ignorePreBlend();
}
if (ra) {
ra->flatten(*raBuffer);
descSize += raBuffer->bytesWritten();
entryCount += 1;
rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion
}
///////////////////////////////////////////////////////////////////////////
// Now that we're done tweaking the rec, call the PostMakeRec cleanup
@ -1630,7 +1611,6 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContextRec* rec,
static void test_desc(const SkScalerContextRec& rec,
const SkPathEffect* pe, SkBinaryWriteBuffer* peBuffer,
const SkMaskFilter* mf, SkBinaryWriteBuffer* mfBuffer,
const SkRasterizer* ra, SkBinaryWriteBuffer* raBuffer,
const SkDescriptor* desc, size_t descSize) {
// Check that we completely write the bytes in desc (our key), and that
// there are no uninitialized bytes. If there were, then we would get
@ -1659,10 +1639,6 @@ static void test_desc(const SkScalerContextRec& rec,
add_flattenable(desc1, kMaskFilter_SkDescriptorTag, mfBuffer);
add_flattenable(desc2, kMaskFilter_SkDescriptorTag, mfBuffer);
}
if (ra) {
add_flattenable(desc1, kRasterizer_SkDescriptorTag, raBuffer);
add_flattenable(desc2, kRasterizer_SkDescriptorTag, raBuffer);
}
SkASSERT(descSize == desc1->getLength());
SkASSERT(descSize == desc2->getLength());
@ -1683,28 +1659,26 @@ void SkPaint::getScalerContextDescriptor(SkScalerContextEffects* effects,
SkPathEffect* pe = this->getPathEffect();
SkMaskFilter* mf = this->getMaskFilter();
SkRasterizer* ra = this->getRasterizer();
SkBinaryWriteBuffer peBuffer, mfBuffer, raBuffer;
SkBinaryWriteBuffer peBuffer, mfBuffer;
size_t descSize = fill_out_rec(*this, &rec, &surfaceProps,
SkToBool(scalerContextFlags & kFakeGamma_ScalerContextFlag),
SkToBool(scalerContextFlags & kBoostContrast_ScalerContextFlag),
deviceMatrix, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer);
deviceMatrix, pe, &peBuffer, mf, &mfBuffer);
ad->reset(descSize);
SkDescriptor* desc = ad->getDesc();
write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize);
write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, descSize);
SkASSERT(descSize == desc->getLength());
#ifdef TEST_DESC
test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize);
test_desc(rec, pe, &peBuffer, mf, &mfBuffer, desc, descSize);
#endif
effects->fPathEffect = pe;
effects->fMaskFilter = mf;
effects->fRasterizer = ra;
}
/*
@ -1722,26 +1696,25 @@ void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps,
SkPathEffect* pe = this->getPathEffect();
SkMaskFilter* mf = this->getMaskFilter();
SkRasterizer* ra = this->getRasterizer();
SkBinaryWriteBuffer peBuffer, mfBuffer, raBuffer;
size_t descSize = fill_out_rec(*this, &rec, surfaceProps,
SkToBool(scalerContextFlags & kFakeGamma_ScalerContextFlag),
SkToBool(scalerContextFlags & kBoostContrast_ScalerContextFlag),
deviceMatrix, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer);
deviceMatrix, pe, &peBuffer, mf, &mfBuffer);
SkAutoDescriptor ad(descSize);
SkDescriptor* desc = ad.getDesc();
write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize);
write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, descSize);
SkASSERT(descSize == desc->getLength());
#ifdef TEST_DESC
test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize);
test_desc(rec, pe, &peBuffer, mf, &mfBuffer, desc, descSize);
#endif
proc(fTypeface.get(), { pe, mf, ra }, desc, context);
proc(fTypeface.get(), { pe, mf }, desc, context);
}
SkGlyphCache* SkPaint::detachCache(const SkSurfaceProps* surfaceProps,
@ -1880,7 +1853,6 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
asint(this->getShader()) |
asint(this->getMaskFilter()) |
asint(this->getColorFilter()) |
asint(this->getRasterizer()) |
asint(this->getLooper()) |
asint(this->getImageFilter())) {
flatFlags |= kHasEffects_FlatFlag;
@ -1906,7 +1878,7 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
buffer.writeFlattenable(this->getShader());
buffer.writeFlattenable(this->getMaskFilter());
buffer.writeFlattenable(this->getColorFilter());
buffer.writeFlattenable(this->getRasterizer());
buffer.write32(0); // use to be SkRasterizer
buffer.writeFlattenable(this->getLooper());
buffer.writeFlattenable(this->getImageFilter());
}
@ -1942,7 +1914,7 @@ bool SkPaint::unflatten(SkReadBuffer& buffer) {
this->setShader(buffer.readShader());
this->setMaskFilter(buffer.readMaskFilter());
this->setColorFilter(buffer.readColorFilter());
this->setRasterizer(buffer.readRasterizer());
(void)buffer.read32(); // use to be SkRasterizer
this->setLooper(buffer.readDrawLooper());
this->setImageFilter(buffer.readImageFilter());
} else {
@ -1950,7 +1922,6 @@ bool SkPaint::unflatten(SkReadBuffer& buffer) {
this->setShader(nullptr);
this->setMaskFilter(nullptr);
this->setColorFilter(nullptr);
this->setRasterizer(nullptr);
this->setLooper(nullptr);
this->setImageFilter(nullptr);
}
@ -1996,7 +1967,7 @@ bool SkPaint::canComputeFastBounds() const {
if (this->getImageFilter() && !this->getImageFilter()->canComputeFastBounds()) {
return false;
}
return !this->getRasterizer();
return true;
}
const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc,
@ -2100,12 +2071,6 @@ void SkPaint::toString(SkString* str) const {
str->append("</dd>");
}
SkRasterizer* rasterizer = this->getRasterizer();
if (rasterizer) {
str->append("<dt>Rasterizer:</dt><dd>");
str->append("</dd>");
}
SkDrawLooper* looper = this->getLooper();
if (looper) {
str->append("<dt>DrawLooper:</dt><dd>");
@ -2342,9 +2307,9 @@ bool SkPaint::nothingToDraw() const {
}
uint32_t SkPaint::getHash() const {
// We're going to hash 10 pointers and 7 32-bit values, finishing up with fBitfields,
// so fBitfields should be 10 pointers and 6 32-bit values from the start.
static_assert(offsetof(SkPaint, fBitfields) == 8 * sizeof(void*) + 7 * sizeof(uint32_t),
// We're going to hash 7 pointers and 7 32-bit values, finishing up with fBitfields,
// so fBitfields should be 7 pointers and 6 32-bit values from the start.
static_assert(offsetof(SkPaint, fBitfields) == 7 * sizeof(void*) + 7 * sizeof(uint32_t),
"SkPaint_notPackedTightly");
return SkOpts::hash(reinterpret_cast<const uint32_t*>(this),
offsetof(SkPaint, fBitfields) + sizeof(fBitfields));

View File

@ -4,13 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkPictureFlat.h"
#include "SkPictureFlat.h"
#include "SkChecksum.h"
#include "SkColorFilter.h"
#include "SkDrawLooper.h"
#include "SkMaskFilter.h"
#include "SkRasterizer.h"
#include "SkShader.h"
#include "SkTypeface.h"

View File

@ -1,46 +0,0 @@
/*
* 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.
*/
#include "SkRasterizer.h"
#include "SkDraw.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
#include "SkStrokeRec.h"
bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
const SkIRect* clipBounds, SkMaskFilter* filter,
SkMask* mask, SkMask::CreateMode mode) const {
SkIRect storage;
if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) {
SkIPoint margin;
SkMask srcM, dstM;
srcM.fFormat = SkMask::kA8_Format;
srcM.fBounds.set(0, 0, 1, 1);
if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
return false;
}
storage = clipBounds->makeOutset(margin.fX, margin.fY);
clipBounds = &storage;
}
return this->onRasterize(fillPath, matrix, clipBounds, mask, mode);
}
/* Our default implementation of the virtual method just scan converts
*/
bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
const SkIRect* clipBounds,
SkMask* mask, SkMask::CreateMode mode) const {
SkPath devPath;
fillPath.transform(matrix, &devPath);
return SkDraw::DrawToMask(devPath, clipBounds, nullptr, nullptr, mask, mode,
SkStrokeRec::kFill_InitStyle);
}

View File

@ -17,7 +17,6 @@
#include "SkPath.h"
#include "SkPathEffect.h"
#include "SkPicture.h"
#include "SkRasterizer.h"
#include "SkReadBuffer.h"
#include "SkReader32.h"
#include "SkRefCnt.h"
@ -146,7 +145,6 @@ public:
sk_sp<SkImageFilter> readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
sk_sp<SkShader> readShader() { return this->readFlattenable<SkShaderBase>(); }
// Reads SkAlign4(bytes), but will only copy bytes into the buffer.

View File

@ -133,7 +133,6 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint,
!layerPaint->isSrcOver() ||
layerPaint->getMaskFilter() ||
layerPaint->getColorFilter() ||
layerPaint->getRasterizer() ||
layerPaint->getLooper() ||
layerPaint->getImageFilter()) {
return false;

View File

@ -20,7 +20,6 @@
#include "SkPaintPriv.h"
#include "SkPathEffect.h"
#include "SkRasterClip.h"
#include "SkRasterizer.h"
#include "SkReadBuffer.h"
#include "SkStroke.h"
#include "SkStrokeRec.h"
@ -70,9 +69,8 @@ SkScalerContext::SkScalerContext(sk_sp<SkTypeface> typeface, const SkScalerConte
, fTypeface(std::move(typeface))
, fPathEffect(sk_ref_sp(effects.fPathEffect))
, fMaskFilter(sk_ref_sp(effects.fMaskFilter))
, fRasterizer(sk_ref_sp(effects.fRasterizer))
// Initialize based on our settings. Subclasses can also force this.
, fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != nullptr || fRasterizer != nullptr)
, fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != nullptr)
, fPreBlend(fMaskFilter ? SkMaskGamma::PreBlend() : SkScalerContext::GetMaskPreBlend(fRec))
, fPreBlendForFilter(fMaskFilter ? SkScalerContext::GetMaskPreBlend(fRec)
@ -135,19 +133,6 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
this->internalGetPath(glyph->getPackedID(), &fillPath, &devPath, &fillToDevMatrix);
if (fillPath.isEmpty()) {
generatingImageFromPath = false;
} else if (fRasterizer) {
SkMask mask;
if (fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
fMaskFilter.get(), &mask,
SkMask::kJustComputeBounds_CreateMode)) {
glyph->fLeft = mask.fBounds.fLeft;
glyph->fTop = mask.fBounds.fTop;
glyph->fWidth = SkToU16(mask.fBounds.width());
glyph->fHeight = SkToU16(mask.fBounds.height());
} else {
goto SK_ERROR;
}
} else {
// just use devPath
const SkIRect ir = devPath.getBounds().roundOut();
@ -487,21 +472,6 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
if (fillPath.isEmpty()) {
generateImage(*glyph);
} else if (fRasterizer) {
// Paths do not have color information, so we should not have a color mask here.
// This case should have been caught up in generateMetrics().
SkASSERT(SkMask::kARGB32_Format != origGlyph.fMaskFormat);
mask.fFormat = SkMask::kA8_Format;
sk_bzero(glyph->fImage, mask.computeImageSize());
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
fMaskFilter.get(), &mask,
SkMask::kJustRenderImage_CreateMode)) {
return;
}
if (fPreBlend.isApplicable()) {
applyLUTToA8Mask(mask, fPreBlend.fG);
}
} else {
SkASSERT(SkMask::kARGB32_Format != origGlyph.fMaskFormat);
SkASSERT(SkMask::kARGB32_Format != mask.fFormat);

View File

@ -18,16 +18,14 @@
class SkDescriptor;
class SkMaskFilter;
class SkPathEffect;
class SkRasterizer;
struct SkScalerContextEffects {
SkScalerContextEffects() : fPathEffect(nullptr), fMaskFilter(nullptr), fRasterizer(nullptr) {}
SkScalerContextEffects(SkPathEffect* pe, SkMaskFilter* mf, SkRasterizer* ra)
: fPathEffect(pe), fMaskFilter(mf), fRasterizer(ra) {}
SkScalerContextEffects() : fPathEffect(nullptr), fMaskFilter(nullptr) {}
SkScalerContextEffects(SkPathEffect* pe, SkMaskFilter* mf)
: fPathEffect(pe), fMaskFilter(mf) {}
SkPathEffect* fPathEffect;
SkMaskFilter* fMaskFilter;
SkRasterizer* fRasterizer;
};
enum SkAxisAlignment {
@ -271,7 +269,7 @@ public:
const SkScalerContextRec& getRec() const { return fRec; }
SkScalerContextEffects getEffects() const {
return { fPathEffect.get(), fMaskFilter.get(), fRasterizer.get() };
return { fPathEffect.get(), fMaskFilter.get() };
}
/**
@ -341,7 +339,6 @@ private:
// optional objects, which may be null
sk_sp<SkPathEffect> fPathEffect;
sk_sp<SkMaskFilter> fMaskFilter;
sk_sp<SkRasterizer> fRasterizer;
// if this is set, we draw the image from a path, rather than
// calling generateImage.
@ -363,7 +360,6 @@ private:
#define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c')
#define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e')
#define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f')
#define kRasterizer_SkDescriptorTag SkSetFourByteTag('r', 'a', 's', 't')
///////////////////////////////////////////////////////////////////////////////

View File

@ -1,226 +0,0 @@
/*
* 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.
*/
#include "SkLayerRasterizer.h"
#include "SkDraw.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkMask.h"
#include "SkMaskFilter.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPathEffect.h"
#include "../core/SkRasterClip.h"
#include "../core/SkStrokeRec.h"
#include <new>
struct SkLayerRasterizer_Rec {
SkPaint fPaint;
SkVector fOffset;
};
SkLayerRasterizer::SkLayerRasterizer() : fLayers(new SkDeque(sizeof(SkLayerRasterizer_Rec))) {}
SkLayerRasterizer::SkLayerRasterizer(SkDeque* layers) : fLayers(layers)
{
}
// Helper function to call destructors on SkPaints held by layers and delete layers.
static void clean_up_layers(SkDeque* layers) {
SkDeque::F2BIter iter(*layers);
SkLayerRasterizer_Rec* rec;
while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr)
rec->fPaint.~SkPaint();
delete layers;
}
SkLayerRasterizer::~SkLayerRasterizer() {
SkASSERT(fLayers);
clean_up_layers(const_cast<SkDeque*>(fLayers));
}
static bool compute_bounds(const SkDeque& layers, const SkPath& path,
const SkMatrix& matrix,
const SkIRect* clipBounds, SkIRect* bounds) {
SkDeque::F2BIter iter(layers);
SkLayerRasterizer_Rec* rec;
bounds->set(SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32);
while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) {
const SkPaint& paint = rec->fPaint;
SkPath fillPath, devPath;
const SkPath* p = &path;
if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) {
paint.getFillPath(path, &fillPath);
p = &fillPath;
}
if (p->isEmpty()) {
continue;
}
// apply the matrix and offset
{
SkMatrix m = matrix;
m.preTranslate(rec->fOffset.fX, rec->fOffset.fY);
p->transform(m, &devPath);
}
SkMask mask;
if (!SkDraw::DrawToMask(devPath, clipBounds, paint.getMaskFilter(),
&matrix, &mask,
SkMask::kJustComputeBounds_CreateMode,
SkStrokeRec::kFill_InitStyle)) {
return false;
}
bounds->join(mask.fBounds);
}
return true;
}
bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds,
SkMask* mask, SkMask::CreateMode mode) const {
SkASSERT(fLayers);
if (fLayers->empty()) {
return false;
}
if (SkMask::kJustRenderImage_CreateMode != mode) {
if (!compute_bounds(*fLayers, path, matrix, clipBounds, &mask->fBounds))
return false;
}
if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) {
mask->fFormat = SkMask::kA8_Format;
mask->fRowBytes = mask->fBounds.width();
size_t size = mask->computeImageSize();
if (0 == size) {
return false; // too big to allocate, abort
}
mask->fImage = SkMask::AllocImage(size);
memset(mask->fImage, 0, size);
}
if (SkMask::kJustComputeBounds_CreateMode != mode) {
SkDraw draw;
if (!draw.fDst.reset(*mask)) {
return false;
}
SkRasterClip rectClip;
SkMatrix translatedMatrix; // this translates us to our local pixels
SkMatrix drawMatrix; // this translates the path by each layer's offset
rectClip.setRect(SkIRect::MakeWH(mask->fBounds.width(), mask->fBounds.height()));
translatedMatrix = matrix;
translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft),
-SkIntToScalar(mask->fBounds.fTop));
draw.fMatrix = &drawMatrix;
draw.fRC = &rectClip;
// we set the matrixproc in the loop, as the matrix changes each time (potentially)
SkDeque::F2BIter iter(*fLayers);
SkLayerRasterizer_Rec* rec;
while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != nullptr) {
drawMatrix = translatedMatrix;
drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY);
draw.drawPath(path, rec->fPaint);
}
}
return true;
}
sk_sp<SkFlattenable> SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
return sk_sp<SkFlattenable>(new SkLayerRasterizer(ReadLayers(buffer)));
}
SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) {
int count = buffer.readInt();
SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec));
for (int i = 0; i < count; i++) {
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back();
new (&rec->fPaint) SkPaint;
buffer.readPaint(&rec->fPaint);
buffer.readPoint(&rec->fOffset);
}
return layers;
}
void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
SkASSERT(fLayers);
buffer.writeInt(fLayers->count());
SkDeque::F2BIter iter(*fLayers);
const SkLayerRasterizer_Rec* rec;
while ((rec = (const SkLayerRasterizer_Rec*)iter.next()) != nullptr) {
buffer.writePaint(rec->fPaint);
buffer.writePoint(rec->fOffset);
}
}
SkLayerRasterizer::Builder::Builder() : fLayers(new SkDeque(sizeof(SkLayerRasterizer_Rec))) {}
SkLayerRasterizer::Builder::~Builder()
{
if (fLayers != nullptr) {
clean_up_layers(fLayers);
}
}
void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx,
SkScalar dy) {
SkASSERT(fLayers);
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back();
new (&rec->fPaint) SkPaint(paint);
rec->fOffset.set(dx, dy);
}
sk_sp<SkLayerRasterizer> SkLayerRasterizer::Builder::detach() {
SkLayerRasterizer* rasterizer;
if (0 == fLayers->count()) {
rasterizer = nullptr;
delete fLayers;
} else {
rasterizer = new SkLayerRasterizer(fLayers);
}
fLayers = nullptr;
return sk_sp<SkLayerRasterizer>(rasterizer);
}
sk_sp<SkLayerRasterizer> SkLayerRasterizer::Builder::snapshot() const {
if (0 == fLayers->count()) {
return nullptr;
}
SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec), fLayers->count());
SkDeque::F2BIter iter(*fLayers);
const SkLayerRasterizer_Rec* recOrig;
SkDEBUGCODE(int count = 0;)
while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != nullptr) {
SkDEBUGCODE(count++);
SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(layers->push_back());
new (&recCopy->fPaint) SkPaint(recOrig->fPaint);
recCopy->fOffset = recOrig->fOffset;
}
SkASSERT(fLayers->count() == count);
SkASSERT(layers->count() == count);
return sk_sp<SkLayerRasterizer>(new SkLayerRasterizer(layers));
}

View File

@ -61,7 +61,6 @@ SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex,
skPaint.getScalerContextDescriptor(&effects, desc, props, scalerContextFlags, viewMatrix);
run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
run->fPathEffect = sk_ref_sp(effects.fPathEffect);
run->fRasterizer = sk_ref_sp(effects.fRasterizer);
run->fMaskFilter = sk_ref_sp(effects.fMaskFilter);
return SkGlyphCache::DetachCache(run->fTypeface.get(), effects, desc->getDesc());
}

View File

@ -18,7 +18,6 @@
#include "SkOpts.h"
#include "SkPathEffect.h"
#include "SkPoint3.h"
#include "SkRasterizer.h"
#include "SkRectPriv.h"
#include "SkSurfaceProps.h"
#include "SkTInternalLList.h"
@ -489,7 +488,6 @@ private:
// Effects from the paint that are used to build a SkScalerContext.
sk_sp<SkPathEffect> fPathEffect;
sk_sp<SkRasterizer> fRasterizer;
sk_sp<SkMaskFilter> fMaskFilter;
// Distance field text cannot draw coloremoji, and so has to fall back. However,

View File

@ -199,7 +199,6 @@ Regenerator::Result Regenerator::doRegen() {
if (!*fLazyCache || (*fLazyCache)->getDescriptor() != *desc) {
SkScalerContextEffects effects;
effects.fPathEffect = fRun->fPathEffect.get();
effects.fRasterizer = fRun->fRasterizer.get();
effects.fMaskFilter = fRun->fMaskFilter.get();
fLazyCache->reset(SkGlyphCache::DetachCache(fRun->fTypeface.get(), effects, desc));
}

View File

@ -494,9 +494,8 @@ bool GrAtlasTextContext::canDrawAsDistanceFields(const SkPaint& skPaint, const S
}
}
// rasterizers and mask filters modify alpha, which doesn't
// translate well to distance
if (skPaint.getRasterizer() || skPaint.getMaskFilter() || !caps.shaderDerivativeSupport()) {
// mask filters modify alpha, which doesn't translate well to distance
if (skPaint.getMaskFilter() || !caps.shaderDerivativeSupport()) {
return false;
}

View File

@ -53,9 +53,6 @@ GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() {
}
bool GrStencilAndCoverTextContext::internalCanDraw(const SkPaint& skPaint) {
if (skPaint.getRasterizer()) {
return false;
}
if (skPaint.getMaskFilter()) {
return false;
}

View File

@ -74,7 +74,7 @@ uint32_t GrTextUtils::FilterTextFlags(const SkSurfaceProps& surfaceProps, const
}
bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) {
return paint.getMaskFilter() || paint.getRasterizer() || paint.getPathEffect() ||
return paint.getMaskFilter() || paint.getPathEffect() ||
paint.isFakeBoldText() || paint.getStyle() != SkPaint::kFill_Style;
}

View File

@ -16,7 +16,6 @@
#include "SkPipeCanvas.h"
#include "SkPipeFormat.h"
#include "SkRSXform.h"
#include "SkRasterizer.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTextBlob.h"
@ -70,7 +69,6 @@ static uint16_t compute_nondef(const SkPaint& paint, PaintUsage usage) {
if (usage & (kText_PaintUsage | kGeometry_PaintUsage | kTextBlob_PaintUsage)) {
bits |= (paint.getPathEffect() ? kPathEffect_NonDef : 0);
bits |= (paint.getRasterizer() ? kRasterizer_NonDef : 0);
if (paint.getStyle() != SkPaint::kFill_Style || (usage & kRespectsStroke_PaintUsage)) {
bits |= (paint.getStrokeWidth() != kStrokeWidth_Default ? kStrokeWidth_NonDef : 0);
@ -176,7 +174,6 @@ static void write_paint(SkWriteBuffer& writer, const SkPaint& paint, unsigned us
CHECK_WRITE_FLATTENABLE(writer, nondef, paint, Shader);
CHECK_WRITE_FLATTENABLE(writer, nondef, paint, MaskFilter);
CHECK_WRITE_FLATTENABLE(writer, nondef, paint, ColorFilter);
CHECK_WRITE_FLATTENABLE(writer, nondef, paint, Rasterizer);
CHECK_WRITE_FLATTENABLE(writer, nondef, paint, ImageFilter);
CHECK_WRITE_FLATTENABLE(writer, nondef, paint, DrawLooper);
}

View File

@ -181,7 +181,6 @@ static SkPaint read_paint(SkReadBuffer& reader) {
CHECK_SET_FLATTENABLE(Shader);
CHECK_SET_FLATTENABLE(MaskFilter);
CHECK_SET_FLATTENABLE(ColorFilter);
CHECK_SET_FLATTENABLE(Rasterizer);
CHECK_SET_FLATTENABLE(ImageFilter);
CHECK_SET_FLATTENABLE(DrawLooper);

View File

@ -23,7 +23,6 @@
#include "SkHighContrastFilter.h"
#include "SkImageSource.h"
#include "SkLayerDrawLooper.h"
#include "SkLayerRasterizer.h"
#include "SkLightingImageFilter.h"
#include "SkLocalMatrixImageFilter.h"
#include "SkLumaColorFilter.h"
@ -70,9 +69,6 @@ void SkFlattenable::PrivateInitializer::InitEffects() {
// DrawLooper
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper)
// Rasterizer
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer)
// ColorFilter
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilterRowMajor255)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter)

View File

@ -973,7 +973,6 @@ static int lpaint_getEffects(lua_State* L) {
lua_newtable(L);
setfield_bool_if(L, "looper", !!paint->getLooper());
setfield_bool_if(L, "pathEffect", !!paint->getPathEffect());
setfield_bool_if(L, "rasterizer", !!paint->getRasterizer());
setfield_bool_if(L, "maskFilter", !!paint->getMaskFilter());
setfield_bool_if(L, "shader", !!paint->getShader());
setfield_bool_if(L, "colorFilter", !!paint->getColorFilter());

View File

@ -40,7 +40,6 @@
#include "SkPathOps.h"
#include "SkPoint.h"
#include "SkRasterClip.h"
#include "SkRasterizer.h"
#include "SkSFNTHeader.h"
#include "SkShader.h"
#include "SkSize.h"
@ -1076,7 +1075,6 @@ static bool rect_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) {
return paint.getPathEffect() ||
paint.getMaskFilter() ||
paint.getRasterizer() ||
(stroke && (
(matrix.hasPerspective() && !zeroWidth) ||
SkPaint::kMiter_Join != paint.getStrokeJoin() ||
@ -1518,7 +1516,7 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath,
SkMatrix matrix = this->ctm();
SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath);
if (prePathMatrix) {
if (paintHasPathEffect || paint->getRasterizer()) {
if (paintHasPathEffect) {
if (!pathIsMutable) {
skeletalPath = &modifiedPath;
pathIsMutable = true;
@ -1562,11 +1560,10 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath,
HRVM(shadedPath->SetGeometryLocal(shadedGeometry.get()),
"Could not add the shaded geometry to shaded path.");
SkRasterizer* rasterizer = paint->getRasterizer();
SkMaskFilter* filter = paint->getMaskFilter();
//Determine if we will draw or shade and mask.
if (rasterizer || filter) {
if (filter) {
if (paint->getStyle() != SkPaint::kFill_Style) {
paint.writable()->setStyle(SkPaint::kFill_Style);
}
@ -1581,44 +1578,6 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath,
&fill,
&stroke));
//Rasterizer
if (rasterizer) {
SkIRect clipIRect;
SkVector ppuScale;
this->convertToPpm(filter,
&matrix,
&ppuScale,
this->cs().bounds(size(*this)).roundOut(),
&clipIRect);
SkMask* mask = nullptr;
//[Fillable-path -> Mask]
SkMask rasteredMask;
if (rasterizer->rasterize(
*fillablePath,
matrix,
&clipIRect,
filter, //just to compute how much to draw.
&rasteredMask,
SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage);
mask = &rasteredMask;
//[Mask -> Mask]
SkMask filteredMask;
if (filter && filter->filterMask(&filteredMask, *mask, this->ctm(), nullptr)) {
mask = &filteredMask;
}
SkAutoMaskFreeImage filteredAmi(filteredMask.fImage);
//Draw mask.
HRV(this->applyMask(*mask, ppuScale, shadedPath.get()));
}
return;
}
//Mask filter
if (filter) {
SkIRect clipIRect;
@ -2039,7 +1998,6 @@ static bool text_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) {
|| SkPaint::kStroke_Style == style
|| SkPaint::kStrokeAndFill_Style == style
|| paint.getMaskFilter()
|| paint.getRasterizer()
;
}

View File

@ -1,146 +0,0 @@
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkDeque.h"
#include "SkLayerRasterizer.h"
#include "SkPaint.h"
#include "SkRasterizer.h"
#include "Test.h"
class SkReadBuffer;
// Dummy class to place on a paint just to ensure the paint's destructor
// is called.
// ONLY to be used by LayerRasterizer_destructor, since other tests may
// be run in a separate thread, and this class is not threadsafe.
class DummyRasterizer : public SkRasterizer {
public:
DummyRasterizer()
: INHERITED()
{
// Not threadsafe. Only used in one thread.
gCount++;
}
~DummyRasterizer() override {
// Not threadsafe. Only used in one thread.
gCount--;
}
static int GetCount() { return gCount; }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyRasterizer)
private:
static int gCount;
typedef SkRasterizer INHERITED;
};
int DummyRasterizer::gCount;
sk_sp<SkFlattenable> DummyRasterizer::CreateProc(SkReadBuffer&) {
return sk_make_sp<DummyRasterizer>();
}
// Check to make sure that the SkPaint in the layer has its destructor called.
DEF_TEST(LayerRasterizer_destructor, reporter) {
{
SkPaint paint;
paint.setRasterizer(sk_make_sp<DummyRasterizer>());
REPORTER_ASSERT(reporter, DummyRasterizer::GetCount() == 1);
SkLayerRasterizer::Builder builder;
builder.addLayer(paint);
}
REPORTER_ASSERT(reporter, DummyRasterizer::GetCount() == 0);
}
class LayerRasterizerTester {
public:
static int CountLayers(const SkLayerRasterizer& layerRasterizer) {
return layerRasterizer.fLayers->count();
}
static const SkDeque& GetLayers(const SkLayerRasterizer& layerRasterizer) {
return *layerRasterizer.fLayers;
}
};
// MUST stay in sync with definition of SkLayerRasterizer_Rec in SkLayerRasterizer.cpp.
struct SkLayerRasterizer_Rec {
SkPaint fPaint;
SkVector fOffset;
};
static bool equals(const SkLayerRasterizer_Rec& rec1, const SkLayerRasterizer_Rec& rec2) {
return rec1.fPaint == rec2.fPaint && rec1.fOffset == rec2.fOffset;
}
DEF_TEST(LayerRasterizer_copy, reporter) {
SkLayerRasterizer::Builder builder;
REPORTER_ASSERT(reporter, nullptr == builder.snapshot());
SkPaint paint;
// Create a bunch of paints with different flags.
for (uint32_t flags = 0x01; flags < SkPaint::kAllFlags; flags <<= 1) {
paint.setFlags(flags);
builder.addLayer(paint, static_cast<SkScalar>(flags), static_cast<SkScalar>(flags));
}
// Create a layer rasterizer with all the existing layers.
sk_sp<SkLayerRasterizer> firstCopy(builder.snapshot());
// Add one more layer.
paint.setFlags(SkPaint::kAllFlags);
builder.addLayer(paint);
sk_sp<SkLayerRasterizer> oneLarger(builder.snapshot());
sk_sp<SkLayerRasterizer> detached(builder.detach());
// Check the counts for consistency.
const int largerCount = LayerRasterizerTester::CountLayers(*oneLarger.get());
const int smallerCount = LayerRasterizerTester::CountLayers(*firstCopy.get());
REPORTER_ASSERT(reporter, largerCount == LayerRasterizerTester::CountLayers(*detached.get()));
REPORTER_ASSERT(reporter, smallerCount == largerCount - 1);
const SkLayerRasterizer_Rec* recFirstCopy = nullptr;
const SkLayerRasterizer_Rec* recOneLarger = nullptr;
const SkLayerRasterizer_Rec* recDetached = nullptr;
const SkDeque& layersFirstCopy = LayerRasterizerTester::GetLayers(*firstCopy.get());
const SkDeque& layersOneLarger = LayerRasterizerTester::GetLayers(*oneLarger.get());
const SkDeque& layersDetached = LayerRasterizerTester::GetLayers(*detached.get());
// Ensure that our version of SkLayerRasterizer_Rec is the same as the one in
// SkLayerRasterizer.cpp - or at least the same size. If the order were switched, we
// would fail the test elsewhere.
REPORTER_ASSERT(reporter, layersFirstCopy.elemSize() == sizeof(SkLayerRasterizer_Rec));
REPORTER_ASSERT(reporter, layersOneLarger.elemSize() == sizeof(SkLayerRasterizer_Rec));
REPORTER_ASSERT(reporter, layersDetached.elemSize() == sizeof(SkLayerRasterizer_Rec));
SkDeque::F2BIter iterFirstCopy(layersFirstCopy);
SkDeque::F2BIter iterOneLarger(layersOneLarger);
SkDeque::F2BIter iterDetached(layersDetached);
for (int i = 0; i < largerCount; ++i) {
recFirstCopy = static_cast<const SkLayerRasterizer_Rec*>(iterFirstCopy.next());
recOneLarger = static_cast<const SkLayerRasterizer_Rec*>(iterOneLarger.next());
recDetached = static_cast<const SkLayerRasterizer_Rec*>(iterDetached.next());
REPORTER_ASSERT(reporter, equals(*recOneLarger, *recDetached));
if (smallerCount == i) {
REPORTER_ASSERT(reporter, recFirstCopy == nullptr);
} else {
REPORTER_ASSERT(reporter, equals(*recFirstCopy, *recOneLarger));
}
}
}
DEF_TEST(LayerRasterizer_detachEmpty, reporter) {
SkLayerRasterizer::Builder builder;
REPORTER_ASSERT(reporter, nullptr == builder.detach());
}

View File

@ -12,7 +12,6 @@
#include "SkMakeUnique.h"
#include "SkPath.h"
#include "SkRandomScalerContext.h"
#include "SkRasterizer.h"
class SkDescriptor;