////////////////////////////////////////////////////////////////////////////////
-DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, false)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, true)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, false)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, true)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipRegionBench, ()); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, false)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, true)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, false)); )
-DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, true)); )
-DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (false)); )
-DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (true)); )
+DEF_BENCH(return new AAClipBuilderBench(false, false);)
+DEF_BENCH(return new AAClipBuilderBench(false, true);)
+DEF_BENCH(return new AAClipBuilderBench(true, false);)
+DEF_BENCH(return new AAClipBuilderBench(true, true);)
+DEF_BENCH(return new AAClipRegionBench();)
+DEF_BENCH(return new AAClipBench(false, false);)
+DEF_BENCH(return new AAClipBench(false, true);)
+DEF_BENCH(return new AAClipBench(true, false);)
+DEF_BENCH(return new AAClipBench(true, true);)
+DEF_BENCH(return new NestedAAClipBench(false);)
+DEF_BENCH(return new NestedAAClipBench(true);)
typedef Benchmark INHERITED;
};
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kWhite_ColorPattern, kWhite_ColorPattern,
- kPath_DrawType)); )
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kBlue_ColorPattern, kBlue_ColorPattern,
- kPath_DrawType)); )
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kWhite_ColorPattern, kBlue_ColorPattern,
- kPath_DrawType)); )
-
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kOpaqueBitmap_ColorPattern, kOpaqueBitmap_ColorPattern,
- kPath_DrawType)); )
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kAlphaBitmap_ColorPattern, kAlphaBitmap_ColorPattern,
- kPath_DrawType)); )
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kOpaqueBitmap_ColorPattern, kAlphaBitmap_ColorPattern,
- kPath_DrawType)); )
-
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kOpaqueBitmap_ColorPattern, kOpaqueBitmap_ColorPattern,
- kRect_DrawType)); )
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kAlphaBitmap_ColorPattern, kAlphaBitmap_ColorPattern,
- kRect_DrawType)); )
-DEF_BENCH( return SkNEW_ARGS(AlternatingColorPatternBench,
- (kOpaqueBitmap_ColorPattern, kAlphaBitmap_ColorPattern,
- kRect_DrawType)); )
-
+DEF_BENCH(return new AlternatingColorPatternBench(kWhite_ColorPattern,
+ kWhite_ColorPattern,
+ kPath_DrawType);)
+DEF_BENCH(return new AlternatingColorPatternBench(kBlue_ColorPattern,
+ kBlue_ColorPattern,
+ kPath_DrawType);)
+DEF_BENCH(return new AlternatingColorPatternBench(kWhite_ColorPattern,
+ kBlue_ColorPattern,
+ kPath_DrawType);)
+
+DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern,
+ kOpaqueBitmap_ColorPattern,
+ kPath_DrawType);)
+DEF_BENCH(return new AlternatingColorPatternBench(kAlphaBitmap_ColorPattern,
+ kAlphaBitmap_ColorPattern,
+ kPath_DrawType);)
+DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern,
+ kAlphaBitmap_ColorPattern,
+ kPath_DrawType);)
+
+DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern,
+ kOpaqueBitmap_ColorPattern,
+ kRect_DrawType);)
+DEF_BENCH(return new AlternatingColorPatternBench(kAlphaBitmap_ColorPattern,
+ kAlphaBitmap_ColorPattern,
+ kRect_DrawType);)
+DEF_BENCH(return new AlternatingColorPatternBench(kOpaqueBitmap_ColorPattern,
+ kAlphaBitmap_ColorPattern,
+ kRect_DrawType);)
BenchLogger::~BenchLogger() {
if (fFileStream) {
- SkDELETE(fFileStream);
+ delete fFileStream;
}
}
bool BenchLogger::SetLogFile(const char *file) {
- fFileStream = SkNEW_ARGS(SkFILEWStream, (file));
+ fFileStream = new SkFILEWStream(file);
return fFileStream->isValid();
}
// Disabled this benchmark: it takes 15x longer than any other benchmark
// and is probably not giving us important information.
-// DEF_BENCH(return SkNEW(ScrollGmailBench));
+// DEF_BENCH(return new ScrollGmailBench);
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include "Benchmark.h"
#include "SkColorPriv.h"
#include "SkRandom.h"
};
#define COMMA ,
-DEF_BENCH( return SkNEW(FourByteInterpBench<true COMMA true>); )
-DEF_BENCH( return SkNEW(FourByteInterpBench<true COMMA false>); )
-DEF_BENCH( return SkNEW(FourByteInterpBench<false COMMA true>); )
-DEF_BENCH( return SkNEW(FourByteInterpBench<false COMMA false>); )
+DEF_BENCH(return (new FourByteInterpBench<true COMMA true>);)
+DEF_BENCH(return (new FourByteInterpBench<true COMMA false>);)
+DEF_BENCH(return (new FourByteInterpBench<false COMMA true>);)
+DEF_BENCH(return (new FourByteInterpBench<false COMMA false>);)
#undef COMMA
typedef Benchmark INHERITED;
};
-DEF_BENCH( return SkNEW_ARGS(FSRectBench, ()); )
+DEF_BENCH(return new FSRectBench();)
///////////////////////////////////////////////////////////////////////////////
-DEF_BENCH( return SkNEW_ARGS(FontScalerBench, (false)); )
-DEF_BENCH( return SkNEW_ARGS(FontScalerBench, (true)); )
+DEF_BENCH(return new FontScalerBench(false);)
+DEF_BENCH(return new FontScalerBench(true);)
};
// Partial clear
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kScale_Type,
- GameBench::kPartial_Clear)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
- GameBench::kPartial_Clear)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
- GameBench::kPartial_Clear, true)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kRotate_Type,
- GameBench::kPartial_Clear)); )
+DEF_BENCH(return new GameBench(GameBench::kScale_Type, GameBench::kPartial_Clear);)
+DEF_BENCH(return new GameBench(GameBench::kTranslate_Type, GameBench::kPartial_Clear);)
+DEF_BENCH(return new GameBench(GameBench::kTranslate_Type, GameBench::kPartial_Clear, true);)
+DEF_BENCH(return new GameBench(GameBench::kRotate_Type, GameBench::kPartial_Clear);)
// Full clear
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kScale_Type,
- GameBench::kFull_Clear)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
- GameBench::kFull_Clear)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
- GameBench::kFull_Clear, true)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kRotate_Type,
- GameBench::kFull_Clear)); )
+DEF_BENCH(return new GameBench(GameBench::kScale_Type, GameBench::kFull_Clear);)
+DEF_BENCH(return new GameBench(GameBench::kTranslate_Type, GameBench::kFull_Clear);)
+DEF_BENCH(return new GameBench(GameBench::kTranslate_Type, GameBench::kFull_Clear, true);)
+DEF_BENCH(return new GameBench(GameBench::kRotate_Type, GameBench::kFull_Clear);)
// Atlased
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
- GameBench::kFull_Clear, false, true)); )
-DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
- GameBench::kFull_Clear, false, true, true)); )
+DEF_BENCH(return new GameBench(GameBench::kTranslate_Type, GameBench::kFull_Clear, false, true);)
+DEF_BENCH(return new GameBench(
+ GameBench::kTranslate_Type, GameBench::kFull_Clear, false, true, true);)
for (int i = 0; i < resourceCount; ++i) {
GrUniqueKey key;
BenchResource::ComputeKey(i, keyData32Count, &key);
- GrGpuResource* resource = SkNEW_ARGS(BenchResource, (gpu));
+ GrGpuResource* resource = new BenchResource(gpu);
resource->resourcePriv().setUniqueKey(key);
resource->unref();
}
void populateCache() {
for (int i = 0; i < CACHE_COUNT; ++i) {
- fCache.add(SkNEW_ARGS(TestRec, (TestKey(i), i)));
+ fCache.add(new TestRec(TestKey(i), i));
}
}
///////////////////////////////////////////////////////////////////////////////
-DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("XY", &make_XYordered_rects)));
-DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("YX", &make_YXordered_rects)));
-DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("random", &make_random_rects)));
-DEF_BENCH(return SkNEW_ARGS(RTreeBuildBench, ("concentric", &make_concentric_rects)));
-
-DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("XY", &make_XYordered_rects)));
-DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("YX", &make_YXordered_rects)));
-DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("random", &make_random_rects)));
-DEF_BENCH(return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects)));
+DEF_BENCH(return new RTreeBuildBench("XY", &make_XYordered_rects));
+DEF_BENCH(return new RTreeBuildBench("YX", &make_YXordered_rects));
+DEF_BENCH(return new RTreeBuildBench("random", &make_random_rects));
+DEF_BENCH(return new RTreeBuildBench("concentric", &make_concentric_rects));
+
+DEF_BENCH(return new RTreeQueryBench("XY", &make_XYordered_rects));
+DEF_BENCH(return new RTreeQueryBench("YX", &make_YXordered_rects));
+DEF_BENCH(return new RTreeQueryBench("random", &make_random_rects));
+DEF_BENCH(return new RTreeQueryBench("concentric", &make_concentric_rects));
kMaskType _type;
};
-
-DEF_BENCH( return SkNEW_ARGS(RectBench, (1)); )
-DEF_BENCH( return SkNEW_ARGS(RectBench, (1, 4)); )
-DEF_BENCH( return SkNEW_ARGS(RectBench, (3)); )
-DEF_BENCH( return SkNEW_ARGS(RectBench, (3, 4)); )
-DEF_BENCH( return SkNEW_ARGS(OvalBench, (1)); )
-DEF_BENCH( return SkNEW_ARGS(OvalBench, (3)); )
-DEF_BENCH( return SkNEW_ARGS(OvalBench, (1, 4)); )
-DEF_BENCH( return SkNEW_ARGS(OvalBench, (3, 4)); )
-DEF_BENCH( return SkNEW_ARGS(RRectBench, (1)); )
-DEF_BENCH( return SkNEW_ARGS(RRectBench, (1, 4)); )
-DEF_BENCH( return SkNEW_ARGS(RRectBench, (3)); )
-DEF_BENCH( return SkNEW_ARGS(RRectBench, (3, 4)); )
-DEF_BENCH( return SkNEW_ARGS(PointsBench, (SkCanvas::kPoints_PointMode, "points")); )
-DEF_BENCH( return SkNEW_ARGS(PointsBench, (SkCanvas::kLines_PointMode, "lines")); )
-DEF_BENCH( return SkNEW_ARGS(PointsBench, (SkCanvas::kPolygon_PointMode, "polygon")); )
-
-DEF_BENCH( return SkNEW_ARGS(SrcModeRectBench, ()); )
+DEF_BENCH(return new RectBench(1);)
+DEF_BENCH(return new RectBench(1, 4);)
+DEF_BENCH(return new RectBench(3);)
+DEF_BENCH(return new RectBench(3, 4);)
+DEF_BENCH(return new OvalBench(1);)
+DEF_BENCH(return new OvalBench(3);)
+DEF_BENCH(return new OvalBench(1, 4);)
+DEF_BENCH(return new OvalBench(3, 4);)
+DEF_BENCH(return new RRectBench(1);)
+DEF_BENCH(return new RRectBench(1, 4);)
+DEF_BENCH(return new RRectBench(3);)
+DEF_BENCH(return new RRectBench(3, 4);)
+DEF_BENCH(return new PointsBench(SkCanvas::kPoints_PointMode, "points");)
+DEF_BENCH(return new PointsBench(SkCanvas::kLines_PointMode, "lines");)
+DEF_BENCH(return new PointsBench(SkCanvas::kPolygon_PointMode, "polygon");)
+
+DEF_BENCH(return new SrcModeRectBench();)
/* init the blitmask bench
*/
-DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
- (SkCanvas::kPoints_PointMode,
- BlitMaskBench::kMaskOpaque, "maskopaque")
- ); )
-DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
- (SkCanvas::kPoints_PointMode,
- BlitMaskBench::kMaskBlack, "maskblack")
- ); )
-DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
- (SkCanvas::kPoints_PointMode,
- BlitMaskBench::kMaskColor, "maskcolor")
- ); )
-DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
- (SkCanvas::kPoints_PointMode,
- BlitMaskBench::KMaskShader, "maskshader")
- ); )
+DEF_BENCH(return new BlitMaskBench(SkCanvas::kPoints_PointMode,
+ BlitMaskBench::kMaskOpaque,
+ "maskopaque");)
+DEF_BENCH(return new BlitMaskBench(SkCanvas::kPoints_PointMode,
+ BlitMaskBench::kMaskBlack,
+ "maskblack");)
+DEF_BENCH(return new BlitMaskBench(SkCanvas::kPoints_PointMode,
+ BlitMaskBench::kMaskColor,
+ "maskcolor");)
+DEF_BENCH(return new BlitMaskBench(SkCanvas::kPoints_PointMode,
+ BlitMaskBench::KMaskShader,
+ "maskshader");)
SkASSERT(NULL == fRectanizer.get());
if (kPow2_RectanizerType == fRectanizerType) {
- fRectanizer.reset(SkNEW_ARGS(GrRectanizerPow2, (kWidth, kHeight)));
+ fRectanizer.reset(new GrRectanizerPow2(kWidth, kHeight));
} else {
SkASSERT(kSkyline_RectanizerType == fRectanizerType);
- fRectanizer.reset(SkNEW_ARGS(GrRectanizerSkyline, (kWidth, kHeight)));
+ fRectanizer.reset(new GrRectanizerSkyline(kWidth, kHeight));
}
}
typedef Benchmark INHERITED;
};
-DEF_BENCH( return SkNEW_ARGS(RectoriBench, ()); )
+DEF_BENCH(return new RectoriBench();)
#define SMALL 16
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, union_proc, "union")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sect_proc, "intersect")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diff_proc, "difference")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrect_proc, "differencerect")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrectbig_proc, "differencerectbig")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsrect_proc, "containsrect")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrgn_proc, "intersectsrgn")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrect_proc, "intersectsrect")); )
-DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsxy_proc, "containsxy")); )
+DEF_BENCH(return new RegionBench(SMALL, union_proc, "union");)
+DEF_BENCH(return new RegionBench(SMALL, sect_proc, "intersect");)
+DEF_BENCH(return new RegionBench(SMALL, diff_proc, "difference");)
+DEF_BENCH(return new RegionBench(SMALL, diffrect_proc, "differencerect");)
+DEF_BENCH(return new RegionBench(SMALL, diffrectbig_proc, "differencerectbig");)
+DEF_BENCH(return new RegionBench(SMALL, containsrect_proc, "containsrect");)
+DEF_BENCH(return new RegionBench(SMALL, sectsrgn_proc, "intersectsrgn");)
+DEF_BENCH(return new RegionBench(SMALL, sectsrect_proc, "intersectsrect");)
+DEF_BENCH(return new RegionBench(SMALL, containsxy_proc, "containsxy");)
typedef Benchmark INHERITED;
};
-DEF_BENCH( return SkNEW_ARGS(RegionContainBench, (sect_proc, "sect")); )
+DEF_BENCH(return new RegionContainBench(sect_proc, "sect");)
SKPAnimationBench::Animation* SKPAnimationBench::CreateZoomAnimation(SkScalar zoomMax,
double zoomPeriodMs) {
- return SkNEW_ARGS(ZoomAnimation, (zoomMax, zoomPeriodMs));
+ return new ZoomAnimation(zoomMax, zoomPeriodMs);
}
};
// Enable the true version once the feature is checked in.
-DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true)));
-DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false)));
+DEF_BENCH(return new SkipZeroesBench("arrow.png", true));
+DEF_BENCH(return new SkipZeroesBench("arrow.png", false));
return paint;
}
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "line_1", 1)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "quad_1", 1)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "conic_1", 1)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "cubic_1", 1)); )
+DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_1", 1);)
+DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_1", 1);)
+DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_1", 1);)
+DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_1", 1);)
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "line_4", 4)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "quad_4", 4)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "conic_4", 4)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "cubic_4", 4)); )
+DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_4", 4);)
+DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_4", 4);)
+DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_4", 4);)
+DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_4", 4);)
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "line_.25", .25f)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "quad_.25", .25f)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "conic_.25", .25f)); )
-DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "cubic_.25", .25f)); )
+DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_.25", .25f);)
+DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_.25", .25f);)
+DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_.25", .25f);)
+DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_.25", .25f);)
///////////////////////////////////////////////////////////////////////////////
-DEF_BENCH( return SkNEW_ARGS(VertBench, ()); )
+DEF_BENCH(return new VertBench();)
//////////////////////////////////////////////////////////////////////////////
-DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kPremul_SkAlphaType)); )
-DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (kRGBA_8888_SkColorType, kUnpremul_SkAlphaType)); )
+DEF_BENCH(return new WritePixelsBench(kRGBA_8888_SkColorType, kPremul_SkAlphaType);)
+DEF_BENCH(return new WritePixelsBench(kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);)
SkPMColor colors[256];
int colorCount;
const SkImageInfo info = codec->getInfo().makeColorType(colorType);
- SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes()));
+ SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(SkScanlineDecoder::NewFromData(encoded));
if (NULL == scanlineDecoder || scanlineDecoder->start(info, NULL,
colors, &colorCount) != SkCodec::kSuccess)
}
static void cleanup_run(Target* target) {
- SkDELETE(target);
+ delete target;
#if SK_SUPPORT_GPU
if (FLAGS_abandonGpuContext) {
gGrFactory->abandonContexts();
if (gm->runAsBench()) {
fSourceType = "gm";
fBenchType = "micro";
- return SkNEW_ARGS(GMBench, (gm.detach()));
+ return new GMBench(gm.detach());
}
}
fBenchType = "recording";
fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic));
fSKPOps = pic->approximateOpCount();
- return SkNEW_ARGS(RecordingBench, (name.c_str(), pic.get(), FLAGS_bbh));
+ return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh);
}
// Then once each for each scale as SKPBenches (playback).
SkString name = SkOSPath::Basename(path.c_str());
fSourceType = "skp";
fBenchType = "playback";
- return SkNEW_ARGS(SKPBench,
- (name.c_str(), pic.get(), fClip, fScales[fCurrentScale],
- fUseMPDs[fCurrentUseMPD++], FLAGS_loopSKP));
-
+ return new SKPBench(name.c_str(), pic.get(), fClip, fScales[fCurrentScale],
+ fUseMPDs[fCurrentUseMPD++], FLAGS_loopSKP);
}
fCurrentUseMPD = 0;
fCurrentSKP++;
SkString name = SkOSPath::Basename(path.c_str());
SkAutoTUnref<SKPAnimationBench::Animation> animation(
SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriodMs));
- return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), fClip, animation,
- FLAGS_loopSKP));
+ return new SKPAnimationBench(name.c_str(), pic.get(), fClip, animation,
+ FLAGS_loopSKP);
}
}
#if SK_SUPPORT_GPU
GrContextOptions grContextOpts;
grContextOpts.fDrawPathToCompressedTexture = FLAGS_gpuCompressAlphaMasks;
- gGrFactory.reset(SkNEW_ARGS(GrContextFactory, (grContextOpts)));
+ gGrFactory.reset(new GrContextFactory(grContextOpts));
#endif
if (FLAGS_veryVerbose) {
}
}
- SkAutoTDelete<ResultsWriter> log(SkNEW(ResultsWriter));
+ SkAutoTDelete<ResultsWriter> log(new ResultsWriter);
if (!FLAGS_outResultsFile.isEmpty()) {
- log.reset(SkNEW(NanoJSONResultsWriter(FLAGS_outResultsFile[0])));
+ log.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0]));
}
if (1 == FLAGS_properties.count() % 2) {
static inline void alloc_pixels(SkBitmap* bitmap, const SkImageInfo& info, SkPMColor* colors,
int colorCount) {
if (kIndex_8_SkColorType == info.colorType()) {
- SkAutoTUnref<SkColorTable> colorTable(SkNEW_ARGS(SkColorTable, (colors, colorCount)));
+ SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, colorCount));
bitmap->allocPixels(info, NULL, colorTable);
} else {
bitmap->allocPixels(info);
SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(
SkScanlineDecoder::NewFromStream(fStream->duplicate()));
const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType);
- SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes()));
+ SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
scanlineDecoder->start(info, NULL, colors, &colorCount);
SkBitmap bitmap;
SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(
SkScanlineDecoder::NewFromStream(fStream->duplicate()));
const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType);
- SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes()));
+ SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
scanlineDecoder->start(info, NULL, colors, &colorCount);
SkBitmap bitmap;
// We create a color table here to satisfy allocPixels() when the output
// type is kIndex8. It's okay that this is uninitialized since we never
// use it.
- SkColorTable* colorTable = SkNEW_ARGS(SkColorTable, (colors, 0));
+ SkColorTable* colorTable = new SkColorTable(colors, 0);
for (int count = 0; count < n; count++) {
int width, height;
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(
SkScanlineDecoder::NewFromStream(fStream->duplicate()));
const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType);
- SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes()));
+ SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
scanlineDecoder->start(info, NULL, colors, &colorCount);
const int centerX = info.width() / 2;
void SkDebuggerGUI::loadPicture(const SkString& fileName) {
fFileName = fileName;
fLoading = true;
- SkAutoTDelete<SkStream> stream(SkNEW_ARGS(SkFILEStream, (fileName.c_str())));
+ SkAutoTDelete<SkStream> stream(new SkFILEStream(fileName.c_str()));
SkPicture* picture = SkPicture::CreateFromStream(stream);
int maxColors = 256;
if (kIndex_8_SkColorType == decodeInfo.colorType()) {
SkPMColor colors[256];
- colorTable.reset(SkNEW_ARGS(SkColorTable, (colors, maxColors)));
+ colorTable.reset(new SkColorTable(colors, maxColors));
colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
colorCountPtr = &maxColors;
}
largestSubsetDecodeInfo.width(), largestSubsetDecodeInfo.height());
}
const size_t rowBytes = decodeInfo.minRowBytes();
- char* buffer = SkNEW_ARRAY(char, largestSubsetDecodeInfo.height() * rowBytes);
+ char* buffer = new char[largestSubsetDecodeInfo.height() * rowBytes];
SkAutoTDeleteArray<char> lineDeleter(buffer);
for (int col = 0; col < divisor; col++) {
//currentSubsetWidth may be larger than subsetWidth for rightmost subsets
SVGSink::SVGSink() {}
Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
- SkAutoTDelete<SkXMLWriter> xmlWriter(SkNEW_ARGS(SkXMLStreamWriter, (dst)));
+ SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size().height())),
xmlWriter));
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include "SkCanvas.h"
#include "SkCGUtils.h"
#include "SkGraphics.h"
SkBitmap bm;
if (SkImageDecoder::DecodeFile(path, &bm)) {
bm.setImmutable();
- pic = SkNEW(SkPicture);
+ pic = new SkPicture;
SkCanvas* can = pic->beginRecording(bm.width(), bm.height());
can->drawBitmap(bm, 0, 0, NULL);
pic->endRecording();
} else {
SkFILEStream stream(path);
if (stream.isValid()) {
- pic = SkNEW_ARGS(SkPicture,
- (&stream, NULL, &SkImageDecoder::DecodeStream));
+ pic = new SkPicture(&stream, NULL, &SkImageDecoder::DecodeStream);
}
if (false) { // re-record
canvas.divName(filename, false);
SkPicture* pic = LoadPicture(path.c_str());
pic->draw(&canvas);
- SkDELETE(pic);
+ delete pic;
}
SkDebugf("\n</div>\n\n");
canvas.divName(filename, true);
SkPicture* pic = LoadPicture(path.c_str());
pic->draw(&canvas);
- SkDELETE(pic);
+ delete pic;
}
SkDebugf("];\n\n");
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(AAClipGM); )
+DEF_GM(return new AAClipGM;)
/////////////////////////////////////////////////////////////////////////
(SkPMColor*)bm.getPixels(),
bm.rowBytes());
} else {
- return SkNEW_ARGS(SkCanvas, (bm));
+ return new SkCanvas(bm);
}
}
};
#if 0 // Disabled pending fix from reed@
-DEF_GM( return SkNEW(CGImageGM); )
+DEF_GM( return new CGImageGM; )
#endif
#endif
private:
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(ClipCubicGM); )
-
+DEF_GM(return new ClipCubicGM;)
pmColors[i] = premultiply_color(colors[i]);
}
SkBitmap bm;
- SkAutoTUnref<SkColorTable> ctable(
- SkNEW_ARGS(SkColorTable, (pmColors, SK_ARRAY_COUNT(pmColors))));
+ SkAutoTUnref<SkColorTable> ctable(new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors)));
SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType,
kPremul_SkAlphaType);
bm.allocPixels(info, NULL, ctable);
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(AlphaGradientsGM); )
+DEF_GM(return new AlphaGradientsGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(AnisotropicGM); )
-
+DEF_GM(return new AnisotropicGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(ArcOfZorroGM); )
-
+DEF_GM(return new ArcOfZorroGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(skiagm::ASTCBitmapGM); )
+DEF_GM(return new skiagm::ASTCBitmapGM;)
/////////////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(BadPaintGM); )
+DEF_GM(return new BadPaintGM;)
static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo,
const SkScalar klmEqs[9], SkScalar sign) {
- return SkNEW_ARGS(BezierCubicOrConicTestBatch, (gp, geo, klmEqs, sign));
+ return new BezierCubicOrConicTestBatch(gp, geo, klmEqs, sign);
}
private:
static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo,
const GrPathUtils::QuadUVMatrix& devToUV) {
- return SkNEW_ARGS(BezierQuadTestBatch, (gp, geo, devToUV));
+ return new BezierQuadTestBatch(gp, geo, devToUV);
}
private:
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(BezierCubicEffects); )
-DEF_GM( return SkNEW(BezierConicEffects); )
-DEF_GM( return SkNEW(BezierQuadEffects); )
-
+DEF_GM(return new BezierCubicEffects;)
+DEF_GM(return new BezierConicEffects;)
+DEF_GM(return new BezierQuadEffects;)
}
#endif
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(BigBlursGM); )
-
+DEF_GM(return new BigBlursGM;)
}
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(BigTextGM); )
+DEF_GM(return new BigTextGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(BigTileImageFilterGM); )
-
+DEF_GM(return new BigTileImageFilterGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW_ARGS(BitmapSourceGM, ("none", kNone_SkFilterQuality) ); )
-DEF_GM( return SkNEW_ARGS(BitmapSourceGM, ("low", kLow_SkFilterQuality) ); )
-DEF_GM( return SkNEW_ARGS(BitmapSourceGM, ("med", kMedium_SkFilterQuality) ); )
-DEF_GM( return SkNEW_ARGS(BitmapSourceGM, ("high", kHigh_SkFilterQuality) ); )
-
+DEF_GM(return new BitmapSourceGM("none", kNone_SkFilterQuality);)
+DEF_GM(return new BitmapSourceGM("low", kLow_SkFilterQuality);)
+DEF_GM(return new BitmapSourceGM("med", kMedium_SkFilterQuality);)
+DEF_GM(return new BitmapSourceGM("high", kHigh_SkFilterQuality);)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(BmpFilterQualityRepeat); )
+DEF_GM(return new BmpFilterQualityRepeat;)
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(ClipStrokeRectGM); )
-
+DEF_GM(return new ClipStrokeRectGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return SkNEW(ClipDrawDrawGM);)
-
+DEF_GM(return new ClipDrawDrawGM;)
}
stream.rewind();
codec->setDitherImage(dither);
codec->decode(&stream, &fBitmap, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- SkDELETE(codec);
+ delete codec;
}
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(ColorFiltersGM); )
+DEF_GM(return new ColorFiltersGM;)
if (NULL == orig) {
orig = SkTypeface::RefDefault();
}
- fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint));
+ fColorType = new SkGTypeface(orig, paint);
orig->unref();
}
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(ColorTypeGM); )
+DEF_GM(return new ColorTypeGM;)
if (NULL == orig) {
orig = SkTypeface::RefDefault();
}
- fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint));
+ fColorType = new SkGTypeface(orig, paint);
orig->unref();
fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType,
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, false, false)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, false, true)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, true, false)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, true, true)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, false, false)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, false, true)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, true, false)); )
-DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, true, true)); )
-
+DEF_GM(return new ComplexClipGM(false, false, false);)
+DEF_GM(return new ComplexClipGM(false, false, true);)
+DEF_GM(return new ComplexClipGM(false, true, false);)
+DEF_GM(return new ComplexClipGM(false, true, true);)
+DEF_GM(return new ComplexClipGM(true, false, false);)
+DEF_GM(return new ComplexClipGM(true, false, true);)
+DEF_GM(return new ComplexClipGM(true, true, false);)
+DEF_GM(return new ComplexClipGM(true, true, true);)
}
SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode));
- return SkNEW_ARGS(SkComposeShader, (shaderA, shaderB, xfer));
+ return new SkComposeShader(shaderA, shaderB, xfer);
}
class ComposeShaderGM : public skiagm::GM {
SkPath fGiantCircle;
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(ConicPathsGM); )
+DEF_GM(return new ConicPathsGM;)
//////////////////////////////////////////////////////////////////////////////
const SkScalar ConstColorProcessor::kPad = 10.f;
const SkScalar ConstColorProcessor::kRectSize = 20.f;
-DEF_GM( return SkNEW(ConstColorProcessor); )
+DEF_GM(return new ConstColorProcessor;)
}
#endif
break;
}
- data.reset(SkNEW_ARRAY(SkPoint, numPts));
+ data.reset(new SkPoint[numPts]);
create_ngon(numPts, data.get(), width, height);
points = data.get();
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(ConvexLineOnlyPathsGM); )
-
+DEF_GM(return new ConvexLineOnlyPathsGM;)
}
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(ConvexPolyClip); )
-
+DEF_GM(return new ConvexPolyClip;)
}
const char* name() const override { return "ConvexPolyTestBatch"; }
static GrDrawBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) {
- return SkNEW_ARGS(ConvexPolyTestBatch, (gp, geo));
+ return new ConvexPolyTestBatch(gp, geo);
}
private:
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(ConvexPolyEffect); )
+DEF_GM(return new ConvexPolyEffect;)
}
#endif
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return SkNEW(DashingGM);)
-DEF_GM(return SkNEW(Dashing2GM);)
-DEF_GM(return SkNEW(Dashing3GM);)
-DEF_GM(return SkNEW(Dashing4GM);)
-DEF_GM(return SkNEW_ARGS(Dashing5GM, (true));)
-DEF_GM(return SkNEW_ARGS(Dashing5GM, (false));)
-
+DEF_GM(return new DashingGM;)
+DEF_GM(return new Dashing2GM;)
+DEF_GM(return new Dashing3GM;)
+DEF_GM(return new Dashing4GM;)
+DEF_GM(return new Dashing5GM(true);)
+DEF_GM(return new Dashing5GM(false);)
SkFlattenable* DCShader::CreateProc(SkReadBuffer& buf) {
SkMatrix matrix;
buf.readMatrix(&matrix);
- return SkNEW_ARGS(DCShader, (matrix));
+ return new DCShader(matrix);
}
class DCFP : public GrFragmentProcessor {
}
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override {}
};
- return SkNEW(DCGLFP);
+ return new DCGLFP;
}
const char* name() const override { return "DCFP"; }
const SkMatrix* localMatrix, GrColor* color,
GrProcessorDataManager* procDataManager,
GrFragmentProcessor** fp) const {
- *fp = SkNEW_ARGS(DCFP, (procDataManager, fDeviceMatrix));
+ *fp = new DCFP(procDataManager, fDeviceMatrix);
*color = GrColorPackA4(paint.getAlpha());
return true;
}
~DCShaderGM() override {
for (int i = 0; i < fPrims.count(); ++i) {
- SkDELETE(fPrims[i]);
+ delete fPrims[i];
}
}
virtual const char* text() const { return "Hello, Skia!"; }
};
- fPrims.push_back(SkNEW(Rect));
- fPrims.push_back(SkNEW(Circle));
- fPrims.push_back(SkNEW(RRect));
- fPrims.push_back(SkNEW(DRRect));
- fPrims.push_back(SkNEW(Path));
- fPrims.push_back(SkNEW(Points(SkCanvas::kPoints_PointMode)));
- fPrims.push_back(SkNEW(Points(SkCanvas::kLines_PointMode)));
- fPrims.push_back(SkNEW(Points(SkCanvas::kPolygon_PointMode)));
- fPrims.push_back(SkNEW(Text));
+ fPrims.push_back(new Rect);
+ fPrims.push_back(new Circle);
+ fPrims.push_back(new RRect);
+ fPrims.push_back(new DRRect);
+ fPrims.push_back(new Path);
+ fPrims.push_back(new Points(SkCanvas::kPoints_PointMode));
+ fPrims.push_back(new Points(SkCanvas::kLines_PointMode));
+ fPrims.push_back(new Points(SkCanvas::kPolygon_PointMode));
+ fPrims.push_back(new Text);
}
void onDraw(SkCanvas* canvas) override {
for (int i = 0; i < fPrims.count(); ++i) {
for (int j = 0; j < devMats.count(); ++j) {
for (int k = 0; k < viewMats.count(); ++k) {
- paint.setShader(SkNEW_ARGS(DCShader, (devMats[j])))->unref();
+ paint.setShader(new DCShader(devMats[j]))->unref();
paint.setAntiAlias(SkToBool(aa));
canvas->save();
canvas->concat(viewMats[k]);
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(DCShaderGM); )
+DEF_GM(return new DCShaderGM;)
}
#endif
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(DFTextGM); )
+DEF_GM(return new DFTextGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(DiscardGM); )
+DEF_GM(return new DiscardGM;)
} // end namespace
if (codec) {
stream.rewind();
codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- SkDELETE(codec);
+ delete codec;
} else {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(EmbossGM); )
+DEF_GM(return new EmbossGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); )
-DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); )
-DEF_GM( return SkNEW(skiagm::ETC1Bitmap_R11_KTX_GM); )
+DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;)
+DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;)
+DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;)
#ifndef SK_IGNORE_ETC1_SUPPORT
-DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); )
+DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;)
#endif // SK_IGNORE_ETC1_SUPPORT
if (codec) {
stream.rewind();
codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- SkDELETE(codec);
+ delete codec;
} else {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return SkNEW(ImageFilterFastBoundGM);)
-
+DEF_GM(return new ImageFilterFastBoundGM;)
}
if (codec) {
stream.rewind();
codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- SkDELETE(codec);
+ delete codec;
} else {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(FontCacheGM); )
+DEF_GM(return new FontCacheGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(FontMgrGM); )
-DEF_GM( return SkNEW(FontMgrMatchGM); )
-DEF_GM( return SkNEW(FontMgrBoundsGM(1.0, 0)); )
-DEF_GM( return SkNEW(FontMgrBoundsGM(0.75, 0)); )
-DEF_GM( return SkNEW(FontMgrBoundsGM(1.0, -0.25)); )
+DEF_GM(return new FontMgrGM;)
+DEF_GM(return new FontMgrMatchGM;)
+DEF_GM(return new FontMgrBoundsGM(1.0, 0);)
+DEF_GM(return new FontMgrBoundsGM(0.75, 0);)
+DEF_GM(return new FontMgrBoundsGM(1.0, -0.25);)
#ifdef SK_BUILD_FOR_WIN
- DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); )
+DEF_GM(return new FontMgrGM(SkFontMgr_New_DirectWrite());)
#endif
fDoRotate = doRotate;
}
- virtual ~GiantBitmapGM() {
- SkDELETE(fBM);
- }
+ virtual ~GiantBitmapGM() { delete fBM; }
protected:
static skiagm::GMRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
// See colorwheel.cpp for example usage.
-#define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \
- static void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas* CANVAS); \
- DEF_GM( return SkNEW_ARGS(skiagm::SimpleGM, \
- (SkString(#NAME), \
- SK_MACRO_CONCAT(NAME, _GM), \
- SkISize::Make(W, H))); ) \
- void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas* CANVAS)
+#define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \
+ static void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS); \
+ DEF_GM(return new skiagm::SimpleGM(SkString(#NAME), SK_MACRO_CONCAT(NAME, _GM), \
+ SkISize::Make(W, H));) \
+ void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas * CANVAS)
namespace skiagm {
ColorPos() : fColors(NULL), fPos(NULL), fCount(0) {}
~ColorPos() {
- SkDELETE_ARRAY(fColors);
- SkDELETE_ARRAY(fPos);
+ delete[] fColors;
+ delete[] fPos;
}
void construct(const SkColor colors[], const SkScalar pos[], int count) {
- fColors = SkNEW_ARRAY(SkColor, count);
+ fColors = new SkColor[count];
memcpy(fColors, colors, count * sizeof(SkColor));
if (pos) {
- fPos = SkNEW_ARRAY(SkScalar, count);
+ fPos = new SkScalar[count];
memcpy(fPos, pos, count * sizeof(SkScalar));
fPos[0] = 0;
fPos[count - 1] = 1;
///////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(GradientsNoTextureGM));
-DEF_GM( return SkNEW(GradientsManyColorsGM));
+DEF_GM(return new GradientsNoTextureGM);
+DEF_GM(return new GradientsManyColorsGM);
FailImageFilter::GetFlattenableType());
}
};
- static FailImageFilter* Create() {
- return SkNEW(FailImageFilter);
- }
+ static FailImageFilter* Create() { return new FailImageFilter; }
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
}
};
static IdentityImageFilter* Create(SkImageFilter* input = NULL) {
- return SkNEW_ARGS(IdentityImageFilter, (input));
+ return new IdentityImageFilter(input);
}
SK_TO_STRING_OVERRIDE()
}
};
static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input) {
- return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input));
+ return new SimpleOffsetFilter(dx, dy, input);
}
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(ImageFromYUVTextures); )
+DEF_GM(return new ImageFromYUVTextures;)
}
#endif
//////////////////////////////////////////////////////////////////////////////
-static GM* MyFactory(void*) { return SkNEW(InternalLinksGM); }
+static GM* MyFactory(void*) { return new InternalLinksGM; }
static GMRegistry reg(MyFactory);
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(LargeGlyphBlur); )
+DEF_GM(return new LargeGlyphBlur;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(LerpXfermodeGM); )
+DEF_GM(return new LerpXfermodeGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(ImageLightingGM); )
-
+DEF_GM(return new ImageLightingGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(LightingShaderGM); )
-
+DEF_GM(return new LightingShaderGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(LumaFilterGM); )
+DEF_GM(return new LumaFilterGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(MixedTextBlobsGM); )
+DEF_GM(return new MixedTextBlobsGM;)
}
SkIntToScalar(checkSize), SkIntToScalar(checkSize));
canvas.drawRect(rect1, paint);
canvas.drawRect(rect0, paint);
- return SkNEW_ARGS(SkBitmapProcShader, (bmp, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode));
+ return new SkBitmapProcShader(bmp, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
class ModeColorFilterGM : public GM {
class ComposeStep {
public:
ComposeStep() : fSurf(NULL), fX(0.0f), fY(0.0f), fPaint(NULL) { }
- ~ComposeStep() { SkSafeUnref(fSurf); SkDELETE(fPaint); }
+ ~ComposeStep() {
+ SkSafeUnref(fSurf);
+ delete fPaint;
+ }
SkSurface* fSurf;
SkScalar fX;
step.fX = SkIntToScalar(x*kTileWidth);
step.fY = SkIntToScalar(y*kTileHeight);
- step.fPaint = SkNEW(SkPaint);
+ step.fPaint = new SkPaint;
step.fPaint->setColorFilter(
SkColorFilter::CreateModeFilter(colors[x][y], SkXfermode::kModulate_Mode))->unref();
typedef GM INHERITED;
};
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kNoClipSingle_Content,
- MultiPictureDraw::kSimple_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRectClipMulti_Content,
- MultiPictureDraw::kSimple_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRRectClipMulti_Content,
- MultiPictureDraw::kSimple_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti_Content,
- MultiPictureDraw::kSimple_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMulti_Content,
- MultiPictureDraw::kSimple_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Content,
- MultiPictureDraw::kSimple_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Content,
- MultiPictureDraw::kSimple_Layout));)
-
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kNoClipSingle_Content,
- MultiPictureDraw::kTiled_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRectClipMulti_Content,
- MultiPictureDraw::kTiled_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kRRectClipMulti_Content,
- MultiPictureDraw::kTiled_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti_Content,
- MultiPictureDraw::kTiled_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMulti_Content,
- MultiPictureDraw::kTiled_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Content,
- MultiPictureDraw::kTiled_Layout));)
- DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Content,
- MultiPictureDraw::kTiled_Layout));)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kNoClipSingle_Content,
+ MultiPictureDraw::kSimple_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRectClipMulti_Content,
+ MultiPictureDraw::kSimple_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRRectClipMulti_Content,
+ MultiPictureDraw::kSimple_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content,
+ MultiPictureDraw::kSimple_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Content,
+ MultiPictureDraw::kSimple_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content,
+ MultiPictureDraw::kSimple_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content,
+ MultiPictureDraw::kSimple_Layout);)
+
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kNoClipSingle_Content,
+ MultiPictureDraw::kTiled_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRectClipMulti_Content,
+ MultiPictureDraw::kTiled_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kRRectClipMulti_Content,
+ MultiPictureDraw::kTiled_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content,
+ MultiPictureDraw::kTiled_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Content,
+ MultiPictureDraw::kTiled_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content,
+ MultiPictureDraw::kTiled_Layout);)
+ DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content,
+ MultiPictureDraw::kTiled_Layout);)
}
typedef GM INHERITED;
};
-DEF_GM(return SkNEW(SkPatchGM); )
-
+DEF_GM(return new SkPatchGM;)
}
typedef GM INHERITED;
};
-DEF_GM(return SkNEW(SkPatchGridGM); )
-
+DEF_GM(return new SkPatchGridGM;)
}
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(PeekPixelsGM); )
+DEF_GM(return new PeekPixelsGM;)
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(PictureGM); )
+DEF_GM(return new PictureGM;)
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(PictureGeneratorGM); )
+DEF_GM(return new PictureGeneratorGM;)
typedef GM INHERITED;
};
-DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
+DEF_GM(return new PictureShaderGM(50, 100);)
DEF_SIMPLE_GM(tiled_picture_shader, canvas, 400, 400) {
// https://code.google.com/p/skia/issues/detail?id=3398
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(PictureShaderTileGM); )
+DEF_GM(return new PictureShaderTileGM;)
};
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(PointSnapGM); )
-DEF_GM( return SkNEW(LineSnapGM); )
-DEF_GM( return SkNEW(RectSnapGM); )
-DEF_GM( return SkNEW(ComboSnapGM); )
+DEF_GM(return new PointSnapGM;)
+DEF_GM(return new LineSnapGM;)
+DEF_GM(return new RectSnapGM;)
+DEF_GM(return new ComboSnapGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(SmallArcGM); )
-
+DEF_GM(return new SmallArcGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return SkNEW(StrokeFillGM);)
-
+DEF_GM(return new StrokeFillGM;)
}
static skiagm::GMRegistry R3(F3);
static skiagm::GMRegistry R4(F4);
-DEF_GM( return SkNEW(ZeroLenStrokesGM); )
+DEF_GM( return new ZeroLenStrokesGM; )
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(StrokeTextGM); )
+DEF_GM(return new StrokeTextGM;)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return SkNEW(TallStretchedBitmapsGM);)
-
+DEF_GM(return new TallStretchedBitmapsGM;)
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW_ARGS(TextBlobGM, ("hamburgefons")); )
+DEF_GM(return new TextBlobGM("hamburgefons");)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TextBlobColorTrans); )
+DEF_GM(return new TextBlobColorTrans;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TextBlobGeometryChange); )
+DEF_GM(return new TextBlobGeometryChange;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TextBlobLooperGM); )
+DEF_GM(return new TextBlobLooperGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW_ARGS(TextBlobMixedSizes, (false)); )
+DEF_GM( return new TextBlobMixedSizes(false); )
#if SK_SUPPORT_GPU
-DEF_GM( return SkNEW_ARGS(TextBlobMixedSizes, (true)); )
+DEF_GM( return new TextBlobMixedSizes(true); )
#endif
}
if (NULL == orig) {
orig.reset(SkTypeface::RefDefault());
}
- SkAutoTUnref<SkTypeface> random(SkNEW_ARGS(SkRandomTypeface, (orig, paint, false)));
+ SkAutoTUnref<SkTypeface> random(new SkRandomTypeface(orig, paint, false));
paint.setTypeface(random);
SkRect bounds;
const char* emojiText = sk_tool_utils::emoji_sample_text();
paint.measureText(emojiText, strlen(emojiText), &bounds);
offset += bounds.height();
- SkAutoTUnref<SkTypeface> randomEmoji(SkNEW_ARGS(SkRandomTypeface, (orig, paint,
- false)));
+ SkAutoTUnref<SkTypeface> randomEmoji(new SkRandomTypeface(orig, paint, false));
paint.setTypeface(randomEmoji);
sk_tool_utils::add_to_text_blob(&builder, emojiText, paint, 0, offset);
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TextBlobRandomFont); )
+DEF_GM(return new TextBlobRandomFont;)
}
#endif
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW_ARGS(TextBlobShaderGM, ("Blobber")); )
+DEF_GM(return new TextBlobShaderGM("Blobber");)
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TextBlobTransforms); )
+DEF_GM(return new TextBlobTransforms;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TextBlobUseAfterGpuFree); )
+DEF_GM(return new TextBlobUseAfterGpuFree;)
}
#endif
const SkScalar TextureDomainEffect::kDrawPad = 10.f;
const SkScalar TextureDomainEffect::kTestPad = 10.f;
-DEF_GM( return SkNEW(TextureDomainEffect); )
+DEF_GM(return new TextureDomainEffect;)
}
#endif
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(ThinStrokedRectsGM); )
-
+DEF_GM(return new ThinStrokedRectsGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM(return SkNEW(TiledScaledBitmapGM);)
-
+DEF_GM(return new TiledScaledBitmapGM;)
}
//////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW(TileImageFilterGM); )
-
+DEF_GM(return new TileImageFilterGM;)
}
typedef skiagm::GM INHERITED;
};
-DEF_GM( return SkNEW(VariedTextGM(false, false)); )
-DEF_GM( return SkNEW(VariedTextGM(true, false)); )
-DEF_GM( return SkNEW(VariedTextGM(false, true)); )
-DEF_GM( return SkNEW(VariedTextGM(true, true)); )
+DEF_GM(return new VariedTextGM(false, false);)
+DEF_GM(return new VariedTextGM(true, false);)
+DEF_GM(return new VariedTextGM(false, true);)
+DEF_GM(return new VariedTextGM(true, true);)
/////////////////////////////////////////////////////////////////////////////////////
-DEF_GM( return SkNEW_ARGS(VerticesGM, (0xFF)); )
-DEF_GM( return SkNEW_ARGS(VerticesGM, (0x80)); )
+DEF_GM(return new VerticesGM(0xFF);)
+DEF_GM(return new VerticesGM(0x80);)
typedef GM INHERITED;
};
-DEF_GM( return SkNEW(YUVtoRGBEffect); )
+DEF_GM(return new YUVtoRGBEffect;)
}
#endif
virtual ~SkAnnotation();
static SkAnnotation* Create(const char key[], SkData* value) {
- return SkNEW_ARGS(SkAnnotation, (key, value));
+ return new SkAnnotation(key, value);
}
- static SkAnnotation* Create(SkReadBuffer& buffer) {
- return SkNEW_ARGS(SkAnnotation, (buffer));
- }
+ static SkAnnotation* Create(SkReadBuffer& buffer) { return new SkAnnotation(buffer); }
/**
* Return the data for the specified key, or NULL.
// This macro defines the global creation entry point for each decoder. Each
// decoder implementation that registers with the decoder factory must call it.
-#define DEFINE_DECODER_CREATOR(codec) \
- SkImageDecoder *Create ## codec () { \
- return SkNEW( Sk ## codec ); \
- }
+#define DEFINE_DECODER_CREATOR(codec) \
+ SkImageDecoder* Create##codec() { return new Sk##codec; }
// All the decoders known by Skia. Note that, depending on the compiler settings,
// not all of these will be available
// This macro defines the global creation entry point for each encoder. Each
// encoder implementation that registers with the encoder factory must call it.
-#define DEFINE_ENCODER_CREATOR(codec) \
- SkImageEncoder *Create ## codec () { \
- return SkNEW( Sk ## codec ); \
- }
+#define DEFINE_ENCODER_CREATOR(codec) \
+ SkImageEncoder* Create##codec() { return new Sk##codec; }
// All the encoders known by Skia. Note that, depending on the compiler settings,
// not all of these will be available
* Example usage:
*
* Foo* GetSingletonFoo() {
- * SK_DECLARE_STATIC_LAZY_PTR(Foo, singleton); // Created with SkNEW, destroyed with SkDELETE.
+ * SK_DECLARE_STATIC_LAZY_PTR(Foo, singleton); // Created with new, destroyed with delete.
* return singleton.get();
* }
*
* These macros take an optional T* (*Create)() and void (*Destroy)(T*) at the end.
- * If not given, we'll use SkNEW and SkDELETE.
+ * If not given, we'll use new and delete.
* These options are most useful when T doesn't have a public constructor or destructor.
* Create comes first, so you may use a custom Create with a default Destroy, but not vice versa.
*
}
}
-template <typename T> T* sk_new() { return SkNEW(T); }
-template <typename T> void sk_delete(T* ptr) { SkDELETE(ptr); }
+template <typename T>
+T* sk_new() {
+ return new T;
+}
+template <typename T>
+void sk_delete(T* ptr) {
+ delete ptr;
+}
// We're basing these implementations here on this article:
// http://preshing.com/20140709/the-purpose-of-memory_order_consume-in-cpp11/
T* fPtr;
};
-template <typename T> T* sk_new_arg(int i) { return SkNEW_ARGS(T, (i)); }
+template <typename T>
+T* sk_new_arg(int i) {
+ return new T(i);
+}
// This has no constructor and must be zero-initalized (the macro above does this).
template <typename T, int N, T* (*Create)(int) = sk_new_arg<T>, void (*Destroy)(T*) = sk_delete<T> >
T* get() const {
T* ptr = Private::consume_load(&fPtr);
- return ptr ? ptr : Private::try_cas<T*, Destroy>(&fPtr, SkNEW(T));
+ return ptr ? ptr : Private::try_cas<T*, Destroy>(&fPtr, new T);
}
template <typename Create>
and decremented in the destructor.
*/
static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
- return SkNEW_ARGS(SkComposePathEffect, (outer, inner));
+ return new SkComposePathEffect(outer, inner);
}
virtual bool filterPath(SkPath* dst, const SkPath& src,
and decremented in the destructor.
*/
static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
- return SkNEW_ARGS(SkSumPathEffect, (first, second));
+ return new SkSumPathEffect(first, second);
}
virtual bool filterPath(SkPath* dst, const SkPath& src,
*/
virtual void internal_dispose() const {
this->internal_dispose_restore_refcnt_to_1();
- SkDELETE(this);
+ delete this;
}
// The following friends are those which override internal_dispose()
void ref() const { (void)sk_atomic_fetch_add(&fRefCnt, +1, sk_memory_order_relaxed); }
void unref() const {
if (1 == sk_atomic_fetch_add(&fRefCnt, -1, sk_memory_order_acq_rel)) {
- SkDEBUGCODE(fRefCnt = 1;) // restore the 1 for our destructor's assert
- SkDELETE((const Derived*)this);
+ SkDEBUGCODE(fRefCnt = 1;) // restore the 1 for our destructor's assert
+ delete (const Derived*)this;
}
}
void deref() const { this->unref(); }
template<typename T>
inline void copy(SkTArray<T, false>* self, int dst, int src) {
- SkNEW_PLACEMENT_ARGS(&self->fItemArray[dst], T, (self->fItemArray[src]));
+ new (&self->fItemArray[dst]) T(self->fItemArray[src]);
}
template<typename T>
inline void copy(SkTArray<T, false>* self, const T* array) {
for (int i = 0; i < self->fCount; ++i) {
- SkNEW_PLACEMENT_ARGS(self->fItemArray + i, T, (array[i]));
+ new (self->fItemArray + i) T(array[i]);
}
}
template<typename T>
inline void copyAndDelete(SkTArray<T, false>* self, char* newMemArray) {
for (int i = 0; i < self->fCount; ++i) {
- SkNEW_PLACEMENT_ARGS(newMemArray + sizeof(T) * i, T, (self->fItemArray[i]));
+ new (newMemArray + sizeof(T) * i) T(self->fItemArray[i]);
self->fItemArray[i].~T();
}
}
this->checkRealloc(n);
fCount = n;
for (int i = 0; i < fCount; ++i) {
- SkNEW_PLACEMENT(fItemArray + i, T);
+ new (fItemArray + i) T;
}
}
*/
T& push_back() {
T* newT = reinterpret_cast<T*>(this->push_back_raw(1));
- SkNEW_PLACEMENT(newT, T);
+ new (newT) T;
return *newT;
}
*/
T& push_back(const T& t) {
T* newT = reinterpret_cast<T*>(this->push_back_raw(1));
- SkNEW_PLACEMENT_ARGS(newT, T, (t));
+ new (newT) T(t);
return *newT;
}
SkASSERT(n >= 0);
T* newTs = reinterpret_cast<T*>(this->push_back_raw(n));
for (int i = 0; i < n; ++i) {
- SkNEW_PLACEMENT(newTs + i, T);
+ new (newTs + i) T;
}
return newTs;
}
SkASSERT(n >= 0);
T* newTs = reinterpret_cast<T*>(this->push_back_raw(n));
for (int i = 0; i < n; ++i) {
- SkNEW_PLACEMENT_ARGS(newTs[i], T, (t));
+ new (newTs[i]) T(t);
}
return newTs;
}
SkASSERT(n >= 0);
this->checkRealloc(n);
for (int i = 0; i < n; ++i) {
- SkNEW_PLACEMENT_ARGS(fItemArray + fCount + i, T, (t[i]));
+ new (fItemArray + fCount + i) T(t[i]);
}
fCount += n;
return fItemArray + fCount - n;
T* iter = fArray;
T* stop = fArray + fCount;
while (iter < stop) {
- SkDELETE (*iter);
+ delete *iter;
iter += 1;
}
this->reset();
public:
virtual ~LocalizedStrings() { }
virtual bool next(LocalizedString* localizedString) = 0;
- void unref() { SkDELETE(this); }
+ void unref() { delete this; }
};
/**
* Returns an iterator which will attempt to enumerate all of the
*/
static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase,
Style style) {
- return SkNEW_ARGS(SkPath1DPathEffect, (path, advance, phase, style));
+ return new SkPath1DPathEffect(path, advance, phase, style);
}
virtual bool filterPath(SkPath*, const SkPath&,
class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
public:
static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
- return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
+ return new SkLine2DPathEffect(width, matrix);
}
virtual bool filterPath(SkPath* dst, const SkPath& src,
* the latice.
*/
static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
- return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
+ return new SkPath2DPathEffect(matrix, path);
}
SK_TO_STRING_OVERRIDE()
if (radius <= 0) {
return NULL;
}
- return SkNEW_ARGS(SkArcToPathEffect, (radius));
+ return new SkArcToPathEffect(radius);
}
bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
class SK_API SkBitmapSource : public SkImageFilter {
public:
- static SkBitmapSource* Create(const SkBitmap& bitmap) {
- return SkNEW_ARGS(SkBitmapSource, (bitmap));
- }
+ static SkBitmapSource* Create(const SkBitmap& bitmap) { return new SkBitmapSource(bitmap); }
static SkBitmapSource* Create(const SkBitmap& bitmap,
const SkRect& srcRect, const SkRect& dstRect,
SkFilterQuality filterQuality = kHigh_SkFilterQuality) {
- return SkNEW_ARGS(SkBitmapSource, (bitmap, srcRect, dstRect, filterQuality));
+ return new SkBitmapSource(bitmap, srcRect, dstRect, filterQuality);
}
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
static SkBlurDrawLooper* Create(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy,
uint32_t flags = kNone_BlurFlag) {
- return SkNEW_ARGS(SkBlurDrawLooper, (color, sigma, dx, dy, flags));
+ return new SkBlurDrawLooper(color, sigma, dx, dy, flags);
}
virtual ~SkBlurDrawLooper();
SkScalar sigmaY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
- return SkNEW_ARGS(SkBlurImageFilter, (sigmaX, sigmaY, input, cropRect));
+ return new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect);
}
void computeFastBounds(const SkRect&, SkRect*) const override;
class SK_API SkColorMatrixFilter : public SkColorFilter {
public:
static SkColorMatrixFilter* Create(const SkColorMatrix& cm) {
- return SkNEW_ARGS(SkColorMatrixFilter, (cm));
+ return new SkColorMatrixFilter(cm);
}
static SkColorMatrixFilter* Create(const SkScalar array[20]) {
- return SkNEW_ARGS(SkColorMatrixFilter, (array));
+ return new SkColorMatrixFilter(array);
}
void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
return SkRef(outer);
}
SkImageFilter* inputs[2] = { outer, inner };
- return SkNEW_ARGS(SkComposeImageFilter, (inputs));
+ return new SkComposeImageFilter(inputs);
}
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
/** radius must be > 0 to have an effect. It specifies the distance from each corner
that should be "rounded".
*/
- static SkCornerPathEffect* Create(SkScalar radius) {
- return SkNEW_ARGS(SkCornerPathEffect, (radius));
- }
+ static SkCornerPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); }
virtual ~SkCornerPathEffect();
virtual bool filterPath(SkPath* dst, const SkPath& src,
*/
static SkDashPathEffect* Create(const SkScalar intervals[], int count,
SkScalar phase) {
- return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase));
+ return new SkDashPathEffect(intervals, count, phase);
}
virtual ~SkDashPathEffect();
static SkDiscretePathEffect* Create(SkScalar segLength,
SkScalar deviation,
uint32_t seedAssist=0) {
- return SkNEW_ARGS(SkDiscretePathEffect,
- (segLength, deviation, seedAssist));
+ return new SkDiscretePathEffect(segLength, deviation, seedAssist);
}
virtual bool filterPath(SkPath* dst, const SkPath& src,
ShadowMode shadowMode,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
- return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY, color,
- shadowMode, input, cropRect));
+ return new SkDropShadowImageFilter(dx, dy, sigmaX, sigmaY, color, shadowMode, input,
+ cropRect);
}
void computeFastBounds(const SkRect&, SkRect*) const override;
const CropRect* cropRect = NULL) {
SkImageFilter* inputs[2] = { first, second };
SkXfermode::Mode modes[2] = { mode, mode };
- return SkNEW_ARGS(SkMergeImageFilter, (inputs, 2, modes, cropRect));
+ return new SkMergeImageFilter(inputs, 2, modes, cropRect);
}
static SkMergeImageFilter* Create(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[] = NULL,
const CropRect* cropRect = NULL) {
- return SkNEW_ARGS(SkMergeImageFilter, (filters, count, modes, cropRect));
+ return new SkMergeImageFilter(filters, count, modes, cropRect);
}
SK_TO_STRING_OVERRIDE()
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
- return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect));
+ return new SkDilateImageFilter(radiusX, radiusY, input, cropRect);
}
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
- return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect));
+ return new SkErodeImageFilter(radiusX, radiusY, input, cropRect);
}
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) {
return NULL;
}
- return SkNEW_ARGS(SkOffsetImageFilter, (dx, dy, input, cropRect));
+ return new SkOffsetImageFilter(dx, dy, input, cropRect);
}
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
SK_TO_STRING_OVERRIDE()
* Refs the passed-in picture.
*/
static SkPictureImageFilter* Create(const SkPicture* picture) {
- return SkNEW_ARGS(SkPictureImageFilter, (picture));
+ return new SkPictureImageFilter(picture);
}
/**
* the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
*/
static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
- return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect,
- kDeviceSpace_PictureResolution,
- kLow_SkFilterQuality));
+ return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureResolution,
+ kLow_SkFilterQuality);
}
/**
static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture,
const SkRect& cropRect,
SkFilterQuality filterQuality) {
- return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect,
- kLocalSpace_PictureResolution, filterQuality));
+ return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureResolution,
+ filterQuality);
}
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
*/
class SK_API SkPixelXorXfermode : public SkXfermode {
public:
- static SkPixelXorXfermode* Create(SkColor opColor) {
- return SkNEW_ARGS(SkPixelXorXfermode, (opColor));
- }
+ static SkPixelXorXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); }
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max);
static SkTableMaskFilter* Create(const uint8_t table[256]) {
- return SkNEW_ARGS(SkTableMaskFilter, (table));
+ return new SkTableMaskFilter(table);
}
static SkTableMaskFilter* CreateGamma(SkScalar gamma) {
uint8_t table[256];
MakeGammaTable(table, gamma);
- return SkNEW_ARGS(SkTableMaskFilter, (table));
+ return new SkTableMaskFilter(table);
}
static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) {
uint8_t table[256];
MakeClipTable(table, min, max);
- return SkNEW_ARGS(SkTableMaskFilter, (table));
+ return new SkTableMaskFilter(table);
}
SkMask::Format getFormat() const override;
if (scale > SK_Scalar1 || scale <= 0) {
return NULL;
}
- return SkNEW_ARGS(SkDownSampleImageFilter, (scale, input));
+ return new SkDownSampleImageFilter(scale, input);
}
SK_TO_STRING_OVERRIDE()
SkImageFilter* foreground = NULL,
const CropRect* cropRect = NULL) {
SkImageFilter* inputs[2] = { background, foreground };
- return SkNEW_ARGS(SkXfermodeImageFilter, (mode, inputs, cropRect));
+ return new SkXfermodeImageFilter(mode, inputs, cropRect);
}
SK_TO_STRING_OVERRIDE()
fCoverageStages = paint.fCoverageStages;
fXPFactory.reset(SkRef(paint.getXPFactory()));
- fProcDataManager.reset(SkNEW_ARGS(GrProcessorDataManager, (*paint.processorDataManager())));
+ fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataManager()));
return *this;
}
--fRefCnt;
if (0 == fRefCnt) {
if (0 == fPendingExecutions) {
- SkDELETE(this);
+ delete this;
return;
} else {
this->removeRefs();
--fPendingExecutions;
if (0 == fPendingExecutions) {
if (0 == fRefCnt) {
- SkDELETE(this);
+ delete this;
return;
} else {
this->pendingIOComplete();
static const int kInputModeCnt = kLastInputMode + 1;
static GrFragmentProcessor* Create(GrColor color, InputMode mode) {
- return SkNEW_ARGS(GrConstColorProcessor, (color, mode));
+ return new GrConstColorProcessor(color, mode);
}
~GrConstColorProcessor() override {}
*/
class SK_API GrGLExtensions {
public:
- GrGLExtensions() : fInitialized(false), fStrings(SkNEW(SkTArray<SkString>)) {}
+ GrGLExtensions() : fInitialized(false), fStrings(new SkTArray<SkString>) {}
GrGLExtensions(const GrGLExtensions&);
if (kGL_GrGLStandard == forcedGpuAPI) {
return NULL;
}
- SkANGLEGLContext* ctx = SkNEW(SkANGLEGLContext);
+ SkANGLEGLContext* ctx = new SkANGLEGLContext;
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
SkFunction() {}
template <typename Fn>
- SkFunction(const Fn& fn) : fFunction(SkNEW_ARGS(LambdaImpl<Fn>, (fn))) {}
+ SkFunction(const Fn& fn)
+ : fFunction(new LambdaImpl<Fn>(fn)) {}
- SkFunction(R (*fn)(Args...)) : fFunction(SkNEW_ARGS(FnPtrImpl, (fn))) {}
+ SkFunction(R (*fn)(Args...)) : fFunction(new FnPtrImpl(fn)) {}
SkFunction(const SkFunction& other) { *this = other; }
SkFunction& operator=(const SkFunction& other) {
LambdaImpl(const Fn& fn) : fFn(fn) {}
R call(Args... args) const override { return fFn(skstd::forward<Args>(args)...); }
- Interface* clone() const override { return SkNEW_ARGS(LambdaImpl<Fn>, (fFn)); }
+ Interface* clone() const override { return new LambdaImpl<Fn>(fFn); }
+
private:
Fn fFn;
};
FnPtrImpl(R (*fn)(Args...)) : fFn(fn) {}
R call(Args... args) const override { return fFn(skstd::forward<Args>(args)...); }
- Interface* clone() const override { return SkNEW_ARGS(FnPtrImpl, (fFn)); }
+ Interface* clone() const override { return new FnPtrImpl(fFn); }
+
private:
R (*fFn)(Args...);
};
// Clear the table.
void reset() {
this->~SkTHashTable();
- SkNEW_PLACEMENT(this, SkTHashTable);
+ new (this) SkTHashTable;
}
// How many entries are in the table?
template <typename T> class SkAutoTDelete : SkNoncopyable {
public:
SkAutoTDelete(T* obj = NULL) : fObj(obj) {}
- ~SkAutoTDelete() { SkDELETE(fObj); }
+ ~SkAutoTDelete() { delete fObj; }
T* get() const { return fObj; }
operator T*() const { return fObj; }
void reset(T* obj) {
if (fObj != obj) {
- SkDELETE(fObj);
+ delete fObj;
fObj = obj;
}
}
* Delete the owned object, setting the internal pointer to NULL.
*/
void free() {
- SkDELETE(fObj);
+ delete fObj;
fObj = NULL;
}
template <typename T> class SkAutoTDeleteArray : SkNoncopyable {
public:
SkAutoTDeleteArray(T array[]) : fArray(array) {}
- ~SkAutoTDeleteArray() { SkDELETE_ARRAY(fArray); }
+ ~SkAutoTDeleteArray() { delete[] fArray; }
T* get() const { return fArray; }
- void free() { SkDELETE_ARRAY(fArray); fArray = NULL; }
+ void free() {
+ delete[] fArray;
+ fArray = NULL;
+ }
T* detach() { T* array = fArray; fArray = NULL; return array; }
void reset(T array[]) {
if (fArray != array) {
- SkDELETE_ARRAY(fArray);
+ delete[] fArray;
fArray = array;
}
}
SkASSERT(count >= 0);
fArray = NULL;
if (count) {
- fArray = SkNEW_ARRAY(T, count);
+ fArray = new T[count];
}
SkDEBUGCODE(fCount = count;)
}
/** Reallocates given a new count. Reallocation occurs even if new count equals old count.
*/
void reset(int count) {
- SkDELETE_ARRAY(fArray);
+ delete[] fArray;
SkASSERT(count >= 0);
fArray = NULL;
if (count) {
- fArray = SkNEW_ARRAY(T, count);
+ fArray = new T[count];
}
SkDEBUGCODE(fCount = count;)
}
- ~SkAutoTArray() {
- SkDELETE_ARRAY(fArray);
- }
+ ~SkAutoTArray() { delete[] fArray; }
/** Return the array of T elements. Will be NULL if count == 0
*/
iter = fArray;
T* stop = fArray + count;
while (iter < stop) {
- SkNEW_PLACEMENT(iter++, T);
+ new (iter++) T;
}
}
if (storage == obj) {
obj->~T();
} else {
- SkDELETE(obj);
+ delete obj;
}
}
* SkInPlaceDeleteCheck(obj, storage);
*/
template <typename T> T* SkInPlaceNewCheck(void* storage, size_t size) {
- return (sizeof(T) <= size) ? new (storage) T : SkNEW(T);
+ return (sizeof(T) <= size) ? new (storage) T : new T;
}
template <typename T, typename A1, typename A2, typename A3>
T* SkInPlaceNewCheck(void* storage, size_t size, const A1& a1, const A2& a2, const A3& a3) {
- return (sizeof(T) <= size) ? new (storage) T(a1, a2, a3) : SkNEW_ARGS(T, (a1, a2, a3));
+ return (sizeof(T) <= size) ? new (storage) T(a1, a2, a3) : new T(a1, a2, a3);
}
/**
}
if (kDestroyRequested_State == visualBenchState.fState) {
- SkDELETE(visualBenchState.fWindow);
+ delete visualBenchState.fWindow;
visualBenchState.fWindow = NULL;
application_term();
ANativeActivity_finish(state->activity);
SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) {
SkMatrix matrix;
buffer.readMatrix(&matrix);
- return SkNEW_ARGS(Dot2DPathEffect, (buffer.readScalar(), matrix, NULL));
+ return new Dot2DPathEffect(buffer.readScalar(), matrix, NULL);
}
class InverseFillPE : public SkPathEffect {
typedef SkPathEffect INHERITED;
};
-SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) {
- return SkNEW(InverseFillPE);
-}
+SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new InverseFillPE; }
static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) {
SkMatrix lattice;
}
SkEvent* GMSampleView::NewShowSizeEvt(bool doShowSize) {
- SkEvent* evt = SkNEW_ARGS(SkEvent, ("GMSampleView::showSize"));
+ SkEvent* evt = new SkEvent("GMSampleView::showSize");
evt->setFast32(doShowSize);
return evt;
}
};
SkView* create_overview(int count, const SkViewFactory* factories[]) {
- return SkNEW_ARGS(OverView, (count, factories));
+ return new OverView(count, factories);
}
bool is_overview(SkView* view) {
fSubpixelState != SkOSMenu::kMixedState ||
fHintingState > 0 ||
fFilterQualityIndex > 0) {
-
- canvas = SkNEW_ARGS(FlagsFilterCanvas, (canvas, fLCDState, fAAState, fSubpixelState,
- fHintingState, fFilterQualityIndex));
+ canvas = new FlagsFilterCanvas(canvas, fLCDState, fAAState, fSubpixelState, fHintingState,
+ fFilterQualityIndex);
fFlagsFilterCanvas.reset(canvas);
}
}
break;
case 'B':
- post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox")), curr_view(this));
+ post_event_to_sink(new SkEvent("PictFileView::toggleBBox"), curr_view(this));
// Cannot call updateTitle() synchronously, because the toggleBBox event is still in
// the queue.
- post_event_to_sink(SkNEW_ARGS(SkEvent, (gUpdateWindowTitleEvtName)), this);
+ post_event_to_sink(new SkEvent(gUpdateWindowTitleEvtName), this);
this->inval(NULL);
break;
case 'D':
fRect.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
fRect.offset(SkIntToScalar(20), SkIntToScalar(20));
- fAnimatingDrawable = SkNEW_ARGS(MyDrawable, (fRect));
+ fAnimatingDrawable = new MyDrawable(fRect);
SkPictureRecorder recorder;
this->drawRoot(recorder.beginRecording(SkRect::MakeWH(800, 500)));
void spawnAnimation(SkMSec now) {
this->setTime(now);
- SkDELETE(fInterp);
- fInterp = SkNEW_ARGS(SkInterpolator, (5, 3));
+ delete fInterp;
+ fInterp = new SkInterpolator(5, 3);
SkScalar values[5];
color_to_floats(fColor, values); values[4] = 0;
fInterp->setKeyFrame(0, now, values);
switch (res) {
case SkInterpolator::kFreezeEnd_Result:
- SkDELETE(fInterp);
+ delete fInterp;
fInterp = NULL;
break;
default:
if (codec) {
stream.rewind();
codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- SkDELETE(codec);
+ delete codec;
} else {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
public:
LuaView() : fLua(NULL) {}
- virtual ~LuaView() {
- SkDELETE(fLua);
- }
+ virtual ~LuaView() { delete fLua; }
void setImageFilename(lua_State* L) {
SkString str = GetResourcePath("mandrill_256.png");
lua_State* ensureLua() {
if (NULL == fLua) {
- fLua = SkNEW(SkLua);
+ fLua = new SkLua;
SkString str = GetResourcePath(LUA_FILENAME);
SkData* data = SkData::NewFromFileName(str.c_str());
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+
#ifdef SAMPLE_PDF_FILE_VIEWER
#include "SampleCode.h"
return NULL;
}
- SkPicture* pic = SkNEW(SkPicture);
+ SkPicture* pic = new SkPicture;
SkCanvas* canvas = pic->beginRecording((int) renderer->MediaBox(0).width(),
(int) renderer->MediaBox(0).height());
renderer->renderPage(0, canvas, renderer->MediaBox(0));
// no bbox playback necessary
return pic.detach();
case kRTree_BBoxType:
- factory.reset(SkNEW(SkRTreeFactory));
+ factory.reset(new SkRTreeFactory);
break;
default:
SkASSERT(false);
if (codec) {
stream.rewind();
codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- SkDELETE(codec);
+ delete codec;
} else {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
<!--?prettify?-->
~~~~
this->method();
-Memory Management
-~~~~
-
-All memory allocation should be routed through SkNEW and its variants. These are
-#defined in SkPostConfig.h, but the correct way to get access to the config
-system is to #include SkTypes.h, which will allow external users of the library
-to provide a custom memory manager or other adaptations.
-
-<!--?prettify?-->
-~~~~
-SkNEW(type_name)
-SkNEW_ARGS(type_name, args)
-SkNEW_ARRAY(type_name, count)
-SkNEW_PLACEMENT(buf, type_name)
-SkNEW_PLACEMENT_ARGS(buf, type_name, args)
-SkDELETE(obj)
-SkDELETE_ARRAY(array)
~~~~
Comparisons
void(*draw)(SkCanvas*),
const char* path) {
SkFILEWStream svgStream(path);
- SkAutoTDelete<SkXMLWriter> xmlWriter(SkNEW_ARGS(SkXMLStreamWriter, (&svgStream)));
+ SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(&svgStream));
SkAutoTUnref<SkCanvas> svgCanvas(SkSVGCanvas::Create(
SkRect::MakeWH(SkIntToScalar(src.size().width()),
SkIntToScalar(src.size().height())),
fState.setCount(animators);
int index;
for (index = 0; index < animators; index++)
- fInterpolators[index] = SkNEW(SkOperandInterpolator);
+ fInterpolators[index] = new SkOperandInterpolator;
initState(&fApply, 0);
// for (index = 0; index < animators; index++)
// fState[index].bumpSave();
fInterpolators.setCount(total);
memset(&fInterpolators.begin()[oldCount], 0, newCount * sizeof(SkOperandInterpolator*));
for (index = oldCount; index < total; index++)
- fInterpolators[index] = SkNEW(SkOperandInterpolator);
+ fInterpolators[index] = new SkOperandInterpolator;
fAnimators.setCount(total);
memcpy(&fAnimators[oldCount], animates.begin(), sizeof(fAnimators[0]) *
newCount);
fValues.setType(outType);
fValues.setCount(comps);
if (outType == SkType_String || outType == SkType_DynamicString)
- fValues[0].fString = SkNEW(SkString);
+ fValues[0].fString = new SkString;
else
memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0]));
} else {
initialize();
}
-SkAnimator::~SkAnimator() {
- SkDELETE(fMaker);
-}
+SkAnimator::~SkAnimator() { delete fMaker; }
void SkAnimator::addExtras(SkExtras* extras) {
*fMaker->fExtras.append() = extras;
}
void SkAnimator::initialize() {
- SkDELETE(fMaker);
- fMaker = SkNEW_ARGS(SkAnimateMaker, (this, NULL, NULL));
+ delete fMaker;
+ fMaker = new SkAnimateMaker(this, NULL, NULL);
decodeMemory(gMathPrimer, sizeof(gMathPrimer)-1);
#ifdef SK_BUILD_FOR_ANDROID
InitializeSkExtraPathEffects(this);
} break;
case SkType_String: {
SkDisplayString* boxedValue = (SkDisplayString*) displayable;
- scriptValue->fOperand.fString = SkNEW_ARGS(SkString, (boxedValue->value));
+ scriptValue->fOperand.fString = new SkString(boxedValue->value);
} break;
default: {
const char* id = NULL;
SkDEBUGCODE(bool success = ) maker->findKey(displayable, &id);
SkASSERT(success);
- scriptValue->fOperand.fString = SkNEW_ARGS(SkString, (id));
+ scriptValue->fOperand.fString = new SkString(id);
type = SkType_String;
}
}
} break;
case SkType_String: {
SkDisplayString* boxedValue = (SkDisplayString*) displayable;
- operand->fString = SkNEW_ARGS(SkString, (boxedValue->value));
+ operand->fString = new SkString(boxedValue->value);
} break;
default: {
const char* id;
bool success = fEngine->getMaker().findKey(displayable, &id);
SkASSERT(success);
- operand->fString = SkNEW_ARGS(SkString, (id));
+ operand->fString = new SkString(id);
}
}
return true;
break;
case kAddString:
if (fTrackString.find(operand1.fString) < 0) {
- operand1.fString = SkNEW_ARGS(SkString, (*operand1.fString));
+ operand1.fString = new SkString(*operand1.fString);
track(operand1.fString);
}
operand1.fString->append(*operand2.fString);
break;
case SkScriptEngine2::kAddString:
// if (fTrackString.find(operand[1].fString) < 0) {
-// operand[1].fString = SkNEW_ARGS(SkString, (*operand[1].fString));
-// track(operand[1].fString);
-// }
+ // operand[1].fString = new SkString (*operand[1].fString);
+ // track(operand[1].fString);
+ // }
operand[0].fString->append(*operand[1].fString);
break;
case SkScriptEngine2::kBitAndInt:
//////////////////////////////////////////////////////////////////////////////////////////////////
-sk_paint_t* sk_paint_new() {
- return (sk_paint_t*)SkNEW(SkPaint);
-}
+sk_paint_t* sk_paint_new() { return (sk_paint_t*)new SkPaint; }
-void sk_paint_delete(sk_paint_t* cpaint) {
- SkDELETE(AsPaint(cpaint));
-}
+void sk_paint_delete(sk_paint_t* cpaint) { delete AsPaint(cpaint); }
bool sk_paint_is_antialias(const sk_paint_t* cpaint) {
return AsPaint(*cpaint).isAntiAlias();
///////////////////////////////////////////////////////////////////////////////////////////
-sk_path_t* sk_path_new() {
- return (sk_path_t*)SkNEW(SkPath);
-}
+sk_path_t* sk_path_new() { return (sk_path_t*)new SkPath; }
-void sk_path_delete(sk_path_t* cpath) {
- SkDELETE(as_path(cpath));
-}
+void sk_path_delete(sk_path_t* cpath) { delete as_path(cpath); }
void sk_path_move_to(sk_path_t* cpath, float x, float y) {
as_path(cpath)->moveTo(x, y);
// Bmps embedded in Icos skip the first Bmp header
if (!inIco) {
// Read the first header and the size of the second header
- SkAutoTDeleteArray<uint8_t> hBuffer(
- SkNEW_ARRAY(uint8_t, kBmpHeaderBytesPlusFour));
+ SkAutoTDeleteArray<uint8_t> hBuffer(new uint8_t[kBmpHeaderBytesPlusFour]);
if (stream->read(hBuffer.get(), kBmpHeaderBytesPlusFour) !=
kBmpHeaderBytesPlusFour) {
SkCodecPrintf("Error: unable to read first bitmap header.\n");
offset = 0;
// Read the size of the second header
- SkAutoTDeleteArray<uint8_t> hBuffer(
- SkNEW_ARRAY(uint8_t, 4));
+ SkAutoTDeleteArray<uint8_t> hBuffer(new uint8_t[4]);
if (stream->read(hBuffer.get(), 4) != 4) {
SkCodecPrintf("Error: unable to read size of second bitmap header.\n");
return false;
const uint32_t infoBytesRemaining = infoBytes - 4;
// Read the second header
- SkAutoTDeleteArray<uint8_t> iBuffer(
- SkNEW_ARRAY(uint8_t, infoBytesRemaining));
+ SkAutoTDeleteArray<uint8_t> iBuffer(new uint8_t[infoBytesRemaining]);
if (stream->read(iBuffer.get(), infoBytesRemaining) != infoBytesRemaining) {
SkCodecPrintf("Error: unable to read second bitmap header.\n");
return false;
switch (headerType) {
case kInfoV1_BmpHeaderType: {
// The V1 header stores the bit masks after the header
- SkAutoTDeleteArray<uint8_t> mBuffer(
- SkNEW_ARRAY(uint8_t, kBmpMaskBytes));
+ SkAutoTDeleteArray<uint8_t> mBuffer(new uint8_t[kBmpMaskBytes]);
if (stream->read(mBuffer.get(), kBmpMaskBytes) !=
kBmpMaskBytes) {
SkCodecPrintf("Error: unable to read bit inputMasks.\n");
// Return the codec
switch (inputFormat) {
case kStandard_BmpInputFormat:
- *codecOut = SkNEW_ARGS(SkBmpStandardCodec, (imageInfo, stream,
- bitsPerPixel, numColors, bytesPerColor,
- offset - bytesRead, rowOrder, inIco));
+ *codecOut =
+ new SkBmpStandardCodec(imageInfo, stream, bitsPerPixel, numColors,
+ bytesPerColor, offset - bytesRead, rowOrder, inIco);
return true;
case kBitMask_BmpInputFormat:
// Bmp-in-Ico must be standard mode
return false;
}
- *codecOut = SkNEW_ARGS(SkBmpMaskCodec, (imageInfo, stream,
- bitsPerPixel, masks.detach(), rowOrder));
+ *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.detach(),
+ rowOrder);
return true;
case kRLE_BmpInputFormat:
// Bmp-in-Ico must be standard mode
// require that RLE Bmps have a valid number of totalBytes, and
// Icos skip the header that contains totalBytes.
SkASSERT(!inIco);
- *codecOut = SkNEW_ARGS(SkBmpRLECodec, (
- imageInfo, stream, bitsPerPixel, numColors,
- bytesPerColor, offset - bytesRead, rowOrder, RLEBytes));
+ *codecOut =
+ new SkBmpRLECodec(imageInfo, stream, bitsPerPixel, numColors, bytesPerColor,
+ offset - bytesRead, rowOrder, RLEBytes);
return true;
default:
SkASSERT(false);
bool SkBmpMaskCodec::initializeSwizzler(const SkImageInfo& dstInfo) {
// Allocate space for a row buffer
const size_t rowBytes = SkAlign4(compute_row_bytes(dstInfo.width(), this->bitsPerPixel()));
- fSrcBuffer.reset(SkNEW_ARRAY(uint8_t, rowBytes));
+ fSrcBuffer.reset(new uint8_t[rowBytes]);
// Create the swizzler
fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(
* Creates an instance of the decoder
* Called only by NewFromStream
*/
-SkBmpRLECodec::SkBmpRLECodec(const SkImageInfo& info, SkStream* stream,
- uint16_t bitsPerPixel, uint32_t numColors,
- uint32_t bytesPerColor, uint32_t offset,
- SkBmpCodec::RowOrder rowOrder, size_t RLEBytes)
+SkBmpRLECodec::SkBmpRLECodec(const SkImageInfo& info,
+ SkStream* stream,
+ uint16_t bitsPerPixel,
+ uint32_t numColors,
+ uint32_t bytesPerColor,
+ uint32_t offset,
+ SkBmpCodec::RowOrder rowOrder,
+ size_t RLEBytes)
: INHERITED(info, stream, bitsPerPixel, rowOrder)
, fColorTable(NULL)
, fNumColors(this->computeNumColors(numColors))
, fBytesPerColor(bytesPerColor)
, fOffset(offset)
- , fStreamBuffer(SkNEW_ARRAY(uint8_t, RLEBytes))
+ , fStreamBuffer(new uint8_t[RLEBytes])
, fRLEBytes(RLEBytes)
- , fCurrRLEByte(0)
-{}
+ , fCurrRLEByte(0) {}
/*
* Initiates the bitmap decode
// Read the color table from the stream
colorBytes = fNumColors * fBytesPerColor;
- SkAutoTDeleteArray<uint8_t> cBuffer(SkNEW_ARRAY(uint8_t, colorBytes));
+ SkAutoTDeleteArray<uint8_t> cBuffer(new uint8_t[colorBytes]);
if (stream()->read(cBuffer.get(), colorBytes) != colorBytes) {
SkCodecPrintf("Error: unable to read color table.\n");
return false;
}
// Set the color table
- fColorTable.reset(SkNEW_ARGS(SkColorTable, (colorTable, maxColors)));
+ fColorTable.reset(new SkColorTable(colorTable, maxColors));
}
// Check that we have not read past the pixel array offset
// Read the color table from the stream
colorBytes = fNumColors * fBytesPerColor;
- SkAutoTDeleteArray<uint8_t> cBuffer(SkNEW_ARRAY(uint8_t, colorBytes));
+ SkAutoTDeleteArray<uint8_t> cBuffer(new uint8_t[colorBytes]);
if (stream()->read(cBuffer.get(), colorBytes) != colorBytes) {
SkCodecPrintf("Error: unable to read color table.\n");
return false;
}
// Set the color table
- fColorTable.reset(SkNEW_ARGS(SkColorTable, (colorTable, maxColors)));
+ fColorTable.reset(new SkColorTable(colorTable, maxColors));
}
// Bmp-in-Ico files do not use an offset to indicate where the pixel data
const Options& opts) {
// Allocate space for a row buffer
const size_t rowBytes = SkAlign4(compute_row_bytes(dstInfo.width(), this->bitsPerPixel()));
- fSrcBuffer.reset(SkNEW_ARRAY(uint8_t, rowBytes));
+ fSrcBuffer.reset(new uint8_t[rowBytes]);
// Get swizzler configuration
SkSwizzler::SrcConfig config;
if (!data) {
return NULL;
}
- return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
+ return NewFromStream(new SkMemoryStream(data));
}
SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
// use kPremul directly even when kUnpremul is supported.
const SkImageInfo& imageInfo = SkImageInfo::Make(width, height,
kIndex_8_SkColorType, kPremul_SkAlphaType);
- *codecOut = SkNEW_ARGS(SkGifCodec, (imageInfo, streamDeleter.detach(), gif.detach()));
+ *codecOut = new SkGifCodec(imageInfo, streamDeleter.detach(), gif.detach());
} else {
SkASSERT(NULL != gifOut);
streamDeleter.detach();
}
// Stores output from dgiflib and input to the swizzler
- SkAutoTDeleteArray<uint8_t>
- buffer(SkNEW_ARRAY(uint8_t, innerWidth));
+ SkAutoTDeleteArray<uint8_t> buffer(new uint8_t[innerWidth]);
// Check the interlace flag and iterate over rows of the input
if (fGif->Image.Interlace) {
static const uint32_t kIcoDirEntryBytes = 16;
// Read the directory header
- SkAutoTDeleteArray<uint8_t> dirBuffer(
- SkNEW_ARRAY(uint8_t, kIcoDirectoryBytes));
+ SkAutoTDeleteArray<uint8_t> dirBuffer(new uint8_t[kIcoDirectoryBytes]);
if (inputStream.get()->read(dirBuffer.get(), kIcoDirectoryBytes) !=
kIcoDirectoryBytes) {
SkCodecPrintf("Error: unable to read ico directory header.\n");
}
// Ensure that we can read all of indicated directory entries
- SkAutoTDeleteArray<uint8_t> entryBuffer(
- SkNEW_ARRAY(uint8_t, numImages*kIcoDirEntryBytes));
+ SkAutoTDeleteArray<uint8_t> entryBuffer(new uint8_t[numImages * kIcoDirEntryBytes]);
if (inputStream.get()->read(entryBuffer.get(), numImages*kIcoDirEntryBytes) !=
numImages*kIcoDirEntryBytes) {
SkCodecPrintf("Error: unable to read ico directory entries.\n");
uint32_t offset;
uint32_t size;
};
- SkAutoTDeleteArray<Entry> directoryEntries(SkNEW_ARRAY(Entry, numImages));
+ SkAutoTDeleteArray<Entry> directoryEntries(new Entry[numImages]);
// Iterate over directory entries
for (uint32_t i = 0; i < numImages; i++) {
// Now will construct a candidate codec for each of the embedded images
uint32_t bytesRead = kIcoDirectoryBytes + numImages * kIcoDirEntryBytes;
SkAutoTDelete<SkTArray<SkAutoTDelete<SkCodec>, true>> codecs(
- SkNEW_ARGS((SkTArray<SkAutoTDelete<SkCodec>, true>), (numImages)));
+ new (SkTArray<SkAutoTDelete<SkCodec>, true>)(numImages));
for (uint32_t i = 0; i < numImages; i++) {
uint32_t offset = directoryEntries.get()[i].offset;
uint32_t size = directoryEntries.get()[i].size;
SkCodecPrintf("Warning: could not create embedded stream.\n");
break;
}
- SkAutoTDelete<SkMemoryStream>
- embeddedStream(SkNEW_ARGS(SkMemoryStream, (data.get())));
+ SkAutoTDelete<SkMemoryStream> embeddedStream(new SkMemoryStream(data.get()));
bytesRead += size;
// Check if the embedded codec is bmp or png and create the codec
// Note that stream is owned by the embedded codec, the ico does not need
// direct access to the stream.
- return SkNEW_ARGS(SkIcoCodec, (info, codecs.detach()));
+ return new SkIcoCodec(info, codecs.detach());
}
/*
*ctableCount = colorCount;
}
- fColorTable.reset(SkNEW_ARGS(SkColorTable, (colorStorage, colorCount)));
+ fColorTable.reset(new SkColorTable(colorStorage, colorCount));
return true;
}
SkImageInfo imageInfo;
int bitDepth;
if (read_header(stream, &png_ptr, &info_ptr, &imageInfo, &bitDepth)) {
- return SkNEW_ARGS(SkPngCodec, (imageInfo, streamDeleter.detach(),
- png_ptr, info_ptr, bitDepth));
+ return new SkPngCodec(imageInfo, streamDeleter.detach(), png_ptr, info_ptr, bitDepth);
}
return NULL;
}
const SkImageInfo& srcInfo = codec->getInfo();
if (codec->fNumberPasses > 1) {
// interlaced image
- return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (srcInfo, codec.detach()));
+ return new SkPngInterlacedScanlineDecoder(srcInfo, codec.detach());
}
- return SkNEW_ARGS(SkPngScanlineDecoder, (srcInfo, codec.detach()));
+ return new SkPngScanlineDecoder(srcInfo, codec.detach());
}
}
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(),
kGray_8_SkColorType, kOpaque_SkAlphaType);
- return SkNEW_ARGS(SkWbmpCodec, (info, streamDeleter.detach()));
+ return new SkWbmpCodec(info, streamDeleter.detach());
}
class SkWbmpScanlineDecoder : public SkScanlineDecoder {
// Copy the color table to a pointer that can be owned by the scanline decoder
if (kIndex_8_SkColorType == dstInfo.colorType()) {
- fColorTable.reset(SkNEW_ARGS(SkColorTable, (inputColorTable, 2)));
+ fColorTable.reset(new SkColorTable(inputColorTable, 2));
}
// Initialize the swizzler
}
// Return the new scanline decoder
- return SkNEW_ARGS(SkWbmpScanlineDecoder, (codec.detach()));
+ return new SkWbmpScanlineDecoder(codec.detach());
}
JpegDecoderMgr** decoderMgrOut) {
// Create a JpegDecoderMgr to own all of the decompress information
- SkAutoTDelete<JpegDecoderMgr> decoderMgr(SkNEW_ARGS(JpegDecoderMgr, (stream)));
+ SkAutoTDelete<JpegDecoderMgr> decoderMgr(new JpegDecoderMgr(stream));
// libjpeg errors will be caught and reported here
if (setjmp(decoderMgr->getJmpBuf())) {
// Create image info object and the codec
const SkImageInfo& imageInfo = SkImageInfo::Make(decoderMgr->dinfo()->image_width,
decoderMgr->dinfo()->image_height, colorType, kOpaque_SkAlphaType);
- *codecOut = SkNEW_ARGS(SkJpegCodec, (imageInfo, stream, decoderMgr.detach()));
+ *codecOut = new SkJpegCodec(imageInfo, stream, decoderMgr.detach());
} else {
SkASSERT(NULL != decoderMgrOut);
*decoderMgrOut = decoderMgr.detach();
const SkImageInfo& srcInfo = codec->getInfo();
// Return the new scanline decoder
- return SkNEW_ARGS(SkJpegScanlineDecoder, (srcInfo, codec.detach()));
+ return new SkJpegScanlineDecoder(srcInfo, codec.detach());
}
SkASSERT(false);
return NULL;
}
- return SkNEW_ARGS(SkMaskSwizzler, (info, masks, proc));
+ return new SkMaskSwizzler(info, masks, proc);
}
/*
const MaskInfo blue = process_mask(masks.blue, bitsPerPixel);
const MaskInfo alpha = process_mask(masks.alpha, bitsPerPixel);
- return SkNEW_ARGS(SkMasks, (red, green, blue, alpha));
+ return new SkMasks(red, green, blue, alpha);
}
}
// wrap in new SkScaledCodec
- return SkNEW_ARGS(SkScaledCodec, (scanlineDecoder.detach()));
+ return new SkScaledCodec(scanlineDecoder.detach());
}
SkCodec* SkScaledCodec::NewFromData(SkData* data) {
if (!data) {
return NULL;
}
- return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
+ return NewFromStream(new SkMemoryStream(data));
}
SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder)
if (!data) {
return NULL;
}
- return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
+ return NewFromStream(new SkMemoryStream(data));
}
// get sampleX based on srcInfo and dstInfo dimensions
int sampleX;
SkScaledCodec::ComputeSampleSize(dstInfo, srcInfo, &sampleX, NULL);
-
- return SkNEW_ARGS(SkSwizzler, (proc, ctable, deltaSrc, dstInfo, sampleX));
+
+ return new SkSwizzler(proc, ctable, deltaSrc, dstInfo, sampleX);
}
SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable,
SkAutoTDelete<SkStream> streamDeleter(stream);
SkImageInfo info;
if (webp_parse_header(stream, &info)) {
- return SkNEW_ARGS(SkWebpCodec, (info, streamDeleter.detach()));
+ return new SkWebpCodec(info, streamDeleter.detach());
}
return NULL;
}
SkBBoxHierarchy* SkRTreeFactory::operator()(const SkRect& bounds) const {
SkScalar aspectRatio = bounds.width() / bounds.height();
- return SkNEW_ARGS(SkRTree, (aspectRatio));
+ return new SkRTree(aspectRatio);
}
}
const SkBigPicture::Analysis& SkBigPicture::analysis() const {
- auto create = [&]() { return SkNEW_ARGS(Analysis, (*fRecord)); };
+ auto create = [&]() { return new Analysis(*fRecord); };
return *fAnalysis.get(create);
}
SkAutoTUnref<SkColorTable> ctable;
if (buffer->readBool()) {
- ctable.reset(SkNEW_ARGS(SkColorTable, (*buffer)));
+ ctable.reset(new SkColorTable(*buffer));
unsigned char maxIndex = ctable->count() ? ctable->count()-1 : 0;
for (uint64_t i = 0; i < ramSize; ++i) {
return;
}
SkASSERT(result.isImmutable());
- BitmapRec* rec = SkNEW_ARGS(BitmapRec, (src.getGenerationID(), invScaleX, invScaleY,
- get_bounds_from_bitmap(src), result));
+ BitmapRec* rec = new BitmapRec(src.getGenerationID(), invScaleX, invScaleY,
+ get_bounds_from_bitmap(src), result);
CHECK_LOCAL(localCache, add, Add, rec);
src.pixelRef()->notifyAddedToCache();
}
|| result.height() != subset.height()) {
return false;
} else {
- BitmapRec* rec = SkNEW_ARGS(BitmapRec, (pr->getGenerationID(), 1, 1, subset, result));
+ BitmapRec* rec = new BitmapRec(pr->getGenerationID(), 1, 1, subset, result);
CHECK_LOCAL(localCache, add, Add, rec);
pr->notifyAddedToCache();
void SkBitmapCache::Add(uint32_t genID, const SkBitmap& result, SkResourceCache* localCache) {
SkASSERT(result.isImmutable());
- BitmapRec* rec = SkNEW_ARGS(BitmapRec, (genID, 1, 1, SkIRect::MakeEmpty(), result));
+ BitmapRec* rec = new BitmapRec(genID, 1, 1, SkIRect::MakeEmpty(), result);
CHECK_LOCAL(localCache, add, Add, rec);
}
const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* localCache) {
SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
if (mipmap) {
- MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap));
+ MipMapRec* rec = new MipMapRec(src, mipmap);
CHECK_LOCAL(localCache, add, Add, rec);
src.pixelRef()->notifyAddedToCache();
}
}
}
- return SkNEW_ARGS(SkBitmapDevice, (bitmap, surfaceProps));
+ return new SkBitmapDevice(bitmap, surfaceProps);
}
SkImageInfo SkBitmapDevice::imageInfo() const {
SkBitmapFilter *SkBitmapFilter::Allocate() {
if (!strcmp(c_bitmapFilter, "mitchell")) {
- return SkNEW_ARGS(SkMitchellFilter,(1.f/3.f,1.f/3.f));
+ return new SkMitchellFilter(1.f / 3.f, 1.f / 3.f);
} else if (!strcmp(c_bitmapFilter, "lanczos")) {
- return SkNEW(SkLanczosFilter);
+ return new SkLanczosFilter;
} else if (!strcmp(c_bitmapFilter, "hamming")) {
- return SkNEW(SkHammingFilter);
+ return new SkHammingFilter;
} else if (!strcmp(c_bitmapFilter, "gaussian")) {
- return SkNEW_ARGS(SkGaussianFilter,(2));
+ return new SkGaussianFilter(2);
} else if (!strcmp(c_bitmapFilter, "triangle")) {
- return SkNEW(SkTriangleFilter);
+ return new SkTriangleFilter;
} else if (!strcmp(c_bitmapFilter, "box")) {
- return SkNEW(SkBoxFilter);
+ return new SkBoxFilter;
} else {
SkDEBUGFAIL("Unknown filter type");
}
if (index < 0) {
// insert ourselves into the bitmapIndex
index = ~index;
- *fLookupTable.insert(index) = SkNEW_ARGS(LookupEntry, (indexEntry));
+ *fLookupTable.insert(index) = new LookupEntry(indexEntry);
} else if (entry != NULL) {
// populate the entry if needed
*entry = fStorage[fLookupTable[index]->fStorageSlot];
// a new entry to the lookup table.
SkASSERT(count == fLookupTable.count());
fBytesAllocated -= fStorage[entry->fStorageSlot]->fBytesAllocated;
- SkDELETE(fLookupTable[index]);
+ delete fLookupTable[index];
fLookupTable.remove(index);
return index;
}
fUnusedSlots.pop(&slot);
entry = fStorage[slot];
} else {
- entry = SkNEW(SkBitmapHeapEntry);
+ entry = new SkBitmapHeapEntry;
fStorage.append(1, &entry);
entry->fSlot = fStorage.count() - 1;
fBytesAllocated += sizeof(SkBitmapHeapEntry);
// if the copy failed then we must abort
if (!copySucceeded) {
// delete the index
- SkDELETE(fLookupTable[searchIndex]);
+ delete fLookupTable[searchIndex];
fLookupTable.remove(searchIndex);
// If entry is the last slot in storage, it is safe to delete it.
if (fStorage.count() - 1 == entry->fSlot) {
// free the slot
fStorage.remove(entry->fSlot);
fBytesAllocated -= sizeof(SkBitmapHeapEntry);
- SkDELETE(entry);
+ delete entry;
} else {
fUnusedSlots.push(entry->fSlot);
}
}
void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
- SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState);
+ SkBitmapProcState* state = new (stateStorage) SkBitmapProcState;
SkASSERT(state);
state->fTileModeX = fTileModeX;
return NULL;
}
- return SkNEW_PLACEMENT_ARGS(storage, BitmapProcShaderContext, (*this, rec, state));
+ return new (storage) BitmapProcShaderContext(*this, rec, state);
}
size_t SkBitmapProcShader::contextSize() const {
SkColor color;
if (src.isNull() || bitmap_is_too_big(src)) {
if (NULL == allocator) {
- shader = SkNEW(SkEmptyShader);
+ shader = new SkEmptyShader;
} else {
shader = allocator->createT<SkEmptyShader>();
}
} else if (can_use_color_shader(src, &color)) {
if (NULL == allocator) {
- shader = SkNEW_ARGS(SkColorShader, (color));
+ shader = new SkColorShader(color);
} else {
shader = allocator->createT<SkColorShader>(color);
}
} else {
if (NULL == allocator) {
- shader = SkNEW_ARGS(SkBitmapProcShader, (src, tmx, tmy, localMatrix));
+ shader = new SkBitmapProcShader(src, tmx, tmy, localMatrix);
} else {
shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy, localMatrix);
}
float destWidth, float destHeight,
const SkRect& destSubset,
const SkConvolutionProcs& convolveProcs);
- ~SkResizeFilter() {
- SkDELETE( fBitmapFilter );
- }
+ ~SkResizeFilter() { delete fBitmapFilter; }
// Returns the filled filter values.
const SkConvolutionFilter1D& xFilter() { return fXFilter; }
switch(method) {
case SkBitmapScaler::RESIZE_BOX:
- fBitmapFilter = SkNEW(SkBoxFilter);
+ fBitmapFilter = new SkBoxFilter;
break;
case SkBitmapScaler::RESIZE_TRIANGLE:
- fBitmapFilter = SkNEW(SkTriangleFilter);
+ fBitmapFilter = new SkTriangleFilter;
break;
case SkBitmapScaler::RESIZE_MITCHELL:
- fBitmapFilter = SkNEW_ARGS(SkMitchellFilter, (1.f/3.f, 1.f/3.f));
+ fBitmapFilter = new SkMitchellFilter(1.f / 3.f, 1.f / 3.f);
break;
case SkBitmapScaler::RESIZE_HAMMING:
- fBitmapFilter = SkNEW(SkHammingFilter);
+ fBitmapFilter = new SkHammingFilter;
break;
case SkBitmapScaler::RESIZE_LANCZOS3:
- fBitmapFilter = SkNEW(SkLanczosFilter);
+ fBitmapFilter = new SkLanczosFilter;
break;
default:
// NOTREACHED:
- fBitmapFilter = SkNEW_ARGS(SkMitchellFilter, (1.f/3.f, 1.f/3.f));
+ fBitmapFilter = new SkMitchellFilter(1.f / 3.f, 1.f / 3.f);
break;
}
return NULL;
}
}
- return SkNEW_PLACEMENT_ARGS(storage, Sk3DShaderContext, (*this, rec, proxyContext));
+ return new (storage) Sk3DShaderContext(*this, rec, proxyContext);
}
class Sk3DShaderContext : public SkShader::Context {
SkFlattenable* Sk3DShader::CreateProc(SkReadBuffer& buffer) {
SkAutoTUnref<SkShader> shader(buffer.readShader());
- return SkNEW_ARGS(Sk3DShader, (shader));
+ return new Sk3DShader(shader);
}
class Sk3DBlitter : public SkBlitter {
if (origPaint.getMaskFilter() != NULL &&
origPaint.getMaskFilter()->getFormat() == SkMask::k3D_Format) {
- shader3D = SkNEW_ARGS(Sk3DShader, (shader));
+ shader3D = new Sk3DShader(shader);
// we know we haven't initialized lazyPaint yet, so just do it
paint.writable()->setShader(shader3D)->unref();
shader = shader3D;
if (NULL == shader) {
if (mode) {
// xfermodes (and filters) require shaders for our current blitters
- shader = SkNEW_ARGS(SkColorShader, (paint->getColor()));
+ shader = new SkColorShader(paint->getColor());
paint.writable()->setShader(shader)->unref();
paint.writable()->setAlpha(0xFF);
} else if (cf) {
if (cf) {
SkASSERT(shader);
- shader = SkNEW_ARGS(SkFilterShader, (shader, cf));
+ shader = new SkFilterShader(shader, cf);
paint.writable()->setShader(shader)->unref();
// blitters should ignore the presence/absence of a filter, since
// if there is one, the shader will take care of it.
if (NULL == ctx) {
// Need a valid context in fShaderContext's storage, so we can later (or our caller) call
// the in-place destructor.
- SkNEW_PLACEMENT_ARGS(fShaderContext, SkZeroShaderContext, (*fShader, rec));
+ new (fShaderContext) SkZeroShaderContext(*fShader, rec);
return false;
}
return true;
sk_free(fStorage.fMalloc);
break;
case kDiscardableMemory_StorageType:
- SkDELETE(fStorage.fDM);
+ delete fStorage.fDM;
break;
}
dec();
void SkCachedData::internalUnref(bool fromCache) const {
if (AutoMutexWritable(this)->inMutexUnref(fromCache)) {
// can't delete inside doInternalUnref, since it is locking a mutex (which we own)
- SkDELETE(this);
+ delete this;
}
}
device->onAttachToCanvas(canvas);
}
fDevice = device;
- fPaint = paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL;
+ fPaint = paint ? new SkPaint(*paint) : NULL;
}
~DeviceCM() {
fDevice->onDetachFromCanvas();
fDevice->unref();
}
- SkDELETE(fPaint);
+ delete fPaint;
}
void reset(const SkIRect& bounds) {
}
~MCRec() {
SkSafeUnref(fFilter);
- SkDELETE(fLayer);
+ delete fLayer;
dec_rec();
}
fSaveCount = 1;
fMetaData = NULL;
- fClipStack.reset(SkNEW(SkClipStack));
+ fClipStack.reset(new SkClipStack);
fMCRec = (MCRec*)fMCStack.push_back();
new (fMCRec) MCRec(fConservativeRasterClip);
{
inc_canvas();
- this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice,
- (SkIRect::MakeWH(width, height), fProps)), kDefault_InitFlags)->unref();
+ this->init(new SkNoPixelsBitmapDevice(SkIRect::MakeWH(width, height), fProps),
+ kDefault_InitFlags)->unref();
}
SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
{
inc_canvas();
- this->init(SkNEW_ARGS(SkNoPixelsBitmapDevice, (bounds, fProps)), flags)->unref();
+ this->init(new SkNoPixelsBitmapDevice(bounds, fProps), flags)->unref();
}
SkCanvas::SkCanvas(SkBaseDevice* device)
{
inc_canvas();
- SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap, fProps)));
+ SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
this->init(device, kDefault_InitFlags);
}
{
inc_canvas();
- SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap, fProps)));
+ SkAutoTUnref<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
this->init(device, kDefault_InitFlags);
}
this->internalRestore(); // restore the last, since we're going away
- SkDELETE(fMetaData);
+ delete fMetaData;
dec_canvas();
}
}
device->setOrigin(ir.fLeft, ir.fTop);
- DeviceCM* layer = SkNEW_ARGS(DeviceCM, (device, paint, this, fConservativeRasterClip,
- forceSpriteOnRestore));
+ DeviceCM* layer =
+ new DeviceCM(device, paint, this, fConservativeRasterClip, forceSpriteOnRestore);
device->unref();
layer->fNext = fMCRec->fTopLayer;
layer->fPaint, layer->fDeviceIsBitmapDevice);
// reset this, since internalDrawDevice will have set it to true
fDeviceCMDirty = true;
- SkDELETE(layer);
+ delete layer;
} else {
// we're at the root
SkASSERT(layer == (void*)fDeviceCMStorage);
if (!bitmap.installPixels(info, pixels, rowBytes)) {
return NULL;
}
- return SkNEW_ARGS(SkCanvas, (bitmap));
+ return new SkCanvas(bitmap);
}
///////////////////////////////////////////////////////////////////////////////
prior = (Element*) fDeque.back();
}
}
- Element* newElement = SkNEW_PLACEMENT_ARGS(fDeque.push_back(), Element, (element));
+ Element* newElement = new (fDeque.push_back()) Element(element);
newElement->updateBoundAndGenID(prior);
}
if (count > SK_MAX_COMPOSE_COLORFILTER_COUNT) {
return NULL;
}
- return SkNEW_ARGS(SkComposeColorFilter, (outer, inner, count));
+ return new SkComposeColorFilter(outer, inner, count);
}
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter)
if (!shaderA.get() || !shaderB.get()) {
return NULL;
}
- return SkNEW_ARGS(SkComposeShader, (shaderA, shaderB, mode));
+ return new SkComposeShader(shaderA, shaderB, mode);
}
void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
return NULL;
}
- return SkNEW_PLACEMENT_ARGS(storage, ComposeShaderContext, (*this, rec, contextA, contextB));
+ return new (storage) ComposeShaderContext(*this, rec, contextA, contextB);
}
SkComposeShader::ComposeShaderContext::ComposeShaderContext(
SkDataTable* SkDataTable::NewEmpty() {
static SkDataTable* gEmpty;
if (NULL == gEmpty) {
- gEmpty = SkNEW(SkDataTable);
+ gEmpty = new SkDataTable;
}
gEmpty->ref();
return gEmpty;
elem += sizes[i];
}
- return SkNEW_ARGS(SkDataTable, (dir, count, malloc_freeproc, buffer));
+ return new SkDataTable(dir, count, malloc_freeproc, buffer);
}
SkDataTable* SkDataTable::NewCopyArray(const void* array, size_t elemSize,
void* buffer = sk_malloc_throw(bufferSize);
memcpy(buffer, array, bufferSize);
- return SkNEW_ARGS(SkDataTable,
- (buffer, elemSize, count, malloc_freeproc, buffer));
+ return new SkDataTable(buffer, elemSize, count, malloc_freeproc, buffer);
}
SkDataTable* SkDataTable::NewArrayProc(const void* array, size_t elemSize,
if (count <= 0) {
return SkDataTable::NewEmpty();
}
- return SkNEW_ARGS(SkDataTable, (array, elemSize, count, proc, ctx));
+ return new SkDataTable(array, elemSize, count, proc, ctx);
}
///////////////////////////////////////////////////////////////////////////////
-static void chunkalloc_freeproc(void* context) {
- SkDELETE((SkChunkAlloc*)context);
-}
+static void chunkalloc_freeproc(void* context) { delete (SkChunkAlloc*)context; }
SkDataTableBuilder::SkDataTableBuilder(size_t minChunkSize)
: fHeap(NULL)
fMinChunkSize = minChunkSize;
fDir.reset();
if (fHeap) {
- SkDELETE(fHeap);
+ delete fHeap;
fHeap = NULL;
}
}
void SkDataTableBuilder::append(const void* src, size_t size) {
if (NULL == fHeap) {
- fHeap = SkNEW_ARGS(SkChunkAlloc, (fMinChunkSize));
+ fHeap = new SkChunkAlloc(fMinChunkSize);
}
void* dst = fHeap->alloc(size, SkChunkAlloc::kThrow_AllocFailType);
SkChunkAlloc::kThrow_AllocFailType);
memcpy(dir, fDir.begin(), count * sizeof(SkDataTable::Dir));
- SkDataTable* table = SkNEW_ARGS(SkDataTable,
- ((SkDataTable::Dir*)dir, count,
- chunkalloc_freeproc, fHeap));
+ SkDataTable* table = new SkDataTable((SkDataTable::Dir*)dir, count, chunkalloc_freeproc, fHeap);
// we have to detach our fHeap, since we are giving that to the table
fHeap = NULL;
fDir.reset();
fMetaData = NULL;
}
-SkBaseDevice::~SkBaseDevice() {
- SkDELETE(fMetaData);
-}
+SkBaseDevice::~SkBaseDevice() { delete fMetaData; }
SkMetaData& SkBaseDevice::getMetaData() {
// metadata users are rare, so we lazily allocate it. If that changes we
float contrast,
LCDConfig config,
FontHintLevel level) {
- return SkNEW_ARGS(SkDeviceProfile, (gammaExp, contrast, config, level));
+ return new SkDeviceProfile(gammaExp, contrast, config, level);
}
SK_DECLARE_STATIC_MUTEX(gMutex);
protected:
Context* onCreateContext(const ContextRec& rec, void* storage) const override {
- return SkNEW_PLACEMENT_ARGS(storage, TriColorShaderContext, (*this, rec));
+ return new (storage) TriColorShaderContext(*this, rec);
}
private:
xmode = SkXfermode::Create(SkXfermode::kModulate_Mode);
releaseMode = true;
}
- composeShader.reset(SkNEW_ARGS(SkComposeShader, (&triShader, shader, xmode)));
+ composeShader.reset(new SkComposeShader(&triShader, shader, xmode));
p.setShader(composeShader);
if (releaseMode) {
xmode->unref();
#include <stdarg.h>
namespace {
- void *CreateThreadError() {
- return SkNEW_ARGS(SkError, (kNoError_SkError));
- }
- void DeleteThreadError(void* v) {
- SkDELETE(reinterpret_cast<SkError*>(v));
- }
+void *CreateThreadError() { return new SkError(kNoError_SkError); }
+void DeleteThreadError(void *v) { delete reinterpret_cast<SkError *>(v); }
#define THREAD_ERROR \
(*reinterpret_cast<SkError*>(SkTLS::Get(CreateThreadError, DeleteThreadError)))
void *CreateThreadErrorCallback() {
- return SkNEW_ARGS(SkErrorCallbackFunction, (SkErrorInternals::DefaultErrorCallback));
+ return new SkErrorCallbackFunction(SkErrorInternals::DefaultErrorCallback);
}
void DeleteThreadErrorCallback(void* v) {
- SkDELETE(reinterpret_cast<SkErrorCallbackFunction *>(v));
+ delete reinterpret_cast<SkErrorCallbackFunction *>(v);
}
#define THREAD_ERROR_CALLBACK \
*(reinterpret_cast<SkErrorCallbackFunction *>(SkTLS::Get(CreateThreadErrorCallback, \
DeleteThreadErrorCallback)))
- void *CreateThreadErrorContext() {
- return SkNEW_ARGS(void **, (NULL));
- }
- void DeleteThreadErrorContext(void* v) {
- SkDELETE(reinterpret_cast<void **>(v));
- }
+ void *CreateThreadErrorContext() { return new void **(NULL); }
+ void DeleteThreadErrorContext(void *v) { delete reinterpret_cast<void **>(v); }
#define THREAD_ERROR_CONTEXT \
(*reinterpret_cast<void **>(SkTLS::Get(CreateThreadErrorContext, DeleteThreadErrorContext)))
#define ERROR_STRING_LENGTH 2048
- void *CreateThreadErrorString() {
- return SkNEW_ARRAY(char, (ERROR_STRING_LENGTH));
- }
- void DeleteThreadErrorString(void* v) {
- SkDELETE_ARRAY(reinterpret_cast<char *>(v));
- }
+ void *CreateThreadErrorString() { return new char[(ERROR_STRING_LENGTH)]; }
+ void DeleteThreadErrorString(void *v) { delete[] reinterpret_cast<char *>(v); }
#define THREAD_ERROR_STRING \
(reinterpret_cast<char *>(SkTLS::Get(CreateThreadErrorString, DeleteThreadErrorString)))
}
if (!shader.get() || !filter.get()) {
return NULL;
}
- return SkNEW_ARGS(SkFilterShader, (shader, filter));
+ return new SkFilterShader(shader, filter);
}
void SkFilterShader::flatten(SkWriteBuffer& buffer) const {
if (NULL == shaderContext) {
return NULL;
}
- return SkNEW_PLACEMENT_ARGS(storage, FilterShaderContext, (*this, shaderContext, rec));
+ return new (storage) FilterShaderContext(*this, shaderContext, rec);
}
size_t SkFilterShader::contextSize() const {
return NULL;
}
flags &= kAllFlags;
- return SkNEW_ARGS(SkFont, (face, size, scaleX, skewX, mt, flags));
+ return new SkFont(face, size, scaleX, skewX, mt, flags);
}
SkFont* SkFont::Create(SkTypeface* face, SkScalar size, MaskType mt, uint32_t flags) {
if (length > 0) {
SkAutoTUnref<SkData> data(SkData::NewUninitialized(length));
if (stream->read(data->writable_data(), length) == length) {
- fFontData.reset(new SkFontData(SkNEW_ARGS(SkMemoryStream, (data)), index,
- axis, axisCount));
+ fFontData.reset(new SkFontData(new SkMemoryStream(data), index, axis, axisCount));
}
}
}
}
};
-SkFontStyleSet* SkFontStyleSet::CreateEmpty() {
- return SkNEW(SkEmptyFontStyleSet);
-}
+SkFontStyleSet* SkFontStyleSet::CreateEmpty() { return new SkEmptyFontStyleSet; }
///////////////////////////////////////////////////////////////////////////////
return NULL;
}
SkTypeface* onCreateFromStream(SkStreamAsset* stream, int) const override {
- SkDELETE(stream);
+ delete stream;
return NULL;
}
SkTypeface* onCreateFromFile(const char[], int) const override {
// As a template argument this must have external linkage.
SkFontMgr* sk_fontmgr_create_default() {
SkFontMgr* fm = SkFontMgr::Factory();
- return fm ? fm : SkNEW(SkEmptyFontMgr);
+ return fm ? fm : new SkEmptyFontMgr;
}
SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default);
namespace {
-SkGlyphCache_Globals* create_globals() {
- return SkNEW(SkGlyphCache_Globals);
-}
+SkGlyphCache_Globals* create_globals() { return new SkGlyphCache_Globals; }
} // namespace
}
SkGlyphCache::~SkGlyphCache() {
- fGlyphMap.foreach(
- [](SkGlyph* g) {
- SkDELETE(g->fPath);
- }
- );
+ fGlyphMap.foreach ([](SkGlyph* g) { delete g->fPath; });
SkDescriptor::Free(fDesc);
- SkDELETE(fScalerContext);
+ delete fScalerContext;
this->invokeAndRemoveAuxProcs();
}
const SkPath* SkGlyphCache::findPath(const SkGlyph& glyph) {
if (glyph.fWidth) {
if (glyph.fPath == NULL) {
- const_cast<SkGlyph&>(glyph).fPath = SkNEW(SkPath);
+ const_cast<SkGlyph&>(glyph).fPath = new SkPath;
fScalerContext->getPath(glyph, glyph.fPath);
fMemoryUsed += sizeof(SkPath) +
glyph.fPath->countPoints() * sizeof(SkPoint);
rec = rec->fNext;
}
// not found, create a new rec
- rec = SkNEW(AuxProcRec);
+ rec = new AuxProcRec;
rec->fProc = proc;
rec->fData = data;
rec->fNext = fAuxProcList;
while (rec) {
rec->fProc(rec->fData);
AuxProcRec* next = rec->fNext;
- SkDELETE(rec);
+ delete rec;
rec = next;
}
}
ctx = typeface->createScalerContext(desc, false);
SkASSERT(ctx);
}
- cache = SkNEW_ARGS(SkGlyphCache, (typeface, desc, ctx));
+ cache = new SkGlyphCache(typeface, desc, ctx);
}
AutoValidate av(cache);
countFreed += 1;
this->internalDetachCache(cache);
- SkDELETE(cache);
+ delete cache;
cache = prev;
}
SkGlyphCache* cache = fHead;
while (cache) {
SkGlyphCache* next = cache->fNext;
- SkDELETE(cache);
+ delete cache;
cache = next;
}
}
subset = &bounds;
}
- return SkNEW_ARGS(SkImageCacherator, (gen,
- gen->getInfo().makeWH(subset->width(), subset->height()),
- SkIPoint::Make(subset->x(), subset->y()),
- uniqueID));
+ return new SkImageCacherator(gen, gen->getInfo().makeWH(subset->width(), subset->height()),
+ SkIPoint::Make(subset->x(), subset->y()), uniqueID);
}
SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& info,
, fUniqueID(uniqueID)
{}
-SkImageCacherator::~SkImageCacherator() {
- SkDELETE(fGenerator);
-}
+SkImageCacherator::~SkImageCacherator() { delete fGenerator; }
static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) {
SkASSERT(bitmap.getGenerationID() == expectedID);
if (common.unflatten(buffer, inputCount)) {
fCropRect = common.cropRect();
fInputCount = common.inputCount();
- fInputs = SkNEW_ARRAY(SkImageFilter*, fInputCount);
+ fInputs = new SkImageFilter* [fInputCount];
common.detachInputs(fInputs);
for (int i = 0; i < fInputCount; ++i) {
if (NULL == fInputs[i] || fInputs[i]->usesSrcInput()) {
void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
result->setInfo(info);
- result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
+ result->setPixelRef(new SkGrPixelRef(info, texture))->unref();
}
bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy,
return false;
}
SkAutoTUnref<GrTexture> resultTex(GrRefCachedBitmapTexture(context, *result, NULL));
- result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, resultTex)))->unref();
+ result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
}
return true;
} else {
} // namespace
SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) {
- return SkNEW_ARGS(CacheImpl, (maxBytes));
+ return new CacheImpl(maxBytes);
}
SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache);
*
* If this fails or when the SkDiscardablePixelRef that is
* installed into destination is destroyed, it will call
- * SkDELETE() on the generator. Therefore, generator should be
- * allocated with SkNEW() or SkNEW_ARGS().
+ * `delete` on the generator. Therefore, generator should be
+ * allocated with `new`.
*
* @param destination Upon success, this bitmap will be
* configured and have a pixelref installed.
class BlockInfo {
public:
BlockInfo() : fPicture(NULL), fPaint(NULL), fKey(NULL), fKeySize(0) {}
- ~BlockInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); SkDELETE_ARRAY(fKey); }
+ ~BlockInfo() {
+ SkSafeUnref(fPicture);
+ delete fPaint;
+ delete[] fKey;
+ }
// The picture owning the layer. If the owning picture is the top-most
// one (i.e., the picture for which this SkLayerInfo was created) then
const SkVector& invNormRotation() const { return fInvNormRotation; }
private:
- GrGLFragmentProcessor* onCreateGLInstance() const override { return SkNEW(LightingGLFP); }
+ GrGLFragmentProcessor* onCreateGLInstance() const override { return new LightingGLFP; }
bool onIsEqual(const GrFragmentProcessor& proc) const override {
const LightingFP& lightingFP = proc.cast<LightingFP>();
return false;
}
-
- *fp = SkNEW_ARGS(LightingFP, (pdm, diffuseTexture, normalTexture,
- diffM, normM, diffParams, normParams, fLights,
- fInvNormRotation));
+ *fp = new LightingFP(pdm, diffuseTexture, normalTexture, diffM, normM, diffParams, normParams,
+ fLights, fInvNormRotation);
*color = GrColorPackA4(paint.getAlpha());
return true;
SkAutoTUnref<const SkLightingShader::Lights> lights(builder.finish());
- return SkNEW_ARGS(SkLightingShaderImpl, (diffuse, normal, lights,
- SkVector::Make(1.0f, 0.0f),
- &diffLocalM, &normLocalM));
+ return new SkLightingShaderImpl(diffuse, normal, lights, SkVector::Make(1.0f, 0.0f),
+ &diffLocalM, &normLocalM);
}
void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const {
}
void* diffuseStateStorage = (char*)storage + sizeof(LightingShaderContext);
- SkBitmapProcState* diffuseState = SkNEW_PLACEMENT(diffuseStateStorage, SkBitmapProcState);
+ SkBitmapProcState* diffuseState = new (diffuseStateStorage) SkBitmapProcState;
SkASSERT(diffuseState);
diffuseState->fTileModeX = SkShader::kClamp_TileMode;
}
void* normalStateStorage = (char*)storage + sizeof(LightingShaderContext) + sizeof(SkBitmapProcState);
- SkBitmapProcState* normalState = SkNEW_PLACEMENT(normalStateStorage, SkBitmapProcState);
+ SkBitmapProcState* normalState = new (normalStateStorage) SkBitmapProcState;
SkASSERT(normalState);
normalState->fTileModeX = SkShader::kClamp_TileMode;
return NULL;
}
- return SkNEW_PLACEMENT_ARGS(storage, LightingShaderContext, (*this, rec,
- diffuseState, normalState));
+ return new (storage) LightingShaderContext(*this, rec, diffuseState, normalState);
}
///////////////////////////////////////////////////////////////////////////////
SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1));
- return SkNEW_ARGS(SkLightingShaderImpl, (diffuse, normal, lights,
- invNormRotation, diffLocalM, normLocalM));
+ return new SkLightingShaderImpl(diffuse, normal, lights, invNormRotation, diffLocalM,
+ normLocalM);
}
///////////////////////////////////////////////////////////////////////////////
class Builder {
public:
Builder(const SkLight lights[], int numLights)
- : fLights(SkNEW_ARGS(Lights, (lights, numLights))) {
- }
+ : fLights(new Lights(lights, numLights)) {}
+
+ Builder() : fLights(new Lights) {}
- Builder() : fLights(SkNEW(Lights)) { }
-
// TODO: limit the number of lights here or just ignore those
// above some maximum?
void add(const SkLight& light) {
proxy = otherProxy.get();
}
- return SkNEW_ARGS(SkLocalMatrixShader, (proxy, *lm));
+ return new SkLocalMatrixShader(proxy, *lm);
}
if (!is_valid(info, ctable)) {
return NULL;
}
- return SkNEW_ARGS(SkMallocPixelRef,
- (info, addr, rowBytes, ctable, NULL, NULL));
+ return new SkMallocPixelRef(info, addr, rowBytes, ctable, NULL, NULL);
}
return NULL;
}
- return SkNEW_ARGS(SkMallocPixelRef,
- (info, addr, rowBytes, ctable,
- sk_free_releaseproc, NULL));
+ return new SkMallocPixelRef(info, addr, rowBytes, ctable, sk_free_releaseproc, NULL);
}
SkMallocPixelRef* SkMallocPixelRef::NewWithProc(const SkImageInfo& info,
if (!is_valid(info, ctable)) {
return NULL;
}
- return SkNEW_ARGS(SkMallocPixelRef,
- (info, addr, rowBytes, ctable, proc, context));
+ return new SkMallocPixelRef(info, addr, rowBytes, ctable, proc, context);
}
static void sk_data_releaseproc(void*, void* dataPtr) {
return NULL;
}
data->ref();
- SkMallocPixelRef* pr
- = SkNEW_ARGS(SkMallocPixelRef,
- (info, const_cast<void*>(data->data()), rowBytes, ctable,
- sk_data_releaseproc, static_cast<void*>(data)));
+ SkMallocPixelRef* pr =
+ new SkMallocPixelRef(info, const_cast<void*>(data->data()), rowBytes, ctable,
+ sk_data_releaseproc, static_cast<void*>(data));
SkASSERT(pr != NULL);
// We rely on the immutability of the pixels to make the
// const_cast okay.
const SkRRect& rrect, const SkMask& mask, SkCachedData* data,
SkResourceCache* localCache) {
RRectBlurKey key(sigma, rrect, style, quality);
- return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RRectBlurRec, (key, mask, data)));
+ return CHECK_LOCAL(localCache, add, Add, new RRectBlurRec(key, mask, data));
}
//////////////////////////////////////////////////////////////////////////////////////////
const SkRect rects[], int count, const SkMask& mask, SkCachedData* data,
SkResourceCache* localCache) {
RectsBlurKey key(sigma, style, quality, rects, count);
- return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RectsBlurRec, (key, mask, data)));
+ return CHECK_LOCAL(localCache, add, Add, new RectsBlurRec(key, mask, data));
}
SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform,
SkFilterQuality filterQuality,
SkImageFilter* input) {
- return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterQuality, input));
+ return new SkMatrixImageFilter(transform, filterQuality, input);
}
SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
if (fState != State::kEmpty) {
// We have internal state pending.
// Detaching then deleting a picture is an easy way to clean up.
- SkDELETE(this->detachAsPicture(SkRect::MakeEmpty()));
+ delete this->detachAsPicture(SkRect::MakeEmpty());
}
SkASSERT(fState == State::kEmpty);
}
SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
-#define CASE(Type) \
- case State::k##Type: \
- fState = State::kEmpty; \
- return SkNEW_ARGS(SkMiniPicture<Type>, (cull, reinterpret_cast<Type*>(fBuffer.get())))
+#define CASE(Type) \
+ case State::k##Type: \
+ fState = State::kEmpty; \
+ return new SkMiniPicture<Type>(cull, reinterpret_cast<Type*>(fBuffer.get()))
switch (fState) {
case State::kEmpty: return SkRef(gEmptyPicture.get());
if (NULL == dm) {
return NULL;
}
- mipmap = SkNEW_ARGS(SkMipMap, (storageSize, dm));
+ mipmap = new SkMipMap(storageSize, dm);
} else {
- mipmap = SkNEW_ARGS(SkMipMap, (sk_malloc_throw(storageSize), storageSize));
+ mipmap = new SkMipMap(sk_malloc_throw(storageSize), storageSize);
}
// init
fMatrix.setIdentity();
}
if (paint) {
- fPaint = SkNEW_ARGS(SkPaint, (*paint));
+ fPaint = new SkPaint(*paint);
} else {
fPaint = NULL;
}
for (int i = 0; i < data.count(); ++i) {
data[i].fPicture->unref();
data[i].fCanvas->unref();
- SkDELETE(data[i].fPaint);
+ delete data[i].fPaint;
}
data.rewind();
}
gMaskGammaCacheMutex.assertHeld();
if (0 == contrast && SK_Scalar1 == paintGamma && SK_Scalar1 == deviceGamma) {
if (NULL == gLinearMaskGamma) {
- gLinearMaskGamma = SkNEW(SkMaskGamma);
+ gLinearMaskGamma = new SkMaskGamma;
}
return *gLinearMaskGamma;
}
if (gContrast != contrast || gPaintGamma != paintGamma || gDeviceGamma != deviceGamma) {
SkSafeUnref(gMaskGamma);
- gMaskGamma = SkNEW_ARGS(SkMaskGamma, (contrast, paintGamma, deviceGamma));
+ gMaskGamma = new SkMaskGamma(contrast, paintGamma, deviceGamma);
gContrast = contrast;
gPaintGamma = paintGamma;
gDeviceGamma = deviceGamma;
if ((*pathRef)->unique()) {
(*pathRef)->incReserve(incReserveVerbs, incReservePoints);
} else {
- SkPathRef* copy = SkNEW(SkPathRef);
+ SkPathRef* copy = new SkPathRef;
copy->copy(**pathRef, incReserveVerbs, incReservePoints);
pathRef->reset(copy);
}
// As a template argument, this must have external linkage.
SkPathRef* sk_create_empty_pathref() {
- SkPathRef* empty = SkNEW(SkPathRef);
+ SkPathRef* empty = new SkPathRef;
empty->computeBounds(); // Avoids races later to be the first to do this.
return empty;
}
}
if (!(*dst)->unique()) {
- dst->reset(SkNEW(SkPathRef));
+ dst->reset(new SkPathRef);
}
if (*dst != &src) {
}
SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) {
- SkPathRef* ref = SkNEW(SkPathRef);
+ SkPathRef* ref = new SkPathRef;
bool isOval;
uint8_t segmentMask;
int32_t packed;
if (!buffer->readS32(&packed)) {
- SkDELETE(ref);
+ delete ref;
return NULL;
}
!buffer->readS32(&verbCount) ||
!buffer->readS32(&pointCount) ||
!buffer->readS32(&conicCount)) {
- SkDELETE(ref);
+ delete ref;
return NULL;
}
!buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) ||
!buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)) ||
!buffer->read(&ref->fBounds, sizeof(SkRect))) {
- SkDELETE(ref);
+ delete ref;
return NULL;
}
ref->fBoundsIsDirty = false;
} else {
int oldVCnt = (*pathRef)->countVerbs();
int oldPCnt = (*pathRef)->countPoints();
- pathRef->reset(SkNEW(SkPathRef));
+ pathRef->reset(new SkPathRef);
(*pathRef)->resetToSize(0, 0, 0, oldVCnt, oldPCnt);
}
}
void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) {
if (NULL == listener || this == empty.get()) {
- SkDELETE(listener);
+ delete listener;
return;
}
*fGenIDChangeListeners.append() = listener;
rec.beginRecording();
this->playback(&rec);
rec.endRecording();
- return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/));
+ return new SkPictureData(rec, info, false /*deep copy ops?*/);
}
void SkPicture::serialize(SkWStream* stream, SkPixelSerializer* pixelSerializer) const {
const SkTDArray<const SkPicture* >& pictures = record.getPictureRefs();
fPictureCount = pictures.count();
if (fPictureCount > 0) {
- fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
+ fPictureRefs = new const SkPicture* [fPictureCount];
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i] = pictures[i];
fPictureRefs[i]->ref();
const SkTDArray<const SkTextBlob*>& blobs = record.getTextBlobRefs();
fTextBlobCount = blobs.count();
if (fTextBlobCount > 0) {
- fTextBlobRefs = SkNEW_ARRAY(const SkTextBlob*, fTextBlobCount);
+ fTextBlobRefs = new const SkTextBlob* [fTextBlobCount];
for (int i = 0; i < fTextBlobCount; ++i) {
fTextBlobRefs[i] = SkRef(blobs[i]);
}
const SkTDArray<const SkImage*>& imgs = record.getImageRefs();
fImageCount = imgs.count();
if (fImageCount > 0) {
- fImageRefs = SkNEW_ARRAY(const SkImage*, fImageCount);
+ fImageRefs = new const SkImage* [fImageCount];
for (int i = 0; i < fImageCount; ++i) {
fImageRefs[i] = SkRef(imgs[i]);
}
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i]->unref();
}
- SkDELETE_ARRAY(fPictureRefs);
+ delete[] fPictureRefs;
for (int i = 0; i < fTextBlobCount; i++) {
fTextBlobRefs[i]->unref();
}
- SkDELETE_ARRAY(fTextBlobRefs);
+ delete[] fTextBlobRefs;
for (int i = 0; i < fImageCount; i++) {
fImageRefs[i]->unref();
}
- SkDELETE_ARRAY(fImageRefs);
+ delete[] fImageRefs;
- SkDELETE(fFactoryPlayback);
+ delete fFactoryPlayback;
}
bool SkPictureData::containsBitmaps() const {
case SK_PICT_FACTORY_TAG: {
SkASSERT(!haveBuffer);
size = stream->readU32();
- fFactoryPlayback = SkNEW_ARGS(SkFactoryPlayback, (size));
+ fFactoryPlayback = new SkFactoryPlayback(size);
for (size_t i = 0; i < size; i++) {
SkString str;
const size_t len = stream->readPackedUInt();
} break;
case SK_PICT_PICTURE_TAG: {
fPictureCount = 0;
- fPictureRefs = SkNEW_ARRAY(const SkPicture*, size);
+ fPictureRefs = new const SkPicture* [size];
for (uint32_t i = 0; i < size; i++) {
fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc, topLevelTFPlayback);
if (!fPictureRefs[i]) {
return true;
}
*outCount = inCount;
- *array = SkNEW_ARRAY(const T*, *outCount);
+ *array = new const T* [*outCount];
bool success = true;
int i = 0;
for (; i < *outCount; i++) {
(*array)[j]->unref();
}
// Delete the array
- SkDELETE_ARRAY(*array);
+ delete[] * array;
*array = NULL;
*outCount = 0;
return false;
const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc,
SkTypefacePlayback* topLevelTFPlayback) {
- SkAutoTDelete<SkPictureData> data(SkNEW_ARGS(SkPictureData, (info)));
+ SkAutoTDelete<SkPictureData> data(new SkPictureData(info));
if (!topLevelTFPlayback) {
topLevelTFPlayback = &data->fTFPlayback;
}
SkPictureData* SkPictureData::CreateFromBuffer(SkReadBuffer& buffer,
const SkPictInfo& info) {
- SkAutoTDelete<SkPictureData> data(SkNEW_ARGS(SkPictureData, (info)));
+ SkAutoTDelete<SkPictureData> data(new SkPictureData(info));
buffer.setVersion(info.fVersion);
if (!data->parseBuffer(buffer)) {
SkASSERT(fArray[i]);
fArray[i]->unref();
}
- SkDELETE_ARRAY(fArray);
+ delete[] fArray;
if (rec!= NULL && rec->count() > 0) {
fCount = rec->count();
- fArray = SkNEW_ARRAY(SkRefCnt*, fCount);
+ fArray = new SkRefCnt* [fCount];
rec->copyToArray(fArray);
for (int i = 0; i < fCount; i++) {
fArray[i]->ref();
this->reset(NULL);
fCount = count;
- fArray = SkNEW_ARRAY(SkRefCnt*, count);
+ fArray = new SkRefCnt* [count];
sk_bzero(fArray, count * sizeof(SkRefCnt*));
}
class SkFactoryPlayback {
public:
- SkFactoryPlayback(int count) : fCount(count) {
- fArray = SkNEW_ARRAY(SkFlattenable::Factory, count);
- }
+ SkFactoryPlayback(int count) : fCount(count) { fArray = new SkFlattenable::Factory[count]; }
- ~SkFactoryPlayback() {
- SkDELETE_ARRAY(fArray);
- }
+ ~SkFactoryPlayback() { delete[] fArray; }
SkFlattenable::Factory* base() const { return fArray; }
return nullptr;
}
- return SkNEW_ARGS(SkPictureImageGenerator, (size, picture, matrix, paint));
+ return new SkPictureImageGenerator(size, picture, matrix, paint);
}
SkPictureImageGenerator::SkPictureImageGenerator(const SkISize& size, const SkPicture* picture,
SkPictureRecorder::SkPictureRecorder() {
fActivelyRecording = false;
- fRecorder.reset(SkNEW_ARGS(SkRecorder, (nullptr, SkRect::MakeWH(0,0), &fMiniRecorder)));
+ fRecorder.reset(new SkRecorder(nullptr, SkRect::MakeWH(0, 0), &fMiniRecorder));
}
SkPictureRecorder::~SkPictureRecorder() {}
}
if (!fRecord) {
- fRecord.reset(SkNEW(SkRecord));
+ fRecord.reset(new SkRecord);
}
SkRecorder::DrawPictureMode dpm = (recordFlags & kPlaybackDrawPicture_RecordFlag)
? SkRecorder::Playback_DrawPictureMode
SkAutoTUnref<SkLayerInfo> saveLayerData;
if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) {
- saveLayerData.reset(SkNEW(SkLayerInfo));
+ saveLayerData.reset(new SkLayerInfo);
}
SkDrawableList* drawableList = fRecorder->getDrawableList();
for (int i = 0; pictList && i < pictList->count(); i++) {
subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]);
}
- return SkNEW_ARGS(SkBigPicture, (fCullRect,
- fRecord.detach(),
- pictList,
- fBBH.detach(),
- saveLayerData.detach(),
- subPictureBytes));
+ return new SkBigPicture(fCullRect, fRecord.detach(), pictList, fBBH.detach(),
+ saveLayerData.detach(), subPictureBytes);
}
SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) {
SkAutoTUnref<SkLayerInfo> saveLayerData;
if (fBBH && fDoSaveLayerInfo) {
- saveLayerData.reset(SkNEW(SkLayerInfo));
+ saveLayerData.reset(new SkLayerInfo);
SkBBoxHierarchy* bbh = NULL; // we've already computed fBBH (received in constructor)
// TODO: update saveLayer info computation to reuse the already computed
}
// SkBigPicture will take ownership of a ref on both fRecord and fBBH.
// We're not willing to give up our ownership, so we must ref them for SkPicture.
- return SkNEW_ARGS(SkBigPicture, (fBounds,
- SkRef(fRecord.get()),
- pictList,
- SkSafeRef(fBBH.get()),
- saveLayerData.detach(),
- subPictureBytes));
+ return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()),
+ saveLayerData.detach(), subPictureBytes);
}
};
SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
}
- SkDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable,
- (fRecord, fBBH, fRecorder->detachDrawableList(),
- fCullRect,
- SkToBool(fFlags & kComputeSaveLayerInfo_RecordFlag)));
+ SkDrawable* drawable =
+ new SkRecordedDrawable(fRecord, fBBH, fRecorder->detachDrawableList(), fCullRect,
+ SkToBool(fFlags & kComputeSaveLayerInfo_RecordFlag));
// release our refs now, so only the drawable will be the owner.
fRecord.reset(NULL);
if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
return SkShader::CreateEmptyShader();
}
- return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile));
+ return new SkPictureShader(picture, tmx, tmy, localMatrix, tile);
}
SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix));
- SkResourceCache::Add(SkNEW_ARGS(BitmapShaderRec, (key, tileShader.get(), bm.getSize())));
+ SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSize()));
}
return tileShader.detach();
SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage,
const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapShader) {
- PictureShaderContext* ctx = SkNEW_PLACEMENT_ARGS(storage, PictureShaderContext,
- (shader, rec, bitmapShader));
+ PictureShaderContext* ctx = new (storage) PictureShaderContext(shader, rec, bitmapShader);
if (NULL == ctx->fBitmapShaderContext) {
ctx->~PictureShaderContext();
ctx = NULL;
void SkPixelRef::addGenIDChangeListener(GenIDChangeListener* listener) {
if (NULL == listener || !this->genIDIsUnique()) {
// No point in tracking this if we're not going to call it.
- SkDELETE(listener);
+ delete listener;
return;
}
*fGenIDChangeListeners.append() = listener;
}
#endif
-SkROBuffer* SkRWBuffer::newRBufferSnapshot() const {
- return SkNEW_ARGS(SkROBuffer, (fHead, fTotalUsed));
-}
+SkROBuffer* SkRWBuffer::newRBufferSnapshot() const { return new SkROBuffer(fHead, fTotalUsed); }
///////////////////////////////////////////////////////////////////////////////////////////////////
return fBuffer->size() == fGlobalOffset;
}
- SkStreamAsset* duplicate() const override {
- return SkNEW_ARGS(SkROBufferStreamAsset, (fBuffer));
- }
+ SkStreamAsset* duplicate() const override { return new SkROBufferStreamAsset(fBuffer); }
size_t getPosition() const override {
return fGlobalOffset;
SkStreamAsset* SkRWBuffer::newStreamSnapshot() const {
SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot());
- return SkNEW_ARGS(SkROBufferStreamAsset, (buffer));
+ return new SkROBufferStreamAsset(buffer);
}
dst.fPreMat = src.fPreMat;
dst.fPreMat.postConcat(fFillBounds.ctm());
if (src.fPaint) {
- dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint));
+ dst.fPaint = new SkPaint(*src.fPaint);
}
dst.fSaveLayerOpID = src.fSaveLayerOpID;
dst.fRestoreOpID = src.fRestoreOpID;
// Store 'saveLayer ops from enclosing picture' + drawPict op + 'ops from sub-picture'
dst.fKeySize = fSaveLayerOpStack.count() + src.fKeySize + 1;
- dst.fKey = SkNEW_ARRAY(int, dst.fKeySize);
+ dst.fKey = new int[dst.fKeySize];
memcpy(dst.fKey, fSaveLayerOpStack.begin(), fSaveLayerOpStack.count() * sizeof(int));
dst.fKey[fSaveLayerOpStack.count()] = fFillBounds.currentOp();
memcpy(&dst.fKey[fSaveLayerOpStack.count()+1], src.fKey, src.fKeySize * sizeof(int));
block.fLocalMat = fFillBounds.ctm();
block.fPreMat = SkMatrix::I();
if (sli.fPaint) {
- block.fPaint = SkNEW_ARGS(SkPaint, (*sli.fPaint));
+ block.fPaint = new SkPaint(*sli.fPaint);
}
block.fSrcBounds = sli.fBounds;
block.fIsNested = fSaveLayersInStack > 0;
block.fKeySize = fSaveLayerOpStack.count();
- block.fKey = SkNEW_ARRAY(int, block.fKeySize);
+ block.fKey = new int[block.fKeySize];
memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(int));
fSaveLayerOpStack.pop();
for (int i = 0; i < count; ++i) {
pics[i] = fArray[i]->newPictureSnapshot();
}
- return SkNEW_ARGS(SkBigPicture::SnapshotArray, (pics.detach(), count));
+ return new SkBigPicture::SnapshotArray(pics.detach(), count);
}
void SkDrawableList::append(SkDrawable* drawable) {
}
// To make appending to fRecord a little less verbose.
-#define APPEND(T, ...) \
- if (fMiniRecorder) { this->flushMiniRecorder(); } \
- SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__VA_ARGS__))
+#define APPEND(T, ...) \
+ if (fMiniRecorder) { \
+ this->flushMiniRecorder(); \
+ } \
+ new (fRecord->append<SkRecords::T>()) SkRecords::T(__VA_ARGS__)
#define TRY_MINIRECORDER(method, ...) \
if (fMiniRecorder && fMiniRecorder->method(__VA_ARGS__)) { return; }
if (NULL == src) {
return NULL;
}
- return SkNEW_PLACEMENT_ARGS(fRecord->alloc<T>(), T, (*src));
+ return new (fRecord->alloc<T>()) T(*src);
}
// This copy() is for arrays.
}
T* dst = fRecord->alloc<T>(count);
for (size_t i = 0; i < count; i++) {
- SkNEW_PLACEMENT_ARGS(dst + i, T, (src[i]));
+ new (dst + i) T(src[i]);
}
return dst;
}
void SkRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
if (!fDrawableList) {
- fDrawableList.reset(SkNEW(SkDrawableList));
+ fDrawableList.reset(new SkDrawableList);
}
fDrawableList->append(drawable);
APPEND(DrawDrawable, this->copy(matrix), drawable->getBounds(), fDrawableList->count() - 1);
fFirstTime = true;
}
-SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
- SkDELETE(fDM);
-}
+SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() { delete fDM; }
bool SkOneShotDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
if (fFirstTime) {
}
SkImageInfo info = bitmap->info();
- bitmap->setPixelRef(SkNEW_ARGS(SkOneShotDiscardablePixelRef,
- (info, dm, bitmap->rowBytes())))->unref();
+ bitmap->setPixelRef(new SkOneShotDiscardablePixelRef(info, dm, bitmap->rowBytes()))->unref();
bitmap->lockPixels();
return bitmap->readyToDraw();
}
this->init();
fDiscardableFactory = factory;
- fAllocator = SkNEW_ARGS(SkResourceCacheDiscardableAllocator, (factory));
+ fAllocator = new SkResourceCacheDiscardableAllocator(factory);
}
SkResourceCache::SkResourceCache(size_t byteLimit) {
Rec* rec = fHead;
while (rec) {
Rec* next = rec->fNext;
- SkDELETE(rec);
+ delete rec;
rec = next;
}
delete fHash;
// See if we already have this key (racy inserts, etc.)
Rec* existing = fHash->find(rec->getKey());
if (existing) {
- SkDELETE(rec);
+ delete rec;
return;
}
bytesStr.c_str(), rec, rec->getHash(), totalStr.c_str(), fCount);
}
- SkDELETE(rec);
+ delete rec;
}
void SkResourceCache::purgeAsNeeded(bool forcePurge) {
if (fDiscardableFactory) {
SkDiscardableMemory* dm = fDiscardableFactory(bytes);
- return dm ? SkNEW_ARGS(SkCachedData, (bytes, dm)) : NULL;
+ return dm ? new SkCachedData(bytes, dm) : NULL;
} else {
- return SkNEW_ARGS(SkCachedData, (sk_malloc_throw(bytes), bytes));
+ return new SkCachedData(sk_malloc_throw(bytes), bytes);
}
}
// makes this unsafe to delete when the main process atexit()s.
// SkLazyPtr does the same sort of thing.
#if SK_DEVELOPER
- SkDELETE(gResourceCache);
+ delete gResourceCache;
#endif
}
gMutex.assertHeld();
if (NULL == gResourceCache) {
#ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE
- gResourceCache = SkNEW_ARGS(SkResourceCache, (SkDiscardableMemory::Create));
+ gResourceCache = new SkResourceCache(SkDiscardableMemory::Create);
#else
- gResourceCache = SkNEW_ARGS(SkResourceCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT));
+ gResourceCache = new SkResourceCache(SK_DEFAULT_IMAGE_CACHE_LIMIT);
#endif
atexit(cleanup_gResourceCache);
}
SkScalerContext* c = this->onCreateScalerContext(desc);
if (!c && !allowFailure) {
- c = SkNEW_ARGS(SkScalerContext_Empty,
- (const_cast<SkTypeface*>(this), desc));
+ c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), desc);
}
return c;
}
};
#endif
-SkSemaphore::SkSemaphore() : fCount(0), fOSSemaphore(SkNEW(OSSemaphore)) {}
-SkSemaphore::~SkSemaphore() { SkDELETE(fOSSemaphore); }
+ SkSemaphore::SkSemaphore() : fCount(0), fOSSemaphore(new OSSemaphore) {}
+ SkSemaphore::~SkSemaphore() { delete fOSSemaphore; }
void SkSemaphore::signal(int n) {
SkASSERT(n >= 0);
return NULL;
}
-SkShader* SkShader::CreateEmptyShader() {
- return SkNEW(SkEmptyShader);
-}
+SkShader* SkShader::CreateEmptyShader() { return new SkEmptyShader; }
-SkShader* SkShader::CreateColorShader(SkColor color) {
- return SkNEW_ARGS(SkColorShader, (color));
-}
+SkShader* SkShader::CreateColorShader(SkColor color) { return new SkColorShader(color); }
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
const SkMatrix* localMatrix) {
}
SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) {
- return SkNEW_ARGS(SkColorShader, (buffer.readColor()));
+ return new SkColorShader(buffer.readColor());
}
void SkColorShader::flatten(SkWriteBuffer& buffer) const {
}
SkShader::Context* SkColorShader::onCreateContext(const ContextRec& rec, void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, ColorShaderContext, (*this, rec));
+ return new (storage) ColorShaderContext(*this, rec);
}
SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shader,
if (NULL == buf) {
return NULL;
}
- SkNEW_PLACEMENT(buf, T);
+ new (buf) T;
return static_cast<T*>(buf);
}
if (NULL == buf) {
return NULL;
}
- SkNEW_PLACEMENT_ARGS(buf, T, (a1));
+ new (buf) T(a1);
return static_cast<T*>(buf);
}
if (NULL == buf) {
return NULL;
}
- SkNEW_PLACEMENT_ARGS(buf, T, (a1, a2));
+ new (buf) T(a1, a2);
return static_cast<T*>(buf);
}
if (NULL == buf) {
return NULL;
}
- SkNEW_PLACEMENT_ARGS(buf, T, (a1, a2, a3));
+ new (buf) T(a1, a2, a3);
return static_cast<T*>(buf);
}
if (NULL == buf) {
return NULL;
}
- SkNEW_PLACEMENT_ARGS(buf, T, (a1, a2, a3, a4));
+ new (buf) T(a1, a2, a3, a4);
return static_cast<T*>(buf);
}
return true;
}
-SkMemoryStream* SkMemoryStream::duplicate() const {
- return SkNEW_ARGS(SkMemoryStream, (fData));
-}
+SkMemoryStream* SkMemoryStream::duplicate() const { return new SkMemoryStream(fData); }
size_t SkMemoryStream::getPosition() const {
return fOffset;
class SkBlockMemoryStream : public SkStreamAsset {
public:
SkBlockMemoryStream(SkDynamicMemoryWStream::Block* head, size_t size)
- : fBlockMemory(SkNEW_ARGS(SkBlockMemoryRefCnt, (head))), fCurrent(head)
- , fSize(size) , fOffset(0), fCurrentOffset(0) { }
+ : fBlockMemory(new SkBlockMemoryRefCnt(head))
+ , fCurrent(head)
+ , fSize(size)
+ , fOffset(0)
+ , fCurrentOffset(0) {}
SkBlockMemoryStream(SkBlockMemoryRefCnt* headRef, size_t size)
: fBlockMemory(SkRef(headRef)), fCurrent(fBlockMemory->fHead)
}
SkBlockMemoryStream* duplicate() const override {
- return SkNEW_ARGS(SkBlockMemoryStream, (fBlockMemory.get(), fSize));
+ return new SkBlockMemoryStream(fBlockMemory.get(), fSize);
}
size_t getPosition() const override {
SkStreamAsset* SkDynamicMemoryWStream::detachAsStream() {
if (fCopy) {
- SkMemoryStream* stream = SkNEW_ARGS(SkMemoryStream, (fCopy));
+ SkMemoryStream* stream = new SkMemoryStream(fCopy);
this->reset();
return stream;
}
- SkBlockMemoryStream* stream = SkNEW_ARGS(SkBlockMemoryStream, (fHead, fBytesWritten));
+ SkBlockMemoryStream* stream = new SkBlockMemoryStream(fHead, fBytesWritten);
fHead = 0;
this->reset();
return stream;
SkStreamAsset* SkStream::NewFromFile(const char path[]) {
SkAutoTUnref<SkData> data(mmap_filename(path));
if (data.get()) {
- return SkNEW_ARGS(SkMemoryStream, (data.get()));
+ return new SkMemoryStream(data.get());
}
// If we get here, then our attempt at using mmap failed, so try normal
// file access.
- SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
+ SkFILEStream* stream = new SkFILEStream(path);
if (!stream->isValid()) {
- SkDELETE(stream);
+ delete stream;
stream = NULL;
}
return stream;
length -= stream->getPosition();
}
SkAutoTUnref<SkData> data(SkData::NewFromStream(stream, length));
- return SkNEW_ARGS(SkMemoryStream, (data.get()));
+ return new SkMemoryStream(data.get());
}
SkDynamicMemoryWStream tempStream;
const size_t bufferSize = 4096;
this->validate();
Node* node = this->createNode();
fList.addToHead(node);
- SkNEW_PLACEMENT_ARGS(node->fObj, T, (t));
+ new (node->fObj) T(t);
this->validate();
return reinterpret_cast<T*>(node->fObj);
}
this->validate();
Node* node = this->createNode();
fList.addToHead(node);
- SkNEW_PLACEMENT(node->fObj, T);
+ new (node->fObj) T;
this->validate();
return reinterpret_cast<T*>(node->fObj);
}
this->validate();
Node* node = this->createNode();
fList.addToTail(node);
- SkNEW_PLACEMENT_ARGS(node->fObj, T, (t));
+ new (node->fObj) T(t);
this->validate();
return reinterpret_cast<T*>(node->fObj);
}
this->validate();
Node* node = this->createNode();
fList.addToTail(node);
- SkNEW_PLACEMENT(node->fObj, T);
+ new (node->fObj) T;
this->validate();
return reinterpret_cast<T*>(node->fObj);
}
/** Adds a new element to the list before the location indicated by the iterator. If the
iterator refers to a NULL location then the new element is added at the tail */
T* addBefore(const T& t, const Iter& location) {
- return SkNEW_PLACEMENT_ARGS(this->internalAddBefore(location), T, (t));
+ return new (this->internalAddBefore(location)) T(t);
}
/** Adds a new element to the list after the location indicated by the iterator. If the
iterator refers to a NULL location then the new element is added at the head */
T* addAfter(const T& t, const Iter& location) {
- return SkNEW_PLACEMENT_ARGS(this->internalAddAfter(location), T, (t));
+ return new (this->internalAddAfter(location)) T(t);
}
/** Convenience methods for getting an iterator initialized to the head/tail of the list. */
} else {
Block* block = reinterpret_cast<Block*>(sk_malloc_flags(this->blockSize(), 0));
node = &block->fNodes[0];
- SkNEW_PLACEMENT(node, Node);
+ new (node) Node;
node->fBlock = block;
block->fNodesInUse = 1;
for (int i = 1; i < fAllocCnt; ++i) {
- SkNEW_PLACEMENT(block->fNodes + i, Node);
+ new (block->fNodes + i) Node;
fFreeList.addToHead(block->fNodes + i);
block->fNodes[i].fBlock = block;
}
SkTLSRec* rec = (SkTLSRec*)ptr;
do {
SkTLSRec* next = rec->fNext;
- SkDELETE(rec);
+ delete rec;
rec = next;
} while (rec);
}
// we have a new head of our chain
SkTLS::PlatformSetSpecific(next);
}
- SkDELETE(curr);
+ delete curr;
break;
}
prev = curr;
if (list) {
// The new ValueList entry is inserted as the second element in the
// linked list, and it will contain the value of the first element.
- ValueList* newEntry = SkNEW_ARGS(ValueList, (list->fValue));
+ ValueList* newEntry = new ValueList(list->fValue);
newEntry->fNext = list->fNext;
// The existing first ValueList entry is updated to contain the
// inserted value.
list->fNext = newEntry;
list->fValue = value;
} else {
- fHash.add(SkNEW_ARGS(ValueList, (value)));
+ fHash.add(new ValueList(value));
}
++fCount;
ValueList* next = list->fNext;
list->fValue = next->fValue;
list->fNext = next->fNext;
- SkDELETE(next);
+ delete next;
} else if (prev) {
prev->fNext = NULL;
- SkDELETE(list);
+ delete list;
} else {
fHash.remove(key);
- SkDELETE(list);
+ delete list;
}
--fCount;
threads = sk_num_cores();
}
for (int i = 0; i < threads; i++) {
- fThreads.push(SkNEW_ARGS(SkThread, (&ThreadPool::Loop, this)));
+ fThreads.push(new SkThread(&ThreadPool::Loop, this));
fThreads.top()->start();
}
}
SkTaskGroup::Enabler::Enabler(int threads) {
SkASSERT(ThreadPool::gGlobal == NULL);
if (threads != 0) {
- ThreadPool::gGlobal = SkNEW_ARGS(ThreadPool, (threads));
+ ThreadPool::gGlobal = new ThreadPool(threads);
}
}
-SkTaskGroup::Enabler::~Enabler() {
- SkDELETE(ThreadPool::gGlobal);
-}
+SkTaskGroup::Enabler::~Enabler() { delete ThreadPool::gGlobal; }
SkTaskGroup::SkTaskGroup() : fPending(0) {}
class SkEmptyTypeface : public SkTypeface {
public:
- static SkEmptyTypeface* Create() {
- return SkNEW(SkEmptyTypeface);
- }
+ static SkEmptyTypeface* Create() { return new SkEmptyTypeface; }
protected:
SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { }
familyName->reset();
}
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override {
- return SkNEW(EmptyLocalizedStrings);
+ return new EmptyLocalizedStrings;
};
int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override {
BoundsComputer(const SkTypeface& tf) : fTypeface(tf) {}
SkRect* operator()() const {
- SkRect* rect = SkNEW(SkRect);
+ SkRect* rect = new SkRect;
if (!fTypeface.onComputeBounds(rect)) {
rect->setEmpty();
}
if (auto xfermode = SkOpts::create_xfermode(rec, mode)) {
return xfermode;
}
- return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
+ return new SkProcCoeffXfermode(rec, mode);
}
} // namespace
void SkYUVPlanesCache::Add(uint32_t genID, SkCachedData* data, Info* info,
SkResourceCache* localCache) {
YUVPlanesKey key(genID);
- return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(YUVPlanesRec, (key, data, info)));
+ return CHECK_LOCAL(localCache, add, Add, new YUVPlanesRec(key, data, info));
}
static SkPDFObject* create_pdf_page_content(const SkPDFDevice* pageDevice) {
SkAutoTDelete<SkStreamAsset> content(pageDevice->content());
- return SkNEW_ARGS(SkPDFStream, (content.get()));
+ return new SkPDFStream(content.get());
}
static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) {
- SkAutoTUnref<SkPDFDict> page(SkNEW_ARGS(SkPDFDict, ("Page")));
+ SkAutoTUnref<SkPDFDict> page(new SkPDFDict("Page"));
page->insertObject("Resources", pageDevice->createResourceDict());
page->insertObject("MediaBox", pageDevice->copyMediaBox());
if (SkPDFArray* annots = pageDevice->getAnnotations()) {
}
SkTDArray<SkPDFDict*> pages;
- SkAutoTUnref<SkPDFDict> dests(SkNEW(SkPDFDict));
+ SkAutoTUnref<SkPDFDict> dests(new SkPDFDict);
for (int i = 0; i < pageDevices.count(); i++) {
SkASSERT(pageDevices[i]);
}
SkTDArray<SkPDFDict*> pageTree;
- SkAutoTUnref<SkPDFDict> docCatalog(SkNEW_ARGS(SkPDFDict, ("Catalog")));
+ SkAutoTUnref<SkPDFDict> docCatalog(new SkPDFDict("Catalog"));
SkPDFDict* pageTreeRoot;
generate_page_tree(pages, &pageTree, &pageTreeRoot);
SkScalarRoundToInt(width), SkScalarRoundToInt(height));
SkAutoTUnref<SkPDFDevice> device(
SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
- fCanvas.reset(SkNEW_ARGS(SkCanvas, (device.get())));
+ fCanvas.reset(new SkCanvas(device.get()));
fPageDevices.push(device.detach());
fCanvas->clipRect(trimBox);
fCanvas->translate(trimBox.x(), trimBox.y());
///////////////////////////////////////////////////////////////////////////////
SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) {
- return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, NULL, dpi)) : NULL;
+ return stream ? new SkDocument_PDF(stream, NULL, dpi) : NULL;
}
SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
- SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
+ SkFILEWStream* stream = new SkFILEWStream(path);
if (!stream->isValid()) {
- SkDELETE(stream);
+ delete stream;
return NULL;
}
- auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); };
- return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi));
+ auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
+ return new SkDocument_PDF(stream, delete_wstream, dpi);
}
const SkRect& trimBox) override {
fDevice.beginSheet(fUnitsPerMeter, fPixelsPerMeter,
SkSize::Make(width, height));
- fCanvas.reset(SkNEW_ARGS(SkCanvas, (&fDevice)));
+ fCanvas.reset(new SkCanvas(&fDevice));
fCanvas->clipRect(trimBox);
fCanvas->translate(trimBox.x(), trimBox.y());
return fCanvas.get();
///////////////////////////////////////////////////////////////////////////////
SkDocument* SkDocument::CreateXPS(SkWStream* stream, SkScalar dpi) {
- return stream ? SkNEW_ARGS(SkDocument_XPS, (stream, NULL, dpi)) : NULL;
+ return stream ? new SkDocument_XPS(stream, NULL, dpi) : NULL;
}
-static void delete_wstream(SkWStream* stream, bool aborted) {
- SkDELETE(stream);
-}
+static void delete_wstream(SkWStream* stream, bool aborted) { delete stream; }
SkDocument* SkDocument::CreateXPS(const char path[], SkScalar dpi) {
- SkAutoTDelete<SkFILEWStream> stream(SkNEW_ARGS(SkFILEWStream, (path)));
+ SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
if (!stream->isValid()) {
return NULL;
}
- return SkNEW_ARGS(SkDocument_XPS, (stream.detach(), delete_wstream, dpi));
+ return new SkDocument_XPS(stream.detach(), delete_wstream, dpi);
}
SkScalar innerThreshold,
SkScalar outerThreshold,
SkImageFilter* input) {
- return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outerThreshold, input));
+ return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold, input);
}
#if SK_SUPPORT_GPU
GrTexture* maskTexture,
float innerThreshold,
float outerThreshold) {
- return SkNEW_ARGS(AlphaThresholdEffect, (procDataManager,
- texture,
- maskTexture,
- innerThreshold,
- outerThreshold));
+ return new AlphaThresholdEffect(procDataManager, texture, maskTexture, innerThreshold,
+ outerThreshold);
}
virtual ~AlphaThresholdEffect() {};
}
GrGLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this));
+ return new GrGLAlphaThresholdEffect(*this);
}
bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
public:
static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
bool enforcePMColor) {
- return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4, enforcePMColor));
+ return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor);
}
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
int32_t i3 = toDot8(k3);
int32_t i4 = toDot8(k4);
if (i1) {
- return SkNEW_ARGS(SkArithmeticMode_quad, (i1, i2, i3, i4));
+ return new SkArithmeticMode_quad (i1, i2, i3, i4);
}
if (0 == i2) {
- return SkNEW_ARGS(SkArithmeticMode_dst, (i3, i4));
+ return new SkArithmeticMode_dst (i3, i4);
}
if (0 == i3) {
- return SkNEW_ARGS(SkArithmeticMode_src, (i2, i4));
+ return new SkArithmeticMode_src (i2, i4);
}
- return SkNEW_ARGS(SkArithmeticMode_linear, (i2, i3, i4));
+ return new SkArithmeticMode_linear (i2, i3, i4);
#endif
}
return SkArithmeticMode_scalar::Create(k1, k2, k3, k4, enforcePMColor);
}
GrGLFragmentProcessor* GrArithmeticFP::onCreateGLInstance() const {
- return SkNEW_ARGS(GLArithmeticFP, (*this));
+ return new GLArithmeticFP(*this);
}
bool GrArithmeticFP::onIsEqual(const GrFragmentProcessor& fpBase) const {
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- return SkNEW_ARGS(GrArithmeticFP, (d->fProcDataManager, k1, k2, k3, k4, enforcePMColor,
- d->fTextures[0]));
+ return new GrArithmeticFP(d->fProcDataManager, k1, k2, k3, k4, enforcePMColor, d->fTextures[0]);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP);
GLArithmeticXP::GenKey(*this, caps, b);
}
-GrGLXferProcessor* ArithmeticXP::createGLInstance() const {
- return SkNEW_ARGS(GLArithmeticXP, (*this));
-}
+GrGLXferProcessor* ArithmeticXP::createGLInstance() const { return new GLArithmeticXP(*this); }
GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
const GrProcOptInfo& coveragePOI,
bool hasMixedSamples,
const DstTexture* dstTexture) const {
- return SkNEW_ARGS(ArithmeticXP, (dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4,
- fEnforcePMColor));
+ return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEnforcePMColor);
}
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, float k1, float k2,
float k3, float k4, bool enforcePMColor,
GrTexture* background) {
- return SkNEW_ARGS(GrArithmeticFP, (procDataManager, k1, k2, k3, k4, enforcePMColor,
- background));
+ return new GrArithmeticFP(procDataManager, k1, k2, k3, k4, enforcePMColor, background);
}
~GrArithmeticFP() override {};
class GrArithmeticXPFactory : public GrXPFactory {
public:
static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) {
- return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor));
+ return new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor);
}
bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override {
////////////////////////////////////////////////////////////////////////////////////////
SkDrawLooper::Context* SkBlurDrawLooper::createContext(SkCanvas*, void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, BlurDrawLooperContext, (this));
+ return new (storage) BlurDrawLooperContext(this);
}
SkBlurDrawLooper::BlurDrawLooperContext::BlurDrawLooperContext(
int size = SkScalarCeilToInt(6*sigma);
int center = size >> 1;
- uint8_t *profile = SkNEW_ARRAY(uint8_t, size);
+ uint8_t* profile = new uint8_t[size];
float invr = 1.f/(2*sigma);
if (flags > SkBlurMaskFilter::kAll_BlurFlag) {
return NULL;
}
- return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
+ return new SkBlurMaskFilterImpl(sigma, style, flags);
}
///////////////////////////////////////////////////////////////////////////////
if (!createdBlurProfileTexture) {
return NULL;
}
- return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture));
+ return new GrRectBlurEffect(rect, sigma, blurProfileTexture);
}
const SkRect& getRect() const { return fRect; }
}
GrGLFragmentProcessor* GrRectBlurEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLRectBlurEffect, (*this));
+ return new GrGLRectBlurEffect(*this);
}
bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
}
texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture);
}
- return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
+ return new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture);
}
void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
}
GrGLFragmentProcessor* GrRRectBlurEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLRRectBlurEffect, (*this));
+ return new GrGLRRectBlurEffect(*this);
}
bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvider,
return NULL;
}
- return SkNEW_ARGS(SkColorCubeFilter, (cubeData, cubeDimension));
+ return new SkColorCubeFilter(cubeData, cubeDimension);
}
SkColorCubeFilter::SkColorCubeFilter(SkData* cubeData, int cubeDimension)
class GrColorCubeEffect : public GrFragmentProcessor {
public:
static GrFragmentProcessor* Create(GrTexture* colorCube) {
- return (NULL != colorCube) ? SkNEW_ARGS(GrColorCubeEffect, (colorCube)) : NULL;
+ return (NULL != colorCube) ? new GrColorCubeEffect(colorCube) : NULL;
}
virtual ~GrColorCubeEffect();
}
GrGLFragmentProcessor* GrColorCubeEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLProcessor, (*this));
+ return new GLProcessor(*this);
}
void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
SkAutoUnref autoUnref(inputCF);
SkAutoTUnref<SkColorFilter> newCF(SkColorFilter::CreateComposeFilter(cf, inputCF));
if (newCF) {
- return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0), cropRect));
+ return new SkColorFilterImageFilter(newCF, input->getInput(0), cropRect);
}
}
- return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect));
+ return new SkColorFilterImageFilter(cf, input, cropRect);
}
SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
// SkDebugf("Failing to create color filter for mode %d\n", mode);
return NULL;
}
- return SkNEW_ARGS(ModeColorFilterEffect, (c, mode));
+ return new ModeColorFilterEffect(c, mode);
}
bool willUseFilterColor() const {
this->initClassID<ModeColorFilterEffect>();
}
- GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GLProcessor, (*this));
- }
+ GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLProcessor(*this); }
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
switch (mode) {
case SkXfermode::kSrc_Mode:
- return SkNEW_ARGS(Src_SkModeColorFilter, (color));
+ return new Src_SkModeColorFilter(color);
case SkXfermode::kSrcOver_Mode:
- return SkNEW_ARGS(SrcOver_SkModeColorFilter, (color));
+ return new SrcOver_SkModeColorFilter(color);
default:
- return SkNEW_ARGS(SkModeColorFilter, (color, mode));
+ return new SkModeColorFilter(color, mode);
}
}
class ColorMatrixEffect : public GrFragmentProcessor {
public:
static GrFragmentProcessor* Create(const SkColorMatrix& matrix) {
- return SkNEW_ARGS(ColorMatrixEffect, (matrix));
+ return new ColorMatrixEffect(matrix);
}
const char* name() const override { return "Color Matrix"; }
this->initClassID<ColorMatrixEffect>();
}
- GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GLProcessor, (*this));
- }
+ GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLProcessor(*this); }
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
}
SkImageFilter* inputs[2] = { displacement, color };
- return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
- inputs, cropRect));
+ return new SkDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, inputs, cropRect);
}
SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color,
const SkISize& colorDimensions) {
- return SkNEW_ARGS(GrDisplacementMapEffect, (procDataManager,
- xChannelSelector,
- yChannelSelector,
- scale,
- displacement,
- offsetMatrix,
- color,
- colorDimensions));
+ return new GrDisplacementMapEffect(procDataManager, xChannelSelector, yChannelSelector,
+ scale, displacement, offsetMatrix, color,
+ colorDimensions);
}
virtual ~GrDisplacementMapEffect();
private:
GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this));
+ return new GrGLDisplacementMapEffect(*this);
}
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
#include "SkString.h"
SkEmbossMaskFilter* SkEmbossMaskFilter::Create(SkScalar blurSigma, const Light& light) {
- return SkNEW_ARGS(SkEmbossMaskFilter, (blurSigma, light));
+ return new SkEmbossMaskFilter(blurSigma, light);
}
static inline int pin2byte(int n) {
Rec* rec = fRecs;
while (rec) {
Rec* next = rec->fNext;
- SkDELETE(rec);
+ delete rec;
rec = next;
}
}
SkLayerDrawLooper::Context* SkLayerDrawLooper::createContext(SkCanvas* canvas, void* storage) const {
canvas->save();
- return SkNEW_PLACEMENT_ARGS(storage, LayerDrawLooperContext, (this));
+ return new (storage) LayerDrawLooperContext(this);
}
static SkColor xferColor(SkColor src, SkColor dst, SkXfermode::Mode mode) {
Rec* rec = fRecs;
while (rec) {
Rec* next = rec->fNext;
- SkDELETE(rec);
+ delete rec;
rec = next;
}
}
SkPaint* SkLayerDrawLooper::Builder::addLayer(const LayerInfo& info) {
fCount += 1;
- Rec* rec = SkNEW(Rec);
+ Rec* rec = new Rec;
rec->fNext = fRecs;
rec->fInfo = info;
fRecs = rec;
SkPaint* SkLayerDrawLooper::Builder::addLayerOnTop(const LayerInfo& info) {
fCount += 1;
- Rec* rec = SkNEW(Rec);
+ Rec* rec = new Rec;
rec->fNext = NULL;
rec->fInfo = info;
if (NULL == fRecs) {
}
SkLayerDrawLooper* SkLayerDrawLooper::Builder::detachLooper() {
- SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper);
+ SkLayerDrawLooper* looper = new SkLayerDrawLooper;
looper->fCount = fCount;
looper->fRecs = fRecs;
SkVector fOffset;
};
-SkLayerRasterizer::SkLayerRasterizer()
- : fLayers(SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec))))
-{
-}
+SkLayerRasterizer::SkLayerRasterizer() : fLayers(new SkDeque(sizeof(SkLayerRasterizer_Rec))) {}
SkLayerRasterizer::SkLayerRasterizer(SkDeque* layers) : fLayers(layers)
{
while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL)
rec->fPaint.~SkPaint();
- SkDELETE(layers);
+ delete layers;
}
SkLayerRasterizer::~SkLayerRasterizer() {
}
SkFlattenable* SkLayerRasterizer::CreateProc(SkReadBuffer& buffer) {
- return SkNEW_ARGS(SkLayerRasterizer, (ReadLayers(buffer)));
+ return new SkLayerRasterizer(ReadLayers(buffer));
}
SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) {
int count = buffer.readInt();
- SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec)));
+ SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec));
for (int i = 0; i < count; i++) {
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back();
- SkNEW_PLACEMENT(&rec->fPaint, SkPaint);
+ new (&rec->fPaint) SkPaint;
buffer.readPaint(&rec->fPaint);
buffer.readPoint(&rec->fOffset);
}
}
}
-SkLayerRasterizer::Builder::Builder()
- : fLayers(SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec))))
-{
-}
+SkLayerRasterizer::Builder::Builder() : fLayers(new SkDeque(sizeof(SkLayerRasterizer_Rec))) {}
SkLayerRasterizer::Builder::~Builder()
{
SkASSERT(fLayers);
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers->push_back();
- SkNEW_PLACEMENT_ARGS(&rec->fPaint, SkPaint, (paint));
+ new (&rec->fPaint) SkPaint(paint);
rec->fOffset.set(dx, dy);
}
SkLayerRasterizer* rasterizer;
if (0 == fLayers->count()) {
rasterizer = NULL;
- SkDELETE(fLayers);
+ delete fLayers;
} else {
- rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers));
+ rasterizer = new SkLayerRasterizer(fLayers);
}
fLayers = NULL;
return rasterizer;
if (0 == fLayers->count()) {
return NULL;
}
- SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec), fLayers->count()));
+ SkDeque* layers = new SkDeque(sizeof(SkLayerRasterizer_Rec), fLayers->count());
SkDeque::F2BIter iter(*fLayers);
const SkLayerRasterizer_Rec* recOrig;
SkDEBUGCODE(int count = 0;)
while ((recOrig = static_cast<SkLayerRasterizer_Rec*>(iter.next())) != NULL) {
SkDEBUGCODE(count++);
SkLayerRasterizer_Rec* recCopy = static_cast<SkLayerRasterizer_Rec*>(layers->push_back());
- SkNEW_PLACEMENT_ARGS(&recCopy->fPaint, SkPaint, (recOrig->fPaint));
+ new (&recCopy->fPaint) SkPaint(recOrig->fPaint);
recCopy->fOffset = recOrig->fOffset;
}
SkASSERT(fLayers->count() == count);
SkASSERT(layers->count() == count);
- SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (layers));
+ SkLayerRasterizer* rasterizer = new SkLayerRasterizer(layers);
return rasterizer;
}
} else if (scale256 <= 0) {
return SkXfermode::Create(SkXfermode::kDst_Mode);
}
- return SkNEW_ARGS(SkLerpXfermode, (scale256));
+ return new SkLerpXfermode(scale256);
}
SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {}
}
SkFlattenable* SkLerpXfermode::CreateProc(SkReadBuffer& buffer) {
- return SkNEW_ARGS(SkLerpXfermode, (buffer.readUInt()));
+ return new SkLerpXfermode(buffer.readUInt());
}
void SkLerpXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count,
const SkMatrix& matrix,
SkScalar kd,
BoundaryMode boundaryMode) {
- return SkNEW_ARGS(GrDiffuseLightingEffect, (procDataManager,
- texture,
- light,
- surfaceScale,
- matrix,
- kd,
- boundaryMode));
+ return new GrDiffuseLightingEffect(procDataManager, texture, light, surfaceScale, matrix,
+ kd, boundaryMode);
}
const char* name() const override { return "DiffuseLighting"; }
SkScalar ks,
SkScalar shininess,
BoundaryMode boundaryMode) {
- return SkNEW_ARGS(GrSpecularLightingEffect, (procDataManager,
- texture,
- light,
- surfaceScale,
- matrix,
- ks,
- shininess,
- boundaryMode));
+ return new GrSpecularLightingEffect(procDataManager, texture, light, surfaceScale, matrix,
+ ks, shininess, boundaryMode);
}
const char* name() const override { return "SpecularLighting"; }
const SkPoint3& direction() const { return fDirection; }
GrGLLight* createGLLight() const override {
#if SK_SUPPORT_GPU
- return SkNEW(GrGLDistantLight);
+ return new GrGLDistantLight;
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return NULL;
const SkPoint3& location() const { return fLocation; }
GrGLLight* createGLLight() const override {
#if SK_SUPPORT_GPU
- return SkNEW(GrGLPointLight);
+ return new GrGLPointLight;
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return NULL;
}
GrGLLight* createGLLight() const override {
#if SK_SUPPORT_GPU
- return SkNEW(GrGLSpotLight);
+ return new GrGLSpotLight;
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return NULL;
switch (type) {
// Each of these constructors must first call SkLight's, so we'll read the baseclass
// then subclass, same order as flattenLight.
- case SkImageFilterLight::kDistant_LightType: return SkNEW_ARGS(SkDistantLight, (buffer));
- case SkImageFilterLight::kPoint_LightType: return SkNEW_ARGS(SkPointLight, (buffer));
- case SkImageFilterLight::kSpot_LightType: return SkNEW_ARGS(SkSpotLight, (buffer));
+ case SkImageFilterLight::kDistant_LightType:
+ return new SkDistantLight(buffer);
+ case SkImageFilterLight::kPoint_LightType:
+ return new SkPointLight(buffer);
+ case SkImageFilterLight::kSpot_LightType:
+ return new SkSpotLight(buffer);
default:
SkDEBUGFAIL("Unknown LightType.");
buffer.validate(false);
SkScalar kd,
SkImageFilter* input,
const CropRect* cropRect) {
- SkAutoTUnref<SkImageFilterLight> light(SkNEW_ARGS(SkDistantLight, (direction, lightColor)));
+ SkAutoTUnref<SkImageFilterLight> light(new SkDistantLight(direction, lightColor));
return SkDiffuseLightingImageFilter::Create(light, surfaceScale, kd, input, cropRect);
}
SkScalar kd,
SkImageFilter* input,
const CropRect* cropRect) {
- SkAutoTUnref<SkImageFilterLight> light(SkNEW_ARGS(SkPointLight, (location, lightColor)));
+ SkAutoTUnref<SkImageFilterLight> light(new SkPointLight(location, lightColor));
return SkDiffuseLightingImageFilter::Create(light, surfaceScale, kd, input, cropRect);
}
SkScalar kd,
SkImageFilter* input,
const CropRect* cropRect) {
- SkAutoTUnref<SkImageFilterLight> light(SkNEW_ARGS(SkSpotLight, (location, target,
- specularExponent,
- cutoffAngle, lightColor)));
+ SkAutoTUnref<SkImageFilterLight> light(
+ new SkSpotLight(location, target, specularExponent, cutoffAngle, lightColor));
return SkDiffuseLightingImageFilter::Create(light, surfaceScale, kd, input, cropRect);
}
SkScalar shine,
SkImageFilter* input,
const CropRect* cropRect) {
- SkAutoTUnref<SkImageFilterLight> light(SkNEW_ARGS(SkDistantLight, (direction, lightColor)));
+ SkAutoTUnref<SkImageFilterLight> light(new SkDistantLight(direction, lightColor));
return SkSpecularLightingImageFilter::Create(light, surfaceScale, ks, shine, input, cropRect);
}
SkScalar shine,
SkImageFilter* input,
const CropRect* cropRect) {
- SkAutoTUnref<SkImageFilterLight> light(SkNEW_ARGS(SkPointLight, (location, lightColor)));
+ SkAutoTUnref<SkImageFilterLight> light(new SkPointLight(location, lightColor));
return SkSpecularLightingImageFilter::Create(light, surfaceScale, ks, shine, input, cropRect);
}
SkScalar shine,
SkImageFilter* input,
const CropRect* cropRect) {
- SkAutoTUnref<SkImageFilterLight> light(SkNEW_ARGS(SkSpotLight, (location, target,
- specularExponent,
- cutoffAngle, lightColor)));
+ SkAutoTUnref<SkImageFilterLight> light(
+ new SkSpotLight(location, target, specularExponent, cutoffAngle, lightColor));
return SkSpecularLightingImageFilter::Create(light, surfaceScale, ks, shine, input, cropRect);
}
if (kd < 0) {
return NULL;
}
- return SkNEW_ARGS(SkDiffuseLightingImageFilter, (light, surfaceScale, kd, input, cropRect));
+ return new SkDiffuseLightingImageFilter(light, surfaceScale, kd, input, cropRect);
}
SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkImageFilterLight* light,
if (ks < 0) {
return NULL;
}
- return SkNEW_ARGS(SkSpecularLightingImageFilter,
- (light, surfaceScale, ks, shininess, input, cropRect));
+ return new SkSpecularLightingImageFilter(light, surfaceScale, ks, shininess, input, cropRect);
}
SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkImageFilterLight* light,
int type = random->nextULessThan(3);
switch (type) {
case 0: {
- return SkNEW_ARGS(SkDistantLight, (random_point3(random), random->nextU()));
+ return new SkDistantLight(random_point3(random), random->nextU());
}
case 1: {
- return SkNEW_ARGS(SkPointLight, (random_point3(random), random->nextU()));
+ return new SkPointLight(random_point3(random), random->nextU());
}
case 2: {
- return SkNEW_ARGS(SkSpotLight, (random_point3(random),
- random_point3(random),
- random->nextUScalar1(),
- random->nextUScalar1(),
- random->nextU()));
+ return new SkSpotLight(random_point3(random), random_point3(random),
+ random->nextUScalar1(), random->nextUScalar1(), random->nextU());
}
default:
SkFAIL("Unexpected value.");
}
GrGLFragmentProcessor* GrDiffuseLightingEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLDiffuseLightingEffect, (*this));
+ return new GrGLDiffuseLightingEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
}
GrGLFragmentProcessor* GrSpecularLightingEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLSpecularLightingEffect, (*this));
+ return new GrGLSpecularLightingEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
}
}
-SkColorFilter* SkLumaColorFilter::Create() {
- return SkNEW(SkLumaColorFilter);
-}
+SkColorFilter* SkLumaColorFilter::Create() { return new SkLumaColorFilter; }
SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {}
-SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) {
- return SkNEW(SkLumaColorFilter);
-}
+SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) { return new SkLumaColorFilter; }
void SkLumaColorFilter::flatten(SkWriteBuffer&) const {}
this->initClassID<LumaColorFilterEffect>();
}
- GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GLProcessor, (*this));
- }
+ GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLProcessor(*this); }
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
float yInvZoom,
float xInvInset,
float yInvInset) {
- return SkNEW_ARGS(GrMagnifierEffect, (procDataManager,
- texture,
- bounds,
- xOffset,
- yOffset,
- xInvZoom,
- yInvZoom,
- xInvInset,
- yInvInset));
+ return new GrMagnifierEffect(procDataManager, texture, bounds, xOffset, yOffset, xInvZoom,
+ yInvZoom, xInvInset, yInvInset);
}
virtual ~GrMagnifierEffect() {};
}
GrGLFragmentProcessor* GrMagnifierEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLMagnifierEffect, (*this));
+ return new GrGLMagnifierEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
if (srcRect.fLeft < 0 || srcRect.fTop < 0) {
return NULL;
}
- return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset, input));
+ return new SkMagnifierImageFilter(srcRect, inset, input);
}
fTileMode(tileMode),
fConvolveAlpha(convolveAlpha) {
size_t size = (size_t) sk_64_mul(fKernelSize.width(), fKernelSize.height());
- fKernel = SkNEW_ARRAY(SkScalar, size);
+ fKernel = new SkScalar[size];
memcpy(fKernel, kernel, size * sizeof(SkScalar));
SkASSERT(kernelSize.fWidth >= 1 && kernelSize.fHeight >= 1);
SkASSERT(kernelOffset.fX >= 0 && kernelOffset.fX < kernelSize.fWidth);
(kernelOffset.fY < 0) || (kernelOffset.fY >= kernelSize.fHeight)) {
return NULL;
}
- return SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, kernel, gain, bias,
- kernelOffset, tileMode, convolveAlpha,
- input, cropRect));
+ return new SkMatrixConvolutionImageFilter(kernelSize, kernel, gain, bias, kernelOffset,
+ tileMode, convolveAlpha, input, cropRect);
}
SkFlattenable* SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) {
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* tex,
Direction dir, int radius, MorphologyType type) {
- return SkNEW_ARGS(GrMorphologyEffect, (procDataManager, tex, dir, radius, type));
+ return new GrMorphologyEffect(procDataManager, tex, dir, radius, type);
}
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* tex,
Direction dir, int radius, MorphologyType type,
float bounds[2]) {
- return SkNEW_ARGS(GrMorphologyEffect, (procDataManager, tex, dir, radius, type, bounds));
+ return new GrMorphologyEffect(procDataManager, tex, dir, radius, type, bounds);
}
virtual ~GrMorphologyEffect();
}
GrGLFragmentProcessor* GrMorphologyEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLMorphologyEffect, (*this));
+ return new GrGLMorphologyEffect(*this);
}
bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
int numOctaves, SkScalar seed,
const SkISize* tileSize) {
- return SkNEW_ARGS(SkPerlinNoiseShader, (kFractalNoise_Type, baseFrequencyX, baseFrequencyY,
- numOctaves, seed, tileSize));
+ return new SkPerlinNoiseShader(kFractalNoise_Type, baseFrequencyX, baseFrequencyY, numOctaves,
+ seed, tileSize);
}
SkShader* SkPerlinNoiseShader::CreateTurbulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
int numOctaves, SkScalar seed,
const SkISize* tileSize) {
- return SkNEW_ARGS(SkPerlinNoiseShader, (kTurbulence_Type, baseFrequencyX, baseFrequencyY,
- numOctaves, seed, tileSize));
+ return new SkPerlinNoiseShader(kTurbulence_Type, baseFrequencyX, baseFrequencyY, numOctaves,
+ seed, tileSize);
}
SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type,
SkShader::Context* SkPerlinNoiseShader::onCreateContext(const ContextRec& rec,
void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, PerlinNoiseShaderContext, (*this, rec));
+ return new (storage) PerlinNoiseShaderContext(*this, rec);
}
size_t SkPerlinNoiseShader::contextSize() const {
// This (1,1) translation is due to WebKit's 1 based coordinates for the noise
// (as opposed to 0 based, usually). The same adjustment is in the setData() function.
fMatrix.setTranslate(-newMatrix.getTranslateX() + SK_Scalar1, -newMatrix.getTranslateY() + SK_Scalar1);
- fPaintingData = SkNEW_ARGS(PaintingData, (shader.fTileSize, shader.fSeed, shader.fBaseFrequencyX, shader.fBaseFrequencyY, newMatrix));
+ fPaintingData = new PaintingData(shader.fTileSize, shader.fSeed, shader.fBaseFrequencyX,
+ shader.fBaseFrequencyY, newMatrix);
}
-SkPerlinNoiseShader::PerlinNoiseShaderContext::~PerlinNoiseShaderContext() {
- SkDELETE(fPaintingData);
-}
+SkPerlinNoiseShader::PerlinNoiseShaderContext::~PerlinNoiseShaderContext() { delete fPaintingData; }
void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan(
int x, int y, SkPMColor result[], int count) {
SkPerlinNoiseShader::PaintingData* paintingData,
GrTexture* permutationsTexture, GrTexture* noiseTexture,
const SkMatrix& matrix, uint8_t alpha) {
- return SkNEW_ARGS(GrPerlinNoiseEffect, (procDataManager, type, numOctaves, stitchTiles,
- paintingData, permutationsTexture, noiseTexture,
- matrix, alpha));
+ return new GrPerlinNoiseEffect(procDataManager, type, numOctaves, stitchTiles, paintingData,
+ permutationsTexture, noiseTexture, matrix, alpha);
}
- virtual ~GrPerlinNoiseEffect() {
- SkDELETE(fPaintingData);
- }
+ virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
const char* name() const override { return "PerlinNoise"; }
private:
GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GrGLPerlinNoise, (*this));
+ return new GrGLPerlinNoise(*this);
}
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
&paintColor, grPaint.getProcessorDataManager(),
&effect));
- SkDELETE(shader);
+ delete shader;
return effect;
}
SkASSERT(!fStitchTiles || !fTileSize.isEmpty());
SkPerlinNoiseShader::PaintingData* paintingData =
- SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix));
+ new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
SkAutoTUnref<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), NULL));
SkAutoTUnref<GrTexture> noiseTexture(
permutationsTexture, noiseTexture,
m, paint.getAlpha());
} else {
- SkDELETE(paintingData);
+ delete paintingData;
*fp = NULL;
}
return true;
flags = 0x0;
}
CropRect cropRect(rect, flags);
- return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)) : NULL;
+ return s ? new SkRectShaderImageFilter(s, &cropRect) : NULL;
}
SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) {
SkASSERT(s);
- return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect)) : NULL;
+ return s ? new SkRectShaderImageFilter(s, cropRect) : NULL;
}
SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect)
}
}
- virtual ~SkTable_ColorFilter() {
- SkDELETE(fBitmap);
- }
+ virtual ~SkTable_ColorFilter() { delete fBitmap; }
bool asComponentTable(SkBitmap* table) const override;
SkColorFilter* newComposed(const SkColorFilter* inner) const override;
bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
if (table) {
if (NULL == fBitmap) {
- SkBitmap* bmp = SkNEW(SkBitmap);
+ SkBitmap* bmp = new SkBitmap;
bmp->allocPixels(SkImageInfo::MakeA8(256, 4));
uint8_t* bitmapPixels = bmp->getAddr8(0, 0);
int offset = 0;
texture.reset(SkRef(atlas->getTexture()));
}
- return SkNEW_ARGS(ColorTableEffect, (texture, atlas, row, flags));
+ return new ColorTableEffect(texture, atlas, row, flags);
}
ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row,
}
GrGLFragmentProcessor* ColorTableEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLColorTableEffect, (*this));
+ return new GLColorTableEffect(*this);
}
bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const {
///////////////////////////////////////////////////////////////////////////////
SkColorFilter* SkTableColorFilter::Create(const uint8_t table[256]) {
- return SkNEW_ARGS(SkTable_ColorFilter, (table, table, table, table));
+ return new SkTable_ColorFilter(table, table, table, table);
}
SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256],
const uint8_t tableR[256],
const uint8_t tableG[256],
const uint8_t tableB[256]) {
- return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB));
+ return new SkTable_ColorFilter(tableA, tableR, tableG, tableB);
}
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter)
if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) {
return NULL;
}
- return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input));
+ return new SkTileImageFilter(srcRect, dstRect, input);
}
bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
fEntryCount -= 1;
}
- Entry* entry = SkNEW_ARGS(Entry, (buffer, len, bm));
+ Entry* entry = new Entry(buffer, len, bm);
this->attachToHead(entry);
fEntryCount += 1;
}
SkGradientShaderBase::GradientShaderCache* SkGradientShaderBase::refCache(U8CPU alpha) const {
SkAutoMutexAcquire ama(fCacheMutex);
if (!fCache || fCache->getAlpha() != alpha) {
- fCache.reset(SkNEW_ARGS(GradientShaderCache, (alpha, *this)));
+ fCache.reset(new GradientShaderCache(alpha, *this));
}
// Increment the ref counter inside the mutex to ensure the returned pointer is still valid.
// Otherwise, the pointer may have been overwritten on a different thread before the object's
SkAutoMutexAcquire ama(gGradientCacheMutex);
if (NULL == gCache) {
- gCache = SkNEW_ARGS(SkGradientBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITMAPS));
+ gCache = new SkGradientBitmapCache(MAX_NUM_CACHED_GRADIENT_BITMAPS);
}
size_t size = count * sizeof(int32_t);
SkGradientShaderBase::Descriptor desc;
desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix);
- return SkNEW_ARGS(SkLinearGradient, (pts, desc));
+ return new SkLinearGradient(pts, desc);
}
SkShader* SkGradientShader::CreateRadial(const SkPoint& center, SkScalar radius,
SkGradientShaderBase::Descriptor desc;
desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix);
- return SkNEW_ARGS(SkRadialGradient, (center, radius, desc));
+ return new SkRadialGradient(center, radius, desc);
}
SkShader* SkGradientShader::CreateTwoPointConical(const SkPoint& start,
if (!flipGradient) {
desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix);
- return SkNEW_ARGS(SkTwoPointConicalGradient,
- (start, startRadius, end, endRadius, flipGradient, desc));
+ return new SkTwoPointConicalGradient(start, startRadius, end, endRadius, flipGradient,
+ desc);
} else {
SkAutoSTArray<8, SkColor> colorsNew(colorCount);
SkAutoSTArray<8, SkScalar> posNew(colorCount);
desc_init(&desc, colorsNew.get(), NULL, colorCount, mode, flags, localMatrix);
}
- return SkNEW_ARGS(SkTwoPointConicalGradient,
- (end, endRadius, start, startRadius, flipGradient, desc));
+ return new SkTwoPointConicalGradient(end, endRadius, start, startRadius, flipGradient,
+ desc);
}
}
SkGradientShaderBase::Descriptor desc;
desc_init(&desc, colors, pos, colorCount, SkShader::kClamp_TileMode, flags, localMatrix);
- return SkNEW_ARGS(SkSweepGradient, (cx, cy, desc));
+ return new SkSweepGradient(cx, cy, desc);
}
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkGradientShader)
}
SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, LinearGradientContext, (*this, rec));
+ return new (storage) LinearGradientContext(*this, rec);
}
SkLinearGradient::LinearGradientContext::LinearGradientContext(
const SkLinearGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- return SkNEW_ARGS(GrLinearGradient, (ctx, procDataManager, shader, matrix, tm));
+ return new GrLinearGradient(ctx, procDataManager, shader, matrix, tm);
}
virtual ~GrLinearGradient() { }
}
GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GrGLLinearGradient, (*this));
+ return new GrGLLinearGradient(*this);
}
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
}
SkShader::Context* SkRadialGradient::onCreateContext(const ContextRec& rec, void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, RadialGradientContext, (*this, rec));
+ return new (storage) RadialGradientContext(*this, rec);
}
SkRadialGradient::RadialGradientContext::RadialGradientContext(
const SkRadialGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- return SkNEW_ARGS(GrRadialGradient, (ctx, procDataManager, shader, matrix, tm));
+ return new GrRadialGradient(ctx, procDataManager, shader, matrix, tm);
}
virtual ~GrRadialGradient() { }
}
GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GrGLRadialGradient, (*this));
+ return new GrGLRadialGradient(*this);
}
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
}
SkShader::Context* SkSweepGradient::onCreateContext(const ContextRec& rec, void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, SweepGradientContext, (*this, rec));
+ return new (storage) SweepGradientContext(*this, rec);
}
SkSweepGradient::SweepGradientContext::SweepGradientContext(
public:
static GrFragmentProcessor* Create(GrContext* ctx, GrProcessorDataManager* procDataManager,
const SkSweepGradient& shader, const SkMatrix& m) {
- return SkNEW_ARGS(GrSweepGradient, (ctx, procDataManager, shader, m));
+ return new GrSweepGradient(ctx, procDataManager, shader, m);
}
virtual ~GrSweepGradient() { }
}
GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GrGLSweepGradient, (*this));
+ return new GrGLSweepGradient(*this);
}
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
SkShader::Context* SkTwoPointConicalGradient::onCreateContext(const ContextRec& rec,
void* storage) const {
- return SkNEW_PLACEMENT_ARGS(storage, TwoPointConicalGradientContext, (*this, rec));
+ return new (storage) TwoPointConicalGradientContext(*this, rec);
}
SkTwoPointConicalGradient::TwoPointConicalGradientContext::TwoPointConicalGradientContext(
const SkTwoPointConicalGradient& shader,
const SkMatrix& matrix,
SkShader::TileMode tm) {
- return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, procDataManager, shader, matrix, tm));
+ return new Edge2PtConicalEffect(ctx, procDataManager, shader, matrix, tm);
}
virtual ~Edge2PtConicalEffect() {}
}
GrGLFragmentProcessor* Edge2PtConicalEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLEdge2PtConicalEffect, (*this));
+ return new GLEdge2PtConicalEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect);
const SkMatrix& matrix,
SkShader::TileMode tm,
SkScalar focalX) {
- return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, procDataManager, shader, matrix, tm,
- focalX));
+ return new FocalOutside2PtConicalEffect(ctx, procDataManager, shader, matrix, tm, focalX);
}
virtual ~FocalOutside2PtConicalEffect() { }
}
GrGLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLFocalOutside2PtConicalEffect, (*this));
+ return new GLFocalOutside2PtConicalEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect);
const SkMatrix& matrix,
SkShader::TileMode tm,
SkScalar focalX) {
- return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, procDataManager, shader, matrix, tm,
- focalX));
+ return new FocalInside2PtConicalEffect(ctx, procDataManager, shader, matrix, tm, focalX);
}
virtual ~FocalInside2PtConicalEffect() {}
}
GrGLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLFocalInside2PtConicalEffect, (*this));
+ return new GLFocalInside2PtConicalEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect);
const SkMatrix& matrix,
SkShader::TileMode tm,
const CircleConicalInfo& info) {
- return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, procDataManager, shader, matrix, tm,
- info));
+ return new CircleInside2PtConicalEffect(ctx, procDataManager, shader, matrix, tm, info);
}
virtual ~CircleInside2PtConicalEffect() {}
}
GrGLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLCircleInside2PtConicalEffect, (*this));
+ return new GLCircleInside2PtConicalEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect);
const SkMatrix& matrix,
SkShader::TileMode tm,
const CircleConicalInfo& info) {
- return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, procDataManager, shader, matrix,
- tm, info));
+ return new CircleOutside2PtConicalEffect(ctx, procDataManager, shader, matrix, tm, info);
}
virtual ~CircleOutside2PtConicalEffect() {}
}
GrGLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLCircleOutside2PtConicalEffect, (*this));
+ return new GLCircleOutside2PtConicalEffect(*this);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect);
SkFontStyleSet_FC::SkFontStyleSet_FC(FcPattern** matches, int count) {
fRecCount = count;
- fRecs = SkNEW_ARRAY(Rec, count);
+ fRecs = new Rec[count];
for (int i = 0; i < count; ++i) {
fRecs[i].fStyleName.set(get_name(matches[i], FC_STYLE));
fRecs[i].fFileName.set(get_name(matches[i], FC_FILE));
}
}
-SkFontStyleSet_FC::~SkFontStyleSet_FC() {
- SkDELETE_ARRAY(fRecs);
-}
+SkFontStyleSet_FC::~SkFontStyleSet_FC() { delete[] fRecs; }
void SkFontStyleSet_FC::getStyle(int index, SkFontStyle* style,
SkString* styleName) {
}
}
- SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC,
- (trimmedMatches.begin(),
- trimmedMatches.count()));
+ SkFontStyleSet_FC* sset =
+ new SkFontStyleSet_FC(trimmedMatches.begin(), trimmedMatches.count());
return sset;
}
SkFontMgr* SkFontMgr::Factory() {
SkFontConfigInterface* fci = RefFCI();
- return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
+ return fci ? new SkFontMgr_fontconfig(fci) : NULL;
}
if (NULL == set) {
return NULL;
}
- return SkNEW_ARGS(SkStyleSet_Indirect, (this, index, set));
+ return new SkStyleSet_Indirect(this, index, set);
}
SkFontStyleSet* SkFontMgr_Indirect::onMatchFamily(const char familyName[]) const {
- return SkNEW_ARGS(SkStyleSet_Indirect, (this, -1, fProxy->matchName(familyName)));
+ return new SkStyleSet_Indirect(this, -1, fProxy->matchName(familyName));
}
SkTypeface* SkFontMgr_Indirect::createTypefaceFromFontId(const SkFontIdentity& id) const {
fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
}
-SkGScalerContext::~SkGScalerContext() {
- SkDELETE(fProxy);
-}
+SkGScalerContext::~SkGScalerContext() { delete fProxy; }
unsigned SkGScalerContext::generateGlyphCount() {
return fProxy->getGlyphCount();
SkScalerContext* SkGTypeface::onCreateScalerContext(
const SkDescriptor* desc) const {
- return SkNEW_ARGS(SkGScalerContext, (const_cast<SkGTypeface*>(this), desc));
+ return new SkGScalerContext(const_cast<SkGTypeface*>(this), desc);
}
void SkGTypeface::onFilterRec(SkScalerContextRec* rec) const {
fProxy = face->proxy()->createScalerContext(desc);
}
-SkRandomScalerContext::~SkRandomScalerContext() {
- SkDELETE(fProxy);
-}
+SkRandomScalerContext::~SkRandomScalerContext() { delete fProxy; }
unsigned SkRandomScalerContext::generateGlyphCount() {
return fProxy->getGlyphCount();
SkScalerContext* SkRandomTypeface::onCreateScalerContext(
const SkDescriptor* desc) const {
- return SkNEW_ARGS(SkRandomScalerContext, (const_cast<SkRandomTypeface*>(this), desc, fFakeIt));
+ return new SkRandomScalerContext(const_cast<SkRandomTypeface*>(this), desc, fFakeIt);
}
void SkRandomTypeface::onFilterRec(SkScalerContextRec* rec) const {
// As a template argument, this must have external linkage.
SkRemotableFontIdentitySet* sk_remotable_font_identity_set_new() {
- return SkNEW(SkRemotableFontIdentitySet);
+ return new SkRemotableFontIdentitySet;
}
SK_DECLARE_STATIC_LAZY_PTR(SkRemotableFontIdentitySet, empty, sk_remotable_font_identity_set_new);
SkTestFont::~SkTestFont() {
for (unsigned index = 0; index < fCharCodesCount; ++index) {
- SkDELETE(fPaths[index]);
+ delete fPaths[index];
}
- SkDELETE_ARRAY(fPaths);
+ delete[] fPaths;
}
#ifdef SK_DEBUG
}
void SkTestFont::init(const SkScalar* pts, const unsigned char* verbs) {
- fPaths = SkNEW_ARRAY(SkPath*, fCharCodesCount);
+ fPaths = new SkPath* [fCharCodesCount];
for (unsigned index = 0; index < fCharCodesCount; ++index) {
- SkPath* path = SkNEW(SkPath);
+ SkPath* path = new SkPath;
SkPath::Verb verb;
while ((verb = (SkPath::Verb) *verbs++) != SkPath::kDone_Verb) {
switch (verb) {
};
SkScalerContext* SkTestTypeface::onCreateScalerContext(const SkDescriptor* desc) const {
- return SkNEW_ARGS(SkTestScalerContext, (const_cast<SkTestTypeface*>(this), desc));
+ return new SkTestScalerContext(const_cast<SkTestTypeface*>(this), desc);
}
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix, usesLocalCoords));
+ return new QuadEdgeEffect(color, localMatrix, usesLocalCoords);
}
virtual ~QuadEdgeEffect() {}
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const override {
- return SkNEW_ARGS(GLProcessor, (*this, bt));
+ return new GLProcessor(*this, bt);
}
private:
SkPath fPath;
};
- static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(AAConvexPathBatch, (geometry));
- }
+ static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPathBatch(geometry); }
const char* name() const override { return "AAConvexBatch"; }
GrAAConvexTessellator::Ring* GrAAConvexTessellator::getNextRing(Ring* lastRing) {
#if GR_AA_CONVEX_TESSELLATOR_VIZ
- Ring* ring = *fRings.push() = SkNEW(Ring);
+ Ring* ring = *fRings.push() = new Ring;
ring->setReserve(fInitialRing.numPts());
ring->rewind();
return ring;
if (id == pathData->fID) {
dfpr->fPathCache.remove(pathData->fKey);
dfpr->fPathList.remove(pathData);
- SkDELETE(pathData);
+ delete pathData;
#ifdef DF_PATH_TRACKING
++g_NumFreedPaths;
#endif
while ((pathData = iter.get())) {
iter.next();
fPathList.remove(pathData);
- SkDELETE(pathData);
+ delete pathData;
}
- SkDELETE(fAtlas);
+ delete fAtlas;
#ifdef DF_PATH_TRACKING
SkDebugf("Cached paths: %d, freed paths: %d\n", g_NumCachedPaths, g_NumFreedPaths);
static GrDrawBatch* Create(const Geometry& geometry, GrColor color, const SkMatrix& viewMatrix,
GrBatchAtlas* atlas, PathCache* pathCache, PathDataList* pathList) {
- return SkNEW_ARGS(AADistanceFieldPathBatch, (geometry, color, viewMatrix,
- atlas, pathCache, pathList));
+ return new AADistanceFieldPathBatch(geometry, color, viewMatrix, atlas, pathCache,
+ pathList);
}
const char* name() const override { return "AADistanceFieldPathBatch"; }
if (args.fPathData) {
fPathCache->remove(args.fPathData->fKey);
fPathList->remove(args.fPathData);
- SkDELETE(args.fPathData);
+ delete args.fPathData;
}
SkScalar scale = desiredDimension/maxDim;
- args.fPathData = SkNEW(PathData);
+ args.fPathData = new PathData;
if (!this->addPathToAtlas(target,
dfProcessor,
this->pipeline(),
while ((pathData = iter.get())) {
iter.next();
fPathList.remove(pathData);
- SkDELETE(pathData);
+ delete pathData;
}
- SkDELETE(fAtlas);
+ delete fAtlas;
fPathCache.reset();
}
if (id == pathData->fID) {
dfpr->fPathCache.remove(pathData->fKey);
dfpr->fPathList.remove(pathData);
- SkDELETE(pathData);
+ delete pathData;
}
}
}
SkIRect fDevClipBounds;
};
- static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(AAHairlineBatch, (geometry));
- }
+ static GrDrawBatch* Create(const Geometry& geometry) { return new AAHairlineBatch(geometry); }
const char* name() const override { return "AAHairlineBatch"; }
class GrAAHairLinePathRenderer : public GrPathRenderer {
public:
- static GrPathRenderer* Create() { return SkNEW(GrAAHairLinePathRenderer); }
+ static GrPathRenderer* Create() { return new GrAAHairLinePathRenderer; }
typedef SkTArray<SkPoint, true> PtArray;
typedef SkTArray<int, true> IntArray;
};
static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(AAFlatteningConvexPathBatch, (geometry));
+ return new AAFlatteningConvexPathBatch(geometry);
}
const char* name() const override { return "AAConvexBatch"; }
#include "GrTessellatingPathRenderer.h"
void GrPathRenderer::AddPathRenderers(GrContext* ctx, GrPathRendererChain* chain) {
- chain->addPathRenderer(SkNEW(GrDashLinePathRenderer))->unref();
+ chain->addPathRenderer(new GrDashLinePathRenderer)->unref();
if (GrPathRenderer* pr = GrStencilAndCoverPathRenderer::Create(ctx->resourceProvider(),
*ctx->caps())) {
chain->addPathRenderer(pr)->unref();
}
- chain->addPathRenderer(SkNEW(GrTessellatingPathRenderer))->unref();
+ chain->addPathRenderer(new GrTessellatingPathRenderer)->unref();
if (GrPathRenderer* pr = GrAAHairLinePathRenderer::Create()) {
chain->addPathRenderer(pr)->unref();
}
- chain->addPathRenderer(SkNEW(GrAAConvexPathRenderer))->unref();
- chain->addPathRenderer(SkNEW(GrAALinearizingConvexPathRenderer))->unref();
- chain->addPathRenderer(SkNEW(GrAADistanceFieldPathRenderer))->unref();
+ chain->addPathRenderer(new GrAAConvexPathRenderer)->unref();
+ chain->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref();
+ chain->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref();
}
T& push_back() {
void* item = fAllocator.push_back();
SkASSERT(item);
- SkNEW_PLACEMENT(item, T);
+ new (item) T;
return *(T*)item;
}
T& push_back(const T& t) {
void* item = fAllocator.push_back();
SkASSERT(item);
- SkNEW_PLACEMENT_ARGS(item, T, (t));
+ new (item) T(t);
return *(T*)item;
}
}
GrPlot::~GrPlot() {
- SkDELETE_ARRAY(fPlotData);
+ delete[] fPlotData;
fPlotData = NULL;
delete fRects;
}
int plotWidth = fRects->width();
int plotHeight = fRects->height();
if (fBatchUploads && NULL == fPlotData && 0.0f == percentFull) {
- fPlotData = SkNEW_ARRAY(unsigned char, fBytesPerPixel*plotWidth*plotHeight);
+ fPlotData = new unsigned char[fBytesPerPixel * plotWidth * plotHeight];
memset(fPlotData, 0, fBytesPerPixel*plotWidth*plotHeight);
}
// set up allocated plots
size_t bpp = GrBytesPerPixel(fPixelConfig);
- fPlotArray = SkNEW_ARRAY(GrPlot, (fNumPlotsX*fNumPlotsY));
+ fPlotArray = new GrPlot[(fNumPlotsX * fNumPlotsY)];
GrPlot* currPlot = fPlotArray;
for (int y = numPlotsY-1; y >= 0; --y) {
GrAtlas::~GrAtlas() {
SkSafeUnref(fTexture);
- SkDELETE_ARRAY(fPlotArray);
+ delete[] fPlotArray;
fGpu->unref();
#if FONT_CACHE_STATS
GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
GrDrawContext* drawContext,
const SkSurfaceProps& surfaceProps)
- : INHERITED(context, drawContext, surfaceProps)
- , fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) {
+ : INHERITED(context, drawContext, surfaceProps), fDistanceAdjustTable(new DistanceAdjustTable) {
// We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
// vertexStride
static_assert(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= kLCDTextVASize,
&width, &height);
SkASSERT(kExpectedDistanceAdjustTableSize == height);
- fTable = SkNEW_ARRAY(SkScalar, height);
+ fTable = new SkScalar[height];
SkAutoTArray<uint8_t> data((int)size);
SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data.get());
GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context,
GrDrawContext* drawContext,
const SkSurfaceProps& surfaceProps) {
- return SkNEW_ARGS(GrAtlasTextContext, (context, drawContext, surfaceProps));
+ return new GrAtlasTextContext(context, drawContext, surfaceProps);
}
bool GrAtlasTextContext::canDraw(const GrRenderTarget*,
Run& run = blob->fRuns[runIndex];
// Push back a new subrun to fill and set the override descriptor
run.push_back();
- run.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor));
+ run.fOverrideDescriptor.reset(new SkAutoDescriptor);
skPaint.getScalerContextDescriptor(run.fOverrideDescriptor,
fSurfaceProps, &viewMatrix, false);
SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
return;
}
- glyph->fPath = SkNEW_ARGS(SkPath, (*glyphPath));
+ glyph->fPath = new SkPath(*glyphPath);
}
blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, applyVM));
}
static TextBatch* CreateBitmap(GrMaskFormat maskFormat, int glyphCount,
GrBatchFontCache* fontCache) {
- TextBatch* batch = SkNEW(TextBatch);
+ TextBatch* batch = new TextBatch;
batch->initClassID<TextBatch>();
batch->fFontCache = fontCache;
DistanceAdjustTable* distanceAdjustTable,
SkColor filteredColor, bool isLCD,
bool useBGR) {
- TextBatch* batch = SkNEW(TextBatch);
+ TextBatch* batch = new TextBatch;
batch->initClassID<TextBatch>();
batch->fFontCache = fontCache;
batch->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistanceField_MaskType;
if (context->uniqueID() != gContextID) {
gContextID = context->uniqueID();
- SkDELETE(gTextContext);
+ delete gTextContext;
// We don't yet test the fall back to paths in the GrTextContext base class. This is mostly
// because we don't really want to have a gpu device here.
// refcnted and malloced
struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> {
DistanceAdjustTable() { this->buildDistanceAdjustTable(); }
- ~DistanceAdjustTable() { SkDELETE_ARRAY(fTable); }
+ ~DistanceAdjustTable() { delete[] fTable; }
const SkScalar& operator[] (int i) const {
return fTable[i];
// set up allocated plots
fBPP = GrBytesPerPixel(texture->desc().fConfig);
- fPlotArray = SkNEW_ARRAY(SkAutoTUnref<BatchPlot>, (fNumPlotsX * fNumPlotsY));
+ fPlotArray = new SkAutoTUnref<BatchPlot>[(fNumPlotsX * fNumPlotsY)];
SkAutoTUnref<BatchPlot>* currPlot = fPlotArray;
for (int y = fNumPlotsY - 1, r = 0; y >= 0; --y, ++r) {
for (int x = fNumPlotsX - 1, c = 0; x >= 0; --x, ++c) {
uint32_t id = r * fNumPlotsX + c;
- currPlot->reset(SkNEW(BatchPlot));
+ currPlot->reset(new BatchPlot);
(*currPlot)->init(this, texture, id, 1, x, y, fPlotWidth, fPlotHeight, fBPP);
// build LRU list
GrBatchAtlas::~GrBatchAtlas() {
SkSafeUnref(fTexture);
- SkDELETE_ARRAY(fPlotArray);
+ delete[] fPlotArray;
}
void GrBatchAtlas::processEviction(AtlasID id) {
// This new update will piggy back on that previously scheduled update.
if (target->hasTokenBeenFlushed(plot->lastUploadToken())) {
plot->setLastUploadToken(target->asapToken());
- SkAutoTUnref<GrPlotUploader> uploader(SkNEW_ARGS(GrPlotUploader, (plot)));
+ SkAutoTUnref<GrPlotUploader> uploader(new GrPlotUploader(plot));
target->upload(uploader);
}
*id = plot->id();
this->processEviction(plot->id());
fPlotList.remove(plot);
SkAutoTUnref<BatchPlot>& newPlot = fPlotArray[plot->index()];
- newPlot.reset(SkNEW(BatchPlot));
+ newPlot.reset(new BatchPlot);
newPlot->init(this, fTexture, index, ++generation, x, y, fPlotWidth, fPlotHeight, fBPP);
fPlotList.addToHead(newPlot.get());
SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc, fBPP * width);
SkASSERT(verify);
newPlot->setLastUploadToken(batchTarget->currentToken());
- SkAutoTUnref<GrPlotUploader> uploader(SkNEW_ARGS(GrPlotUploader, (newPlot)));
+ SkAutoTUnref<GrPlotUploader> uploader(new GrPlotUploader(newPlot));
batchTarget->upload(uploader);
*id = newPlot->id();
plot->unref();
++iter;
}
for (int i = 0; i < kMaskFormatCount; ++i) {
- SkDELETE(fAtlases[i]);
+ delete fAtlases[i];
}
}
}
fCache.rewind();
for (int i = 0; i < kMaskFormatCount; ++i) {
- SkDELETE(fAtlases[i]);
+ delete fAtlases[i];
fAtlases[i] = NULL;
}
}
// flush
for (int i = 0; i < kMaskFormatCount; i++) {
if (fAtlases[i]) {
- SkDELETE(fAtlases[i]);
+ delete fAtlases[i];
fAtlases[i] = NULL;
}
}
bool initAtlas(GrMaskFormat);
GrBatchTextStrike* generateStrike(GrFontScaler* scaler) {
- GrBatchTextStrike* strike = SkNEW_ARGS(GrBatchTextStrike, (this, scaler->getKey()));
+ GrBatchTextStrike* strike = new GrBatchTextStrike(this, scaler->getKey());
fCache.add(strike);
return strike;
}
StateForPathDraw* allocState(const GrPrimitiveProcessor* primProc = NULL) {
void* allocation = fPipelineBuffer.alloc(sizeof(StateForPathDraw),
SkChunkAlloc::kThrow_AllocFailType);
- return SkNEW_PLACEMENT_ARGS(allocation, StateForPathDraw, (primProc));
+ return new (allocation) StateForPathDraw(primProc);
}
void unallocState(StateForPathDraw* state) {
, fResourceProvider(resourceProvider) {
// We need an initial frame to capture the clip state prior to
// any pushes
- SkNEW_PLACEMENT(fStack.push_back(), GrClipStackFrame);
+ new (fStack.push_back()) GrClipStackFrame;
}
-void GrClipMaskCache::push() {
- SkNEW_PLACEMENT(fStack.push_back(), GrClipStackFrame);
-}
+void GrClipMaskCache::push() { new (fStack.push_back()) GrClipStackFrame; }
GrCommandBuilder* GrCommandBuilder::Create(GrGpu* gpu, bool reorder) {
if (reorder) {
- return SkNEW(GrReorderCommandBuilder);
+ return new GrReorderCommandBuilder;
} else {
- return SkNEW(GrInOrderCommandBuilder);
+ return new GrInOrderCommandBuilder;
}
}
fContext = context;
#ifdef IMMEDIATE_MODE
- fDrawTarget = SkNEW_ARGS(GrImmediateDrawTarget, (context));
+ fDrawTarget = new GrImmediateDrawTarget(context);
#else
- fDrawTarget = SkNEW_ARGS(GrBufferedDrawTarget, (context));
+ fDrawTarget = new GrBufferedDrawTarget(context);
#endif
}
SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
if (!fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]) {
fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()] =
- SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, props));
+ new GrDrawContext(fContext, fDrawTarget, props);
}
return fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()];
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
const GrContextOptions& options) {
- GrContext* context = SkNEW(GrContext);
+ GrContext* context = new GrContext;
if (context->init(backend, backendContext, options)) {
return context;
void GrContext::initCommon() {
fCaps = SkRef(fGpu->caps());
- fResourceCache = SkNEW_ARGS(GrResourceCache, (fCaps));
+ fResourceCache = new GrResourceCache(fCaps);
fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
- fResourceProvider = SkNEW_ARGS(GrResourceProvider, (fGpu, fResourceCache));
+ fResourceProvider = new GrResourceProvider(fGpu, fResourceCache);
- fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this)));
+ fLayerCache.reset(new GrLayerCache(this));
fDidTestPMConversions = false;
fDrawingMgr.init(this);
// GrBatchFontCache will eventually replace GrFontCache
- fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this));
+ fBatchFontCache = new GrBatchFontCache(this);
- fTextBlobCache.reset(SkNEW_ARGS(GrTextBlobCache, (TextBlobCacheOverBudgetCB, this)));
+ fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this));
}
GrContext::~GrContext() {
(*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
}
- SkDELETE(fResourceProvider);
- SkDELETE(fResourceCache);
- SkDELETE(fBatchFontCache);
+ delete fResourceProvider;
+ delete fResourceCache;
+ delete fBatchFontCache;
fGpu->unref();
fCaps->unref();
GrPathRendererChain::StencilSupport* stencilSupport) {
if (!fPathRendererChain) {
- fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this));
+ fPathRendererChain = new GrPathRendererChain(this);
}
GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target,
if (!pr && allowSW) {
if (!fSoftwarePathRenderer) {
- fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this));
+ fSoftwarePathRenderer = new GrSoftwarePathRenderer(this);
}
pr = fSoftwarePathRenderer;
}
bool localCoordsWillBeRead,
bool coverageWillBeIgnored,
uint8_t coverage) {
- return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags,
- color,
- viewMatrix,
- localMatrix,
- coverage,
- localCoordsWillBeRead,
- coverageWillBeIgnored));
+ return new DefaultGeoProc(gpTypeFlags, color, viewMatrix, localMatrix, coverage,
+ localCoordsWillBeRead, coverageWillBeIgnored);
}
const char* name() const override { return "DefaultGeometryProcessor"; }
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const override {
- return SkNEW_ARGS(GLProcessor, (*this, bt));
+ return new GLProcessor(*this, bt);
}
private:
static GrDrawBatch* Create(const Geometry& geometry, uint8_t coverage,
const SkMatrix& viewMatrix, bool isHairline,
const SkRect& devBounds) {
- return SkNEW_ARGS(DefaultPathBatch, (geometry, coverage, viewMatrix, isHairline,
- devBounds));
+ return new DefaultPathBatch(geometry, coverage, viewMatrix, isHairline, devBounds);
}
const char* name() const override { return "DefaultPathBatch"; }
GrDrawContext::~GrDrawContext() {
SkSafeUnref(fDrawTarget);
- SkDELETE(fTextContext);
+ delete fTextContext;
}
void GrDrawContext::copySurface(GrRenderTarget* dst, GrSurface* src,
this->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), *rect);
} else {
- GrBatch* batch = SkNEW_ARGS(GrClearBatch, (*rect, color, renderTarget));
+ GrBatch* batch = new GrClearBatch(*rect, color, renderTarget);
this->onDrawBatch(batch);
batch->unref();
}
void GrDrawTarget::discard(GrRenderTarget* renderTarget) {
if (this->caps()->discardRenderTargetSupport()) {
- GrBatch* batch = SkNEW_ARGS(GrDiscardBatch, (renderTarget));
+ GrBatch* batch = new GrDiscardBatch(renderTarget);
this->onDrawBatch(batch);
batch->unref();
}
GrClipTarget::GrClipTarget(GrContext* context)
: INHERITED(context->getGpu(), context->resourceProvider())
, fContext(context) {
- fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this)));
+ fClipMaskManager.reset(new GrClipMaskManager(this));
}
};
void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) {
- GrBatch* batch = SkNEW_ARGS(GrClearStencilClipBatch, (rect, insideClip, rt));
+ GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
this->onDrawBatch(batch);
batch->unref();
}
const GrFontDescKey* GrFontScaler::getKey() {
if (NULL == fKey) {
- fKey = SkNEW_ARGS(GrFontDescKey, (fStrike->getDescriptor()));
+ fKey = new GrFontDescKey(fStrike->getDescriptor());
}
return fKey;
}
void GrGpuResource::notifyAllCntsAreZero(CntType lastCntTypeToReachZero) const {
if (this->wasDestroyed()) {
// We've already been removed from the cache. Goodbye cruel world!
- SkDELETE(this);
+ delete this;
return;
}
*/
void release() {
fResource->release();
- if (fResource->isPurgeable()) {
- SkDELETE(fResource);
+ if (fResource->isPurgeable()) {
+ delete fResource;
}
}
*/
void abandon() {
fResource->abandon();
- if (fResource->isPurgeable()) {
- SkDELETE(fResource);
+ if (fResource->isPurgeable()) {
+ delete fResource;
}
}
GrCachedLayer* layer = &(*iter);
SkASSERT(0 == layer->uses());
this->unlock(layer);
- SkDELETE(layer);
+ delete layer;
}
SkASSERT(0 == fPictureHash.count());
GR_STATIC_ASSERT(kNumPlotsX*kNumPlotsX == GrPictureInfo::kNumPlots);
SkISize textureSize = SkISize::Make(kAtlasTextureWidth, kAtlasTextureHeight);
- fAtlas.reset(SkNEW_ARGS(GrAtlas, (fContext->getGpu(), kSkia8888_GrPixelConfig,
- kRenderTarget_GrSurfaceFlag,
- textureSize, kNumPlotsX, kNumPlotsY, false)));
+ fAtlas.reset(new GrAtlas(fContext->getGpu(), kSkia8888_GrPixelConfig,
+ kRenderTarget_GrSurfaceFlag, textureSize, kNumPlotsX, kNumPlotsY,
+ false));
}
void GrLayerCache::freeAll() {
for (; !iter.done(); ++iter) {
GrCachedLayer* layer = &(*iter);
this->unlock(layer);
- SkDELETE(layer);
+ delete layer;
}
fLayerHash.rewind();
const SkPaint* paint) {
SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0);
- GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop,
- srcIR, dstIR, initialMat,
- key, keySize, paint));
+ GrCachedLayer* layer = new GrCachedLayer(pictureID, start, stop, srcIR, dstIR, initialMat, key,
+ keySize, paint);
fLayerHash.add(layer);
return layer;
}
// Not in the atlas - will it fit?
GrPictureInfo* pictInfo = fPictureHash.find(layer->pictureID());
if (NULL == pictInfo) {
- pictInfo = SkNEW_ARGS(GrPictureInfo, (layer->pictureID()));
+ pictInfo = new GrPictureInfo(layer->pictureID());
fPictureHash.add(pictInfo);
}
if (pictInfo->fPlotUsage.isEmpty()) {
fPictureHash.remove(pictInfo->fPictureID);
- SkDELETE(pictInfo);
+ delete pictInfo;
}
}
if (pictInfo->fPlotUsage.isEmpty()) {
fPictureHash.remove(pictInfo->fPictureID);
- SkDELETE(pictInfo);
+ delete pictInfo;
}
}
SkASSERT(0 == toBeRemoved[i]->uses());
this->unlock(toBeRemoved[i]);
fLayerHash.remove(GrCachedLayer::GetKey(*toBeRemoved[i]));
- SkDELETE(toBeRemoved[i]);
+ delete toBeRemoved[i];
}
GrPictureInfo* pictInfo = fPictureHash.find(pictureID);
if (pictInfo) {
fPictureHash.remove(pictureID);
- SkDELETE(pictInfo);
+ delete pictInfo;
}
}
// Aggressively remove layers and, if it becomes totally uncached, delete the picture info
fLayerHash.remove(GrCachedLayer::GetKey(*toBeRemoved[i]));
- SkDELETE(toBeRemoved[i]);
+ delete toBeRemoved[i];
GrPictureInfo* pictInfo = fPictureHash.find(pictureIDToRemove);
if (pictInfo) {
if (pictInfo->fPlotUsage.isEmpty()) {
fPictureHash.remove(pictInfo->fPictureID);
- SkDELETE(pictInfo);
+ delete pictInfo;
}
}
}
fIDMatrix.fInitialMat.getType(); // force initialization of type so hashes match
if (copyKey) {
- int* tempKey = SkNEW_ARRAY(int, keySize);
+ int* tempKey = new int[keySize];
memcpy(tempKey, key, keySize*sizeof(int));
fKey = tempKey;
} else {
~Key() {
if (fFreeKey) {
- SkDELETE_ARRAY(fKey);
+ delete[] fKey;
}
}
static uint32_t Hash(const Key& key) { return key.hash(); }
// GrCachedLayer proper
- GrCachedLayer(uint32_t pictureID, int start, int stop,
- const SkIRect& srcIR, const SkIRect& dstIR,
+ GrCachedLayer(uint32_t pictureID,
+ int start,
+ int stop,
+ const SkIRect& srcIR,
+ const SkIRect& dstIR,
const SkMatrix& ctm,
- const int* key, int keySize,
+ const int* key,
+ int keySize,
const SkPaint* paint)
: fKey(pictureID, ctm, key, keySize, true)
, fStart(start)
, fSrcIR(srcIR)
, fDstIR(dstIR)
, fOffset(SkIPoint::Make(0, 0))
- , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL)
+ , fPaint(paint ? new SkPaint(*paint) : NULL)
, fFilter(NULL)
, fTexture(NULL)
, fRect(SkIRect::MakeEmpty())
~GrCachedLayer() {
SkSafeUnref(fTexture);
SkSafeUnref(fFilter);
- SkDELETE(fPaint);
+ delete fPaint;
}
uint32_t pictureID() const { return fKey.pictureID(); }
SkBitmap result;
result.setInfo(texture->surfacePriv().info(kPremul_SkAlphaType));
- result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref();
+ result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref();
return result;
}
SkASSERT(fRefCnt > 0);
--fRefCnt;
if (0 == fRefCnt) {
- SkDELETE(this);
+ delete this;
return;
}
}
public:
static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix, usesLocalCoords));
+ return new CircleEdgeEffect(color, stroke, localMatrix, usesLocalCoords);
}
const Attribute* inPosition() const { return fInPosition; }
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const override {
- return SkNEW_ARGS(GLProcessor, (*this, bt));
+ return new GLProcessor(*this, bt);
}
private:
public:
static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix, usesLocalCoords));
+ return new EllipseEdgeEffect(color, stroke, localMatrix, usesLocalCoords);
}
virtual ~EllipseEdgeEffect() {}
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const override {
- return SkNEW_ARGS(GLProcessor, (*this, bt));
+ return new GLProcessor(*this, bt);
}
private:
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, Mode mode,
bool usesLocalCoords) {
- return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode, usesLocalCoords));
+ return new DIEllipseEdgeEffect(color, viewMatrix, mode, usesLocalCoords);
}
virtual ~DIEllipseEdgeEffect() {}
virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const override {
- return SkNEW_ARGS(GLProcessor, (*this, bt));
+ return new GLProcessor(*this, bt);
}
private:
SkRect fDevBounds;
};
- static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(CircleBatch, (geometry));
- }
+ static GrDrawBatch* Create(const Geometry& geometry) { return new CircleBatch(geometry); }
const char* name() const override { return "CircleBatch"; }
SkRect fDevBounds;
};
- static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(EllipseBatch, (geometry));
- }
+ static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBatch(geometry); }
const char* name() const override { return "EllipseBatch"; }
};
static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) {
- return SkNEW_ARGS(DIEllipseBatch, (geometry, bounds));
+ return new DIEllipseBatch(geometry, bounds);
}
const char* name() const override { return "DIEllipseBatch"; }
};
static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(RRectCircleRendererBatch, (geometry));
+ return new RRectCircleRendererBatch(geometry);
}
const char* name() const override { return "RRectCircleBatch"; }
};
static GrDrawBatch* Create(const Geometry& geometry) {
- return SkNEW_ARGS(RRectEllipseRendererBatch, (geometry));
+ return new RRectEllipseRendererBatch(geometry);
}
const char* name() const override { return "RRectEllipseRendererBatch"; }
: fAntiAlias(false)
, fDither(false)
, fColor(GrColor_WHITE)
- , fProcDataManager(SkNEW(GrProcessorDataManager)) {
-}
+ , fProcDataManager(new GrProcessorDataManager) {}
void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage) {
fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage));
GrGLPrimitiveProcessor* GrPathProcessor::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps& caps) const {
SkASSERT(caps.pathRenderingSupport());
- return SkNEW_ARGS(GrGLPathProcessor, (*this, bt));
+ return new GrGLPathProcessor(*this, bt);
}
static GrPathProcessor* Create(GrColor color,
const SkMatrix& viewMatrix = SkMatrix::I(),
const SkMatrix& localMatrix = SkMatrix::I()) {
- return SkNEW_ARGS(GrPathProcessor, (color, viewMatrix, localMatrix));
+ return new GrPathProcessor(color, viewMatrix, localMatrix);
}
void initBatchTracker(GrBatchTracker*, const GrPipelineOptimizations&) const override;
bool twoSided = caps->twoSidedStencilSupport();
bool wrapOp = caps->stencilWrapOpsSupport();
GrPathRenderer::AddPathRenderers(fOwner, this);
- this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer,
- (twoSided, wrapOp)))->unref();
+ this->addPathRenderer(new GrDefaultPathRenderer(twoSided, wrapOp))->unref();
fInit = true;
}
}
if (desc) {
- SkAutoTUnref<GlyphGenerator> generator(SkNEW_ARGS(GlyphGenerator, (*typeface, *desc)));
+ SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, *desc));
return this->createPathRange(generator, stroke);
}
genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
genericDesc->computeChecksum();
- SkAutoTUnref<GlyphGenerator> generator(SkNEW_ARGS(GlyphGenerator, (*typeface, *genericDesc)));
+ SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, *genericDesc));
return this->createPathRange(generator, stroke);
}
overrideColor = GrColor_ILLEGAL;
}
- GrPipeline* pipeline = SkNEW_PLACEMENT(memory, GrPipeline);
+ GrPipeline* pipeline = new (memory) GrPipeline;
pipeline->fXferProcessor.reset(xferProcessor.get());
pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
#include "effects/GrPorterDuffXferProcessor.h"
GrPipelineBuilder::GrPipelineBuilder()
- : fProcDataManager(SkNEW(GrProcessorDataManager))
- , fFlags(0x0)
- , fDrawFace(kBoth_DrawFace) {
+ : fProcDataManager(new GrProcessorDataManager), fFlags(0x0), fDrawFace(kBoth_DrawFace) {
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
}
GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) {
- fProcDataManager.reset(SkNEW_ARGS(GrProcessorDataManager, (*that.processorDataManager())));
+ fProcDataManager.reset(new GrProcessorDataManager(*that.processorDataManager()));
fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get()));
fFlags = that.fFlags;
fStencilSettings = that.fStencilSettings;
static inline void wrap_texture(GrTexture* texture, int width, int height, SkBitmap* result) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
result->setInfo(info);
- result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
+ result->setPixelRef(new SkGrPixelRef(info, texture))->unref();
}
static inline void draw_replacement_bitmap(GrCachedLayer* layer, SkCanvas* canvas) {
// factory is now in GrRectanizer_skyline.cpp
//GrRectanizer* GrRectanizer::Factory(int width, int height) {
-// return SkNEW_ARGS(GrRectanizerPow2, (width, height));
+// return new GrRectanizerPow2 (width, height);
//}
///////////////////////////////////////////////////////////////////////////////
GrRectanizer* GrRectanizer::Factory(int width, int height) {
- return SkNEW_ARGS(GrRectanizerSkyline, (width, height));
+ return new GrRectanizerSkyline(width, height);
}
GrResourceCache::~GrResourceCache() {
this->releaseAll();
- SkDELETE_ARRAY(fFlushTimestamps);
+ delete[] fFlushTimestamps;
}
void GrResourceCache::setLimits(int count, size_t bytes, int maxUnusedFlushes) {
}
void GrResourceCache::resetFlushTimestamps() {
- SkDELETE_ARRAY(fFlushTimestamps);
+ delete[] fFlushTimestamps;
// We assume this number is a power of two when wrapping indices into the timestamp array.
fMaxUnusedFlushes = SkNextPow2(fMaxUnusedFlushes);
return;
}
- fFlushTimestamps = SkNEW_ARRAY(uint32_t, fMaxUnusedFlushes);
+ fFlushTimestamps = new uint32_t[fMaxUnusedFlushes];
fLastFlushTimestampIndex = 0;
// Set all the historical flush timestamps to initially be at the beginning of time (timestamp
// 0).
uint16_t* data = (uint16_t*) buffer->map();
bool useTempData = (NULL == data);
if (useTempData) {
- data = SkNEW_ARRAY(uint16_t, reps * patternSize);
+ data = new uint16_t[reps * patternSize];
}
for (int i = 0; i < reps; ++i) {
int baseIdx = i * patternSize;
buffer->unref();
return NULL;
}
- SkDELETE_ARRAY(data);
+ delete[] data;
} else {
buffer->unmap();
}
if (!texture) {
return NULL;
}
- return SkNEW_ARGS(GrBatchAtlas, (texture, numPlotsX, numPlotsY));
+ return new GrBatchAtlas(texture, numPlotsX, numPlotsY);
}
GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrResourceProvider* resourceProvider,
const GrCaps& caps) {
if (caps.shaderCaps()->pathRenderingSupport()) {
- return SkNEW_ARGS(GrStencilAndCoverPathRenderer, (resourceProvider));
+ return new GrStencilAndCoverPathRenderer(resourceProvider);
} else {
return NULL;
}
GrStencilAndCoverTextContext*
GrStencilAndCoverTextContext::Create(GrContext* context, GrDrawContext* drawContext,
const SkSurfaceProps& surfaceProps) {
- GrStencilAndCoverTextContext* textContext = SkNEW_ARGS(GrStencilAndCoverTextContext,
- (context, drawContext, surfaceProps));
+ GrStencilAndCoverTextContext* textContext =
+ new GrStencilAndCoverTextContext(context, drawContext, surfaceProps);
textContext->fFallbackTextContext = GrAtlasTextContext::Create(context, drawContext, surfaceProps);
return textContext;
#define LOG(...)
#endif
-#define ALLOC_NEW(Type, args, alloc) \
- SkNEW_PLACEMENT_ARGS(alloc.allocThrow(sizeof(Type)), Type, args)
+#define ALLOC_NEW(Type, args, alloc) new (alloc.allocThrow(sizeof(Type))) Type args
namespace {
const GrStrokeInfo& stroke,
const SkMatrix& viewMatrix,
SkRect clipBounds) {
- return SkNEW_ARGS(TessellatingPathBatch, (color, path, stroke, viewMatrix, clipBounds));
+ return new TessellatingPathBatch(color, path, stroke, viewMatrix, clipBounds);
}
const char* name() const override { return "TessellatingPathBatch"; }
}
LOG("got %d pts, %d contours\n", maxPts, contourCnt);
- SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt));
+ SkAutoTDeleteArray<Vertex*> contours(new Vertex* [contourCnt]);
// For the initial size of the chunk allocator, estimate based on the point count:
// one vertex per point for the initial passes, plus two for the vertices in the
if (canMapVB) {
verts = static_cast<SkPoint*>(vertexBuffer->map());
} else {
- verts = SkNEW_ARRAY(SkPoint, count);
+ verts = new SkPoint[count];
}
SkPoint* end = polys_to_triangles(polys, fillType, verts);
int actualCount = static_cast<int>(end - verts);
vertexBuffer->unmap();
} else {
vertexBuffer->updateData(verts, actualCount * sizeof(SkPoint));
- SkDELETE_ARRAY(verts);
+ delete[] verts;
}
SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
key->setCustomData(data.get());
resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get());
- SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key)));
+ SkPathPriv::AddGenIDChangeListener(fPath, new PathInvalidator(*key));
}
return actualCount;
}
class MockGpu : public GrGpu {
public:
MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(context) {
- fCaps.reset(SkNEW_ARGS(GrCaps, (options)));
+ fCaps.reset(new GrCaps(options));
}
~MockGpu() override {}
};
GrContext* GrContext::CreateMockContext() {
- GrContext* context = SkNEW(GrContext);
+ GrContext* context = new GrContext;
context->initMockContext();
return context;
GrContextOptions options;
options.fGeometryBufferMapThreshold = 0;
SkASSERT(NULL == fGpu);
- fGpu = SkNEW_ARGS(MockGpu, (this, options));
+ fGpu = new MockGpu(this, options);
SkASSERT(fGpu);
this->initCommon();
randomize_stroke_rec(&strokeInfo, random);
SkPathEffect::DashInfo dashInfo;
dashInfo.fCount = random->nextRangeU(1, 50) * 2;
- dashInfo.fIntervals = SkNEW_ARRAY(SkScalar, dashInfo.fCount);
+ dashInfo.fIntervals = new SkScalar[dashInfo.fCount];
SkScalar sum = 0;
for (int i = 0; i < dashInfo.fCount; i++) {
dashInfo.fIntervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01),
}
dashInfo.fPhase = random->nextRangeScalar(0, sum);
strokeInfo.setDashInfo(dashInfo);
- SkDELETE_ARRAY(dashInfo.fIntervals);
+ delete[] dashInfo.fIntervals;
return strokeInfo;
}
sk_bzero(allocation, size);
#endif
- GrAtlasTextBlob* cacheBlob = SkNEW_PLACEMENT(allocation, GrAtlasTextBlob);
+ GrAtlasTextBlob* cacheBlob = new (allocation) GrAtlasTextBlob;
#ifdef CACHE_SANITY_CHECK
cacheBlob->fSize = size;
#endif
// Initialize runs
for (int i = 0; i < runCount; i++) {
- SkNEW_PLACEMENT(&cacheBlob->fRuns[i], GrAtlasTextBlob::Run);
+ new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run;
}
cacheBlob->fRunCount = runCount;
cacheBlob->fPool = &fPool;
, fDrawContext(drawContext) {
}
-GrTextContext::~GrTextContext() {
- SkDELETE(fFallbackTextContext);
-}
+GrTextContext::~GrTextContext() { delete fFallbackTextContext; }
void GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPaint& paint,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
}
}
-//*** change to output positions?
+// *** change to output positions?
int GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
const char text[], size_t byteLength, SkVector* stopVector) {
SkFixed x = 0, y = 0;
scaler = (GrFontScaler*)auxData;
}
if (NULL == scaler) {
- scaler = SkNEW_ARGS(GrFontScaler, (cache));
+ scaler = new GrFontScaler(cache);
cache->setAuxProc(GlyphCacheAuxProc, scaler);
}
if (!CheckAlphaTypeAndGetFlags(NULL, init, &flags)) {
return NULL;
}
- return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags));
+ return new SkGpuDevice(rt, width, height, props, flags);
}
SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgeted,
return NULL;
}
- return SkNEW_ARGS(SkGpuDevice, (rt, info.width(), info.height(), props, flags));
+ return new SkGpuDevice(rt, info.width(), info.height(), props, flags);
}
SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
- SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt));
+ SkPixelRef* pr = new SkGrPixelRef(info, rt);
fLegacyBitmap.setInfo(info);
fLegacyBitmap.setPixelRef(pr)->unref();
kPremul_SkAlphaType);
SkASSERT(info == fLegacyBitmap.info());
#endif
- SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (fLegacyBitmap.info(), fRenderTarget));
+ SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget);
fLegacyBitmap.setPixelRef(pr)->unref();
fDrawContext.reset(SkRef(fRenderTarget->getContext()->drawContext(&this->surfaceProps())));
static SkBitmap wrap_texture(GrTexture* texture, int width, int height) {
SkBitmap result;
result.setInfo(SkImageInfo::MakeN32Premul(width, height));
- result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref();
+ result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref();
return result;
}
//number of indices for lines per triangle with kLines
indexCount = triangleCount * 6;
- outAlloc.reset(SkNEW_ARRAY(uint16_t, indexCount));
+ outAlloc.reset(new uint16_t[indexCount]);
outIndices = outAlloc.get();
uint16_t* auxIndices = outAlloc.get();
int i = 0;
size_t rowBytes) {
GrTexture* result = ctx->textureProvider()->createTexture(desc, true, pixels, rowBytes);
if (result && optionalKey.isValid()) {
- BitmapInvalidator* listener = SkNEW_ARGS(BitmapInvalidator, (optionalKey));
+ BitmapInvalidator* listener = new BitmapInvalidator(optionalKey);
pixelRefForInvalidationNotification->addGenIDChangeListener(listener);
ctx->textureProvider()->assignUniqueKeyToTexture(optionalKey, result);
}
void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap* dst) {
const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
dst->setInfo(info);
- dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
+ dst->setPixelRef(new SkGrPixelRef(info, src))->unref();
}
GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType,
dstPT);
- SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
+ SkGrPixelRef* pixelRef = new SkGrPixelRef(info, dst);
SkSafeUnref(dst);
return pixelRef;
}
};
static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix) {
- return SkNEW_ARGS(GrAAStrokeRectBatch, (geometry, viewMatrix));
+ return new GrAAStrokeRectBatch(geometry, viewMatrix);
}
const char* name() const override { return "AAStrokeRect"; }
&clippedDstPoint)) {
return NULL;
}
- return SkNEW_ARGS(GrCopySurfaceBatch, (dst, src, clippedSrcRect, clippedDstPoint));
+ return new GrCopySurfaceBatch(dst, src, clippedSrcRect, clippedDstPoint);
}
static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
int spriteCount, const SkRSXform* xforms, const SkRect* rects,
const SkColor* colors) {
- return SkNEW_ARGS(GrDrawAtlasBatch, (geometry, viewMatrix, spriteCount,
- xforms, rects, colors));
+ return new GrDrawAtlasBatch(geometry, viewMatrix, spriteCount, xforms, rects, colors);
}
const char* name() const override { return "DrawAtlasBatch"; }
public:
// This must return the concrete type because we install the stencil settings late :(
static GrDrawPathBatch* Create(const GrPathProcessor* primProc, const GrPath* path) {
- return SkNEW_ARGS(GrDrawPathBatch, (primProc, path));
+ return new GrDrawPathBatch(primProc, path);
}
const char* name() const override { return "DrawPath"; }
const uint16_t* indices, int indexCount,
const GrColor* colors, const SkPoint* localCoords,
const SkRect& bounds) {
- return SkNEW_ARGS(GrDrawVerticesBatch, (geometry, primitiveType, viewMatrix, positions,
- vertexCount, indices, indexCount, colors,
- localCoords, bounds));
+ return new GrDrawVerticesBatch(geometry, primitiveType, viewMatrix, positions, vertexCount,
+ indices, indexCount, colors, localCoords, bounds);
}
const char* name() const override { return "DrawVerticesBatch"; }
const GrScissorState& scissor,
GrRenderTarget* renderTarget,
const GrPath* path) {
- return SkNEW_ARGS(GrStencilPathBatch, (viewMatrix, useHWAA, stencil, scissor, renderTarget,
- path));
+ return new GrStencilPathBatch(viewMatrix, useHWAA, stencil, scissor, renderTarget, path);
}
const char* name() const override { return "StencilPath"; }
};
static GrDrawBatch* Create(const Geometry& geometry, bool snapToPixelCenters) {
- return SkNEW_ARGS(GrStrokeRectBatch, (geometry, snapToPixelCenters));
+ return new GrStrokeRectBatch(geometry, snapToPixelCenters);
}
const char* name() const override { return "GrStrokeRectBatch"; }
public:
typedef typename Impl::Geometry Geometry;
- static GrTInstanceBatch* Create() {
- return SkNEW(GrTInstanceBatch);
- }
+ static GrTInstanceBatch* Create() { return new GrTInstanceBatch; }
const char* name() const override { return Impl::Name(); }
GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GrGLConicEffect, (*this, bt));
+ return new GrGLConicEffect(*this, bt);
}
GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GrGLQuadEffect, (*this, bt));
+ return new GrGLQuadEffect(*this, bt);
}
GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GrGLCubicEffect, (*this, bt));
+ return new GrGLCubicEffect(*this, bt);
}
GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix,
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return NULL;
}
- return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage,
- kFillAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords));
+ return new GrConicEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords);
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return NULL;
}
- return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage,
- kHairlineAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords));
+ return new GrConicEffect(color, viewMatrix, coverage,
+ kHairlineAA_GrProcessorEdgeType, localMatrix,
+ usesLocalCoords);
case kFillBW_GrProcessorEdgeType:
- return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage,
- kFillBW_GrProcessorEdgeType,
- localMatrix, usesLocalCoords));
+ return new GrConicEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords);
default:
return NULL;
}
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return NULL;
}
- return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage,
- kFillAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords));
+ return new GrQuadEffect(color, viewMatrix, coverage, kFillAA_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords);
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return NULL;
}
- return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage,
- kHairlineAA_GrProcessorEdgeType,
- localMatrix, usesLocalCoords));
+ return new GrQuadEffect(color, viewMatrix, coverage,
+ kHairlineAA_GrProcessorEdgeType, localMatrix,
+ usesLocalCoords);
case kFillBW_GrProcessorEdgeType:
- return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage,
- kFillBW_GrProcessorEdgeType,
- localMatrix, usesLocalCoords));
+ return new GrQuadEffect(color, viewMatrix, coverage, kFillBW_GrProcessorEdgeType,
+ localMatrix, usesLocalCoords);
default:
return NULL;
}
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return NULL;
}
- return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, kFillAA_GrProcessorEdgeType));
+ return new GrCubicEffect(color, viewMatrix, kFillAA_GrProcessorEdgeType);
case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
return NULL;
}
- return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix,
- kHairlineAA_GrProcessorEdgeType));
+ return new GrCubicEffect(color, viewMatrix, kHairlineAA_GrProcessorEdgeType);
case kFillBW_GrProcessorEdgeType:
- return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix,
- kFillBW_GrProcessorEdgeType));
+ return new GrCubicEffect(color, viewMatrix, kFillBW_GrProcessorEdgeType);
default:
return NULL;
}
}
GrGLFragmentProcessor* GrBicubicEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLBicubicEffect, (*this));
+ return new GrGLBicubicEffect(*this);
}
bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
return Create(procDataManager, tex, coefficients,
GrCoordTransform::MakeDivByTextureWHMatrix(tex), kTileModes);
} else {
- return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, coefficients,
- GrCoordTransform::MakeDivByTextureWHMatrix(tex),
- *domain));
+ return new GrBicubicEffect(procDataManager, tex, coefficients,
+ GrCoordTransform::MakeDivByTextureWHMatrix(tex), *domain);
}
}
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* tex,
const SkScalar coefficients[16], const SkMatrix& matrix,
const SkShader::TileMode tileModes[2]) {
- return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, coefficients, matrix, tileModes));
+ return new GrBicubicEffect(procDataManager, tex, coefficients, matrix, tileModes);
}
/**
*/
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, GrTexture* tex,
const SkMatrix& matrix, const SkRect& domain) {
- return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, gMitchellCoefficients, matrix,
- domain));
+ return new GrBicubicEffect(procDataManager, tex, gMitchellCoefficients, matrix, domain);
}
/**
GrGLPrimitiveProcessor*
GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps& caps) const {
- return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt));
+ return new GrGLBitmapTextGeoProc(*this, bt);
}
///////////////////////////////////////////////////////////////////////////////
static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
GrMaskFormat format, const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, format, localMatrix,
- usesLocalCoords));
+ return new GrBitmapTextGeoProc(color, tex, p, format, localMatrix, usesLocalCoords);
}
virtual ~GrBitmapTextGeoProc() {}
} else {
swapRB = d->fRandom->nextBool();
}
- return SkNEW_ARGS(GrConfigConversionEffect,
- (d->fProcDataManager,
- d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
- swapRB,
- pmConv,
- GrTest::TestMatrix(d->fRandom)));
+ return new GrConfigConversionEffect(d->fProcDataManager,
+ d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx],
+ swapRB, pmConv, GrTest::TestMatrix(d->fRandom));
}
///////////////////////////////////////////////////////////////////////////////
}
GrGLFragmentProcessor* GrConfigConversionEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLConfigConversionEffect, (*this));
+ return new GrGLConfigConversionEffect(*this);
}
GrPaint paint1;
GrPaint paint2;
GrPaint paint3;
- SkAutoTUnref<GrFragmentProcessor> pmToUPM1(
- SkNEW_ARGS(GrConfigConversionEffect,
- (paint1.getProcessorDataManager(), dataTex, false, *pmToUPMRule,
- SkMatrix::I())));
- SkAutoTUnref<GrFragmentProcessor> upmToPM(
- SkNEW_ARGS(GrConfigConversionEffect,
- (paint2.getProcessorDataManager(), readTex, false, *upmToPMRule,
- SkMatrix::I())));
- SkAutoTUnref<GrFragmentProcessor> pmToUPM2(
- SkNEW_ARGS(GrConfigConversionEffect,
- (paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule,
- SkMatrix::I())));
+ SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
+ paint1.getProcessorDataManager(), dataTex, false, *pmToUPMRule, SkMatrix::I()));
+ SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
+ paint2.getProcessorDataManager(), readTex, false, *upmToPMRule, SkMatrix::I()));
+ SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
+ paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule, SkMatrix::I()));
paint1.addColorProcessor(pmToUPM1);
// The PM conversions assume colors are 0..255
return NULL;
}
- return SkNEW_ARGS(GrConfigConversionEffect, (procDataManager,
- texture,
- swapRedAndBlue,
- pmConversion,
- matrix));
+ return new GrConfigConversionEffect(procDataManager, texture, swapRedAndBlue, pmConversion,
+ matrix);
}
}
}
GrGLFragmentProcessor* GrConstColorProcessor::onCreateGLInstance() const {
- return SkNEW(GLConstColorProcessor);
+ return new GLConstColorProcessor;
}
bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const {
const SkRect& getRect() const { return fRect; }
static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
- return SkNEW_ARGS(AARectEffect, (edgeType, rect));
+ return new AARectEffect(edgeType, rect);
}
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
}
GrGLFragmentProcessor* AARectEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLAARectEffect, (*this));
+ return new GLAARectEffect(*this);
}
//////////////////////////////////////////////////////////////////////////////
}
GrGLFragmentProcessor* GrConvexPolyEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLConvexPolyEffect, (*this));
+ return new GrGLConvexPolyEffect(*this);
}
GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[])
if (n <= 0 || n > kMaxEdges || kHairlineAA_GrProcessorEdgeType == edgeType) {
return NULL;
}
- return SkNEW_ARGS(GrConvexPolyEffect, (edgeType, n, edges));
+ return new GrConvexPolyEffect(edgeType, n, edges);
}
/**
}
GrGLFragmentProcessor* GrConvolutionEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLConvolutionEffect, (*this));
+ return new GrGLConvolutionEffect(*this);
}
bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const float* kernel,
bool useBounds,
float bounds[2]) {
- return SkNEW_ARGS(GrConvolutionEffect, (procDataManager,
- tex,
- dir,
- halfWidth,
- kernel,
- useBounds,
- bounds));
+ return new GrConvolutionEffect(procDataManager, tex, dir, halfWidth, kernel, useBounds,
+ bounds);
}
/// Convolve with a Gaussian kernel
float gaussianSigma,
bool useBounds,
float bounds[2]) {
- return SkNEW_ARGS(GrConvolutionEffect, (procDataManager,
- tex,
- dir,
- halfWidth,
- gaussianSigma,
- useBounds,
- bounds));
+ return new GrConvolutionEffect(procDataManager, tex, dir, halfWidth, gaussianSigma,
+ useBounds, bounds);
}
virtual ~GrConvolutionEffect();
class CoverageSetOpXP : public GrXferProcessor {
public:
static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) {
- return SkNEW_ARGS(CoverageSetOpXP, (regionOp, invertCoverage));
+ return new CoverageSetOpXP(regionOp, invertCoverage);
}
~CoverageSetOpXP() override;
}
GrGLXferProcessor* CoverageSetOpXP::createGLInstance() const {
- return SkNEW_ARGS(GLCoverageSetOpXP, (*this));
+ return new GLCoverageSetOpXP(*this);
}
GrXferProcessor::OptFlags
if (!GrCustomXfermode::IsSupportedMode(mode)) {
return NULL;
} else {
- return SkNEW_ARGS(GrCustomXferFP, (procDataManager, mode, background));
+ return new GrCustomXferFP(procDataManager, mode, background);
}
}
}
GrGLFragmentProcessor* GrCustomXferFP::onCreateGLInstance() const {
- return SkNEW_ARGS(GLCustomXferFP, (*this));
+ return new GLCustomXferFP(*this);
}
bool GrCustomXferFP::onIsEqual(const GrFragmentProcessor& other) const {
GrFragmentProcessor* GrCustomXferFP::TestCreate(GrProcessorTestData* d) {
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode);
- return SkNEW_ARGS(GrCustomXferFP, (d->fProcDataManager, static_cast<SkXfermode::Mode>(mode),
- d->fTextures[0]));
+ return new GrCustomXferFP(d->fProcDataManager, static_cast<SkXfermode::Mode>(mode),
+ d->fTextures[0]);
}
///////////////////////////////////////////////////////////////////////////////
if (!GrCustomXfermode::IsSupportedMode(mode)) {
return NULL;
} else {
- return SkNEW_ARGS(GrCustomXPFactory, (mode));
+ return new GrCustomXPFactory(mode);
}
}
GrGLXferProcessor* CustomXP::createGLInstance() const {
SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation());
- return SkNEW_ARGS(GLCustomXP, (*this));
+ return new GLCustomXP(*this);
}
bool CustomXP::onIsEqual(const GrXferProcessor& other) const {
const DstTexture* dstTexture) const {
if (can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps)) {
SkASSERT(!dstTexture || !dstTexture->texture());
- return SkNEW_ARGS(CustomXP, (fMode, fHWBlendEquation));
+ return new CustomXP(fMode, fHWBlendEquation);
}
- return SkNEW_ARGS(CustomXP, (dstTexture, hasMixedSamples, fMode));
+ return new CustomXP(dstTexture, hasMixedSamples, fMode);
}
bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps,
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1,
SkXfermode::kLastSeparableMode);
- return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode)));
+ return new GrCustomXPFactory(static_cast<SkXfermode::Mode>(mode));
}
static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode,
bool fullDash) {
- return SkNEW_ARGS(DashBatch, (geometry, cap, aaMode, fullDash));
+ return new DashBatch(geometry, cap, aaMode, fullDash);
}
const char* name() const override { return "DashBatch"; }
DashAAMode aaMode,
const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return SkNEW_ARGS(DashingCircleEffect, (color, aaMode, localMatrix, usesLocalCoords));
+ return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords);
}
void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
GrGLPrimitiveProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
+ return new GLDashingCircleEffect(*this, bt);
}
DashingCircleEffect::DashingCircleEffect(GrColor color,
DashAAMode aaMode,
const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return SkNEW_ARGS(DashingLineEffect, (color, aaMode, localMatrix, usesLocalCoords));
+ return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords);
}
void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
GrGLPrimitiveProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
+ return new GLDashingLineEffect(*this, bt);
}
DashingLineEffect::DashingLineEffect(GrColor color,
*/
class DisableColorXP : public GrXferProcessor {
public:
- static GrXferProcessor* Create() {
- return SkNEW(DisableColorXP);
- }
+ static GrXferProcessor* Create() { return new DisableColorXP; }
~DisableColorXP() override {};
GLDisableColorXP::GenKey(*this, caps, b);
}
-GrGLXferProcessor* DisableColorXP::createGLInstance() const {
- return SkNEW_ARGS(GLDisableColorXP, (*this));
-}
+GrGLXferProcessor* DisableColorXP::createGLInstance() const { return new GLDisableColorXP(*this); }
void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
blendInfo->fWriteColor = false;
class GrDisableColorXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create() {
- return SkNEW(GrDisableColorXPFactory);
- }
+ static GrXPFactory* Create() { return new GrDisableColorXPFactory; }
bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override {
return true;
GrGLPrimitiveProcessor*
GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt));
+ return new GrGLDistanceFieldA8TextGeoProc(*this, bt);
}
///////////////////////////////////////////////////////////////////////////////
GrGLPrimitiveProcessor*
GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrGLSLCaps&) const {
- return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt));
+ return new GrGLDistanceFieldPathGeoProc(*this, bt);
}
///////////////////////////////////////////////////////////////////////////////
GrGLPrimitiveProcessor*
GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt,
const GrGLSLCaps&) const {
- return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt));
+ return new GrGLDistanceFieldLCDTextGeoProc(*this, bt);
}
///////////////////////////////////////////////////////////////////////////////
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
GrTexture* tex, const GrTextureParams& params,
float lum, uint32_t flags, bool usesLocalCoords) {
- return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex, params, lum,
- flags, usesLocalCoords));
+ return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, lum, flags,
+ usesLocalCoords);
}
#else
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix,
GrTexture* tex, const GrTextureParams& params,
uint32_t flags, bool usesLocalCoords) {
- return SkNEW_ARGS(GrDistanceFieldA8TextGeoProc, (color, viewMatrix, tex, params, flags,
- usesLocalCoords));
+ return new GrDistanceFieldA8TextGeoProc(color, viewMatrix, tex, params, flags,
+ usesLocalCoords);
}
#endif
static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix, GrTexture* tex,
const GrTextureParams& params,
uint32_t flags, bool usesLocalCoords) {
- return SkNEW_ARGS(GrDistanceFieldPathGeoProc, (color, viewMatrix, tex, params, flags,
- usesLocalCoords));
+ return new GrDistanceFieldPathGeoProc(color, viewMatrix, tex, params, flags,
+ usesLocalCoords);
}
virtual ~GrDistanceFieldPathGeoProc() {}
GrTexture* tex, const GrTextureParams& params,
DistanceAdjust distanceAdjust, uint32_t flags,
bool usesLocalCoords) {
- return SkNEW_ARGS(GrDistanceFieldLCDTextGeoProc,
- (color, viewMatrix, tex, params, distanceAdjust, flags, usesLocalCoords));
+ return new GrDistanceFieldLCDTextGeoProc(color, viewMatrix, tex, params, distanceAdjust,
+ flags, usesLocalCoords);
}
virtual ~GrDistanceFieldLCDTextGeoProc() {}
}
GrGLFragmentProcessor* DitherEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLDitherEffect, (*this));
+ return new GLDitherEffect(*this);
}
GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); }
}
GrGLFragmentProcessor* GrMatrixConvolutionEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLMatrixConvolutionEffect, (*this));
+ return new GrGLMatrixConvolutionEffect(*this);
}
bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
for (int i = 0; i < width * height; ++i) {
kernel[i] *= scale;
}
- return SkNEW_ARGS(GrMatrixConvolutionEffect, (procDataManager,
- texture,
- bounds,
- kernelSize,
- kernel,
- gain,
- bias,
- kernelOffset,
- tileMode,
- convolveAlpha));
+ return new GrMatrixConvolutionEffect(procDataManager, texture, bounds, kernelSize, kernel, gain,
+ bias, kernelOffset, tileMode, convolveAlpha);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
const SkIPoint& kernelOffset,
GrTextureDomain::Mode tileMode,
bool convolveAlpha) {
- return SkNEW_ARGS(GrMatrixConvolutionEffect, (procDataManager,
- texture,
- bounds,
- kernelSize,
- kernel,
- gain,
- bias,
- kernelOffset,
- tileMode,
- convolveAlpha));
+ return new GrMatrixConvolutionEffect(procDataManager, texture, bounds, kernelSize, kernel,
+ gain, bias, kernelOffset, tileMode, convolveAlpha);
}
static GrFragmentProcessor* CreateGaussian(GrProcessorDataManager*,
GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const SkPoint& center,
SkScalar radius) {
SkASSERT(radius >= 0);
- return SkNEW_ARGS(CircleEffect, (edgeType, center, radius));
+ return new CircleEffect(edgeType, center, radius);
}
void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
}
GrGLFragmentProcessor* CircleEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLCircleEffect, (*this));
+ return new GLCircleEffect(*this);
}
//////////////////////////////////////////////////////////////////////////////
SkScalar rx,
SkScalar ry) {
SkASSERT(rx >= 0 && ry >= 0);
- return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry));
+ return new EllipseEffect(edgeType, center, rx, ry);
}
void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
}
GrGLFragmentProcessor* EllipseEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLEllipseEffect, (*this));
+ return new GLEllipseEffect(*this);
}
//////////////////////////////////////////////////////////////////////////////
}
GrGLXferProcessor* PorterDuffXferProcessor::createGLInstance() const {
- return SkNEW(GLPorterDuffXferProcessor);
+ return new GLPorterDuffXferProcessor;
}
GrXferProcessor::OptFlags
}
GrGLXferProcessor* ShaderPDXferProcessor::createGLInstance() const {
- return SkNEW(GLShaderPDXferProcessor);
+ return new GLShaderPDXferProcessor;
}
///////////////////////////////////////////////////////////////////////////////
uint8_t alpha = GrColorUnpackA(blendConstant);
blendConstant |= (0xff << GrColor_SHIFT_A);
- return SkNEW_ARGS(PDLCDXferProcessor, (blendConstant, alpha));
+ return new PDLCDXferProcessor(blendConstant, alpha);
}
PDLCDXferProcessor::~PDLCDXferProcessor() {
}
GrGLXferProcessor* PDLCDXferProcessor::createGLInstance() const {
- return SkNEW_ARGS(GLPDLCDXferProcessor, (*this));
+ return new GLPDLCDXferProcessor(*this);
}
GrXferProcessor::OptFlags
BlendFormula blendFormula = get_blend_formula(colorPOI, covPOI, hasMixedSamples, fXfermode);
if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlendingSupport()) {
- return SkNEW_ARGS(ShaderPDXferProcessor, (dstTexture, hasMixedSamples, fXfermode));
+ return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, fXfermode);
}
SkASSERT(!dstTexture || !dstTexture->texture());
- return SkNEW_ARGS(PorterDuffXferProcessor, (blendFormula));
+ return new PorterDuffXferProcessor(blendFormula);
}
bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/,
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return NULL;
}
- return SkNEW_ARGS(CircularRRectEffect, (edgeType, circularCornerFlags, rrect));
+ return new CircularRRectEffect(edgeType, circularCornerFlags, rrect);
}
void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
}
GrGLFragmentProcessor* CircularRRectEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLCircularRRectEffect, (*this));
+ return new GLCircularRRectEffect(*this);
}
//////////////////////////////////////////////////////////////////////////////
if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return NULL;
}
- return SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrect));
+ return new EllipticalRRectEffect(edgeType, rrect);
}
void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
}
GrGLFragmentProcessor* EllipticalRRectEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GLEllipticalRRectEffect, (*this));
+ return new GLEllipticalRRectEffect(*this);
}
//////////////////////////////////////////////////////////////////////////////
}
GrGLFragmentProcessor* GrSimpleTextureEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLSimpleTextureEffect, (*this));
+ return new GrGLSimpleTextureEffect(*this);
}
///////////////////////////////////////////////////////////////////////////////
GrTexture* tex,
const SkMatrix& matrix,
GrCoordSet coordSet = kLocal_GrCoordSet) {
- return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix,
- GrTextureParams::kNone_FilterMode, coordSet));
+ return new GrSimpleTextureEffect(procDataManager, tex, matrix,
+ GrTextureParams::kNone_FilterMode, coordSet);
}
/* clamp mode */
const SkMatrix& matrix,
GrTextureParams::FilterMode filterMode,
GrCoordSet coordSet = kLocal_GrCoordSet) {
- return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix, filterMode,
- coordSet));
+ return new GrSimpleTextureEffect(procDataManager, tex, matrix, filterMode, coordSet);
}
static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
const SkMatrix& matrix,
const GrTextureParams& p,
GrCoordSet coordSet = kLocal_GrCoordSet) {
- return SkNEW_ARGS(GrSimpleTextureEffect, (procDataManager, tex, matrix, p, coordSet));
+ return new GrSimpleTextureEffect(procDataManager, tex, matrix, p, coordSet);
}
virtual ~GrSimpleTextureEffect() {}
(GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) {
return GrSimpleTextureEffect::Create(procDataManager, texture, matrix, filterMode);
} else {
-
- return SkNEW_ARGS(GrTextureDomainEffect, (procDataManager,
- texture,
- matrix,
- domain,
- mode,
- filterMode,
- coordSet));
+ return new GrTextureDomainEffect(procDataManager, texture, matrix, domain, mode, filterMode,
+ coordSet);
}
}
}
GrGLFragmentProcessor* GrTextureDomainEffect::onCreateGLInstance() const {
- return SkNEW_ARGS(GrGLTextureDomainEffect, (*this));
+ return new GrGLTextureDomainEffect(*this);
}
bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() {
if (NULL == gAtlasCache) {
- gAtlasCache = SkNEW(Hash);
+ gAtlasCache = new Hash;
}
return gAtlasCache;
GetCache()->remove(entry->fDesc);
// remove the actual entry
- SkDELETE(entry);
+ delete entry;
if (0 == GetCache()->count()) {
- SkDELETE(gAtlasCache);
+ delete gAtlasCache;
gAtlasCache = NULL;
}
}
GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::Desc& desc) {
AtlasEntry* entry = GetCache()->find(desc);
if (NULL == entry) {
- entry = SkNEW(AtlasEntry);
+ entry = new AtlasEntry;
- entry->fAtlas = SkNEW_ARGS(GrTextureStripAtlas, (desc));
+ entry->fAtlas = new GrTextureStripAtlas(desc);
entry->fDesc = desc;
desc.fContext->addCleanUp(CleanUp, entry);
, fDesc(desc)
, fNumRows(desc.fHeight / desc.fRowHeight)
, fTexture(NULL)
- , fRows(SkNEW_ARRAY(AtlasRow, fNumRows))
+ , fRows(new AtlasRow[fNumRows])
, fLRUFront(NULL)
, fLRUBack(NULL) {
SkASSERT(fNumRows * fDesc.fRowHeight == fDesc.fHeight);
VALIDATE;
}
-GrTextureStripAtlas::~GrTextureStripAtlas() {
- SkDELETE_ARRAY(fRows);
-}
+GrTextureStripAtlas::~GrTextureStripAtlas() { delete[] fRows; }
int GrTextureStripAtlas::lockRow(const SkBitmap& data) {
VALIDATE;
// AtlasEntry proper
AtlasEntry() : fAtlas(NULL) {}
- ~AtlasEntry() { SkDELETE(fAtlas); }
+ ~AtlasEntry() { delete fAtlas; }
Desc fDesc;
GrTextureStripAtlas* fAtlas;
};
(sizes[2].fHeight != sizes[0].fHeight)) ?
GrTextureParams::kBilerp_FilterMode :
GrTextureParams::kNone_FilterMode;
- return SkNEW_ARGS(YUVtoRGBEffect, (procDataManager, yTexture, uTexture, vTexture, yuvMatrix,
- uvFilterMode, colorSpace));
+ return new YUVtoRGBEffect(procDataManager, yTexture, uTexture, vTexture, yuvMatrix,
+ uvFilterMode, colorSpace);
}
const char* name() const override { return "YUV to RGB"; }
this->addTextureAccess(&fVAccess);
}
- GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GLProcessor, (*this));
- }
+ GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLProcessor(*this); }
virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
GrProcessorKeyBuilder* b) const override {
return NULL;
}
- GrGLInterface* interface = SkNEW(GrGLInterface());
+ GrGLInterface* interface = new GrGLInterface();
GrGLInterface::Functions* functions = &interface->fFunctions;
GET_PROC(ActiveTexture);
return NULL;
}
- GrGLInterface* interface = SkNEW(GrGLInterface);
+ GrGLInterface* interface = new GrGLInterface;
GrGLInterface::Functions* functions = &interface->fFunctions;
GET_PROC(ActiveTexture);
fReadPixelsSupportedCache.reset();
- fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions)));
+ fShaderCaps.reset(new GrGLSLCaps(contextOptions));
this->init(contextOptions, ctxInfo, glInterface);
}
args.fContextOptions = &options;
- return SkNEW_ARGS(GrGLContext, (args));
+ return new GrGLContext(args);
}
GrGLContextInfo::GrGLContextInfo(const ConstructorArgs& args) {
fDriver = args.fDriver;
fDriverVersion = args.fDriverVersion;
- fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*args.fContextOptions, *this, fInterface)));
+ fGLCaps.reset(new GrGLCaps(*args.fContextOptions, *this, fInterface));
}
BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) {
}
- ~BufferObj() { SkDELETE_ARRAY(fDataPtr); }
+ ~BufferObj() { delete[] fDataPtr; }
void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
if (fDataPtr) {
SkASSERT(0 != fSize);
- SkDELETE_ARRAY(fDataPtr);
+ delete[] fDataPtr;
}
fSize = size;
- fDataPtr = SkNEW_ARRAY(char, size);
+ fDataPtr = new char[size];
}
GrGLuint id() const { return fID; }
if (kFreeListEnd == fFreeListHead) {
// no free slots - create a new one
id = fBuffers.count();
- buffer = SkNEW_ARGS(BufferObj, (id));
+ buffer = new BufferObj(id);
*fBuffers.append() = buffer;
} else {
// grab the head of the free list and advance the head to the next free slot.
id = static_cast<GrGLuint>(fFreeListHead);
fFreeListHead = reinterpret_cast<intptr_t>(fBuffers[id]);
- buffer = SkNEW_ARGS(BufferObj, (id));
+ buffer = new BufferObj(id);
fBuffers[id] = buffer;
}
SkASSERT(fBuffers.count() > 0);
GrGLuint id = buffer->id();
- SkDELETE(buffer);
+ delete buffer;
fBuffers[id] = reinterpret_cast<BufferObj*>(fFreeListHead);
fFreeListHead = id;
, fCurrShaderID(0) {}
private:
- static void* Create() { return SkNEW(ThreadContext ); }
- static void Delete(void* context) { SkDELETE(reinterpret_cast<ThreadContext *>(context)); }
+ static void* Create() { return new ThreadContext; }
+ static void Delete(void* context) { delete reinterpret_cast<ThreadContext*>(context); }
};
// Functions not declared in GrGLBogusInterface.h (not common with the Debug GL interface).
} // end anonymous namespace
const GrGLInterface* GrGLCreateNullInterface() {
- GrGLInterface* interface = SkNEW(GrGLInterface);
+ GrGLInterface* interface = new GrGLInterface;
interface->fStandard = kGL_GrGLStandard;
return idx;
}
-GrGLExtensions::GrGLExtensions(const GrGLExtensions& that) : fStrings(SkNEW(SkTArray<SkString>)) {
+GrGLExtensions::GrGLExtensions(const GrGLExtensions& that) : fStrings(new SkTArray<SkString>) {
*this = that;
}
// This is not terribly effecient but we really only expect this function to be called at
// most a handful of times when our test programs start.
SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.detach());
- fStrings.reset(SkNEW(SkTArray<SkString>(oldStrings->count() - 1)));
+ fStrings.reset(new SkTArray<SkString>(oldStrings->count() - 1));
fStrings->push_back_n(idx, &oldStrings->front());
fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx] + 1);
return true;
virtual ~GrGLFragmentProcessor() {
for (int i = 0; i < fChildProcessors.count(); ++i) {
- SkDELETE(fChildProcessors[i]);
+ delete fChildProcessors[i];
}
}
}
GrGLContext* glContext = GrGLContext::Create(glInterface, options);
if (glContext) {
- return SkNEW_ARGS(GrGLGpu, (glContext, context));
+ return new GrGLGpu(glContext, context);
}
return NULL;
}
SkDebugf("%s", this->glCaps().dump().c_str());
}
- fProgramCache = SkNEW_ARGS(ProgramCache, (this));
+ fProgramCache = new ProgramCache(this);
SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVertexAttribs);
idDesc.fTextureID, &rtIDDesc)) {
return NULL;
}
- texture = SkNEW_ARGS(GrGLTextureRenderTarget, (this, surfDesc, idDesc, rtIDDesc));
+ texture = new GrGLTextureRenderTarget(this, surfDesc, idDesc, rtIDDesc);
} else {
- texture = SkNEW_ARGS(GrGLTexture, (this, surfDesc, idDesc));
+ texture = new GrGLTexture(this, surfDesc, idDesc);
}
if (NULL == texture) {
return NULL;
desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount());
desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
- GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc));
+ GrRenderTarget* tgt = new GrGLRenderTarget(this, desc, idDesc);
if (wrapDesc.fStencilBits) {
GrGLStencilAttachment::IDDesc sbDesc;
GrGLStencilAttachment::Format format;
format.fPacked = false;
format.fStencilBits = wrapDesc.fStencilBits;
format.fTotalBits = wrapDesc.fStencilBits;
- GrGLStencilAttachment* sb = SkNEW_ARGS(GrGLStencilAttachment,
- (this,
- sbDesc,
- desc.fWidth,
- desc.fHeight,
- desc.fSampleCnt,
- format));
+ GrGLStencilAttachment* sb = new GrGLStencilAttachment(
+ this, sbDesc, desc.fWidth, desc.fHeight, desc.fSampleCnt, format);
tgt->renderTargetPriv().didAttachStencilAttachment(sb);
sb->unref();
}
GL_CALL(DeleteTextures(1, &idDesc.fTextureID));
return return_null_texture();
}
- tex = SkNEW_ARGS(GrGLTextureRenderTarget, (this, desc, idDesc, rtIDDesc));
+ tex = new GrGLTextureRenderTarget(this, desc, idDesc, rtIDDesc);
} else {
- tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc));
+ tex = new GrGLTexture(this, desc, idDesc);
}
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
}
GrGLTexture* tex;
- tex = SkNEW_ARGS(GrGLTexture, (this, desc, idDesc));
+ tex = new GrGLTexture(this, desc, idDesc);
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
SkDebugf("--- new compressed texture [%d] size=(%d %d) config=%d\n",
// whatever sizes GL gives us. In that case we query for the size.
GrGLStencilAttachment::Format format = sFmt;
get_stencil_rb_sizes(this->glInterface(), &format);
- SkAutoTUnref<GrGLStencilAttachment> sb(SkNEW_ARGS(GrGLStencilAttachment,
- (this, sbDesc, width, height, samples, format)));
+ SkAutoTUnref<GrGLStencilAttachment> sb(
+ new GrGLStencilAttachment(this, sbDesc, width, height, samples, format));
if (this->attachStencilAttachmentToRenderTarget(sb, rt)) {
fLastSuccessfulStencilFmtIdx = sIdx;
rt->renderTargetPriv().didAttachStencilAttachment(sb);
if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) {
desc.fID = 0;
- GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this, desc));
+ GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc);
return vertexBuffer;
} else {
GL_CALL(GenBuffers(1, &desc.fID));
this->notifyVertexBufferDelete(desc.fID);
return NULL;
}
- GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this, desc));
+ GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc);
return vertexBuffer;
}
return NULL;
if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) {
desc.fID = 0;
- GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc));
+ GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
return indexBuffer;
} else {
GL_CALL(GenBuffers(1, &desc.fID));
this->notifyIndexBufferDelete(desc.fID);
return NULL;
}
- GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc));
+ GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
return indexBuffer;
}
return NULL;
GrGLuint arrayID;
GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID));
int attrCount = gpu->glCaps().maxVertexAttributes();
- fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (arrayID, attrCount));
+ fVBOVertexArray = new GrGLVertexArray(arrayID, attrCount);
}
if (ibufferID) {
attribState = fVBOVertexArray->bindWithIndexBuffer(gpu, *ibufferID);
public:
HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); }
- ~HWGeometryState() { SkDELETE(fVBOVertexArray); }
+ ~HWGeometryState() { delete fVBOVertexArray; }
void invalidate() {
fBoundVertexArrayIDIsValid = false;
GrGLGpu::ProgramCache::~ProgramCache() {
for (int i = 0; i < fCount; ++i){
- SkDELETE(fEntries[i]);
+ delete fEntries[i];
}
// dump stats
#ifdef PROGRAM_CACHE_STATS
for (int i = 0; i < fCount; ++i) {
SkASSERT(fEntries[i]->fProgram.get());
fEntries[i]->fProgram->abandon();
- SkDELETE(fEntries[i]);
+ delete fEntries[i];
}
fCount = 0;
}
}
int purgeIdx = 0;
if (fCount < kMaxEntries) {
- entry = SkNEW(Entry);
+ entry = new Entry;
purgeIdx = fCount++;
fEntries[purgeIdx] = entry;
} else {
GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
SkASSERT(interface);
- GrGLInterface* clone = SkNEW(GrGLInterface);
+ GrGLInterface* clone = new GrGLInterface;
clone->fStandard = interface->fStandard;
clone->fExtensions = interface->fExtensions;
clone->fFunctions = interface->fFunctions;
return this->takeRef();
}
- SparseNameRange* left = SkNEW_ARGS(ContiguousNameRange, (fFirst, name));
+ SparseNameRange* left = new ContiguousNameRange(fFirst, name);
SparseNameRange* right = this->takeRef();
fFirst = name + 1;
- return SkNEW_ARGS(SparseNameTree, (left, right));
+ return new SparseNameTree(left, right);
}
};
GrGLuint GrGLNameAllocator::allocateName() {
if (NULL == fAllocatedNames.get()) {
- fAllocatedNames.reset(SkNEW_ARGS(ContiguousNameRange, (fFirstName, fFirstName + 1)));
+ fAllocatedNames.reset(new ContiguousNameRange(fFirstName, fFirstName + 1));
return fFirstName;
}
}
GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const GrStrokeInfo& stroke) {
- return SkNEW_ARGS(GrGLPath, (this->gpu(), inPath, stroke));
+ return new GrGLPath(this->gpu(), inPath, stroke);
}
GrPathRange* GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* pathGenerator,
const GrStrokeInfo& stroke) {
- return SkNEW_ARGS(GrGLPathRange, (this->gpu(), pathGenerator, stroke));
+ return new GrGLPathRange(this->gpu(), pathGenerator, stroke);
}
void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* path) {
static const int range = 65536;
GrGLuint firstName;
GL_CALL_RET(firstName, GenPaths(range));
- fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, firstName + range)));
+ fPathNameAllocator.reset(new GrGLNameAllocator(firstName, firstName + range));
}
// When allocating names one at a time, pull from a client-side pool of
}
SkGLContext::GLFenceSync* SkGLContext::GLFenceSync::CreateIfSupported(const SkGLContext* ctx) {
- SkAutoTDelete<GLFenceSync> ret(SkNEW(GLFenceSync));
+ SkAutoTDelete<GLFenceSync> ret(new GLFenceSync);
if (kGL_GrGLStandard == ctx->gl()->fStandard) {
const GrGLubyte* versionStr;
BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) {}
- ~BufferObj() { SkDELETE_ARRAY(fDataPtr); }
+ ~BufferObj() { delete[] fDataPtr; }
void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
if (fDataPtr) {
SkASSERT(0 != fSize);
- SkDELETE_ARRAY(fDataPtr);
+ delete[] fDataPtr;
}
fSize = size;
- fDataPtr = SkNEW_ARRAY(char, size);
+ fDataPtr = new char[size];
}
GrGLuint id() const { return fID; }
if (kFreeListEnd == fFreeListHead) {
// no free slots - create a new one
id = fBuffers.count();
- buffer = SkNEW_ARGS(BufferObj, (id));
+ buffer = new BufferObj(id);
*fBuffers.append() = buffer;
} else {
// grab the head of the free list and advance the head to the next free slot.
id = static_cast<GrGLuint>(fFreeListHead);
fFreeListHead = reinterpret_cast<intptr_t>(fBuffers[id]);
- buffer = SkNEW_ARGS(BufferObj, (id));
+ buffer = new BufferObj(id);
fBuffers[id] = buffer;
}
SkASSERT(fBuffers.count() > 0);
GrGLuint id = buffer->id();
- SkDELETE(buffer);
+ delete buffer;
fBuffers[id] = reinterpret_cast<BufferObj*>(fFreeListHead);
fFreeListHead = id;
} // end anonymous namespace
static GrGLInterface* create_null_interface(State* state) {
- GrGLInterface* interface = SkNEW_ARGS(NullInterface, (state));
+ GrGLInterface* interface = new NullInterface(state);
interface->fStandard = kGL_GrGLStandard;
//////////////////////////////////////////////////////////////////////////////
static void* create_tls() {
- State** current = SkNEW(State*);
+ State** current = new State*;
*current = NULL;
return current;
}
if (*current) {
(*current)->unref();
}
- SkDELETE(current);
+ delete current;
}
static State* current_context() {
if (kGLES_GrGLStandard == forcedGpuAPI) {
return NULL;
}
- SkNullGLContext* ctx = SkNEW(SkNullGLContext);
+ SkNullGLContext* ctx = new SkNullGLContext;
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
}
SkNullGLContext::SkNullGLContext() {
- fState = SkNEW(ContextState);
+ fState = new ContextState;
GrGLInterface* interface = create_null_interface(fState);
this->init(interface);
#if GR_GL_PER_GL_FUNC_CALLBACK
}
GrGLProgram* GrGLPathProgramBuilder::createProgram(GrGLuint programID) {
- return SkNEW_ARGS(GrGLPathProgram, (fGpu, this->desc(), fUniformHandles, programID,
- fUniforms,
- fSeparableVaryingInfos,
- fGeometryProcessor,
- fXferProcessor, fFragmentProcessors.get(),
- &fSamplerUniforms));
+ return new GrGLPathProgram(fGpu, this->desc(), fUniformHandles, programID, fUniforms,
+ fSeparableVaryingInfos, fGeometryProcessor, fXferProcessor,
+ fFragmentProcessors.get(), &fSamplerUniforms);
}
GrGLProgramBuilder::SeparableVaryingHandle GrGLPathProgramBuilder::addSeparableVarying(
SkASSERT(gpu->glCaps().shaderCaps()->pathRenderingSupport() &&
!args.fPrimitiveProcessor->willUseGeoShader() &&
args.fPrimitiveProcessor->numAttribs() == 0);
- return SkNEW_ARGS(GrGLPathProgramBuilder, (gpu, args));
+ return new GrGLPathProgramBuilder(gpu, args);
} else {
- return SkNEW_ARGS(GrGLProgramBuilder, (gpu, args));
+ return new GrGLProgramBuilder(gpu, args);
}
}
this->emitAndInstallProc(primProc, inputColor, inputCoverage);
- fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs));
+ fFragmentProcessors.reset(new GrGLInstalledFragProcs);
int numProcs = this->pipeline().numFragmentStages();
this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentStages(), inputColor);
this->emitAndInstallFragProcs(this->pipeline().numColorFragmentStages(), numProcs,
int index,
const char* outColor,
const char* inColor) {
- GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc);
+ GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc;
const GrFragmentProcessor& fp = *fs.processor();
ifp->fGLProc.reset(fp.createGLInstance());
const char* outColor,
const char* outCoverage) {
SkASSERT(!fGeometryProcessor);
- fGeometryProcessor = SkNEW(GrGLInstalledGeoProc);
+ fGeometryProcessor = new GrGLInstalledGeoProc;
const GrBatchTracker& bt = this->batchTracker();
fGeometryProcessor->fGLProc.reset(gp.createGLInstance(bt, *fGpu->glCaps().glslCaps()));
AutoStageAdvance adv(this);
SkASSERT(!fXferProcessor);
- fXferProcessor = SkNEW(GrGLInstalledXferProc);
+ fXferProcessor = new GrGLInstalledXferProc;
fXferProcessor->fGLProc.reset(xp.createGLInstance());
}
GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) {
- return SkNEW_ARGS(GrGLProgram, (fGpu, this->desc(), fUniformHandles, programID, fUniforms,
- fGeometryProcessor, fXferProcessor, fFragmentProcessors.get(),
- &fSamplerUniforms));
+ return new GrGLProgram(fGpu, this->desc(), fUniformHandles, programID, fUniforms,
+ fGeometryProcessor, fXferProcessor, fFragmentProcessors.get(),
+ &fSamplerUniforms);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
int numProcs = fProcs.count();
for (int e = 0; e < numProcs; ++e) {
- SkDELETE(fProcs[e]);
+ delete fProcs[e];
}
}
SkASSERT(0 < gStaticRefCount);
if (NULL == gObj) {
- gObj = SkNEW(GrDebugGL);
+ gObj = new GrDebugGL;
}
return gObj;
SkASSERT(gStaticRefCount > 0);
gStaticRefCount--;
if (0 == gStaticRefCount) {
- SkDELETE(gObj);
+ delete gObj;
gObj = NULL;
}
}
// factory creation entry point. This entry point is used by the GrGLDebug
// object to instantiate the various objects
// all globally unique IDs
-#define GR_DEFINE_CREATOR(className) \
- public: \
- static GrFakeRefObj *create ## className() { \
- return SkNEW(className); \
- }
+#define GR_DEFINE_CREATOR(className) \
+public: \
+ static GrFakeRefObj *create##className() { return new className; }
#endif // GrFakeRefObj_DEFINED
////////////////////////////////////////////////////////////////////////////////
const GrGLInterface* GrGLCreateDebugInterface() {
- GrGLInterface* interface = SkNEW(GrDebugGLInterface);
+ GrGLInterface *interface = new GrDebugGLInterface;
interface->fStandard = kGL_GrGLStandard;
if (kGLES_GrGLStandard == forcedGpuAPI) {
return NULL;
}
- return SkNEW(SkDebugGLContext);
+ return new SkDebugGLContext;
}
private:
void onPlatformMakeCurrent() const override {}
if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) {
return NULL;
}
- return SkNEW_ARGS(SkEGLFenceSync, (display));
+ return new SkEGLFenceSync(display);
}
SkPlatformGpuFence SkEGLFenceSync::insertFence() const {
} // anonymous namespace
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
- EGLGLContext* ctx = SkNEW_ARGS(EGLGLContext, (forcedGpuAPI));
+ EGLGLContext* ctx = new EGLGLContext(forcedGpuAPI);
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
} // anonymous namespace
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
- GLXGLContext* ctx = SkNEW_ARGS(GLXGLContext, (forcedGpuAPI));
+ GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI);
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
if (kGLES_GrGLStandard == forcedGpuAPI) {
return NULL;
}
- MacGLContext* ctx = SkNEW(MacGLContext);
+ MacGLContext* ctx = new MacGLContext;
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
if (kGLES_GrGLStandard == forcedGpuAPI) {
return NULL;
}
- SkMesaGLContext* ctx = SkNEW(SkMesaGLContext);
+ SkMesaGLContext* ctx = new SkMesaGLContext;
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
} // anonymous namespace
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
- WinGLContext* ctx = SkNEW_ARGS(WinGLContext, (forcedGpuAPI));
+ WinGLContext* ctx = new WinGLContext(forcedGpuAPI);
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
return NULL;
}
return ctx;
unrefCopy.reset(tex);
}
const SkImageInfo info = bm.info();
- return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), bm.getGenerationID(),
- info.alphaType(), tex, 0, SkSurface::kNo_Budgeted));
+ return new SkImage_Gpu(info.width(), info.height(), bm.getGenerationID(), info.alphaType(),
+ tex, 0, SkSurface::kNo_Budgeted);
}
#endif
}
const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted;
- return SkNEW_ARGS(SkImage_Gpu,
- (desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, 0, budgeted));
-
+ return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, 0, budgeted);
}
SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at,
const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted;
const int sampleCount = 0; // todo: make this an explicit parameter to newSurface()?
- return SkNEW_ARGS(SkImage_Gpu, (desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
- at, dst, sampleCount, budgeted));
+ return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst, sampleCount,
+ budgeted);
}
SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorSpace,
GrDrawContext* drawContext = ctx->drawContext();
drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(dst);
- return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
- kOpaque_SkAlphaType, dst, 0, budgeted));
+ return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
+ kOpaque_SkAlphaType, dst, 0, budgeted);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Here we actually make a copy of the caller's pixel data
SkAutoDataUnref data(SkData::NewWithCopy(pixels, size));
- return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, ctable, NULL));
+ return new SkImage_Raster(info, data, rowBytes, ctable, NULL);
}
}
SkColorTable* ctable = NULL;
- return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, ctable, NULL));
+ return new SkImage_Raster(info, data, rowBytes, ctable, NULL);
}
SkImage* SkImage::NewFromRaster(const SkImageInfo& info, const void* pixels, size_t rowBytes,
SkColorTable* ctable = NULL;
SkAutoDataUnref data(SkData::NewWithProc(pixels, size, proc, ctx));
- return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, ctable, NULL));
+ return new SkImage_Raster(info, data, rowBytes, ctable, NULL);
}
SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* subset) {
return NULL;
}
- return SkNEW_ARGS(SkImage_Raster, (bitmap, NULL));
+ return new SkImage_Raster(bitmap, NULL);
}
SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
if (!SkImage_Raster::ValidArgs(info, rowBytes, NULL, NULL)) {
return NULL;
}
- return SkNEW_ARGS(SkImage_Raster, (info, pr, pixelRefOrigin, rowBytes, props));
+ return new SkImage_Raster(info, pr, pixelRefOrigin, rowBytes, props);
}
SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* props,
as_IB(image)->initWithProps(*props);
}
} else {
- image = SkNEW_ARGS(SkImage_Raster, (bm, props));
+ image = new SkImage_Raster(bm, props);
}
return image;
}
// When we think this works...
// flags |= SkCanvas::kConservativeRasterClip_InitFlag;
- return SkNEW_ARGS(SkCanvas, (fDevice, flags));
+ return new SkCanvas(fDevice, flags);
}
SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
SkImage* image = NULL;
GrTexture* tex = fDevice->accessRenderTarget()->asTexture();
if (tex) {
- image = SkNEW_ARGS(SkImage_Gpu,
- (info.width(), info.height(), kNeedNewImageUniqueID, info.alphaType(),
- tex, sampleCount, budgeted));
+ image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUniqueID,
+ info.alphaType(), tex, sampleCount, budgeted);
}
if (image) {
as_IB(image)->initWithProps(this->props());
if (!device) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (device));
+ return new SkSurface_Gpu(device);
}
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const SkImageInfo& info,
if (!device) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (device));
+ return new SkSurface_Gpu(device);
}
SkSurface* SkSurface::NewFromBackendTexture(GrContext* context, const GrBackendTextureDesc& desc,
if (!device) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (device));
+ return new SkSurface_Gpu(device);
}
SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext* context,
if (!device) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Gpu, (device));
+ return new SkSurface_Gpu(device);
}
#endif
}
}
-SkCanvas* SkSurface_Raster::onNewCanvas() {
- return SkNEW_ARGS(SkCanvas, (fBitmap, this->props()));
-}
+SkCanvas* SkSurface_Raster::onNewCanvas() { return new SkCanvas(fBitmap, this->props()); }
SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
return SkSurface::NewRaster(info, &this->props());
return NULL;
}
- return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rb, releaseProc, context, props));
+ return new SkSurface_Raster(info, pixels, rb, releaseProc, context, props);
}
SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes,
if (NULL == pr.get()) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Raster, (pr, props));
+ return new SkSurface_Raster(pr, props);
}
return NULL;
}
- return SkNEW_ARGS(DecodingImageGenerator,
- (data, autoStream.detach(), info.makeAlphaType(newAlphaType),
- opts.fSampleSize, opts.fDitherImage));
+ return new DecodingImageGenerator(data, autoStream.detach(), info.makeAlphaType(newAlphaType),
+ opts.fSampleSize, opts.fDitherImage);
}
} // namespace
if (NULL == data) {
return NULL;
}
- SkStreamRewindable* stream = SkNEW_ARGS(SkMemoryStream, (data));
+ SkStreamRewindable* stream = new SkMemoryStream(data);
SkASSERT(stream != NULL);
return CreateDecodingImageGenerator(data, stream, opts);
}
bool SkImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, int* /*width*/,
int* /*height*/) {
- SkDELETE(stream);
+ delete stream;
return false;
}
// if we are given a stream that does not support rewinding.
if (!rewindSuceeded) {
SkDEBUGF(("Unable to rewind the image stream."));
- SkDELETE(codec);
+ delete codec;
return NULL;
}
static SkImageDecoder* sk_libastc_dfactory(SkStreamRewindable* stream) {
if (is_astc(stream)) {
- return SkNEW(SkASTCImageDecoder);
+ return new SkASTCImageDecoder;
}
return NULL;
}
static SkImageDecoder* sk_libktx_dfactory(SkStreamRewindable* stream) {
if (SkKTXFile::is_ktx(stream)) {
- return SkNEW(SkKTXImageDecoder);
+ return new SkKTXImageDecoder;
}
return NULL;
}
}
SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) {
- return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL;
+ return (SkImageEncoder::kKTX_Type == t) ? new SkKTXImageEncoder : NULL;
}
static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory);
static SkImageDecoder* sk_libbmp_dfactory(SkStreamRewindable* stream) {
if (is_bmp(stream)) {
- return SkNEW(SkBMPImageDecoder);
+ return new SkBMPImageDecoder;
}
return NULL;
}
fillIndex = 0; // If not, fix it.
}
- SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colorPtr, colorCount)));
+ SkAutoTUnref<SkColorTable> ctable(new SkColorTable(colorPtr, colorCount));
if (!this->allocPixelRef(bm, ctable)) {
return error_return(*bm, "allocPixelRef");
}
static SkImageDecoder* sk_libgif_dfactory(SkStreamRewindable* stream) {
if (is_gif(stream)) {
- return SkNEW(SkGIFImageDecoder);
+ return new SkGIFImageDecoder;
}
return NULL;
}
static SkImageDecoder* sk_libico_dfactory(SkStreamRewindable* stream) {
if (is_ico(stream)) {
- return SkNEW(SkICOImageDecoder);
+ return new SkICOImageDecoder;
}
return NULL;
}
fImageHeight = 0;
}
- virtual ~SkJPEGImageDecoder() {
- SkDELETE(fImageIndex);
- }
+ virtual ~SkJPEGImageDecoder() { delete fImageIndex; }
#endif
Format getFormat() const override {
#ifdef SK_BUILD_FOR_ANDROID
bool SkJPEGImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, int *width, int *height) {
-
- SkAutoTDelete<SkJPEGImageIndex> imageIndex(SkNEW_ARGS(SkJPEGImageIndex, (stream, this)));
+ SkAutoTDelete<SkJPEGImageIndex> imageIndex(new SkJPEGImageIndex(stream, this));
skjpeg_error_mgr sk_err;
set_error_mgr(imageIndex->cinfo(), &sk_err);
*height = fImageHeight;
}
- SkDELETE(fImageIndex);
+ delete fImageIndex;
fImageIndex = imageIndex.detach();
return true;
static SkImageDecoder* sk_libjpeg_dfactory(SkStreamRewindable* stream) {
if (is_jpeg(stream)) {
- return SkNEW(SkJPEGImageDecoder);
+ return new SkJPEGImageDecoder;
}
return NULL;
}
}
static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
- return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
+ return (SkImageEncoder::kJPEG_Type == t) ? new SkJPEGImageEncoder : NULL;
}
static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
return kPNG_Format;
}
- virtual ~SkPNGImageDecoder() {
- SkDELETE(fImageIndex);
- }
+ virtual ~SkPNGImageDecoder() { delete fImageIndex; }
protected:
#ifdef SK_BUILD_FOR_ANDROID
*colorPtr++ = lastColor;
}
- *colorTablep = SkNEW_ARGS(SkColorTable, (colorStorage, colorCount));
+ *colorTablep = new SkColorTable(colorStorage, colorCount);
*reallyHasAlphap = reallyHasAlpha;
return true;
}
png_build_index(png_ptr);
if (fImageIndex) {
- SkDELETE(fImageIndex);
+ delete fImageIndex;
}
- fImageIndex = SkNEW_ARGS(SkPNGImageIndex, (streamDeleter.detach(), png_ptr, info_ptr));
+ fImageIndex = new SkPNGImageIndex(streamDeleter.detach(), png_ptr, info_ptr);
return true;
}
SkImageDecoder* sk_libpng_dfactory(SkStreamRewindable* stream) {
if (is_png(stream)) {
- return SkNEW(SkPNGImageDecoder);
+ return new SkPNGImageDecoder;
}
return NULL;
}
}
SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
- return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
+ return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : NULL;
}
static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
}
// Magic matches, call decoder
- return SkNEW(SkWEBPImageDecoder);
+ return new SkWEBPImageDecoder;
}
static SkImageDecoder::Format get_format_webp(SkStreamRewindable* stream) {
}
static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
- return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NULL;
+ return (SkImageEncoder::kWEBP_Type == t) ? new SkWEBPImageEncoder : NULL;
}
static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
static SkImageDecoder* sk_libpkm_dfactory(SkStreamRewindable* stream) {
if (is_pkm(stream)) {
- return SkNEW(SkPKMImageDecoder);
+ return new SkPKMImageDecoder;
}
return NULL;
}
}
const SkPMColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
- SkColorTable* ct = SkNEW_ARGS(SkColorTable, (colors, 2));
+ SkColorTable* ct = new SkColorTable(colors, 2);
SkAutoUnref aur(ct);
if (!this->allocPixelRef(decodedBitmap, ct)) {
wbmp_head head;
if (head.init(stream)) {
- return SkNEW(SkWBMPImageDecoder);
+ return new SkWBMPImageDecoder;
}
return NULL;
}
memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
// must rewind here, since our construct wants to re-read the data
stream->rewind();
- return SkNEW_ARGS(SkGIFMovie, (stream));
+ return new SkGIFMovie(stream);
}
}
return NULL;
}
const SkImageInfo info = generator->getInfo();
if (!dst->setInfo(info)) {
- SkDELETE(generator);
+ delete generator;
return false;
}
- SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef,
- (info, generator, dst->rowBytes())));
+ SkAutoTUnref<SkCachingPixelRef> ref(new SkCachingPixelRef(info, generator, dst->rowBytes()));
dst->setPixelRef(ref);
return true;
}
SkASSERT(fImageGenerator != NULL);
}
SkCachingPixelRef::~SkCachingPixelRef() {
- SkDELETE(fImageGenerator);
+ delete fImageGenerator;
// Assert always unlock before unref.
}
*
* If Install fails or when the SkCachingPixelRef that is
* installed into destination is destroyed, it will call
- * SkDELETE() on the generator. Therefore, generator should be
- * allocated with SkNEW() or SkNEW_ARGS().
+ * `delete` on the generator. Therefore, generator should be
+ * allocated with `new`.
*/
static bool Install(SkImageGenerator* gen, SkBitmap* dst);
if (NULL == addr) {
return NULL;
}
- PoolDiscardableMemory* dm = SkNEW_ARGS(PoolDiscardableMemory,
- (this, addr, bytes));
+ PoolDiscardableMemory* dm = new PoolDiscardableMemory(this, addr, bytes);
SkAutoMutexAcquire autoMutexAcquire(fMutex);
fList.addToHead(dm);
fUsed += bytes;
} // namespace
SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create(size_t size, SkBaseMutex* mutex) {
- return SkNEW_ARGS(DiscardableMemoryPool, (size, mutex));
+ return new DiscardableMemoryPool(size, mutex);
}
SK_DECLARE_STATIC_LAZY_PTR(SkDiscardableMemoryPool, global, create_global_pool);
fDiscardableMemory->unlock();
fDiscardableMemoryIsLocked = false;
}
- SkDELETE(fDiscardableMemory);
+ delete fDiscardableMemory;
SkSafeUnref(fDMFactory);
- SkDELETE(fGenerator);
+ delete fGenerator;
}
bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
rec->fRowBytes = fRowBytes;
return true;
}
- SkDELETE(fDiscardableMemory);
+ delete fDiscardableMemory;
fDiscardableMemory = NULL;
fDiscardableMemoryIsLocked = false;
}
if (!fGenerator->getPixels(info, pixels, fRowBytes, colors, &colorCount)) {
fDiscardableMemory->unlock();
fDiscardableMemoryIsLocked = false;
- SkDELETE(fDiscardableMemory);
+ delete fDiscardableMemory;
fDiscardableMemory = NULL;
return false;
}
// could move it into the block, but then again perhaps it is small enough that this doesn't
// really matter.
if (colorCount > 0) {
- fCTable.reset(SkNEW_ARGS(SkColorTable, (colors, colorCount)));
+ fCTable.reset(new SkColorTable(colors, colorCount));
} else {
fCTable.reset(NULL);
}
return dst->tryAllocPixels();
}
SkAutoTUnref<SkDiscardablePixelRef> ref(
- SkNEW_ARGS(SkDiscardablePixelRef,
- (prInfo, autoGenerator.detach(), dst->rowBytes(), factory)));
+ new SkDiscardablePixelRef(prInfo, autoGenerator.detach(), dst->rowBytes(), factory));
dst->setPixelRef(ref, origin.x(), origin.y());
return true;
}
static SkXfermode* create_xfermode(const ProcCoeff& rec, SkXfermode::Mode mode) {
switch (mode) {
- #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \
- return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>))
+#define CASE(Mode) \
+ case SkXfermode::k##Mode##_Mode: \
+ return new Sk4pxXfermode(rec, mode, &Mode, &xfer_aa<Mode>)
CASE(Clear);
CASE(Src);
CASE(Dst);
CASE(Lighten);
#undef CASE
- #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \
- return SkNEW_ARGS(SkPMFloatXfermode, (rec, mode, &Mode))
+#define CASE(Mode) \
+ case SkXfermode::k##Mode##_Mode: \
+ return new SkPMFloatXfermode(rec, mode, &Mode)
CASE(ColorDodge);
CASE(ColorBurn);
CASE(SoftLight);
int cpu_info[4] = { 0, 0, 0, 0 };
getcpuid(1, cpu_info);
- int* level = SkNEW(int);
+ int* level = new int;
if ((cpu_info[2] & (1<<20)) != 0) {
*level = SK_CPU_SSE_LEVEL_SSE42;
#if DEBUG_SHOW_TEST_NAME
-void* SkPathOpsDebug::CreateNameStr() {
- return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH);
-}
+void* SkPathOpsDebug::CreateNameStr() { return new char[DEBUG_FILENAME_STRING_LENGTH]; }
-void SkPathOpsDebug::DeleteNameStr(void* v) {
- SkDELETE_ARRAY(reinterpret_cast<char* >(v));
-}
+void SkPathOpsDebug::DeleteNameStr(void* v) { delete[] reinterpret_cast<char*>(v); }
void SkPathOpsDebug::BumpTestName(char* test) {
char* num = test + strlen(test);
template<typename TCurve, typename OppCurve>
void SkTSpan<TCurve, OppCurve>::addBounded(SkTSpan<OppCurve, TCurve>* span, SkChunkAlloc* heap) {
- SkTSpanBounded<OppCurve, TCurve>* bounded = SkNEW_PLACEMENT(heap->allocThrow(
- sizeof(SkTSpanBounded<OppCurve, TCurve>)), (SkTSpanBounded<OppCurve, TCurve>));
+ SkTSpanBounded<OppCurve, TCurve>* bounded = new (heap->allocThrow(
+ sizeof(SkTSpanBounded<OppCurve, TCurve>)))(SkTSpanBounded<OppCurve, TCurve>);
bounded->fBounded = span;
bounded->fNext = fBounded;
fBounded = bounded;
result->reset();
fDeleted = result->fNext;
} else {
- result = SkNEW_PLACEMENT(fHeap.allocThrow(sizeof(SkTSpan<TCurve, OppCurve>)),
- (SkTSpan<TCurve, OppCurve>));
+ result = new (fHeap.allocThrow(sizeof(SkTSpan<TCurve, OppCurve>)))(
+ SkTSpan<TCurve, OppCurve>);
result->fBounded = NULL;
#if DEBUG_T_SECT
++fDebugAllocatedCount;
z_stream fZStream;
};
-SkDeflateWStream::SkDeflateWStream(SkWStream* out)
- : fImpl(SkNEW(SkDeflateWStream::Impl)) {
+SkDeflateWStream::SkDeflateWStream(SkWStream* out) : fImpl(new SkDeflateWStream::Impl) {
fImpl->fOut = out;
fImpl->fInBufferIndex = 0;
if (!fImpl->fOut) {
}
static SkPDFArray* make_indexed_color_space(const SkColorTable* table) {
- SkPDFArray* result = SkNEW(SkPDFArray);
+ SkPDFArray* result = new SkPDFArray;
result->reserve(4);
result->appendName("Indexed");
result->appendName("DeviceRGB");
SkJFIFInfo info;
if (data && SkIsJFIF(data, &info)) {
bool yuv = info.fType == SkJFIFInfo::kYCbCr;
- SkPDFBitmap* pdfBitmap = SkNEW_ARGS(PDFJpegBitmap, (bm, data, yuv));
+ SkPDFBitmap* pdfBitmap = new PDFJpegBitmap(bm, data, yuv);
canon->addBitmap(pdfBitmap);
return pdfBitmap;
}
SkPDFObject* smask = NULL;
if (!bm.isOpaque() && !SkBitmap::ComputeIsOpaque(bm)) {
- smask = SkNEW_ARGS(PDFAlphaBitmap, (bm));
+ smask = new PDFAlphaBitmap(bm);
}
- SkPDFBitmap* pdfBitmap = SkNEW_ARGS(PDFDefaultBitmap, (bm, smask));
+ SkPDFBitmap* pdfBitmap = new PDFDefaultBitmap(bm, smask);
canon->addBitmap(pdfBitmap);
return pdfBitmap;
}
////////////////////////////////////////////////////////////////////////////////
-SkPDFDevice::SkPDFDevice(SkISize pageSize,
- SkScalar rasterDpi,
- SkPDFCanon* canon,
- bool flip)
+SkPDFDevice::SkPDFDevice(SkISize pageSize, SkScalar rasterDpi, SkPDFCanon* canon, bool flip)
: INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry))
, fPageSize(pageSize)
, fContentSize(pageSize)
, fLastMarginContentEntry(NULL)
, fDrawingArea(kContent_DrawingArea)
, fClipStack(NULL)
- , fFontGlyphUsage(SkNEW(SkPDFGlyphSetMap))
+ , fFontGlyphUsage(new SkPDFGlyphSetMap)
, fRasterDpi(rasterDpi)
, fCanon(canon) {
SkASSERT(pageSize.width() > 0);
fLastMarginContentEntry = NULL;
fDrawingArea = kContent_DrawingArea;
if (fFontGlyphUsage.get() == NULL) {
- fFontGlyphUsage.reset(SkNEW(SkPDFGlyphSetMap));
+ fFontGlyphUsage.reset(new SkPDFGlyphSetMap);
}
}
}
static SkPDFDict* create_link_annotation(const SkRect& translatedRect) {
- SkAutoTUnref<SkPDFDict> annotation(SkNEW_ARGS(SkPDFDict, ("Annot")));
+ SkAutoTUnref<SkPDFDict> annotation(new SkPDFDict("Annot"));
annotation->insertName("Subtype", "Link");
- SkAutoTUnref<SkPDFArray> border(SkNEW(SkPDFArray));
+ SkAutoTUnref<SkPDFArray> border(new SkPDFArray);
border->reserve(3);
border->appendInt(0); // Horizontal corner radius.
border->appendInt(0); // Vertical corner radius.
border->appendInt(0); // Width, 0 = no border.
annotation->insertObject("Border", border.detach());
- SkAutoTUnref<SkPDFArray> rect(SkNEW(SkPDFArray));
+ SkAutoTUnref<SkPDFArray> rect(new SkPDFArray);
rect->reserve(4);
rect->appendScalar(translatedRect.fLeft);
rect->appendScalar(translatedRect.fTop);
SkString url(static_cast<const char *>(urlData->data()),
urlData->size() - 1);
- SkAutoTUnref<SkPDFDict> action(SkNEW_ARGS(SkPDFDict, ("Action")));
+ SkAutoTUnref<SkPDFDict> action(new SkPDFDict("Action"));
action->insertName("S", "URI");
action->insertString("URI", url);
annotation->insertObject("A", action.detach());
SkPDFArray* SkPDFDevice::copyMediaBox() const {
// should this be a singleton?
- SkAutoTUnref<SkPDFArray> mediaBox(SkNEW(SkPDFArray));
+ SkAutoTUnref<SkPDFArray> mediaBox(new SkPDFArray);
mediaBox->reserve(4);
mediaBox->appendInt(0);
mediaBox->appendInt(0);
for (size_t i = 0; i < count; i++) {
SkPoint translatedPoint;
transform.mapXY(points[i].x(), points[i].y(), &translatedPoint);
- fNamedDestinations.push(
- SkNEW_ARGS(NamedDestination, (nameData, translatedPoint)));
-
+ fNamedDestinations.push(new NamedDestination(nameData, translatedPoint));
}
return true;
}
void SkPDFDevice::addAnnotation(SkPDFDict* annotation) {
if (NULL == fAnnotations) {
- fAnnotations = SkNEW(SkPDFArray);
+ fAnnotations = new SkPDFArray;
}
fAnnotations->appendObject(annotation);
}
int nDest = fNamedDestinations.count();
for (int i = 0; i < nDest; i++) {
NamedDestination* dest = fNamedDestinations[i];
- SkAutoTUnref<SkPDFArray> pdfDest(SkNEW(SkPDFArray));
+ SkAutoTUnref<SkPDFArray> pdfDest(new SkPDFArray);
pdfDest->reserve(5);
pdfDest->appendObjRef(SkRef(page));
pdfDest->appendName("XYZ");
}
SkPDFFormXObject* SkPDFDevice::createFormXObjectFromDevice() {
- SkPDFFormXObject* xobject = SkNEW_ARGS(SkPDFFormXObject, (this));
+ SkPDFFormXObject* xobject = new SkPDFFormXObject(this);
// We always draw the form xobjects that we create back into the device, so
// we simply preserve the font usage instead of pulling it out and merging
// it back in later.
static SkPDFDevice* Create(SkISize pageSize,
SkScalar rasterDpi,
SkPDFCanon* canon) {
- return SkNEW_ARGS(SkPDFDevice, (pageSize, rasterDpi, canon, true));
+ return new SkPDFDevice(pageSize, rasterDpi, canon, true);
}
/** Create a PDF drawing context without fipping the y-axis. */
static SkPDFDevice* CreateUnflipped(SkISize pageSize,
SkScalar rasterDpi,
SkPDFCanon* canon) {
- return SkNEW_ARGS(SkPDFDevice, (pageSize, rasterDpi, canon, false));
+ return new SkPDFDevice(pageSize, rasterDpi, canon, false);
}
virtual ~SkPDFDevice();
SkAutoTUnref<SkData> psInvertStream(
SkData::NewWithoutCopy(psInvert, strlen(psInvert)));
- SkPDFStream* invertFunction = SkNEW_ARGS(
- SkPDFStream, (psInvertStream.get()));
+ SkPDFStream* invertFunction = new SkPDFStream(psInvertStream.get());
invertFunction->insertInt("FunctionType", 4);
invertFunction->insertObject("Domain", SkRef(domainAndRange.get()));
invertFunction->insertObject("Range", domainAndRange.detach());
SkWStream* stream,
const SkPDFObjNumMap& objNumMap,
const SkPDFSubstituteMap& substitutes) const {
- SkAutoTUnref<SkPDFDict> dict(SkNEW_ARGS(SkPDFDict, ("ExtGState")));
+ SkAutoTUnref<SkPDFDict> dict(new SkPDFDict("ExtGState"));
dict->insertName("Type", "ExtGState");
SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF;
if (0 == resourceList.count()) {
return;
}
- SkAutoTUnref<SkPDFDict> resources(SkNEW(SkPDFDict));
+ SkAutoTUnref<SkPDFDict> resources(new SkPDFDict);
for (int i = 0; i < resourceList.count(); i++) {
resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i),
SkRef(resourceList[i]));
const SkTDArray<SkPDFObject*>* patternResources,
const SkTDArray<SkPDFObject*>* xObjectResources,
const SkTDArray<SkPDFObject*>* fontResources) {
- SkAutoTUnref<SkPDFDict> dict(SkNEW(SkPDFDict));
+ SkAutoTUnref<SkPDFDict> dict(new SkPDFDict);
static const char kProcs[][7] = {
"PDF", "Text", "ImageB", "ImageC", "ImageI"};
- SkAutoTUnref<SkPDFArray> procSets(SkNEW(SkPDFArray));
+ SkAutoTUnref<SkPDFArray> procSets(new SkPDFArray);
procSets->reserve(SK_ARRAY_COUNT(kProcs));
for (size_t i = 0; i < SK_ARRAY_COUNT(kProcs); i++) {
const SkMatrix& matrix,
const SkIRect& surfaceBBox,
SkScalar rasterScale) {
- SkAutoTDelete<SkPDFShader::State> state(
- SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale)));
+ SkAutoTDelete<SkPDFShader::State> state(new State(shader, matrix, surfaceBBox, rasterScale));
return get_pdf_shader_by_state(canon, dpi, &state);
}
create_smask_graphic_state(canon, dpi, state));
SkPDFAlphaFunctionShader* alphaFunctionShader =
- SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach()));
+ new SkPDFAlphaFunctionShader(autoState->detach());
SkAutoTUnref<SkPDFDict> resourceDict(
get_gradient_resource_dict(colorShader.get(), alphaGs.get()));
namespace {
SkPDFObject* create_range_object() {
- SkPDFArray* range = SkNEW(SkPDFArray);
+ SkPDFArray* range = new SkPDFArray;
range->reserve(6);
range->appendInt(0);
range->appendInt(1);
SkPDFArray* domain) {
SkAutoDataUnref funcData(
SkData::NewWithCopy(psCode.c_str(), psCode.size()));
- SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get()));
+ SkPDFStream* result = new SkPDFStream(funcData.get());
result->insertInt("FunctionType", 4);
result->insertObject("Domain", SkRef(domain));
result->insertObject("Range", SkRef(rangeObject.get()));
make_ps_function(functionCode, domain.get()));
pdfShader->insertObjRef("Function", function.detach());
- SkPDFFunctionShader* pdfFunctionShader =
- SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach()));
+ SkPDFFunctionShader* pdfFunctionShader = new SkPDFFunctionShader(autoState->detach());
pdfFunctionShader->insertInt("PatternType", 2);
pdfFunctionShader->insertObject("Matrix",
// Put the canvas into the pattern stream (fContent).
SkAutoTDelete<SkStreamAsset> content(patternDevice->content());
- SkPDFImageShader* imageShader =
- SkNEW_ARGS(SkPDFImageShader, (autoState->detach()));
+ SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->detach());
imageShader->setData(content.get());
SkAutoTUnref<SkPDFDict> resourceDict(
SkPDFUnion& SkPDFUnion::operator=(SkPDFUnion&& other) {
if (this != &other) {
this->~SkPDFUnion();
- SkNEW_PLACEMENT_ARGS(this, SkPDFUnion, (other.move()));
+ new (this) SkPDFUnion(other.move());
}
return *this;
}
switch (fType) {
case Type::kNameSkS:
case Type::kStringSkS:
- SkNEW_PLACEMENT_ARGS(pun(u.fSkString), SkString,
- (*pun(fSkString)));
+ new (pun(u.fSkString)) SkString (*pun(fSkString));
return u.move();
case Type::kObjRef:
case Type::kObject:
SkPDFUnion SkPDFUnion::Name(const SkString& s) {
SkPDFUnion u(Type::kNameSkS);
- SkNEW_PLACEMENT_ARGS(pun(u.fSkString), SkString, (s));
+ new (pun(u.fSkString)) SkString(s);
return u.move();
}
SkPDFUnion SkPDFUnion::String(const SkString& s) {
SkPDFUnion u(Type::kStringSkS);
- SkNEW_PLACEMENT_ARGS(pun(u.fSkString), SkString, (s));
+ new (pun(u.fSkString)) SkString(s);
return u.move();
}
}
}
-void SkPDFArray::append(SkPDFUnion&& value) {
- SkNEW_PLACEMENT_ARGS(fValues.append(), SkPDFUnion, (value.move()));
-}
+void SkPDFArray::append(SkPDFUnion&& value) { new (fValues.append()) SkPDFUnion(value.move()); }
void SkPDFArray::appendInt(int32_t value) {
this->append(SkPDFUnion::Int(value));
void SkPDFDict::set(SkPDFUnion&& name, SkPDFUnion&& value) {
Record* rec = fRecords.append();
SkASSERT(name.isName());
- SkNEW_PLACEMENT_ARGS(&rec->fKey, SkPDFUnion, (name.move()));
- SkNEW_PLACEMENT_ARGS(&rec->fValue, SkPDFUnion, (value.move()));
+ new (&rec->fKey) SkPDFUnion(name.move());
+ new (&rec->fValue) SkPDFUnion(value.move());
}
int SkPDFDict::size() const { return fRecords.count(); }
class SkPDFSharedStream : public SkPDFObject {
public:
// Takes ownership of asset.
- SkPDFSharedStream(SkStreamAsset* data)
- : fAsset(data), fDict(SkNEW(SkPDFDict)) {
- SkASSERT(data);
- }
+ SkPDFSharedStream(SkStreamAsset* data) : fAsset(data), fDict(new SkPDFDict) { SkASSERT(data); }
SkPDFDict* dict() { return fDict; }
void emitObject(SkWStream*,
const SkPDFObjNumMap&,
~BitmapInfo() {
SkASSERT(0 == fToBeDrawnCount);
- SkDELETE(fBitmap);
+ delete fBitmap;
}
void addDraws(int drawsToAdd) {
SkASSERT(shouldFlattenBitmaps(fFlags));
SkBitmap* bm;
if(fBitmaps.count() == index) {
- bm = SkNEW(SkBitmap);
+ bm = new SkBitmap;
*fBitmaps.append() = bm;
} else {
bm = fBitmaps[index];
#define FLATTENABLES_TO_KEEP 10
SkGPipeCanvas::SkGPipeCanvas(SkGPipeController* controller,
- SkWriter32* writer, uint32_t flags,
- uint32_t width, uint32_t height)
+ SkWriter32* writer,
+ uint32_t flags,
+ uint32_t width,
+ uint32_t height)
: SkCanvas(width, height)
- , fFactorySet(is_cross_process(flags) ? SkNEW(SkNamedFactorySet) : NULL)
+ , fFactorySet(is_cross_process(flags) ? new SkNamedFactorySet : NULL)
, fWriter(*writer)
, fFlags(flags)
, fFlattenableHeap(FLATTENABLES_TO_KEEP, fFactorySet, is_cross_process(flags))
- , fFlatDictionary(&fFlattenableHeap)
-{
+ , fFlatDictionary(&fFlattenableHeap) {
fController = controller;
fDone = false;
fBlockSize = 0; // need first block from controller
}
if (shouldFlattenBitmaps(flags)) {
- fBitmapShuttle.reset(SkNEW_ARGS(BitmapShuttle, (this)));
- fBitmapHeap = SkNEW_ARGS(SkBitmapHeap, (fBitmapShuttle.get(), BITMAPS_TO_KEEP));
+ fBitmapShuttle.reset(new BitmapShuttle(this));
+ fBitmapHeap = new SkBitmapHeap(fBitmapShuttle.get(), BITMAPS_TO_KEEP);
} else {
- fBitmapHeap = SkNEW_ARGS(SkBitmapHeap,
- (BITMAPS_TO_KEEP, controller->numberOfReaders()));
+ fBitmapHeap = new SkBitmapHeap(BITMAPS_TO_KEEP, controller->numberOfReaders());
if (this->needOpBytes(sizeof(void*))) {
this->writeOp(kShareBitmapHeap_DrawOp);
fWriter.writePtr(static_cast<void*>(fBitmapHeap));
}
fFlattenableHeap.setBitmapStorage(fBitmapHeap);
- fImageHeap = SkNEW(SkImageHeap);
+ fImageHeap = new SkImageHeap;
if (this->needOpBytes(sizeof(void*))) {
this->writeOp(kShareImageHeap_DrawOp);
fWriter.writePtr(static_cast<void*>(fImageHeap));
uint32_t width, uint32_t height) {
if (NULL == fCanvas) {
fWriter.reset(NULL, 0);
- fCanvas = SkNEW_ARGS(SkGPipeCanvas, (controller, &fWriter, flags, width, height));
+ fCanvas = new SkGPipeCanvas(controller, &fWriter, flags, width, height);
}
controller->setCanvas(fCanvas);
return fCanvas;
SkAutoMutexAcquire ac(mutex);
static SkFontConfigInterfaceDirect* singleton = NULL;
if (singleton == NULL) {
- singleton = SkNEW(SkFontConfigInterfaceDirect);
+ singleton = new SkFontConfigInterfaceDirect;
}
return singleton;
}
}
}
- SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC,
- (trimmedMatches.begin(),
- trimmedMatches.count()));
+ SkFontStyleSet_FC* sset = new SkFontStyleSet_FC (trimmedMatches.begin(), trimmedMatches.count());
#endif
return false;
}
static FontConfigTypeface* Create(const SkFontStyle& style,
const SkFontConfigInterface::FontIdentity& fi,
const SkString& familyName) {
- return SkNEW_ARGS(FontConfigTypeface, (style, fi, familyName));
+ return new FontConfigTypeface(style, fi, familyName);
}
static FontConfigTypeface* Create(const SkFontStyle& style, bool fixedWidth,
SkStreamAsset* localStream) {
- return SkNEW_ARGS(FontConfigTypeface, (style, fixedWidth, localStream));
+ return new FontConfigTypeface(style, fixedWidth, localStream);
}
const SkFontConfigInterface::FontIdentity& getIdentity() const {
if (0 == gFTCount) {
SkASSERT(NULL == gFTLibrary);
- gFTLibrary = SkNEW(FreeTypeLibrary);
+ gFTLibrary = new FreeTypeLibrary;
}
++gFTCount;
return gFTLibrary->library();
--gFTCount;
if (0 == gFTCount) {
SkASSERT(NULL != gFTLibrary);
- SkDELETE(gFTLibrary);
+ delete gFTLibrary;
SkDEBUGCODE(gFTLibrary = NULL;)
}
}
}
// this passes ownership of stream to the rec
- rec = SkNEW_ARGS(SkFaceRec, (data->detachStream(), fontID));
+ rec = new SkFaceRec(data->detachStream(), fontID);
FT_Open_Args args;
memset(&args, 0, sizeof(args));
FT_Error err = FT_Open_Face(gFTLibrary->library(), &args, data->getIndex(), &rec->fFace);
if (err) {
SkDEBUGF(("ERROR: unable to open font '%x'\n", fontID));
- SkDELETE(rec);
+ delete rec;
return NULL;
}
SkASSERT(rec->fFace);
gFaceRecHead = next;
}
FT_Done_Face(face);
- SkDELETE(rec);
+ delete rec;
}
return;
}
SkScalerContext* SkTypeface_FreeType::onCreateScalerContext(
const SkDescriptor* desc) const {
- SkScalerContext_FreeType* c = SkNEW_ARGS(SkScalerContext_FreeType,
- (const_cast<SkTypeface_FreeType*>(this),
- desc));
+ SkScalerContext_FreeType* c =
+ new SkScalerContext_FreeType(const_cast<SkTypeface_FreeType*>(this), desc);
if (!c->success()) {
- SkDELETE(c);
+ delete c;
c = NULL;
}
return c;
bool isFixedPitch;
(void)computeStyleBits(ctFont, &isFixedPitch);
- face = SkNEW_ARGS(SkTypeface_Mac, (ctFont.detach(), NULL,
- cacheRequest.fStyle, isFixedPitch,
- skFamilyName.c_str(), false));
+ face = new SkTypeface_Mac(ctFont.detach(), NULL, cacheRequest.fStyle, isFixedPitch,
+ skFamilyName.c_str(), false);
SkTypefaceCache::Add(face, face->fontStyle());
return face;
}
AutoCFRelease<CTFontDescriptorRef> desc(
CTFontDescriptorCreateWithAttributes(cfAttr));
- return SkNEW_ARGS(SkFontStyleSet_Mac, (cfFamilyName, desc));
+ return new SkFontStyleSet_Mac(cfFamilyName, desc);
}
public:
///////////////////////////////////////////////////////////////////////////////
-SkFontMgr* SkFontMgr::Factory() {
- return SkNEW(SkFontMgr_Mac);
-}
+SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; }
}
SkScalerContext* LogFontTypeface::onCreateScalerContext(const SkDescriptor* desc) const {
- SkScalerContext_GDI* ctx = SkNEW_ARGS(SkScalerContext_GDI,
- (const_cast<LogFontTypeface*>(this), desc));
+ SkScalerContext_GDI* ctx = new SkScalerContext_GDI(const_cast<LogFontTypeface*>(this), desc);
if (!ctx->isValid()) {
- SkDELETE(ctx);
+ delete ctx;
ctx = NULL;
}
return ctx;
SkFontStyleSet* onCreateStyleSet(int index) const override {
SkASSERT((unsigned)index < (unsigned)fLogFontArray.count());
- return SkNEW_ARGS(SkFontStyleSetGDI, (fLogFontArray[index].elfLogFont.lfFaceName));
+ return new SkFontStyleSetGDI(fLogFontArray[index].elfLogFont.lfFaceName);
}
SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
}
LOGFONT lf;
logfont_for_name(familyName, &lf);
- return SkNEW_ARGS(SkFontStyleSetGDI, (lf.lfFaceName));
+ return new SkFontStyleSetGDI(lf.lfFaceName);
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
// could be in base impl
- return this->createFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
+ return this->createFromStream(new SkMemoryStream(data));
}
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
///////////////////////////////////////////////////////////////////////////////
-SkFontMgr* SkFontMgr_New_GDI() {
- return SkNEW(SkFontMgrGDI);
-}
+SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; }
// TODO: warn on defaulted axis?
}
- SkDEBUGCODE (
- // Check for axis specified, but not matched in font.
- for (int i = 0; i < fontFile.fAxes.count(); ++i) {
- SkFourByteTag skTag = fontFile.fAxes[i].fTag;
- bool found = false;
- for (int j = 0; j < axisDefinitions.count(); ++j) {
- if (skTag == axisDefinitions[j].fTag) {
- found = true;
- break;
+ SkDEBUGCODE(
+ // Check for axis specified, but not matched in font.
+ for (int i = 0; i < fontFile.fAxes.count(); ++i) {
+ SkFourByteTag skTag = fontFile.fAxes[i].fTag;
+ bool found = false;
+ for (int j = 0; j < axisDefinitions.count(); ++j) {
+ if (skTag == axisDefinitions[j].fTag) {
+ found = true;
+ break;
+ }
}
- }
- if (!found) {
- SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n",
- familyName.c_str(),
- (skTag >> 24) & 0xFF,
- (skTag >> 16) & 0xFF,
- (skTag >> 8) & 0xFF,
- (skTag ) & 0xFF));
- }
- }
- )
+ if (!found) {
+ SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n",
+ familyName.c_str(), (skTag >> 24) & 0xFF,
+ (skTag >> 16) & 0xFF, (skTag >> 8) & 0xFF, (skTag)&0xFF));
+ }
+ })
- fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem,
- (pathName, ttcIndex,
- axisValues.get(), axisDefinitions.count(),
- style, isFixedWidth, familyName,
- lang, variant)));
+ fStyles.push_back().reset(new SkTypeface_AndroidSystem(
+ pathName, ttcIndex, axisValues.get(), axisDefinitions.count(), style,
+ isFixedWidth, familyName, lang, variant));
}
}
return NULL;
}
SkFontData* data(new SkFontData(stream.detach(), ttcIndex, NULL, 0));
- return SkNEW_ARGS(SkTypeface_AndroidStream, (data, style, isFixedPitch, name));
+ return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
}
SkTypeface* onCreateFromFontData(SkFontData* data) const override {
if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixedPitch, NULL)) {
return NULL;
}
- return SkNEW_ARGS(SkTypeface_AndroidStream, (data, style, isFixedPitch, name));
+ return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
}
}
}
- SkFontStyleSet_Android* newSet =
- SkNEW_ARGS(SkFontStyleSet_Android, (family, fScanner));
+ SkFontStyleSet_Android* newSet = new SkFontStyleSet_Android(family, fScanner);
if (0 == newSet->count()) {
- SkDELETE(newSet);
+ delete newSet;
continue;
}
fFontStyleSets.push_back().reset(newSet);
for (int j = 0; j < family.fNames.count(); j++) {
NameToFamily* nextEntry = nameToFamily->append();
- SkNEW_PLACEMENT_ARGS(&nextEntry->name, SkString, (family.fNames[j]));
+ new (&nextEntry->name) SkString(family.fNames[j]);
nextEntry->styleSet = newSet;
}
}
custom->fFallbackFontsXml));
}
- return SkNEW_ARGS(SkFontMgr_Android, (custom));
+ return new SkFontMgr_Android(custom);
}
SkFontStyle style;
SkString name;
if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, NULL)) {
- return SkNEW_ARGS(SkTypeface_Stream, (style, isFixedPitch, false, name,
- stream.detach(), ttcIndex));
+ return new SkTypeface_Stream(style, isFixedPitch, false, name, stream.detach(),
+ ttcIndex);
} else {
return NULL;
}
if (families->empty()) {
SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString());
families->push_back().reset(family);
- family->appendTypeface(SkNEW(SkTypeface_Empty));
+ family->appendTypeface(new SkTypeface_Empty);
}
}
continue;
}
- SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_File, (
- style,
- isFixedPitch,
- true, // system-font (cannot delete)
- realname,
- filename.c_str(),
- faceIndex));
+ SkTypeface_Custom* tf = new SkTypeface_File(style, isFixedPitch,
+ true, // system-font (cannot delete)
+ realname, filename.c_str(), faceIndex);
SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str());
if (NULL == addTo) {
if (families->empty()) {
SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString());
families->push_back().reset(family);
- family->appendTypeface(SkNEW(SkTypeface_Empty));
+ family->appendTypeface(new SkTypeface_Empty);
}
}
return;
}
- SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_Stream, (
- style,
- isFixedPitch,
- true, // system-font (cannot delete)
- realname,
- stream.detach(),
- faceIndex));
+ SkTypeface_Custom* tf =
+ new SkTypeface_Stream(style, isFixedPitch, true, // system-font (cannot delete)
+ realname, stream.detach(), faceIndex);
SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str());
if (NULL == addTo) {
SK_DECLARE_STATIC_MUTEX(gFCMutex);
#ifdef SK_DEBUG
- void *CreateThreadFcLocked() { return SkNEW_ARGS(bool, (false)); }
- void DeleteThreadFcLocked(void* v) { SkDELETE(static_cast<bool*>(v)); }
+void* CreateThreadFcLocked() { return new bool(false); }
+void DeleteThreadFcLocked(void* v) { delete static_cast<bool*>(v); }
# define THREAD_FC_LOCKED \
static_cast<bool*>(SkTLS::Get(CreateThreadFcLocked, DeleteThreadFcLocked))
#endif
public:
/** @param pattern takes ownership of the reference. */
static SkTypeface_fontconfig* Create(FcPattern* pattern) {
- return SkNEW_ARGS(SkTypeface_fontconfig, (pattern));
+ return new SkTypeface_fontconfig(pattern);
}
mutable SkAutoFcPattern fPattern;
}
}
- return SkNEW_ARGS(StyleSet, (this, matches.detach()));
+ return new StyleSet(this, matches.detach());
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
return NULL;
}
- return SkNEW_ARGS(SkTypeface_stream, (new SkFontData(stream.detach(), ttcIndex, NULL, 0),
- style, isFixedWidth));
+ return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, NULL, 0), style,
+ isFixedWidth);
}
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
- return this->createFromStream(SkNEW_ARGS(SkMemoryStream, (data)), ttcIndex);
+ return this->createFromStream(new SkMemoryStream(data), ttcIndex);
}
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
return NULL;
}
- return SkNEW_ARGS(SkTypeface_stream, (fontData, style, isFixedWidth));
+ return new SkTypeface_stream(fontData, style, isFixedWidth);
}
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
HRNM(fFontCollection->GetFontFamily(index, &fontFamily), "Could not get requested family.");
- return SkNEW_ARGS(SkFontStyleSet_DirectWrite, (this, fontFamily.get()));
+ return new SkFontStyleSet_DirectWrite(this, fontFamily.get());
}
SkFontStyleSet* SkFontMgr_DirectWrite::onMatchFamily(const char familyName[]) const {
}
SkTypeface* SkFontMgr_DirectWrite::onCreateFromData(SkData* data, int ttcIndex) const {
- return this->createFromStream(SkNEW_ARGS(SkMemoryStream, (data)), ttcIndex);
+ return this->createFromStream(new SkMemoryStream(data), ttcIndex);
}
SkTypeface* SkFontMgr_DirectWrite::onCreateFromFile(const char path[], int ttcIndex) const {
};
}
- return SkNEW_ARGS(SkFontMgr_DirectWrite, (factory, sysFontCollection.get(),
- localeName, localeNameLen));
+ return new SkFontMgr_DirectWrite(factory, sysFontCollection.get(), localeName, localeNameLen);
}
#include "SkFontMgr_indirect.h"
if (impl.get() == NULL) {
return NULL;
}
- return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy));
+ return new SkFontMgr_Indirect(impl.get(), proxy);
}
SkImageDecoder* decoder = image_decoder_from_stream(stream);
if (NULL == decoder) {
// If no image decoder specific to the stream exists, use SkImageDecoder_CG.
- return SkNEW(SkImageDecoder_CG);
+ return new SkImageDecoder_CG;
} else {
return decoder;
}
default:
return NULL;
}
- return SkNEW_ARGS(SkImageEncoder_CG, (t));
+ return new SkImageEncoder_CG(t);
}
static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_cg_factory);
SkImageDecoder* decoder = image_decoder_from_stream(stream);
if (NULL == decoder) {
// If no image decoder specific to the stream exists, use SkImageDecoder_WIC.
- return SkNEW(SkImageDecoder_WIC);
+ return new SkImageDecoder_WIC;
} else {
return decoder;
}
default:
return NULL;
}
- return SkNEW_ARGS(SkImageEncoder_WIC, (t));
+ return new SkImageEncoder_WIC(t);
}
static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory);
bool SkImageDecoder::onBuildTileIndex(SkStreamRewindable* stream,
int* /*width*/, int* /*height*/) {
- SkDELETE(stream);
+ delete stream;
return false;
}
bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctableEntries[], int* ctableCount) override {
SkMemoryStream stream(fData->data(), fData->size(), false);
- SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocator,
- (info, pixels, rowBytes)));
+ SkAutoTUnref<BareMemoryAllocator> allocator(
+ new BareMemoryAllocator(info, pixels, rowBytes));
fDecoder->setAllocator(allocator);
fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType());
SkBitmap bm;
stream.rewind();
if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode)) {
- SkDELETE(decoder);
+ delete decoder;
return NULL;
}
- return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data));
+ return new SkImageDecoderGenerator(bm.info(), decoder, data);
}
};
static_assert(sizeof(SkOSFileIterData) <= SkOSFile::Iter::kStorageSize, "not_enough_space");
-SkOSFile::Iter::Iter() {
- SkNEW_PLACEMENT(fSelf.get(), SkOSFileIterData);
-}
+SkOSFile::Iter::Iter() { new (fSelf.get()) SkOSFileIterData; }
SkOSFile::Iter::Iter(const char path[], const char suffix[]) {
- SkNEW_PLACEMENT(fSelf.get(), SkOSFileIterData);
+ new (fSelf.get()) SkOSFileIterData;
this->reset(path, suffix);
}
return dst;
}
-SkOSFile::Iter::Iter() {
- SkNEW_PLACEMENT(fSelf.get(), SkOSFileIterData);
-}
+SkOSFile::Iter::Iter() { new (fSelf.get()) SkOSFileIterData; }
SkOSFile::Iter::Iter(const char path[], const char suffix[]) {
- SkNEW_PLACEMENT(fSelf.get(), SkOSFileIterData);
+ new (fSelf.get()) SkOSFileIterData;
this->reset(path, suffix);
}
HRNM(loader->CreateStreamFromKey(id.fKey, id.fKeySize, &fontFileStream),
"Could not create font file stream.");
- return SkNEW_ARGS(SkDWriteFontFileStream, (fontFileStream.get()));
+ return new SkDWriteFontFileStream(fontFileStream.get());
}
private:
};
}
- return SkNEW_ARGS(SkRemotableFontMgr_DirectWrite, (sysFontCollection.get(),
- localeName, localeNameLen));
+ return new SkRemotableFontMgr_DirectWrite(sysFontCollection.get(), localeName, localeNameLen);
}
&fontFileStream),
"Could not create font file stream.");
- return SkNEW_ARGS(SkDWriteFontFileStream, (fontFileStream.get()));
+ return new SkDWriteFontFileStream(fontFileStream.get());
}
SkScalerContext* DWriteFontTypeface::onCreateScalerContext(const SkDescriptor* desc) const {
- return SkNEW_ARGS(SkScalerContext_DW, (const_cast<DWriteFontTypeface*>(this), desc));
+ return new SkScalerContext_DW(const_cast<DWriteFontTypeface*>(this), desc);
}
void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {
IDWriteFontFileLoader* fontFileLoader = NULL,
IDWriteFontCollectionLoader* fontCollectionLoader = NULL) {
SkFontID fontID = SkTypefaceCache::NewFontID();
- return SkNEW_ARGS(DWriteFontTypeface, (get_style(font), fontID,
- factory, fontFace, font, fontFamily,
- fontFileLoader, fontCollectionLoader));
+ return new DWriteFontTypeface(get_style(font), fontID, factory, fontFace, font, fontFamily,
+ fontFileLoader, fontCollectionLoader);
}
protected:
SkISize size = bounds.roundOut().size();
SkAutoTUnref<SkBaseDevice> device(SkSVGDevice::Create(size, writer));
- return SkNEW_ARGS(SkCanvas, (device));
+ return new SkCanvas(device);
}
if (!res.fClip.isEmpty()) {
// The clip is in device space. Apply it via a <g> wrapper to avoid local transform
// interference.
- fClipGroup.reset(SkNEW_ARGS(AutoElement, ("g", fWriter)));
+ fClipGroup.reset(new AutoElement("g", fWriter));
fClipGroup->addAttribute("clip-path",res.fClip);
}
return NULL;
}
- return SkNEW_ARGS(SkSVGDevice, (size, writer));
+ return new SkSVGDevice(size, writer);
}
SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer)
: INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry))
, fWriter(writer)
- , fResourceBucket(SkNEW(ResourceBucket)) {
+ , fResourceBucket(new ResourceBucket) {
SkASSERT(writer);
fLegacyBitmap.setInfo(SkImageInfo::MakeUnknown(size.width(), size.height()));
fWriter->writeHeader();
// The root <svg> tag gets closed by the destructor.
- fRootElement.reset(SkNEW_ARGS(AutoElement, ("svg", fWriter)));
+ fRootElement.reset(new AutoElement("svg", fWriter));
fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg");
fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
SkAutoTDelete<SkWStream> outStream;
if (FLAGS_output.count() > 0) {
- SkFILEWStream* fileStream = SkNEW_ARGS(SkFILEWStream, (FLAGS_output[0]));
+ SkFILEWStream* fileStream = new SkFILEWStream(FLAGS_output[0]);
if (!fileStream->isValid()) {
SkDebugf("Couldn't open output file for writing: %s\n", FLAGS_output[0]);
return kIOError;
}
outStream.reset(fileStream);
} else {
- outStream.reset(SkNEW(SkDebugWStream));
+ outStream.reset(new SkDebugWStream);
}
- SkAutoTDelete<SkXMLWriter> xmlWriter(SkNEW_ARGS(SkXMLStreamWriter, (outStream.get())));
+ SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(outStream.get()));
SkAutoTUnref<SkCanvas> svgCanvas(SkSVGCanvas::Create(pic->cullRect(), xmlWriter.get()));
pic->playback(svgCanvas);
Rec* rec = fRec;
while (rec != &fInitialRec) {
Rec* next = rec->fNext;
- SkDELETE(rec);
+ delete rec;
rec = next;
}
}
void Sk3DView::save() {
- Rec* rec = SkNEW(Rec);
+ Rec* rec = new Rec;
rec->fNext = fRec;
rec->fMatrix = fRec->fMatrix;
fRec = rec;
void Sk3DView::restore() {
SkASSERT(fRec != &fInitialRec);
Rec* next = fRec->fNext;
- SkDELETE(fRec);
+ delete fRec;
fRec = next;
}
return NULL;
}
- SkAutoTDelete<SkCanvasState_v1> canvasState(SkNEW_ARGS(SkCanvasState_v1, (canvas)));
+ SkAutoTDelete<SkCanvasState_v1> canvasState(new SkCanvasState_v1(canvas));
// decompose the total matrix and clip
setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(),
SkASSERT(!bitmap.empty());
SkASSERT(!bitmap.isNull());
- SkAutoTUnref<SkCanvas> canvas(SkNEW_ARGS(SkCanvas, (bitmap)));
+ SkAutoTUnref<SkCanvas> canvas(new SkCanvas(bitmap));
// setup the matrix and clip
setup_canvas_from_MC_state(layerState.mcState, canvas.get());
return NULL;
}
- SkAutoTUnref<SkCanvasStack> canvas(SkNEW_ARGS(SkCanvasStack, (state->width, state->height)));
+ SkAutoTUnref<SkCanvasStack> canvas(new SkCanvasStack(state->width, state->height));
// setup the matrix and clip on the n-way canvas
setup_canvas_from_MC_state(state_v1->mcState, canvas);
// Upcast to the correct version of SkCanvasState. This avoids having a virtual destructor on
// SkCanvasState. That would be strange since SkCanvasState has no other virtual functions, and
// instead uses the field "version" to determine how to behave.
- SkDELETE(static_cast<SkCanvasState_v1*>(state));
+ delete static_cast<SkCanvasState_v1*>(state);
}
SkASSERT(nullptr == sk_atomic_load(&gUserTracer, sk_memory_order_acquire));
sk_atomic_store(&gUserTracer, tracer, sk_memory_order_release);
// An atomic load during process shutdown is probably overkill, but safe overkill.
- atexit([](){ SkDELETE(sk_atomic_load(&gUserTracer, sk_memory_order_acquire)); });
+ atexit([]() { delete sk_atomic_load(&gUserTracer, sk_memory_order_acquire); });
}
SkEventTracer* SkEventTracer::GetInstance() {
if (NULL == stream) {
return NULL;
}
- return SkNEW_ARGS(FrontBufferedStream, (stream, bufferSize));
+ return new FrontBufferedStream(stream, bufferSize);
}
FrontBufferedStream::FrontBufferedStream(SkStream* stream, size_t bufferSize)
};
SkImageGenerator* SkImageGeneratorUtils::NewEmpty(const SkImageInfo& info) {
- return SkNEW_ARGS(GeneratorFromEmpty, (info));
+ return new GeneratorFromEmpty(info);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
};
SkImageGenerator* SkImageGeneratorUtils::NewFromBitmap(const SkBitmap& bm) {
- return SkNEW_ARGS(GeneratorFromBitmap, (bm));
+ return new GeneratorFromBitmap(bm);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
}
const SkAlphaType at = kPremul_SkAlphaType; // take isOpaque from caller?
SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, ct, at, cpt);
- return SkNEW_ARGS(GeneratorFromTexture, (ctx, tex, info));
+ return new GeneratorFromTexture(ctx, tex, info);
}
#endif
return nullptr;
const SkColorType ct = kN32_SkColorType;
const SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
const SkImageInfo info = SkImageInfo::Make(image->width(), image->height(), ct, at);
- return SkNEW_ARGS(GeneratorFromImage, (image, info));
+ return new GeneratorFromImage(image, info);
}
return nullptr;
}
SkCanvas* SkCreateNullCanvas() {
// An N-Way canvas forwards calls to N canvas's. When N == 0 it's
// effectively a null canvas.
- return SkNEW_ARGS(SkNWayCanvas, (0,0));
+ return new SkNWayCanvas(0, 0);
}
}
SkPatchGrid::~SkPatchGrid() {
- SkDELETE_ARRAY(fCornerPts);
- SkDELETE_ARRAY(fCornerColors);
- SkDELETE_ARRAY(fTexCoords);
- SkDELETE_ARRAY(fHrzCtrlPts);
- SkDELETE_ARRAY(fVrtCtrlPts);
+ delete[] fCornerPts;
+ delete[] fCornerColors;
+ delete[] fTexCoords;
+ delete[] fHrzCtrlPts;
+ delete[] fVrtCtrlPts;
}
bool SkPatchGrid::setPatch(int x, int y, const SkPoint cubics[12], const SkColor colors[4],
}
void SkPatchGrid::reset(int rows, int cols, VertexType flags, SkXfermode* xMode) {
- SkDELETE_ARRAY(fCornerPts);
- SkDELETE_ARRAY(fCornerColors);
- SkDELETE_ARRAY(fTexCoords);
- SkDELETE_ARRAY(fHrzCtrlPts);
- SkDELETE_ARRAY(fVrtCtrlPts);
-
+ delete[] fCornerPts;
+ delete[] fCornerColors;
+ delete[] fTexCoords;
+ delete[] fHrzCtrlPts;
+ delete[] fVrtCtrlPts;
+
fCols = cols;
fRows = rows;
fModeFlags = flags;
fXferMode = xMode;
-
- fCornerPts = SkNEW_ARRAY(SkPoint, (fRows + 1) * (fCols + 1));
- fHrzCtrlPts = SkNEW_ARRAY(SkPoint, (fRows + 1) * fCols * 2);
- fVrtCtrlPts = SkNEW_ARRAY(SkPoint, fRows * 2 * (fCols + 1));
+
+ fCornerPts = new SkPoint[(fRows + 1) * (fCols + 1)];
+ fHrzCtrlPts = new SkPoint[(fRows + 1) * fCols * 2];
+ fVrtCtrlPts = new SkPoint[fRows * 2 * (fCols + 1)];
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 = SkNEW_ARRAY(SkColor, (fRows + 1) * (fCols + 1));
+ fCornerColors = new SkColor[(fRows + 1) * (fCols + 1)];
memset(fCornerColors, 0, (fRows + 1) * (fCols + 1) * sizeof(SkColor));
}
if (fModeFlags & kTexs_VertexType) {
- fTexCoords = SkNEW_ARRAY(SkPoint, (fRows + 1) * (fCols + 1));
+ fTexCoords = new SkPoint[(fRows + 1) * (fCols + 1)];
memset(fTexCoords, 0, (fRows + 1) * (fCols + 1) * sizeof(SkPoint));
}
}
void SkPatchGrid::draw(SkCanvas* canvas, SkPaint& paint) {
- int* maxCols = SkNEW_ARRAY(int, fCols);
- int* maxRows = SkNEW_ARRAY(int, fRows);
+ int* maxCols = new int[fCols];
+ int* maxRows = new int[fRows];
memset(maxCols, 0, fCols * sizeof(int));
memset(maxRows, 0, fRows * sizeof(int));
}
}
}
- SkDELETE_ARRAY(maxCols);
- SkDELETE_ARRAY(maxRows);
+ delete[] maxCols;
+ delete[] maxRows;
}
data->fVertexCount = (lodX + 1) * (lodY + 1);
}
data->fIndexCount = lodX * lodY * 6;
-
- data->fPoints = SkNEW_ARRAY(SkPoint, data->fVertexCount);
- data->fIndices = SkNEW_ARRAY(uint16_t, data->fIndexCount);
-
+
+ data->fPoints = new SkPoint[data->fVertexCount];
+ data->fIndices = new uint16_t[data->fIndexCount];
+
// if colors is not null then create array for colors
SkPMColor colorsPM[kNumCorners];
if (colors) {
for (int i = 0; i < kNumCorners; i++) {
colorsPM[i] = SkPreMultiplyColor(colors[i]);
}
- data->fColors = SkNEW_ARRAY(uint32_t, data->fVertexCount);
+ data->fColors = new uint32_t[data->fVertexCount];
}
// if texture coordinates are not null then create array for them
if (texCoords) {
- data->fTexCoords = SkNEW_ARRAY(SkPoint, data->fVertexCount);
+ data->fTexCoords = new SkPoint[data->fVertexCount];
}
SkPoint pts[kNumPtsCubic];
, fIndices(NULL) { }
~VertexData() {
- SkDELETE_ARRAY(fPoints);
- SkDELETE_ARRAY(fTexCoords);
- SkDELETE_ARRAY(fColors);
- SkDELETE_ARRAY(fIndices);
+ delete[] fPoints;
+ delete[] fTexCoords;
+ delete[] fColors;
+ delete[] fIndices;
}
};
continue;
}
- SkString* key = SkNEW_ARGS(SkString,(keyptr));
- SkString* val = SkNEW_ARGS(SkString,(valptr));
+ SkString *key = new SkString(keyptr);
+ SkString *val = new SkString(valptr);
fConfigFileKeys.append(1, &key);
fConfigFileValues.append(1, &val);
}
for (int i = 0 ; i < fConfigFileKeys.count() ; i++) {
- SkDELETE(fConfigFileKeys[i]);
- SkDELETE(fConfigFileValues[i]);
+ delete fConfigFileKeys[i];
+ delete fConfigFileValues[i];
}
}
class DebugPaintFilterCanvas : public SkPaintFilterCanvas {
public:
- DebugPaintFilterCanvas(int width, int height, bool overdrawViz, bool overrideFilterQuality,
+ DebugPaintFilterCanvas(int width,
+ int height,
+ bool overdrawViz,
+ bool overrideFilterQuality,
SkFilterQuality quality)
: INHERITED(width, height)
- , fOverdrawXfermode(overdrawViz ? SkNEW(OverdrawXfermode) : NULL)
+ , fOverdrawXfermode(overdrawViz ? new OverdrawXfermode : NULL)
, fOverrideFilterQuality(overrideFilterQuality)
- , fFilterQuality(quality) { }
+ , fFilterQuality(quality) {}
protected:
void onFilterPaint(SkPaint* paint, Type) const override {
}
const SkImageInfo info = this->imageInfo();
- fPaintFilterCanvas.reset(SkNEW_ARGS(DebugPaintFilterCanvas, (info.width(),
- info.height(),
- fOverdrawViz,
- fOverrideFilterQuality,
- fFilterQuality)));
+ fPaintFilterCanvas.reset(new DebugPaintFilterCanvas(info.width(), info.height(), fOverdrawViz,
+ fOverrideFilterQuality, fFilterQuality));
}
void SkDebugCanvas::setOverdrawViz(bool overdrawViz) {
if (boundStr) {
mPath->append(*boundStr);
- SkDELETE(boundStr);
+ delete boundStr;
}
return mPath;
SkStream* stream = (SkStream*)info;
SkASSERT(stream->getMemoryBase() == addr);
SkASSERT(stream->getLength() == size);
- SkDELETE(stream);
+ delete stream;
}
// These are used by CGDataProviderSequentialCallbacks
// Used when info is an SkStream.
static void release_info_proc(void* info) {
SkASSERT(info);
- SkDELETE((SkStream*)info);
+ delete (SkStream*)info;
}
CGDataProviderRef SkCreateDataProviderFromStream(SkStream* stream) {
}
SkDWriteFontFileStream* SkDWriteFontFileStream::duplicate() const {
- return SkNEW_ARGS(SkDWriteFontFileStream, (fFontFileStream.get()));
+ return new SkDWriteFontFileStream(fFontFileStream.get());
}
size_t SkDWriteFontFileStream::getPosition() const {
if (dc) {
HGLRC glrc = create_gl_context(dc, extensions, contextType);
if (glrc) {
- return SkNEW_ARGS(SkWGLPbufferContext, (pbuf, dc, glrc));
+ return new SkWGLPbufferContext(pbuf, dc, glrc);
}
extensions.releasePbufferDC(pbuf, dc);
}
count = prev->countListners();
}
- SkListenersTagList* next = SkNEW_ARGS(SkListenersTagList, (count + 1));
+ SkListenersTagList* next = new SkListenersTagList(count + 1);
if (prev)
{
const SkEventSinkID* iter = list->fIDs;
const SkEventSinkID* stop = iter + list->countListners();
while (iter < stop) {
- SkEvent* copy = SkNEW_ARGS(SkEvent, (evt));
+ SkEvent* copy = new SkEvent(evt);
copy->setTargetID(*iter++)->postDelay(delay);
}
}
SkXMLParser* SkDOM::beginParsing() {
SkASSERT(!fParser);
- fParser.reset(SkNEW_ARGS(SkDOMParser, (&fAlloc)));
+ fParser.reset(new SkDOMParser(&fAlloc));
return fParser.get();
}
desc.fSampleCnt = 0;
SkAutoTUnref<GrTexture> texture(grContext->createTexture(desc, false, NULL, 0));
- SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture.get())));
+ SkAutoTUnref<SkGpuDevice> device(new SkGpuDevice (grContext, texture.get()));
SkCanvas canvas(device.get());
blur_path(&canvas, path, gaussianSigma);
SkDiscardableMemory* dm = pool->create(size);
// the pool "can" return null, but it shouldn't in these controlled conditions
SK_ALWAYSBREAK(dm);
- return SkNEW_ARGS(SkCachedData, (size, dm));
+ return new SkCachedData(size, dm);
} else {
- return SkNEW_ARGS(SkCachedData, (sk_malloc_throw(size), size));
+ return new SkCachedData(sk_malloc_throw(size), size);
}
}
PixelRefType pixelRefType,
SkDiscardableMemory::Factory* factory) {
SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType));
- SkAutoTDelete<SkImageGenerator> gen(SkNEW_ARGS(TestImageGenerator,
- (type, reporter)));
+ SkAutoTDelete<SkImageGenerator> gen(new TestImageGenerator(type, reporter));
REPORTER_ASSERT(reporter, gen.get() != NULL);
SkBitmap lazy;
bool success;
};
for (size_t i = 0; i < SK_ARRAY_COUNT(testTypes); ++i) {
TestImageGenerator::TestType test = testTypes[i];
- SkImageGenerator* gen = SkNEW_ARGS(TestImageGenerator, (test, r));
+ SkImageGenerator* gen = new TestImageGenerator(test, r);
SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen));
if (NULL == image.get()) {
ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed ["
}
addr = (const SkPMColor*)((const char*)addr + rowBytes);
}
- SkDELETE(canvas);
+ delete canvas;
// now try a deliberately bad info
info = info.makeWH(-1, info.height());
info = SkImageInfo::MakeN32Premul(0, 0);
canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
REPORTER_ASSERT(reporter, canvas);
- SkDELETE(canvas);
+ delete canvas;
}
DEF_TEST(Canvas, reporter) {
check_alphabet_buffer(reporter, readers[i]);
check_alphabet_stream(reporter, streams[i]);
readers[i]->unref();
- SkDELETE(streams[i]);
+ delete streams[i];
}
}
SkAutoTUnref<SkDiscardableMemoryPool> pool(
SkDiscardableMemoryPool::Create(10 * 1000, NULL));
SkBitmap bm;
- bool success = SkInstallDiscardablePixelRef(SkNEW(FailureImageGenerator), NULL, &bm, pool);
+ bool success = SkInstallDiscardablePixelRef(new FailureImageGenerator, NULL, &bm, pool);
REPORTER_ASSERT(reporter, success);
// now our bitmap has a pixelref, but we know it will fail to lock
SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
SkCanvas* canvas = surface->getCanvas();
-
- SkAutoTUnref<TestFilter> df(SkNEW(TestFilter));
+ SkAutoTUnref<TestFilter> df(new TestFilter);
REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter());
// NOTE: For this and other tests in this file, we cheat and continue to refer to the
// wrapped stream, but that's okay because we know the wrapping stream has not been
// deleted yet (and we only call const methods in it).
- SkMemoryStream* memStream = SkNEW_ARGS(SkMemoryStream, (gAbcs, strlen(gAbcs), false));
+ SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
test_hasLength(reporter, *bufferedStream.get(), *memStream);
}
static void test_perfectly_sized_buffer(skiatest::Reporter* reporter, size_t bufferSize) {
- SkMemoryStream* memStream = SkNEW_ARGS(SkMemoryStream, (gAbcs, strlen(gAbcs), false));
+ SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
test_hasLength(reporter, *bufferedStream.get(), *memStream);
}
static void test_skipping(skiatest::Reporter* reporter, size_t bufferSize) {
- SkMemoryStream* memStream = SkNEW_ARGS(SkMemoryStream, (gAbcs, strlen(gAbcs), false));
+ SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
test_hasLength(reporter, *bufferedStream.get(), *memStream);
// does not invalidate the buffer.
static void test_read_beyond_buffer(skiatest::Reporter* reporter, size_t bufferSize) {
// Use a stream that behaves like Android's stream.
- AndroidLikeMemoryStream* memStream = SkNEW_ARGS(AndroidLikeMemoryStream, ((void*)gAbcs, bufferSize, false));
+ AndroidLikeMemoryStream* memStream =
+ new AndroidLikeMemoryStream((void*)gAbcs, bufferSize, false);
// Create a buffer that matches the length of the stream.
SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
static void test_length_combos(skiatest::Reporter* reporter, size_t bufferSize) {
for (int hasLen = 0; hasLen <= 1; hasLen++) {
for (int hasPos = 0; hasPos <= 1; hasPos++) {
- LengthOptionalStream* stream = SkNEW_ARGS(LengthOptionalStream, (SkToBool(hasLen), SkToBool(hasPos)));
+ LengthOptionalStream* stream =
+ new LengthOptionalStream(SkToBool(hasLen), SkToBool(hasPos));
SkAutoTDelete<SkStream> buffered(SkFrontBufferedStream::Create(stream, bufferSize));
test_hasLength(reporter, *buffered.get(), *stream);
}
// Test using a stream with an initial offset.
static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize) {
- SkMemoryStream* memStream = SkNEW_ARGS(SkMemoryStream, (gAbcs, strlen(gAbcs), false));
+ SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
// Skip a few characters into the memStream, so that bufferedStream represents an offset into
// the stream it wraps.
};
DEF_TEST(ShortFrontBufferedStream, reporter) {
- FailingStream* failingStream = SkNEW(FailingStream);
+ FailingStream* failingStream = new FailingStream;
SkAutoTDelete<SkStreamRewindable> stream(SkFrontBufferedStream::Create(failingStream, 64));
SkBitmap bm;
// The return value of DecodeStream is not important. We are just using DecodeStream because
const char* name() const override { return "Big Ole Key"; }
GrGLFragmentProcessor* onCreateGLInstance() const override {
- return SkNEW_ARGS(GLBigKeyProcessor, (*this));
+ return new GLBigKeyProcessor(*this);
}
private:
REPORTER_ASSERT(reporter, !cache.find(key, TestingRec::Visitor, &value));
REPORTER_ASSERT(reporter, -1 == value);
- cache.add(SkNEW_ARGS(TestingRec, (key, i)));
+ cache.add(new TestingRec(key, i));
REPORTER_ASSERT(reporter, cache.find(key, TestingRec::Visitor, &value));
REPORTER_ASSERT(reporter, i == value);
// stress test, should trigger purges
for (int i = 0; i < COUNT * 100; ++i) {
TestingKey key(i);
- cache.add(SkNEW_ARGS(TestingRec, (key, i)));
+ cache.add(new TestingRec(key, i));
}
}
static void test_cache_purge_shared_id(skiatest::Reporter* reporter, SkResourceCache& cache) {
for (int i = 0; i < COUNT; ++i) {
- TestingKey key(i, i & 1); // every other key will have a 1 for its sharedID
- cache.add(SkNEW_ARGS(TestingRec, (key, i)));
+ TestingKey key(i, i & 1); // every other key will have a 1 for its sharedID
+ cache.add(new TestingRec(key, i));
}
// Ensure that everyone is present
TestingKey key(1);
- cache.add(SkNEW_ARGS(TestingRec, (key, 2)));
- cache.add(SkNEW_ARGS(TestingRec, (key, 3)));
+ cache.add(new TestingRec(key, 2));
+ cache.add(new TestingRec(key, 3));
// Lookup can return either value.
intptr_t value = -1;
pixels[pixelCount] = sentinal; // This value should not be changed.
SkAutoTUnref<SingleAllocator> allocator(
- SkNEW_ARGS(SingleAllocator,
- ((void*)pixels.get(), sizeof(uint16_t) * pixelCount)));
+ new SingleAllocator((void*)pixels.get(), sizeof(uint16_t) * pixelCount));
decoder->setAllocator(allocator);
decoder->setSampleSize(2);
SkBitmap bitmap;
skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr();
SkMatrix matrix;
buffer.readMatrix(&matrix);
- return SkNEW_ARGS(MatrixTestImageFilter, (reporter, matrix));
+ return new MatrixTestImageFilter(reporter, matrix);
}
#ifndef SK_IGNORE_TO_STRING
const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0);
const SkPMColor blue = SkPackARGB32(0xFF, 0, 0, 0xFF);
SkPMColor colors[] = { red, green, blue, 0 };
- SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colors, SK_ARRAY_COUNT(colors))));
+ SkAutoTUnref<SkColorTable> ctable(new SkColorTable(colors, SK_ARRAY_COUNT(colors)));
// The colortable made a copy, so we can trash the original colors
memset(colors, 0xFF, sizeof(colors));
DEF_TEST(Jpeg_YUV, reporter) {
size_t len = sizeof(goodJpegImage);
- SkMemoryStream* stream = SkNEW_ARGS(SkMemoryStream, (goodJpegImage, len));
+ SkMemoryStream* stream = new SkMemoryStream(goodJpegImage, len);
SkBitmap bitmap;
SkDecodingImageGenerator::Options opts;
SkAutoDataUnref encodedData(SkImageEncoder::EncodeData(bm8888, SkImageEncoder::kKTX_Type, 0));
REPORTER_ASSERT(reporter, encodedData);
- SkAutoTDelete<SkMemoryStream> stream(SkNEW_ARGS(SkMemoryStream, (encodedData)));
+ SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encodedData));
REPORTER_ASSERT(reporter, stream);
SkBitmap decodedBitmap;
0xFF, 0xFF, 0xFF, 0x80, // Pixel 3
0xFF, 0xFF, 0xFF, 0x80};// Pixel 4
- SkAutoTDelete<SkMemoryStream> stream(
- SkNEW_ARGS(SkMemoryStream, (kHalfWhiteKTX, sizeof(kHalfWhiteKTX))));
+ SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(kHalfWhiteKTX, sizeof(kHalfWhiteKTX)));
REPORTER_ASSERT(reporter, stream);
SkBitmap decodedBitmap;
int DummyRasterizer::gCount;
-SkFlattenable* DummyRasterizer::CreateProc(SkReadBuffer&) {
- return SkNEW(DummyRasterizer);
-}
+SkFlattenable* DummyRasterizer::CreateProc(SkReadBuffer&) { return new DummyRasterizer; }
// Check to make sure that the SkPaint in the layer has its destructor called.
DEF_TEST(LayerRasterizer_destructor, reporter) {
{
SkPaint paint;
- paint.setRasterizer(SkNEW(DummyRasterizer))->unref();
+ paint.setRasterizer(new DummyRasterizer)->unref();
REPORTER_ASSERT(reporter, DummyRasterizer::GetCount() == 1);
SkLayerRasterizer::Builder builder;
struct CreateIntFromFloat {
CreateIntFromFloat(float val) : fVal(val) {}
- int* operator()() const { return SkNEW_ARGS(int, ((int)fVal)); }
+ int* operator()() const { return new int((int)fVal); }
float fVal;
};
} // namespace
DEF_TEST(LazyPtr, r) {
- // Basic usage: calls SkNEW(int).
+ // Basic usage: calls new int.
SkLazyPtr<int> lazy;
int* ptr = lazy.get();
REPORTER_ASSERT(r, ptr);
REPORTER_ASSERT(r, ptr);
REPORTER_ASSERT(r, 99 == *ptr);
// Since custom_destroy didn't actually delete ptr, we do now.
- SkDELETE(ptr);
+ delete ptr;
}
DEF_TEST(LazyPtr_Threaded, r) {
SkBitmap make_invalid_bitmap(const SkImageInfo& imageInfo) {
SkBitmap bitmap;
bitmap.setInfo(imageInfo);
- bitmap.setPixelRef(SkNEW_ARGS(InvalidPixelRef, (imageInfo)))->unref();
+ bitmap.setPixelRef(new InvalidPixelRef(imageInfo))->unref();
return bitmap;
}
SkFlattenable* DummyImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
bool visited = buffer.readBool();
- return SkNEW_ARGS(DummyImageFilter, (visited));
+ return new DummyImageFilter(visited);
}
#ifndef SK_IGNORE_TO_STRING
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
for (int d = 0; d < 2; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testOpCirclesMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testOpCirclesMain, a, b, c, d, &testRunner);
}
}
if (!reporter->allowExtendedTest()) goto finish;
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
for (int d = c + 1; d < 7; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testOpCubicsMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() =
+ new PathOpsThreadedRunnable(&testOpCubicsMain, a, b, c, d, &testRunner);
}
}
if (!reporter->allowExtendedTest()) goto finish;
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
for (int d = c + 1; d < 7; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testOpLoopsMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() =
+ new PathOpsThreadedRunnable(&testOpLoopsMain, a, b, c, d, &testRunner);
}
}
if (!reporter->allowExtendedTest()) goto finish;
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
for (int d = c + 1; d < 7; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testPathOpsRectsMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testPathOpsRectsMain, a, b, c, d, &testRunner);
}
}
if (!reporter->allowExtendedTest()) goto finish;
for (int a = 0; a < 16; ++a) {
for (int b = 0 ; b < 16; ++b) {
for (int c = 0 ; c < 16; ++c) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testQuadLineIntersectMain, a, b, c, 0, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testQuadLineIntersectMain, a, b, c, 0, &testRunner);
}
if (!reporter->allowExtendedTest()) goto finish;
}
int cx = c & 0x03;
int cy = c >> 2;
bool abcIsATriangle = (bx - ax) * (cy - ay) != (by - ay) * (cx - ax);
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testSimplifyDegeneratesMain, a, b, c, abcIsATriangle,
- &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testSimplifyDegeneratesMain, a, b, c, abcIsATriangle, &testRunner);
}
if (!reporter->allowExtendedTest()) goto finish;
}
for (int b = a ; b < 16; ++b) {
for (int c = b ; c < 16; ++c) {
for (int d = c; d < 16; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testSimplifyQuadsMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testSimplifyQuadsMain, a, b, c, d, &testRunner);
}
if (!reporter->allowExtendedTest()) goto finish;
}
for (int b = a ; b < 16; ++b) {
for (int c = b ; c < 16; ++c) {
for (int d = c; d < 16; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testSimplifyQuadralateralsMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testSimplifyQuadralateralsMain, a, b, c, d, &testRunner);
}
if (!reporter->allowExtendedTest()) goto finish;
}
for (int b = a ; b < 8; ++b) {
for (int c = b ; c < 8; ++c) {
for (int d = c; d < 8; ++d) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testSimplify4x4RectsMain, a, b, c, d, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testSimplify4x4RectsMain, a, b, c, d, &testRunner);
}
if (!reporter->allowExtendedTest()) goto finish;
}
if ((bx - ax) * (cy - ay) == (by - ay) * (cx - ax)) {
continue;
}
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testSimplifyTrianglesMain, a, b, c, 0, &testRunner));
+ *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
+ &testSimplifyTrianglesMain, a, b, c, 0, &testRunner);
}
if (!reporter->allowExtendedTest()) goto finish;
}
TestRunner::~TestRunner() {
for (int index = 0; index < fRunnables.count(); index++) {
- SkDELETE(fRunnables[index]);
+ delete fRunnables[index];
}
}
if (!filename.endsWith(".skp")) {
filename.append(".skp");
}
- *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableEncode,
- (&testSkpClipEncode, result.fDirNo, filename.c_str(), &testRunner));
+ *testRunner.fRunnables.append() = new TestRunnableEncode(&testSkpClipEncode, result.fDirNo,
+ filename.c_str(), &testRunner);
}
testRunner.render();
}
typedef SkTRegistry<Test*(*)(void*)> TestRegistry;
-#define DEF_TEST(name) \
- static void test_##name(); \
- class name##Class : public Test { \
- public: \
- static Test* Factory(void*) { return SkNEW(name##Class); } \
- protected: \
- void onGetName(SkString* name) override { \
- name->set(#name); \
- } \
- void onRun() override { test_##name(); } \
- }; \
- static TestRegistry gReg_##name##Class(name##Class::Factory); \
+#define DEF_TEST(name) \
+ static void test_##name(); \
+ class name##Class : public Test { \
+ public: \
+ static Test* Factory(void*) { return new name##Class; } \
+ \
+ protected: \
+ void onGetName(SkString* name) override { name->set(#name); } \
+ void onRun() override { test_##name(); } \
+ }; \
+ static TestRegistry gReg_##name##Class(name##Class::Factory); \
static void test_##name()
DEF_TEST(PathOpsSkpClip) {
int dirNo;
gDirs.reset();
while ((dirNo = gDirs.next()) > 0) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableDir,
- (&testSkpClipMain, dirNo, &testRunner));
+ *testRunner.fRunnables.append() = new TestRunnableDir(&testSkpClipMain, dirNo, &testRunner);
}
testRunner.render();
TestState state;
int count = sorted.get()[dirNo - firstDirNo].count();
if (SkTSearch<SortByName, Less>(sorted.get()[dirNo - firstDirNo].begin(),
count, &name, sizeof(&name)) < 0) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(TestRunnableFile,
- (&testSkpClip, dirNo, filename.c_str(), &testRunner));
+ *testRunner.fRunnables.append() = new TestRunnableFile(
+ &testSkpClip, dirNo, filename.c_str(), &testRunner);
}
}
checkEarlyExit:
PathOpsThreadedTestRunner::~PathOpsThreadedTestRunner() {
for (int index = 0; index < fRunnables.count(); index++) {
- SkDELETE(fRunnables[index]);
+ delete fRunnables[index];
}
}
int outerCount = reporter->allowExtendedTest() ? 100 : 1;
for (int index = 0; index < outerCount; ++index) {
for (int idx2 = 0; idx2 < 10; ++idx2) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testTightBoundsLines, 0, 0, 0, 0, &testRunner));
+ *testRunner.fRunnables.append() =
+ new PathOpsThreadedRunnable(&testTightBoundsLines, 0, 0, 0, 0, &testRunner);
}
}
testRunner.render();
int outerCount = reporter->allowExtendedTest() ? 100 : 1;
for (int index = 0; index < outerCount; ++index) {
for (int idx2 = 0; idx2 < 10; ++idx2) {
- *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
- (&testTightBoundsQuads, 0, 0, 0, 0, &testRunner));
+ *testRunner.fRunnables.append() =
+ new PathOpsThreadedRunnable(&testTightBoundsQuads, 0, 0, 0, 0, &testRunner);
}
}
testRunner.render();
static void TestPathRef(skiatest::Reporter* reporter) {
static const int kRepeatCnt = 10;
- SkAutoTUnref<SkPathRef> pathRef(SkNEW(SkPathRef));
+ SkAutoTUnref<SkPathRef> pathRef(new SkPathRef);
SkPathRef::Editor ed(&pathRef);
// Check that listener is notified on moveTo().
- SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed));
REPORTER_ASSERT(reporter, !changed);
p.moveTo(10, 0);
REPORTER_ASSERT(reporter, changed);
// Check that listener is notified on lineTo().
- SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed));
REPORTER_ASSERT(reporter, !changed);
p.lineTo(20, 0);
REPORTER_ASSERT(reporter, changed);
// Check that listener is notified on reset().
- SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed));
REPORTER_ASSERT(reporter, !changed);
p.reset();
REPORTER_ASSERT(reporter, changed);
p.moveTo(0, 0);
// Check that listener is notified on rewind().
- SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed));
REPORTER_ASSERT(reporter, !changed);
p.rewind();
REPORTER_ASSERT(reporter, changed);
{
SkPath q;
q.moveTo(10, 10);
- SkPathPriv::AddGenIDChangeListener(q, SkNEW(ChangeListener(&changed)));
+ SkPathPriv::AddGenIDChangeListener(q, new ChangeListener(&changed));
REPORTER_ASSERT(reporter, !changed);
}
// q went out of scope.
// Register a listener.
int count = 0;
- pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
+ pixelRef->addGenIDChangeListener(new TestListener(&count));
REPORTER_ASSERT(r, 0 == count);
// No one has looked at our pixelRef's generation ID, so invalidating it doesn't make sense.
// Force the generation ID to be recalculated, then add a listener.
REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
- pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
+ pixelRef->addGenIDChangeListener(new TestListener(&count));
pixelRef->notifyPixelsChanged();
REPORTER_ASSERT(r, 1 == count);
public:
SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const override {
- return SkNEW_PLACEMENT(storage, TestDrawLooperContext);
+ return new (storage) TestDrawLooperContext;
}
size_t contextSize() const override { return sizeof(TestDrawLooperContext); }
};
};
-SkFlattenable* TestLooper::CreateProc(SkReadBuffer&) { return SkNEW(TestLooper); }
+SkFlattenable* TestLooper::CreateProc(SkReadBuffer&) { return new TestLooper; }
static void test_drawBitmap(skiatest::Reporter* reporter) {
SkBitmap src;
}
};
-#define APPEND(record, type, ...) SkNEW_PLACEMENT_ARGS(record.append<type>(), type, (__VA_ARGS__))
+#define APPEND(record, type, ...) new (record.append<type>()) type(__VA_ARGS__)
// Basic tests for the low-level SkRecord code.
DEF_TEST(Record, r) {
}
static TestResource* CreateScratch(GrGpu* gpu, SimulatedProperty property, bool cached = true) {
- return SkNEW_ARGS(TestResource, (gpu, property, cached, kScratchConstructor));
+ return new TestResource(gpu, property, cached, kScratchConstructor);
}
~TestResource() {
GrResourceCache* cache = mock.cache();
// Create a bunch of resources with no keys
- TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
- TestResource* b = SkNEW_ARGS(TestResource, (context->getGpu()));
- TestResource* c = SkNEW_ARGS(TestResource, (context->getGpu()));
- TestResource* d = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* a = new TestResource(context->getGpu());
+ TestResource* b = new TestResource(context->getGpu());
+ TestResource* c = new TestResource(context->getGpu());
+ TestResource* d = new TestResource(context->getGpu());
a->setSize(11);
b->setSize(12);
c->setSize(13);
TestResource* scratch =
TestResource::CreateScratch(context->getGpu(), TestResource::kB_SimulatedProperty);
scratch->setSize(10);
- TestResource* unique = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* unique = new TestResource(context->getGpu());
unique->setSize(11);
unique->resourcePriv().setUniqueKey(uniqueKey);
- TestResource* wrapped = SkNEW_ARGS(TestResource,
- (context->getGpu(), GrGpuResource::kBorrowed_LifeCycle));
+ TestResource* wrapped = new TestResource(context->getGpu(), GrGpuResource::kBorrowed_LifeCycle);
wrapped->setSize(12);
- TestResource* unbudgeted = SkNEW_ARGS(TestResource,
- (context->getGpu(), GrGpuResource::kUncached_LifeCycle));
+ TestResource* unbudgeted =
+ new TestResource(context->getGpu(), GrGpuResource::kUncached_LifeCycle);
unbudgeted->setSize(13);
// Make sure we can't add a unique key to the wrapped resource
unbudgeted->gpuMemorySize() == cache->getResourceBytes());
// Now try freeing the budgeted resources first
- wrapped = SkNEW_ARGS(TestResource, (context->getGpu(), GrGpuResource::kBorrowed_LifeCycle));
+ wrapped = new TestResource(context->getGpu(), GrGpuResource::kBorrowed_LifeCycle);
scratch->setSize(12);
unique->unref();
cache->purgeAllUnlocked();
REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 10 == cache->getBudgetedResourceBytes());
- unique = SkNEW_ARGS(TestResource, (context->getGpu()));
+ unique = new TestResource(context->getGpu());
unique->setSize(11);
unique->resourcePriv().setUniqueKey(uniqueKey);
unique->unref();
REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
size_t large = 2 * cache->getResourceBytes();
- unbudgeted = SkNEW_ARGS(TestResource,
- (context->getGpu(), large, GrGpuResource::kUncached_LifeCycle));
+ unbudgeted = new TestResource(context->getGpu(), large, GrGpuResource::kUncached_LifeCycle);
REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
REPORTER_ASSERT(reporter, 21 + large == cache->getResourceBytes());
REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
- wrapped = SkNEW_ARGS(TestResource,
- (context->getGpu(), large, GrGpuResource::kBorrowed_LifeCycle));
+ wrapped = new TestResource(context->getGpu(), large, GrGpuResource::kBorrowed_LifeCycle);
REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
REPORTER_ASSERT(reporter, 21 + large == cache->getResourceBytes());
REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
make_unique_key<0>(&key, 0);
// Create two resources that we will attempt to register with the same unique key.
- TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* a = new TestResource(context->getGpu());
a->setSize(11);
// Set key on resource a.
REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
// Create resource b and set the same key. It should replace a's unique key cache entry.
- TestResource* b = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* b = new TestResource(context->getGpu());
b->setSize(12);
b->resourcePriv().setUniqueKey(key);
REPORTER_ASSERT(reporter, b == cache->findAndRefUniqueResource(key));
// Now replace b with c, but make sure c can start with one unique key and change it to b's key.
// Also make b be unreffed when replacement occurs.
b->unref();
- TestResource* c = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* c = new TestResource(context->getGpu());
GrUniqueKey differentKey;
make_unique_key<0>(&differentKey, 1);
c->setSize(13);
{
GrUniqueKey key2;
make_unique_key<0>(&key2, 0);
- SkAutoTUnref<TestResource> d(SkNEW_ARGS(TestResource, (context->getGpu())));
+ SkAutoTUnref<TestResource> d(new TestResource(context->getGpu()));
int foo = 4132;
SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
key2.setCustomData(data.get());
make_unique_key<0>(&key3, 3);
// Add three resources to the cache. Only c is usable as scratch.
- TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
- TestResource* b = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* a = new TestResource(context->getGpu());
+ TestResource* b = new TestResource(context->getGpu());
TestResource* c = TestResource::CreateScratch(context->getGpu(),
TestResource::kA_SimulatedProperty);
a->resourcePriv().setUniqueKey(key1);
make_unique_key<0>(&key1, 1);
make_unique_key<0>(&key2, 2);
-
- TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
- TestResource* b = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* a = new TestResource(context->getGpu());
+ TestResource* b = new TestResource(context->getGpu());
a->resourcePriv().setUniqueKey(key1);
b->resourcePriv().setUniqueKey(key2);
GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* a = new TestResource(context->getGpu());
a->resourcePriv().setUniqueKey(key1);
a->unref();
- TestResource* b = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* b = new TestResource(context->getGpu());
b->resourcePriv().setUniqueKey(key2);
b->unref();
GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* a = new TestResource(context->getGpu());
a->setSize(100);
a->resourcePriv().setUniqueKey(key1);
a->unref();
- TestResource* b = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* b = new TestResource(context->getGpu());
b->setSize(100);
b->resourcePriv().setUniqueKey(key2);
b->unref();
GrUniqueKey key;
make_unique_key<0>(&key, j);
- TestResource* r = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* r = new TestResource(context->getGpu());
r->resourcePriv().setUniqueKey(key);
if (random.nextU() % kLockedFreq) {
// Make this is purgeable.
{
// Insert a resource and send a flush notification kFlushCount times.
for (int i = 0; i < kFlushCount; ++i) {
- TestResource* r = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* r = new TestResource(context->getGpu());
GrUniqueKey k;
make_unique_key<1>(&k, i);
r->resourcePriv().setUniqueKey(k);
{
GrGpuResource* refedResources[kFlushCount >> 1];
for (int i = 0; i < kFlushCount; ++i) {
- TestResource* r = SkNEW_ARGS(TestResource, (context->getGpu()));
+ TestResource* r = new TestResource(context->getGpu());
GrUniqueKey k;
make_unique_key<1>(&k, i);
r->resourcePriv().setUniqueKey(k);
TestResource* resource;
- resource = SkNEW_ARGS(TestResource, (context->getGpu()));
+ resource = new TestResource(context->getGpu());
resource->resourcePriv().setUniqueKey(key1);
resource->setSize(1);
resource->unref();
- resource = SkNEW_ARGS(TestResource, (context->getGpu()));
+ resource = new TestResource(context->getGpu());
resource->resourcePriv().setUniqueKey(key2);
resource->setSize(1);
resource->unref();
SkAutoTDelete<SkResourceCache> cache;
if (factory) {
- cache.reset(SkNEW_ARGS(SkResourceCache, (factory)));
+ cache.reset(new SkResourceCache(factory));
} else {
const size_t byteLimit = 100 * 1024;
- cache.reset(SkNEW_ARGS(SkResourceCache, (byteLimit)));
+ cache.reset(new SkResourceCache(byteLimit));
}
SkBitmap cachedBitmap;
make_bitmap(&cachedBitmap, SkImageInfo::MakeN32Premul(5, 5), allocator);
SkAutoTDelete<SkResourceCache> cache;
if (factory) {
- cache.reset(SkNEW_ARGS(SkResourceCache, (factory)));
+ cache.reset(new SkResourceCache(factory));
} else {
const size_t byteLimit = 100 * 1024;
- cache.reset(SkNEW_ARGS(SkResourceCache, (byteLimit)));
+ cache.reset(new SkResourceCache(byteLimit));
}
SkBitmap cachedBitmap;
make_bitmap(&cachedBitmap, SkImageInfo::MakeN32Premul(5, 5), allocator);
SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() {
for (int index = 0; index < fRunnables.count(); index++) {
- SkDELETE(fRunnables[index]);
+ delete fRunnables[index];
}
}
}
}
finish:
- SkDELETE(pic);
+ delete pic;
}
static SkString makeStatusString(int dirNo) {
goto skipOver;
}
}
- *testRunner.fRunnables.append() = SkNEW_ARGS(SkpSkGrThreadedRunnable,
- (&testSkGrMain, dirIndex, filename.c_str(), &testRunner));
+ *testRunner.fRunnables.append() = new SkpSkGrThreadedRunnable(
+ &testSkGrMain, dirIndex, filename.c_str(), &testRunner);
skipOver:
;
}
REPORTER_ASSERT(reporter, NULL == SkImage::NewRasterCopy(info, NULL, 0));
REPORTER_ASSERT(reporter, NULL == SkImage::NewRasterData(info, NULL, 0));
REPORTER_ASSERT(reporter, NULL == SkImage::NewFromRaster(info, NULL, 0, NULL, NULL));
- REPORTER_ASSERT(reporter, NULL == SkImage::NewFromGenerator(SkNEW(EmptyGenerator)));
+ REPORTER_ASSERT(reporter, NULL == SkImage::NewFromGenerator(new EmptyGenerator));
}
static void test_empty_surface(skiatest::Reporter* reporter, GrContext* ctx) {
const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset;
// Create fake image data where every byte has a value of 0
- SkAutoTDeleteArray<uint8_t> storage(SkNEW_ARRAY(uint8_t, totalBytes));
+ SkAutoTDeleteArray<uint8_t> storage(new uint8_t[totalBytes]);
memset(storage.get(), 0, totalBytes);
// Adjust the pointer in order to test on different memory alignments
uint8_t* imageData = storage.get() + offset;
namespace {
SkTArray<int>* make() {
typedef SkTArray<int> IntArray;
- return SkNEW(IntArray);
+ return new IntArray;
}
template <int N> SkTArray<int>* make_s() {
typedef SkSTArray<N, int> IntArray;
- return SkNEW(IntArray);
+ return new IntArray;
}
}
for (int i = 0; i < kSizes[dataSizeB]; ++i) {
REPORTER_ASSERT(reporter, curr++ == (*a)[i]);
}
- SkDELETE(b);
+ delete b;
a->swap(a);
curr = kSizes[dataSizeA];
for (int i = 0; i < kSizes[dataSizeB]; ++i) {
REPORTER_ASSERT(reporter, curr++ == (*a)[i]);
}
- SkDELETE(a);
+ delete a;
}
}
}
if (normal) {
paint.setTypeface(orig);
} else {
- SkAutoTUnref<SkTypeface> typeface(SkNEW_ARGS(SkRandomTypeface, (orig, paint, true)));
+ SkAutoTUnref<SkTypeface> typeface(new SkRandomTypeface(orig, paint, true));
paint.setTypeface(typeface);
}
}
fStatus->endTest(fTest.name, !reporter.fError, elapsed,
reporter.fTestCount);
- SkDELETE(this);
+ delete this;
}
private:
} else if (test.needsGpu) {
gpuTests.push_back(&test);
} else {
- cpuTests.add(SkNEW_ARGS(SkTestRunnable, (test, &status)));
+ cpuTests.add(new SkTestRunnable(test, &status));
}
}
// Run GPU tests on this thread.
for (int i = 0; i < gpuTests.count(); i++) {
- SkNEW_ARGS(SkTestRunnable, (*gpuTests[i], &status, grContextFactoryPtr))
- ->run();
+ (new SkTestRunnable(*gpuTests[i], &status, grContextFactoryPtr))->run();
}
// Block until threaded tests finish.
Timer* PictureBenchmark::setupTimer(bool useGLTimer) {
#if SK_SUPPORT_GPU
if (useGLTimer && fRenderer != NULL && fRenderer->isUsingGpuDevice()) {
- return SkNEW_ARGS(Timer, (fRenderer->getGLContext()));
+ return new Timer(fRenderer->getGLContext());
}
#endif
- return SkNEW_ARGS(Timer, (NULL));
+ return new Timer(NULL);
}
PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* renderer) {
case kBitmap_DeviceType: {
SkBitmap bitmap;
sk_tools::setup_bitmap(&bitmap, width, height);
- canvas.reset(SkNEW_ARGS(SkCanvas, (bitmap)));
+ canvas.reset(new SkCanvas(bitmap));
}
break;
#if SK_SUPPORT_GPU
if (!device) {
return NULL;
}
- canvas.reset(SkNEW_ARGS(SkCanvas, (device)));
+ canvas.reset(new SkCanvas(device));
break;
}
#endif
canvas->setAllowSoftClip(false);
}
- canvas.reset(SkNEW_ARGS(FlagsFilterCanvas, (canvas.get(), fDrawFilters)));
+ canvas.reset(new FlagsFilterCanvas(canvas.get(), fDrawFilters));
}
this->scaleToScaleFactor(canvas);
writer.endRecording();
fCanvas->flush();
if (out) {
- *out = SkNEW(SkBitmap);
+ *out = new SkBitmap;
setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
SkScalarCeilToInt(fPicture->cullRect().height()));
fCanvas->readPixels(*out, 0, 0);
}
fCanvas->flush();
if (out) {
- *out = SkNEW(SkBitmap);
+ *out = new SkBitmap;
setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
SkScalarCeilToInt(fPicture->cullRect().height()));
fCanvas->readPixels(*out, 0, 0);
SkBitmap bitmap;
if (out) {
- *out = SkNEW(SkBitmap);
+ *out = new SkBitmap;
setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
SkScalarCeilToInt(fPicture->cullRect().height()));
setup_bitmap(&bitmap, fTileWidth, fTileHeight);
void PlaybackCreationRenderer::setup() {
SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
- fRecorder.reset(SkNEW(SkPictureRecorder));
+ fRecorder.reset(new SkPictureRecorder);
SkCanvas* canvas = fRecorder->beginRecording(SkIntToScalar(this->getViewWidth()),
SkIntToScalar(this->getViewHeight()),
factory.get(),
case kNone_BBoxHierarchyType:
return NULL;
case kRTree_BBoxHierarchyType:
- return SkNEW(SkRTreeFactory);
+ return new SkRTreeFactory;
}
SkASSERT(0); // invalid bbhType
return NULL;
if (FLAGS_mode.count() >= 1) {
mode = FLAGS_mode[0];
if (0 == strcmp(mode, "record")) {
- renderer.reset(SkNEW_ARGS(sk_tools::RecordPictureRenderer, RENDERER_ARGS));
+ renderer.reset(new sk_tools::RecordPictureRenderer RENDERER_ARGS);
} else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile")
|| 0 == strcmp(mode, "copyTile")) {
useTiles = true;
heightString = FLAGS_mode[2];
} else if (0 == strcmp(mode, "playbackCreation") && kBench_PictureTool == tool) {
- renderer.reset(SkNEW_ARGS(sk_tools::PlaybackCreationRenderer, RENDERER_ARGS));
+ renderer.reset(new sk_tools::PlaybackCreationRenderer RENDERER_ARGS);
// undocumented
} else if (0 == strcmp(mode, "rerecord") && kRender_PictureTool == tool) {
- renderer.reset(SkNEW_ARGS(sk_tools::RecordPictureRenderer, RENDERER_ARGS));
+ renderer.reset(new sk_tools::RecordPictureRenderer RENDERER_ARGS);
} else if (0 == strcmp(mode, "simple")) {
// Allow 'mode' to be set to 'simple', but do not create a renderer, so we can
// ensure that pipe does not override a mode besides simple. The renderer will
x = y = 4;
}
#if SK_SUPPORT_GPU
- tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (grContextOpts, x, y)));
+ tiledRenderer.reset(new sk_tools::CopyTilesRenderer(grContextOpts, x, y));
#else
- tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y)));
+ tiledRenderer.reset(new sk_tools::CopyTilesRenderer(x, y));
#endif
} else {
- tiledRenderer.reset(SkNEW_ARGS(sk_tools::TiledPictureRenderer, RENDERER_ARGS));
+ tiledRenderer.reset(new sk_tools::TiledPictureRenderer RENDERER_ARGS);
}
if (isPowerOf2Mode) {
error.printf("Pipe is incompatible with other modes.\n");
return NULL;
}
- renderer.reset(SkNEW_ARGS(sk_tools::PipePictureRenderer, RENDERER_ARGS));
+ renderer.reset(new sk_tools::PipePictureRenderer RENDERER_ARGS);
}
}
if (NULL == renderer) {
- renderer.reset(SkNEW_ARGS(sk_tools::SimplePictureRenderer, RENDERER_ARGS));
+ renderer.reset(new sk_tools::SimplePictureRenderer RENDERER_ARGS);
}
if (FLAGS_viewport.count() > 0) {
, fLoops(1)
, fState(kPreWarmLoops_State)
, fBenchmark(NULL)
- , fResults(SkNEW(ResultsWriter)) {
+ , fResults(new ResultsWriter) {
SkCommandLineFlags::Parse(argc, argv);
this->setTitle();
this->setupBackend();
- fBenchmarkStream.reset(SkNEW(VisualBenchmarkStream));
+ fBenchmarkStream.reset(new VisualBenchmarkStream);
// Print header
SkDebugf("curr/maxrss\tloops\tflushes\tmin\tmedian\tmean\tmax\tstddev\tbench\n");
// setup json logging if required
if (!FLAGS_outResultsFile.isEmpty()) {
- fResults.reset(SkNEW(NanoJSONResultsWriter(FLAGS_outResultsFile[0])));
+ fResults.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0]));
}
if (1 == FLAGS_properties.count() % 2) {
if (gm->runAsBench()) {
fSourceType = "gm";
fBenchType = "micro";
- return SkNEW_ARGS(GMBench, (gm.detach()));
+ return new GMBench(gm.detach());
}
}
SkString name = SkOSPath::Basename(path.c_str());
fSourceType = "skp";
fBenchType = "playback";
- return SkNEW_ARGS(VisualSKPBench, (name.c_str(), pic.get()));
+ return new VisualSKPBench(name.c_str(), pic.get());
}
return NULL;
SkAutoTDelete<PictureJSONResultsWriter> jsonWriter;
if (FLAGS_jsonLog.count() == 1) {
SkASSERT(FLAGS_builderName.count() == 1 && FLAGS_gitHash.count() == 1);
- jsonWriter.reset(SkNEW(PictureJSONResultsWriter(
- FLAGS_jsonLog[0],
- FLAGS_builderName[0],
- FLAGS_buildNumber,
- FLAGS_timestamp,
- FLAGS_gitHash[0],
- FLAGS_gitNumber)));
+ jsonWriter.reset(new PictureJSONResultsWriter(FLAGS_jsonLog[0], FLAGS_builderName[0],
+ FLAGS_buildNumber, FLAGS_timestamp,
+ FLAGS_gitHash[0], FLAGS_gitNumber));
gWriter.add(jsonWriter.get());
}
bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName,
SkCommandLineFlags::StringArray* pStrings,
const char* defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType, helpString));
+ SkFlagInfo* info = new SkFlagInfo(name, shortName, kString_FlagType, helpString);
info->fDefaultString.set(defaultValue);
info->fStrings = pStrings;
gHead = NULL;
while (flag != NULL) {
SkFlagInfo* next = flag->next();
- SkDELETE(flag);
+ delete flag;
flag = next;
}
if (helpPrinted) {
*/
static bool CreateBoolFlag(const char* name, const char* shortName, bool* pBool,
bool defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kBool_FlagType, helpString));
+ SkFlagInfo* info = new SkFlagInfo(name, shortName, kBool_FlagType, helpString);
info->fBoolValue = pBool;
*info->fBoolValue = info->fDefaultBool = defaultValue;
return true;
*/
static bool CreateIntFlag(const char* name, int32_t* pInt,
int32_t defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, NULL, kInt_FlagType, helpString));
+ SkFlagInfo* info = new SkFlagInfo(name, NULL, kInt_FlagType, helpString);
info->fIntValue = pInt;
*info->fIntValue = info->fDefaultInt = defaultValue;
return true;
*/
static bool CreateDoubleFlag(const char* name, double* pDouble,
double defaultValue, const char* helpString) {
- SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, NULL, kDouble_FlagType, helpString));
+ SkFlagInfo* info = new SkFlagInfo(name, NULL, kDouble_FlagType, helpString);
info->fDoubleValue = pDouble;
*info->fDoubleValue = info->fDefaultDouble = defaultValue;
return true;
static SkWStream* open_stream(const SkString& outputDir,
const SkString& inputFilename) {
if (outputDir.isEmpty()) {
- return SkNEW(NullWStream);
+ return new NullWStream;
}
SkString outputPath;
return NULL;
}
- SkAutoTDelete<SkFILEWStream> stream(
- SkNEW_ARGS(SkFILEWStream, (outputPath.c_str())));
+ SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(outputPath.c_str()));
if (!stream.get() || !stream->isValid()) {
SkDebugf("Could not write to file %s\n", outputPath.c_str());
return NULL;
if (!success || ((FLAGS_validate || FLAGS_writeWholeImage) && bitmap == NULL)) {
SkDebugf("Failed to draw the picture.\n");
- SkDELETE(bitmap);
+ delete bitmap;
return false;
}
arbbh.set(referenceRenderer, sk_tools::PictureRenderer::kNone_BBoxHierarchyType);
} else {
#if SK_SUPPORT_GPU
- referenceRenderer = SkNEW_ARGS(sk_tools::SimplePictureRenderer,
- (renderer.getGrContextOptions()));
+ referenceRenderer = new sk_tools::SimplePictureRenderer(renderer.getGrContextOptions());
#else
- referenceRenderer = SkNEW(sk_tools::SimplePictureRenderer);
+ referenceRenderer = new sk_tools::SimplePictureRenderer;
#endif
}
SkAutoTUnref<sk_tools::PictureRenderer> aurReferenceRenderer(referenceRenderer);
if (!success || NULL == referenceBitmap || NULL == referenceBitmap->getPixels()) {
SkDebugf("Failed to draw the reference picture.\n");
- SkDELETE(bitmap);
- SkDELETE(referenceBitmap);
+ delete bitmap;
+ delete referenceBitmap;
return false;
}
if (success && (bitmap->width() != referenceBitmap->width())) {
SkDebugf("Expected image width: %i, actual image width %i.\n",
referenceBitmap->width(), bitmap->width());
- SkDELETE(bitmap);
- SkDELETE(referenceBitmap);
+ delete bitmap;
+ delete referenceBitmap;
return false;
}
if (success && (bitmap->height() != referenceBitmap->height())) {
SkDebugf("Expected image height: %i, actual image height %i",
referenceBitmap->height(), bitmap->height());
- SkDELETE(bitmap);
- SkDELETE(referenceBitmap);
+ delete bitmap;
+ delete referenceBitmap;
return false;
}
x, y, FLAGS_maxComponentDiff,
*referenceBitmap->getAddr32(x, y),
*bitmap->getAddr32(x, y));
- SkDELETE(bitmap);
- SkDELETE(referenceBitmap);
+ delete bitmap;
+ delete referenceBitmap;
return false;
}
}
}
- SkDELETE(referenceBitmap);
+ delete referenceBitmap;
for (int i = 1; i <= 255; ++i) {
if(diffs[i] > 0) {
success &= sk_tools::write_bitmap_to_disk(*bitmap, *writePath, NULL, outputFilename);
}
}
- SkDELETE(bitmap);
+ delete bitmap;
return success;
}
if (fontData->fFontCache) {
font = SkSafeRef(fontData->fFontCache);
} else {
- font = SkNEW_ARGS(SkTestFont, (*fontData));
+ font = new SkTestFont(*fontData);
SkDEBUGCODE(font->fDebugName = sub->fName);
SkDEBUGCODE(font->fDebugStyle = sub->fStyle);
fontData->fFontCache = SkSafeRef(font);
}
}
- return SkNEW_ARGS(SkTestTypeface, (font, SkFontStyle(style)));
+ return new SkTestTypeface(font, SkFontStyle(style));
}
}
SkDiffContext::~SkDiffContext() {
if (fDiffers) {
- SkDELETE_ARRAY(fDiffers);
+ delete[] fDiffers;
}
}
void SkDiffContext::setDiffers(const SkTDArray<SkImageDiffer*>& differs) {
// Delete whatever the last array of differs was
if (fDiffers) {
- SkDELETE_ARRAY(fDiffers);
+ delete[] fDiffers;
fDiffers = NULL;
fDifferCount = 0;
}
// Copy over the new differs
fDifferCount = differs.count();
- fDiffers = SkNEW_ARRAY(SkImageDiffer*, fDifferCount);
+ fDiffers = new SkImageDiffer* [fDifferCount];
differs.copy(fDiffers);
}
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include <cmath>
#include <math.h>
height(h) {
SkASSERT(w > 0);
SkASSERT(h > 0);
- image = SkNEW_ARRAY(T, w * h);
+ image = new T[w * h];
}
- ~Image2D() {
- SkDELETE_ARRAY(image);
- }
+ ~Image2D() { delete[] image; }
void readPixel(int x, int y, T* pixel) const {
SkASSERT(x >= 0);
ImageArray(int w, int h, int s)
: slices(s) {
SkASSERT(s > 0);
- image = SkNEW_ARRAY(Image2D<T>*, s);
+ image = new Image2D<T>* [s];
for (int sliceIndex = 0; sliceIndex < slices; sliceIndex++) {
- image[sliceIndex] = SkNEW_ARGS(Image2D<T>, (w, h));
+ image[sliceIndex] = new Image2D<T>(w, h);
}
}
~ImageArray() {
for (int sliceIndex = 0; sliceIndex < slices; sliceIndex++) {
- SkDELETE(image[sliceIndex]);
+ delete image[sliceIndex];
}
- SkDELETE_ARRAY(image);
+ delete[] image;
}
Image2D<T>* getLayer(int z) const {
ImageL3D baselineL(width, height, maxLevels);
ImageL3D testL(width, height, maxLevels);
ImageL scratchImageL(width, height);
- float* cyclesPerDegree = SkNEW_ARRAY(float, maxLevels);
- float* thresholdFactorFrequency = SkNEW_ARRAY(float, maxLevels - 2);
- float* contrast = SkNEW_ARRAY(float, maxLevels - 2);
+ float* cyclesPerDegree = new float[maxLevels];
+ float* thresholdFactorFrequency = new float[maxLevels - 2];
+ float* contrast = new float[maxLevels - 2];
lab_to_l(baselineLAB, baselineL.getLayer(0));
lab_to_l(testLAB, testL.getLayer(0));
// Contrast sensitivity is based on image dimensions. Therefore it cannot be statically
// generated.
- float* contrastSensitivityTable = SkNEW_ARRAY(float, maxLevels * 1000);
+ float* contrastSensitivityTable = new float[maxLevels * 1000];
for (int levelIndex = 0; levelIndex < maxLevels; levelIndex++) {
for (int csLum = 0; csLum < 1000; csLum++) {
contrastSensitivityTable[levelIndex * 1000 + csLum] =
}
}
- SkDELETE_ARRAY(cyclesPerDegree);
- SkDELETE_ARRAY(contrast);
- SkDELETE_ARRAY(thresholdFactorFrequency);
- SkDELETE_ARRAY(contrastSensitivityTable);
+ delete[] cyclesPerDegree;
+ delete[] contrast;
+ delete[] thresholdFactorFrequency;
+ delete[] contrastSensitivityTable;
return 1.0 - (double)(*poiCount) / (width * height);
}