diff options
author | Leon Scroggins III <scroggo@google.com> | 2015-01-20 15:52:43 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2015-03-12 19:51:57 +0000 |
commit | 3449789b9ca58fee7e5cd02ff89d544f4a6bc9b5 (patch) | |
tree | 4bae1e5c337a33c8ae280a2aed7741ec29f400be /cmds/screencap | |
parent | c6ee744a90a4a84df93b6631ca7df8736ef320e1 (diff) | |
download | frameworks_base-3449789b9ca58fee7e5cd02ff89d544f4a6bc9b5.zip frameworks_base-3449789b9ca58fee7e5cd02ff89d544f4a6bc9b5.tar.gz frameworks_base-3449789b9ca58fee7e5cd02ff89d544f4a6bc9b5.tar.bz2 |
SkStream is no longer a ref counted object.
With https://codereview.chromium.org/849103004/, SkStream is no longer
ref counted. Change callers that currently unref() SkStreams to one of
either:
- delete the stream
- pass ownership of the stream
screencap.cpp:
Call EncodeData directly, bypassing SkDynamicMemoryWStream and SkBitmap.
Utils.cpp:
Write directly to an SkData, and then use that to construct a new
SkStream.
Cherry-pick of a change that originally landed in master-skia and is
dependent on a skia merge (ag/655422).
Change-Id: Idc99ad7d5a70c893dc012d59915216f301ab3c9d
Diffstat (limited to 'cmds/screencap')
-rw-r--r-- | cmds/screencap/screencap.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index b0aee7b..dbc35af 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -36,9 +36,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkImageEncoder.h> -#include <SkBitmap.h> #include <SkData.h> -#include <SkStream.h> #pragma GCC diagnostic pop using namespace android; @@ -198,14 +196,11 @@ int main(int argc, char** argv) if (png) { const SkImageInfo info = SkImageInfo::Make(w, h, flinger2skia(f), kPremul_SkAlphaType); - SkBitmap b; - b.installPixels(info, const_cast<void*>(base), s*bytesPerPixel(f)); - SkDynamicMemoryWStream stream; - SkImageEncoder::EncodeStream(&stream, b, - SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality); - SkData* streamData = stream.copyToData(); - write(fd, streamData->data(), streamData->size()); - streamData->unref(); + SkAutoTUnref<SkData> data(SkImageEncoder::EncodeData(info, base, s*bytesPerPixel(f), + SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality)); + if (data.get()) { + write(fd, data->data(), data->size()); + } if (fn != NULL) { notifyMediaScanner(fn); } |