}
} while(SkCommandLineFlags::ShouldSkip(FLAGS_sourceType, fSourceType) ||
SkCommandLineFlags::ShouldSkip(FLAGS_benchType, fBenchType));
- return bench.detach();
+ return bench.release();
}
Benchmark* rawNext() {
if (gm->runAsBench()) {
fSourceType = "gm";
fBenchType = "micro";
- return new GMBench(gm.detach());
+ return new GMBench(gm.release());
}
}
FLAGS_src.contains(tag) &&
!SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
TaggedSrc& s = gSrcs.push_back();
- s.reset(src.detach());
+ s.reset(src.release());
s.tag = tag;
s.options = options;
}
}
TaggedSink& ts = gSinks.push_back();
- ts.reset(sink.detach());
+ ts.reset(sink.release());
ts.tag = config.getTag();
}
// We have disabled these tests in DM.cpp.
SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType());
- SkAutoTDelete<SkImage> image(SkImage::NewFromGenerator(gen.detach(), nullptr));
+ SkAutoTDelete<SkImage> image(SkImage::NewFromGenerator(gen.release(), nullptr));
if (!image) {
return "Could not create image from codec image generator.";
}
SkSafeUnref(fRenderTarget);
fRenderTarget = NULL;
- INHERITED::detach();
+ INHERITED::release();
}
void HelloWorldWindow::setTitle() {
bool result = attach(kNativeGL_BackEndType, 0 /*msaa*/, &fAttachmentInfo);
if (false == result) {
SkDebugf("Not possible to create backend.\n");
- detach();
+ release();
return false;
}
SkSafeUnref(fCurContext);
SkSafeUnref(fCurIntf);
SkDebugf("Failed to setup 3D");
- win->detach();
+ win->release();
}
#endif // SK_SUPPORT_GPU
// call windowSizeChanged to create the render target
SkSafeUnref(fCurRenderTarget);
fCurRenderTarget = NULL;
#endif
- win->detach();
+ win->release();
fBackend = SampleWindow::kNone_BackEndType;
}
SkBitmap bm;
SkAutoTDelete<SkStream> in(open_for_reading(argc > 1 ? argv[1] : NULL));
SkAutoTDelete<SkWStream> out(open_for_writing(argc > 2 ? argv[2] : NULL));
- if (SkPDFDocumentToBitmap(in.detach(), &bm) && to_png(out, bm)) {
+ if (SkPDFDocumentToBitmap(in.release(), &bm) && to_png(out, bm)) {
return 0;
} else {
return 1;
public:
explicit SkAutoTUnref(T* obj = nullptr) : std::unique_ptr<T, SkTUnref<T>>(obj) {}
- T* detach() { return this->release(); }
operator T*() const { return this->get(); }
// Android's std::unique_ptr's operator bool() is sometimes not explicit...
internal reference to null. Note the caller is reponsible for calling
sk_free on the returned address.
*/
- void* detach() { return this->set(NULL); }
+ void* release() { return this->set(NULL); }
/** Free the current buffer, and set the internal reference to NULL. Same
- as calling sk_free(detach())
+ as calling sk_free(release())
*/
void free() {
sk_free(fPtr);
/**
* Manage an allocated block of heap memory. This object is the sole manager of
* the lifetime of the block, so the caller must not call sk_free() or delete
- * on the block, unless detach() was called.
+ * on the block, unless release() was called.
*/
class SkAutoMalloc : SkNoncopyable {
public:
internal reference to null. Note the caller is reponsible for calling
sk_free on the returned address.
*/
- void* detach() {
+ void* release() {
void* ptr = fPtr;
fPtr = NULL;
fSize = 0;
/** Return a ptr to the array of data, to be freed with sk_free. This also
resets the SkTDArray to be empty.
*/
- T* detach() {
+ T* release() {
T* array = fArray;
fArray = NULL;
fReserve = fCount = 0;
Call a function when this goes out of scope. The template uses two
parameters, the object, and a function that is to be called in the destructor.
- If detach() is called, the object reference is set to null. If the object
+ If release() is called, the object reference is set to null. If the object
reference is null when the destructor is called, we do not call the
function.
*/
SkAutoTCallVProc(T* obj): std::unique_ptr<T, SkFunctionWrapper<void, T, P>>(obj) {}
operator T*() const { return this->get(); }
- T* detach() { return this->release(); }
};
/** \class SkAutoTCallIProc
Call a function when this goes out of scope. The template uses two
parameters, the object, and a function that is to be called in the destructor.
-If detach() is called, the object reference is set to null. If the object
+If release() is called, the object reference is set to null. If the object
reference is null when the destructor is called, we do not call the
function.
*/
SkAutoTCallIProc(T* obj): std::unique_ptr<T, SkFunctionWrapper<int, T, P>>(obj) {}
operator T*() const { return this->get(); }
- T* detach() { return this->release(); }
};
/** \class SkAutoTDelete
operator T*() const { return this->get(); }
void free() { this->reset(nullptr); }
- T* detach() { return this->release(); }
// See SkAutoTUnref for why we do this.
explicit operator bool() const { return this->get() != nullptr; }
SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {}
void free() { this->reset(nullptr); }
- T* detach() { return this->release(); }
};
/** Allocate an array of T elements, and free the array in the destructor
* pointer to NULL. Note that this differs from get(), which also returns
* the pointer, but it does not transfer ownership.
*/
- T* detach() {
+ T* release() {
T* ptr = fPtr;
fPtr = NULL;
return ptr;
};
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo* info);
- void detach();
+ void release();
void present();
bool makeFullscreen() { return true; }
void closeWindow();
#endif // SK_COMMAND_BUFFER
};
- void detach();
+ void release();
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void present();
#endif // SK_COMMAND_BUFFER
};
- void detach();
+ void release();
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void present();
bool makeFullscreen();
};
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
- void detach();
+ void release();
void present();
int getMSAASampleCount() const { return fMSAASampleCount; }
};
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
- void detach();
+ void release();
void present();
bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
kNativeGL_BackEndType,
};
- void detach();
+ void release();
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void present();
return true;
}
-void SkOSWindow::detach() {
+void SkOSWindow::release() {
}
void SkOSWindow::present() {
}
SkOSWindow::~SkOSWindow() {
- this->detach();
+ this->release();
}
bool SkOSWindow::attach(SkBackEndTypes attachType,
}
}
-void SkOSWindow::detach() {
+void SkOSWindow::release() {
if (fWindow.fDisplay != EGL_NO_DISPLAY) {
eglMakeCurrent(fWindow.fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (fWindow.fContext != EGL_NO_CONTEXT) {
fCurIntf = nullptr;
SkDebugf("Failed to setup 3D");
- win->detach();
+ win->release();
}
#endif // SK_SUPPORT_GPU
// call windowSizeChanged to create the render target
SkSafeUnref(fCurRenderTarget);
fCurRenderTarget = nullptr;
#endif
- win->detach();
+ win->release();
fBackend = kNone_BackEndType;
}
switch (bbox) {
case kNo_BBoxType:
// no bbox playback necessary
- return pic.detach();
+ return pic.release();
case kRTree_BBoxType:
factory.reset(new SkRTreeFactory);
break;
SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {
case kCanvas_Strategy: {
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.release()));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create decoder.\n");
return nullptr;
SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrder() ||
SkCodec::kNone_SkScanlineOrder == codec->getScanlineOrder());
- return new SkBitmapRegionCanvas(codec.detach());
+ return new SkBitmapRegionCanvas(codec.release());
}
case kAndroidCodec_Strategy: {
SkAutoTDelete<SkAndroidCodec> codec =
- SkAndroidCodec::NewFromStream(streamDeleter.detach());
+ SkAndroidCodec::NewFromStream(streamDeleter.release());
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return NULL;
return nullptr;
}
- return new SkBitmapRegionCodec(codec.detach());
+ return new SkBitmapRegionCodec(codec.release());
}
default:
SkASSERT(false);
#endif
case kBMP_SkEncodedFormat:
case kWBMP_SkEncodedFormat:
- return new SkSampledCodec(codec.detach());
+ return new SkSampledCodec(codec.release());
#ifdef SK_CODEC_DECODES_WEBP
case kWEBP_SkEncodedFormat:
- return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
+ return new SkWebpAdapterCodec((SkWebpCodec*) codec.release());
#endif
#ifdef SK_CODEC_DECODES_RAW
case kDNG_SkEncodedFormat:
- return new SkRawAdapterCodec((SkRawCodec*)codec.detach());
+ return new SkRawAdapterCodec((SkRawCodec*)codec.release());
#endif
default:
return nullptr;
return false;
}
- *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.detach(),
+ *codecOut = new SkBmpMaskCodec(imageInfo, stream, bitsPerPixel, masks.release(),
rowOrder);
return true;
case kRLE_BmpInputFormat:
// codec has taken ownership of stream, so we do not need to
// delete it.
SkASSERT(codec);
- streamDeleter.detach();
+ streamDeleter.release();
return codec;
}
return nullptr;
// But this code follows the same pattern as the loop.
#ifdef SK_CODEC_DECODES_PNG
if (SkPngCodec::IsPng(buffer, bytesRead)) {
- return SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader);
+ return SkPngCodec::NewFromStream(streamDeleter.release(), chunkReader);
} else
#endif
{
for (DecoderProc proc : gDecoderProcs) {
if (proc.IsFormat(buffer, bytesRead)) {
- return proc.NewFromStream(streamDeleter.detach());
+ return proc.NewFromStream(streamDeleter.release());
}
}
#ifdef SK_CODEC_DECODES_RAW
// Try to treat the input as RAW if all the other checks failed.
- return SkRawCodec::NewFromStream(streamDeleter.detach());
+ return SkRawCodec::NewFromStream(streamDeleter.release());
#endif
}
// the default.
SkImageInfo imageInfo = SkImageInfo::Make(size.width(), size.height(), kIndex_8_SkColorType,
alphaType);
- *codecOut = new SkGifCodec(imageInfo, streamDeleter.detach(), gif.detach(), transIndex,
+ *codecOut = new SkGifCodec(imageInfo, streamDeleter.release(), gif.release(), transIndex,
frameRect, frameIsSubset);
} else {
SkASSERT(nullptr != gifOut);
- streamDeleter.detach();
- *gifOut = gif.detach();
+ streamDeleter.release();
+ *gifOut = gif.release();
}
return true;
}
// Check if the embedded codec is bmp or png and create the codec
SkCodec* codec = nullptr;
if (SkPngCodec::IsPng((const char*) data->bytes(), data->size())) {
- codec = SkPngCodec::NewFromStream(embeddedStream.detach());
+ codec = SkPngCodec::NewFromStream(embeddedStream.release());
} else {
- codec = SkBmpCodec::NewFromIco(embeddedStream.detach());
+ codec = SkBmpCodec::NewFromIco(embeddedStream.release());
}
// Save a valid codec
// Note that stream is owned by the embedded codec, the ico does not need
// direct access to the stream.
- return new SkIcoCodec(info, codecs.detach());
+ return new SkIcoCodec(info, codecs.release());
}
/*
// Create image info object and the codec
const SkImageInfo& imageInfo = SkImageInfo::Make(decoderMgr->dinfo()->image_width,
decoderMgr->dinfo()->image_height, colorType, kOpaque_SkAlphaType);
- *codecOut = new SkJpegCodec(imageInfo, stream, decoderMgr.detach());
+ *codecOut = new SkJpegCodec(imageInfo, stream, decoderMgr.release());
} else {
SkASSERT(nullptr != decoderMgrOut);
- *decoderMgrOut = decoderMgr.detach();
+ *decoderMgrOut = decoderMgr.release();
}
return true;
}
if (ReadHeader(stream, &codec, nullptr)) {
// Codec has taken ownership of the stream, we do not need to delete it
SkASSERT(codec);
- streamDeleter.detach();
+ streamDeleter.release();
return codec;
}
return nullptr;
fInfo_ptr = info_ptr;
}
- void detach() {
+ void release() {
fPng_ptr = nullptr;
fInfo_ptr = nullptr;
}
if (imageInfo) {
*imageInfo = SkImageInfo::Make(origWidth, origHeight, colorType, alphaType, profileType);
}
- autoClean.detach();
+ autoClean.release();
if (png_ptrp) {
*png_ptrp = png_ptr;
}
auto colorSpace = read_color_space(png_ptr, info_ptr);
if (1 == numberPasses) {
- return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunkReader,
+ return new SkPngScanlineDecoder(imageInfo, streamDeleter.release(), chunkReader,
png_ptr, info_ptr, bitDepth, colorSpace);
}
- return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(), chunkReader,
+ return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.release(), chunkReader,
png_ptr, info_ptr, bitDepth, numberPasses,
colorSpace);
}
}
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(),
kGray_8_SkColorType, kOpaque_SkAlphaType);
- return new SkWbmpCodec(info, streamDeleter.detach());
+ return new SkWbmpCodec(info, streamDeleter.release());
}
int SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
SkAutoTDelete<SkStream> streamDeleter(stream);
SkImageInfo info;
if (webp_parse_header(stream, &info)) {
- return new SkWebpCodec(info, streamDeleter.detach());
+ return new SkWebpCodec(info, streamDeleter.release());
}
return nullptr;
}
finishRange(curRange, lastIndex - 1,
SkAdvancedTypefaceMetrics::WidthRange::kRange);
}
- return result.detach();
+ return result.release();
}
// Make AdvanceMetric template functions available for linking with typename
}
}
void free() { this->reset(nullptr); }
- T* detach() {
+ T* release() {
T* ptr = fPtr;
fPtr = nullptr;
return ptr;
return nullptr;
}
- return new SkColorTable(colors.detach(), count, kAllocatedWithMalloc);
+ return new SkColorTable(colors.release(), count, kAllocatedWithMalloc);
}
}
bool hasStream() const { return fStream.get() != nullptr; }
SkStreamAsset* duplicateStream() const { return fStream->duplicate(); }
- SkStreamAsset* detachStream() { return fStream.detach(); }
+ SkStreamAsset* detachStream() { return fStream.release(); }
SkStreamAsset* getStream() { return fStream.get(); }
int getIndex() const { return fIndex; }
int getAxisCount() const { return fAxisCount; }
const char* getFullName() const { return fFullName.c_str(); }
const char* getPostscriptName() const { return fPostscriptName.c_str(); }
bool hasFontData() const { return fFontData.get() != nullptr; }
- SkFontData* detachFontData() { return fFontData.detach(); }
+ SkFontData* detachFontData() { return fFontData.release(); }
void setFamilyName(const char* name) { fFamilyName.set(name); }
void setFullName(const char* name) { fFullName.set(name); }
// Now that we know we can hand-off the generator (to be owned by the cacherator) we can
// release our holder. (we DONT want to delete it here anymore)
- genHolder.detach();
+ genHolder.release();
return new SkImageCacherator(gen, gen->getInfo().makeWH(subset->width(), subset->height()),
SkIPoint::Make(subset->x(), subset->y()), uniqueID);
}
const Lights* finish() {
- return fLights.detach();
+ return fLights.release();
}
private:
if (!data->parseStream(stream, proc, topLevelTFPlayback)) {
return nullptr;
}
- return data.detach();
+ return data.release();
}
SkPictureData* SkPictureData::CreateFromBuffer(SkReadBuffer& buffer,
if (!data->parseBuffer(buffer)) {
return nullptr;
}
- return data.detach();
+ return data.release();
}
bool SkPictureData::parseStream(SkStream* stream,
for (int i = 0; pictList && i < pictList->count(); i++) {
subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]);
}
- return new SkBigPicture(fCullRect, fRecord.detach(), pictList, fBBH.detach(),
- saveLayerData.detach(), subPictureBytes);
+ return new SkBigPicture(fCullRect, fRecord.release(), pictList, fBBH.release(),
+ saveLayerData.release(), subPictureBytes);
}
SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) {
// 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 new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()),
- saveLayerData.detach(), subPictureBytes);
+ saveLayerData.release(), subPictureBytes);
}
};
for (int i = 0; i < count; ++i) {
pics[i] = fArray[i]->newPictureSnapshot();
}
- return new SkBigPicture::SnapshotArray(pics.detach(), count);
+ return new SkBigPicture::SnapshotArray(pics.release(), count);
}
void SkDrawableList::append(SkDrawable* drawable) {
size_t approxBytesUsedBySubPictures() const { return fApproxBytesUsedBySubPictures; }
SkDrawableList* getDrawableList() const { return fDrawableList.get(); }
- SkDrawableList* detachDrawableList() { return fDrawableList.detach(); }
+ SkDrawableList* detachDrawableList() { return fDrawableList.release(); }
// Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail.
void forgetRecord();
size_t used = rec->bytesUsed();
SkASSERT(used <= fTotalBytesUsed);
- this->detach(rec);
+ this->release(rec);
fHash->remove(rec->getKey());
fTotalBytesUsed -= used;
///////////////////////////////////////////////////////////////////////////////
-void SkResourceCache::detach(Rec* rec) {
+void SkResourceCache::release(Rec* rec) {
Rec* prev = rec->fPrev;
Rec* next = rec->fNext;
this->validate();
- this->detach(rec);
+ this->release(rec);
fHead->fPrev = rec;
rec->fNext = fHead;
// linklist management
void moveToHead(Rec*);
void addToHead(Rec*);
- void detach(Rec*);
+ void release(Rec*);
void remove(Rec*);
void init(); // called by constructors
if (!fName.isEmpty()) {
SkAutoTDelete<SkFILEStream> that(new SkFILEStream(fName.c_str()));
if (sk_fidentical(that->fFILE, this->fFILE)) {
- return that.detach();
+ return that.release();
}
}
SkStreamAsset* SkFILEStream::fork() const {
SkAutoTDelete<SkStreamAsset> that(this->duplicate());
that->seek(this->getPosition());
- return that.detach();
+ return that.release();
}
size_t SkFILEStream::getLength() const {
SkMemoryStream* SkMemoryStream::fork() const {
SkAutoTDelete<SkMemoryStream> that(this->duplicate());
that->seek(fOffset);
- return that.detach();
+ return that.release();
}
size_t SkMemoryStream::getLength() const {
that->fCurrent = this->fCurrent;
that->fOffset = this->fOffset;
that->fCurrentOffset = this->fCurrentOffset;
- return that.detach();
+ return that.release();
}
size_t getLength() const override {
fStorage.realloc(fStorageUsed);
}
- const SkTextBlob* blob = new (fStorage.detach()) SkTextBlob(fRunCount, fBounds);
+ const SkTextBlob* blob = new (fStorage.release()) SkTextBlob(fRunCount, fBounds);
SkDEBUGCODE(const_cast<SkTextBlob*>(blob)->fStorageSize = fStorageSize;)
SkDEBUGCODE(
SkFontData* SkTypeface::onCreateFontData() const {
int index;
SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
- return new SkFontData(stream.detach(), index, nullptr, 0);
+ return new SkFontData(stream.release(), index, nullptr, 0);
};
int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding,
clamp_with_orig(dp + passCount * (rx + ry * dst->fRowBytes),
dst->fRowBytes, sp, src.fRowBytes, sw, sh, style);
}
- (void)autoCall.detach();
+ (void)autoCall.release();
}
if (style == kInner_SkBlurStyle) {
clamp_with_orig(dstPixels + pad*dst->fRowBytes + pad,
dst->fRowBytes, srcPixels, src.fRowBytes, srcWidth, srcHeight, style);
}
- (void)autoCall.detach();
+ (void)autoCall.release();
}
if (style == kInner_SkBlurStyle) {
}
}
-SkGradientBitmapCache::Entry* SkGradientBitmapCache::detach(Entry* entry) const {
+SkGradientBitmapCache::Entry* SkGradientBitmapCache::release(Entry* entry) const {
if (entry->fPrev) {
SkASSERT(fHead != entry);
entry->fPrev->fNext = entry->fNext;
*bm = entry->fBitmap;
}
// move to the head of our list, so we purge it last
- this->detach(entry);
+ this->release(entry);
this->attachToHead(entry);
return true;
}
if (fEntryCount == fMaxEntries) {
SkASSERT(fTail);
- delete this->detach(fTail);
+ delete this->release(fTail);
fEntryCount -= 1;
}
mutable Entry* fHead;
mutable Entry* fTail;
- inline Entry* detach(Entry*) const;
+ inline Entry* release(Entry*) const;
inline void attachToHead(Entry*) const;
#ifdef SK_DEBUG
return nullptr;
}
- SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, stream.detach());
+ SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, stream.release());
return face;
}
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
- return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : nullptr;
+ return stream.get() ? this->createFromStream(stream.release(), ttcIndex) : nullptr;
}
SkTypeface* onLegacyCreateTypeface(const char familyName[],
if (dataTypeface.get() != nullptr) {
SkAutoTDelete<SkStreamAsset> stream(dataTypeface->openStream(nullptr));
if (stream.get() != nullptr) {
- return fImpl->createFromStream(stream.detach(), dataTypefaceIndex);
+ return fImpl->createFromStream(stream.release(), dataTypefaceIndex);
}
}
return nullptr;
}
- SkAutoTUnref<SkTypeface> typeface(fImpl->createFromStream(stream.detach(), id.fTtcIndex));
+ SkAutoTUnref<SkTypeface> typeface(fImpl->createFromStream(stream.release(), id.fTtcIndex));
if (typeface.get() == nullptr) {
return nullptr;
}
newEntry.fTtcIndex = id.fTtcIndex;
newEntry.fTypeface = typeface.get(); // weak reference passed to new entry.
- return typeface.detach();
+ return typeface.release();
}
SkTypeface* SkFontMgr_Indirect::onMatchFamilyStyle(const char familyName[],
face.reset(this->createTypefaceFromFontId(fontId));
}
- return face.detach();
+ return face.release();
}
}
}
- return texture.detach();
+ return texture.release();
}
////////////////////////////////////////////////////////////////////////////////
}
Context& context = fContexts.push_back();
- context.fGLContext = glCtx.detach();
+ context.fGLContext = glCtx.release();
context.fGrContext = SkRef(grCtx.get());
context.fType = type;
context.fOptions = options;
return specs;
}
const MultisampleSpecs& specs = *new (&fMultisampleSpecsAllocator)
- MultisampleSpecs{effectiveKey, effectiveSampleCnt, locations.detach()};
+ MultisampleSpecs{effectiveKey, effectiveSampleCnt, locations.release()};
if (fMultisampleSpecsMap.count() <= effectiveKey) {
int n = 1 + effectiveKey - fMultisampleSpecsMap.count();
fMultisampleSpecsMap.push_back_n(n, (const MultisampleSpecs*) nullptr);
SkRect dstRect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
drawContext->fillRectToRect(GrClip::WideOpen(), paint, SkMatrix::I(), dstRect, localRect);
- return copy.detach();
+ return copy.release();
}
GrTextureAdjuster::GrTextureAdjuster(GrTexture* original,
drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), r);
- return result.detach();
+ return result.release();
}
SkASSERT(fRenderTarget != newRT);
- fRenderTarget.reset(newRT.detach());
+ fRenderTarget.reset(newRT.release());
#ifdef SK_DEBUG
SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlphaType :
fTotalPathCount += that->fTotalPathCount;
while (Draw* head = that->fDraws.head()) {
Draw* draw = fDraws.addToTail();
- draw->fInstanceData.reset(head->fInstanceData.detach());
+ draw->fInstanceData.reset(head->fInstanceData.release());
draw->fX = head->fX;
draw->fY = head->fY;
that->fDraws.popHead();
} else {
SkASSERT(path->isEqualTo(skPath, stroke));
}
- return path.detach();
+ return path.release();
}
void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
if (idx >= 0) {
// 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());
+ SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.release());
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 nullptr;
}
- return ret.detach();
+ return ret.release();
}
SkPlatformGpuFence SkGLContext::GLFenceSync::insertFence() const {
return;
}
- this->init(gl.detach());
+ this->init(gl.release());
}
SkANGLEGLContext::~SkANGLEGLContext() {
return;
}
- this->init(gl.detach());
+ this->init(gl.release());
}
SkCommandBufferGLContext::~SkCommandBufferGLContext() {
continue;
}
- this->init(gl.detach(), SkEGLFenceSync::CreateIfSupported(fDisplay));
+ this->init(gl.release(), SkEGLFenceSync::CreateIfSupported(fDisplay));
break;
}
}
return;
}
- this->init(gl.detach());
+ this->init(gl.release());
}
"/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib",
RTLD_LAZY);
- this->init(gl.detach());
+ this->init(gl.release());
}
IOSGLContext::~IOSGLContext() {
"/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib",
RTLD_LAZY);
- this->init(gl.detach());
+ this->init(gl.release());
}
MacGLContext::~MacGLContext() {
return;
}
- this->init(gl.detach());
+ this->init(gl.release());
}
SkMesaGLContext::~SkMesaGLContext() {
return;
}
- this->init(gl.detach());
+ this->init(gl.release());
}
WinGLContext::~WinGLContext() {
}
SkAutoTUnref<SkData> encoded(this->refEncoded());
if (encoded && effectiveSerializer->useEncodedData(encoded->data(), encoded->size())) {
- return encoded.detach();
+ return encoded.release();
}
SkBitmap bm;
return dst->tryAllocPixels();
}
SkAutoTUnref<SkDiscardablePixelRef> ref(
- new SkDiscardablePixelRef(prInfo, autoGenerator.detach(), dst->rowBytes(), factory));
+ new SkDiscardablePixelRef(prInfo, autoGenerator.release(), dst->rowBytes(), factory));
dst->setPixelRef(ref, origin.x(), origin.y());
return true;
}
return true;
}
-void SkOpCoincidence::detach(SkCoincidentSpans* remove) {
+void SkOpCoincidence::release(SkCoincidentSpans* remove) {
SkCoincidentSpans* coin = fHead;
SkCoincidentSpans* prev = nullptr;
SkCoincidentSpans* next;
do {
if (coin->fCoinPtTStart == deleted) {
if (coin->fCoinPtTEnd->span() == kept->span()) {
- this->detach(coin);
+ this->release(coin);
continue;
}
coin->fCoinPtTStart = kept;
}
if (coin->fCoinPtTEnd == deleted) {
if (coin->fCoinPtTStart->span() == kept->span()) {
- this->detach(coin);
+ this->release(coin);
continue;
}
coin->fCoinPtTEnd = kept;
}
if (coin->fOppPtTStart == deleted) {
if (coin->fOppPtTEnd->span() == kept->span()) {
- this->detach(coin);
+ this->release(coin);
continue;
}
coin->fOppPtTStart = kept;
}
if (coin->fOppPtTEnd == deleted) {
if (coin->fOppPtTStart->span() == kept->span()) {
- this->detach(coin);
+ this->release(coin);
continue;
}
coin->fOppPtTEnd = kept;
return SkDEBUGRELEASE(fDebugState->debugSpan(id), nullptr);
}
- void detach(SkCoincidentSpans* );
+ void release(SkCoincidentSpans* );
void dump() const;
bool expand();
bool extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
return start->starter(end)->windSum();
}
-void SkOpSegment::detach(const SkOpSpan* span) {
+void SkOpSegment::release(const SkOpSpan* span) {
if (span->done()) {
--fDoneCount;
}
SkOpSpanBase* next;
if (spanS->contains(test)) {
if (!test->final()) {
- test->upCast()->detach(spanS->ptT());
+ test->upCast()->release(spanS->ptT());
continue;
} else if (spanS != &fHead) {
- spanS->upCast()->detach(test->ptT());
+ spanS->upCast()->release(test->ptT());
spanS = test;
continue;
}
const SkOpSpanBase* debugSpan(int id) const;
void debugValidate() const;
- void detach(const SkOpSpan* );
+ void release(const SkOpSpan* );
double distSq(double t, const SkOpAngle* opp) const;
bool done() const {
SkOpSpanBase* span = next->span();
next->setDeleted();
if (span->ptT() == next) {
- span->upCast()->detach(kept);
+ span->upCast()->release(kept);
}
}
SkOpPtT* spanPtT = span->ptT();
SkASSERT(this->t() != spanPtT->fT);
SkASSERT(!zero_or_one(spanPtT->fT));
- span->detach(this->ptT());
+ span->release(this->ptT());
SkOpPtT* remainder = spanPtT->next();
ptT()->insert(spanPtT);
while (remainder != spanPtT) {
return false;
}
-void SkOpSpan::detach(SkOpPtT* kept) {
+void SkOpSpan::release(SkOpPtT* kept) {
SkASSERT(!final());
SkOpSpan* prev = this->prev();
SkASSERT(prev);
SkASSERT(next);
prev->setNext(next);
next->setPrev(prev);
- this->segment()->detach(this);
+ this->segment()->release(this);
SkOpCoincidence* coincidence = this->globalState()->coincidence();
if (coincidence) {
coincidence->fixUp(this->ptT(), kept);
}
bool debugCoinLoopCheck() const;
- void detach(SkOpPtT* );
+ void release(SkOpPtT* );
bool done() const {
SkASSERT(!final());
// If the stack is too deep we could get Stack Overflow.
// So we manually destruct the object.
~ContentEntry() {
- ContentEntry* val = fNext.detach();
+ ContentEntry* val = fNext.release();
while (val != nullptr) {
- ContentEntry* valNext = val->fNext.detach();
+ ContentEntry* valNext = val->fNext.release();
// When the destructor is called, fNext is nullptr and exits.
delete val;
val = valNext;
contentEntries->reset(entry);
setLastContentEntry(entry);
} else if (xfermode == SkXfermode::kDstOver_Mode) {
- entry->fNext.reset(contentEntries->detach());
+ entry->fNext.reset(contentEntries->release());
contentEntries->reset(entry);
} else {
lastContentEntry->fNext.reset(entry);
// of the content entries. If nothing was drawn, it needs to be
// removed.
SkAutoTDelete<ContentEntry>* contentEntries = getContentEntries();
- contentEntries->reset(firstContentEntry->fNext.detach());
+ contentEntries->reset(firstContentEntry->fNext.release());
}
return;
}
auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
return stream->isValid()
- ? SkPDFMakeDocument(stream.detach(), delete_wstream, dpi, nullptr).release()
+ ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).release()
: nullptr;
}
uint8_t* const resultTrailer = &(buffer[SkToInt(*headerLen + outputOffset)]);
memcpy(resultTrailer, src + *headerLen + hexDataLen, *trailerLen);
- return SkData::NewFromMalloc(buffer.detach(), length);
+ return SkData::NewFromMalloc(buffer.release(), length);
}
return nullptr;
}
SkASSERT(fontData);
fontSize = fontData->getLength();
SkASSERT(fontSize > 0);
- fontStream.reset(new SkPDFSharedStream(fontData.detach()));
+ fontStream.reset(new SkPDFSharedStream(fontData.release()));
fontStream->dict()->insertInt("Length1", fontSize);
descriptor->insertObjRef("FontFile2", std::move(fontStream));
break;
auto alphaGs = create_smask_graphic_state(canon, dpi, state);
SkPDFAlphaFunctionShader* alphaFunctionShader =
- new SkPDFAlphaFunctionShader(autoState->detach());
+ new SkPDFAlphaFunctionShader(autoState->release());
auto resourceDict =
get_gradient_resource_dict(colorShader.get(), alphaGs.get());
pdfShader->insertObjRef("Function", std::move(function));
sk_sp<SkPDFFunctionShader> pdfFunctionShader(
- new SkPDFFunctionShader(autoState->detach()));
+ new SkPDFFunctionShader(autoState->release()));
pdfFunctionShader->insertInt("PatternType", 2);
pdfFunctionShader->insertObject("Matrix",
SkPDFUtils::MatrixToArray(finalMatrix));
// Put the canvas into the pattern stream (fContent).
auto content = patternDevice->content();
- SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->detach());
+ SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->release());
imageShader->setData(content.get());
auto resourceDict = patternDevice->makeResourceDict();
if (dup && dup->hasLength() &&
dup->getLength() <= length + strlen("/Filter_/FlateDecode_")) {
this->insertInt("Length", dup->getLength());
- fCompressedData.reset(dup.detach());
+ fCompressedData.reset(dup.release());
return;
}
}
}
}
- CFRef detach() {
+ CFRef release() {
CFRef self = fCFRef;
fCFRef = nullptr;
return self;
SkTypeface* face = SkTypefaceCache::FindByProcAndRef(find_by_CTFontRef, (void*)ctFont.get());
if (!face) {
- face = NewFromFontRef(ctFont.detach(), nullptr, nullptr, false);
+ face = NewFromFontRef(ctFont.release(), nullptr, nullptr, false);
SkTypefaceCache::Add(face, face->fontStyle());
}
return face;
CFIndex cgAxisCount;
SkAutoSTMalloc<4, SkFixed> axisValues;
if (get_variations(fFontRef, &cgAxisCount, &axisValues)) {
- return new SkFontData(stream.detach(), index, axisValues.get(), cgAxisCount);
+ return new SkFontData(stream.release(), index, axisValues.get(), cgAxisCount);
}
- return new SkFontData(stream.detach(), index, nullptr, 0);
+ return new SkFontData(stream.release(), index, nullptr, 0);
}
///////////////////////////////////////////////////////////////////////////////
bool isFixedPitch;
(void)computeStyleBits(ctFont, &isFixedPitch);
- face = new SkTypeface_Mac(ctFont.detach(), nullptr, cacheRequest.fStyle, isFixedPitch,
+ face = new SkTypeface_Mac(ctFont.release(), nullptr, cacheRequest.fStyle, isFixedPitch,
skFamilyName.c_str(), false);
SkTypefaceCache::Add(face, face->fontStyle());
return face;
if (cgVariations) {
cgVariant.reset(CGFontCreateCopyWithVariations(cg, cgVariations));
} else {
- cgVariant.reset(cg.detach());
+ cgVariant.reset(cg.release());
}
CTFontRef ct = CTFontCreateWithGraphicsFont(cgVariant, 0, nullptr, nullptr);
if (!ct) {
return nullptr;
}
- return NewFromFontRef(ct, cg.detach(), nullptr, true);
+ return NewFromFontRef(ct, cg.release(), nullptr, true);
}
static CFDictionaryRef get_axes(CGFontRef cg, SkFontData* fontData) {
if (cgVariations) {
cgVariant.reset(CGFontCreateCopyWithVariations(cg, cgVariations));
} else {
- cgVariant.reset(cg.detach());
+ cgVariant.reset(cg.release());
}
CTFontRef ct = CTFontCreateWithGraphicsFont(cgVariant, 0, nullptr, nullptr);
if (!ct) {
return nullptr;
}
- return NewFromFontRef(ct, cg.detach(), nullptr, true);
+ return NewFromFontRef(ct, cg.release(), nullptr, true);
}
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
uint16_t glyphID;
paint.textToGlyphs(&character, sizeof(character), &glyphID);
if (glyphID != 0) {
- return face.detach();
+ return face.release();
}
}
return nullptr;
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
- return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : nullptr;
+ return stream.get() ? this->createFromStream(stream.release(), ttcIndex) : nullptr;
}
SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, nullptr)) {
return nullptr;
}
- SkFontData* data(new SkFontData(stream.detach(), ttcIndex, nullptr, 0));
+ SkFontData* data(new SkFontData(stream.release(), ttcIndex, nullptr, 0));
return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
}
SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, axisValues, name);
- SkFontData* data(new SkFontData(stream.detach(), params.getCollectionIndex(),
+ SkFontData* data(new SkFontData(stream.release(), params.getCollectionIndex(),
axisValues.get(), axisDefinitions.count()));
return new SkTypeface_AndroidStream(data, style, isFixedPitch, name);
}
}
},
/*end*/[](FamilyData* self, const char* tag) {
- *self->fFamilies.append() = self->fCurrentFamily.detach();
+ *self->fFamilies.append() = self->fCurrentFamily.release();
},
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
}
},
/*end*/[](FamilyData* self, const char* tag) {
- *self->fFamilies.append() = self->fCurrentFamily.detach();
+ *self->fFamilies.append() = self->fCurrentFamily.release();
},
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
SkFontStyle style;
SkString name;
if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, nullptr)) {
- return new SkTypeface_Stream(style, isFixedPitch, false, name, stream.detach(),
+ return new SkTypeface_Stream(style, isFixedPitch, false, name, stream.release(),
ttcIndex);
} else {
return nullptr;
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
- return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : nullptr;
+ return stream.get() ? this->createFromStream(stream.release(), ttcIndex) : nullptr;
}
SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) const override {
SkTypeface_Custom* tf =
new SkTypeface_Stream(style, isFixedPitch, true, // system-font (cannot delete)
- realname, stream.detach(), faceIndex);
+ realname, stream.release(), faceIndex);
SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str());
if (nullptr == addTo) {
FcPatternAddString(weak, object, (const FcChar8*)"nomatchstring");
FcPatternAddLangSet(weak, FC_LANG, weakLangSet);
- FcFontSetAdd(fontSet, strong.detach());
- FcFontSetAdd(fontSet, weak.detach());
+ FcFontSetAdd(fontSet, strong.release());
+ FcFontSetAdd(fontSet, weak.release());
// Add 'matchlang' to the copy of the pattern.
FcPatternAddLangSet(minimal, FC_LANG, weakLangSet);
}
}
- return new StyleSet(this, matches.detach());
+ return new StyleSet(this, matches.release());
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
return nullptr;
}
- return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, nullptr, 0), style,
+ return new SkTypeface_stream(new SkFontData(stream.release(), ttcIndex, nullptr, 0), style,
isFixedWidth);
}
SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, axisValues, name);
- SkFontData* data(new SkFontData(stream.detach(), params.getCollectionIndex(),
+ SkFontData* data(new SkFontData(stream.release(), params.getCollectionIndex(),
axisValues.get(), axisDefinitions.count()));
return new SkTypeface_stream(data, style, isFixedPitch);
}
: SkFontStyle::kUpright_Slant);
SkAutoTUnref<SkTypeface> typeface(this->matchFamilyStyle(familyName, style));
if (typeface.get()) {
- return typeface.detach();
+ return typeface.release();
}
return this->matchFamilyStyle(nullptr, style);
// though I think it makes sense to wait until we understand how
// we want to communicate it to the generator.
- return new SkImageGeneratorCG(info, autoImageSrc.detach(), data);
+ return new SkImageGeneratorCG(info, autoImageSrc.release(), data);
}
SkImageGeneratorCG::SkImageGeneratorCG(const SkImageInfo& info, const void* imageSrc, SkData* data)
HRN(FontToIdentity(font.get(), &fontIds[fontIndex]));
}
- return fontIdSet.detach();
+ return fontIdSet.release();
}
virtual SkFontIdentity matchIndexStyle(int familyIndex,
return nullptr;
}
- return new SkOTUtils::LocalizedStrings_NameTable((SkOTTableName*)nameTableData.detach(),
+ return new SkOTUtils::LocalizedStrings_NameTable((SkOTTableName*)nameTableData.release(),
SkOTUtils::LocalizedStrings_NameTable::familyNameTypes,
SK_ARRAY_COUNT(SkOTUtils::LocalizedStrings_NameTable::familyNameTypes));
}
canvasState->layers = (SkCanvasLayerState*) sk_malloc_throw(layerWriter.bytesWritten());
layerWriter.flatten(canvasState->layers);
- return canvasState.detach();
+ return canvasState.release();
}
////////////////////////////////////////////////////////////////////////////////
// setup the matrix and clip
setup_canvas_from_MC_state(layerState.mcState, canvas.get());
- return canvas.detach();
+ return canvas.release();
}
SkCanvas* SkCanvasStateUtils::CreateFromCanvasState(const SkCanvasState* state) {
state_v1->layers[i].y));
}
- return canvas.detach();
+ return canvas.release();
}
////////////////////////////////////////////////////////////////////////////////
// If we have read past the end of the buffer, rewinding is no longer
// supported, so we can go ahead and free the memory.
if (bytesReadDirectly > 0) {
- sk_free(fBuffer.detach());
+ sk_free(fBuffer.release());
}
return bytesReadDirectly;
SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const {
SkAutoTDelete<SkDWriteFontFileStream> that(this->duplicate());
that->seek(fPos);
- return that.detach();
+ return that.release();
}
size_t SkDWriteFontFileStream::getLength() const {
}
*fragmentStart = streamData.get();
- *fragmentContext = streamData.detach();
+ *fragmentContext = streamData.release();
}
return S_OK;
}
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
#import <UIKit/UIKit.h>
#include "SkCanvas.h"
#include "SkGraphics.h"
return success;
}
-void SkOSWindow::detach() {}
+void SkOSWindow::release() {}
void SkOSWindow::present() {
}
return [(SkNSView*)fHWND attach:attachType withMSAASampleCount:sampleCount andGetInfo:info];
}
-void SkOSWindow::detach() {
+void SkOSWindow::release() {
[(SkNSView*)fHWND detach];
}
return nullptr;
}
-void SkOSWindow::detach() {
+void SkOSWindow::release() {
if (fGLContext) {
SDL_GL_DeleteContext(fGLContext);
fGLContext = nullptr;
if (SDL_GL_MakeCurrent(fWindow, fGLContext) != 0) {
report_sdl_error("Failed to make SDL GL context current.");
- this->detach();
+ this->release();
return false;
}
}
void SkOSWindow::destroyWindow() {
- this->detach();
+ this->release();
if (fWindow) {
SDL_DestroyWindow(fWindow);
fWindow = nullptr;
void SkOSWindow::internalCloseWindow() {
if (fUnixWindow.fDisplay) {
- this->detach();
+ this->release();
SkASSERT(fUnixWindow.fGc);
XFreeGC(fUnixWindow.fDisplay, fUnixWindow.fGc);
fUnixWindow.fGc = nullptr;
return true;
}
-void SkOSWindow::detach() {
+void SkOSWindow::release() {
if (nullptr == fUnixWindow.fDisplay || nullptr == fUnixWindow.fGLContext) {
return;
}
return result;
}
-void SkOSWindow::detach() {
+void SkOSWindow::release() {
switch (fAttached) {
case kNone_BackEndType:
// nothing to do
if (!stream->isValid()) {
return nullptr;
}
- return new SkDocument_XPS(stream.detach(), delete_wstream, dpi);
+ return new SkDocument_XPS(stream.release(), delete_wstream, dpi);
}
#endif//defined(SK_BUILD_FOR_WIN32)
}
SkAutoTDelete<SkMemoryStream> newStream(new SkMemoryStream());
- newStream->setMemoryOwned(fontPackageBuffer.detach(), bytesWritten + extra);
+ newStream->setMemoryOwned(fontPackageBuffer.release(), bytesWritten + extra);
SkTScopedComPtr<IStream> newIStream;
- SkIStream::CreateFromSkStream(newStream.detach(), true, &newIStream);
+ SkIStream::CreateFromSkStream(newStream.release(), true, &newIStream);
XPS_FONT_EMBEDDING embedding;
HRM(current->xpsFont->GetEmbeddingOption(&embedding),
for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) {
SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badImages[i]);
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fullPath.c_str()));
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
// These images are corrupt. It's not important whether we succeed/fail in codec
// creation or decoding. We just want to make sure that we don't crash.
SkAutoTDelete<SkImageGenerator> gen(new TestImageGenerator(type, reporter, colorType));
REPORTER_ASSERT(reporter, gen.get() != nullptr);
SkBitmap lazy;
- bool success = SkDEPRECATED_InstallDiscardablePixelRef(gen.detach(), nullptr, &lazy, factory);
+ bool success = SkDEPRECATED_InstallDiscardablePixelRef(gen.release(), nullptr, &lazy, factory);
REPORTER_ASSERT(reporter, success);
if (TestImageGenerator::kSucceedGetPixels_TestType == type) {
SkAutoTUnref<SkData> data((SkData::NewFromStream(stream, 2 * size / 3)));
codec.reset(SkCodec::NewFromData(data));
} else {
- codec.reset(SkCodec::NewFromStream(stream.detach()));
+ codec.reset(SkCodec::NewFromStream(stream.release()));
}
if (!codec) {
ERRORF(r, "Unable to decode '%s'", path);
SkAutoTUnref<SkData> data((SkData::NewFromStream(stream, 2 * size / 3)));
androidCodec.reset(SkAndroidCodec::NewFromData(data));
} else {
- androidCodec.reset(SkAndroidCodec::NewFromStream(stream.detach()));
+ androidCodec.reset(SkAndroidCodec::NewFromStream(stream.release()));
}
if (!androidCodec) {
ERRORF(r, "Unable to decode '%s'", path);
SkDebugf("Missing resource '%s'\n", path);
}
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(r, codec);
if (!codec) {
SkDebugf("Missing resource '%s'\n", path);
return;
}
- SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
if (!codec) {
ERRORF(r, "Unable to create codec '%s'", path);
return;
SkDebugf("Missing resource '%s'\n", path);
return;
}
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(r, nullptr == codec);
}
SkDebugf("Missing resource '%s'\n", path);
return;
}
- SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
// This should return kSuccess because kIndex8 is supported.
SkPMColor colorStorage[256];
0x83, 0xFF, 0x7F, // W: 65535
0x83, 0xFF, 0x7F }; // H: 65535
SkAutoTDelete<SkStream> stream(new SkMemoryStream(maxSizeWbmp, sizeof(maxSizeWbmp), false));
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(r, codec);
if (!codec) return;
0x84, 0x80, 0x00, // W: 65536
0x84, 0x80, 0x00 }; // H: 65536
stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false));
- codec.reset(SkCodec::NewFromStream(stream.detach()));
+ codec.reset(SkCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(r, !codec);
}
SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png"));
REPORTER_ASSERT(r, nullptr != stream);
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(r, nullptr != codec);
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
int ttcIndex;
SkAutoTDelete<SkStreamAsset> fontData(origTypeface->openStream(&ttcIndex));
- SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.detach());
+ SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.release());
SkFontDescriptor desc;
bool isLocalStream = false;
// This will fail to create a codec. However, what we really want to test is that we
// won't read past the end of the stream.
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
}
return;
}
- SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(r, codec);
if (!codec) {
return;
} else {
SkFixed axis = SK_FixedSqrt2;
SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFontData(
- new SkFontData(distortable.detach(), 0, &axis, 1)));
+ new SkFontData(distortable.release(), 0, &axis, 1)));
if (!typeface) {
INFOF(reporter, "Could not run fontstream test because Distortable.ttf not created.");
} else {
REPORTER_ASSERT(reporter, &obj == tmp.get());
REPORTER_ASSERT(reporter, obj.unique());
- REPORTER_ASSERT(reporter, &obj == tmp.detach());
+ REPORTER_ASSERT(reporter, &obj == tmp.release());
REPORTER_ASSERT(reporter, obj.unique());
- REPORTER_ASSERT(reporter, nullptr == tmp.detach());
+ REPORTER_ASSERT(reporter, nullptr == tmp.release());
REPORTER_ASSERT(reporter, nullptr == tmp.get());
obj.ref();
INFOF(reporter, "Missing resource '%s'\n", path);
return;
}
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
REPORTER_ASSERT(reporter, codec);
if (!codec) {
return;
SkString resourcePath = GetResourcePath(resource);
SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str()));
if (stream->isValid()) {
- return stream.detach();
+ return stream.release();
} else {
SkDebugf("Resource %s not found.\n", resource);
return nullptr;
if (!stream) {
return nullptr;
}
- return SkTypeface::CreateFromStream(stream.detach());
+ return SkTypeface::CreateFromStream(stream.release());
}
int screenSamples = FLAGS_offscreen ? 0 : FLAGS_msaa;
if (!this->attach(kNativeGL_BackEndType, screenSamples, &fAttachmentInfo)) {
SkDebugf("Not possible to create backend.\n");
- INHERITED::detach();
+ INHERITED::release();
SkFAIL("Could not create backend\n");
}
fContext.reset();
fSurface.reset();
fInterface.reset();
- this->detach();
+ this->release();
}
}
if (gm->runAsBench()) {
fSourceType = "gm";
fBenchType = "micro";
- return new GMBench(gm.detach());
+ return new GMBench(gm.release());
}
}
const char* ctName = jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_COLOR].asCString();
SkColorType ct = colortype_from_name(ctName);
if (ct != kIndex_8_SkColorType) {
- bitmap.reset(convert_colortype(bitmap.detach(), ct));
+ bitmap.reset(convert_colortype(bitmap.release(), ct));
}
}
- return bitmap.detach();
+ return bitmap.release();
}
SkDebugf("image decode failed\n");
return nullptr;