Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: tools/skiaserve/Request.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/skiaserve/Request.cpp
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index edc0a6820b40dfe18c0037b267d180b0c07c7933..e3a0caa6e2dc2e1cd168c0e166c0216b36f86c3f 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -52,7 +52,7 @@ SkBitmap* Request::getBitmapFromCanvas(SkCanvas* canvas) {
return bmp;
}
-SkData* Request::writeCanvasToPng(SkCanvas* canvas) {
+sk_sp<SkData> Request::writeCanvasToPng(SkCanvas* canvas) {
// capture pixels
SkAutoTDelete<SkBitmap> bmp(this->getBitmapFromCanvas(canvas));
SkASSERT(bmp);
@@ -65,7 +65,7 @@ SkData* Request::writeCanvasToPng(SkCanvas* canvas) {
SkDynamicMemoryWStream buffer;
SkDrawCommand::WritePNG((const png_bytep) encodedBitmap->bytes(), bmp->width(), bmp->height(),
buffer, true);
- return buffer.copyToData();
+ return sk_sp<SkData>(buffer.copyToData());
}
SkCanvas* Request::getCanvas() {
@@ -96,12 +96,12 @@ void Request::drawToCanvas(int n, int m) {
fDebugCanvas->drawTo(target, n, m);
}
-SkData* Request::drawToPng(int n, int m) {
+sk_sp<SkData> Request::drawToPng(int n, int m) {
this->drawToCanvas(n, m);
return writeCanvasToPng(this->getCanvas());
}
-SkData* Request::writeOutSkp() {
+sk_sp<SkData> Request::writeOutSkp() {
// Playback into picture recorder
SkIRect bounds = this->getBounds();
SkPictureRecorder recorder;
@@ -117,7 +117,7 @@ SkData* Request::writeOutSkp() {
SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer());
picture->serialize(&outStream, serializer);
- return outStream.copyToData();
+ return sk_sp<SkData>(outStream.copyToData());
}
GrContext* Request::getContext() {
@@ -242,7 +242,7 @@ bool Request::initPictureFromStream(SkStream* stream) {
return true;
}
-SkData* Request::getJsonOps(int n) {
+sk_sp<SkData> Request::getJsonOps(int n) {
SkCanvas* canvas = this->getCanvas();
Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas);
root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu");
@@ -251,10 +251,10 @@ SkData* Request::getJsonOps(int n) {
SkDynamicMemoryWStream stream;
stream.writeText(Json::FastWriter().write(root).c_str());
- return stream.copyToData();
+ return sk_sp<SkData>(stream.copyToData());
}
-SkData* Request::getJsonBatchList(int n) {
+sk_sp<SkData> Request::getJsonBatchList(int n) {
SkCanvas* canvas = this->getCanvas();
SkASSERT(fGPUEnabled);
@@ -263,10 +263,10 @@ SkData* Request::getJsonBatchList(int n) {
SkDynamicMemoryWStream stream;
stream.writeText(Json::FastWriter().write(result).c_str());
- return stream.copyToData();
+ return sk_sp<SkData>(stream.copyToData());
}
-SkData* Request::getJsonInfo(int n) {
+sk_sp<SkData> Request::getJsonInfo(int n) {
// drawTo
SkAutoTUnref<SkSurface> surface(this->createCPUSurface());
SkCanvas* canvas = surface->getCanvas();
@@ -284,7 +284,7 @@ SkData* Request::getJsonInfo(int n) {
std::string json = Json::FastWriter().write(info);
// We don't want the null terminator so strlen is correct
- return SkData::NewWithCopy(json.c_str(), strlen(json.c_str()));
+ return SkData::MakeWithCopy(json.c_str(), strlen(json.c_str()));
}
SkColor Request::getPixel(int x, int y) {

Powered by Google App Engine
This is Rietveld 408576698