}
void onDraw(int loops, SkCanvas* canvas) override {
- SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
+ sk_sp<GrContext> context(GrContext::CreateMockContext());
if (nullptr == context) {
return;
}
for (int k = 0; k < CACHE_SIZE_COUNT; ++k) {
GrUniqueKey key;
BenchResource::ComputeKey(k, fKeyData32Count, &key);
- SkAutoTUnref<GrGpuResource> resource(cache->findAndRefUniqueResource(key));
+ sk_sp<GrGpuResource> resource(cache->findAndRefUniqueResource(key));
SkASSERT(resource);
}
}
}
private:
- SkAutoTUnref<GrContext> fContext;
+ sk_sp<GrContext> fContext;
SkString fFullName;
int fKeyData32Count;
typedef Benchmark INHERITED;
void drawPicture() override;
private:
- SkAutoTUnref<Animation> fAnimation;
- WallTimer fAnimationTimer;
- SkString fUniqueName;
- SkIRect fDevBounds;
+ sk_sp<Animation> fAnimation;
+ WallTimer fAnimationTimer;
+ SkString fUniqueName;
+ SkIRect fDevBounds;
typedef SKPBench INHERITED;
};
SkMatrix trans;
trans.setTranslate(-fTileRects[j].fLeft/fScale,
-fTileRects[j].fTop/fScale);
- mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans);
+ mpd.add(fSurfaces[j]->getCanvas(), fPic.get(), &trans);
}
mpd.draw();
for (int j = 0; j < fTileRects.count(); ++j) {
const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale,
-fTileRects[j].fTop / fScale);
- fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, nullptr);
+ fSurfaces[j]->getCanvas()->drawPicture(fPic.get(), &trans, nullptr);
}
for (int j = 0; j < fTileRects.count(); ++j) {
context->freeGpuResources();
context->resetContext();
context->getGpu()->resetShaderCacheForTesting();
- draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame");
+ draw_pic_for_stats(canvas, context, fPic.get(), keys, values, "first_frame");
// draw second frame
- draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame");
+ draw_pic_for_stats(canvas, context, fPic.get(), keys, values, "second_frame");
#endif
}
virtual void drawMPDPicture();
virtual void drawPicture();
- const SkPicture* picture() const { return fPic; }
+ const SkPicture* picture() const { return fPic.get(); }
const SkTDArray<SkSurface*>& surfaces() const { return fSurfaces; }
const SkTDArray<SkIRect>& tileRects() const { return fTileRects; }
private:
- SkAutoTUnref<const SkPicture> fPic;
+ sk_sp<const SkPicture> fPic;
const SkIRect fClip;
const SkScalar fScale;
SkString fName;
fCurrentAnimSKP++;
SkString name = SkOSPath::Basename(path.c_str());
- SkAutoTUnref<SKPAnimationBench::Animation> animation(
+ sk_sp<SKPAnimationBench::Animation> animation(
SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriodMs));
- return new SKPAnimationBench(name.c_str(), pic.get(), fClip, animation,
+ return new SKPAnimationBench(name.c_str(), pic.get(), fClip, animation.get(),
FLAGS_loopSKP);
}
}
SkFILEWStream file(filename.c_str());
sk_sp<SkPicture> copy(fDebugger.copyPicture());
- SkAutoTUnref<SkPixelSerializer> serializer(
+ sk_sp<SkPixelSerializer> serializer(
SkImageEncoder::CreatePixelSerializer());
copy->serialize(&file, serializer);
}
private:
void createRenderTarget();
- SkAutoTUnref<const GrGLInterface> fCurIntf;
- SkAutoTUnref<GrContext> fCurContext;
+ sk_sp<const GrGLInterface> fCurIntf;
+ sk_sp<GrContext> fCurContext;
sk_sp<SkSurface> fGpuSurface;
SkCanvas* fCanvas;
static void draw_to_canvas(SkCanvas* canvas, const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor* colorPtr, int colorCount, CodecSrc::DstColorType dstColorType,
SkScalar left = 0, SkScalar top = 0) {
- SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colorPtr, colorCount));
+ sk_sp<SkColorTable> colorTable(new SkColorTable(colorPtr, colorCount));
SkBitmap bitmap;
bitmap.installPixels(info, pixels, rowBytes, colorTable.get(), nullptr, nullptr);
premultiply_if_necessary(bitmap);
Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
#if defined(SK_XML)
std::unique_ptr<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
- SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
+ sk_sp<SkCanvas> canvas(SkSVGCanvas::Create(
SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size().height())),
xmlWriter.get()));
return src.draw(canvas);
Error draw(SkCanvas* canvas) const override {
// Pass through HWUI's upper layers to get operational transforms
std::unique_ptr<android::Canvas> ac(android::Canvas::create_canvas(canvas));
- SkAutoTUnref<android::uirenderer::SkiaCanvasProxy> scProxy
+ sk_sp<android::uirenderer::SkiaCanvasProxy> scProxy
(new android::uirenderer::SkiaCanvasProxy(ac.get()));
// Pass through another proxy to get paint transforms
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// setup GrContext
- SkAutoTUnref<const GrGLInterface> interface(GrGLCreateNativeInterface());
+ sk_sp<const GrGLInterface> interface(GrGLCreateNativeInterface());
// To use NVPR, comment this out
interface.reset(GrGLInterfaceRemoveNVPR(interface));
SkASSERT(interface);
// setup contexts
- SkAutoTUnref<GrContext> grContext(GrContext::Create(kOpenGL_GrBackend,
- (GrBackendContext)interface.get()));
+ sk_sp<GrContext> grContext(GrContext::Create(kOpenGL_GrBackend,
+ (GrBackendContext)interface.get()));
SkASSERT(grContext);
// Wrap the frame buffer object attached to the screen in a Skia render target so Skia can
init_skia(kWidth, kHeight);
- SkAutoTUnref<SkImage> atlas;
+ sk_sp<SkImage> atlas;
SkRSXform xform[kGrid*kGrid+1];
SkRect tex[kGrid*kGrid+1];
WallTimer timer;
if (fType == kImprovedNoise_Type) {
GrTextureParams textureParams(SkShader::TileMode::kRepeat_TileMode,
GrTextureParams::FilterMode::kNone_FilterMode);
- SkAutoTUnref<GrTexture> permutationsTexture(
+ sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getImprovedPermutationsBitmap(),
textureParams, args.fGammaTreatment));
- SkAutoTUnref<GrTexture> gradientTexture(
+ sk_sp<GrTexture> gradientTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getGradientBitmap(),
textureParams, args.fGammaTreatment));
return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
- permutationsTexture, gradientTexture, m);
+ permutationsTexture.get(),
+ gradientTexture.get(), m);
}
if (0 == fNumOctaves) {
GrConstColorProcessor::kIgnore_InputMode);
}
- SkAutoTUnref<GrTexture> permutationsTexture(
+ sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
- SkAutoTUnref<GrTexture> noiseTexture(
+ sk_sp<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
fNumOctaves,
fStitchTiles,
paintingData,
- permutationsTexture, noiseTexture,
+ permutationsTexture.get(), noiseTexture.get(),
m));
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
SkSurface* SkV8ExampleWindow::createSurface() {
if (FLAGS_gpu) {
// Increase the ref count since callers of createSurface put the
- // results in a SkAutoTUnref.
+ // results in a sk_sp.
fCurSurface->ref();
return fCurSurface;
} else {
decodeInfo = decodeInfo.makeWH(size.width(), size.height());
// Construct a color table for the decode if necessary
- SkAutoTUnref<SkColorTable> colorTable(nullptr);
+ sk_sp<SkColorTable> colorTable(nullptr);
SkPMColor* colorPtr = nullptr;
int* colorCountPtr = nullptr;
int maxColors = 256;
(JNIEnv* env, jclass clazz, jobject inputStream, jbyteArray buffer) {
JavaInputStream stream(env, buffer, inputStream);
#if 0
- SkAutoTUnref<SkPicture> p(SkPicture::CreateFromStream(&stream));
+ sk_sp<SkPicture> p(SkPicture::CreateFromStream(&stream));
if (!p) { return 0; }
SkPictureRecorder recorder;
SkRect bounds = p->cullRect();
namespace {
struct GaneshPictureRendererImpl {
- SkAutoTUnref<GrContext> fGrContext;
+ sk_sp<GrContext> fGrContext;
void render(int w, int h, const SkPicture* p, const SkMatrix& m) {
if (!fGrContext) {
// Cache the rendering context between frames.
fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24);
SkASSERT(nullptr == fCurIntf);
- SkAutoTUnref<const GrGLInterface> glInterface;
+ sk_sp<const GrGLInterface> glInterface;
switch (win->getDeviceType()) {
case kRaster_DeviceType: // fallthrough
case kGPU_DeviceType:
}
void onDrawContent(SkCanvas* canvas) override {
- canvas->drawDrawable(fDrawable);
+ canvas->drawDrawable(fDrawable.get());
this->inval(NULL);
}
#endif
private:
- SkAutoTUnref<DrawLitAtlasDrawable> fDrawable;
+ sk_sp<DrawLitAtlasDrawable> fDrawable;
typedef SampleView INHERITED;
};
};
SkRect fModeRect[N_Modes];
- SkAutoTUnref<CircDrawable> fDrs[N];
+ sk_sp<CircDrawable> fDrs[N];
CircDrawable* fSelected;
void addButtons() {
SkScalar x = 10;
SkScalar y = 10;
for (int i = 0; i < N_Modes; ++i) {
- SkAutoTUnref<SkView> v(new PushButtonWig(gModes[i].fName, (int)gModes[i].fMode));
+ sk_sp<SkView> v(new PushButtonWig(gModes[i].fName, (int)gModes[i].fMode));
v->setSize(70, 25);
v->setLoc(x, y);
v->setVisibleP(true);
v->setEnabledP(true);
v->addListenerID(this->getSinkID());
- this->attachChildToFront(v);
+ this->attachChildToFront(v.get());
fModeRect[i] = SkRect::MakeXYWH(x, y + 28, 70, 2);
x += 80;
}
fSelected = nullptr;
for (int i = N - 1; i >= 0; --i) {
if (fDrs[i]->hitTest(x, y)) {
- fSelected = fDrs[i];
+ fSelected = fDrs[i].get();
break;
}
}