DEF_BENCH( return new BigPathBench(kLeft_Align, true); )
DEF_BENCH( return new BigPathBench(kMiddle_Align, true); )
DEF_BENCH( return new BigPathBench(kRight_Align, true); )
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
#define BLUR_SIGMA_LARGE 10.0f
#define BLUR_SIGMA_HUGE 80.0f
-
+
// When 'cropped' is set we apply a cropRect to the blurImageFilter. The crop rect is an inset of
// the source's natural dimensions. This is intended to exercise blurring a larger source bitmap
// to a smaller destination bitmap.
SkMask mask;
if (!SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radius()),
&mask, r, kNormal_SkBlurStyle)) {
- return;
+ return;
}
SkMask::FreeImage(mask.fImage);
}
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
SkISize size = fGM->getISize();
return SkIPoint::Make(size.fWidth, size.fHeight);
}
-
class GeoRectBench_Intersects : public GeoRectBench {
public:
GeoRectBench_Intersects() : GeoRectBench("rect_Intersects") {}
-
+
protected:
void onDraw(int loops, SkCanvas* canvas) override {
for (int outer = 0; outer < loops; ++outer) {
class GeoRectBench_sort : public GeoRectBench {
public:
GeoRectBench_sort() : GeoRectBench("rect_sort") {}
-
+
protected:
void onDraw(int loops, SkCanvas* canvas) override {
for (int outer = 0; outer < loops; ++outer) {
}
};
DEF_BENCH( return new ChopCubicAt; )
-
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); )
DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); )
DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); )
-
DEF_BENCH( return new ChunkAllocBench(64); )
DEF_BENCH( return new ChunkAllocBench(8*1024); )
-
DEF_BENCH( return new MutexBench<SkMutex>(SkString("SkMutex")); )
DEF_BENCH( return new MutexBench<SkSpinlock>(SkString("SkSpinlock")); )
DEF_BENCH( return new SharedBench; )
-
#include "SkString.h"
/**
- * This bench measures the rendering time of the call SkCanvas::drawPatch with different types of
- * input patches (regular case, with loops, a square, with a big difference between "parallel"
- * sides). This bench also tests the different combination of optional parameters for the function
+ * This bench measures the rendering time of the call SkCanvas::drawPatch with different types of
+ * input patches (regular case, with loops, a square, with a big difference between "parallel"
+ * sides). This bench also tests the different combination of optional parameters for the function
* (passing texture coordinates and colors, only textures coordinates, only colors or none).
- * Finally, it applies a scale to test if the size affects the rendering time.
+ * Finally, it applies a scale to test if the size affects the rendering time.
*/
class PatchBench : public Benchmark {
#include "SkString.h"
/**
- * This bench measures the rendering time of a gridof patches.
- * This bench also tests the different combination of optional parameters for the function
+ * This bench measures the rendering time of a gridof patches.
+ * This bench also tests the different combination of optional parameters for the function
* (passing texture coordinates and colors, only textures coordinates, only colors or none).
* Finally, it also has 3 possible sizes small, medium and big to test if the size of the patches
- * in the grid affects time.
+ * in the grid affects time.
*/
class PatchGridBench : public Benchmark {
-
+
public:
-
+
enum Size {
kSmall_Size,
kMedium_Size,
kBig_Size
};
-
+
enum VertexMode {
kNone_VertexMode,
kColors_VertexMode,
kTexCoords_VertexMode,
kBoth_VertexMode
};
-
+
PatchGridBench(Size size, VertexMode vertexMode)
: fVertexMode(vertexMode)
, fSize(size) { }
-
+
void setScale(SkCanvas* canvas){
switch (fSize) {
case kSmall_Size:
break;
}
}
-
+
void setGrid() {
SkPoint vertices[4][5] = {
{{50,50}, {150,50}, {250,50},{350,50},{450,50}},
{{50,250}, {150,250}, {250,250},{350,250},{450,250}},
{{100,300}, {150,350}, {250,350},{350,350},{450,350}}
};
-
+
SkColor cornerColors[4][5] = {
{SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE},
{SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED},
{SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE},
{SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED},
};
-
+
SkPoint texCoords[4][5] = {
{{0.0f,0.0f}, {1.0f,0.0f}, {2.0f,0.0f}, {3.0f,0.0f}, {4.0f,0.0f}},
{{0.0f,1.0f}, {1.0f,1.0f}, {2.0f,1.0f}, {3.0f,1.0f}, {4.0f,1.0f}},
{{0.0f,2.0f}, {1.0f,2.0f}, {2.0f,2.0f}, {3.0f,2.0f}, {4.0f,2.0f}},
{{0.0f,3.0f}, {1.0f,3.0f}, {2.0f,3.0f}, {3.0f,3.0f}, {4.0f,3.0f}},
};
-
+
SkPoint hrzCtrl[4][8] = {
{{75,30},{125,45},{175,70},{225,20},{275,50},{325,50},{375,5},{425,90}},
{{75,150},{125,150},{175,150},{225,150},{275,150},{325,150},{375,150},{425,150}},
{{75,250},{125,250},{175,250},{225,250},{275,200},{325,150},{375,250},{425,250}},
{{75,350},{125,350},{175,350},{225,350},{275,350},{325,350},{375,350},{425,350}}
};
-
+
SkPoint vrtCtrl[6][5] = {
{{50,75},{150,75},{250,75},{350,75},{450,75}},
{{50,125},{150,125},{250,125},{350,125},{450,125}},
{{50,275},{150,275},{250,275},{350,275},{400,305}},
{{50,325},{150,325},{250,325},{350,325},{450,325}}
};
-
+
static const int kRows = 3;
static const int kCols = 4;
-
+
fGrid.reset(kRows, kCols, SkPatchGrid::kColors_VertexType, nullptr);
for (int i = 0; i < kRows; i++) {
for (int j = 0; j < kCols; j++) {
SkPoint points[12];
-
+
//set corners
points[SkPatchUtils::kTopP0_CubicCtrlPts] = vertices[i][j];
points[SkPatchUtils::kTopP3_CubicCtrlPts] = vertices[i][j + 1];
points[SkPatchUtils::kBottomP0_CubicCtrlPts] = vertices[i + 1][j];
points[SkPatchUtils::kBottomP3_CubicCtrlPts] = vertices[i + 1][j + 1];
-
+
points[SkPatchUtils::kTopP1_CubicCtrlPts] = hrzCtrl[i][j * 2];
points[SkPatchUtils::kTopP2_CubicCtrlPts] = hrzCtrl[i][j * 2 + 1];
points[SkPatchUtils::kBottomP1_CubicCtrlPts] = hrzCtrl[i + 1][j * 2];
points[SkPatchUtils::kBottomP2_CubicCtrlPts] = hrzCtrl[i + 1][j * 2 + 1];
-
+
points[SkPatchUtils::kLeftP1_CubicCtrlPts] = vrtCtrl[i * 2][j];
points[SkPatchUtils::kLeftP2_CubicCtrlPts] = vrtCtrl[i * 2 + 1][j];
points[SkPatchUtils::kRightP1_CubicCtrlPts] = vrtCtrl[i * 2][j + 1];
points[SkPatchUtils::kRightP2_CubicCtrlPts] = vrtCtrl[i * 2 + 1][j + 1];
-
+
SkColor colors[4];
colors[0] = cornerColors[i][j];
colors[1] = cornerColors[i][j + 1];
colors[3] = cornerColors[i + 1][j];
colors[2] = cornerColors[i + 1][j + 1];
-
+
SkPoint texs[4];
texs[0] = texCoords[i][j];
texs[1] = texCoords[i][j + 1];
texs[3] = texCoords[i + 1][j];
texs[2] = texCoords[i + 1][j + 1];
-
+
switch (fVertexMode) {
case kNone_VertexMode:
fGrid.setPatch(j, i, points, nullptr, nullptr);
}
}
}
-
+
// override this method to change the shader
sk_sp<SkShader> createShader() {
const SkColor colors[] = {
SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW,
};
const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f } };
-
+
return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
SkShader::kMirror_TileMode);
}
default:
break;
}
-
+
SkString size;
switch (fSize) {
case kSmall_Size:
fName.printf("patch_grid_%s_%s", vertexMode.c_str(), size.c_str());
return fName.c_str();
}
-
+
void onDelayedSetup() override {
this->setGrid();
switch (fVertexMode) {
SkPatchGrid fGrid;
VertexMode fVertexMode;
Size fSize;
-
+
typedef Benchmark INHERITED;
};
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2012 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
kSmallPow2_RectType
};
- RectanizerBench(RectanizerType rectanizerType, RectType rectType)
+ RectanizerBench(RectanizerType rectanizerType, RectType rectType)
: fName("rectanizer_")
, fRectanizerType(rectanizerType)
, fRectType(rectType) {
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
/** This benchmark tests rendering rotated rectangles. It can optionally apply AA and/or change the
paint color between each rect in different ways using the ColorType enum. The xfermode used can
- be specified as well.
+ be specified as well.
*/
enum ColorType {
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2016 Google Inc.
*
DEF_BENCH(return new SkBitmapFPOrigShader(
srcSize, kLinear_SkColorProfileType, mR, true,
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);)
-
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2015 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
///////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return new TopoSortBench(); )
-
-
/*
* Copyright 2012 The Android Open Source Project
*
, fFlags(flags & ~USE_AA)
{
fXfer.reset(SkXfermode::Create(mode));
-
+
fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
fProcN = SkXfermode::GetD32Proc(fXfer, fFlags);
fName.printf("xfer4f_%s_%s_%c_%s_%s",
fDst[i] = 0;
fAAStorage[i] = i * 255 / (N - 1);
}
-
+
if (flags & USE_AA) {
fAA = fAAStorage;
} else {
fDst[i] = 0;
fAAStorage[i] = i * 255 / (N - 1);
}
-
+
if (flags & USE_AA) {
fAA = fAAStorage;
} else {
-
/*
* Copyright 2013 Google Inc.
*
bool HWUITarget::capturePixels(SkBitmap* bmp) {
return this->renderer.capturePixels(bmp);
}
-
-
ClipCubicGM() {
fVPath.moveTo(W, 0);
fVPath.cubicTo(W, H-10, 0, 10, 0, H);
-
+
SkMatrix pivot;
pivot.setRotate(90, W/2, H/2);
fVPath.transform(pivot, &fHPath);
SkString onShortName() override {
return SkString("clipcubic");
}
-
+
SkISize onISize() override {
return SkISize::Make(400, 410);
}
void doDraw(SkCanvas* canvas, const SkPath& path) {
SkPaint paint;
paint.setAntiAlias(true);
-
+
paint.setColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
canvas->drawPath(path, paint);
-
+
paint.setColor(SK_ColorRED);
paint.setStyle(SkPaint::kStroke_Style);
canvas->drawPath(path, paint);
canvas->drawRect(r, paint);
this->doDraw(canvas, path);
-
+
canvas->translate(dx, dy);
canvas->drawRect(r, paint);
canvas->translate(0, 200);
this->drawAndClip(canvas, fHPath, 200, 0);
}
-
+
private:
typedef skiagm::GM INHERITED;
};
-
/*
* Copyright 2015 Google Inc.
*
kLabelSpacing + kShapeTypeSpacing * 1.5f + kShapeSpacing / 2,
kSubtitleSpacing / 2 + fLabelPaint.getTextSize() / 3, fLabelPaint);
canvas->drawText("Src Opaque", sizeof("Src Opaque") - 1,
- kLabelSpacing + kShapeTypeSpacing * 1.5f + kShapeSpacing / 2 +
- kPaintSpacing, kSubtitleSpacing / 2 + fLabelPaint.getTextSize() / 3,
+ kLabelSpacing + kShapeTypeSpacing * 1.5f + kShapeSpacing / 2 +
+ kPaintSpacing, kSubtitleSpacing / 2 + fLabelPaint.getTextSize() / 3,
fLabelPaint);
}
class StrokeCircleGM : public skiagm::GM {
public:
StrokeCircleGM() : fRotate(0) {}
-
+
protected:
SkString onShortName() override { return SkString("strokecircle"); }
-
+
SkISize onISize() override { return SkISize::Make(520, 520); }
-
+
void onDraw(SkCanvas* canvas) override {
canvas->scale(20, 20);
canvas->translate(13, 13);
class ManyArcsGM : public skiagm::GM {
public:
ManyArcsGM() {}
-
+
protected:
SkString onShortName() override { return SkString("manyarcs"); }
-
+
SkISize onISize() override { return SkISize::Make(620, 330); }
-
+
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
for (size_t i = 0; i < SK_ARRAY_COUNT(sweepAngles); ++i) {
sweepAngles[i] *= 180;
}
-
+
SkScalar startAngles[] = { -1, -0.5f, 0, 0.5f };
for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles); ++i) {
startAngles[i] *= 180;
}
-
+
bool anticlockwise = false;
SkScalar sign = 1;
for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles) * 2; ++i) {
canvas->translate(0, 40);
}
}
-
+
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new ManyArcsGM; )
-
void onDraw(SkCanvas* canvas) override {
SkScalar gScales[] = { 0.9f, 0.8f, 0.75f, 0.6f, 0.5f, 0.4f, 0.25f, 0.2f, 0.1f };
-
+
SkASSERT(kNumVertImages-1 == (int)SK_ARRAY_COUNT(gScales)/2);
// Minimize vertically
-
/*
* Copyright 2013 Google Inc.
*
for (size_t et = 0; et < SK_ARRAY_COUNT(kEdgeTypes); ++et) {
GrPrimitiveEdgeType edgeType = kEdgeTypes[et];
canvas->save();
- canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
+ canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
// Draw a background for the test case
SkPaint paint;
-
/*
* Copyright 2011 Google Inc.
*
canvas->clear(sk_tool_utils::color_to_565(0xFFDDDDDD));
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
-
+
SkScalar width = SkIntToScalar(40);
SkScalar height = SkIntToScalar(40);
if (paint.getFontSpacing() > height) {
fBitmap.extractAlpha(&fAlpha);
}
-
+
public:
SkBitmap fBitmap, fAlpha;
-
+
protected:
SkString onShortName() override {
return SkString("extractalpha");
}
-
+
SkISize onISize() override {
return SkISize::Make(540, 330);
}
-
+
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
canvas->drawBitmap(fBitmap, 10, 10, &paint); // should stay blue (ignore paint's color)
canvas->drawBitmap(fAlpha, 120, 10, &paint); // should draw red
}
-
+
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new TestExtractAlphaGM; )
-
DEF_GM( return new DrawBitmapRect4(false); )
DEF_GM( return new DrawBitmapRect4(true); )
#endif
-
-
/*
* Copyright 2013 Google Inc.
*
/** Similar to make_ringed_bitmap with these modifications:
- The backing store is a texture.
- - The texture is larger than the bitmap dimensions (it is surrounded by non-content
+ - The texture is larger than the bitmap dimensions (it is surrounded by non-content
padding on the right/bottom of the contents.)
- The right/bottom sides of the rings are omitted so that the rect to draw is adjacent to
the texture padding.
void onDraw(SkCanvas* canvas) override {
- static const struct {
+ static const struct {
SkFilterQuality fQuality;
const char* fName;
} kQualities[] = {
-
/*
* Copyright 2012 Intel Inc.
*
giantPaint.setAntiAlias(true);
giantPaint.setColor(0x80808080);
canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPaint);
-
+
SkRandom rand;
canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
int i;
canvas->drawRect(rect, fillPaint);
canvas->restore();
-
+
fillPaint.setColor(0xFF000000);
for (size_t i = 0; i < 4; i++) {
const SkRect r = SkRect::MakeWH(50, 100);
sk_sp<SkShader> (*shaders[])() { make_opaque_color, make_alpha_color };
sk_sp<SkColorFilter> (*filters[])() { make_cf_null, make_cf0, make_cf1, make_cf2 };
-
+
SkPaint paint;
for (auto shProc : shaders) {
paint.setShader(shProc());
SkISize onISize() override {
return SkISize::Make(WIDTH, HEIGHT);
}
-
+
void onOnceBeforeDraw() override {
fSolidImg = CreateSolidBitmap(64, 64);
fTransparentImg = CreateTransparentBitmap(64, 64);
typedef skiagm::GM INHERITED;
};
DEF_GM( return new ColorMatrixGM; )
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
SkString str;
str.printf("complexclip3_%s", fDoSimpleClipFirst ? "simple" : "complex");
return str;
- }
+ }
SkISize onISize() { return SkISize::Make(1000, 950); }
canvas->translate(0, r.height() + 5);
}
}
-
+
private:
/** This determines the length and width of the bitmaps used in the ComposeShaders. Values
* above 20 may cause an SkASSERT to fail in SkSmallAllocator. However, larger values will
}
canvas->restore();
- this->drawGiantCircle(canvas);
+ this->drawGiantCircle(canvas);
}
private:
// paths
class ConvexLineOnlyPathsGM : public GM {
public:
- ConvexLineOnlyPathsGM() {
+ ConvexLineOnlyPathsGM() {
this->setBGColor(0xFFFFFFFF);
}
void onDraw(SkCanvas* canvas) override {
// the right edge of the last drawn path
- SkPoint offset = { 0, SkScalarHalf(kMaxPathHeight) };
+ SkPoint offset = { 0, SkScalarHalf(kMaxPathHeight) };
for (int i = 0; i < kNumPaths; ++i) {
this->drawPath(canvas, i, &offset);
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint,
SkScalar finalX = SkIntToScalar(600), SkScalar finalY = SkIntToScalar(0),
- SkScalar phase = SkIntToScalar(0),
+ SkScalar phase = SkIntToScalar(0),
SkScalar startX = SkIntToScalar(0), SkScalar startY = SkIntToScalar(0)) {
SkPaint p(paint);
paint.setStrokeWidth(SkIntToScalar(phase+1));
paint.setColor(gColors[phase]);
sign = (x % 20) ? 1 : -1;
- drawline(canvas, kOn, kOff, paint,
- SkIntToScalar(x), -sign * SkIntToScalar(10003),
+ drawline(canvas, kOn, kOff, paint,
+ SkIntToScalar(x), -sign * SkIntToScalar(10003),
SkIntToScalar(phase),
SkIntToScalar(x), sign * SkIntToScalar(10003));
phase = (phase + 1) % kIntervalLength;
paint.setStrokeWidth(SkIntToScalar(phase+1));
paint.setColor(gColors[phase]);
sign = (y % 20) ? 1 : -1;
- drawline(canvas, kOn, kOff, paint,
- -sign * SkIntToScalar(10003), SkIntToScalar(y),
+ drawline(canvas, kOn, kOff, paint,
+ -sign * SkIntToScalar(10003), SkIntToScalar(y),
SkIntToScalar(phase),
sign * SkIntToScalar(10003), SkIntToScalar(y));
phase = (phase + 1) % kIntervalLength;
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
// Next we play that picture into another picture of the same size.
- pict->playback(recorder.beginRecording(pict->cullRect().width(),
- pict->cullRect().height(),
+ pict->playback(recorder.beginRecording(pict->cullRect().width(),
+ pict->cullRect().height(),
nullptr, 0));
sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture());
public:
DrawAtlasGM() {}
-
+
protected:
-
+
SkString onShortName() override {
return SkString("draw-atlas");
}
-
+
SkISize onISize() override {
return SkISize::Make(640, 480);
}
-
+
void onDraw(SkCanvas* canvas) override {
const SkRect target = { 50, 50, 80, 90 };
if (nullptr == fAtlas) {
SkScalar fDegrees;
SkScalar fTx;
SkScalar fTy;
-
+
void apply(SkRSXform* xform) const {
const SkScalar rad = SkDegreesToRadians(fDegrees);
xform->fSCos = fScale * SkScalarCos(rad);
canvas->translate(0, 100);
canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcIn_Mode, nullptr, &paint);
}
-
+
private:
typedef GM INHERITED;
};
DEF_GM( return new DrawAtlasGM; )
-
paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode));
paint.setColor(SK_ColorWHITE);
- SkRect r = SkRect::MakeXYWH(0, 0,
+ SkRect r = SkRect::MakeXYWH(0, 0,
SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
canvas->drawRect(r, paint);
paint.setColor(SK_ColorRED);
- r = SkRect::MakeXYWH(SkIntToScalar(kBlockSize), 0,
+ r = SkRect::MakeXYWH(SkIntToScalar(kBlockSize), 0,
SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
canvas->drawRect(r, paint);
paint.setColor(SK_ColorGREEN);
- r = SkRect::MakeXYWH(0, SkIntToScalar(kBlockSize),
+ r = SkRect::MakeXYWH(0, SkIntToScalar(kBlockSize),
SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
canvas->drawRect(r, paint);
paint.setColor(SK_ColorTRANSPARENT);
- r = SkRect::MakeXYWH(SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize),
+ r = SkRect::MakeXYWH(SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize),
SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
canvas->drawRect(r, paint);
DrawAtlasColorsGM() {
this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
}
-
+
protected:
SkString onShortName() override {
return SkString("draw-atlas-colors");
}
-
+
SkISize onISize() override {
return SkISize::Make(kNumXferModes * (kAtlasSize + kPad) + kPad,
2 * kNumColors * (kAtlasSize + kPad) + kTextPad + kPad);
}
-
+
void onDraw(SkCanvas* canvas) override {
const SkRect target = SkRect::MakeWH(SkIntToScalar(kAtlasSize), SkIntToScalar(kAtlasSize));
}
for (int i = 0; i < numModes; ++i) {
- canvas->save();
+ canvas->save();
canvas->translate(SkIntToScalar(i*(target.height()+kPad)),
SkIntToScalar(kTextPad+kPad));
// w/o a paint
// w a paint
canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors,
gModes[i].fMode, nullptr, &paint);
- canvas->restore();
+ canvas->restore();
}
}
-
+
private:
static const int kNumXferModes = 29;
static const int kNumColors = 4;
typedef GM INHERITED;
};
DEF_GM( return new DrawAtlasColorsGM; )
-
static sk_sp<SkImage> makebm(SkCanvas* origCanvas, SkBitmap* resultBM, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
-
+
auto surface(origCanvas->makeSurface(info));
if (nullptr == surface) {
// picture canvas will return null, so fall-back to raster
#if SK_SUPPORT_GPU
if (GrTexture* texture = as_IB(image)->peekTexture()) {
GrWrapTextureInBitmap(texture, image->width(), image->height(), image->isOpaque(), &tempBM);
- } else
+ } else
#endif
{
image->asLegacyBitmap(&tempBM, SkImage::kRO_LegacyBitmapMode);
DEF_GM( return new DrawMiniBitmapRectGM(true); )
DEF_GM( return new DrawMiniBitmapRectGM(false); )
-
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
canvas->translate(0, 40);
}
}
-
+
private:
typedef GM INHERITED;
};
for (int i = 0; i < (int)SK_ARRAY_COUNT(gDrawMthds) + kNumXtraCols; ++i) {
canvas->drawLine(SkIntToScalar(i * kTileWidth),
0,
- SkIntToScalar(i * kTileWidth),
+ SkIntToScalar(i * kTileWidth),
SkIntToScalar(paints.count() * kTileWidth),
blackFill);
}
// A column of saveLayers with PictureImageFilters
for (int i = 0; i < pifPaints.count(); ++i) {
- draw_savelayer_with_paint(SkIPoint::Make(0, i*kTileHeight),
+ draw_savelayer_with_paint(SkIPoint::Make(0, i*kTileHeight),
canvas, pifPaints[i]);
}
paint.setTextSkewX(fSkewX);
const SkColor boundsColors[2] = { SK_ColorRED, SK_ColorBLUE };
-
+
SkFontMgr* fm = fFM;
int count = SkMin32(fm->countFamilies(), 32);
static void draw_pair(SkCanvas* canvas, SkPaint* paint, const sk_sp<SkShader>& shader) {
const char text[] = "Now is the time for all good";
const size_t len = strlen(text);
-
+
paint->setShader(nullptr);
canvas->drawText(text, len, 10, 20, *paint);
paint->setShader(SkShader::MakeColorShader(paint->getColor()));
SkString onShortName() override {
return SkString("gammagradienttext");
}
-
+
SkISize onISize() override {
return SkISize::Make(300, 300);
}
canvas->translate(0, 80);
}
}
-
+
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new GammaShaderTextGM; )
-
SkString skiagm::SimpleGM::onShortName() {
return fName;
}
-
-
/*
* Copyright 2013 Google Inc.
*
paint.setDither(fDither);
canvas->drawRect(SkRect::MakeWH(500, 500), paint);
}
-
+
private:
sk_sp<SkShader> fShader;
bool fDither;
paint.setShader(fShader);
canvas->drawRect(SkRect::MakeWH(500, 500), paint);
}
-
+
private:
sk_sp<SkShader> fShader;
bool fDither;
(index + 1) * kHeight), paint);
}
}
-
+
private:
sk_sp<SkShader> fShader[100];
bool fDither;
canvas->translate(0, 120);
}
}
-
+
private:
typedef skiagm::GM INHERITED;
};
#if SK_SUPPORT_GPU
DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); )
#endif
-
-
-
typedef skiagm::GM INHERITED;
};
DEF_GM( return new ImageShaderGM; )
-
canvas->translate(0, 200);
}
}
-
+
private:
typedef GM INHERITED;
};
}
};
DEF_GM( return new ImageFiltersText_CF; )
-
noisePaint.setShader(noise);
SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
- SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10),
- SkIntToScalar(-10),
+ SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10),
+ SkIntToScalar(-10),
SkIntToScalar(20));
SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0);
SkScalar spotExponent = SK_Scalar1;
-
/*
* Copyright 2015 Google Inc.
*
for (int i = 0; i < 3; ++i) {
SkASSERT(fYUVBmps[i].width() == SkToInt(fYUVBmps[i].rowBytes()));
yuvHandles[i] = gpu->createTestingOnlyBackendTexture(fYUVBmps[i].getPixels(),
- fYUVBmps[i].width(),
+ fYUVBmps[i].width(),
fYUVBmps[i].height(),
kAlpha_8_GrPixelConfig);
}
int curColor = 0;
for (int x = 0; x < kImageSize; x += 3) {
- SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(0),
+ SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(0),
SkIntToScalar(3), SkIntToScalar(kImageSize));
SkPaint p;
p.setColor(gColors[curColor]);
-
/*
* Copyright 2013 Google Inc.
*
*/
-/*
+/*
* Tests text rendering with LCD and the various blend modes.
*/
const int kPointSize = 25;
fTextHeight = SkIntToScalar(kPointSize);
}
-
+
protected:
SkString onShortName() override {
return SkString("lcdblendmodes");
void onOnceBeforeDraw() override {
fCheckerboard = sk_tool_utils::create_checkerboard_shader(SK_ColorBLACK, SK_ColorWHITE, 4);
}
-
+
SkISize onISize() override { return SkISize::Make(kWidth, kHeight); }
-
+
void onDraw(SkCanvas* canvas) override {
SkPaint p;
p.setAntiAlias(false);
y+=fTextHeight;
}
}
-
+
private:
SkScalar fTextHeight;
sk_sp<SkShader> fCheckerboard;
const int pointSize = 36;
textHeight = SkIntToScalar(pointSize);
}
-
+
protected:
-
+
SkString onShortName() {
SkString name("lcdtext");
name.append(sk_tool_utils::major_platform_os_name());
return name;
}
-
+
SkISize onISize() { return SkISize::Make(640, 480); }
-
+
virtual void onDraw(SkCanvas* canvas) {
-
+
y = textHeight;
drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderTrue"),
true, true);
drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderFalse"),
false, false);
}
-
+
void drawText(SkCanvas* canvas, const SkString& string,
bool subpixelTextEnabled, bool lcdRenderTextEnabled) {
SkPaint paint;
paint.setSubpixelText(subpixelTextEnabled);
paint.setLCDRenderText(lcdRenderTextEnabled);
paint.setTextSize(textHeight);
-
+
canvas->drawText(string.c_str(), string.size(), 0, y, paint);
y += textHeight;
}
-
+
private:
typedef skiagm::GM INHERITED;
SkScalar y, textHeight;
public:
LcdTextSizeGM() {}
-
+
protected:
SkString onShortName() {
return SkString("lcdtextsize");
}
-
+
SkISize onISize() { return SkISize::Make(320, 120); }
-
+
virtual void onDraw(SkCanvas* canvas) {
const char* lcd_text = "LCD";
const char* gray_text = "GRAY";
SkMatrix matrix;
matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit);
-
+
const SkMatrix& ctm = canvas->getTotalMatrix();
// TODO: correctly pull out the pure rotation
typedef GM INHERITED;
};
DEF_GM( return new LocalMatrixImageFilterGM; )
-
}
canvas->drawImage(img.get(), 20, 20, nullptr);
}
-
SkCanvas* subCanvas = step.fSurf->getCanvas();
- const SkMatrix trans = SkMatrix::MakeTrans(-SkIntToScalar(x*kTileWidth),
+ const SkMatrix trans = SkMatrix::MakeTrans(-SkIntToScalar(x*kTileWidth),
-SkIntToScalar(y*kTileHeight));
create_content(mpd, pfGen, pictures, subCanvas, trans);
SkString onShortName() override {
static const char* gContentNames[] = {
- "noclip", "rectclip", "rrectclip", "pathclip",
+ "noclip", "rectclip", "rrectclip", "pathclip",
"invpathclip", "sierpinski", "biglayer"
};
static const char* gLayoutNames[] = { "simple", "tiled" };
typedef skiagm::GM INHERITED;
};
DEF_GM( return new NinePatchStretchGM; )
-
void onOnceBeforeDraw() override {
fBitmap = SkImage::MakeFromBitmap(
sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e"));
-
+
fCheckerboard = SkImage::MakeFromBitmap(
sk_tool_utils::create_checkerboard_bitmap(80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
class SimpleOffsetImageFilterGM : public skiagm::GM {
public:
SimpleOffsetImageFilterGM() {}
-
+
protected:
SkString onShortName() override {
return SkString("simple-offsetimagefilter");
}
-
+
SkISize onISize() override { return SkISize::Make(640, 200); }
-
+
void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf,
const SkRect* clipR = nullptr) {
SkPaint p;
SkImageFilter::CropRect cr2(r2);
canvas->translate(40, 40);
-
+
canvas->save();
this->doDraw(canvas, r, nullptr);
-
+
canvas->translate(100, 0);
this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20));
-
+
canvas->translate(100, 0);
this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, nullptr, &cr0));
-
+
canvas->translate(100, 0);
this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20), &r);
-
+
canvas->translate(100, 0);
this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, nullptr, &cr1));
-
+
SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
canvas->translate(100, 0);
this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, nullptr, nullptr), &clipR);
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
SK_ColorYELLOW,
};
const SkPoint pts[] = { { 100.f / 4.f, 0.f }, { 3.f * 100.f / 4.f, 100.f } };
-
+
return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
SkShader::kMirror_TileMode);
}
DEF_SIMPLE_GM(patch_primitive, canvas, 800, 800) {
SkPaint paint;
-
+
// The order of the colors and points is clockwise starting at upper-left corner.
const SkPoint cubics[SkPatchUtils::kNumCtrlPts] = {
//top points
//left points
{50,250},{150,150}
};
-
+
const SkColor colors[SkPatchUtils::kNumCorners] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorCYAN
};
const SkPoint texCoords[SkPatchUtils::kNumCorners] = {
{0.0f, 0.0f}, {100.0f, 0.0f}, {100.0f,100.0f}, {0.0f, 100.0f}}
;
-
+
const SkXfermode::Mode modes[] = {
SkXfermode::kSrc_Mode,
SkXfermode::kDst_Mode,
SkXfermode::kModulate_Mode,
};
-
+
sk_sp<SkShader> shader(make_shader());
-
+
canvas->save();
for (int y = 0; y < 3; y++) {
SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(modes[y]));
default:
break;
}
-
+
draw_control_points(canvas, cubics);
canvas->restore();
}
-
/*
* Copyright 2014 Google Inc.
*
* This GM draws a grid of patches, it only uses colors so it could be considered a mesh gradient.
*/
class SkPatchGridGM : public GM {
-
+
public:
SkPatchGridGM() {
this->setBGColor(0xFFFFFFFF);
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
-
+
SkPoint vertices[4][5] = {
{{50,50}, {150,50}, {250,50},{350,50},{450,50}},
{{50,150}, {120,120}, {250,150},{350,150},{450,150}},
{{50,250}, {150,250}, {250,250},{350,250},{450,250}},
{{100,300}, {150,350}, {250,350},{350,350},{450,350}}
};
-
+
SkColor cornerColors[4][5] = {
{SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE},
{SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED},
{SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE},
{SK_ColorRED, SK_ColorBLUE, SK_ColorRED, SK_ColorBLUE, SK_ColorRED},
};
-
+
SkPoint hrzCtrl[4][8] = {
{{75,30},{125,45},{175,70},{225,20},{275,50},{325,50},{375,5},{425,90}},
{{75,150},{125,150},{175,150},{225,150},{275,150},{325,150},{375,150},{425,150}},
{{75,250},{125,250},{175,250},{225,250},{275,200},{325,150},{375,250},{425,250}},
{{75,350},{125,350},{175,350},{225,350},{275,350},{325,350},{375,350},{425,350}}
};
-
+
SkPoint vrtCtrl[6][5] = {
{{50,75},{150,75},{250,75},{350,75},{450,75}},
{{50,125},{150,125},{250,125},{350,125},{450,125}},
{{50,275},{150,275},{250,275},{350,275},{400,305}},
{{50,325},{150,325},{250,325},{350,325},{450,325}}
};
-
+
static const int kRows = 3;
static const int kCols = 4;
-
+
canvas->scale(3, 3);
SkPatchGrid grid(kRows, kCols, SkPatchGrid::kColors_VertexType, nullptr);
for (int i = 0; i < kRows; i++) {
for (int j = 0; j < kCols; j++) {
SkPoint points[12];
-
+
//set corners
points[SkPatchUtils::kTopP0_CubicCtrlPts] = vertices[i][j];
points[SkPatchUtils::kTopP3_CubicCtrlPts] = vertices[i][j + 1];
points[SkPatchUtils::kBottomP0_CubicCtrlPts] = vertices[i + 1][j];
points[SkPatchUtils::kBottomP3_CubicCtrlPts] = vertices[i + 1][j + 1];
-
+
points[SkPatchUtils::kTopP1_CubicCtrlPts] = hrzCtrl[i][j * 2];
points[SkPatchUtils::kTopP2_CubicCtrlPts] = hrzCtrl[i][j * 2 + 1];
points[SkPatchUtils::kBottomP1_CubicCtrlPts] = hrzCtrl[i + 1][j * 2];
points[SkPatchUtils::kBottomP2_CubicCtrlPts] = hrzCtrl[i + 1][j * 2 + 1];
-
+
points[SkPatchUtils::kLeftP1_CubicCtrlPts] = vrtCtrl[i * 2][j];
points[SkPatchUtils::kLeftP2_CubicCtrlPts] = vrtCtrl[i * 2 + 1][j];
points[SkPatchUtils::kRightP1_CubicCtrlPts] = vrtCtrl[i * 2][j + 1];
points[SkPatchUtils::kRightP2_CubicCtrlPts] = vrtCtrl[i * 2 + 1][j + 1];
-
+
SkColor colors[4];
colors[0] = cornerColors[i][j];
colors[1] = cornerColors[i][j + 1];
colors[3] = cornerColors[i + 1][j];
colors[2] = cornerColors[i + 1][j + 1];
-
+
grid.setPatch(j, i, points, colors, nullptr);
}
}
-
+
grid.draw(canvas, paint);
SkISize dims = grid.getDimensions();
for (int y = 0; y < dims.height(); y++) {
///////////////////////////////////////////////////////////////////////////////
DEF_GM( return new StrokeZeroGM(); )
-
DEF_GM( return new ContourStartGM(); )
} // namespace skiagm
-
* paint.setTextSize(SkIntToScalar(100));
* paint.setTypeface(SkTypeface::CreateFromName("Hiragino Maru Gothic Pro"));
* paint.getTextPath("e", 1, 50, 50, &path);
- *
+ *
* The path data is duplicated here to allow the test to
* run on all platforms and to remove the bug dependency
* should future Macs edit or delete the font.
paint.setColor(0x80FF0000);
path.moveTo(0, 0); path.lineTo(100, 0); path.lineTo(100, 100);
canvas->drawPath(path, paint);
-
+
paint.setColor(0x8000FF00);
path.reset(); path.moveTo(0, 0); path.lineTo(100, 0); path.lineTo(0, 100);
canvas->drawPath(path, paint);
SkPaint paint;
canvas->drawPicture(fPicture);
-
+
matrix.setTranslate(110, 0);
canvas->drawPicture(fPicture, &matrix, nullptr);
-
+
matrix.postTranslate(110, 0);
canvas->drawPicture(fPicture, &matrix, &paint);
SkPaint bgPaint;
bgPaint.setShader(
sk_tool_utils::create_checkerboard_shader(
- sk_tool_utils::color_to_565(0xFFAAAAAA),
+ sk_tool_utils::color_to_565(0xFFAAAAAA),
sk_tool_utils::color_to_565(0xFF777777), 1));
canvas->drawPaint(bgPaint);
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2016 Google Inc.
*
GR_GL_CALL(gl, TexParameteri(TARGET, GR_GL_TEXTURE_MIN_FILTER,
GR_GL_NEAREST));
GR_GL_CALL(gl, TexParameteri(TARGET, GR_GL_TEXTURE_WRAP_S,
- GR_GL_CLAMP_TO_EDGE));
+ GR_GL_CLAMP_TO_EDGE));
GR_GL_CALL(gl, TexParameteri(TARGET, GR_GL_TEXTURE_WRAP_T,
GR_GL_CLAMP_TO_EDGE));
GR_GL_CALL(gl, TexImage2D(TARGET, 0, GR_GL_RGBA, width, height, 0,
-
/*
* Copyright 2013 Google Inc.
*
SkShader::kClamp_TileMode);
}
}
-
+
SkBitmap bm;
makebm(&bm, w/16, h/4);
for (size_t tx = 0; tx < SK_ARRAY_COUNT(tileModes); ++tx) {
}
void onDraw(SkCanvas* canvas) override {
- const SkColor colors[] = { sk_tool_utils::color_to_565(0xFF555555),
+ const SkColor colors[] = { sk_tool_utils::color_to_565(0xFF555555),
sk_tool_utils::color_to_565(0xFF444444) };
const int colorCount = SK_ARRAY_COUNT(colors);
-
/*
* Copyright 2016 Google Inc.
*
canvas->translate(0, bm.height() * 0.85f);
}
}
-
+
private:
typedef skiagm::GM INHERITED;
};
canvas->translate(0, SkScalarRoundToScalar(bm.height() * 0.85f));
}
}
-
+
private:
typedef skiagm::GM INHERITED;
};
static SkScalar yOffset = 50.f;
path->moveTo(-32.5f + xOffset, 0.0f + yOffset);
path->lineTo(32.5f + xOffset, 0.0f + yOffset);
-
+
path->moveTo(-32.5f + xOffset, 19 + yOffset);
path->lineTo(32.5f + xOffset, 19 + yOffset);
-
+
path->moveTo(-32.5f + xOffset, -19 + yOffset);
path->lineTo(32.5f + xOffset, -19 + yOffset);
path->lineTo(-32.5f + xOffset, -19 + yOffset);
-
+
path->close();
-
+
return SkIntToScalar(70);
}
static SkScalar yOffset = 40.f;
path->moveTo(-26.f + xOffset, 0.0f + yOffset);
path->lineTo(26.f + xOffset, 0.0f + yOffset);
-
+
path->moveTo(-28.f + xOffset, -2.4748745f + yOffset);
path->lineTo(0 + xOffset, 25.525126f + yOffset);
-
+
path->moveTo(-28.f + xOffset, 2.4748745f + yOffset);
path->lineTo(0 + xOffset, -25.525126f + yOffset);
path->lineTo(-28.f + xOffset, 2.4748745f + yOffset);
path->close();
-
+
return SkIntToScalar(70);
}
path->conicTo(435.93292f + xOffset, 56.000031f + yOffset,
382.61078f + xOffset, 69.752716f + yOffset,
0.9920463f);
-
+
return SkIntToScalar(40);
}
path->lineTo(24.67f + xOffset, 5.3299999f);
path->lineTo(24.67f + xOffset, 0.33000004f);
path->close();
-
+
path->moveTo(25.727224f + xOffset, 12.886665f);
path->lineTo(10.907918f + xOffset, 12.886665f);
path->lineTo(7.5166659f + xOffset, 28.683645f);
static SkScalar make_battery2(SkPath* path) {
static SkScalar xOffset = 5.f;
-
+
path->moveTo(32.669998f + xOffset, 9.8640003f);
path->lineTo(0.33000004f + xOffset, 9.8640003f);
path->lineTo(0.33000004f + xOffset, 50.669998f);
path->lineTo(32.669998f + xOffset, 50.669998f);
path->lineTo(32.669998f + xOffset, 9.8640003f);
path->close();
-
+
path->moveTo(10.907918f + xOffset, 12.886665f);
path->lineTo(25.727224f + xOffset, 12.886665f);
path->lineTo(16.854223f + xOffset, 25.136419f);
path->lineTo(7.5166659f + xOffset, 28.683645f);
path->lineTo(10.907918f + xOffset, 12.886665f);
path->close();
-
+
return SkIntToScalar(70);
}
}
canvas->restore();
canvas->translate(SkIntToScalar(120), SkIntToScalar(0));
-
+
// second column: stroked paths
canvas->save();
paint.setStyle(SkPaint::kStroke_Style);
}
canvas->restore();
canvas->translate(SkIntToScalar(120), SkIntToScalar(0));
-
+
// third column: stroked paths with different widths
canvas->save();
paint.setStyle(SkPaint::kStroke_Style);
}
canvas->restore();
canvas->translate(SkIntToScalar(120), SkIntToScalar(0));
-
+
// fourth column: stroked and filled paths
paint.setStyle(SkPaint::kStrokeAndFill_Style);
paint.setStrokeCap(SkPaint::kButt_Cap);
canvas->drawPath(fPath[i], paint);
canvas->translate(SkIntToScalar(0), fDY[i]);
}
-
+
}
private:
};
DEF_GM(return new SmallPathsGM;)
-
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(100));
paint.setStrokeWidth(SkIntToScalar(5));
-
+
// use paths instead of text to test the path data on all platforms, since the
// Mac-specific font may change or is not available everywhere
path_bold(canvas, papyrus_hello(), paint);
path_bold(canvas, hiragino_maru_gothic_pro_dash(), paint);
-
+
// use the portable typeface to generically test the fake bold code everywhere
// (as long as the freetype option to do the bolding itself isn't enabled)
sk_tool_utils::set_portable_typeface(&paint, "serif");
path3.addRect(r, SkPath::kCCW_Direction);
canvas->drawPath(path3, paint);
- r = SkRect::MakeXYWH(x + SkIntToScalar(70), y + SkIntToScalar(280),
+ r = SkRect::MakeXYWH(x + SkIntToScalar(70), y + SkIntToScalar(280),
SkIntToScalar(100), SkIntToScalar(100));
SkPath path4;
path4.setFillType(SkPath::kWinding_FillType);
path4.addRect(r, SkPath::kCW_Direction);
canvas->drawPath(path4, paint);
- r = SkRect::MakeXYWH(x + SkIntToScalar(190), y + SkIntToScalar(280),
+ r = SkRect::MakeXYWH(x + SkIntToScalar(190), y + SkIntToScalar(280),
SkIntToScalar(100), SkIntToScalar(100));
path4.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
path4.moveTo(0, 0); // test for crbug.com/247770
canvas->drawPath(path4, paint);
- r = SkRect::MakeXYWH(x + SkIntToScalar(310), y + SkIntToScalar(280),
+ r = SkRect::MakeXYWH(x + SkIntToScalar(310), y + SkIntToScalar(280),
SkIntToScalar(100), SkIntToScalar(100));
path4.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
-
/*
* Copyright 2011 Google Inc.
*
p.setStrokeWidth(0);
SkPath path;
SkPoint pts[] = {{105.738571f,13.126318f},
- {105.738571f,13.126318f},
+ {105.738571f,13.126318f},
{123.753784f,1.f}};
SkVector tangent = pts[1] - pts[2];
tangent.normalize();
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(0.055f);
-
+
canvas->scale(1000, 1000);
canvas->drawCircle(0, 2, 1.97f, paint);
}
{ kRGB_V_SkPixelGeometry, "RGB_V" },
{ kBGR_V_SkPixelGeometry, "BGR_V" },
};
-
+
SkScalar x = 0;
for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) {
for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) {
typedef GM INHERITED;
};
DEF_GM( return new NewSurfaceGM )
-
{
fName.printf("colorcomposefilter_%s", suffix);
}
-
+
protected:
virtual SkString onShortName() {
return fName;
}
-
+
virtual SkISize onISize() {
return SkISize::Make(790, 790);
}
canvas->translate(0, r.height() + spacer);
}
}
-
+
private:
typedef GM INHERITED;
};
-
/*
* Copyright 2011 Google Inc.
*
SkRect bounds = fBlob->bounds();
const int yDelta = SkScalarFloorToInt(bounds.height()) + 20;
const int xDelta = SkScalarFloorToInt(bounds.width());
-
+
canvas->drawTextBlob(fBlob, 0, 0, paint);
-
+
canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta));
// draw a rect where the text should be, and then twiddle the xfermode
typedef GM INHERITED;
};
-
+
//////////////////////////////////////////////////////////////////////////////
DEF_GM(return new TextBlobBlockReordering;)
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
};
DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); )
DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); )
-
kSmallTransparentImage_SrcType = 0x40,
//! kRectangleImage_SrcType drawn directly with a mask.
kRectangleWithMask_SrcType = 0x80,
-
+
kAll_SrcType = 0xFF, //!< All the source types.
kBasic_SrcType = 0x03, //!< Just basic source types.
};
{ SkXfermode::kDstOut_Mode, "DstOut", kAll_SrcType },
{ SkXfermode::kSrcATop_Mode, "SrcATop", kAll_SrcType },
{ SkXfermode::kDstATop_Mode, "DstATop", kAll_SrcType },
-
+
{ SkXfermode::kXor_Mode, "Xor", kBasic_SrcType },
{ SkXfermode::kPlus_Mode, "Plus", kBasic_SrcType },
{ SkXfermode::kModulate_Mode, "Modulate", kAll_SrcType },
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2011 Skia
*
-
/*
* Copyright 2011 Skia
*
-
/*
* Copyright 2011 Google Inc.
*
bool GMSampleView::onAnimate(const SkAnimTimer& timer) {
return fGM->animate(timer);
}
-
}
SkPaint paint;
-
+
SkScalar texWidth = fTexScale * TexWidth;
SkScalar texHeight = fTexScale * TexHeight;
const SkPoint texCoords[SkPatchUtils::kNumCorners] = {
{ fTexX + texWidth, fTexY + texHeight},
{ fTexX - texWidth, fTexY + texHeight}}
;
-
+
SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kSrc_Mode));
SkScalar scaleFreq = 2.0;
};
DEF_SAMPLE( return new PerlinPatchView(); )
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
}
bool onAnimate(const SkAnimTimer& timer) override {
- // We add noise to the scale and rotation animations to
+ // We add noise to the scale and rotation animations to
// keep the font atlas from falling into a steady state
fRotation += (1.0f + gRand.nextRangeF(-0.1f, 0.1f));
fScale += (fScaleInc + gRand.nextRangeF(-0.025f, 0.025f));
-
/*
* Copyright 2011 Google Inc.
*
fDeviceType = kGPU_DeviceType;
}
#endif
-
+
#if DEFAULT_TO_GPU
fDeviceType = kGPU_DeviceType;
#endif
void SampleWindow::setDeviceType(DeviceType type) {
if (type == fDeviceType)
return;
-
+
fDevManager->tearDownBackend(this);
-
+
fDeviceType = type;
-
+
fDevManager->setUpBackend(this, fMSAASampleCount);
-
+
this->updateTitle();
this->inval(nullptr);
}
this->setColorType(ct, pt);
fDevManager->tearDownBackend(this);
-
+
fDevManager->setUpBackend(this, fMSAASampleCount);
-
+
this->updateTitle();
this->inval(nullptr);
}
*/
class DeviceManager : public SkRefCnt {
public:
-
+
virtual void setUpBackend(SampleWindow* win, int msaaSampleCount) = 0;
for (int i = 0; i < count; ++i) {
SkMatrix matrix;
matrix.setRSXform(xform[i]);
-
+
canvas->save();
canvas->concat(matrix);
canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()), paint,
fDAlpha = -fDAlpha;
}
}
-
+
SkRSXform asRSXform() const {
return SkRSXform::MakeFromRadians(fScale, fRadian, fCenter.x(), fCenter.y(),
SkScalarHalf(kCellSize), SkScalarHalf(kCellSize));
const SkScalar sx = SkIntToScalar(x);
const SkScalar sy = SkIntToScalar(y);
fTex[i].setXYWH(sx, sy, cell, cell);
-
+
fRec[i].fCenter.set(sx + cell/2, sy + 3*cell/4);
fRec[i].fVelocity.fX = rand.nextSScalar1() * kMaxSpeed;
fRec[i].fVelocity.fY = rand.nextSScalar1() * kMaxSpeed;
const SkColor* colorsPtr = fUseColors ? colors : nullptr;
fProc(canvas, fAtlas.get(), xform, fTex, colorsPtr, N, &cull, &paint);
}
-
+
SkRect onGetBounds() override {
const SkScalar border = kMaxScale * kCellSize;
SkRect r = fBounds;
-
/*
* Copyright 2011 Google Inc.
*
void resetBounce() {
fSrcPts[0].set(0, 0);
fSrcPts[1].set(SCALAR_SIZE, SCALAR_SIZE);
-
+
fSrcVec[0] = unit_vec(30);
fSrcVec[1] = unit_vec(107);
}
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
case kRectAndConcave_Geometry:
canvas->drawPath(create_concave_path(offset), p);
break;
- }
+ }
}
class ClipDrawMatchView : public SampleView {
canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
canvas->clipPath(create_concave_path(offset), SkRegion::kIntersect_Op, useAA);
} break;
- }
+ }
SkISize size = canvas->getDeviceSize();
SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar(size.height()));
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
{
SkRTreeFactory factory;
SkPictureRecorder recorder;
- SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(kBitmapSize),
- SkIntToScalar(kBitmapSize),
+ SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(kBitmapSize),
+ SkIntToScalar(kBitmapSize),
&factory, 0);
drawSomething(recordingCanvas);
sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
SkPaint paint;
paint.setShader(make_shader(SkRect::MakeWH(N, N)));
-
+
canvas->drawPath(path, paint);
return surface->makeImageSnapshot();
}
const SkScalar S = 16; // amount to scale up
const int D = 2; // dimension scaling for the offscreen
// since we only view the center, don't need to produce the entire thing
-
+
SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() * D,
kOpaque_SkAlphaType);
auto surface(origSurf->makeSurface(info));
canvas->translate(-SkScalarHalf(orig->width()) * (S - D) / S,
-SkScalarHalf(orig->height()) * (S - D) / S);
canvas->drawImage(orig, 0, 0, nullptr);
-
+
if (S > 3) {
SkPaint paint;
paint.setColor(SK_ColorWHITE);
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
fInterp = nullptr;
fTime = 0;
}
-
+
void spawnAnimation(SkMSec now) {
this->setTime(now);
W = 640,
H = 480,
};
-
+
struct Rec {
HTDrawable* fDrawable;
};
Rec fArray[N];
sk_sp<SkDrawable> fRoot;
SkMSec fTime;
-
+
HTView() {
SkRandom rand;
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
typedef SampleView INHERITED;
};
DEF_SAMPLE( return new BackdropView; )
-
-
/*
* Copyright 2015 Google Inc.
*
nullptr, nullptr));
paint.setColor(SK_ColorBLACK);
- SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(),
+ SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(),
(SkScalar)fDiffuseBitmap.height());
canvas->drawRect(r, paint);
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
typedef SampleView INHERITED;
};
DEF_SAMPLE( return new ArcToView; )
-
-
/*
* Copyright 2011 Google Inc.
*
if (p0.fY == p1.fY) {
return 0;
}
-
+
if (p0.fY > p1.fY) {
SkTSwap(p0, p1);
}
if (p1.fY <= bounds.top() || p0.fY >= bounds.bottom()) {
return 0;
}
-
+
double dxdy = (double)(p1.fX - p0.fX) / (p1.fY - p0.fY);
if (p0.fY < bounds.top()) {
p0.fX = SkDoubleToScalar(p0.fX + dxdy * (bounds.top() - p0.fY));
p1.fX = SkDoubleToScalar(p1.fX + dxdy * (bounds.bottom() - p1.fY));
p1.fY = bounds.bottom();
}
-
+
// Now p0...p1 is strictly inside bounds vertically, so we just need to clip horizontally
-
+
if (p0.fX > p1.fX) {
SkTSwap(p0, p1);
}
// now we're left-to-right: p0 .. p1
-
+
if (p1.fX <= bounds.left()) { // entirely to the left
p0.fX = p1.fX = bounds.left();
*edges++ = p0;
*edges++ = p1;
return 2;
}
-
+
if (p0.fX < bounds.left()) {
float y = SkDoubleToScalar(p0.fY + (bounds.left() - p0.fX) / dxdy);
*edges++ = SkPoint::Make(bounds.left(), p0.fY);
SkPoint fPoly[N];
SkRect fClip;
SkColor fEdgeColor[N];
-
+
EdgeClipView() : fClip(SkRect::MakeLTRB(150, 150, 550, 450)) {
fPoly[0].set(300, 40);
fPoly[1].set(550, 250);
fEdgeColor[1] = 0xFF00FF00;
fEdgeColor[2] = 0xFF0000FF;
}
-
+
protected:
bool onQuery(SkEvent* evt) override {
if (SampleCode::TitleQ(*evt)) {
MyClick(SkView* view) : Click(view) {}
virtual void handleMove() = 0;
};
-
+
class VertClick : public MyClick {
SkPoint* fPt;
public:
VertClick(SkView* view, SkPoint* pt) : MyClick(view), fPt(pt) {}
void handleMove() override { *fPt = snap(fCurr); }
};
-
+
class DragRectClick : public MyClick {
SkRect* fRect;
public:
DragRectClick(SkView* view, SkRect* rect) : MyClick(view), fRect(rect) {}
void handleMove() override { fRect->offset(fCurr.x() - fPrev.x(), fCurr.y() - fPrev.y()); }
};
-
+
class DragPolyClick : public MyClick {
SkPoint fSrc[100];
SkPoint* fPoly;
return new VertClick(this, &fPoly[i]);
}
}
-
+
SkPath path;
path.addPoly(fPoly, N, true);
if (path.contains(x, y)) {
}
return new DoNothingClick(this);
}
-
+
bool onClick(Click* click) override {
((MyClick*)click)->handleMove();
this->inval(nullptr);
return false;
}
-
+
private:
typedef SampleView INHERITED;
};
DEF_SAMPLE( return new EdgeClipView; )
-
-
/*
* Copyright 2011 Google Inc.
*
static SkView* MyFactory() { return new PathFuzzView; }
static SkViewRegister reg(MyFactory);
-
-
-
/*
* Copyright 2011 Google Inc.
*
return;
}
SkRect bounds = path.getBounds();
- this->setWHZ(SkScalarCeilToInt(bounds.right()), drawText
+ this->setWHZ(SkScalarCeilToInt(bounds.right()), drawText
? SkScalarRoundToInt(scale * 3 / 2) : SkScalarRoundToInt(scale),
SkScalarRoundToInt(950.0f / scale));
erase(fMinSurface);
path.reset();
path.setFillType(SkPath::kEvenOdd_FillType);
path.addCircle(center.fX, center.fY, maxSide + width / 2);
- SkRect outside = SkRect::MakeXYWH(center.fX - maxSide - width, center.fY - maxSide - width,
+ SkRect outside = SkRect::MakeXYWH(center.fX - maxSide - width, center.fY - maxSide - width,
(maxSide + width) * 2, (maxSide + width) * 2);
path.addRect(outside);
canvas->drawPath(path, paint);
if (fArcButton.fEnabled) {
SkPoint center;
if (arcCenter(¢er)) {
- r.set(center.fX - fRadius, center.fY - fRadius, center.fX + fRadius,
+ r.set(center.fX - fRadius, center.fY - fRadius, center.fX + fRadius,
center.fY + fRadius);
}
}
long totArea = 0;
for (int i = 0; i < fCurRandRect; ++i) {
- r = SkRect::MakeXYWH(SkIntToScalar(fRectLocations[i].fX),
+ r = SkRect::MakeXYWH(SkIntToScalar(fRectLocations[i].fX),
SkIntToScalar(fRectLocations[i].fY),
SkIntToScalar((*fCurRects)[i].fWidth),
SkIntToScalar((*fCurRects)[i].fHeight));
-
/*
* Copyright 2011 Google Inc.
*
for (int i = 0; i < count; ++i) {
SkMatrix matrix;
matrix.setRSXform(xform[i]);
-
+
canvas->save();
canvas->concat(matrix);
canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()), paint,
return;
}
}
-
+
SkScalar anchorX = fAtlas->width()*0.5f;
SkScalar anchorY = fAtlas->height()*0.5f;
int currIndex = 0;
for (int y = 0; y < kGrid; y++) {
float xPos = (x / (kGrid - 1.0f)) * kWidth;
float yPos = (y / (kGrid - 1.0f)) * kWidth;
-
+
fTex[currIndex] = SkRect::MakeLTRB(0.0f, 0.0f,
SkIntToScalar(fAtlas->width()),
SkIntToScalar(fAtlas->height()));
SkIntToScalar(fAtlas->height()));
fXform[currIndex] = SkRSXform::MakeFromRadians(0.5f, SK_ScalarPI*0.5f,
kWidth*0.5f, kHeight*0.5f, anchorX, anchorY);
-
+
fCurrentTime = 0;
fTimer.start();
}
~DrawShipView() override {}
-
+
protected:
// overrides from SkEventSink
bool onQuery(SkEvent* evt) override {
}
return this->INHERITED::onQuery(evt);
}
-
+
void onDrawContent(SkCanvas* canvas) override {
const float kCosDiff = 0.99984769515f;
const float kSinDiff = 0.01745240643f;
-
+
if (!fAtlas) {
return;
}
-
+
SkPaint paint;
paint.setFilterQuality(kLow_SkFilterQuality);
paint.setColor(SK_ColorWHITE);
paint.setTextSize(15.0f);
-
+
fTimer.end();
-
+
fTimes[fCurrentTime] = (float)(fTimer.fWall);
fCurrentTime = (fCurrentTime + 1) & 0x1f;
-
+
float meanTime = 0.0f;
for (int i = 0; i < 32; ++i) {
meanTime += fTimes[i];
outString.appendScalar(fps);
outString.append(" ms: ");
outString.appendScalar(meanTime);
-
+
fTimer.start();
-
+
SkScalar anchorX = fAtlas->width()*0.5f;
SkScalar anchorY = fAtlas->height()*0.5f;
for (int i = 0; i < kGrid*kGrid+1; ++i) {
SkScalar c = fXform[i].fSCos;
SkScalar s = fXform[i].fSSin;
-
+
SkScalar dx = c*anchorX - s*anchorY;
SkScalar dy = s*anchorX + c*anchorY;
-
+
fXform[i].fSCos = kCosDiff*c - kSinDiff*s;
fXform[i].fSSin = kSinDiff*c + kCosDiff*s;
-
+
dx -= fXform[i].fSCos*anchorX - fXform[i].fSSin*anchorY;
dy -= fXform[i].fSSin*anchorX + fXform[i].fSCos*anchorY;
fXform[i].fTx += dx;
fXform[i].fTy += dy;
}
-
+
fProc(canvas, fAtlas.get(), fXform, fTex, nullptr, kGrid*kGrid+1, nullptr, &paint);
paint.setColor(SK_ColorBLACK);
canvas->drawRect(SkRect::MakeXYWH(0, 0, 200, 24), paint);
private:
const char* fName;
DrawAtlasProc fProc;
-
+
sk_sp<SkImage> fAtlas;
SkRSXform fXform[kGrid*kGrid+1];
SkRect fTex[kGrid*kGrid+1];
WallTimer fTimer;
float fTimes[32];
int fCurrentTime;
-
-
+
+
typedef SampleView INHERITED;
};
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
fColor = (gRand.nextU() & 0x7F7F7F7F) | SkColorSetARGB(0xFF, 0, 0, 0x80);
fFast32 = fast;
}
-
+
protected:
void onPrepareWidEvent(SkEvent* evt) override {
evt->setType("push-button");
}
return true;
}
-
+
private:
typedef HasEventWig INHERITED;
};
enum {
N = 4
};
-
+
SkRect fModeRect[N_Modes];
SkAutoTUnref<CircDrawable> fDrs[N];
CircDrawable* fSelected;
this->inval(nullptr);
return fSelected ? new Click(this) : nullptr;
}
-
+
bool onClick(Click* click) override {
fSelected->fLoc.fX += click->fCurr.fX - click->fPrev.fX;
fSelected->fLoc.fY += click->fCurr.fY - click->fPrev.fY;
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2016 Google Inc.
*
return data.release();
}
-
-
/*
* Copyright 2016 Google Inc.
*
private:
SkBitmap fResultBitmap;
SkAutoTUnref<const SkMipMap> fCurrMip;
-
+
bool processHQRequest(const SkBitmapProvider&);
bool processMediumRequest(const SkBitmapProvider&);
};
if (fQuality != kHigh_SkFilterQuality) {
return false;
}
-
+
// Our default return state is to downgrade the request to Medium, w/ or w/o setting fBitmap
// to a valid bitmap. If we succeed, we will set this to Low instead.
fQuality = kMedium_SkFilterQuality;
-
+
if (kN32_SkColorType != provider.info().colorType() || !cache_size_okay(provider, fInvMatrix) ||
fInvMatrix.hasPerspective())
{
return false; // can't handle the reqeust
}
-
+
SkScalar invScaleX = fInvMatrix.getScaleX();
SkScalar invScaleY = fInvMatrix.getScaleY();
if (fInvMatrix.getType() & SkMatrix::kAffine_Mask) {
dstW, dstH, SkResourceCache::GetAllocator())) {
return false; // we failed to create fScaledBitmap
}
-
+
SkASSERT(fResultBitmap.getPixels());
fResultBitmap.setImmutable();
if (!provider.isVolatile()) {
}
}
}
-
+
SkASSERT(fResultBitmap.getPixels());
-
+
fInvMatrix.postScale(SkIntToScalar(dstW) / provider.width(),
SkIntToScalar(dstH) / provider.height());
fQuality = kLow_SkFilterQuality;
if (fQuality != kMedium_SkFilterQuality) {
return false;
}
-
+
// Our default return state is to downgrade the request to Low, w/ or w/o setting fBitmap
// to a valid bitmap.
fQuality = kLow_SkFilterQuality;
-
+
SkSize invScaleSize;
if (!fInvMatrix.decomposeScale(&invScaleSize, nullptr)) {
return false;
if (nullptr == fCurrMip->data()) {
sk_throw();
}
-
+
const SkSize scale = SkSize::Make(SkScalarInvert(invScaleSize.width()),
SkScalarInvert(invScaleSize.height()));
SkMipMap::Level level;
void* storage, size_t size) {
return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm, inverse, quality);
}
-
const SkPixmap& pixmap() const { return fPixmap; }
const SkMatrix& invMatrix() const { return fInvMatrix; }
SkFilterQuality quality() const { return fQuality; }
-
+
protected:
SkPixmap fPixmap;
SkMatrix fInvMatrix;
SkFilterQuality fQuality;
-
+
private:
friend class SkBitmapController;
};
class SkDefaultBitmapController : public SkBitmapController {
public:
SkDefaultBitmapController() {}
-
+
protected:
State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
void* storage, size_t storageSize) override;
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
SkASSERT(resultPtr->getPixels());
return true;
}
-
-
/*
* Copyright 2006 The Android Open Source Project
*
virtual void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
int16_t runs[3];
uint8_t aa[2];
-
+
runs[0] = 1;
runs[1] = 1;
runs[2] = 0;
virtual void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
int16_t runs[2];
uint8_t aa[1];
-
+
runs[0] = 1;
runs[1] = 0;
aa[0] = SkToU8(a0);
aa[0] = SkToU8(a1);
this->blitAntiH(x, y + 1, aa, runs);
}
-
+
/**
* Special method just to identify the null blitter, which is returned
* from Choose() if the request cannot be fulfilled. Default impl
-
/*
* Copyright 2006 The Android Open Source Project
*
void blitH(int x, int y, int width) override {
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
-
+
fState.fProc1(fState.fXfer, State::WritableAddr(fDevice, x, y),
&fState.fPM4f, width, nullptr);
}
void blitV(int x, int y, int height, SkAlpha alpha) override {
SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height());
-
+
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
size_t deviceRB = fDevice.rowBytes();
-
+
for (int i = 0; i < height; ++i) {
fState.fProc1(fState.fXfer, device, &fState.fPM4f, 1, &alpha);
device = (typename State::DstType*)((char*)device + deviceRB);
void blitRect(int x, int y, int width, int height) override {
SkASSERT(x >= 0 && y >= 0 &&
x + width <= fDevice.width() && y + height <= fDevice.height());
-
+
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
size_t deviceRB = fDevice.rowBytes();
-
+
do {
fState.fProc1(fState.fXfer, device, &fState.fPM4f, width, nullptr);
y += 1;
void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override {
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
-
+
for (;;) {
int count = *runs;
if (count <= 0) {
void blitLCDMask(const SkMask& mask, const SkIRect& clip) {
auto proc = fState.getLCDProc(SkXfermode::kSrcIsSingle_LCDFlag);
-
+
const int x = clip.fLeft;
const int width = clip.width();
const int y = clip.fTop;
const int height = clip.height();
-
+
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
const size_t dstRB = fDevice.rowBytes();
const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
-
+
for (int i = 0; i < height; ++i) {
proc(device, &fState.fPM4f, width, maskRow);
device = (typename State::DstType*)((char*)device + dstRB);
maskRow = (const uint16_t*)((const char*)maskRow + maskRB);
}
}
-
+
void blitMask(const SkMask& mask, const SkIRect& clip) override {
if (SkMask::kLCD16_Format == mask.fFormat) {
this->blitLCDMask(mask, clip);
this->INHERITED::blitMask(mask, clip);
return;
}
-
+
SkASSERT(mask.fBounds.contains(clip));
-
+
const int x = clip.fLeft;
const int width = clip.width();
const int y = clip.fTop;
const int height = clip.height();
-
+
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
const size_t dstRB = fDevice.rowBytes();
const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
-
+
for (int i = 0; i < height; ++i) {
fState.fProc1(fState.fXfer, device, &fState.fPM4f, width, maskRow);
device = (typename State::DstType*)((char*)device + dstRB);
, fBlitBW(bstate.fBlitBW)
, fBlitAA(bstate.fBlitAA)
{}
-
+
void blitH(int x, int y, int width) override {
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
-
+
if (fBlitBW) {
fBlitBW(&fBState, x, y, fDevice, width);
return;
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
size_t deviceRB = fDevice.rowBytes();
-
+
if (fConstInY) {
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, 1);
}
void blitRect(int x, int y, int width, int height) override {
SkASSERT(x >= 0 && y >= 0 &&
x + width <= fDevice.width() && y + height <= fDevice.height());
-
+
if (fBlitBW) {
for (const int bottom = y + height; y < bottom; ++y) {
fBlitBW(&fBState, x, y, fDevice, width);
}
return;
}
-
+
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
size_t deviceRB = fDevice.rowBytes();
-
+
if (fConstInY) {
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
}
void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override {
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
-
+
for (;;) {
int count = *runs;
if (count <= 0) {
void blitLCDMask(const SkMask& mask, const SkIRect& clip) {
auto proc = fState.getLCDProc(0);
-
+
const int x = clip.fLeft;
const int width = clip.width();
int y = clip.fTop;
-
+
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
const size_t deviceRB = fDevice.rowBytes();
const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
-
+
if (fConstInY) {
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
}
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
const size_t deviceRB = fDevice.rowBytes();
-
+
if (fConstInY) {
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
}
maskRow += maskRB;
}
}
-
+
protected:
State fState;
SkShader::Context::BlitState fBState;
struct State32 : State4f {
typedef uint32_t DstType;
-
+
SkXfermode::D32Proc fProc1;
SkXfermode::D32Proc fProcN;
-
+
State32(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext)
: State4f(info, paint, shaderContext)
{
fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
fProcN = SkXfermode::GetD32Proc(fXfer, fFlags);
}
-
+
SkXfermode::LCD32Proc getLCDProc(uint32_t oneOrManyFlag) const {
uint32_t flags = fFlags & 1;
if (!(fFlags & SkXfermode::kDstIsSRGB_D32Flag)) {
struct State64 : State4f {
typedef uint64_t DstType;
-
+
SkXfermode::D64Proc fProc1;
SkXfermode::D64Proc fProcN;
-
+
State64(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext)
: State4f(info, paint, shaderContext)
{
}
return SkXfermode::GetLCD64Proc(flags | oneOrManyFlag);
}
-
+
static DstType* WritableAddr(const SkPixmap& device, int x, int y) {
return device.writable_addr64(x, y);
}
-
/*
* Copyright 2006 The Android Open Source Project
*
if ((1 == fRefCnt) && fInCache) {
this->inMutexLock();
}
-
+
fRefCnt += 1;
if (fromCache) {
SkASSERT(!fInCache);
default:
break;
}
-
+
if (fromCache) {
SkASSERT(fInCache);
fInCache = false;
}
-
+
// return true when we need to be deleted
return 0 == fRefCnt;
}
void SkCachedData::inMutexLock() {
fMutex.assertHeld();
-
+
SkASSERT(!fIsLocked);
fIsLocked = true;
-
+
switch (fStorageType) {
case kMalloc_StorageType:
this->setData(fStorage.fMalloc);
void SkCachedData::inMutexUnlock() {
fMutex.assertHeld();
-
+
SkASSERT(fIsLocked);
fIsLocked = false;
-
+
switch (fStorageType) {
case kMalloc_StorageType:
// nothing to do/check
return;
}
}
-
+
SkLazyPaint lazy;
if (nullptr == paint) {
paint = lazy.init();
iter.fDevice->drawImage(iter, image, x, y, pnt);
}
}
-
+
LOOPER_END
}
if (nullptr == paint) {
paint = lazy.init();
}
-
+
LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &dst,
image->isOpaque())
-
+
while (iter.next()) {
iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), constraint);
}
-
+
LOOPER_END
}
void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageNine()");
-
+
if (nullptr == paint || paint->canComputeFastBounds()) {
SkRect storage;
if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) : dst)) {
return;
}
}
-
+
SkLazyPaint lazy;
if (nullptr == paint) {
paint = lazy.init();
}
-
+
LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
-
+
while (iter.next()) {
iter.fDevice->drawImageNine(iter, image, center, dst, looper.paint());
}
-
+
LOOPER_END
}
return;
}
}
-
+
SkLazyPaint lazy;
if (nullptr == paint) {
paint = lazy.init();
}
-
+
LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
-
+
while (iter.next()) {
iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint());
}
-
+
LOOPER_END
}
if (paint) {
pnt = *paint;
}
-
+
LOOPER_BEGIN(pnt, SkDrawFilter::kPath_Type, nullptr)
while (iter.next()) {
iter.fDevice->drawAtlas(iter, atlas, xform, tex, colors, count, mode, pnt);
char* fFreePtr;
// data[] follows
- size_t blockSize() {
+ size_t blockSize() {
char* start = this->startOfData();
size_t bytes = fFreePtr - start;
return fFreeSize + bytes;
SkASSERT(totCapacity == totUsed + totLost + totAvailable);
}
#endif
-
// Can only claim alphaunchanged and SkPM4f support if both our proxys do.
return fOuter->getFlags() & fInner->getFlags();
}
-
+
void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) const override {
fInner->filterSpan(shader, count, result);
fOuter->filterSpan(result, count, result);
}
-
+
void filterSpan4f(const SkPM4f shader[], int count, SkPM4f result[]) const override {
fInner->filterSpan4f(shader, count, result);
fOuter->filterSpan4f(result, count, result);
}
-
+
#ifndef SK_IGNORE_TO_STRING
void toString(SkString* str) const override {
SkString outerS, innerS;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter)
-
+
protected:
void flatten(SkWriteBuffer& buffer) const override {
buffer.writeFlattenable(fOuter.get());
buffer.writeFlattenable(fInner.get());
}
-
+
private:
SkComposeColorFilter(sk_sp<SkColorFilter> outer, sk_sp<SkColorFilter> inner,
int composedFilterCount)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
-
// Takes ownership of shaderContext and calls its destructor.
FilterShaderContext(const SkColorFilterShader&, SkShader::Context*, const ContextRec&);
virtual ~FilterShaderContext();
-
+
uint32_t getFlags() const override;
-
+
void shadeSpan(int x, int y, SkPMColor[], int count) override;
void shadeSpan4f(int x, int y, SkPM4f[], int count) override;
// forward to our proxy
fShaderContext->set3DMask(mask);
}
-
+
private:
SkShader::Context* fShaderContext;
-
+
typedef SkShader::Context INHERITED;
};
-
+
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterShader)
-
+
protected:
void flatten(SkWriteBuffer&) const override;
size_t onContextSize(const ContextRec&) const override;
Context* onCreateContext(const ContextRec&, void* storage) const override;
-
+
private:
sk_sp<SkShader> fShader;
sk_sp<SkColorFilter> fFilter;
-
+
typedef SkShader INHERITED;
};
-
/*
* Copyright 2009 The Android Open Source Project
*
return new SkColorTable(colors.release(), count, kAllocatedWithMalloc);
}
-
-
/*
* Copyright 2006 The Android Open Source Project
*
static void copy_g8_to_32(void* dst, size_t dstRB, const void* src, size_t srcRB, int w, int h) {
uint32_t* dst32 = (uint32_t*)dst;
const uint8_t* src8 = (const uint8_t*)src;
-
+
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
dst32[x] = SkPackARGB32(0xFF, src8[x], src8[x], src8[x]);
if (srcInfo.dimensions() != dstInfo.dimensions()) {
return false;
}
-
+
const int width = srcInfo.width();
const int height = srcInfo.height();
-
+
// Do the easiest one first : both configs are equal
if ((srcInfo == dstInfo) && !ctable) {
size_t bytes = width * srcInfo.bytesPerPixel();
return true;
}
}
-
void blitRect(int x, int y, int width, int height) override;
void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) override;
void blitMask(const SkMask&, const SkIRect&) override;
-
+
private:
SkXfermode* fXfermode;
SkPMColor* fBuffer;
SkBlitRow::Proc32 fProc32;
SkBlitRow::Proc32 fProc32Blend;
bool fShadeDirectlyIntoDevice;
-
+
// illegal
SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&);
-
+
typedef SkShaderBlitter INHERITED;
};
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) {
SkPatchUtils::VertexData data;
-
+
SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, draw.fMatrix);
// It automatically adjusts lodX and lodY in case it exceeds the number of indices.
- // If it fails to generate the vertices, then we do not draw.
+ // If it fails to generate the vertices, then we do not draw.
if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width(), lod.height())) {
this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCount, data.fPoints,
data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount,
void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
SkNinePatchIter iter(bitmap.width(), bitmap.height(), center, dst);
-
+
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
for (int i = 0; i < count; ++i) {
SkPoint quad[4];
xform[i].toQuad(tex[i].width(), tex[i].height(), quad);
-
+
SkMatrix localM;
localM.setRSXform(xform[i]);
localM.preTranslate(-tex[i].left(), -tex[i].top());
if (colors) {
pnt.setColorFilter(SkColorFilter::MakeModeFilter(colors[i], mode));
}
-
+
path.rewind();
path.addPoly(quad, 4, true);
path.setConvexity(SkPath::kConvex_Convexity);
static void morphpoints(SkPoint dst[], const SkPoint src[], int count,
SkPathMeasure& meas, const SkMatrix& matrix) {
SkMatrix::MapXYProc proc = matrix.getMapXYProc();
-
+
for (int i = 0; i < count; i++) {
SkPoint pos;
SkVector tangent;
-
+
proc(matrix, src[i].fX, src[i].fY, &pos);
SkScalar sx = pos.fX;
SkScalar sy = pos.fY;
-
+
if (!meas.getPosTan(sx, &pos, &tangent)) {
// set to 0 if the measure failed, so that we just set dst == pos
tangent.set(0, 0);
}
-
+
/* This is the old way (that explains our approach but is way too slow
SkMatrix matrix;
SkPoint pt;
-
+
pt.set(sx, sy);
matrix.setSinCos(tangent.fY, tangent.fX);
matrix.preTranslate(-sx, 0);
}
/* TODO
-
+
Need differentially more subdivisions when the follow-path is curvy. Not sure how to
determine that, but we need it. I guess a cheap answer is let the caller tell us,
but that seems like a cop-out. Another answer is to get Rob Johnson to figure it out.
SkPath::Iter iter(src, false);
SkPoint srcP[4], dstP[3];
SkPath::Verb verb;
-
+
while ((verb = iter.next(srcP)) != SkPath::kDone_Verb) {
switch (verb) {
case SkPath::kMove_Verb:
const SkPath& follow, const SkMatrix* matrix,
const SkPaint& paint) {
SkASSERT(byteLength == 0 || text != nullptr);
-
+
// nothing to draw
if (text == nullptr || byteLength == 0 || draw.fRC->isEmpty()) {
return;
}
-
+
SkTextToPathIter iter((const char*)text, byteLength, paint, true);
SkPathMeasure meas(follow, false);
SkScalar hOffset = 0;
-
+
// need to measure first
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
SkScalar pathLen = meas.getLength();
}
hOffset += pathLen;
}
-
+
const SkPath* iterPath;
SkScalar xpos;
SkMatrix scaledMatrix;
SkScalar scale = iter.getPathScale();
-
+
scaledMatrix.setScale(scale, scale);
-
+
while (iter.next(&iterPath, &xpos)) {
if (iterPath) {
SkPath tmp;
SkMatrix m(scaledMatrix);
-
+
tmp.setIsVolatile(true);
m.postTranslate(xpos + hOffset, 0);
if (matrix) {
class SkDeviceProfile : public SkRefCnt {
public:
-
+
enum LCDConfig {
kNone_LCDConfig, // disables LCD text rendering, uses A8 instead
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2008 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2008 The Android Open Source Project
*
}
SkGlyphCache::~SkGlyphCache() {
- fGlyphMap.foreach ([](SkGlyph* g) {
+ fGlyphMap.foreach ([](SkGlyph* g) {
if (g->fPathData) {
delete g->fPathData->fPath;
} } );
intercept->fInterval[1] = SkTMax(intercept->fInterval[1], val);
}
-void SkGlyphCache::AddPoints(const SkPoint* pts, int ptCount, const SkScalar bounds[2],
+void SkGlyphCache::AddPoints(const SkPoint* pts, int ptCount, const SkScalar bounds[2],
bool yAxis, SkGlyph::Intercept* intercept) {
for (int i = 0; i < ptCount; ++i) {
SkScalar val = *(&pts[i].fY - yAxis);
static void OffsetResults(const SkGlyph::Intercept* intercept, SkScalar scale,
SkScalar xPos, SkScalar* array, int* count);
static void AddInterval(SkScalar val, SkGlyph::Intercept* intercept);
- static void AddPoints(const SkPoint* pts, int ptCount, const SkScalar bounds[2],
+ static void AddPoints(const SkPoint* pts, int ptCount, const SkScalar bounds[2],
bool yAxis, SkGlyph::Intercept* intercept);
static void AddLine(const SkPoint pts[2], SkScalar axis, bool yAxis,
SkGlyph::Intercept* intercept);
-
/*
* Copyright 2006 The Android Open Source Project
*
static const uint32_t sign_mask = 0x80000000u;
static const uint32_t round_mask = ~0xfffu;
SkHalf o = 0;
-
+
FloatUIntUnion floatUnion;
floatUnion.fFloat = f;
-
+
uint32_t sign = floatUnion.fUInt & sign_mask;
floatUnion.fUInt ^= sign;
-
+
// NOTE all the integer compares in this function can be safely
// compiled into signed compares since all operands are below
// 0x80000000. Important if you want fast straight SSE2 code
// (since there's no unsigned PCMPGTD).
-
+
// Inf or NaN (all exponent bits set)
if (floatUnion.fUInt >= f32infty)
// NaN->qNaN and Inf->Inf
if (floatUnion.fUInt > f16infty) {
floatUnion.fUInt = f16infty;
}
-
+
o = floatUnion.fUInt >> 13; // Take the bits!
}
-
+
o |= sign >> 16;
return o;
}
float SkHalfToFloat(SkHalf h) {
static const FloatUIntUnion magic = { 126 << 23 };
FloatUIntUnion o;
-
+
if (halfExponent(h) == 0)
{
// Zero / Denormal
else
o.fUInt |= ((127 - 15 + halfExponent(h)) << 23);
}
-
+
// Set sign
o.fUInt |= (halfSign(h) << 31);
return o.fFloat;
SkBitmap* result, SkIPoint* offset) {
return fDevice->filterImage(filter, src, ctx, result, offset);
}
-
-
/*
* Copyright 2015 Google Inc.
*
LightType type() const { return fType; }
const SkColor3f& color() const { return fColor; }
- const SkVector3& dir() const {
+ const SkVector3& dir() const {
SkASSERT(kAmbient_LightType != fType);
- return fDirection;
+ return fDirection;
}
private:
-
/*
* Copyright 2015 Google Inc.
*
SkLightingShaderImpl(const SkBitmap& diffuse, const SkBitmap& normal,
const SkLightingShader::Lights* lights,
const SkVector& invNormRotation,
- const SkMatrix* diffLocalM, const SkMatrix* normLocalM)
+ const SkMatrix* diffLocalM, const SkMatrix* normLocalM)
: INHERITED(diffLocalM)
, fDiffuseMap(diffuse)
, fNormalMap(normal)
"Xform", &xformUniName);
fragBuilder->codeAppend("vec4 diffuseColor = ");
- fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0],
- args.fCoords[0].c_str(),
+ fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0],
+ args.fCoords[0].c_str(),
args.fCoords[0].getType());
fragBuilder->codeAppend(";");
fragBuilder->codeAppend("vec4 normalColor = ");
fragBuilder->appendTextureLookup(args.fSamplers[1],
- args.fCoords[1].c_str(),
+ args.fCoords[1].c_str(),
args.fCoords[1].getType());
fragBuilder->codeAppend(";");
fragBuilder->codeAppendf(
"mat3 m = mat3(%s.x, -%s.y, 0.0, %s.y, %s.x, 0.0, 0.0, 0.0, 1.0);",
xformUniName, xformUniName, xformUniName, xformUniName);
-
+
// TODO: inverse map the light direction vectors in the vertex shader rather than
// transforming all the normals here!
fragBuilder->codeAppend("normal = normalize(m*normal);");
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new LightingGLFP; }
- bool onIsEqual(const GrFragmentProcessor& proc) const override {
+ bool onIsEqual(const GrFragmentProcessor& proc) const override {
const LightingFP& lightingFP = proc.cast<LightingFP>();
return fDiffDeviceTransform == lightingFP.fDiffDeviceTransform &&
fNormDeviceTransform == lightingFP.fNormDeviceTransform &&
const SkMatrix& localMatrix1,
const SkMatrix* localMatrix2,
SkMatrix* result) {
-
+
result->setIDiv(bm.width(), bm.height());
SkMatrix lmInverse;
SkASSERT(fDiffuseMap.width() == fNormalMap.width() &&
fDiffuseMap.height() == fNormalMap.height());
SkMatrix diffM, normM;
-
+
if (!make_mat(fDiffuseMap, this->getLocalMatrix(), localMatrix, &diffM)) {
return nullptr;
}
bool doBicubic;
GrTextureParams::FilterMode diffFilterMode = GrSkFilterQualityToGrFilterMode(
- SkTMin(filterQuality, kMedium_SkFilterQuality),
+ SkTMin(filterQuality, kMedium_SkFilterQuality),
viewM,
this->getLocalMatrix(),
- &doBicubic);
+ &doBicubic);
SkASSERT(!doBicubic);
GrTextureParams::FilterMode normFilterMode = GrSkFilterQualityToGrFilterMode(
- SkTMin(filterQuality, kMedium_SkFilterQuality),
+ SkTMin(filterQuality, kMedium_SkFilterQuality),
viewM,
fNormLocalMatrix,
- &doBicubic);
+ &doBicubic);
SkASSERT(!doBicubic);
// TODO: support other tile modes
color.fX = 0.0f;
} else if (color.fX >= 255.0f) {
color.fX = 255.0f;
- }
+ }
if (color.fY <= 0.0f) {
color.fY = 0.0f;
} else if (color.fY >= 255.0f) {
color.fY = 255.0f;
- }
+ }
if (color.fZ <= 0.0f) {
color.fZ = 0.0f;
} else if (color.fZ >= 255.0f) {
color.fZ = 255.0f;
- }
+ }
return SkPreMultiplyARGB(a, (int) color.fX, (int) color.fY, (int) color.fZ);
}
xformedNorm.fX = lightShader.fInvNormRotation.fX * norm.fX +
lightShader.fInvNormRotation.fY * norm.fY;
- xformedNorm.fY = lightShader.fInvNormRotation.fX * norm.fX -
+ xformedNorm.fY = lightShader.fInvNormRotation.fX * norm.fX -
lightShader.fInvNormRotation.fY * norm.fY;
xformedNorm.fZ = norm.fZ;
if (!buf.readScalarArray(&dir.fX, 3)) {
return nullptr;
}
- builder.add(SkLight(color, dir));
+ builder.add(SkLight(color, dir));
}
}
@param normal the normal map
@param light the light applied to the normal map
@param ambient the linear (unpremul) ambient light color. Range is 0..1/channel.
- @param localMatrix the matrix mapping the textures to the dest rect
+ @param localMatrix the matrix mapping the textures to the dest rect
nullptr will be returned if:
either 'diffuse' or 'normal' are empty
-
/*
* Copyright 2011 Google Inc.
*
// first pixel to the center of the last pixel. This implies that length is count-1.
fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count});
}
-
-
/*
* Copyright 2006 The Android Open Source Project
*
* @param B The number of luminance bits to use [1, 8] from the blue channel.
*/
template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskGamma : public SkRefCnt {
-
+
public:
/** Creates a linear SkTMaskGamma. */
const uint8_t* getGammaTables() const {
return (const uint8_t*) fGammaTables;
}
-
+
private:
static const int MAX_LUM_BITS =
B_LUM_BITS > (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS)
-
/*
* Copyright 2006 The Android Open Source Project
*
void SkModeColorFilter::filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) const {
SkPMColor color = fPMColor;
SkXfermodeProc proc = fProc;
-
+
for (int i = 0; i < count; i++) {
result[i] = proc(color, shader[i]);
}
void SkModeColorFilter::filterSpan4f(const SkPM4f shader[], int count, SkPM4f result[]) const {
SkPM4f color = SkPM4f::FromPMColor(fPMColor);
SkXfermodeProc4f proc = SkXfermode::GetProc4f(fMode);
-
+
for (int i = 0; i < count; i++) {
result[i] = proc(color, shader[i]);
}
GrLayerHoister::End(context);
#endif
}
-
fSrcX[1] = SkIntToScalar(c.fLeft);
fSrcX[2] = SkIntToScalar(c.fRight);
fSrcX[3] = SkIntToScalar(w);
-
+
fSrcY[0] = 0;
fSrcY[1] = SkIntToScalar(c.fTop);
fSrcY[2] = SkIntToScalar(c.fBottom);
fSrcY[3] = SkIntToScalar(h);
-
+
fDstX[0] = dst.fLeft;
fDstX[1] = dst.fLeft + SkIntToScalar(c.fLeft);
fDstX[2] = dst.fRight - SkIntToScalar(w - c.fRight);
fDstX[3] = dst.fRight;
-
+
fDstY[0] = dst.fTop;
fDstY[1] = dst.fTop + SkIntToScalar(c.fTop);
fDstY[2] = dst.fBottom - SkIntToScalar(h - c.fBottom);
fDstY[3] = dst.fBottom;
-
+
if (fDstX[1] > fDstX[2]) {
fDstX[1] = fDstX[0] + (fDstX[3] - fDstX[0]) * c.fLeft / (w - c.width());
fDstX[2] = fDstX[1];
* While it returns true, use src/dst to draw the image/bitmap
*/
bool next(SkRect* src, SkRect* dst);
-
+
private:
SkScalar fSrcX[4];
SkScalar fSrcY[4];
SkScalar fDstX[4];
SkScalar fDstY[4];
-
+
int fCurrX;
int fCurrY;
bool fDone;
};
#endif
-
}
int SkPaint::getTextIntercepts(const void* textData, size_t length,
- SkScalar x, SkScalar y, const SkScalar bounds[2],
+ SkScalar x, SkScalar y, const SkScalar bounds[2],
SkScalar* array) const {
SkASSERT(length == 0 || textData != nullptr);
if (!length) {
kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque
kNotOpaque_ShaderOverrideOpacity, //!< the overriding shader may not be opaque
};
-
+
/**
* Returns true if drawing with this paint (or nullptr) will ovewrite all affected pixels.
*
if ((onCurveCount & 1) || evenOddFill) {
return SkToBool(onCurveCount & 1) ^ isInverse;
}
- // If the point touches an even number of curves, and the fill is winding, check for
+ // If the point touches an even number of curves, and the fill is winding, check for
// coincidence. Count coincidence as places where the on curve points have identical tangents.
iter.setPath(*this, true);
done = false;
-
/*
* Copyright 2008 The Android Open Source Project
*
if (count <= 0) {
return ~0;
}
-
+
SkASSERT(base != nullptr); // base may be nullptr if count is zero
-
+
int lo = 0;
int hi = count - 1;
-
+
while (lo < hi) {
int mid = (hi + lo) >> 1;
if (base[mid].fDistance < key) {
hi = mid;
}
}
-
+
if (base[hi].fDistance < key) {
hi += 1;
hi = ~hi;
*/
static FirstDirection OppositeFirstDirection(FirstDirection dir) {
static const FirstDirection gOppositeDir[] = {
- kCCW_FirstDirection, kCW_FirstDirection, kUnknown_FirstDirection,
+ kCCW_FirstDirection, kCW_FirstDirection, kUnknown_FirstDirection,
};
return gOppositeDir[dir];
}
-
/*
* Copyright 2006 The Android Open Source Project
*
}
#endif
///////////////////////////////////////////////////////////////////////////////
-
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
SkCanvas::SaveLayerFlags SkCanvas::LegacySaveFlagsToSaveLayerFlags(uint32_t flags) {
uint32_t layerFlags = 0;
-
+
if (0 == (flags & kClipToLayer_LegacySaveFlags)) {
layerFlags |= SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag;
}
SkASSERTF(false, "Unknown draw type: %d", op);
}
}
-
}
///////////////////////////////////////////////////////////////////////////////
-
-
/*
* Copyright 2014 Google Inc.
*
if (!r.intersect(srcRect, subset)) {
return false; // r is empty (i.e. no intersection)
}
-
+
// If the upper left of the rectangle was outside the bounds of this SkBitmap, we should have
// exited above.
SkASSERT(static_cast<unsigned>(r.fLeft) < static_cast<unsigned>(this->width()));
if (0 == requestedDstInfo.width() || 0 == requestedDstInfo.height()) {
return false;
}
-
+
SkIRect srcR = SkIRect::MakeXYWH(x, y, requestedDstInfo.width(), requestedDstInfo.height());
if (!srcR.intersect(0, 0, this->width(), this->height())) {
return false;
}
-
+
// the intersect may have shrunk info's logical size
const SkImageInfo dstInfo = requestedDstInfo.makeWH(srcR.width(), srcR.height());
-
+
// if x or y are negative, then we have to adjust pixels
if (x > 0) {
x = 0;
int height = area.height();
const int width = area.width();
const int rowBytes = this->rowBytes();
-
+
switch (this->colorType()) {
case kGray_8_SkColorType: {
if (255 != a) {
case kRGB_565_SkColorType: {
uint16_t* p = this->writable_addr16(area.fLeft, area.fTop);
uint16_t v;
-
+
// make rgb premultiplied
if (255 != a) {
r = SkMulDiv255Round(r, a);
g = SkMulDiv255Round(g, a);
b = SkMulDiv255Round(b, a);
}
-
+
if (kARGB_4444_SkColorType == this->colorType()) {
v = pack_8888_to_4444(a, r, g, b);
} else {
case kBGRA_8888_SkColorType:
case kRGBA_8888_SkColorType: {
uint32_t* p = this->writable_addr32(area.fLeft, area.fTop);
-
+
if (255 != a && kPremul_SkAlphaType == this->alphaType()) {
r = SkMulDiv255Round(r, a);
g = SkMulDiv255Round(g, a);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
-
-
/*
* Copyright 2008 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2008 The Android Open Source Project
*
*/
class SkPtrSet : public SkRefCnt {
public:
-
+
/**
* Search for the specified ptr in the set. If it is found, return its
*/
class SkNamedFactorySet : public SkRefCnt {
public:
-
+
SkNamedFactorySet();
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2012 Google Inc.
*
}
} else {
base.setRect(bounds);
-
+
if (SkRegion::kReplace_Op == op) {
return this->setPath(path, base, doAA);
} else {
}
return this->op(ir, op);
}
-
+
if (fIsBW && doAA) {
// check that the rect really needs aa, or is it close enought to
// integer boundaries that we can just treat it as a BW rect?
void SkRasterClip::convertToAA() {
AUTO_RASTERCLIP_VALIDATE(*this);
-
+
SkASSERT(!fForceConservativeRects);
-
+
SkASSERT(fIsBW);
fAA.setRegion(fBW);
fIsBW = false;
-
+
// since we are being explicitly asked to convert-to-aa, we pass false so we don't "optimize"
// ourselves back to BW.
(void)this->updateCacheAndReturnNonEmpty(false);
bool op(const SkRect&, const SkIRect&, SkRegion::Op, bool doAA);
bool op(const SkRRect&, const SkIRect&, SkRegion::Op, bool doAA);
bool op(const SkPath&, const SkIRect&, SkRegion::Op, bool doAA);
-
+
void translate(int dx, int dy, SkRasterClip* dst) const;
void translate(int dx, int dy) {
this->translate(dx, dy, this);
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2010 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 The Android Open Source Project
*
} else {
rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdgesUp;
}
-
+
walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc, rightEdge);
}
}
}
~SkSpecialImage_Image() override { }
-
+
bool isOpaque() const override { return fImage->isOpaque(); }
size_t getSize() const override {
bool getBitmapDeprecated(SkBitmap* result) const override {
#if SK_SUPPORT_GPU
if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) {
- const SkImageInfo info = GrMakeInfoFromTexture(texture,
+ const SkImageInfo info = GrMakeInfoFromTexture(texture,
fImage->width(), fImage->height(),
fImage->isOpaque());
if (!result->setInfo(info)) {
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
SkBitmap subsetBM;
-
+
if (!fBitmap.extractSubset(&subsetBM, subset)) {
return nullptr;
}
#include "SkImage_Gpu.h"
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
-public:
+public:
SkSpecialImage_Gpu(SkImageFilter::Proxy* proxy, const SkIRect& subset,
uint32_t uniqueID, GrTexture* tex, SkAlphaType at)
: INHERITED(proxy, subset, uniqueID)
GrTexture* onPeekTexture() const override { return fTexture; }
bool getBitmapDeprecated(SkBitmap* result) const override {
- const SkImageInfo info = GrMakeInfoFromTexture(fTexture,
+ const SkImageInfo info = GrMakeInfoFromTexture(fTexture,
this->width(), this->height(),
this->isOpaque());
if (!result->setInfo(info)) {
bool testingOnlyOnGetROPixels(SkBitmap* result) const override {
- const SkImageInfo info = SkImageInfo::MakeN32(this->width(),
+ const SkImageInfo info = SkImageInfo::MakeN32(this->width(),
this->height(),
this->isOpaque() ? kOpaque_SkAlphaType
: kPremul_SkAlphaType);
return SkSpecialImage::MakeFromGpu(this->internal_getProxy(),
subset,
this->uniqueID(),
- fTexture,
+ fTexture,
fAlphaType);
}
};
sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+ const SkIRect& subset,
uint32_t uniqueID,
GrTexture* tex,
SkAlphaType at) {
static sk_sp<SkSpecialImage> MakeFromGpu(SkImageFilter::Proxy*,
const SkIRect& subset,
uint32_t uniqueID,
- GrTexture*,
+ GrTexture*,
SkAlphaType at = kPremul_SkAlphaType);
static sk_sp<SkSpecialImage> MakeFromPixmap(SkImageFilter::Proxy*,
const SkIRect& subset,
};
#endif
-
SkPixelRef* pr,
const SkIRect& subset,
const SkSurfaceProps* props)
- : INHERITED(proxy, subset, props) {
+ : INHERITED(proxy, subset, props) {
const SkImageInfo& info = pr->info();
fBitmap.setInfo(info, info.minRowBytes());
typedef SkSpecialSurface_Base INHERITED;
};
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(SkImageFilter::Proxy* proxy,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(SkImageFilter::Proxy* proxy,
const SkIRect& subset,
GrTexture* texture,
const SkSurfaceProps* props) {
/**
* Return a canvas that will draw into this surface. This will always
* return the same canvas for a given surface, and is managed/owned by the
- * surface.
+ * surface.
*
* The canvas will be invalid after 'newImageSnapshot' is called.
*/
fFilter = SkFilterSpanProc_Choose(paint);
fBuffer.reset(src.width());
}
-
+
protected:
SkXfermode* fXfer;
SkLoadSpanProc fLoader;
SkFilterSpanProc fFilter;
SkAutoTMalloc<SkPM4f> fBuffer;
-
+
private:
typedef SkSpriteBlitter INHERITED;
};
dst = (uint64_t* SK_RESTRICT)((char*)dst + dstRB);
}
}
-
+
private:
SkXfermode::D64Proc fWriter;
}
fWriter = SkXfermode::GetD32Proc(fXfer, flags);
}
-
+
void blitRect(int x, int y, int width, int height) override {
SkASSERT(width > 0 && height > 0);
uint32_t* SK_RESTRICT dst = fDst.writable_addr32(x, y);
size_t dstRB = fDst.rowBytes();
-
+
for (int bottom = y + height; y < bottom; ++y) {
fLoader(fSource, x - fLeft, y - fTop, fBuffer, width);
fFilter(*fPaint, fBuffer, width);
dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
}
}
-
+
protected:
SkXfermode::D32Proc fWriter;
-
+
private:
typedef Sprite_4f INHERITED;
};
SkSpriteBlitter* SkSpriteBlitter::ChooseS32(const SkPixmap& source, const SkPaint& paint,
SkTBlitterAllocator* allocator) {
SkASSERT(allocator != nullptr);
-
+
if (paint.getMaskFilter() != nullptr) {
return nullptr;
}
-
+
switch (source.colorType()) {
case kN32_SkColorType:
case kRGBA_F16_SkColorType:
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
continue;
}
return true;
- case SkPath::kClose_Verb:
+ case SkPath::kClose_Verb:
case SkPath::kDone_Verb:
return false;
}
SkScalar xT = 0, yT = 0;
(void) conic.findXExtrema(&xT);
(void) conic.findYExtrema(&yT);
- SkScalar t = SkTMax(xT, yT);
+ SkScalar t = SkTMax(xT, yT);
if (0 == t) {
return kLine_ReductionType;
}
#include "SkStroke.h"
-#ifdef SK_DEBUG
+#ifdef SK_DEBUG
// enables tweaking these values at runtime from SampleApp
bool gDebugStrokerErrorSet = false;
SkScalar gDebugStrokerError;
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
void SkSwapRB(uint32_t* dest, const uint32_t* src, int count) {
SkOpts::RGBA_to_BGRA(dest, src, count);
}
-
-
/** Gets the next item in the queue without popping it. */
const T& peek() const { return fArray[0]; }
T& peek() { return fArray[0]; }
-
+
/** Removes the next item. */
void pop() {
this->validate();
SkASSERT(index >= 0);
do {
int child = LeftOf(index);
-
+
if (child >= fArray.count()) {
// We're a leaf.
this->setIndex(index);
}
SkTDArray<T> fArray;
-
+
typedef SkNoncopyable INHERITED;
};
fDeleted = 0;
}
- void reset() {
- fCount = 0;
- fDeleted = 0;
- fCapacity = 0;
- sk_free(fArray);
- fArray = nullptr;
+ void reset() {
+ fCount = 0;
+ fDeleted = 0;
+ fCapacity = 0;
+ sk_free(fArray);
+ fArray = nullptr;
}
protected:
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
void SkTaskGroup::batch(int N, std::function<void(int)> fn) {
ThreadPool::Batch(N, fn, &fPending);
}
-
-
/*
* Copyright 2010 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2012 The Android Open Source Project
*
-
/*
* Copyright 2012 The Android Open Source Project
*
-
/*
* Copyright 2012 Google Inc.
*
*g = L + (*g - L) * scale;
*b = L + (*b - L) * scale;
}
-
+
if ((x > a) && (denom = x - L)) { // Compute denom and make sure it's non zero
float scale = (a - L) / denom;
*r = L + (*r - L) * scale;
float sr = s[SkPM4f::R];
float sg = s[SkPM4f::G];
float sb = s[SkPM4f::B];
-
+
float da = d[SkPM4f::A];
float dr = d[SkPM4f::R];
float dg = d[SkPM4f::G];
float sr = s[SkPM4f::R];
float sg = s[SkPM4f::G];
float sb = s[SkPM4f::B];
-
+
float da = d[SkPM4f::A];
float dr = d[SkPM4f::R];
float dg = d[SkPM4f::G];
float db = d[SkPM4f::B];
-
+
float Dr = dr;
float Dg = dg;
float Db = db;
SetSat(&Dr, &Dg, &Db, Sat(sr, sg, sb) * da);
SetLum(&Dr, &Dg, &Db, sa * da, Lum(dr, dg, db) * sa);
-
+
return color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Dr, Dg, Db),
sa + da - sa * da);
}
float sr = s[SkPM4f::R];
float sg = s[SkPM4f::G];
float sb = s[SkPM4f::B];
-
+
float da = d[SkPM4f::A];
float dr = d[SkPM4f::R];
float dg = d[SkPM4f::G];
float Sg = sg;
float Sb = sb;
SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa);
-
+
Sk4f res = color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Sr, Sg, Sb),
sa + da - sa * da);
// Can return tiny negative values ...
float sr = s[SkPM4f::R];
float sg = s[SkPM4f::G];
float sb = s[SkPM4f::B];
-
+
float da = d[SkPM4f::A];
float dr = d[SkPM4f::R];
float dg = d[SkPM4f::G];
float db = d[SkPM4f::B];
-
+
float Dr = dr;
float Dg = dg;
float Db = db;
SetLum(&Dr, &Dg, &Db, sa * da, Lum(sr, sg, sb) * da);
-
+
Sk4f res = color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Dr, Dg, Db),
sa + da - sa * da);
// Can return tiny negative values ...
SkXfermode::D64Proc SkXfermode::onGetD64Proc(uint32_t flags) const {
SkASSERT(0 == (flags & ~7));
flags &= 7;
-
+
Mode mode;
return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags];
}
SkXfermode::D64Proc SkXfermode::GetD64Proc(SkXfermode* xfer, uint32_t flags) {
return xfer ? xfer->onGetD64Proc(flags) : find_proc(SkXfermode::kSrcOver_Mode, flags);
}
-
if (!CHECK_LOCAL(localCache, find, Find, key, YUVPlanesRec::Visitor, &result)) {
return nullptr;
}
-
+
*info = result.fInfo;
return result.fData;
}
-
/*
* Copyright 2015 Google Inc.
*
// We just want to compute "length(vec) - %s.z + 0.5) * %s.w" but need to rearrange
// for precision
- fragBuilder->codeAppendf("vec2 vec = vec2( (%s.x - %s.x) * %s.w , (%s.y - %s.y) * %s.w );",
+ fragBuilder->codeAppendf("vec2 vec = vec2( (%s.x - %s.x) * %s.w , (%s.y - %s.y) * %s.w );",
fragmentPos, dataName, dataName,
fragmentPos, dataName, dataName);
fragBuilder->codeAppendf("float dist = length(vec) + ( 0.5 - %s.z ) * %s.w;",
GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(const SkRect& circle,
float sigma,
float offset,
- GrTexture* blurProfile)
+ GrTexture* blurProfile)
: fCircle(circle)
, fSigma(sigma)
, fOffset(offset)
class GrTextureProvider;
-// This FP handles the special case of a blurred circle. It uses a 1D
+// This FP handles the special case of a blurred circle. It uses a 1D
// profile that is just rotated about the origin of the circle.
class GrCircleBlurFragmentProcessor : public GrFragmentProcessor {
public:
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
str->append(")");
}
#endif
-
fK[3] = k4;
fEnforcePMColor = enforcePMColor;
}
-
+
void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) const override;
SK_TO_STRING_OVERRIDE()
SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4)) {
return SkXfermode::Create(SkXfermode::kDst_Mode);
}
-
+
return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor);
}
GrXPFactory::InvariantBlendedColor*) const override;
private:
- GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePMColor);
+ GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePMColor);
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
bool hasMixedSamples,
- const DstTexture*) const override;
+ const DstTexture*) const override;
bool onWillReadDstColor(const GrCaps& caps,
const GrPipelineOptimizations& optimizations,
}
AvoidFP(SkColor opColor, uint8_t tolerance,
- SkAvoidXfermode::Mode mode, const GrFragmentProcessor* dst)
+ SkAvoidXfermode::Mode mode, const GrFragmentProcessor* dst)
: fOpColor(opColor), fTolerance(tolerance), fMode(mode) {
this->initClassID<AvoidFP>();
void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
- bool onIsEqual(const GrXferProcessor& xpBase) const override {
+ bool onIsEqual(const GrXferProcessor& xpBase) const override {
const AvoidXP& xp = xpBase.cast<AvoidXP>();
return fOpColor == xp.fOpColor &&
SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
}
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
+ return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
SkIRect::MakeWH(dstBounds.width(),
dstBounds.height()),
dst);
-
/*
* Copyright 2006 The Android Open Source Project
*
// in OpenGL ES, mediump floats have a minimum range of 2^14. If we have coordinates bigger
// than that, the shader math will end up with infinities and result in the blur effect not
// working correctly. To avoid this, we switch into highp when the coordinates are too big.
- // As 2^14 is the minimum range but the actual range can be bigger, we might end up
- // switching to highp sooner than strictly necessary, but most devices that have a bigger
+ // As 2^14 is the minimum range but the actual range can be bigger, we might end up
+ // switching to highp sooner than strictly necessary, but most devices that have a bigger
// range for mediump also have mediump being exactly the same as highp (e.g. all non-OpenGL
// ES devices), and thus incur no additional penalty for the switch.
static const SkScalar kMAX_BLUR_COORD = SkIntToScalar(16000);
fragBuilder->codeAppendf("vec4 src=vec4(1);");
}
- fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precisionString, fragmentPos,
+ fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precisionString, fragmentPos,
rectName);
fragBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString, rectName, rectName);
fragBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString, rectName, rectName);
- fragBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s);", precisionString,
+ fragBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s);", precisionString,
profileSizeName, profileSizeName);
fragBuilder->codeAppendf("%s float center = 2.0 * floor(%s/2.0 + .25) - 1.0;", precisionString,
profileSizeName);
OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "horiz_lookup", profileSizeName,
"translatedPos.x", "width", "wh.x");
- OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "vert_lookup", profileSizeName,
+ OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "vert_lookup", profileSizeName,
"translatedPos.y", "height", "wh.y");
fragBuilder->codeAppendf("float final = horiz_lookup * vert_lookup;");
SkRect proxyRect = rrect.rect();
proxyRect.outset(extra, extra);
- SkAutoTUnref<const GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
+ SkAutoTUnref<const GrFragmentProcessor> fp(GrRRectBlurEffect::Create(texProvider,
xformedSigma, rrect));
if (!fp) {
return false;
}
SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
- SkImageFilter* input,
+ SkImageFilter* input,
const CropRect* cropRect)
: INHERITED(1, &input, cropRect)
, fColorFilter(SkRef(cf)) {
setrow(fMat + 10, 1, kU2B, 0);
fMat[kA_Scale] = 1;
}
-
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
b->add32(xKey | yKey);
}
#endif
-
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
if (!srcDrawContext) {
return nullptr;
- }
+ }
}
// Clear out a radius to the right of the srcRect to prevent the
srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
if (!srcDrawContext) {
return nullptr;
- }
+ }
}
// Clear out a radius below the srcRect to prevent the Y
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
class SkImageFilterLight : public SkRefCnt {
public:
-
+
enum LightType {
kDistant_LightType,
// Use X scale and Y scale on Z and average the result
SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ);
matrix.mapVectors(&locationZ, 1);
- SkPoint3 location = SkPoint3::Make(location2.fX,
- location2.fY,
+ SkPoint3 location = SkPoint3::Make(location2.fX,
+ location2.fY,
SkScalarAve(locationZ.fX, locationZ.fY));
return new SkPointLight(location, color());
}
if (!inputs[i]) {
continue;
}
- const SkIRect inputBounds = SkIRect::MakeXYWH(offsets[i].fX, offsets[i].fY,
+ const SkIRect inputBounds = SkIRect::MakeXYWH(offsets[i].fX, offsets[i].fY,
inputs[i]->width(), inputs[i]->height());
bounds.join(inputBounds);
}
#ifndef SK_IGNORE_TO_STRING
void SkMergeImageFilter::toString(SkString* str) const {
str->appendf("SkMergeImageFilter: (");
-
+
for (int i = 0; i < this->countInputs(); ++i) {
SkImageFilter* filter = this->getInput(i);
str->appendf("%d: (", i);
call_proc_X(procX, inputPixmap, &dst, width, srcBounds);
} else if (height > 0) {
call_proc_Y(procY,
- inputPixmap.addr32(srcBounds.left(), srcBounds.top()),
+ inputPixmap.addr32(srcBounds.left(), srcBounds.top()),
inputPixmap.rowBytesAsPixels(),
&dst, height, srcBounds);
}
SkIPoint* offset) const {
return this->filterImageGeneric(false, source, ctx, offset);
}
-
-
/*
* Copyright 2008 The Android Open Source Project
*
: INHERITED(0, 0, nullptr)
, fPicture(std::move(picture))
, fCropRect(fPicture ? fPicture->cullRect() : SkRect::MakeEmpty())
- , fPictureResolution(kDeviceSpace_PictureResolution)
+ , fPictureResolution(kDeviceSpace_PictureResolution)
, fFilterQuality(kLow_SkFilterQuality) {
}
pictureResolution = kDeviceSpace_PictureResolution;
} else {
pictureResolution = (PictureResolution)buffer.readInt();
- }
+ }
if (kLocalSpace_PictureResolution == pictureResolution) {
//filterLevel is only serialized if pictureResolution is LocalSpace
return false;
}
- if (kDeviceSpace_PictureResolution == fPictureResolution ||
+ if (kDeviceSpace_PictureResolution == fPictureResolution ||
0 == (ctx.ctm().getType() & ~SkMatrix::kTranslate_Mask)) {
- this->drawPictureAtDeviceResolution(device.get(), bounds, ctx);
+ this->drawPictureAtDeviceResolution(device.get(), bounds, ctx);
} else {
this->drawPictureAtLocalResolution(proxy, device.get(), bounds, ctx);
}
#ifndef SK_IGNORE_TO_STRING
void SkPictureImageFilter::toString(SkString* str) const {
str->appendf("SkPictureImageFilter: (");
- str->appendf("crop: (%f,%f,%f,%f) ",
+ str->appendf("crop: (%f,%f,%f,%f) ",
fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fBottom);
if (fPicture) {
str->appendf("picture: (%f,%f,%f,%f)",
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrXferProcessor& processor) override {
const PixelXorXP& pixelXor = processor.cast<PixelXorXP>();
- pdman.set3f(fOpColorUni,
+ pdman.set3f(fOpColorUni,
SkGetPackedR32(pixelXor.opColor())/255.0f,
SkGetPackedG32(pixelXor.opColor())/255.0f,
SkGetPackedB32(pixelXor.opColor())/255.0f);
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
if (fCachedRadius != radius0 ||
fCachedDiffRadius != diffRadius) {
- pdman.set3f(fParamUni, SkScalarToFloat(radius0),
+ pdman.set3f(fParamUni, SkScalarToFloat(radius0),
SkScalarToFloat(SkScalarMul(radius0, radius0)), SkScalarToFloat(diffRadius));
fCachedRadius = radius0;
fCachedDiffRadius = diffRadius;
auditBatch->fClientID = kGrAuditTrailInvalidID;
auditBatch->fBatchListID = kGrAuditTrailInvalidID;
auditBatch->fChildID = kGrAuditTrailInvalidID;
-
+
// consume the current stack trace if any
auditBatch->fStackTrace = fCurrentStackTrace;
fCurrentStackTrace.reset();
-
+
if (fClientID != kGrAuditTrailInvalidID) {
auditBatch->fClientID = fClientID;
Batches** batchesLookup = fClientIDLookup.find(fClientID);
// steal all of consumed's batches
for (int i = 0; i < consumedBatch.fChildren.count(); i++) {
Batch* childBatch = consumedBatch.fChildren[i];
-
+
// set the ids for the child batch
childBatch->fBatchListID = index;
childBatch->fChildID = consumerBatch.fChildren.count();
consumerBatch.fChildren.push_back(childBatch);
}
-
+
// Update the bounds for the combineWith node
consumerBatch.fBounds = consumer->bounds();
if (kGrAuditTrailInvalidID == currentBatchListID ||
batch->fBatchListID != currentBatchListID) {
BatchInfo& outBatchInfo = outInfo->push_back();
-
+
// copy out all of the batches so the client can display them even if
// they have a different clientID
this->copyOutFromBatchList(&outBatchInfo, batch->fBatchListID);
public:
GrAutoLocaleSetter (const char* name) {
#if defined(SK_BUILD_FOR_WIN)
- fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+ fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
char* oldLocale = setlocale(LC_ALL, name);
if (oldLocale) {
fOldLocale = oldLocale;
#undef HAVE_LOCALE_T
#endif
-
const GrStrokeInfo& strokeInfo,
bool doAA,
int sampleCnt) {
- // This mask will ultimately be drawn as a non-AA rect (see draw_mask).
- // Non-AA rects have a bad habit of snapping arbitrarily. Integerize here
+ // This mask will ultimately be drawn as a non-AA rect (see draw_mask).
+ // Non-AA rects have a bad habit of snapping arbitrarily. Integerize here
// so the mask draws in a reproducible manner.
*maskRect = SkRect::Make(maskRect->roundOut());
strokeInfo, pathPtr, pathIsMutable);
}
-void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
+void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrDrawContext* drawContext,
const GrClip& clip,
const SkPath& origSrcPath,
drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
}
}
-
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2015 Google Inc.
*
path.toggleInverseFillType();
}
GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
-
+
GrPathRendererChain::DrawType type;
-
+
if (needsStencil) {
type = element->isAA()
? GrPathRendererChain::kStencilAndColorAntiAlias_DrawType
} else {
type = element->isAA()
? GrPathRendererChain::kColorAntiAlias_DrawType
- : GrPathRendererChain::kColor_DrawType;
+ : GrPathRendererChain::kColor_DrawType;
}
-
+
GrPathRenderer::CanDrawPathArgs canDrawArgs;
canDrawArgs.fShaderCaps = context->caps()->shaderCaps();
canDrawArgs.fViewMatrix = &viewMatrix;
SkRegion::Op op = element->getOp();
bool invert = element->isInverseFilled();
- bool needsStencil = invert ||
+ bool needsStencil = invert ||
SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op;
if (PathNeedsSWRenderer(context, pipelineBuilder.getStencil().isDisabled(),
bool setupScissorClip(const GrPipelineBuilder& pipelineBuilder,
GrPipelineBuilder::AutoRestoreStencil* ars,
- const SkIRect& scissor,
+ const SkIRect& scissor,
const SkRect* devBounds,
GrAppliedClip* out);
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2015 Google Inc.
*
class AutoCheckFlush {
public:
- AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingManager) {
+ AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingManager) {
SkASSERT(fDrawingManager);
}
~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); }
} else {
// filled BW rect
batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect,
- nullptr, nullptr);
+ nullptr, nullptr);
}
return batch;
width, snapToPixelCenters));
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
- // hairline rects. We jam all the vertices to pixel centers to avoid this, but not
+ // hairline rects. We jam all the vertices to pixel centers to avoid this, but not
// when MSAA is enabled because it can cause ugly artifacts.
}
}
this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
return;
}
-
+
SkPath path;
path.setIsVolatile(true);
path.addRect(rect);
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas");
AutoCheckFlush acf(fDrawingManager);
-
+
GrDrawAtlasBatch::Geometry geometry;
geometry.fColor = paint.getColor();
SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount,
xform, texRect, colors));
-
+
GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
}
}
} else {
inverseVM.reset();
- }
+ }
GrPaint grPaint(paintIn);
grPaint.setAntiAlias(false);
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
-
+
this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseVM);
return true;
}
GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPath");
if (path.isEmpty() && path.isInverseFillType()) {
- this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I(),
- SkRect::MakeIWH(fDrawContext->fRenderTarget->width(),
+ this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I(),
+ SkRect::MakeIWH(fDrawContext->fRenderTarget->width(),
fDrawContext->fRenderTarget->height()));
return true;
}
GrDrawContextPriv* operator&();
GrDrawContext* fDrawContext;
-
+
friend class GrDrawContext; // to construct/copy this type.
};
}
#endif
-
-
/*
* Copyright 2010 Google Inc.
*
batch->bounds().fLeft, batch->bounds().fRight,
batch->bounds().fTop, batch->bounds().fBottom);
GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str());
- GrBATCH_INFO("\tOutcome:\n");
+ GrBATCH_INFO("\tOutcome:\n");
int maxCandidates = SkTMin(fMaxBatchLookback, fBatches.count());
if (maxCandidates) {
int i = 0;
viewport.fWidth = rt->width();
viewport.fHeight = rt->height();
SkIRect ibounds;
- ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewport.fLeft,
+ ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewport.fLeft,
viewport.fWidth);
- ibounds.fTop = SkTPin(SkScalarFloorToInt(batch->bounds().fTop), viewport.fBottom,
+ ibounds.fTop = SkTPin(SkScalarFloorToInt(batch->bounds().fTop), viewport.fBottom,
viewport.fHeight);
- ibounds.fRight = SkTPin(SkScalarCeilToInt(batch->bounds().fRight), viewport.fLeft,
+ ibounds.fRight = SkTPin(SkScalarCeilToInt(batch->bounds().fRight), viewport.fLeft,
viewport.fWidth);
- ibounds.fBottom = SkTPin(SkScalarCeilToInt(batch->bounds().fBottom), viewport.fBottom,
+ ibounds.fBottom = SkTPin(SkScalarCeilToInt(batch->bounds().fBottom), viewport.fBottom,
viewport.fHeight);
if (scissor != nullptr && scissor->enabled()) {
if (!ibounds.intersect(scissor->rect())) {
}
fFlushing = true;
- SkDEBUGCODE(bool result =)
+ SkDEBUGCODE(bool result =)
SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(&fDrawTargets);
SkASSERT(result);
*fDrawTargets.append() = dt;
- // DrawingManager gets the creation ref - this ref is for the caller
+ // DrawingManager gets the creation ref - this ref is for the caller
return SkRef(dt);
}
GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps*);
- // The caller automatically gets a ref on the returned drawTarget. It must
+ // The caller automatically gets a ref on the returned drawTarget. It must
// be balanced by an unref call.
GrDrawTarget* newDrawTarget(GrRenderTarget* rt);
-
/*
* Copyright 2015 Google Inc.
*
return new SeriesFragmentProcessor(series, cnt);
}
}
-
this->onDraw(pipeline, primProc, meshes, meshCount);
return true;
}
-
* @return the buffer if successful, otherwise nullptr.
*/
GrBuffer* createBuffer(GrBufferType, size_t size, GrAccessPattern);
-
+
/**
* Resolves MSAA.
*/
const GrMesh*,
int meshCount);
- // Called by drawtarget when flushing.
+ // Called by drawtarget when flushing.
// Provides a hook for post-flush actions (e.g. PLS reset and Vulkan command buffer submits).
virtual void finishDrawTarget() {}
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
SkASSERT(this->wasDestroyed());
}
-void GrGpuResource::release() {
+void GrGpuResource::release() {
SkASSERT(fGpu);
this->onRelease();
get_resource_cache(fGpu)->resourceAccess().removeResource(this);
-
/*
* Copyright 2014 Google Inc.
*
* ownership of.
*/
bool isAdopted() const { return GrGpuResource::kAdopted_LifeCycle == fResource->fLifeCycle; }
-
+
/**
* Called by the cache to delete the resource under normal circumstances.
*/
-
/*
* Copyright 2015 Google Inc.
*
class SkImage_Base;
class SkImageCacherator;
-/** Implementation for texture-backed SkBitmaps. The bitmap must stay in scope and unmodified
+/** Implementation for texture-backed SkBitmaps. The bitmap must stay in scope and unmodified
while this object exists. */
class GrBitmapTextureAdjuster : public GrTextureAdjuster {
public:
-
/*
* Copyright 2010 Google Inc.
*
// If the above fails, then the current plot list has no room
return nullptr;
}
-
-
/*
* Copyright 2010 Google Inc.
*
class GrRectanizer;
// The backing GrTexture for a GrLayerAtlas is broken into a spatial grid of Plots. When
-// the atlas needs space on the texture (i.e., in response to an addToAtlas call), it
-// iterates through the plots in use by the requesting client looking for space and,
-// if no space is found, opens up a new Plot for that client. The Plots keep track of
-// subimage placement via their GrRectanizer.
+// the atlas needs space on the texture (i.e., in response to an addToAtlas call), it
+// iterates through the plots in use by the requesting client looking for space and,
+// if no space is found, opens up a new Plot for that client. The Plots keep track of
+// subimage placement via their GrRectanizer.
//
// If all Plots are full, the replacement strategy is up to the client. The Plot::reset
// call will remove a Plot's knowledge of any allocated rects - freeing its space for reuse.
// This class allows each client to independently track the Plots in
// which its data is stored.
- // For example, multiple pictures may simultaneously store their layers in the
+ // For example, multiple pictures may simultaneously store their layers in the
// layer atlas. When a picture goes away it can use the ClientPlotUsage to remove itself
// from those plots.
class ClientPlotUsage {
}
#ifdef SK_DEBUG
- bool contains(const Plot* plot) const {
- return fPlots.contains(const_cast<Plot*>(plot));
+ bool contains(const Plot* plot) const {
+ return fPlots.contains(const_cast<Plot*>(plot));
}
#endif
SkDEBUGCODE(int fMaxPlots;)
};
- GrLayerAtlas(GrTextureProvider*, GrPixelConfig, GrSurfaceFlags flags,
+ GrLayerAtlas(GrTextureProvider*, GrPixelConfig, GrSurfaceFlags flags,
const SkISize& backingTextureSize,
int numPlotsX, int numPlotsY);
~GrLayerAtlas();
- // Requests a width x height block in the atlas. Upon success it returns
- // the containing Plot and absolute location in the backing texture.
+ // Requests a width x height block in the atlas. Upon success it returns
+ // the containing Plot and absolute location in the backing texture.
// nullptr is returned if there is no more space in the atlas.
Plot* addToAtlas(ClientPlotUsage*, int width, int height, SkIPoint16* loc);
static uint32_t Hash(const uint32_t& key) { return SkChecksum::Mix(key); }
// GrPictureInfo proper
- GrPictureInfo(uint32_t pictureID)
+ GrPictureInfo(uint32_t pictureID)
: fPictureID(pictureID)
, fPlotUsage(kNumPlots) {
#if !GR_CACHE_HOISTED_LAYERS
@param topLevelPicture The top-level picture that is about to be rendered
@param initialMat The CTM of the canvas into which the layers will be drawn
@param query The rectangle that is about to be drawn.
- @param atlasedNeedRendering Out parameter storing the layers that
+ @param atlasedNeedRendering Out parameter storing the layers that
should be hoisted to the atlas
@param recycled Out parameter storing layers that are atlased but do not need rendering
@param numSamples The number if MSAA samples required
@param layers The hoisted layers
@param replacements Replacement object that will be used for a replacement draw
*/
- static void ConvertLayersToReplacements(const SkPicture* topLevelPicture,
+ static void ConvertLayersToReplacements(const SkPicture* topLevelPicture,
const SkTDArray<GrHoistedLayer>& layers,
GrReplacements* replacements);
SkASSERT(userStart == block->fCurrPtr);
} else {
AllocHeader* allocData = reinterpret_cast<AllocHeader*>(userStart);
- SkASSERT(allocData->fSentinal == kAssignedMarker ||
+ SkASSERT(allocData->fSentinal == kAssignedMarker ||
allocData->fSentinal == kFreedMarker);
SkASSERT(block == allocData->fHeader);
}
const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; }
const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
-
+
class GLSLProcessor : public GrGLSLGeometryProcessor {
public:
GLSLProcessor()
if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(viewMatrix)) {
return CreateCircleBatch(color, viewMatrix, oval, stroke);
}
-
+
// if we have shader derivative support, render as device-independent
if (shaderCaps->shaderDerivativeSupport()) {
return CreateDIEllipseBatch(color, viewMatrix, oval, stroke);
}
-
+
// otherwise axis-aligned ellipses only
if (viewMatrix.rectStaysRect()) {
return CreateEllipseBatch(color, viewMatrix, oval, stroke);
return string;
}
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
const char* name() const override { return "EllipseBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
const char* name() const override { return "DIEllipseBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
}
helper.recordDraw(target);
}
-
+
DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
const char* name() const override { return "RRectCircleBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
const char* name() const override { return "RRectEllipseRendererBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
*/
class GrPLSGeometryProcessor : public GrGeometryProcessor {
public:
- GrPixelLocalStorageState getPixelLocalStorageState() const override {
+ GrPixelLocalStorageState getPixelLocalStorageState() const override {
return GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState;
}
-
/*
* Copyright 2013 Google Inc.
*
GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo.color(),
colorProcInfo.validFlags(),
colorProcInfo.isOpaque(),
- &blendedColor);
+ &blendedColor);
}
if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) {
return fSkPath == path;
}
#endif
-
class GrPathRange : public GrGpuResource {
public:
-
+
enum PathIndexType {
kU8_PathIndexType, //!< uint8_t
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
canArgs.fAntiAlias = args.fAntiAlias;
canArgs.fIsStencilDisabled = args.fPipelineBuilder->getStencil().isDisabled();
- canArgs.fIsStencilBufferMSAA =
+ canArgs.fIsStencilBufferMSAA =
args.fPipelineBuilder->getRenderTarget()->isStencilBufferMultisampled();
SkASSERT(this->canDrawPath(canArgs));
SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() ||
-
/*
* Copyright 2011 Google Inc.
*
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
- const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() :
+ const GrXferProcessor* xpForOpts = xferProcessor ? xferProcessor.get() :
&GrPorterDuffXPFactory::SimpleSrcOverXP();
optFlags = xpForOpts->getOptimizations(args.fOpts,
builder.getStencil().doesWrite(),
// information.
int firstCoverageProcessorIdx = 0;
- pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fOpts.fColorPOI,
- args.fOpts.fCoveragePOI, &firstColorProcessorIdx,
+ pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fOpts.fColorPOI,
+ args.fOpts.fCoveragePOI, &firstColorProcessorIdx,
&firstCoverageProcessorIdx);
bool usesLocalCoords = false;
overrides->fFlags |= GrXPOverridesForBatch::kReadsLocalCoords_Flag;
}
if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) {
- overrides->fFlags |= GrXPOverridesForBatch::kCanTweakAlphaForCoverage_Flag;
+ overrides->fFlags |= GrXPOverridesForBatch::kCanTweakAlphaForCoverage_Flag;
}
GrXPFactory::InvariantBlendedColor blendedColor;
GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(args.fOpts.fColorPOI.color(),
args.fOpts.fColorPOI.validFlags(),
args.fOpts.fColorPOI.isOpaque(),
- &blendedColor);
+ &blendedColor);
}
if (blendedColor.fWillBlendWithDst) {
overrides->fFlags |= GrXPOverridesForBatch::kWillColorBlendWithDst_Flag;
const GrXferProcessor& xfer = this->getXferProcessor();
for (int i = 0; i < xfer.numTextures(); ++i) {
- GrTexture* texture = xfer.textureAccess(i).getTexture();
+ GrTexture* texture = xfer.textureAccess(i).getTexture();
SkASSERT(rt->getLastDrawTarget());
rt->getLastDrawTarget()->addDependency(texture);
}
}
return true;
}
-
bool GrPipelineBuilder::willXPNeedDstTexture(const GrCaps& caps,
const GrPipelineOptimizations& optimizations) const {
if (this->getXPFactory()) {
- return this->getXPFactory()->willNeedDstTexture(caps, optimizations,
+ return this->getXPFactory()->willNeedDstTexture(caps, optimizations,
this->hasMixedSamples());
}
return GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(caps, optimizations,
*/
class AutoRestoreFragmentProcessorState : public ::SkNoncopyable {
public:
- AutoRestoreFragmentProcessorState()
+ AutoRestoreFragmentProcessorState()
: fPipelineBuilder(nullptr)
, fColorEffectCnt(0)
, fCoverageEffectCnt(0) {}
/**
* Checks whether the xp will need destination in a texture to correctly blend.
*/
- bool willXPNeedDstTexture(const GrCaps& caps,
+ bool willXPNeedDstTexture(const GrCaps& caps,
const GrPipelineOptimizations& optimizations) const;
/// @}
* @param flags bitfield of Flags specifying the states to enable
*/
void enableState(uint32_t flags) { fFlags |= flags; }
-
+
/**
* Disable render state settings.
*
struct GrInitInvariantOutput;
-// Describes the state of pixel local storage with respect to the current draw.
+// Describes the state of pixel local storage with respect to the current draw.
enum GrPixelLocalStorageState {
// The draw is actively updating PLS.
kDraw_GrPixelLocalStorageState,
*/
virtual bool hasTransformedLocalCoords() const = 0;
- virtual GrPixelLocalStorageState getPixelLocalStorageState() const {
+ virtual GrPixelLocalStorageState getPixelLocalStorageState() const {
return kDisabled_GrPixelLocalStorageState;
}
* If non-null, overrides the dest color returned by GrGLSLFragmentShaderBuilder::dstColor().
*/
virtual const char* getDestColorOverride() const { return nullptr; }
-
+
virtual float getSampleShading() const {
return 0.0;
}
GrColorComponentFlags, bool areCoverageStages, bool isLCD = false);
void initUsingInvariantOutput(GrInitInvariantOutput invOutput);
void completeCalculations(const GrFragmentProcessor * const processors[], int cnt);
-
+
bool isSolidWhite() const { return fInOut.isSolidWhite(); }
bool isOpaque() const { return fInOut.isOpaque(); }
bool isSingleComponent() const { return fInOut.isSingleComponent(); }
fGpuResources[i]->pendingIOComplete();
}
}
-
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
// Can a width x height rectangle fit in the free space represented by
// the skyline segments >= 'skylineIndex'? If so, return true and fill in
- // 'y' with the y-location at which it fits (the x location is pulled from
+ // 'y' with the y-location at which it fits (the x location is pulled from
// 'skylineIndex's segment.
bool rectangleFits(int skylineIndex, int width, int height, int* y) const;
// Update the skyline structure to include a width x height rect located
-
/*
* Copyright 2011 Google Inc.
*
if (!fRenderTarget->completeStencilAttachment()) {
SkSafeSetNull(fRenderTarget->fStencilAttachment);
return false;
- }
+ }
return true;
}
GrRenderTargetPriv* operator&();
GrRenderTarget* fRenderTarget;
-
+
friend class GrRenderTarget; // to construct/copy this type.
};
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey,
size_t resourceSize,
uint32_t flags);
-
+
#ifdef SK_DEBUG
// This is not particularly fast and only used for validation, so debug only.
int countScratchEntriesForKey(const GrScratchKey& scratchKey) const {
bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCount > fMaxCount; }
bool wouldFit(size_t bytes) {
- return fBudgetedBytes+bytes <= fMaxBytes && fBudgetedCount+1 <= fMaxCount;
+ return fBudgetedBytes+bytes <= fMaxBytes && fBudgetedCount+1 <= fMaxCount;
}
uint32_t getNextTimestamp();
}
return this->gpu()->wrapBackendTextureAsRenderTarget(desc, ownership);
}
-
fCompressedBuffer.reset(cmpSz);
fCompressionMode = kBlitter_CompressionMode;
}
- }
+ }
sk_bzero(&fDraw, sizeof(fDraw));
// Convert mask generation results to a signed distance field
void toSDF(unsigned char* sdf);
-
+
// Reset the internal bitmap
void clear(uint8_t alpha) {
fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF));
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override {
return GrPathRenderer::kNoSupport_StencilSupport;
}
-
+
bool onCanDrawPath(const CanDrawPathArgs&) const override;
bool onDrawPath(const DrawPathArgs&) override;
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
class GrStencilAttachment : public GrGpuResource {
public:
-
+
virtual ~GrStencilAttachment() {
// TODO: allow SB to be purged and detach itself from rts
SkASSERT(this->computeUniqueKeyFragmentData32Cnt() == i);
}
-
// This is a driver function which calls stages 2-5 in turn.
-Poly* contours_to_polys(Vertex** contours, int contourCnt, const SkRect& pathBounds,
+Poly* contours_to_polys(Vertex** contours, int contourCnt, const SkRect& pathBounds,
SkChunkAlloc& alloc) {
Comparator c;
if (pathBounds.width() > pathBounds.height()) {
return tessellate(vertices, alloc);
}
-Poly* path_to_polys(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
+Poly* path_to_polys(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
int contourCnt, SkChunkAlloc& alloc, bool* isLinear) {
SkPath::FillType fillType = path.getFillType();
if (SkPath::IsInverseFillType(fillType)) {
return contours_to_polys(contours.get(), contourCnt, path.getBounds(), alloc);
}
-void get_contour_count_and_size_estimate(const SkPath& path, SkScalar tolerance, int* contourCnt,
+void get_contour_count_and_size_estimate(const SkPath& path, SkScalar tolerance, int* contourCnt,
int* sizeEstimate) {
int maxPts = GrPathUtils::worstCasePointCount(path, contourCnt, tolerance);
if (maxPts <= 0) {
// Stage 6: Triangulate the monotone polygons into a vertex buffer.
-int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
+int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
VertexAllocator* vertexAllocator, bool* isLinear) {
int contourCnt;
int sizeEstimate;
return actualCount;
}
-int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
+int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
GrTessellator::WindingVertex** verts) {
int contourCnt;
int sizeEstimate;
// WindingVertex entries, each of which contains the position and winding count (which is the same
// for all three vertices of a triangle). The 'verts' out parameter is set to point to the resultant
// vertex array. CALLER IS RESPONSIBLE for deleting this buffer to avoid a memory leak!
-int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
+int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
WindingVertex** verts);
-int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
+int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
VertexAllocator*, bool *isLinear);
}
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
GrTraceMarkerSet::Iter GrTraceMarkerSet::end() const {
return Iter(this, this->fMarkerArray.count());
}
-
-
/*
* Copyright 2014 Google Inc.
*
if (!caps.shaderCaps()->dstReadInShaderSupport()) {
SkASSERT(dstTexture && dstTexture->texture());
} else {
- SkASSERT(!dstTexture || !dstTexture->texture());
+ SkASSERT(!dstTexture || !dstTexture->texture());
}
} else {
- SkASSERT(!dstTexture || !dstTexture->texture());
+ SkASSERT(!dstTexture || !dstTexture->texture());
}
SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport());
#endif
return result.release();
}
-
-
/*
* Copyright 2010 Google Inc.
*
} else {
constraintMode = GrTextureAdjuster::kYes_FilterConstraint;
}
-
+
// If we have to outset for AA then we will generate texture coords outside the src rect. The
// same happens for any mask filter that extends the bounds rendered in the dst.
// This is conservative as a mask filter does not have to expand the bounds rendered.
SkASSERT(!grPaint->getXPFactory());
SkXfermode* xfermode = skPaint.getXfermode();
if (xfermode) {
- // SafeUnref in case a new xfermode is added that returns null.
+ // SafeUnref in case a new xfermode is added that returns null.
// In such cases we will fall back to kSrcOver_Mode.
SkSafeUnref(grPaint->setXPFactory(xfermode->asXPFactory()));
}
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
- *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) =
+ *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) =
tess.coverage(i);
}
}
const char* name() const override { return "AAConvexBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
-
/*
* Copyright 2012 Google Inc.
*
return (v.fX * n1.fY - v.fY * n1.fX) / perpDot;
}
-// This is a special case version of intersect where we have the vector
+// This is a special case version of intersect where we have the vector
// perpendicular to the second line rather than the vector parallel to it.
static SkScalar perp_intersect(const SkPoint& p0, const SkPoint& n0,
const SkPoint& p1, const SkPoint& perp) {
SkVector other;
other.setOrthog(fNorms[prev], fSide);
fBisectors[cur] += other;
- SkAssertResult(fBisectors[cur].normalize());
+ SkAssertResult(fBisectors[cur].normalize());
} else {
fBisectors[cur].negate(); // make the bisector face in
}
// Create as many rings as we need to (up to a predefined limit) to reach the specified target
// depth. If we are in fill mode, the final ring will automatically be fanned.
bool GrAAConvexTessellator::createInsetRings(Ring& previousRing, SkScalar initialDepth,
- SkScalar initialCoverage, SkScalar targetDepth,
+ SkScalar initialCoverage, SkScalar targetDepth,
SkScalar targetCoverage, Ring** finalRing) {
static const int kMaxNumRings = 8;
Ring* nextRing = this->getNextRing(currentRing);
SkASSERT(nextRing != currentRing);
- bool done = this->createInsetRing(*currentRing, nextRing, initialDepth, initialCoverage,
+ bool done = this->createInsetRing(*currentRing, nextRing, initialDepth, initialCoverage,
targetDepth, targetCoverage, i == 0);
currentRing = nextRing;
if (done) {
SkScalar coverage = 1.0f;
SkScalar scaleFactor = 0.0f;
if (fStrokeWidth >= 0.0f) {
- SkASSERT(m.isSimilarity());
+ SkASSERT(m.isSimilarity());
scaleFactor = m.getMaxScale(); // x and y scale are the same
SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth;
Ring outerStrokeRing;
- this->createOuterRing(fInitialRing, effectiveStrokeWidth / 2 - kAntialiasingRadius,
+ this->createOuterRing(fInitialRing, effectiveStrokeWidth / 2 - kAntialiasingRadius,
coverage, &outerStrokeRing);
outerStrokeRing.init(*this);
Ring outerAARing;
SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth;
Ring* insetStrokeRing;
SkScalar strokeDepth = effectiveStrokeWidth / 2 - kAntialiasingRadius;
- if (this->createInsetRings(fInitialRing, 0.0f, coverage, strokeDepth, coverage,
+ if (this->createInsetRings(fInitialRing, 0.0f, coverage, strokeDepth, coverage,
&insetStrokeRing)) {
Ring* insetAARing;
- this->createInsetRings(*insetStrokeRing, strokeDepth, coverage, strokeDepth +
+ this->createInsetRings(*insetStrokeRing, strokeDepth, coverage, strokeDepth +
kAntialiasingRadius * 2, 0.0f, &insetAARing);
}
} else {
this->computeBisectors();
} else if (this->numPts() == 2) {
- // We've got two points, so we're degenerate.
+ // We've got two points, so we're degenerate.
if (fStrokeWidth < 0.0f) {
// it's a fill, so we don't need to worry about degenerate paths
return false;
}
}
-void GrAAConvexTessellator::createOuterRing(const Ring& previousRing, SkScalar outset,
+void GrAAConvexTessellator::createOuterRing(const Ring& previousRing, SkScalar outset,
SkScalar coverage, Ring* nextRing) {
const int numPts = previousRing.numPts();
if (numPts == 0) {
miterLimitSq = SkScalarMul(miterLimitSq, miterLimitSq);
for (int cur = 0; cur < numPts; ++cur) {
int originalIdx = previousRing.index(cur);
- // For each vertex of the original polygon we add at least two points to the
+ // For each vertex of the original polygon we add at least two points to the
// outset polygon - one extending perpendicular to each impinging edge. Connecting these
- // two points yields a bevel join. We need one additional point for a mitered join, and
+ // two points yields a bevel join. We need one additional point for a mitered join, and
// a round join requires one or more points depending upon curvature.
// The perpendicular point for the last edge
this->addTri(originalIdx, perp1Idx, perp2Idx);
break;
default:
- // kRound_Join is unsupported for now. GrAALinearizingConvexPathRenderer is
+ // kRound_Join is unsupported for now. GrAALinearizingConvexPathRenderer is
// only willing to draw mitered or beveled, so we should never get here.
SkASSERT(false);
}
}
}
-static SkScalar compute_coverage(SkScalar depth, SkScalar initialDepth, SkScalar initialCoverage,
+static SkScalar compute_coverage(SkScalar depth, SkScalar initialDepth, SkScalar initialCoverage,
SkScalar targetDepth, SkScalar targetCoverage) {
if (SkScalarNearlyEqual(initialDepth, targetDepth)) {
return targetCoverage;
}
- SkScalar result = (depth - initialDepth) / (targetDepth - initialDepth) *
+ SkScalar result = (depth - initialDepth) / (targetDepth - initialDepth) *
(targetCoverage - initialCoverage) + initialCoverage;
return SkScalarClampMax(result, 1.0f);
}
// return true when processing is complete
-bool GrAAConvexTessellator::createInsetRing(const Ring& lastRing, Ring* nextRing,
- SkScalar initialDepth, SkScalar initialCoverage,
- SkScalar targetDepth, SkScalar targetCoverage,
+bool GrAAConvexTessellator::createInsetRing(const Ring& lastRing, Ring* nextRing,
+ SkScalar initialDepth, SkScalar initialCoverage,
+ SkScalar targetDepth, SkScalar targetCoverage,
bool forceNew) {
bool done = false;
for (int i = 0; i < fCandidateVerts.numPts(); ++i) {
int newIdx;
if (fCandidateVerts.needsToBeNew(i) || forceNew) {
- // if the originating index is still valid then this point wasn't
+ // if the originating index is still valid then this point wasn't
// fused (and is thus movable)
- SkScalar coverage = compute_coverage(depth, initialDepth, initialCoverage,
+ SkScalar coverage = compute_coverage(depth, initialDepth, initialCoverage,
targetDepth, targetCoverage);
newIdx = this->addPt(fCandidateVerts.point(i), depth, coverage,
fCandidateVerts.originatingIdx(i) != -1, false);
}
SkASSERT(fPts.count() <= 1 || fPts.count() == fNorms.count()+1);
- if (this->numPts() >= 2 &&
+ if (this->numPts() >= 2 &&
abs_dist_from_line(fPts.top(), fNorms.top(), p) < kClose) {
// The old last point is on the line from the second to last to the new point
this->popLastPt();
int maxCount = GrPathUtils::quadraticPointCount(pts, kQuadTolerance);
fPointBuffer.setReserve(maxCount);
SkPoint* target = fPointBuffer.begin();
- int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2],
+ int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2],
kQuadTolerance, &target, maxCount);
fPointBuffer.setCount(count);
for (int i = 0; i < count; i++) {
int maxCount = GrPathUtils::cubicPointCount(pts, kCubicTolerance);
fPointBuffer.setReserve(maxCount);
SkPoint* target = fPointBuffer.begin();
- int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3],
+ int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3],
kCubicTolerance, &target, maxCount);
fPointBuffer.setCount(count);
for (int i = 0; i < count; i++) {
stroke.setColor(SK_ColorYELLOW);
stroke.setStyle(SkPaint::kStroke_Style);
stroke.setStrokeWidth(kPointRadius/3.0f);
- canvas->drawCircle(p.fX, p.fY, kPointRadius, stroke);
+ canvas->drawCircle(p.fX, p.fY, kPointRadius, stroke);
}
}
draw_arrow(canvas, tess.point(fPts[cur].fIndex), fPts[cur].fBisector,
kArrowLength, SK_ColorBLUE);
}
- }
+ }
}
void GrAAConvexTessellator::draw(SkCanvas* canvas) const {
for (int i = 0; i < this->numPts(); ++i) {
draw_point(canvas,
- this->point(i), 0.5f + (this->depth(i)/(2 * kAntialiasingRadius)),
+ this->point(i), 0.5f + (this->depth(i)/(2 * kAntialiasingRadius)),
!this->movable(i));
SkPaint paint;
SkString num;
num.printf("%d", i);
- canvas->drawText(num.c_str(), num.size(),
- this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f),
+ canvas->drawText(num.c_str(), num.size(),
+ this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f),
paint);
}
}
#endif
-
// computeDepthFromEdge requests.
class GrAAConvexTessellator {
public:
- GrAAConvexTessellator(SkScalar strokeWidth = -1.0f,
- SkPaint::Join join = SkPaint::Join::kBevel_Join,
+ GrAAConvexTessellator(SkScalar strokeWidth = -1.0f,
+ SkPaint::Join join = SkPaint::Join::kBevel_Join,
SkScalar miterLimit = 0.0f)
: fSide(SkPoint::kOn_Side)
, fStrokeWidth(strokeWidth)
void rewind();
private:
- // CandidateVerts holds the vertices for the next ring while they are
+ // CandidateVerts holds the vertices for the next ring while they are
// being generated. Its main function is to de-dup the points.
class CandidateVerts {
public:
Ring* getNextRing(Ring* lastRing);
- void createOuterRing(const Ring& previousRing, SkScalar outset, SkScalar coverage,
+ void createOuterRing(const Ring& previousRing, SkScalar outset, SkScalar coverage,
Ring* nextRing);
- bool createInsetRings(Ring& previousRing, SkScalar initialDepth, SkScalar initialCoverage,
+ bool createInsetRings(Ring& previousRing, SkScalar initialDepth, SkScalar initialCoverage,
SkScalar targetDepth, SkScalar targetCoverage, Ring** finalRing);
- bool createInsetRing(const Ring& lastRing, Ring* nextRing,
- SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth,
+ bool createInsetRing(const Ring& lastRing, Ring* nextRing,
+ SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth,
SkScalar targetCoverage, bool forceNew);
void validate() const;
// needed for exterior ring creation and then handed off to the initial ring.
SkTDArray<SkVector> fBisectors;
- // Tracks whether a given point is interior to a curve. Such points are
+ // Tracks whether a given point is interior to a curve. Such points are
// assumed to have shallow curvature.
SkTDArray<bool> fIsCurve;
#endif
-
-
/*
* Copyright 2014 Google Inc.
*
if (args.fViewMatrix->hasPerspective()) {
return false;
}
-
+
// only support paths with bounds within kMediumMIP by kMediumMIP,
// scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP
// the goal is to accelerate rendering of lots of small paths that may be scaling
const char* name() const override { return "AADistanceFieldPathBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
color->setKnownFourComponents(fGeoData[0].fColor);
// generated due to stroking it is important that the original path's id is used
// for caching.
geometry.fGenID = args.fPath->getGenerationID();
-
+
SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry,
*args.fViewMatrix, fAtlas,
&fPathCache, &fPathList));
-
/*
* Copyright 2014 Google Inc.
*
public:
// default ctor needed for new of uninitialized PathData
// since fStroke has no default ctor
- Key()
+ Key()
: fGenID(0)
, fDimension(0)
, fStroke(SkStrokeRec::kFill_InitStyle) {}
: fGenID(genID)
, fDimension(dim)
, fStroke(stroke) {}
-
+
bool operator==(const Key& other) const {
return other.fGenID == fGenID && other.fDimension == fDimension &&
fStroke.hasEqualEffect(other.fStroke);
}
-
+
private:
uint32_t fGenID;
// rendered size for stored path (32x32 max, 64x64 max, 128x128 max)
SkRect fBounds;
SkIPoint16 fAtlasLocation;
SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData);
-
+
static inline const Key& GetKey(const PathData& data) {
return data.fKey;
}
-
+
static inline uint32_t Hash(Key key) {
return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), sizeof(key));
}
typedef SkTDynamicHash<PathData, PathData::Key> PathCache;
typedef SkTInternalLList<PathData> PathDataList;
-
+
GrBatchAtlas* fAtlas;
PathCache fPathCache;
PathDataList fPathList;
-
+
typedef GrPathRenderer INHERITED;
friend class AADistanceFieldPathBatch;
static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo,
const GrXPOverridesForBatch& overrides) {
generate_aa_fill_rect_geometry(vertices, vertexStride,
- geo.fColor, geo.fViewMatrix, geo.fRect, geo.fDevRect,
+ geo.fColor, geo.fViewMatrix, geo.fRect, geo.fDevRect,
overrides, nullptr);
}
};
static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry& geo,
const GrXPOverridesForBatch& overrides) {
generate_aa_fill_rect_geometry(vertices, vertexStride,
- geo.fColor, geo.fViewMatrix, geo.fRect, geo.fDevRect,
+ geo.fColor, geo.fViewMatrix, geo.fRect, geo.fDevRect,
overrides, &geo.fLocalMatrix);
}
};
const char* name() const override { return "AAHairlineBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2015 Google Inc.
*
const char* name() const override { return "AAConvexBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
-
/*
* Copyright 2015 Google Inc.
*
const char* name() const override { return "AAStrokeRect"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
return str;
}
-void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color,
+void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const {
if (kColorBitmapMask_MaskType == fMaskType) {
SkString dumpInfo() const override;
protected:
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override;
uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fClassID; }
// We lazily initialize the uniqueID because currently the only user is GrAuditTrail
- uint32_t uniqueID() const {
+ uint32_t uniqueID() const {
if (kIllegalBatchID == fUniqueID) {
fUniqueID = GenBatchID();
}
- return fUniqueID;
+ return fUniqueID;
}
SkDEBUGCODE(bool isUsed() const { return fUsed; })
-
/*
* Copyright 2015 Google Inc.
*
const char* name() const override { return "DefaultPathBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
if (hasColors) {
gpColor.fType = Color::kAttribute_Type;
}
-
+
Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_Type);
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix);
this->color(),
this->viewMatrix(),
this->coverageIgnored()));
-
+
target->initDraw(gp);
-
+
int instanceCount = fGeoData.count();
size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint) + sizeof(SkPoint)
+ (this->hasColors() ? sizeof(GrColor) : 0));
-
+
QuadHelper helper;
int numQuads = this->quadCount();
void* verts = helper.init(target, vertexStride, numQuads);
SkDebugf("Could not allocate vertices\n");
return;
}
-
+
uint8_t* vertPtr = reinterpret_cast<uint8_t*>(verts);
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
-
+
size_t allocSize = args.fVerts.count();
memcpy(vertPtr, args.fVerts.begin(), allocSize);
vertPtr += allocSize;
: INHERITED(ClassID()) {
SkASSERT(xforms);
SkASSERT(rects);
-
+
fViewMatrix = viewMatrix;
Geometry& installedGeo = fGeoData.push_back(geometry);
-
+
// Figure out stride and offsets
// Order within the vertex is: position [color] texCoord
size_t texOffset = sizeof(SkPoint);
texOffset += sizeof(GrColor);
vertexStride += sizeof(GrColor);
}
-
+
// Compute buffer size and alloc buffer
fQuadCount = spriteCount;
int allocSize = static_cast<int>(4*vertexStride*spriteCount);
installedGeo.fVerts.reset(allocSize);
uint8_t* currVertex = installedGeo.fVerts.begin();
-
+
SkRect bounds;
bounds.setLargestInverted();
int paintAlpha = GrColorUnpackA(installedGeo.fColor);
SkPoint quad[4];
const SkRect& currRect = rects[spriteIndex];
xforms[spriteIndex].toQuad(currRect.width(), currRect.height(), quad);
-
+
// Copy colors if necessary
if (colors) {
// convert to GrColor
color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paintAlpha));
}
GrColor grColor = SkColorToPremulGrColor(color);
-
+
*(reinterpret_cast<GrColor*>(currVertex+sizeof(SkPoint))) = grColor;
*(reinterpret_cast<GrColor*>(currVertex+vertexStride+sizeof(SkPoint))) = grColor;
*(reinterpret_cast<GrColor*>(currVertex+2*vertexStride+sizeof(SkPoint))) = grColor;
*(reinterpret_cast<GrColor*>(currVertex+3*vertexStride+sizeof(SkPoint))) = grColor;
}
-
+
// Copy position and uv to verts
*(reinterpret_cast<SkPoint*>(currVertex)) = quad[0];
*(reinterpret_cast<SkPoint*>(currVertex+texOffset)) = SkPoint::Make(currRect.fLeft,
currRect.fTop);
bounds.growToInclude(quad[1].fX, quad[1].fY);
currVertex += vertexStride;
-
+
*(reinterpret_cast<SkPoint*>(currVertex)) = quad[2];
*(reinterpret_cast<SkPoint*>(currVertex+texOffset)) = SkPoint::Make(currRect.fRight,
currRect.fBottom);
bounds.growToInclude(quad[2].fX, quad[2].fY);
currVertex += vertexStride;
-
+
*(reinterpret_cast<SkPoint*>(currVertex)) = quad[3];
*(reinterpret_cast<SkPoint*>(currVertex+texOffset)) = SkPoint::Make(currRect.fLeft,
currRect.fBottom);
bounds.growToInclude(quad[3].fX, quad[3].fY);
currVertex += vertexStride;
}
-
+
viewMatrix.mapRect(&bounds);
// Outset for a half pixel in each direction to account for snapping in non-AA case
bounds.outset(0.5f, 0.5f);
this->setBounds(bounds);
}
-
+
bool GrDrawAtlasBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
GrDrawAtlasBatch* that = t->cast<GrDrawAtlasBatch>();
if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
return false;
}
-
+
if (this->hasColors() != that->hasColors()) {
return false;
}
-
+
if (!this->hasColors() && this->color() != that->color()) {
return false;
}
-
+
if (this->color() != that->color()) {
fColor = GrColor_ILLEGAL;
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
fQuadCount += that->quadCount();
-
+
this->joinBounds(that->bounds());
return true;
}
static SkRect random_texRect(SkRandom* random) {
static const SkScalar kMinCoord = 0.0f;
static const SkScalar kMaxCoord = 1024.f;
-
+
SkRect texRect = SkRect::MakeLTRB(random->nextRangeScalar(kMinCoord, kMaxCoord),
random->nextRangeScalar(kMinCoord, kMaxCoord),
random->nextRangeScalar(kMinCoord, kMaxCoord),
DRAW_BATCH_TEST_DEFINE(GrDrawAtlasBatch) {
uint32_t spriteCount = random->nextRangeU(1, 100);
-
+
SkTArray<SkRSXform> xforms(spriteCount);
SkTArray<SkRect> texRects(spriteCount);
SkTArray<GrColor> colors;
-
+
bool hasColors = random->nextBool();
-
+
randomize_params(spriteCount,
random,
&xforms,
&texRects,
&colors, hasColors);
-
+
SkMatrix viewMatrix = GrTest::TestMatrix(random);
-
+
GrDrawAtlasBatch::Geometry geometry;
geometry.fColor = GrRandomColor(random);
return GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount, xforms.begin(),
const SkColor* colors) {
return new GrDrawAtlasBatch(geometry, viewMatrix, spriteCount, xforms, rects, colors);
}
-
+
const char* name() const override { return "DrawAtlasBatch"; }
-
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
bool hasColors() const { return fHasColors; }
int quadCount() const { return fQuadCount; }
bool coverageIgnored() const { return fCoverageIgnored; }
-
+
bool onCombineIfPossible(GrBatch* t, const GrCaps&) override;
SkSTArray<1, Geometry, true> fGeoData;
-
+
SkMatrix fViewMatrix;
GrColor fColor;
int fQuadCount;
}
protected:
- virtual void computePipelineOptimizations(GrInitInvariantOutput* color,
+ virtual void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const = 0;
class GrDrawPathBatchBase : public GrDrawBatch {
public:
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
color->setKnownFourComponents(fColor);
this->setBounds(bounds);
}
-void GrDrawVerticesBatch::computePipelineOptimizations(GrInitInvariantOutput* color,
+void GrDrawVerticesBatch::computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const {
// When this is called on a batch, there is only one geometry bundle
const char* name() const override { return "DrawVerticesBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override;
return str;
}
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
color->setUnknownFourComponents();
const char* name() const override { return "GrStrokeRectBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
struct PLSVertex {
SkPoint fPos;
// for triangles, these are the three triangle vertices
- // for quads, vert1 is the texture UV coords, and vert2 and vert3 are the line segment
+ // for quads, vert1 is the texture UV coords, and vert2 and vert3 are the line segment
// comprising the flat edge of the quad
SkPoint fVert1;
SkPoint fVert2;
#define kQuadNumVertices 5
static void add_quad(SkPoint pts[3], PLSVertices& vertices) {
- SkPoint normal = SkPoint::Make(pts[0].fY - pts[2].fY,
+ SkPoint normal = SkPoint::Make(pts[0].fY - pts[2].fY,
pts[2].fX - pts[0].fX);
normal.setLength(kBloatSize);
SkScalar cross = (pts[1] - pts[0]).cross(pts[2] - pts[0]);
return true;
}
-static bool get_geometry(const SkPath& path, const SkMatrix& m, PLSVertices& triVertices,
+static bool get_geometry(const SkPath& path, const SkMatrix& m, PLSVertices& triVertices,
PLSVertices& quadVertices, GrResourceProvider* resourceProvider,
SkRect bounds) {
SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance;
GrGLSLVertToFrag v1(kVec2f_GrSLType);
varyingHandler->addVarying("Vertex1", &v1, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);",
+ vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);",
v1.vsOut(),
- te.inVertex1()->fName,
+ te.inVertex1()->fName,
te.inVertex1()->fName);
GrGLSLVertToFrag v2(kVec2f_GrSLType);
varyingHandler->addVarying("Vertex2", &v2, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);",
+ vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);",
v2.vsOut(),
- te.inVertex2()->fName,
+ te.inVertex2()->fName,
te.inVertex2()->fName);
GrGLSLVertToFrag v3(kVec2f_GrSLType);
varyingHandler->addVarying("Vertex3", &v3, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);",
+ vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);",
v3.vsOut(),
- te.inVertex3()->fName,
+ te.inVertex3()->fName,
te.inVertex3()->fName);
GrGLSLVertToFrag delta1(kVec2f_GrSLType);
varyingHandler->addVarying("delta1", &delta1, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
+ vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
delta1.vsOut(), v1.vsOut(), v2.vsOut(), v2.vsOut(), v1.vsOut());
GrGLSLVertToFrag delta2(kVec2f_GrSLType);
varyingHandler->addVarying("delta2", &delta2, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
+ vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
delta2.vsOut(), v2.vsOut(), v3.vsOut(), v3.vsOut(), v2.vsOut());
GrGLSLVertToFrag delta3(kVec2f_GrSLType);
varyingHandler->addVarying("delta3", &delta3, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
+ vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
delta3.vsOut(), v3.vsOut(), v1.vsOut(), v1.vsOut(), v3.vsOut());
GrGLSLVertToFrag windings(kInt_GrSLType);
varyingHandler->addFlatVarying("windings", &windings, kLow_GrSLPrecision);
- vsBuilder->codeAppendf("%s = %s;",
+ vsBuilder->codeAppendf("%s = %s;",
windings.vsOut(), te.inWindings()->fName);
// emit transforms
- this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- te.inPosition()->fName, te.localMatrix(), args.fTransformsIn,
+ this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
+ te.inPosition()->fName, te.localMatrix(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
SkAssertResult(fsBuilder->enableFeature(
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL);
- // Compute four subsamples, each shifted a quarter pixel along x and y from
- // gl_FragCoord. The oriented box positioning of the subsamples is of course not
+ // Compute four subsamples, each shifted a quarter pixel along x and y from
+ // gl_FragCoord. The oriented box positioning of the subsamples is of course not
// optimal, but it greatly simplifies the math and this simplification is necessary for
// performance reasons.
- fsBuilder->codeAppendf("highp vec2 firstSample = %s.xy - vec2(0.25);",
+ fsBuilder->codeAppendf("highp vec2 firstSample = %s.xy - vec2(0.25);",
fsBuilder->fragmentPosition());
fsBuilder->codeAppendf("highp vec2 delta1 = %s;", delta1.fsIn());
fsBuilder->codeAppendf("highp vec2 delta2 = %s;", delta2.fsIn());
// all are < 0, we're inside. The first vector in each case is half of what it is
// "supposed" to be, because we re-use them later as adjustment factors for which half
// is the correct value, so we multiply the dots by two to compensate.
- fsBuilder->codeAppendf("highp float d1 = dot(delta1, (firstSample - %s).yx) * 2.0;",
+ fsBuilder->codeAppendf("highp float d1 = dot(delta1, (firstSample - %s).yx) * 2.0;",
v1.fsIn());
- fsBuilder->codeAppendf("highp float d2 = dot(delta2, (firstSample - %s).yx) * 2.0;",
+ fsBuilder->codeAppendf("highp float d2 = dot(delta2, (firstSample - %s).yx) * 2.0;",
v2.fsIn());
- fsBuilder->codeAppendf("highp float d3 = dot(delta3, (firstSample - %s).yx) * 2.0;",
+ fsBuilder->codeAppendf("highp float d3 = dot(delta3, (firstSample - %s).yx) * 2.0;",
v3.fsIn());
fsBuilder->codeAppend("highp float dmax = max(d1, max(d2, d3));");
fsBuilder->codeAppendf("pls.windings[0] += (dmax <= 0.0) ? %s : 0;", windings.fsIn());
: fLocalMatrix(localMatrix)
, fUsesLocalCoords(usesLocalCoords) {
this->initClassID<PLSAATriangleEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInVertex1 = &this->addVertexAttrib(Attribute("inVertex1", kVec2f_GrVertexAttribType,
+ fInVertex1 = &this->addVertexAttrib(Attribute("inVertex1", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInVertex2 = &this->addVertexAttrib(Attribute("inVertex2", kVec2f_GrVertexAttribType,
+ fInVertex2 = &this->addVertexAttrib(Attribute("inVertex2", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInVertex3 = &this->addVertexAttrib(Attribute("inVertex3", kVec2f_GrVertexAttribType,
+ fInVertex3 = &this->addVertexAttrib(Attribute("inVertex3", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInWindings = &this->addVertexAttrib(Attribute("inWindings", kInt_GrVertexAttribType,
+ fInWindings = &this->addVertexAttrib(Attribute("inWindings", kInt_GrVertexAttribType,
kLow_GrSLPrecision));
this->setWillReadFragmentPosition();
}
const Attribute* fInWindings;
SkMatrix fLocalMatrix;
bool fUsesLocalCoords;
-
+
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
GrGLSLVertToFrag ep1(kVec2f_GrSLType);
varyingHandler->addVarying("endpoint1", &ep1, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);", ep1.vsOut(),
+ vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);", ep1.vsOut(),
qe.inEndpoint1()->fName, qe.inEndpoint1()->fName);
GrGLSLVertToFrag ep2(kVec2f_GrSLType);
varyingHandler->addVarying("endpoint2", &ep2, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);", ep2.vsOut(),
+ vsBuilder->codeAppendf("%s = vec2(%s.x, %s.y);", ep2.vsOut(),
qe.inEndpoint2()->fName, qe.inEndpoint2()->fName);
GrGLSLVertToFrag delta(kVec2f_GrSLType);
varyingHandler->addVarying("delta", &delta, kHigh_GrSLPrecision);
- vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
- delta.vsOut(), ep1.vsOut(), ep2.vsOut(), ep2.vsOut(),
+ vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
+ delta.vsOut(), ep1.vsOut(), ep2.vsOut(), ep2.vsOut(),
ep1.vsOut());
GrGLSLVertToFrag windings(kInt_GrSLType);
varyingHandler->addFlatVarying("windings", &windings, kLow_GrSLPrecision);
- vsBuilder->codeAppendf("%s = %s;",
+ vsBuilder->codeAppendf("%s = %s;",
windings.vsOut(), qe.inWindings()->fName);
// Setup position
this->setupPosition(vsBuilder, gpArgs, qe.inPosition()->fName);
// emit transforms
- this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- qe.inPosition()->fName, qe.localMatrix(), args.fTransformsIn,
+ this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
+ qe.inPosition()->fName, qe.localMatrix(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
"} else {"
"return false;"
"}";
- fsBuilder->emitFunction(kBool_GrSLType, "in_quad", QUAD_ARGS, inQuadArgs, inQuadCode,
+ fsBuilder->emitFunction(kBool_GrSLType, "in_quad", QUAD_ARGS, inQuadArgs, inQuadCode,
&inQuadName);
fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL);
// keep the derivative instructions outside the conditional
fsBuilder->codeAppendf("highp vec2 uvdY = dFdy(%s);", uv.fsIn());
fsBuilder->codeAppend("highp vec2 uvIncX = uvdX * 0.45 + uvdY * -0.1;");
fsBuilder->codeAppend("highp vec2 uvIncY = uvdX * 0.1 + uvdY * 0.55;");
- fsBuilder->codeAppendf("highp vec2 uv = %s.xy - uvdX * 0.35 - uvdY * 0.25;",
+ fsBuilder->codeAppendf("highp vec2 uv = %s.xy - uvdX * 0.35 - uvdY * 0.25;",
uv.fsIn());
fsBuilder->codeAppendf("highp vec2 firstSample = %s.xy - vec2(0.25);",
fsBuilder->fragmentPosition());
- fsBuilder->codeAppendf("highp float d = dot(%s, (firstSample - %s).yx) * 2.0;",
+ fsBuilder->codeAppendf("highp float d = dot(%s, (firstSample - %s).yx) * 2.0;",
delta.fsIn(), ep1.fsIn());
- fsBuilder->codeAppendf("pls.windings[0] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
+ fsBuilder->codeAppendf("pls.windings[0] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
windings.fsIn());
fsBuilder->codeAppend("uv += uvIncX;");
fsBuilder->codeAppendf("d += %s.x;", delta.fsIn());
- fsBuilder->codeAppendf("pls.windings[1] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
+ fsBuilder->codeAppendf("pls.windings[1] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
windings.fsIn());
fsBuilder->codeAppend("uv += uvIncY;");
fsBuilder->codeAppendf("d += %s.y;", delta.fsIn());
- fsBuilder->codeAppendf("pls.windings[2] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
+ fsBuilder->codeAppendf("pls.windings[2] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
windings.fsIn());
fsBuilder->codeAppend("uv -= uvIncX;");
fsBuilder->codeAppendf("d -= %s.x;", delta.fsIn());
- fsBuilder->codeAppendf("pls.windings[3] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
+ fsBuilder->codeAppendf("pls.windings[3] += %s(d, uv) ? %s : 0;", inQuadName.c_str(),
windings.fsIn());
}
: fLocalMatrix(localMatrix)
, fUsesLocalCoords(usesLocalCoords) {
this->initClassID<PLSQuadEdgeEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribType,
+ fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInEndpoint1 = &this->addVertexAttrib(Attribute("inEndpoint1", kVec2f_GrVertexAttribType,
+ fInEndpoint1 = &this->addVertexAttrib(Attribute("inEndpoint1", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInEndpoint2 = &this->addVertexAttrib(Attribute("inEndpoint2", kVec2f_GrVertexAttribType,
+ fInEndpoint2 = &this->addVertexAttrib(Attribute("inEndpoint2", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
- fInWindings = &this->addVertexAttrib(Attribute("inWindings", kInt_GrVertexAttribType,
+ fInWindings = &this->addVertexAttrib(Attribute("inWindings", kInt_GrVertexAttribType,
kLow_GrSLPrecision));
this->setWillReadFragmentPosition();
}
const Attribute* fInWindings;
SkMatrix fLocalMatrix;
bool fUsesLocalCoords;
-
+
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
bool usesLocalCoords() const { return fUsesLocalCoords; }
-
- GrPixelLocalStorageState getPixelLocalStorageState() const override {
+
+ GrPixelLocalStorageState getPixelLocalStorageState() const override {
return GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState;
}
const char* getDestColorOverride() const override {
- return GR_GL_PLS_DSTCOLOR_NAME;
+ return GR_GL_PLS_DSTCOLOR_NAME;
}
class GLSLProcessor : public GrGLSLGeometryProcessor {
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
fUseEvenOdd = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kFloat_GrSLType, kLow_GrSLPrecision,
+ kFloat_GrSLType, kLow_GrSLPrecision,
"useEvenOdd");
const char* useEvenOdd = uniformHandler->getUniformCStr(fUseEvenOdd);
varyingHandler->emitAttributes(fe);
this->setupPosition(vsBuilder, gpArgs, fe.inPosition()->fName);
- this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
- fe.inPosition()->fName, fe.localMatrix(), args.fTransformsIn,
+ this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpArgs->fPositionVar,
+ fe.inPosition()->fName, fe.localMatrix(), args.fTransformsIn,
args.fTransformsOut);
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
fsBuilder->codeAppend("coverage += pls.windings[3] != 0 ? 0.25 : 0.0;");
fsBuilder->codeAppend("}");
if (!fe.colorIgnored()) {
- this->setupUniformColor(fsBuilder, uniformHandler, args.fOutputColor,
+ this->setupUniformColor(fsBuilder, uniformHandler, args.fOutputColor,
&fColorUniform);
}
fsBuilder->codeAppendf("%s = vec4(coverage);", args.fOutputCoverage);
}
private:
- PLSFinishEffect(GrColor color, bool useEvenOdd, const SkMatrix& localMatrix,
+ PLSFinishEffect(GrColor color, bool useEvenOdd, const SkMatrix& localMatrix,
bool usesLocalCoords)
: fColor(color)
, fUseEvenOdd(useEvenOdd)
, fLocalMatrix(localMatrix)
, fUsesLocalCoords(usesLocalCoords) {
this->initClassID<PLSFinishEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
kHigh_GrSLPrecision));
}
const char* name() const override { return "PLSBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
}
SkAutoTUnref<GrGeometryProcessor> finishProcessor(
- PLSFinishEffect::Create(this->color(),
- pathPtr->getFillType() ==
+ PLSFinishEffect::Create(this->color(),
+ pathPtr->getFillType() ==
SkPath::FillType::kEvenOdd_FillType,
- invert,
+ invert,
this->usesLocalCoords()));
const GrBuffer* rectVertexBuffer;
size_t finishStride = finishProcessor->getVertexStride();
-
/*
* Copyright 2012 Google Inc.
*
/*
* Renders arbitrary antialiased paths using pixel local storage as a scratch buffer. The overall
- * technique is very similar to the approach presented in "Resolution independent rendering of
+ * technique is very similar to the approach presented in "Resolution independent rendering of
* deformable vector objects using graphics hardware" by Kokojima et al.
* We first render the straight-line portions of the path (essentially pretending as if all segments
- * were kLine_Verb) as a triangle fan, using a fragment shader which updates the winding counts
- * appropriately. We then render the curved portions of the path using a Loop-Blinn shader which
+ * were kLine_Verb) as a triangle fan, using a fragment shader which updates the winding counts
+ * appropriately. We then render the curved portions of the path using a Loop-Blinn shader which
* calculates which portion of the triangle is covered by the quad (conics and cubics are split down
- * to quads). Where we diverge from Kokojima is that, instead of rendering into the stencil buffer
+ * to quads). Where we diverge from Kokojima is that, instead of rendering into the stencil buffer
* and using built-in MSAA to handle straight-line antialiasing, we use the pixel local storage area
- * and calculate the MSAA ourselves in the fragment shader. Essentially, we manually evaluate the
+ * and calculate the MSAA ourselves in the fragment shader. Essentially, we manually evaluate the
* coverage of each pixel four times, storing four winding counts into the pixel local storage area,
* and compute the final coverage based on those winding counts.
*
- * Our approach is complicated by the need to perform antialiasing on straight edges as well,
- * without relying on hardware MSAA. We instead bloat the triangles to ensure complete coverage,
- * pass the original (un-bloated) vertices in to the fragment shader, and then have the fragment
- * shader use these vertices to evaluate whether a given sample is located within the triangle or
+ * Our approach is complicated by the need to perform antialiasing on straight edges as well,
+ * without relying on hardware MSAA. We instead bloat the triangles to ensure complete coverage,
+ * pass the original (un-bloated) vertices in to the fragment shader, and then have the fragment
+ * shader use these vertices to evaluate whether a given sample is located within the triangle or
* not. This gives us MSAA4 edges on triangles which line up nicely with no seams. We similarly face
- * problems on the back (flat) edges of quads, where we have to ensure that the back edge is
- * antialiased in the same way. Similar to the triangle case, we pass in the two (unbloated)
+ * problems on the back (flat) edges of quads, where we have to ensure that the back edge is
+ * antialiased in the same way. Similar to the triangle case, we pass in the two (unbloated)
* vertices defining the back edge of the quad and the fragment shader uses these vertex coordinates
* to discard samples falling on the other side of the quad's back edge.
*/
-
/*
* Copyright 2012 Google Inc.
*
}
GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider* resourceProvider)
- : fResourceProvider(resourceProvider) {
+ : fResourceProvider(resourceProvider) {
}
bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
-
/*
* Copyright 2012 Google Inc.
*
return str;
}
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
GrTInstanceBatch() : INHERITED(ClassID()) {}
void onPrepareDraws(Target* target) const override {
- SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeometry(),
+ SkAutoTUnref<const GrGeometryProcessor> gp(Impl::CreateGP(this->seedGeometry(),
fOverrides));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
/*
* This path renderer tessellates the path into triangles using GrTessellator, uploads the triangles
- * to a vertex buffer, and renders them with a single draw call. It does not currently do
+ * to a vertex buffer, and renders them with a single draw call. It does not currently do
* antialiasing, so it must be used in conjunction with multisampling.
*/
namespace {
const char* name() const override { return "TessellatingPathBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
color->setKnownFourComponents(fColor);
virtual const char* name() const override = 0;
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
} while (nullptr == gp);
return gp;
}
-
-
/*
* Copyright 2014 Google Inc.
*
GrColor* color,
const GrCaps& caps) const {
// We never look at the color input
- return GrXferProcessor::kIgnoreColor_OptFlag;
+ return GrXferProcessor::kIgnoreColor_OptFlag;
}
void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
bool invertCoverage() const { return fInvertCoverage; }
private:
- GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&, bool, GrColor*,
+ GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&, bool, GrColor*,
const GrCaps&) const override {
// We never look at the color input
- return GrXferProcessor::kIgnoreColor_OptFlag;
+ return GrXferProcessor::kIgnoreColor_OptFlag;
}
void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->nextBool();
return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage);
}
-
const char* name() const override { return "DashBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
// When this is called on a batch, there is only one geometry bundle
-
/*
* Copyright 2014 Google Inc.
*
const GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) {
return GrDisableColorXPFactory::Create();
}
-
vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
-
+
// Use highp to work around aliasing issues
fragBuilder->codeAppend(GrGLSLShaderVar::PrecisionString(args.fGLSLCaps,
kHigh_GrSLPrecision));
fragBuilder->codeAppend("float afwidth;");
if (isUniformScale) {
// For uniform scale, we adjust for the effect of the transformation on the distance
- // by using the length of the gradient of the t coordinate in the y direction.
+ // by using the length of the gradient of the t coordinate in the y direction.
// We use st coordinates to ensure we're mapping 1:1 from texel space to pixel space.
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
if (isUniformScale) {
// For uniform scale, we adjust for the effect of the transformation on the distance
- // by using the length of the gradient of the t coordinate in the y direction.
+ // by using the length of the gradient of the t coordinate in the y direction.
// We use st coordinates to ensure we're mapping 1:1 from texel space to pixel space.
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
SkASSERT(fTextureSizeUni.isValid());
GrTexture* texture = proc.texture(0);
- if (texture->width() != fTextureSize.width() ||
+ if (texture->width() != fTextureSize.width() ||
texture->height() != fTextureSize.height()) {
fTextureSize = SkISize::Make(texture->width(), texture->height());
pdman.set2f(fTextureSizeUni,
// trade-off between quality and speed.
fragBuilder->codeAppend("float afwidth;");
if (isSimilarity) {
- // For similarity transform (uniform scale-only is a subset of this), we adjust for the
- // effect of the transformation on the distance by using the length of the gradient of
+ // For similarity transform (uniform scale-only is a subset of this), we adjust for the
+ // effect of the transformation on the distance by using the length of the gradient of
// the texture coordinates. We use st coordinates to ensure we're mapping 1:1 from texel
// space to pixel space.
kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait mode (not used yet)
kInvalid_DistanceFieldEffectFlag = 0x80, // invalid state (for initialization)
-
+
kUniformScale_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag |
kScaleOnly_DistanceFieldEffectFlag,
// The subset of the flags relevant to GrDistanceFieldA8TextGeoProc
GrGLSLShaderBuilder::ShaderBlock block(fragBuilder);
int offset = y*kWidth + x;
- fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4,
+ fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4,
kVecSuffix[offset & 0x3]);
SkString coord;
coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc);
SkXfermode::Mode getXfermode() const { return fXfermode; }
private:
- GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&, bool, GrColor*,
+ GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&, bool, GrColor*,
const GrCaps&) const override {
return kNone_OptFlags;
}
}
blendFormula = get_lcd_blend_formula(optimizations.fCoveragePOI, fXfermode);
} else {
- blendFormula = get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI,
+ blendFormula = get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI,
hasMixedSamples, fXfermode);
}
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
return false;
}
-
+
// When we have four channel coverage we always need to read the dst in order to correctly
// blend. The one exception is when we are using srcover mode and we know the input color into
// the XP.
}
// We fallback on the shader XP when the blend formula would use dual source blending but we
// don't have support for it.
- return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI, hasMixedSamples,
+ return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI, hasMixedSamples,
fXfermode).hasSecondaryOutput();
}
}
blendFormula = get_lcd_blend_formula(optimizations.fCoveragePOI, SkXfermode::kSrcOver_Mode);
} else {
- blendFormula = get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI,
+ blendFormula = get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI,
hasMixedSamples, SkXfermode::kSrcOver_Mode);
}
!caps.shaderCaps()->dstReadInShaderSupport()) {
return false;
}
- return get_lcd_blend_formula(optimizations.fCoveragePOI,
+ return get_lcd_blend_formula(optimizations.fCoveragePOI,
SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
}
// We fallback on the shader XP when the blend formula would use dual source blending but we
return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI,
hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
}
-
builder->appendTextureLookupAndModulate(inModulateColor, sampler,
inCoords.c_str());
builder->codeAppend(";");
-
+
builder->codeAppend(GrGLSLShaderVar::PrecisionString(glslCaps,
kHigh_GrSLPrecision));
builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
SkString dumpInfo() const override {
SkString str;
- str.appendf("Domain: [L: %.2f, T: %.2f, R: %.2f, B: %.2f] ",
+ str.appendf("Domain: [L: %.2f, T: %.2f, R: %.2f, B: %.2f] ",
fTextureDomain.domain().fLeft, fTextureDomain.domain().fTop,
fTextureDomain.domain().fRight, fTextureDomain.domain().fBottom);
str.append(INHERITED::dumpInfo());
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
fSampleLocationsSupport = version >= GR_GL_VER(3,1);
}
- // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED
+ // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED
// and GL_RG on FBO textures.
if (kMesa_GrGLDriver != ctxInfo.driver()) {
if (kGL_GrGLStandard == standard) {
// We're assuming that on Windows Chromium we're using ANGLE.
bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() ||
kChromium_GrGLDriver == ctxInfo.driver();
- // Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA).
+ // Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA).
fRGBA8888PixelsOpsAreSlow = isANGLE;
// On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is still true and
// check DX11 ANGLE.
if (ctxInfo.hasExtension("GL_EXT_shader_pixel_local_storage")) {
#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
- GR_GL_GetIntegerv(gli, GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT,
+ GR_GL_GetIntegerv(gli, GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT,
&glslCaps->fPixelLocalStorageSize);
glslCaps->fPLSPathRenderingSupport = glslCaps->fFBFetchSupport;
}
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_pixel_buffer_object")) {
fTransferBufferType = kPBO_TransferBufferType;
- }
+ }
} else {
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_NV_pixel_buffer_object")) {
fTransferBufferType = kPBO_TransferBufferType;
r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSupport ? "YES" : "NO"));
r.appendf("Rectangle texture support: %s\n", (fRectangleTextureSupport? "YES" : "NO"));
r.appendf("Texture swizzle support: %s\n", (fTextureSwizzleSupport ? "YES" : "NO"));
- r.appendf("BGRA to RGBA readback conversions are slow: %s\n",
+ r.appendf("BGRA to RGBA readback conversions are slow: %s\n",
(fRGBAToBGRAReadbackConversionsAreSlow ? "YES" : "NO"));
r.append("Configs\n-------\n");
}
void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
- const GrGLInterface* intf,
+ const GrGLInterface* intf,
GrGLSLCaps* glslCaps) {
if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4, 1) ||
ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
first = &glslCaps->fFloatPrecisions[s][p];
}
else if (!glslCaps->fShaderPrecisionVaries) {
- glslCaps->fShaderPrecisionVaries =
+ glslCaps->fShaderPrecisionVaries =
(*first != glslCaps->fFloatPrecisions[s][p]);
}
}
// are recommended against.
if (glslCaps->fGeometryShaderSupport) {
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
- glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
+ glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
glslCaps->fFloatPrecisions[kVertex_GrShaderType][p];
}
}
// This extension GL_BGRA as an unsized internal format. However, it is written against ES
// 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses unsized internal
// formats.
- // GL_APPLE_texture_format_BGRA8888:
+ // GL_APPLE_texture_format_BGRA8888:
// ES 2.0: the extension makes BGRA an external format but not an internal format.
// ES 3.0: the extension explicitly states GL_BGRA8 is not a valid internal format for
// glTexImage (just for glTexStorage).
/** The external format and type are to be used when uploading/downloading data using this
config where both the CPU data and GrSurface are the same config. To get the external
format and type when converting between configs while copying to/from memory use
- getExternalFormat().
+ getExternalFormat().
The kTexImage external format is usually the same as kOther except for kSRGBA on some
GL contexts. */
GrGLenum fExternalFormat[kExternalFormatUsageCnt];
// added to suppress 'no previous prototype' warning and because this code is duplicated in
// SkNullGLContext.cpp
-namespace {
+namespace {
class BufferObj {
public:
#define GR_GL_PIXEL_PACK_BUFFER 0x88EB
#define GR_GL_PIXEL_UNPACK_BUFFER 0x88EC
-#define GR_GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 0x78EC
+#define GR_GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 0x78EC
#define GR_GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM 0x78ED
#define GR_GL_STREAM_DRAW 0x88E0
#define GR_GL_FRAMEBUFFER_SRGB 0x8DB9
#define GR_GL_SHADER_PIXEL_LOCAL_STORAGE 0x8F64
#define GR_GL_SAMPLE_SHADING 0x8C36
-
+
/* ErrorCode */
#define GR_GL_NO_ERROR 0
#define GR_GL_INVALID_ENUM 0x0500
GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUniform_TypeModifier);
GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
-
+
SkString vshaderTxt(version);
if (glslCaps->noperspectiveInterpolationSupport()) {
if (const char* extension = glslCaps->noperspectiveInterpolationExtensionString()) {
vshaderTxt.append(";");
vTexCoord.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";");
-
+
vshaderTxt.append(
"// PLS Setup Program VS\n"
"void main() {"
void GrGLGpu::finishDrawTarget() {
if (fPLSHasBeenUsed) {
- /* There is an ARM driver bug where if we use PLS, and then draw a frame which does not
- * use PLS, it leaves garbage all over the place. As a workaround, we use PLS in a
+ /* There is an ARM driver bug where if we use PLS, and then draw a frame which does not
+ * use PLS, it leaves garbage all over the place. As a workaround, we use PLS in a
* trivial way every frame. And since we use it every frame, there's never a point at which
* it becomes safe to stop using this workaround once we start.
*/
SkASSERT(!fHWPLSEnabled);
SkASSERT(fMSAAEnabled != kYes_TriState);
GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
- this->stampRectUsingProgram(fPLSSetupProgram.fProgram,
- SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.01f),
- fPLSSetupProgram.fPosXformUniform,
+ this->stampRectUsingProgram(fPLSSetupProgram.fProgram,
+ SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.01f),
+ fPLSSetupProgram.fPosXformUniform,
fPLSSetupProgram.fArrayBuffer);
GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
}
#endif
}
-void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint posXformUniform,
+void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint posXformUniform,
GrGLuint arrayBuffer) {
GL_CALL(UseProgram(program));
this->fHWGeometryState.setVertexArrayID(this, 0);
attribs->set(this, 0, arrayBuffer, kVec2f_GrVertexAttribType, 2 * sizeof(GrGLfloat), 0);
attribs->disableUnusedArrays(this, 0x1);
- GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.left(),
+ GL_CALL(Uniform4f(posXformUniform, bounds.width(), bounds.height(), bounds.left(),
bounds.top()));
GrXferProcessor::BlendInfo blendInfo;
void GrGLGpu::setupPixelLocalStorage(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc) {
fPLSHasBeenUsed = true;
- const SkRect& bounds =
+ const SkRect& bounds =
static_cast<const GrPLSGeometryProcessor&>(primProc).getBounds();
// setup pixel local storage -- this means capturing and storing the current framebuffer color
// and initializing the winding counts to zero
GrGLfloat dy0 = -2.0f * (bounds.top() - 1) / height + 1.0f;
GrGLfloat dy1 = -2.0f * (bounds.bottom() + 1) / height + 1.0f;
SkRect deviceBounds = SkRect::MakeXYWH(dx0, dy0, dx1 - dx0, dy1 - dy0);
-
+
GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM));
- this->stampRectUsingProgram(fPLSSetupProgram.fProgram, deviceBounds,
+ this->stampRectUsingProgram(fPLSSetupProgram.fProgram, deviceBounds,
fPLSSetupProgram.fPosXformUniform, fPLSSetupProgram.fArrayBuffer);
}
const SkIRect& srcRect,
const SkIPoint& dstPoint);
- void stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint posXformUniform,
+ void stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint posXformUniform,
GrGLuint arrayBuffer);
void setupPixelLocalStorage(const GrPipeline&, const GrPrimitiveProcessor&);
const GrGLBuffer* vbuffer,
const GrGLBuffer* ibuffer);
- /** Variants of the above that takes GL buffer IDs. Note that 0 does not imply that a
+ /** Variants of the above that takes GL buffer IDs. Note that 0 does not imply that a
buffer won't be bound. The "default buffer" will be bound, which is used for client-side
array rendering. */
GrGLAttribArrayState* bindArrayAndBufferToDraw(GrGLGpu* gpu, GrGLuint vbufferID);
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
struct GrGLGpu::ProgramCache::Entry {
-
+
Entry() : fProgram(nullptr), fLRUStamp(0) {}
SkAutoTUnref<GrGLProgram> fProgram;
nullptr == fFunctions.fDrawElementsInstanced) {
RETURN_FALSE_INTERFACE
}
- }
+ }
} else if (kGLES_GrGLStandard == fStandard) {
if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_draw_instanced")) {
if (nullptr == fFunctions.fDrawArraysInstanced ||
nullptr == fFunctions.fDrawElementsInstanced) {
RETURN_FALSE_INTERFACE
}
- }
+ }
}
if (kGL_GrGLStandard == fStandard) {
if (nullptr == fFunctions.fVertexAttribDivisor) {
RETURN_FALSE_INTERFACE
}
- }
+ }
} else if (kGLES_GrGLStandard == fStandard) {
if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_instanced_arrays")) {
if (nullptr == fFunctions.fVertexAttribDivisor) {
RETURN_FALSE_INTERFACE
}
- }
+ }
}
if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
this->setFragmentData(primProc, pipeline, textureBindings);
- if (primProc.getPixelLocalStorageState() !=
+ if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
const GrXferProcessor& xp = pipeline.getXferProcessor();
fXferProcessor->setData(fProgramDataManager, xp);
virtual GrGLvoid* mapBufferRange(GrGLenum target, GrGLintptr offset, GrGLsizeiptr length, GrGLbitfield access) { return nullptr; }
virtual GrGLvoid* mapBufferSubData(GrGLuint target, GrGLintptr offset, GrGLsizeiptr size, GrGLenum access) { return nullptr; }
virtual GrGLvoid* mapTexSubImage2D(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLenum access) { return nullptr; }
- virtual GrGLvoid minSampleShading(GrGLfloat value) {}
+ virtual GrGLvoid minSampleShading(GrGLfloat value) {}
virtual GrGLvoid pixelStorei(GrGLenum pname, GrGLint param) {}
virtual GrGLvoid popGroupMarker() {}
virtual GrGLvoid pushGroupMarker(GrGLsizei length, const char* marker) {}
GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder;
return glPB->gpu();
}
-
-
friend class GrGLProgramBuilder;
- typedef GrGLSLUniformHandler INHERITED;
+ typedef GrGLSLUniformHandler INHERITED;
};
#endif
friend class GrGLProgramBuilder;
- typedef GrGLSLVaryingHandler INHERITED;
+ typedef GrGLSLVaryingHandler INHERITED;
};
#endif
-
GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, GrGLuint ibufferID) {
GrGLAttribArrayState* state = this->bind(gpu);
if (state) {
- if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) {
+ if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) {
GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ibufferID));
fIndexBufferIDIsValid = true;
fIndexBufferID = ibufferID;
-
/*
* Copyright 2013 Google Inc.
*
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MIN_FILTER,
GR_GL_NEAREST));
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_S,
- GR_GL_CLAMP_TO_EDGE));
+ GR_GL_CLAMP_TO_EDGE));
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_T,
GR_GL_CLAMP_TO_EDGE));
GR_GL_CALL(fGL, TexImage2D(GR_GL_TEXTURE_RECTANGLE, 0, internalFormat, width, height, 0,
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
fFragmentProcessors,
&fSamplerUniforms);
}
-
bool compileAndAttachShaders(GrGLSLShaderBuilder& shader,
GrGLuint programId,
GrGLenum type,
- SkTDArray<GrGLuint>* shaderIds);
+ SkTDArray<GrGLuint>* shaderIds);
GrGLProgram* finalize();
void bindProgramResourceLocations(GrGLuint programID);
bool checkLinkStatus(GrGLuint programID);
GrGLVaryingHandler fVaryingHandler;
GrGLUniformHandler fUniformHandler;
- typedef GrGLSLProgramBuilder INHERITED;
+ typedef GrGLSLProgramBuilder INHERITED;
};
#endif
-
/*
* Copyright 2015 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
}
return ctx;
}
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2014 Google Inc.
*
GrGLFuncPtr getProc(const char name[]) const {
return (GrGLFuncPtr) dlsym(fLoader.handle(), name);
}
-
+
private:
GLLoader fLoader;
};
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2012 Google Inc.
*
SkASSERT(!shareContext);
return nullptr;
}
-
-
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
}
return ctx;
}
-
}
fsBuilder->codeAppend(";");
}
-
void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
}
-
class GrGLSLCaps : public GrShaderCaps {
public:
-
+
/**
* Indicates how GLSL must interact with advanced blend equations. The KHR extension requires
bool mustEnableSpecificAdvBlendEqs() const {
return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction;
}
-
+
bool mustDeclareFragmentShaderOutput() const {
return fGLSLGeneration > k110_GrGLSLGeneration;
}
void onApplyOptionsOverrides(const GrContextOptions& options) override;
GrGLSLGeneration fGLSLGeneration;
-
+
bool fDropsTileOnZeroDivide : 1;
bool fFBFetchSupport : 1;
bool fFBFetchNeedsCustomOutput : 1;
// The Adreno compiler seems to be very touchy about access to "gl_FragCoord".
// Accessing glFragCoord.zw can cause a program to fail to link. Additionally,
// depending on the surrounding code, accessing .xy with a uniform involved can
- // do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand
+ // do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand
// (and only accessing .xy) seems to "fix" things.
const char* precision = glslCaps->usesPrecisionModifiers() ? "highp " : "";
this->codePrependf("\t%svec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n",
return fbFetchColorName;
} else {
return kDstTextureColorName;
- }
+ }
}
void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquation equation) {
va_list argp;
va_start(argp, fmt);
inputs().appendVAList(fmt, argp);
- va_end(argp);
+ va_end(argp);
}
const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const {
int removeAt = fMangleString.findLastOf('_');
fMangleString.remove(removeAt, fMangleString.size() - removeAt);
}
-
void GrGLSLGeometryBuilder::onFinalize() {
fProgramBuilder->varyingHandler()->getGeomDecls(&this->inputs(), &this->outputs());
}
-
" layout(rgba8i) ivec4 windings;\n"\
" layout(rgba8) vec4 dstColor;\n"\
"} pls;\n"
-
this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
inputCoverage);
- if (primProc.getPixelLocalStorageState() !=
+ if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
- this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor,
+ this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor,
*inputCoverage, this->pipeline().ignoresCoverage(),
primProc.getPixelLocalStorageState());
this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOutput());
// Used to add a uniform in the vertex shader for transforming into normalized device space.
void addRTAdjustmentUniform(GrSLPrecision precision, const char* name, const char** outName);
const char* rtAdjustment() const { return "rtAdjustment"; }
-
+
// Used to add a uniform for the RenderTarget height (used for frag position) without mangling
// the name of the uniform inside of a stage.
void addRTHeightUniform(const char* name, const char** outName);
-
/*
* Copyright 2016 Google Inc.
*
};
this->setMatrix3f(u, mt);
}
-
this->appendDecls(fFragInputs, inputDecls);
this->appendDecls(fFragOutputs, outputDecls);
}
-
void GrGLSLVertexBuilder::onFinalize() {
fProgramBuilder->varyingHandler()->getVertexDecls(&this->inputs(), &this->outputs());
}
-
void transformToNormalizedDeviceSpace(const GrShaderVar& posVar);
private:
void onFinalize() override;
-
+
const char* fRtAdjustName;
friend class GrGLProgramBuilder;
int yInt = (random->nextU() % kMaxTrans) * yPos;
SkScalar x = SkIntToScalar(xInt);
SkScalar y = SkIntToScalar(yInt);
-
+
// right now we don't handle textblobs, nor do we handle drawPosText. Since we only
// intend to test the batch with this unit test, that is okay.
SkAutoTUnref<GrAtlasTextBlob> blob(
-
/*
* Copyright 2010 Google Inc.
*
class SkPath;
/*
- * Wrapper class to turn a font cache descriptor into a key
+ * Wrapper class to turn a font cache descriptor into a key
* for GrFontScaler-related lookups
*/
class GrFontDescKey : public SkRefCnt {
public:
explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.getChecksum()) {}
-
+
uint32_t getHash() const { return fHash; }
bool operator==(const GrFontDescKey& rh) const {
return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc());
}
-
+
private:
SkAutoDescriptor fDesc;
uint32_t fHash;
-
+
typedef SkRefCnt INHERITED;
};
/*
* This is Gr's interface to the host platform's font scaler.
*
- * The client is responsible for instantiating this. The instance is created
+ * The client is responsible for instantiating this. The instance is created
* for a specific font+size+matrix.
*/
class GrFontScaler : public SkRefCnt {
public:
explicit GrFontScaler(SkGlyphCache* strike);
virtual ~GrFontScaler();
-
+
const GrFontDescKey* getKey();
GrMaskFormat getMaskFormat() const;
GrMaskFormat getPackedGlyphMaskFormat(const SkGlyph&) const;
bool getPackedGlyphDFImage(const SkGlyph&, int width, int height, void* image);
const SkPath* getGlyphPath(const SkGlyph&);
const SkGlyph& grToSkGlyph(GrGlyph::PackedID);
-
+
private:
SkGlyphCache* fStrike;
GrFontDescKey* fKey;
-
+
typedef SkRefCnt INHERITED;
};
// query to get the physical device properties
VkPhysicalDeviceFeatures deviceFeatures;
vkGetPhysicalDeviceFeatures(physDev, &deviceFeatures);
- // this looks like it would slow things down,
+ // this looks like it would slow things down,
// and we can't depend on it on all platforms
deviceFeatures.robustBufferAccess = VK_FALSE;
ctx->fExtensions = extensionFlags;
ctx->fFeatures = featureFlags;
ctx->fInterface.reset(GrVkCreateInterface(inst, device, extensionFlags));
-
+
return ctx;
}
|| kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType
|| kUniform_Type == fDesc.fType);
}
-
SET_CONFIG_CAN_STENCIL(gS8);
SET_CONFIG_CAN_STENCIL(gD24S8);
}
-
* Stores some capabilities of a Vk backend.
*/
class GrVkCaps : public GrCaps {
-public:
+public:
typedef GrVkStencilAttachment::Format StencilFormat;
/**
for (int i = 0; i < fTrackedResources.count(); ++i) {
fTrackedResources[i]->unref(gpu);
}
-
+
// Destroy the fence, if any
if (VK_NULL_HANDLE != fSubmitFence) {
GR_VK_CALL(gpu->vkInterface(), DestroyFence(gpu->device(), fSubmitFence, nullptr));
void GrVkCommandBuffer::submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu::SyncQueue sync) {
SkASSERT(!fIsActive);
-
+
VkResult err;
VkFenceCreateInfo fenceInfo;
memset(&fenceInfo, 0, sizeof(VkFenceCreateInfo));
GR_VK_CALL_ERRCHECK(gpu->vkInterface(), QueueSubmit(queue, 1, &submitInfo, fSubmitFence));
if (GrVkGpu::kForce_SyncQueue == sync) {
- err = GR_VK_CALL(gpu->vkInterface(),
+ err = GR_VK_CALL(gpu->vkInterface(),
WaitForFences(gpu->device(), 1, &fSubmitFence, true, UINT64_MAX));
if (VK_TIMEOUT == err) {
SkDebugf("Fence failed to signal: %d\n", err);
uint32_t instanceCount,
uint32_t firstVertex,
uint32_t firstInstance) const;
-
+
// Add ref-counted resource that will be tracked and released when this
// command buffer finishes execution
void addResource(const GrVkResource* resource) {
#endif
-
GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count)
: INHERITED()
- , fType (type)
+ , fType (type)
, fCount(count) {
VkDescriptorPoolSize poolSize;
memset(&poolSize, 0, sizeof(VkDescriptorPoolSize));
class GrVkGpu;
/**
- * We require that all descriptor sets are of a single descriptor type. We also use a pool to only
+ * We require that all descriptor sets are of a single descriptor type. We also use a pool to only
* make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for
* for one type of descriptor.
*/
layerCount = fInstanceLayerStrings->count();
for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) {
uint32_t extensionCount = 0;
- res = EnumerateInstanceExtensionProperties((*fInstanceLayerStrings)[layerIndex].c_str(),
+ res = EnumerateInstanceExtensionProperties((*fInstanceLayerStrings)[layerIndex].c_str(),
&extensionCount, nullptr);
if (VK_SUCCESS != res) {
return false;
if (specVersion >= extensions[i].specVersion &&
find_string(*fInstanceExtensionStrings, extensions[i].extensionName) < 0) {
fInstanceExtensionStrings->push_back() = extensions[i].extensionName;
- SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings->back(),
+ SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings->back(),
cmp);
}
}
#include "vk/GrVkDefines.h"
/**
- * This helper queries the Vulkan driver for available extensions and layers, remembers them,
+ * This helper queries the Vulkan driver for available extensions and layers, remembers them,
* and can be queried. It supports queries for both instance and device extensions and layers.
*/
class SK_API GrVkExtensions {
, fDeviceExtensionStrings(new SkTArray<SkString>)
, fInstanceLayerStrings(new SkTArray<SkString>)
, fDeviceLayerStrings(new SkTArray<SkString>) {}
-
+
bool initInstance(uint32_t specVersion);
bool initDevice(uint32_t specVersion, VkInstance, VkPhysicalDevice);
// At the very least we need a renderPass and a colorAttachment
SkASSERT(renderPass);
SkASSERT(colorAttachment);
-
+
VkImageView attachments[3];
attachments[0] = colorAttachment->imageView();
int numAttachments = 1;
if (stencilAttachment) {
attachments[numAttachments++] = stencilAttachment->imageView();
}
-
+
VkFramebufferCreateInfo createInfo;
memset(&createInfo, 0, sizeof(VkFramebufferCreateInfo));
createInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
createInfo.width = width;
createInfo.height = height;
createInfo.layers = 1;
-
+
VkFramebuffer framebuffer;
VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateFramebuffer(gpu->device(),
&createInfo,
SkASSERT(fFramebuffer);
GR_VK_CALL(gpu->vkInterface(), DestroyFramebuffer(gpu->device(), fFramebuffer, nullptr));
}
-
-
////////////////////////////////////////////////////////////////////////////////
-GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
+GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
const GrVkBackendContext* backendCtx)
: INHERITED(context)
, fVkInstance(backendCtx->fInstance)
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // CmdPoolCreateFlags
backendCtx->fQueueFamilyIndex, // queueFamilyIndex
};
- GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPoolInfo, nullptr,
+ GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPoolInfo, nullptr,
&fCmdPool));
// must call this after creating the CommandPool
SkDEBUGCODE(VkResult res =) VK_CALL(QueueWaitIdle(fQueue));
// VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec)
SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res);
-
+
// must call this just before we destroy the VkDevice
fResourceProvider.destroyResources();
}
if (dstSurface->config() != srcConfig) {
- // TODO: This should fall back to drawing or copying to change config of dstSurface to
+ // TODO: This should fall back to drawing or copying to change config of dstSurface to
// match that of srcConfig.
return false;
}
VkDeviceSize offset = texTop*layout.rowPitch + left*bpp;
VkDeviceSize size = height*layout.rowPitch;
void* mapPtr;
- err = GR_VK_CALL(interface, MapMemory(fDevice, tex->textureMemory(), offset, size, 0,
+ err = GR_VK_CALL(interface, MapMemory(fDevice, tex->textureMemory(), offset, size, 0,
&mapPtr));
if (err) {
return false;
GrVkTexture* texture = nullptr;
if (renderTarget) {
- texture = GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(this, surfDesc,
+ texture = GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(this, surfDesc,
lifeCycle, format,
info);
} else {
- texture = GrVkTexture::CreateWrappedTexture(this, surfDesc, lifeCycle, format,
+ texture = GrVkTexture::CreateWrappedTexture(this, surfDesc, lifeCycle, format,
info);
}
if (!texture) {
GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc,
GrWrapOwnership ownership) {
-
+
const GrVkTextureInfo* info =
reinterpret_cast<const GrVkTextureInfo*>(wrapDesc.fRenderTargetHandle);
if (VK_NULL_HANDLE == info->fImage ||
desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
GrVkRenderTarget* tgt = GrVkRenderTarget::CreateWrappedRenderTarget(this, desc,
- lifeCycle,
+ lifeCycle,
info);
if (tgt && wrapDesc.fStencilBits) {
if (!createStencilAttachmentForRenderTarget(tgt, desc.fWidth, desc.fHeight)) {
VkClearColorValue vkColor;
GrColorToRGBAFloat(color, vkColor.float32);
-
+
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(target);
VkImageLayout origDstLayout = vkRT->currentLayout();
subRange.baseArrayLayer = 0;
subRange.layerCount = 1;
- // In the future we may not actually be doing this type of clear at all. If we are inside a
+ // In the future we may not actually be doing this type of clear at all. If we are inside a
// render pass or doing a non full clear then we will use CmdClearColorAttachment. The more
// common use case will be clearing an attachment at the start of a render pass, in which case
// we will use the clear load ops.
// the cache is flushed since it is only being written to.
VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(origDstLayout);;
VkAccessFlags dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
-
+
dstTex->setImageLayout(this,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
srcAccessMask,
srcStageMask,
dstStageMask,
false);
-
+
srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(origSrcLayout);
dstStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT;
dstStageMask,
false);
- GrVkTransferBuffer* transferBuffer =
+ GrVkTransferBuffer* transferBuffer =
static_cast<GrVkTransferBuffer*>(this->createBuffer(kXferGpuToCpu_GrBufferType,
rowBytes * height,
kStream_GrAccessPattern));
#endif
#endif
}
-
VkPipelineStageFlags dstStageMask,
bool byRegion,
VkImageMemoryBarrier* barrier) const;
-
+
shaderc_compiler_t shadercCompiler() const {
return fCompiler;
}
void bindGeometry(const GrPrimitiveProcessor&, const GrNonInstancedMesh&);
// Ends and submits the current command buffer to the queue and then creates a new command
- // buffer and begins it. If sync is set to kForce_SyncQueue, the function will wait for all
+ // buffer and begins it. If sync is set to kForce_SyncQueue, the function will wait for all
// work in the queue to finish before returning.
void submitCommandBuffer(SyncQueue sync);
if (newLayout == fCurrentLayout) {
return;
}
-
+
VkImageMemoryBarrier imageMemoryBarrier = {
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
NULL, // pNext
fCurrentLayout = newLayout;
}
-const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu,
+const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu,
const ImageDesc& imageDesc) {
VkImage image = 0;
VkDeviceMemory alloc;
const GrVkImageView* GrVkImageView::Create(GrVkGpu* gpu, VkImage image, VkFormat format,
Type viewType) {
VkImageView imageView;
-
+
// Create the VkImageView
VkImageViewCreateInfo viewInfo = {
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType
viewInfo.components.a = VK_COMPONENT_SWIZZLE_ZERO;
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT;
}
-
+
VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateImageView(gpu->device(), &viewInfo,
nullptr, &imageView));
if (err) {
return nullptr;
}
-
+
return new GrVkImageView(imageView);
}
void GrVkImageView::freeGPUData(const GrVkGpu* gpu) const {
GR_VK_CALL(gpu->vkInterface(), DestroyImageView(gpu->device(), fImageView, nullptr));
}
-
-
kColor_Type,
kStencil_Type
};
-
+
static const GrVkImageView* Create(GrVkGpu* gpu, VkImage image, VkFormat format, Type viewType);
VkImageView imageView() const { return fImageView; }
SkASSERT(!this->wasDestroyed());
return static_cast<GrVkGpu*>(this->getGpu());
}
-
#define GET_PROC_LOCAL(inst, F) PFN_vk ## F F = (PFN_vk ## F) vkGetInstanceProcAddr(inst, "vk" #F)
#define GET_DEV_PROC(F) functions->f ## F = (PFN_vk ## F) vkGetDeviceProcAddr(device, "vk" #F)
-const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkDevice device,
+const GrVkInterface* GrVkCreateInterface(VkInstance instance, VkDevice device,
uint32_t extensionFlags) {
GrVkInterface* interface = new GrVkInterface();
}
return true;
}
-
SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount);
}
-void setup_multisample_state(const GrPipeline& pipeline,
+void setup_multisample_state(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
const GrCaps* caps,
VkPipelineMultisampleStateCreateInfo* multisampleInfo) {
VkPipeline vkPipeline;
VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->device(),
- cache, 1,
- &pipelineCreateInfo,
+ cache, 1,
+ &pipelineCreateInfo,
nullptr, &vkPipeline));
if (err) {
return nullptr;
if (scissorState.enabled() &&
!scissorState.rect().contains(0, 0, target.width(), target.height())) {
// This all assumes the scissorState has previously been clipped to the device space render
- // target.
+ // target.
scissor.offset.x = scissorState.rect().fLeft;
scissor.extent.width = scissorState.rect().width();
if (kTopLeft_GrSurfaceOrigin == target.origin()) {
class GrVkPipeline : public GrVkResource {
public:
- static GrVkPipeline* Create(GrVkGpu* gpu,
+ static GrVkPipeline* Create(GrVkGpu* gpu,
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
VkPipelineShaderStageCreateInfo* shaderStageInfo,
b.add32(primitiveType);
- // Set key length
+ // Set key length
int keyLength = key->count();
SkASSERT(0 == (keyLength % 4));
*reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength);
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
const GrVkProgramDesc& desc)
- : INHERITED(pipeline, primProc, desc)
+ : INHERITED(pipeline, primProc, desc)
, fGpu(gpu)
- , fVaryingHandler(this)
+ , fVaryingHandler(this)
, fUniformHandler(this) {
}
uint32_t fragmentUniformSize)
: fVertexUniformSize(vertexUniformSize)
, fFragmentUniformSize(fragmentUniformSize)
- , fVertexUniformsDirty(false)
+ , fVertexUniformsDirty(false)
, fFragmentUniformsDirty(false) {
fVertexUniformData.reset(vertexUniformSize);
fFragmentUniformData.reset(fragmentUniformSize);
fFragmentUniformsDirty = false;
}
}
-
beginInfo->clearValueCount = 0;
beginInfo->pClearValues = nullptr;
- // Currently just assuming no secondary cmd buffers. This value will need to be update if we
+ // Currently just assuming no secondary cmd buffers. This value will need to be update if we
// have them.
*contents = VK_SUBPASS_CONTENTS_INLINE;
}
b->add32(fAttachmentsDescriptor.fStencil.fSamples);
}
}
-
const GrVkImage::Resource* imageResource) {
VkFormat pixelFormat;
GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat);
-
+
VkImage colorImage;
// create msaa surface if necessary
SkASSERT(VK_NULL_HANDLE != info->fImage);
SkASSERT(VK_NULL_HANDLE != info->fAlloc || kAdopted_LifeCycle != lifeCycle);
- GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling)
+ GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling)
? Resource::kLinearTiling_Flag : Resource::kNo_Flags;
const GrVkImage::Resource* imageResource;
SkASSERT(!this->wasDestroyed());
return static_cast<GrVkGpu*>(this->getGpu());
}
-
// Returns the total number of attachments
void getAttachmentsDescriptor(GrVkRenderPass::AttachmentsDescriptor* desc,
GrVkRenderPass::AttachmentFlags* flags) const;
-
+
void addResources(GrVkCommandBuffer& commandBuffer) const;
protected:
const GrVkImage::Resource* fMSAAImageResource;
const GrVkImageView* fResolveAttachmentView;
int fColorValuesPerPixel;
-
+
// This is a cached pointer to a simple render pass. The render target should unref it
// once it is done with it.
const GrVkRenderPass* fCachedSimpleRenderPass;
return false;
}
- /** Increment the reference count.
+ /** Increment the reference count.
Must be balanced by a call to unref() or unrefAndFreeResources().
*/
void ref() const {
#endif
private:
- /** Must be implemented by any subclasses.
- * Deletes any Vk data associated with this resource
+ /** Must be implemented by any subclasses.
+ * Deletes any Vk data associated with this resource
*/
virtual void freeGPUData(const GrVkGpu* gpu) const = 0;
- /** Must be overridden by subclasses that themselves store GrVkResources.
- * Will unrefAndAbandon those resources without deleting the underlying Vk data
+ /** Must be overridden by subclasses that themselves store GrVkResources.
+ * Will unrefAndAbandon those resources without deleting the underlying Vk data
*/
virtual void abandonSubResources() const {}
// To create framebuffers, we first need to create a simple RenderPass that is
-// only used for framebuffer creation. When we actually render we will create
+// only used for framebuffer creation. When we actually render we will create
// RenderPasses as needed that are compatible with the framebuffer.
-const GrVkRenderPass*
+const GrVkRenderPass*
GrVkResourceProvider::findOrCreateCompatibleRenderPass(const GrVkRenderTarget& target) {
for (int i = 0; i < fSimpleRenderPasses.count(); ++i) {
GrVkRenderPass* renderPass = fSimpleRenderPasses[i];
uint8_t GrVkSampler::GenerateKey(const GrTextureParams& params) {
uint8_t key = params.filterMode();
-
+
SkASSERT(params.filterMode() <= 3);
key |= (params.getTileModeX() << 2);
return key;
}
-
imageResource, imageView);
imageResource->unref(gpu);
imageView->unref(gpu);
-
+
return stencil;
}
GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu, const GrSurfaceDesc& desc,
GrGpuResource::LifeCycle lifeCycle,
- VkFormat format,
+ VkFormat format,
const GrVkTextureInfo* info) {
SkASSERT(info);
// Wrapped textures require both image and allocation (because they can be mapped)
SkASSERT(!this->wasDestroyed());
return static_cast<GrVkGpu*>(this->getGpu());
}
-
static GrVkTexture* CreateNewTexture(GrVkGpu*, const GrSurfaceDesc&,
GrGpuResource::LifeCycle,
const GrVkImage::ImageDesc&);
-
+
static GrVkTexture* CreateWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
GrGpuResource::LifeCycle,
VkFormat, const GrVkTextureInfo*);
GrGpuResource::LifeCycle, VkFormat,
const GrVkImage::Resource* texImpl);
- GrVkGpu* getVkGpu() const;
+ GrVkGpu* getVkGpu() const;
void onAbandon() override;
void onRelease() override;
return nullptr;
}
- GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, lifeCycle,
+ GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, lifeCycle,
imageDesc.fFormat, imageRsrc);
// Create() will increment the refCount of the image resource if it succeeds
imageRsrc->unref(gpu);
GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu,
const GrSurfaceDesc& desc,
GrGpuResource::LifeCycle lifeCycle,
- VkFormat format,
+ VkFormat format,
const GrVkTextureInfo* info) {
SkASSERT(info);
// Wrapped textures require both image and allocation (because they can be mapped)
return trt;
}
-
GrGpuResource::LifeCycle,
const GrVkImage::ImageDesc&);
- static GrVkTextureRenderTarget* CreateWrappedTextureRenderTarget(GrVkGpu*,
+ static GrVkTextureRenderTarget* CreateWrappedTextureRenderTarget(GrVkGpu*,
const GrSurfaceDesc&,
GrGpuResource::LifeCycle,
VkFormat,
out->appendf("%s\n};\n", uniformsString.c_str());
}
}
-
bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
#endif
-
SkASSERT(!this->wasDestroyed());
return static_cast<GrVkGpu*>(this->getGpu());
}
-
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2009 The Android Open Source Project
*
-
/*
* Copyright 2010 The Android Open Source Project
*
if (SkKTXFile::is_ktx(bytes)) {
return stream->write(bytes, data->size());
}
-
+
// If it's neither a KTX nor a PKM, then we need to
// get at the actual pixels, so fall through and decompress...
}
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2012 The Android Open Source Project
*
-
/*
* Copyright 2010 The Android Open Source Project
*
} fType;
};
-/** Returns true iff the data seems to be a valid JFIF JPEG image.
+/** Returns true iff the data seems to be a valid JFIF JPEG image.
If so and if info is not nullptr, populate info.
JPEG/JFIF References:
static sk_sp<SkImage> color_filter(const SkImageBitmap& imageBitmap,
SkColorFilter* colorFilter) {
- auto surface =
+ auto surface =
SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(imageBitmap.dimensions()));
SkASSERT(surface);
SkCanvas* canvas = surface->getCanvas();
-
/*
* Copyright 2011 Google Inc.
*
reference to each instantiated class.
*/
class SkPDFFont : public SkPDFDict {
-
+
public:
virtual ~SkPDFFont();
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2010 The Android Open Source Project
*
-
/*
* Copyright 2010 The Android Open Source Project
*
-
/*
* Copyright 2010 The Android Open Source Project
*
once, we want to canonicalize them.
*/
class SkPDFGraphicState final : public SkPDFObject {
-
+
public:
enum SkPDFSMaskMode {
kAlpha_SMaskMode,
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2010 Google Inc.
*
SkObjRef).
*/
class SkPDFStream : public SkPDFDict {
-
+
public:
/** Create a PDF stream. A Length entry is automatically added to the
* stream dictionary.
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
class SkImageEncoder_WIC : public SkImageEncoder {
public:
SkImageEncoder_WIC(Type t) : fType(t) {}
-
+
// DO NOT USE this constructor. This exists only so SkForceLinking can
// link the WIC image encoder.
SkImageEncoder_WIC() {}
-
/*
* Copyright 2006 The Android Open Source Project
*
if (!imageSrc) {
return nullptr;
}
-
+
// Make sure we call CFRelease to free the imageSrc. Since CFRelease actually takes
// a const void*, we must cast the imageSrc to a const void*.
SkAutoTCallVProc<const void, CFRelease> autoImageSrc(imageSrc);
if (!properties) {
return nullptr;
}
-
+
CFNumberRef widthRef = (CFNumberRef) (CFDictionaryGetValue(properties,
kCGImagePropertyPixelWidth));
CFNumberRef heightRef = (CFNumberRef) (CFDictionaryGetValue(properties,
!CFNumberGetValue(heightRef, kCFNumberIntType, &height)) {
return nullptr;
}
-
+
SkAlphaType alphaType = hasAlpha ? kPremul_SkAlphaType : kOpaque_SkAlphaType;
SkImageInfo info = SkImageInfo::Make(width, height, kN32_SkColorType, alphaType);
// FIXME: Support other colorTypes.
return false;
}
-
+
switch (info.alphaType()) {
case kOpaque_SkAlphaType:
if (kOpaque_SkAlphaType != this->getInfo().alphaType()) {
default:
return false;
}
-
+
CGImageRef image = CGImageSourceCreateImageAtIndex((CGImageSourceRef) fImageSrc.get(), 0,
nullptr);
if (!image) {
SkAutoTCallVProc<const void, CFRelease> fImageSrc;
SkAutoTUnref<SkData> fData;
-
+
typedef SkImageGenerator INHERITED;
};
SkTScopedComPtr<IWICImagingFactory> fImagingFactory;
SkTScopedComPtr<IWICBitmapSource> fImageSource;
SkAutoTUnref<SkData> fData;
-
+
typedef SkImageGenerator INHERITED;
};
-
/*
* Copyright 2015 Google Inc.
*
setenv(key, value, 1);
#endif
}
-
-
/*
* Copyright 2015 Google Inc.
*
void sk_setenv(const char* key, const char* value);
#endif
-
-
/*
* Copyright 2015 Google Inc.
*
void* GetProcedureAddress(void* library, const char* functionName);
#endif
-
-
/*
* Copyright 2015 Google Inc.
*
-
/*
* Copyright 2015 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
toString(*src, &ss);
rs.prependf("%s ", ss.c_str());
}
-
+
this->dump(kDrawBitmap_Verb, paint, "drawImageRectToRect(%s %s)",
bs.c_str(), rs.c_str());
}
-
/*
* Copyright 2008 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
if (x < 0 || y < 0 || x > fCols - 1 || y > fRows - 1 || nullptr == cubics) {
return false;
}
-
+
// setup corners and colors
int cornerPos = y * (fCols + 1) + x;
fCornerPts[cornerPos] = cubics[SkPatchUtils::kTopP0_CubicCtrlPts];
fCornerPts[cornerPos + 1] = cubics[SkPatchUtils::kTopP3_CubicCtrlPts];
fCornerPts[cornerPos + (fCols + 1)] = cubics[SkPatchUtils::kBottomP0_CubicCtrlPts];
fCornerPts[cornerPos + (fCols + 1) + 1] = cubics[SkPatchUtils::kBottomP3_CubicCtrlPts];
-
+
// set horizontal control points
int hrzPos = y * (fCols * 2) + (x * 2);
fHrzCtrlPts[hrzPos] = cubics[SkPatchUtils::kTopP1_CubicCtrlPts];
fHrzCtrlPts[hrzPos + 1] = cubics[SkPatchUtils::kTopP2_CubicCtrlPts];
fHrzCtrlPts[hrzPos + (fCols * 2)] = cubics[SkPatchUtils::kBottomP1_CubicCtrlPts];
fHrzCtrlPts[hrzPos + (fCols * 2) + 1] = cubics[SkPatchUtils::kBottomP2_CubicCtrlPts];
-
+
// set vertical control points
int vrtPos = (y*2) * (fCols + 1) + x;
fVrtCtrlPts[vrtPos] = cubics[SkPatchUtils::kLeftP1_CubicCtrlPts];
fVrtCtrlPts[vrtPos + 1] = cubics[SkPatchUtils::kRightP1_CubicCtrlPts];
fVrtCtrlPts[vrtPos + (fCols + 1)] = cubics[SkPatchUtils::kLeftP2_CubicCtrlPts];
fVrtCtrlPts[vrtPos + (fCols + 1) + 1] = cubics[SkPatchUtils::kRightP2_CubicCtrlPts];
-
+
// set optional values (colors and texture coordinates)
if ((fModeFlags & kColors_VertexType) && colors) {
fCornerColors[cornerPos] = colors[0];
fCornerColors[cornerPos + (fCols + 1)] = colors[3];
fCornerColors[cornerPos + (fCols + 1) + 1] = colors[2];
}
-
+
if ((fModeFlags & kTexs_VertexType) && texCoords) {
fTexCoords[cornerPos] = texCoords[0];
fTexCoords[cornerPos + 1] = texCoords[1];
fTexCoords[cornerPos + (fCols + 1)] = texCoords[3];
fTexCoords[cornerPos + (fCols + 1) + 1] = texCoords[2];
}
-
+
return true;
}
bool SkPatchGrid::getPatch(int x, int y, SkPoint cubics[12], SkColor colors[4],
SkPoint texCoords[4]) const {
-
+
if (x < 0 || y < 0 || x > fCols - 1 || y > fRows - 1 || nullptr == cubics) {
return false;
}
-
+
// set the patch by building the array of points and colors with the corresponding values.
int cornerPos = y * (fCols + 1) + x;
cubics[SkPatchUtils::kTopP0_CubicCtrlPts] = fCornerPts[cornerPos];
cubics[SkPatchUtils::kTopP3_CubicCtrlPts] = fCornerPts[cornerPos + 1];
cubics[SkPatchUtils::kBottomP0_CubicCtrlPts] = fCornerPts[cornerPos + (fCols + 1)];
cubics[SkPatchUtils::kBottomP3_CubicCtrlPts] = fCornerPts[cornerPos + (fCols + 1) + 1];
-
+
int hrzPos = y * (fCols * 2) + (x * 2);
cubics[SkPatchUtils::kTopP1_CubicCtrlPts] = fHrzCtrlPts[hrzPos];
cubics[SkPatchUtils::kTopP2_CubicCtrlPts] = fHrzCtrlPts[hrzPos + 1];
cubics[SkPatchUtils::kBottomP1_CubicCtrlPts] = fHrzCtrlPts[hrzPos + (fCols * 2)];
cubics[SkPatchUtils::kBottomP2_CubicCtrlPts] = fHrzCtrlPts[hrzPos + (fCols * 2) + 1];
-
+
int vrtPos = (y*2) * (fCols + 1) + x;
cubics[SkPatchUtils::kLeftP1_CubicCtrlPts] = fVrtCtrlPts[vrtPos];
cubics[SkPatchUtils::kRightP1_CubicCtrlPts] = fVrtCtrlPts[vrtPos + 1];
cubics[SkPatchUtils::kLeftP2_CubicCtrlPts] = fVrtCtrlPts[vrtPos + (fCols + 1)];
cubics[SkPatchUtils::kRightP2_CubicCtrlPts] = fVrtCtrlPts[vrtPos + (fCols + 1) + 1];
-
+
if ((fModeFlags & kColors_VertexType) && colors) {
colors[0] = fCornerColors[cornerPos];
colors[1] = fCornerColors[cornerPos + 1];
colors[3] = fCornerColors[cornerPos + (fCols + 1)];
colors[2] = fCornerColors[cornerPos + (fCols + 1) + 1];
}
-
+
if ((fModeFlags & kTexs_VertexType) && texCoords) {
texCoords[0] = fTexCoords[cornerPos];
texCoords[1] = fTexCoords[cornerPos + 1];
texCoords[3] = fTexCoords[cornerPos + (fCols + 1)];
texCoords[2] = fTexCoords[cornerPos + (fCols + 1) + 1];
}
-
+
return true;
}
memset(fCornerPts, 0, (fRows + 1) * (fCols + 1) * sizeof(SkPoint));
memset(fHrzCtrlPts, 0, (fRows + 1) * fCols * 2 * sizeof(SkPoint));
memset(fVrtCtrlPts, 0, fRows * 2 * (fCols + 1) * sizeof(SkPoint));
-
+
if (fModeFlags & kColors_VertexType) {
fCornerColors = new SkColor[(fRows + 1) * (fCols + 1)];
memset(fCornerColors, 0, (fRows + 1) * (fCols + 1) * sizeof(SkColor));
}
-
+
if (fModeFlags & kTexs_VertexType) {
fTexCoords = new SkPoint[(fRows + 1) * (fCols + 1)];
memset(fTexCoords, 0, (fRows + 1) * (fCols + 1) * sizeof(SkPoint));
int* maxRows = new int[fRows];
memset(maxCols, 0, fCols * sizeof(int));
memset(maxRows, 0, fRows * sizeof(int));
-
+
// Get the maximum level of detail per axis for each row and column
for (int y = 0; y < fRows; y++) {
for (int x = 0; x < fCols; x++) {
#include "SkXfermode.h"
/**
- * Class that represents a grid of patches. Adjacent patches share their corners and a color is
+ * Class that represents a grid of patches. Adjacent patches share their corners and a color is
* specified at each one of them. The colors are bilinearly interpolated across the patch.
*
- * This implementation defines a bidimensional array of patches. There are 3 arrays to store the
+ * This implementation defines a bidimensional array of patches. There are 3 arrays to store the
* control points of the patches to avoid storing repeated data since there are several points
- * shared between adjacent patches.
+ * shared between adjacent patches.
*
* The array fCornerPts stores the corner control points of the patches.
* The array fHrzPts holds the intermidiate control points of the top and bottom curves of a patch.
* \ / \ /
* H8 H9 H10 H11
*
- * When trying to get a patch at a certain position it justs builds it with the corresponding
+ * When trying to get a patch at a certain position it justs builds it with the corresponding
* points.
* When adding a patch it tries to add the points at their corresponding position trying to comply
* with the adjacent points or overwriting them.
- *
+ *
* Based the idea on the SVG2 spec for mesh gradients in which a grid of patches is build as in the
* the following example:
* <meshGradient x="100" y="100">
* </meshGradient>
*/
class SkPatchGrid {
-
+
public:
-
+
enum VertexType {
kNone_VertexType = 0X00,
kColors_VertexType = 0x01,
kTexs_VertexType = 0x02,
kColorsAndTexs_VertexType = 0x03
};
-
+
SkPatchGrid(int rows = 0, int cols = 0, VertexType flags = kNone_VertexType,
SkXfermode* xfer = nullptr);
-
+
~SkPatchGrid();
-
+
/**
- * Add a patch at location (x,y) overwriting the previous patch and shared points so they
+ * Add a patch at location (x,y) overwriting the previous patch and shared points so they
* mantain C0 connectivity.
* The control points must be passed in a clockwise order starting at the top left corner.
- * The colors and texCoords are the values at the corners of the patch which will be bilerp
+ * The colors and texCoords are the values at the corners of the patch which will be bilerp
* across it, they must also be in counterclockwise order starting at the top left corner.
*/
bool setPatch(int x, int y, const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4]);
-
+
/**
* Get patch at location (x,y). If cubics, colors or texCoords is not nullptr it sets patch's
* array with its corresponding values.
- * The function returns false if the cubics parameter is nullptr or if the (x,y) coordinates are
+ * The function returns false if the cubics parameter is nullptr or if the (x,y) coordinates are
* not within the range of the grid.
*/
bool getPatch(int x, int y, SkPoint cubics[12], SkColor colors[4], SkPoint texCoords[4]) const;
-
+
/**
* Resets the grid of patches to contain rows and cols of patches.
*/
void reset(int rows, int cols, VertexType flags, SkXfermode* xMode);
-
+
/**
- * Draws the grid of patches. The patches are drawn starting at patch (0,0) drawing columns, so
- * for a 2x2 grid the order would be (0,0)->(0,1)->(1,0)->(1,1). The order follows the order
+ * Draws the grid of patches. The patches are drawn starting at patch (0,0) drawing columns, so
+ * for a 2x2 grid the order would be (0,0)->(0,1)->(1,0)->(1,1). The order follows the order
* of the parametric coordinates of the coons patch.
*/
void draw(SkCanvas* canvas, SkPaint& paint);
-
+
/**
* Get the dimensions of the grid of patches.
*/
SkISize getDimensions() const {
return SkISize::Make(fCols, fRows);
}
-
+
private:
int fRows, fCols;
VertexType fModeFlags;
*/
class FwDCubicEvaluator {
-
+
public:
-
+
/**
* Receives the 4 control points of the cubic bezier.
*/
-
+
explicit FwDCubicEvaluator(const SkPoint points[4])
: fCoefs(points) {
memcpy(fPoints, points, 4 * sizeof(SkPoint));
-
+
this->restart(1);
}
-
+
/**
* Restarts the forward differences evaluator to the first value of t = 0.
*/
fFwDiff[1] = to_point(fCoefs.fA * h3 + fCoefs.fB * h2 + fCoefs.fC * h);
fFwDiff[0] = to_point(fCoefs.fD);
}
-
+
/**
* Check if the evaluator is still within the range of 0<=t<=1
*/
bool done() const {
return fCurrent > fMax;
}
-
+
/**
* Call next to obtain the SkPoint sampled and move to the next one.
*/
fCurrent++;
return point;
}
-
+
const SkPoint* getCtrlPoints() const {
return fPoints;
}
-
+
private:
SkCubicCoeff fCoefs;
int fMax, fCurrent, fDivisions;
}
SkISize SkPatchUtils::GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix) {
-
+
// Approximate length of each cubic.
SkPoint pts[kNumPtsCubic];
SkPatchUtils::getTopCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar topLength = approx_arc_length(pts, kNumPtsCubic);
-
+
SkPatchUtils::getBottomCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar bottomLength = approx_arc_length(pts, kNumPtsCubic);
-
+
SkPatchUtils::getLeftCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar leftLength = approx_arc_length(pts, kNumPtsCubic);
-
+
SkPatchUtils::getRightCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar rightLength = approx_arc_length(pts, kNumPtsCubic);
-
+
// Level of detail per axis, based on the larger side between top and bottom or left and right
int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitionSize);
int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitionSize);
-
+
return SkISize::Make(SkMax32(8, lodX), SkMax32(8, lodY));
}
}
data->fColors = new uint32_t[data->fVertexCount];
}
-
+
// if texture coordinates are not null then create array for them
if (texCoords) {
data->fTexCoords = new SkPoint[data->fVertexCount];
}
-
+
SkPoint pts[kNumPtsCubic];
SkPatchUtils::getBottomCubic(cubics, pts);
FwDCubicEvaluator fBottom(pts);
FwDCubicEvaluator fLeft(pts);
SkPatchUtils::getRightCubic(cubics, pts);
FwDCubicEvaluator fRight(pts);
-
+
fBottom.restart(lodX);
fTop.restart(lodX);
-
+
SkScalar u = 0.0f;
int stride = lodY + 1;
for (int x = 0; x <= lodX; x++) {
SkScalar v = 0.f;
for (int y = 0; y <= lodY; y++) {
int dataIndex = x * (lodY + 1) + y;
-
+
SkPoint left = fLeft.next(), right = fRight.next();
-
+
SkPoint s0 = SkPoint::Make((1.0f - v) * top.x() + v * bottom.x(),
(1.0f - v) * top.y() + v * bottom.y());
SkPoint s1 = SkPoint::Make((1.0f - u) * left.x() + u * right.x(),
+ v * ((1.0f - u) * fBottom.getCtrlPoints()[0].y()
+ u * fBottom.getCtrlPoints()[3].y()));
data->fPoints[dataIndex] = s0 + s1 - s2;
-
+
if (colors) {
uint8_t a = uint8_t(bilerp(u, v,
SkScalar(SkColorGetA(colorsPM[kTopLeft_Corner])),
SkScalar(SkColorGetB(colorsPM[kBottomRight_Corner]))));
data->fColors[dataIndex] = SkPackARGB32(a,r,g,b);
}
-
+
if (texCoords) {
data->fTexCoords[dataIndex] = SkPoint::Make(
bilerp(u, v, texCoords[kTopLeft_Corner].x(),
texCoords[kTopRight_Corner].y(),
texCoords[kBottomLeft_Corner].y(),
texCoords[kBottomRight_Corner].y()));
-
+
}
-
+
if(x < lodX && y < lodY) {
int i = 6 * (x * lodY + y);
data->fIndices[i] = x * stride + y;
#include "SkMatrix.h"
class SK_API SkPatchUtils {
-
+
public:
/**
* Structure that holds the vertex data related to the tessellation of a patch. It is passed
SkPoint* fTexCoords;
uint32_t* fColors;
uint16_t* fIndices;
-
+
VertexData()
: fVertexCount(0)
, fIndexCount(0)
, fTexCoords(nullptr)
, fColors(nullptr)
, fIndices(nullptr) { }
-
+
~VertexData() {
delete[] fPoints;
delete[] fTexCoords;
delete[] fIndices;
}
};
-
+
// Enums for control points based on the order specified in the constructor (clockwise).
enum CubicCtrlPts {
kTopP0_CubicCtrlPts = 0,
kTopP1_CubicCtrlPts = 1,
kTopP2_CubicCtrlPts = 2,
kTopP3_CubicCtrlPts = 3,
-
+
kRightP0_CubicCtrlPts = 3,
kRightP1_CubicCtrlPts = 4,
kRightP2_CubicCtrlPts = 5,
kRightP3_CubicCtrlPts = 6,
-
+
kBottomP0_CubicCtrlPts = 9,
kBottomP1_CubicCtrlPts = 8,
kBottomP2_CubicCtrlPts = 7,
kBottomP3_CubicCtrlPts = 6,
-
+
kLeftP0_CubicCtrlPts = 0,
kLeftP1_CubicCtrlPts = 11,
kLeftP2_CubicCtrlPts = 10,
kLeftP3_CubicCtrlPts = 9,
};
-
+
// Enum for corner also clockwise.
enum Corner {
kTopLeft_Corner = 0,
kBottomRight_Corner,
kBottomLeft_Corner
};
-
+
enum {
kNumCtrlPts = 12,
kNumCorners = 4,
kNumPtsCubic = 4
};
-
+
/**
- * Method that calculates a level of detail (number of subdivisions) for a patch in both axis.
+ * Method that calculates a level of detail (number of subdivisions) for a patch in both axis.
*/
static SkISize GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix);
-
+
/**
* Get the points corresponding to the top cubic of cubics.
*/
static void getTopCubic(const SkPoint cubics[12], SkPoint points[4]);
-
+
/**
* Get the points corresponding to the bottom cubic of cubics.
*/
static void getBottomCubic(const SkPoint cubics[12], SkPoint points[4]);
-
+
/**
* Get the points corresponding to the left cubic of cubics.
*/
static void getLeftCubic(const SkPoint cubics[12], SkPoint points[4]);
-
+
/**
* Get the points corresponding to the right cubic of cubics.
*/
static void getRightCubic(const SkPoint cubics[12], SkPoint points[4]);
-
+
/**
* Function that evaluates the coons patch interpolation.
* data refers to the pointer of the PatchData struct in which the tessellation data is set.
* cubics refers to the points of the cubics.
* lod refers the level of detail for each axis.
* colors refers to the corner colors that will be bilerp across the patch (optional parameter)
- * texCoords refers to the corner texture coordinates that will be bilerp across the patch
+ * texCoords refers to the corner texture coordinates that will be bilerp across the patch
(optional parameter)
*/
static bool getVertexData(SkPatchUtils::VertexData* data, const SkPoint cubics[12],
}
return (SkTextBlob*)visitor.fBuilder.build();
}
-
// - Single plane
// - Low-precision index values
// - Index range 0-7 (three bits per index)
- // 2. Partitions: 0b00
+ // 2. Partitions: 0b00
// - One partition
// 3. Color Endpoint Mode: 0b0000
// - Direct luminance -- e0=(v0,v0,v0,0xFF); e1=(v1,v1,v1,0xFF);
//
////////////////////////////////////////////////////////////////////////////////
-// Enable this to assert whenever a decoded block has invalid ASTC values. Otherwise,
+// Enable this to assert whenever a decoded block has invalid ASTC values. Otherwise,
// each invalid block will result in a disgusting magenta color.
#define ASSERT_ASTC_DECODE_ERROR 0
SkASSERT(nBits > (64 - from));
const int nLow = 64 - from;
const int nHigh = nBits - nLow;
- result =
+ result =
((block.fLow >> from) & ((1ULL << nLow) - 1)) |
((block.fHigh & ((1ULL << nHigh) - 1)) << nLow);
}
v4 = v[4];
v5 = v[5];
}
-
+
endpoints[0] = SkColorSetARGB(v4,
(v[0]*v[3]) >> 8,
(v[1]*v[3]) >> 8,
case kLDR_LuminanceAlpha_Direct_ColorEndpointMode: {
const int* v = colorValues;
-
+
endpoints[i][0] = SkColorSetARGB(v[2], v[0], v[0], v[0]);
endpoints[i][1] = SkColorSetARGB(v[3], v[1], v[1], v[1]);
bit_transfer_signed(&v1, &v0);
bit_transfer_signed(&v3, &v2);
-
+
endpoints[i][0] = SkColorSetARGB(v2, v0, v0, v0);
endpoints[i][1] = SkColorSetARGB(
clamp_byte(v3+v2),
this->decodeDualPlane(dualPlaneBitLoc);
return;
- }
+ }
// If we have more than one partition, then we need to make
// room for the partition index.
this->decodeDualPlane(dualPlaneBitLoc);
return;
- }
+ }
// Move the dual plane selector bits down based on how many
// partitions the block contains.
// Decodes the block mode. This function determines whether or not we use
// dual plane encoding, the size of the texel weight grid, and the number of
- // bits, trits and quints that are used to encode it. For more information,
+ // bits, trits and quints that are used to encode it. For more information,
// see section C.2.10 of the ASTC spec.
//
// For 2D blocks, the Block Mode field is laid out as follows:
// // most likely be implementation dependent. The mask variable will have
// // 0xFF in positions where the block should be updated and 0 in positions
// // where it shouldn't. src contains an uncompressed buffer of pixels.
-// static void UpdateBlock(uint8_t* dst, const uint8_t* src, int srcRowBytes,
+// static void UpdateBlock(uint8_t* dst, const uint8_t* src, int srcRowBytes,
// const uint8_t* mask);
#endif
// };
SkTCompressedAlphaBlitter(int width, int height, void *compressedBuffer)
// 0x7FFE is one minus the largest positive 16-bit int. We use it for
// debugging to make sure that we're properly setting the nextX distance
- // in flushRuns().
+ // in flushRuns().
#ifdef SK_DEBUG
: fCalledOnceWithNonzeroY(false)
, fBlitMaskCalled(false),
this->flushRuns();
}
}
-
+
// Blit a vertical run of pixels with a constant alpha value.
void blitV(int x, int y, int height, SkAlpha alpha) override {
// This function is currently not implemented. It is not explicitly
// Make sure that we're only ever bracketing calls to blitAntiH.
SkASSERT((0 == y) || (!fCalledOnceWithNonzeroY && (fCalledOnceWithNonzeroY = true)));
-
+
#if !(PEDANTIC_BLIT_RECT)
for (int i = 0; i < height; ++i) {
const SkAlpha kFullAlpha = 0xFF;
const int yoff = y - startBlockY;
SkASSERT((yoff + height) <= BlockDim);
-
+
for (int j = 0; j < height; ++j) {
memset(mask + (j + yoff)*BlockDim + xoff, 0xFF, width);
}
// -----------------------------------------------------------------------
// ... | | | | | ----> fBufferedRuns[3]
// -----------------------------------------------------------------------
- //
+ //
// curX -- the macro X value that we've gotten to.
// c[BlockDim] -- the buffers that represent the columns of the current block
// that we're operating on
// This function is used by both R11 EAC and LATC to compress 4x4 blocks
// of 8-bit alpha into 64-bit values that comprise the compressed data.
-// For both formats, we need to make sure that the dimensions of the
+// For both formats, we need to make sure that the dimensions of the
// src pixels are divisible by 4, and copy 4x4 blocks one at a time
// for compression.
static bool compress_4x4_a8_to_64bit(uint8_t* dst, const uint8_t* src,
if (nonExtremalPixels == nUniquePixels) {
// This is really just for correctness, in all of my tests we
// never take this step. We don't lose too much perf here because
- // most of the processing in this function is worth it for the
+ // most of the processing in this function is worth it for the
// 1 == nUniquePixels optimization.
return compress_latc_block_bb(pixels);
} else {
// Converts each 8-bit byte in the integer into an LATC index, and then packs
// the indices into the low 12 bits of the integer.
static inline uint32_t convert_index(uint32_t x) {
- // Since the palette is
+ // Since the palette is
// 255, 0, 219, 182, 146, 109, 73, 36
// we need to map the high three bits of each byte in the integer
// from
// Mask out high bits:
// 9 7 6 5 4 3 2 0 --> 1 7 6 5 4 3 2 0
x &= 0x07070707;
-
+
return pack_index(x);
}
//
// this gives the following formula:
// clamp[0, 2047](0*8+4+(-3)*2*8) = 0
- //
+ //
// Furthermore, it is impervious to endianness:
// 0x0020000000002000ULL
// Will produce one pixel with index 2, which gives:
// Fully opaque? We know this encoding too...
case 255:
-
+
// -1 produces the following:
// basw_cw: 255
// mod: 15, palette: {-3, -5, -7, -9, 2, 4, 6, 8}
x = swap_shift<36>(x, 0xFC0ULL);
// x: 00 00 00 00 00 00 00 00 a e i m d h l p b f j n c g k o
-
+
x = (x & (0xFFFULL << 36)) | ((x & 0xFFFFFFULL) << 12) | ((x >> 24) & 0xFFFULL);
#endif
// the least significant 12 bits of the resulting integer.
static inline uint32_t pack_indices_vertical(uint32_t x) {
#if defined (SK_CPU_BENDIAN)
- return
+ return
(x & 7) |
((x >> 5) & (7 << 3)) |
((x >> 10) & (7 << 6)) |
((x >> 15) & (7 << 9));
#else
- return
+ return
((x >> 24) & 7) |
((x >> 13) & (7 << 3)) |
((x >> 2) & (7 << 6)) |
src += 8;
}
dst += 4 * dstRowBytes;
- }
+ }
}
} // namespace SkTextureCompressor
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2010 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
-
/*
* Copyright 2011 Google Inc.
*
fCommandBuffer = SkCommandBufferGLContext::Create((HWND)fHWND, msaaSampleCount);
if (!fCommandBuffer)
return false;
-
+
SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface());
if (intf) {
COMMAND_BUFFER_GL_CALL(intf, ClearStencil(0));
WindowRect.left = 0;
WindowRect.right = kWidth;
WindowRect.top = 0;
- WindowRect.bottom = kHeight;
+ WindowRect.bottom = kHeight;
ShowCursor(FALSE);
AdjustWindowRectEx(&WindowRect, WS_POPUP, FALSE, WS_EX_APPWINDOW);
HWND fsHWND = CreateWindowEx(
-
/*
* Copyright 2011 Google Inc.
*
}
return 0;
}
-
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2006 The Android Open Source Project
*
-
/*
* Copyright 2011 Google Inc.
*
// This rect should intersect the clip, but slice-out all of the "soft" parts,
// leaving just a rect.
const SkIRect ir = SkIRect::MakeLTRB(10, -10, 50, 90);
-
+
clip.op(ir, SkRegion::kIntersect_Op);
REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeLTRB(10, 0, 50, 90));
-
/*
* Copyright 2011 Google Inc.
*
gRec[i].fRequestedDstSize.height());
bool success = srcBM.readPixels(dstInfo, dstPixels, rowBytes,
gRec[i].fRequestedSrcLoc.x(), gRec[i].fRequestedSrcLoc.y());
-
+
REPORTER_ASSERT(reporter, gRec[i].fExpectedSuccess == success);
if (success) {
const SkIRect srcR = gRec[i].fExpectedSrcR;
refData = (kRGBA_8888_SkColorType == dstBmp.colorType()) ? kData : swizData;
#elif defined(SK_PMCOLOR_IS_BGRA)
refData = (kBGRA_8888_SkColorType == dstBmp.colorType()) ? kData : swizData;
-#else
+#else
#error "PM Color must be BGRA or RGBA to use GPU backend."
#endif
bool foundError = false;
#if SK_SUPPORT_GPU
-// This exercises the problem discovered in crbug.com/570232. The return value from
+// This exercises the problem discovered in crbug.com/570232. The return value from
// SkBlurMask::BoxBlur wasn't being checked in SkBlurMaskFilter.cpp::GrRRectBlurEffect::Create
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SmallBoxBlurBug, reporter, ctx) {
static SkCachedData* test_locking(skiatest::Reporter* reporter,
size_t size, SkDiscardableMemoryPool* pool) {
SkCachedData* data = make_data(size, pool);
-
+
memset(data->writable_data(), 0x80, size); // just to use writable_data()
check_data(reporter, data, 1, kNotInCache, kLocked);
-
+
data->ref();
check_data(reporter, data, 2, kNotInCache, kLocked);
data->unref();
check_data(reporter, data, 1, kNotInCache, kLocked);
-
+
data->attachToCacheAndRef();
check_data(reporter, data, 2, kInCache, kLocked);
-
+
data->unref();
check_data(reporter, data, 1, kInCache, kUnlocked);
-
+
data->ref();
check_data(reporter, data, 2, kInCache, kLocked);
data->detachFromCacheAndUnref();
}
}
-
n = canvas.saveLayer(nullptr, nullptr);
REPORTER_ASSERT(reporter, 2 == n);
REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount());
-
+
canvas.restore();
REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount());
canvas.restore();
-
/*
* Copyright 2015 Google Inc.
*
return;
}
SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
-
+
// This should return kSuccess because kIndex8 is supported.
SkPMColor colorStorage[256];
int colorCount;
matrix[1] = 0.7152f - 0.7152f * amount;
matrix[2] = 1.f - (matrix[0] + matrix[1]);
matrix[3] = matrix[4] = 0.f;
-
+
matrix[5] = 0.2126f - 0.2126f * amount;
matrix[6] = 0.7152f + 0.2848f * amount;
matrix[7] = 1.f - (matrix[5] + matrix[6]);
matrix[8] = matrix[9] = 0.f;
-
+
matrix[10] = 0.2126f - 0.2126f * amount;
matrix[11] = 0.7152f - 0.7152f * amount;
matrix[12] = 1.f - (matrix[10] + matrix[11]);
matrix[13] = matrix[14] = 0.f;
-
+
matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0.f;
matrix[18] = 1.f;
}
static void check_alphabet_buffer(skiatest::Reporter* reporter, const SkROBuffer* reader) {
size_t size = reader->size();
REPORTER_ASSERT(reporter, size % 26 == 0);
-
+
SkAutoTMalloc<char> storage(size);
SkROBuffer::Iter iter(reader);
size_t offset = 0;
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FloatingPointTextureTest, reporter, context) {
runFPTest<float>(reporter, context, FLT_MIN, FLT_MAX, FLT_EPSILON,
- kMaxIntegerRepresentableInSPFloatingPoint,
+ kMaxIntegerRepresentableInSPFloatingPoint,
FP_CONTROL_ARRAY_SIZE, kRGBA_float_GrPixelConfig);
}
SkDebugf("---- Resource files missing for FontConfigParser test\n");
}
}
-
-
/*
* Copyright 2011 Google Inc.
*
SkEvalQuadAt(pts, t, &r0);
SkPoint r1 = SkEvalQuadAt(pts, t);
check_pairs(reporter, i, t, "quad-pos", r0.fX, r0.fY, r1.fX, r1.fY);
-
+
SkVector v0;
SkEvalQuadAt(pts, t, nullptr, &v0);
SkVector v1 = SkEvalQuadTangentAt(pts, t);
-
/*
* Copyright 2013 Google Inc.
*
-
/*
* Copyright 2013 Google Inc.
*
}
static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
GrPipelineOptimizations optimizations;
- optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
+ optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
false);
- optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
+ optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
true);
SkASSERT(!optimizations.fColorPOI.isOpaque());
GrPipelineOptimizations optimizations;
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(229, 0, 154, 0),
kR_GrColorComponentFlag | kB_GrColorComponentFlag, false);
- optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
+ optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
kRGBA_GrColorComponentFlags, true);
SkASSERT(!optimizations.fColorPOI.isOpaque());
static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
GrPipelineOptimizations optimizations;
- optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
+ optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
kA_GrColorComponentFlag, false);
- optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
+ optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
true);
SkASSERT(optimizations.fColorPOI.isOpaque());
GrPipelineOptimizations optimizations;
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0, 82, 0, 255),
kG_GrColorComponentFlag | kA_GrColorComponentFlag, false);
- optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
+ optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
kRGBA_GrColorComponentFlags, true);
SkASSERT(optimizations.fColorPOI.isOpaque());
TestLCDCoverageBatch() : INHERITED(ClassID()) {}
private:
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
color->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221));
for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) {
GrPipelineOptimizations optimizations;
- optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags[c],
+ optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags[c],
false);
for (int f = 0; f <= 1; f++) {
if (!f) {
- optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0,
+ optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0,
kNone_GrColorComponentFlags, true);
} else {
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
}
#endif
-
for (int i = 0; i < 100; ++i) {
if (data) {
- REPORTER_ASSERT(reporter, i == *GrNEW_APPEND_TO_RECORDER(recorder,
+ REPORTER_ASSERT(reporter, i == *GrNEW_APPEND_TO_RECORDER(recorder,
IntWrapper, (i)));
} else {
REPORTER_ASSERT(reporter, i ==
SkMatrix matrix;
matrix.setAffine(affine);
c.concat(matrix);
-
+
c.drawPaint(paint);
}
static bool Visitor(const SkResourceCache::Rec& baseRec, void* context) {
const TestingRec& rec = static_cast<const TestingRec&>(baseRec);
intptr_t* result = (intptr_t*)context;
-
+
*result = rec.fValue;
return true;
}
test_explicit_purging(reporter, fullImg, subsetImg);
}
#endif
-
-
/*
* Copyright 2013 Google Inc.
*
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
SkBudgeted::kNo,
- SkImageInfo::MakeN32Premul(widthHeight,
+ SkImageInfo::MakeN32Premul(widthHeight,
widthHeight),
0,
&props,
SkMatrix m;
m.reset();
assert9(reporter, m, 1, 0, 0, 0, 1, 0, 0, 0, 1);
-
+
m.setScale(2, 3);
assert9(reporter, m, 2, 0, 0, 0, 3, 0, 0, 0, 1);
-
+
m.postTranslate(4, 5);
assert9(reporter, m, 2, 0, 4, 0, 3, 5, 0, 0, 1);
REPORTER_ASSERT(reporter, alloc->contains(ptr));
return ptr;
}
-
+
static void test_chunkalloc(skiatest::Reporter* reporter) {
static const size_t kMin = 1024;
SkChunkAlloc alloc(kMin);
paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
REPORTER_ASSERT(r, !paint.nothingToDraw());
}
-
SkPath path2(path);
testPathOp(reporter, path1, path2, (SkPathOp) 2, filename);
}
-// ../../third_party/tcmalloc/chromium/src/free_list.h:118] Memory corruption detected.
+// ../../third_party/tcmalloc/chromium/src/free_list.h:118] Memory corruption detected.
static void battleOp13(skiatest::Reporter* reporter, const char* filename) {
SkPath path;
}
}
setupOne(reporter, col, row, rot, trial);
- skipTest:
+ skipTest:
;
}
}
path.moveTo(306.588f, -227.984f);
path.conicTo(212.465f, -262.242f, 95.5512f, 58.9764f, 0.707107f);
path.lineTo(306.588f, -227.984f);
-path.close();
+path.close();
testSimplify(reporter, path, __FUNCTION__);
}
manually compute the intersection of a pair of circles and see if the conic intersection matches
given two circles
construct a line connecting their centers
-
+
*/
static const SkDConic testSet[] = {
{{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}, 0.707107008f},
{{{{5.1114602088928223, 628.77813720703125},
- {10.834027290344238, 988.964111328125},
+ {10.834027290344238, 988.964111328125},
{163.40835571289062, 988.964111328125}}}, 0.72944212f},
- {{{{163.40835571289062, 988.964111328125},
- {5, 988.964111328125},
+ {{{{163.40835571289062, 988.964111328125},
+ {5, 988.964111328125},
{5, 614.7423095703125}}}, 0.707106769f},
{{{{11.17222976684570312, -8.103978157043457031},
static void writeDPng(const SkDConic& dC, const char* name) {
const int scale = 5;
- SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
- {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
+ SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
+ {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
{dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight };
SkBitmap bitmap;
SkDRect bounds;
};
const SkDConic* frames[] = {
- frame0, frame1, frame2, frame3, frame4, frame5, frame6
+ frame0, frame1, frame2, frame3, frame4, frame5, frame6
};
const int frameSizes[] = { (int) SK_ARRAY_COUNT(frame0), (int) SK_ARRAY_COUNT(frame1),
int frameSize = frameSizes[index];
for (int fIndex = 0; fIndex < frameSize; ++fIndex) {
const SkDConic& dC = frames[index][fIndex];
- SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
- {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
+ SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
+ {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
{dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight };
SkDRect dBounds;
dBounds.setBounds(dConic);
canvas.drawColor(SK_ColorWHITE);
for (int fIndex = 0; fIndex < frameSize; ++fIndex) {
const SkDConic& dC = frames[index][fIndex];
- SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
- {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
+ SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
+ {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
{dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight };
SkPath path;
path.moveTo(dConic.fPts[0].asSkPoint());
{
{{{{30.6499996,25.6499996}, {30.6499996,20.6499996}, {25.6499996,20.6499996}}}, 0.707107008f},
{{{25.6499996,20.6499996}, {45.6500015,20.6499996}}},
- 1,
+ 1,
{{25.6499996,20.6499996}, {0,0}}
},
};
const SkDLine& line = lineConicTests[index].line;
SkASSERT(ValidLine(line));
SkReduceOrder reducer;
- SkPoint pts[3] = { conic.fPts.fPts[0].asSkPoint(), conic.fPts.fPts[1].asSkPoint(),
+ SkPoint pts[3] = { conic.fPts.fPts[0].asSkPoint(), conic.fPts.fPts[1].asSkPoint(),
conic.fPts.fPts[2].asSkPoint() };
SkPoint reduced[3];
SkPath::Verb order1 = SkReduceOrder::Conic(pts, conic.fWeight, reduced);
static void complex_to_quads(const SkPoint pts[], SkPath* path) {
SkScalar loopT;
if (SkDCubic::ComplexBreak(pts, &loopT)) {
- SkPoint cubicPair[7];
+ SkPoint cubicPair[7];
SkChopCubicAt(pts, cubicPair, loopT);
SkDCubic c1, c2;
c1.set(cubicPair);
dumpID();
SkDebugf(" bounds=(%1.9g,%1.9g, %1.9g,%1.9g) boundsMax=%1.9g%s\n",
fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom, fBoundsMax,
- fCollapsed ? " collapsed" : "");
+ fCollapsed ? " collapsed" : "");
}
template<typename TCurve, typename OppCurve>
lo = hi;
}
break;
- }
+ }
case SkPath::kClose_Verb:
simplePath->close();
break;
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dot, SK_ScalarRoot2Over2));
}
-static void test_length(skiatest::Reporter* reporter,
+static void test_length(skiatest::Reporter* reporter,
SkScalar x, SkScalar y, SkScalar z, SkScalar expectedLen) {
SkPoint3 point = SkPoint3::Make(x, y, z);
SkScalar fX;
SkScalar fY;
SkScalar fZ;
- SkScalar fLength;
+ SkScalar fLength;
} gRec[] = {
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.3f, 0.4f, 0.5f, SK_ScalarRoot2Over2 },
-
/*
* Copyright 2011 Google Inc.
*
test_premul_alpha_roundtrip(reporter, device);
}
#endif
-
-
/*
* Copyright 2016 Google Inc.
*
}
return SkPremultiplyARGBInline(a, r, g, b);
}
-
+
static SkPMColor get_dst_bmp_init_color(int x, int y, int w) {
int n = y * w + x;
if (doReplace) {
REPORTER_ASSERT(r, 0 == numLayers);
} else {
- REPORTER_ASSERT(r, 1 == numLayers);
+ REPORTER_ASSERT(r, 1 == numLayers);
}
}
REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>()));
}
}
-
}
}
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RectangleTexture, reporter, context, glContext) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RectangleTexture, reporter, context, glContext) {
static const int kWidth = 13;
static const int kHeight = 13;
class TestRC : public SkRefCnt {
public:
-
+
private:
typedef SkRefCnt INHERITED;
};
}
}
-// Test out the case where an oval already off in space is translated/scaled
+// Test out the case where an oval already off in space is translated/scaled
// further off into space - yielding numerical issues when the rect & radii
// are transformed separatly
// BUG=skia:2696
SkScalar halfHeight = SkScalarHalf(dst.height());
for (int i = 0; i < 4; ++i) {
- REPORTER_ASSERT(reporter,
+ REPORTER_ASSERT(reporter,
SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, halfWidth));
- REPORTER_ASSERT(reporter,
+ REPORTER_ASSERT(reporter,
SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, halfHeight));
}
}
static SkBitmap draw_picture(SkPicture& picture) {
SkBitmap bitmap;
- bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()),
+ bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()),
SkScalarCeilToInt(picture.cullRect().height()));
SkCanvas canvas(bitmap);
picture.playback(&canvas);
// Paint some text.
SkPictureRecorder recorder;
SkIRect canvasRect = SkIRect::MakeWH(kBitmapSize, kBitmapSize);
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width()),
- SkIntToScalar(canvasRect.height()),
+ SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width()),
+ SkIntToScalar(canvasRect.height()),
nullptr, 0);
canvas->drawColor(SK_ColorWHITE);
canvas->drawText(text, 2, 24, 32, paint);
DEF_TEST(Annotations, reporter) {
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(SkRect::MakeWH(100, 100));
-
+
const char* str0 = "rect-with-url";
const SkRect r0 = SkRect::MakeWH(10, 10);
SkAutoTUnref<SkData> d0(SkData::NewWithCString(str0));
SkAnnotateRectWithURL(recordingCanvas, r0, d0);
-
+
const char* str1 = "named-destination";
const SkRect r1 = SkRect::MakeXYWH(5, 5, 0, 0); // collapsed to a point
SkAutoTUnref<SkData> d1(SkData::NewWithCString(str1));
SkAnnotateNamedDestination(recordingCanvas, {r1.x(), r1.y()}, d1);
-
+
const char* str2 = "link-to-destination";
const SkRect r2 = SkRect::MakeXYWH(20, 20, 5, 6);
SkAutoTUnref<SkData> d2(SkData::NewWithCString(str2));
TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs));
canvas.drawPicture(pict1);
}
-
p.setAntiAlias(false);
temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad),
- SkIntToScalar(kSmallerSize), SkIntToScalar(kSmallerSize)),
+ SkIntToScalar(kSmallerSize), SkIntToScalar(kSmallerSize)),
p);
return bm;
{
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu(
- nullptr, subset,
+ nullptr, subset,
kNeedNewImageUniqueID_SpecialImage,
texture));
test_image(subSImg1, reporter, false, true, kPad, kFullSize);
}
}
-// This test uses file system operations that don't work out of the
-// box on iOS. It's likely that we don't need them on iOS. Ignoring for now.
-// TODO(stephana): Re-evaluate if we need this in the future.
+// This test uses file system operations that don't work out of the
+// box on iOS. It's likely that we don't need them on iOS. Ignoring for now.
+// TODO(stephana): Re-evaluate if we need this in the future.
#ifndef SK_BUILD_FOR_IOS
DEF_TEST(StreamPeek, reporter) {
// Test a memory stream.
SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream());
REPORTER_ASSERT(r, nullptr == asset->getMemoryBase());
}
-
#include "SkTDArray.h"
/* Given a path, generate a the desired minimal subset of the original.
-
+
This does a binary divide-and-conquer on the path, first splitting by
contours, and then by verbs. The caller passes whether the previous subset
behaved the same as the original. If not, the subset() call restores the
prior state before returning a new subset.
-
+
If a path fails a local test, this reduces the data to the
minimal set that fails using a pattern like:
-
+
bool testFailed = true;
SkPath minimal;
SubsetContours subsetContours(testPath);
-
/*
* Copyright 2011 Google Inc.
*
REPORTER_ASSERT(reporter, glContext);
}
#endif
-
SkAutoPixmapStorage pixmap;
pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight));
// leaving the pixels uninitialized, as they don't affect the test...
-
+
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) {
const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor::Format>(i);
if (!compresses_a8(fmt)) {
for (size_t i = 0; i < SK_ARRAY_COUNT(tests); ++i) {
SkTDArray<sk_tool_utils::TopoTestNode*> graph;
-
+
(tests[i].fCreate)(&graph);
sk_tool_utils::TopoTestNode::Shuffle(&graph, &rand);
sk_tool_utils::TopoTestNode::DeallocNodes(&graph);
}
}
-
class RefClass : public SkRefCnt {
public:
-
+
RefClass(int n) : fN(n) {}
int get() const { return fN; }
-
/*
* Copyright 2015 Google Inc.
*
-
/*
* Copyright 2015 Google Inc.
*
-
/*
* Copyright 2016 Google Inc.
*
SkWriter32::WriteDataSize(data0),
SkWriter32::WriteDataSize(data1),
};
-
+
SkSWriter32<1000> writer;
size_t sizeWritten = 0;
writer.writeData(nullptr);
sizeWritten += sizes[0];
REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
-
+
writer.writeData(data0);
sizeWritten += sizes[1];
REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size());
REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1));
REPORTER_ASSERT(reporter, 0 == d2->size());
-
+
REPORTER_ASSERT(reporter, reader.offset() == sizeWritten);
REPORTER_ASSERT(reporter, reader.eof());
}
-
/*
* Copyright 2014 Google Inc.
*
}
}
}
-
+
uint32_t imgSizePadded = (imgSize + 3) & ~3;
buf += imgSizePadded;
bytesLeft -= imgSizePadded;
if (!stream->write(&kKTX_ENDIANNESS_CODE, 4)) {
return false;
}
-
+
Header hdr;
hdr.fGLType = 0;
hdr.fGLTypeSize = 1;
rowPtr += bitmap.rowBytes();
}
}
-
+
return true;
}
-
/*
* Copyright 2014 Google Inc.
*
/* Make sure that this isn't included by Visual C++ */
#ifdef _MSC_VER
-#error You should run hg revert SDL_config.h
+#error You should run hg revert SDL_config.h
#endif
/* C language features */
/* Make sure that this isn't included by Visual C++ */
#ifdef _MSC_VER
-#error You should run hg revert SDL_config.h
+#error You should run hg revert SDL_config.h
#endif
/* C language features */
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
#endif
-
const char *what);
#endif
-
SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
return new VisualBench(hwnd, argc, argv);
}
-
canvas->drawRect(rect, paint);
// draw the 16ms line
paint.setColor(SK_ColorLTGRAY);
- canvas->drawLine(rect.fLeft, rect.fBottom - kBaseMS*kPixelPerMS,
+ canvas->drawLine(rect.fLeft, rect.fBottom - kBaseMS*kPixelPerMS,
rect.fRight, rect.fBottom - kBaseMS*kPixelPerMS, paint);
paint.setColor(SK_ColorRED);
paint.setStyle(SkPaint::kStroke_Style);
int i = fCurrentMeasurement;
do {
int endY = startY - (int)(fMeasurements[i] * kPixelPerMS + 0.5); // round to nearest value
- canvas->drawLine(SkIntToScalar(x), SkIntToScalar(startY),
+ canvas->drawLine(SkIntToScalar(x), SkIntToScalar(startY),
SkIntToScalar(x), SkIntToScalar(endY), paint);
i++;
i &= (kMeasurementCount - 1); // fast mod
bool SkAndroidSDKCanvas::onAccessTopLayerPixels(SkPixmap* pmap) {
SkASSERT(pmap);
SkImageInfo info;
- size_t rowBytes;
+ size_t rowBytes;
const void* addr = fProxyTarget->accessTopLayerPixels(&info, &rowBytes, nullptr);
if (addr) {
pmap->reset(info, addr, rowBytes);
}
void SkAndroidSDKCanvas::onDiscard() { fProxyTarget->discard(); }
-
-
};
#endif // SkAndroidSDKCanvas_DEFINED
-
SkDebugf("#EOF\n");
return ret;
}
-
}
}
fprintf(out, "\n};\n\n");
-
+
// all fonts are now 0x00, 0x20 - 0xFE
// don't need to generate or output character codes?
fprintf(out, "const unsigned %sCharCodes[] = {\n", fontname);
}
}
fprintf(out, "\n};\n\n");
-
+
SkString widthsStr;
fprintf(out, "const SkFixed %sWidths[] = {\n", fontname);
for (int index = 0; index < offsetCount; ++index) {
}
widthsStr = strip_final(widthsStr);
fprintf(out, "%s\n};\n\n", widthsStr.c_str());
-
+
fprintf(out, "const int %sCharCodesCount = (int) SK_ARRAY_COUNT(%sCharCodes);\n\n",
fontname, fontname);
if (fPaintFilterCanvas) {
fPaintFilterCanvas->addCanvas(canvas);
canvas = fPaintFilterCanvas.get();
-
+
}
if (fMegaVizMode) {
this->markActiveCommands(index);
}
-
+
#if SK_SUPPORT_GPU
// If we have a GPU backend we can also visualize the batching information
GrAuditTrail* at = nullptr;
if (i == index && fFilter) {
canvas->clear(0xAAFFFFFF);
}
-
+
#if SK_SUPPORT_GPU
GrAuditTrail::AutoCollectBatches* acb = nullptr;
if (at) {
Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n, SkCanvas* canvas) {
this->drawAndCollectBatches(n, canvas);
-
+
// now collect json
#if SK_SUPPORT_GPU
GrAuditTrail* at = this->getAuditTrail(canvas);
-
/*
* Copyright 2012 Google Inc.
*
void setClipVizColor(SkColor clipVizColor) { this->fClipVizColor = clipVizColor; }
SkColor getClipVizColor() const { return fClipVizColor; }
- void setDrawGpuBatchBounds(bool drawGpuBatchBounds) {
- fDrawGpuBatchBounds = drawGpuBatchBounds;
+ void setDrawGpuBatchBounds(bool drawGpuBatchBounds) {
+ fDrawGpuBatchBounds = drawGpuBatchBounds;
}
bool getDrawGpuBatchBounds() const { return fDrawGpuBatchBounds; }
/**
Returns a JSON object representing up to the Nth draw, where N is less than
- SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such
+ SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such
as images, referring to them via URLs embedded in the JSON.
*/
Json::Value toJSON(UrlDataManager& urlDataManager, int n, SkCanvas*);
-
/*
* Copyright 2012 Google Inc.
*
case SkPath::kInverseEvenOdd_FillType:
result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_INVERSEEVENODD;
break;
- }
+ }
Json::Value verbs(Json::arrayValue);
SkPath::Iter iter(path, false);
SkPoint pts[4];
return Json::Value(SKDEBUGCANVAS_POINTMODE_POINTS);
case SkCanvas::kLines_PointMode:
return Json::Value(SKDEBUGCANVAS_POINTMODE_LINES);
- case SkCanvas::kPolygon_PointMode:
+ case SkCanvas::kPolygon_PointMode:
return Json::Value(SKDEBUGCANVAS_POINTMODE_POLYGON);
default:
SkASSERT(false);
};
}
-static void store_scalar(Json::Value* target, const char* key, SkScalar value,
+static void store_scalar(Json::Value* target, const char* key, SkScalar value,
SkScalar defaultValue) {
if (value != defaultValue) {
(*target)[key] = Json::Value(value);
}
}
-static void encode_data(const void* bytes, size_t count, const char* contentType,
+static void encode_data(const void* bytes, size_t count, const char* contentType,
UrlDataManager& urlDataManager, Json::Value* target) {
SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count));
SkString url = urlDataManager.addData(data, contentType);
*target = Json::Value(url.c_str());
}
-static void flatten(const SkFlattenable* flattenable, Json::Value* target,
+static void flatten(const SkFlattenable* flattenable, Json::Value* target,
UrlDataManager& urlDataManager) {
SkWriteBuffer buffer;
flattenable->flatten(buffer);
out->write(data, length);
}
-void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_32 height,
+void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_32 height,
SkWStream& out) {
png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
SkASSERT(png != nullptr);
sk_free(pixels);
}
-static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* target,
+static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* target,
UrlDataManager& urlDataManager) {
size_t rowBytes = 4 * image.width();
SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height()));
- SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(),
+ SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(),
kN32_SkColorType, kPremul_SkAlphaType);
if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) {
SkDebugf("readPixels failed\n");
}
}
-static Json::ArrayIndex decode_data(Json::Value data, UrlDataManager& urlDataManager,
+static Json::ArrayIndex decode_data(Json::Value data, UrlDataManager& urlDataManager,
const void** target) {
UrlDataManager::UrlData* urlData = urlDataManager.getDataFromUrl(SkString(data.asCString()));
if (urlData == nullptr) {
return (Json::ArrayIndex) urlData->fData->size();
}
-static SkFlattenable* load_flattenable(Json::Value jsonFlattenable,
+static SkFlattenable* load_flattenable(Json::Value jsonFlattenable,
UrlDataManager& urlDataManager) {
if (!jsonFlattenable.isMember(SKDEBUGCANVAS_ATTRIBUTE_NAME)) {
return nullptr;
return result;
}
-static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* target,
+static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* target,
UrlDataManager& urlDataManager) {
bitmap.lockPixels();
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap));
}
}
-static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target,
+static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkMaskFilter* maskFilter = paint.getMaskFilter();
if (maskFilter != nullptr) {
}
}
-static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target,
+static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkPathEffect* pathEffect = paint.getPathEffect();
if (pathEffect != nullptr) {
}
}
}
-
+
static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) {
SkPaint::Align textAlign = paint.getTextAlign();
if (textAlign != SkPaint::kLeft_Align) {
}
}
-static void apply_paint_typeface(const SkPaint& paint, Json::Value* target,
+static void apply_paint_typeface(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkTypeface* typeface = paint.getTypeface();
if (typeface != nullptr) {
void* data = sk_malloc_throw(buffer.bytesWritten());
buffer.copyTo(data);
Json::Value jsonData;
- encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager,
+ encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager,
&jsonData);
jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
sk_free(data);
}
}
-static void apply_paint_shader(const SkPaint& paint, Json::Value* target,
+static void apply_paint_shader(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkFlattenable* shader = paint.getShader();
if (shader != nullptr) {
}
}
-static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target,
+static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkFlattenable* xfermode = paint.getXfermode();
if (xfermode != nullptr) {
}
}
-static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target,
+static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkFlattenable* colorFilter = paint.getColorFilter();
if (colorFilter != nullptr) {
}
}
-static void apply_paint_looper(const SkPaint& paint, Json::Value* target,
+static void apply_paint_looper(const SkPaint& paint, Json::Value* target,
UrlDataManager& urlDataManager) {
SkFlattenable* looper = paint.getLooper();
if (looper != nullptr) {
Json::Value make_json_paint(const SkPaint& paint, UrlDataManager& urlDataManager) {
Json::Value result(Json::objectValue);
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWidth(), 0.0f);
- store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMiter(),
+ store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMiter(),
SkPaintDefaults_MiterLimit);
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false);
- store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
+ store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
SkPaintDefaults_TextSize);
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScaleX(), SK_Scalar1);
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX(), 0.0f);
}
}
-static void extract_json_paint_shader(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_shader(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) {
Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER];
}
}
-static void extract_json_paint_patheffect(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_patheffect(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) {
Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT];
}
}
-static void extract_json_paint_maskfilter(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_maskfilter(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER)) {
Json::Value jsonMaskFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER];
}
}
-static void extract_json_paint_colorfilter(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_colorfilter(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER)) {
Json::Value jsonColorFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER];
}
}
-static void extract_json_paint_xfermode(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_xfermode(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) {
Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE];
}
}
-static void extract_json_paint_looper(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_looper(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_LOOPER)) {
Json::Value jsonLooper = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_LOOPER];
}
}
-static void extract_json_paint_imagefilter(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_imagefilter(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) {
Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER];
- SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImageFilter,
+ SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImageFilter,
urlDataManager);
if (imageFilter != nullptr) {
target->setImageFilter(imageFilter);
}
}
-static void extract_json_paint_typeface(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
+static void extract_json_paint_typeface(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE)) {
Json::Value jsonTypeface = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE];
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH)) {
float strokeWidth = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH].asFloat();
target->setStrokeWidth(strokeWidth);
- }
+ }
}
static void extract_json_paint_strokemiter(Json::Value& jsonPaint, SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER)) {
float strokeMiter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER].asFloat();
target->setStrokeMiter(strokeMiter);
- }
+ }
}
static void extract_json_paint_strokejoin(Json::Value& jsonPaint, SkPaint* target) {
}
}
-static void extract_json_paint(Json::Value& paint, UrlDataManager& urlDataManager,
+static void extract_json_paint(Json::Value& paint, UrlDataManager& urlDataManager,
SkPaint* result) {
extract_json_paint_color(paint, result);
extract_json_paint_shader(paint, urlDataManager, result);
static void extract_json_rrect(Json::Value& rrect, SkRRect* result) {
SkVector radii[4] = {
- { rrect[1][0].asFloat(), rrect[1][1].asFloat() },
- { rrect[2][0].asFloat(), rrect[2][1].asFloat() },
- { rrect[3][0].asFloat(), rrect[3][1].asFloat() },
+ { rrect[1][0].asFloat(), rrect[1][1].asFloat() },
+ { rrect[2][0].asFloat(), rrect[2][1].asFloat() },
+ { rrect[3][0].asFloat(), rrect[3][1].asFloat() },
{ rrect[4][0].asFloat(), rrect[4][1].asFloat() }
};
- result->setRectRadii(SkRect::MakeLTRB(rrect[0][0].asFloat(), rrect[0][1].asFloat(),
- rrect[0][2].asFloat(), rrect[0][3].asFloat()),
+ result->setRectRadii(SkRect::MakeLTRB(rrect[0][0].asFloat(), rrect[0][1].asFloat(),
+ rrect[0][2].asFloat(), rrect[0][3].asFloat()),
radii);
}
static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) {
- SkScalar values[] = {
+ SkScalar values[] = {
matrix[0][0].asFloat(), matrix[0][1].asFloat(), matrix[0][2].asFloat(),
matrix[1][0].asFloat(), matrix[1][1].asFloat(), matrix[1][2].asFloat(),
- matrix[2][0].asFloat(), matrix[2][1].asFloat(), matrix[2][2].asFloat()
+ matrix[2][0].asFloat(), matrix[2][1].asFloat(), matrix[2][2].asFloat()
};
result->set9(values);
}
return result;
}
-SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command,
+SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkPath path;
extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path);
- return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP]),
+ return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP]),
command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool());
}
return result;
}
-SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command,
+SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkASSERT(false);
return nullptr;
return result;
}
-SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command,
+SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkRect rect;
extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
- return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP]),
+ return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP]),
command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool());
}
return result;
}
-SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command,
+SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkRRect rrect;
extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rrect);
- return new SkClipRRectCommand(rrect,
- get_json_regionop(command[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP]),
+ return new SkClipRRectCommand(rrect,
+ get_json_regionop(command[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP]),
command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool());
}
return result;
}
-SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command,
+SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlDataManager);
if (bitmap == nullptr) {
else {
paintPtr = nullptr;
}
- SkDrawBitmapCommand* result = new SkDrawBitmapCommand(*bitmap, point[0].asFloat(),
+ SkDrawBitmapCommand* result = new SkDrawBitmapCommand(*bitmap, point[0].asFloat(),
point[1].asFloat(), paintPtr);
delete bitmap;
return result;
return result;
}
-SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command,
+SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlDataManager);
if (bitmap == nullptr) {
return result;
}
-SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command,
+SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlDataManager);
if (bitmap == nullptr) {
paintPtr = nullptr;
}
SkCanvas::SrcRectConstraint constraint;
- if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) &&
+ if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) &&
command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) {
constraint = SkCanvas::kStrict_SrcRectConstraint;
}
return result;
}
-SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command,
+SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], urlDataManager);
if (image == nullptr) {
}
void SkDrawImageRectCommand::execute(SkCanvas* canvas) const {
- canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(),
+ canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(),
fConstraint);
}
return result;
}
-SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command,
+SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], urlDataManager);
if (image == nullptr) {
paintPtr = nullptr;
}
SkCanvas::SrcRectConstraint constraint;
- if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) &&
+ if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) &&
command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) {
constraint = SkCanvas::kStrict_SrcRectConstraint;
}
return result;
}
-SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command,
+SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkRect coords;
extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
return result;
}
-SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command,
+SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkPaint paint;
extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint);
return result;
}
-SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command,
+SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkPath path;
extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path);
return result;
}
-SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command,
+SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkCanvas::PointMode mode;
const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString();
Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const {
Json::Value result = INHERITED::toJSON(urlDataManager);
- result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
+ result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
((const char*) fText) + fByteLength);
Json::Value coords(Json::arrayValue);
size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr);
return result;
}
-SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command,
+SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
SkPaint paint;
return result;
}
-SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command,
+SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkTextBlobBuilder builder;
Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS];
return result;
}
-SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command,
+SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
Json::Value jsonCubics = command[SKDEBUGCANVAS_ATTRIBUTE_CUBICS];
SkPoint cubics[12];
return result;
}
-SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command,
+SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkRect coords;
extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
return result;
}
-SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command,
+SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkRRect coords;
extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
return result;
}
-SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command,
+SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkRRect outer;
extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer);
Json::Value SkDrawTextCommand::toJSON(UrlDataManager& urlDataManager) const {
Json::Value result = INHERITED::toJSON(urlDataManager);
- result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
+ result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
((const char*) fText) + fByteLength);
Json::Value coords(Json::arrayValue);
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fX, fY);
return result;
}
-SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command,
+SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
SkPaint paint;
extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint);
Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
- return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords[1].asFloat(),
+ return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords[1].asFloat(),
paint);
}
Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) const {
Json::Value result = INHERITED::toJSON(urlDataManager);
- result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
+ result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
((const char*) fText) + fByteLength);
Json::Value coords(Json::arrayValue);
result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath);
return result;
}
-SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command,
+SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
SkPaint paint;
result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = make_json_rect(fBounds);
}
if (fPaintPtr != nullptr) {
- result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
+ result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager);
}
if (fBackdrop != nullptr) {
return result;
}
-SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command,
+SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkCanvas::SaveLayerRec rec;
SkRect bounds;
return result;
}
-SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
+SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
UrlDataManager& urlDataManager) {
SkMatrix matrix;
extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
static const int kOpTypeCount = kLast_OpType + 1;
- static void WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_32 height,
+ static void WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_32 height,
SkWStream& out);
SkDrawCommand(OpType opType);
-
/*
* Copyright 2012 Google Inc.
*
mBitmap->appendS32(bitmap.width());
mBitmap->append(" H: ");
mBitmap->appendS32(bitmap.height());
-
+
const char* gColorTypeStrings[] = {
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8", "G8", "RGBAf16"
};
SkString* SkObjectParser::PathToString(const SkPath& path) {
SkString* mPath = new SkString;
-
+
mPath->appendf("Path (%d) (", path.getGenerationID());
static const char* gFillStrings[] = {
// The SkPicture tracking information is only generated during recording
// an isn't serialized. Replay the picture to regenerated the tracking data.
SkPictureRecorder recorder;
- picture->playback(recorder.beginRecording(picture->cullRect().width(),
- picture->cullRect().height(),
+ picture->playback(recorder.beginRecording(picture->cullRect().width(),
+ picture->cullRect().height(),
nullptr, 0));
sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture());
if (!FLAGS_quiet) {
SkDebugf("Sigma must be greater than zero (it is %f).\n", FLAGS_sigma);
}
- return kError;
+ return kError;
}
sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_in[0]));
if (!FLAGS_quiet) {
SkDebugf("Couldn't write to file: %s\n", FLAGS_out[0]);
}
- return kError;
+ return kError;
}
return kSuccess;
SkDebugf("Channel (--rgb) must be between 0 and 3 (inclusive) - value is %d.\n",
FLAGS_rgb);
}
- return kError;
+ return kError;
}
if (FLAGS_row >= 0 && FLAGS_column >= 0) {
if (!FLAGS_quiet) {
SkDebugf("Only one of '-c' or '-r' can be specified at at time.\n");
}
- return kError;
+ return kError;
}
if (FLAGS_row < 0 && FLAGS_column < 0) {
if (!FLAGS_quiet) {
SkDebugf("At least one of '-c' or '-r' need to be specified.\n");
}
- return kError;
+ return kError;
}
sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_image[0]));
SkDebugf(", %d", ((c) >> (FLAGS_rgb*8)) & 0xFF);
}
- }
+ }
}
SkDebugf("\n");
auto pic(load_picture(path));
if (pic.get()) {
SkAutoTUnref<SkLuaCanvas> canvas(
- new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()),
+ new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()),
SkScalarCeilToInt(pic->cullRect().height()),
L.get(), gAccumulateFunc));
SkDebugf("Could not create SkPicture: %s\n", path);
return nullptr;
}
- printf("picture cullRect: [%f %f %f %f]\n",
+ printf("picture cullRect: [%f %f %f %f]\n",
pic->cullRect().fLeft, pic->cullRect().fTop,
pic->cullRect().fRight, pic->cullRect().fBottom);
return pic;
const char* emoji_sample_text() {
if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) {
return "Hamburgefons";
- }
+ }
if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) {
return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // 💰🏡🎅
"\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // 🍪🍕🚀
SkTypeface* face = create_font(name, style);
SkSafeUnref(paint->setTypeface(face));
}
-
+
void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
SkColorType colorType, SkAlphaType alphaType) {
SkBitmap tmp(bitmap);
for (int x = dst.fLeft; x < dst.fRight; ++x) {
norm.fX = (x + 0.5f - center.fX) / halfSize.fX;
norm.fY = (y + 0.5f - center.fY) / halfSize.fY;
-
+
SkScalar tmp = norm.fX * norm.fX + norm.fY * norm.fY;
if (tmp >= 1.0f) {
norm.set(0.0f, 0.0f, 1.0f);
norm = locX >= locY ? right : down; // LR corner
} else {
norm = locX > -locY ? right : up; // UR corner
- }
+ }
} else {
if (locY > 0.0f) {
norm = -locX > locY ? left : down; // LL corner
} else {
norm = locX > locY ? up : left; // UL corner
- }
+ }
}
}
norm = locX >= locY ? rightUp : down; // LR corner
} else {
norm = rightUp;
- }
+ }
} else {
if (locY > 0.0f) {
norm = -locX > locY ? leftUp : down; // LL corner
} else {
norm = leftUp;
- }
+ }
}
norm_to_rgb(bm, x, y, norm);
*dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh);
}
}
-
+
return dst;
}
static void SetTempMark(TopoTestNode* node) { node->fTempMark = true; }
static void ResetTempMark(TopoTestNode* node) { node->fTempMark = false; }
static bool IsTempMarked(TopoTestNode* node) { return node->fTempMark; }
- static void Output(TopoTestNode* node, int outputPos) {
+ static void Output(TopoTestNode* node, int outputPos) {
SkASSERT(-1 != outputPos);
- node->fOutputPos = outputPos;
+ node->fOutputPos = outputPos;
}
static bool WasOutput(TopoTestNode* node) { return (-1 != node->fOutputPos); }
static int NumDependencies(TopoTestNode* node) { return node->fDependencies.count(); }
- static TopoTestNode* Dependency(TopoTestNode* node, int index) {
+ static TopoTestNode* Dependency(TopoTestNode* node, int index) {
return node->fDependencies[index];
}
// write to png
SkDynamicMemoryWStream buffer;
- SkDrawCommand::WritePNG((const png_bytep) bmp->getPixels(), bmp->width(), bmp->height(),
+ SkDrawCommand::WritePNG((const png_bytep) bmp->getPixels(), bmp->width(), bmp->height(),
buffer);
return buffer.copyToData();
}
return surface;
}
-bool Request::enableGPU(bool enable) {
+bool Request::enableGPU(bool enable) {
if (enable) {
SkSurface* surface = this->createGPUSurface();
if (surface) {
fSurface.reset(this->createCPUSurface());
fGPUEnabled = false;
return true;
-}
+}
bool Request::initPictureFromStream(SkStream* stream) {
// parse picture from stream
bitmap->unlockPixels();
return result;
}
-
UploadContext* fUploadContext;
SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
UrlDataManager fUrlDataManager;
-
+
private:
SkData* writeCanvasToPng(SkCanvas* canvas);
void drawToCanvas(int n, int m = -1);
SkSurface* createGPUSurface();
SkIRect getBounds();
GrContext* getContext();
-
+
sk_sp<SkPicture> fPicture;
GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
};
#endif
-
address.sin_port = htons(FLAGS_port);
int result = inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr);
if (result != 1) {
- printf("inet_pton for %s:%d failed with return %d %s\n",
+ printf("inet_pton for %s:%d failed with return %d %s\n",
FLAGS_address[0], FLAGS_port, result, strerror(errno));
return 1;
}
daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY
#ifdef SK_DEBUG
| MHD_USE_DEBUG
-#endif
+#endif
, FLAGS_port, nullptr, nullptr,
&answer_to_connection, &request,
MHD_OPTION_SOCK_ADDR, &address,
request->fDebugCanvas->setDrawGpuBatchBounds(enabled);
return SendOK(connection);
}
-
// /batches
if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
int n = request->getLastOp();
-
+
SkAutoTUnref<SkData> data(request->getJsonBatchList(n));
return SendData(connection, data, "application/json");
}
return MHD_NO;
}
-
SkAutoTUnref<SkData> data(stream.copyToData());
return SendData(connection, data, "application/json");
}
-
request->fDebugCanvas->setClipVizColor(SkColorSetARGB(alpha, 0, 0, 0));
return SendOK(connection);
}
-
} else {
sscanf(commands[1].c_str(), "%d", &n);
}
-
+
SkAutoTUnref<SkData> data(request->getJsonOps(n));
return SendData(connection, data, "application/json");
}
return MHD_NO;
}
-
return SendData(connection, data, "application/octet-stream", true,
"attachment; filename=something.skp;");
}
-
}
return SendOK(connection);
}
-
SkAutoTUnref<SkData> data(request->drawToPng(n, m));
return SendData(connection, data, "image/png");
}
-
SkAutoTUnref<SkData> data(request->getJsonInfo(n));
return SendData(connection, data, "application/json");
}
-
fprintf(stderr, "Could not create picture from stream.\n");
return MHD_NO;
}
-
+
// clear upload context
delete request->fUploadContext;
request->fUploadContext = nullptr;
return SendTemplate(connection, true, "/");
}
-
const char* upload_data, size_t* upload_data_size) {
return SendTemplate(connection);
}
-
};
/**
- Controls whether GPU rendering is enabled. Posting to /enableGPU/1 turns GPU on, /enableGPU/0
+ Controls whether GPU rendering is enabled. Posting to /enableGPU/1 turns GPU on, /enableGPU/0
disables it.
*/
class EnableGPUHandler : public UrlHandler {
const char* url, const char* method,
const char* upload_data, size_t* upload_data_size) override;
};
-
}
SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue);
- make_skp(SkIntToScalar(FLAGS_width),
- SkIntToScalar(FLAGS_height),
- SkIntToScalar(FLAGS_border),
+ make_skp(SkIntToScalar(FLAGS_width),
+ SkIntToScalar(FLAGS_height),
+ SkIntToScalar(FLAGS_border),
color, FLAGS_writePath[0]);
return 0;
}
0x30307833, -0.83252f, -0.83252f, 0.300293f, 0.300293f, 0, 0.791992f, 0.0123749f,
-0.0942383f, 0.697754f, 0.538086f, 0.0104446f, 0.100098f, 0.23291f
};
-
0x30307833, -1.02979f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 1.3374f, 0.0208969f,
-0.208984f, 1.12842f, 0.537598f, 0.0109024f, 0.10498f, 0.105957f
};
-
0x30307833, -0.980957f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 1.32861f, 0.0207596f,
-0.178223f, 1.15039f, 0.469727f, 0.0103607f, 0.0952148f, 0.108887f
};
-