diff options
author | reed <reed@google.com> | 2016-09-12 12:01:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-12 12:01:44 -0700 |
commit | 42943c8aa9c611c18ad0f1a30a27669f3d82239c (patch) | |
tree | deff0bbc59dd92559191c188d73f97b4f9c580aa /tools/skiaserve | |
parent | 09524ae42998ece3a8e7973064ab286646511b31 (diff) |
change SkStreams to work with sk_sp<SkData> instead of SkData*
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2333713002
Review-Url: https://codereview.chromium.org/2333713002
Diffstat (limited to 'tools/skiaserve')
-rw-r--r-- | tools/skiaserve/Request.cpp | 10 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/BreakHandler.cpp | 3 |
2 files changed, 6 insertions, 7 deletions
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp index 22fa211abc..ea2d17afb9 100644 --- a/tools/skiaserve/Request.cpp +++ b/tools/skiaserve/Request.cpp @@ -65,7 +65,7 @@ sk_sp<SkData> Request::writeCanvasToPng(SkCanvas* canvas) { SkDynamicMemoryWStream buffer; SkDrawCommand::WritePNG((const png_bytep) encodedBitmap->bytes(), bmp->width(), bmp->height(), buffer, true); - return sk_sp<SkData>(buffer.copyToData()); + return buffer.detachAsData(); } SkCanvas* Request::getCanvas() { @@ -117,7 +117,7 @@ sk_sp<SkData> Request::writeOutSkp() { SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer()); picture->serialize(&outStream, serializer); - return sk_sp<SkData>(outStream.copyToData()); + return outStream.detachAsData(); } GrContext* Request::getContext() { @@ -257,7 +257,7 @@ sk_sp<SkData> Request::getJsonOps(int n) { SkDynamicMemoryWStream stream; stream.writeText(Json::FastWriter().write(root).c_str()); - return sk_sp<SkData>(stream.copyToData()); + return stream.detachAsData(); } sk_sp<SkData> Request::getJsonBatchList(int n) { @@ -269,7 +269,7 @@ sk_sp<SkData> Request::getJsonBatchList(int n) { SkDynamicMemoryWStream stream; stream.writeText(Json::FastWriter().write(result).c_str()); - return sk_sp<SkData>(stream.copyToData()); + return stream.detachAsData(); } sk_sp<SkData> Request::getJsonInfo(int n) { @@ -301,7 +301,7 @@ SkColor Request::getPixel(int x, int y) { // Convert to format suitable for inspection sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); - SkASSERT(encodedBitmap.get()); + SkASSERT(encodedBitmap); const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4); SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); diff --git a/tools/skiaserve/urlhandlers/BreakHandler.cpp b/tools/skiaserve/urlhandlers/BreakHandler.cpp index 7766adb021..f4f741fe34 100644 --- a/tools/skiaserve/urlhandlers/BreakHandler.cpp +++ b/tools/skiaserve/urlhandlers/BreakHandler.cpp @@ -80,6 +80,5 @@ int BreakHandler::handle(Request* request, MHD_Connection* connection, canvas->restoreToCount(saveCount); SkDynamicMemoryWStream stream; stream.writeText(Json::FastWriter().write(response).c_str()); - sk_sp<SkData> data(stream.copyToData()); - return SendData(connection, data.get(), "application/json"); + return SendData(connection, stream.detachAsData().get(), "application/json"); } |