aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2016-11-30 17:07:59 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-30 22:48:56 +0000
commit1fcc40474f1ad1f522d0a61086e25a71ca0a6881 (patch)
tree298d1a0b66d5d1899133c6252c877931661c5e95 /include
parent3a7492fc04d83ed2729d2ba226d5277459536b74 (diff)
SkEncodeImage: no more link-time registration
Also, no more SkImageEncoder class. SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS now only guards some old API shims. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5006 Change-Id: I3797f584f3e8e12ade10d31e8733163453725f40 Reviewed-on: https://skia-review.googlesource.com/5006 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/android/SkBitmapRegionDecoder.h4
-rw-r--r--include/codec/SkAndroidCodec.h4
-rw-r--r--include/codec/SkEncodedFormat.h36
-rw-r--r--include/core/SkImageEncoder.h72
-rw-r--r--include/images/SkForceLinking.h17
5 files changed, 7 insertions, 126 deletions
diff --git a/include/android/SkBitmapRegionDecoder.h b/include/android/SkBitmapRegionDecoder.h
index b8922d4697..660aa0aefc 100644
--- a/include/android/SkBitmapRegionDecoder.h
+++ b/include/android/SkBitmapRegionDecoder.h
@@ -10,7 +10,7 @@
#include "SkBitmap.h"
#include "SkBRDAllocator.h"
-#include "SkEncodedFormat.h"
+#include "SkEncodedImageFormat.h"
#include "SkStream.h"
/*
@@ -66,7 +66,7 @@ public:
*/
virtual bool conversionSupported(SkColorType colorType) = 0;
- virtual SkEncodedFormat getEncodedFormat() = 0;
+ virtual SkEncodedImageFormat getEncodedFormat() = 0;
int width() const { return fWidth; }
int height() const { return fHeight; }
diff --git a/include/codec/SkAndroidCodec.h b/include/codec/SkAndroidCodec.h
index ee9d0f36d7..a4f46f939f 100644
--- a/include/codec/SkAndroidCodec.h
+++ b/include/codec/SkAndroidCodec.h
@@ -9,7 +9,7 @@
#define SkAndroidCodec_DEFINED
#include "SkCodec.h"
-#include "SkEncodedFormat.h"
+#include "SkEncodedImageFormat.h"
#include "SkStream.h"
#include "SkTypes.h"
@@ -51,7 +51,7 @@ public:
/**
* Format of the encoded data.
*/
- SkEncodedFormat getEncodedFormat() const { return (SkEncodedFormat)fCodec->getEncodedFormat(); }
+ SkEncodedImageFormat getEncodedFormat() const { return fCodec->getEncodedFormat(); }
/**
* @param requestedColorType Color type requested by the client
diff --git a/include/codec/SkEncodedFormat.h b/include/codec/SkEncodedFormat.h
deleted file mode 100644
index 485bff181a..0000000000
--- a/include/codec/SkEncodedFormat.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkEncodedFormat_DEFINED
-#define SkEncodedFormat_DEFINED
-
-#include "SkEncodedImageFormat.h"
-#include "SkTypes.h"
-
-#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
-
-enum SkEncodedFormat {
- kBMP_SkEncodedFormat = (int)SkEncodedImageFormat::kBMP,
- kGIF_SkEncodedFormat = (int)SkEncodedImageFormat::kGIF,
- kICO_SkEncodedFormat = (int)SkEncodedImageFormat::kICO,
- kJPEG_SkEncodedFormat = (int)SkEncodedImageFormat::kJPEG,
- kPNG_SkEncodedFormat = (int)SkEncodedImageFormat::kPNG,
- kWBMP_SkEncodedFormat = (int)SkEncodedImageFormat::kWBMP,
- kWEBP_SkEncodedFormat = (int)SkEncodedImageFormat::kWEBP,
- kPKM_SkEncodedFormat = (int)SkEncodedImageFormat::kPKM,
- kKTX_SkEncodedFormat = (int)SkEncodedImageFormat::kKTX,
- kASTC_SkEncodedFormat = (int)SkEncodedImageFormat::kASTC,
- kDNG_SkEncodedFormat = (int)SkEncodedImageFormat::kDNG,
-};
-
-#else
-
-typedef SkEncodedImageFormat SkEncodedFormat;
-
-#endif // SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
-
-#endif // SkEncodedFormat_DEFINED
diff --git a/include/core/SkImageEncoder.h b/include/core/SkImageEncoder.h
index 41cdb38f38..17d0603531 100644
--- a/include/core/SkImageEncoder.h
+++ b/include/core/SkImageEncoder.h
@@ -10,9 +10,7 @@
#include "SkBitmap.h"
#include "SkEncodedImageFormat.h"
-#include "SkPixelSerializer.h"
#include "SkStream.h"
-#include "SkTRegistry.h"
/**
* Encode SkPixmap in the given binary image format.
@@ -41,10 +39,8 @@ inline bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFor
return src.peekPixels(&pixmap) && SkEncodeImage(dst, pixmap, f, q);
}
+//TODO(halcanary): remove this code once all changes land.
#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
-
-////////////////////////////////////////////////////////////////////////////////
-
class SkImageEncoder {
public:
enum Type {
@@ -60,65 +56,11 @@ public:
kWEBP_Type = (int)SkEncodedImageFormat::kWEBP,
kKTX_Type = (int)SkEncodedImageFormat::kKTX,
};
- static SkImageEncoder* Create(Type);
-
- virtual ~SkImageEncoder() {}
-
- /* Quality ranges from 0..100 */
- enum {
- kDefaultQuality = 80
- };
-
- /**
- * Encode bitmap 'bm', returning the results in an SkData, at quality level
- * 'quality' (which can be in range 0-100). If the bitmap cannot be
- * encoded, return null. On success, the caller is responsible for
- * calling unref() on the data when they are finished.
- */
- SkData* encodeData(const SkBitmap& bm, int quality) {
- SkDynamicMemoryWStream buffer;
- return this->encodeStream(&buffer, bm, quality)
- ? buffer.detachAsData().release()
- : nullptr;
- }
-
- /**
- * Encode bitmap 'bm' in the desired format, writing results to
- * file 'file', at quality level 'quality' (which can be in range
- * 0-100). Returns false on failure.
- */
- bool encodeFile(const char path[], const SkBitmap& bm, int quality) {
- SkFILEWStream file(path);
- return this->encodeStream(&file, bm, quality);
- }
-
- /**
- * Encode bitmap 'bm' in the desired format, writing results to
- * stream 'stream', at quality level 'quality' (which can be in
- * range 0-100). Returns false on failure.
- */
- bool encodeStream(SkWStream* dst, const SkBitmap& src, int quality) {
- return this->onEncode(dst, src, SkMin32(100, SkMax32(0, quality)));
- }
-
- static SkData* EncodeData(const SkImageInfo& info, const void* pixels, size_t rowBytes,
- Type t, int quality) {
- SkPixmap pixmap(info, pixels, rowBytes, nullptr);
- return SkImageEncoder::EncodeData(pixmap, t, quality);
- }
-
static SkData* EncodeData(const SkBitmap& src, Type t, int quality) {
SkDynamicMemoryWStream buf;
return SkEncodeImage(&buf, src, (SkEncodedImageFormat)t, quality)
? buf.detachAsData().release() : nullptr;
}
-
- static SkData* EncodeData(const SkPixmap& pixmap, Type t, int quality) {
- SkDynamicMemoryWStream buf;
- return SkEncodeImage(&buf, pixmap, (SkEncodedImageFormat)t, quality)
- ? buf.detachAsData().release() : nullptr;
- }
-
static bool EncodeFile(const char path[], const SkBitmap& src, Type t, int quality) {
SkFILEWStream file(path);
return SkEncodeImage(&file, src, (SkEncodedImageFormat)t, quality);
@@ -126,17 +68,7 @@ public:
static bool EncodeStream(SkWStream* dst, const SkBitmap& bm, Type t, int quality) {
return SkEncodeImage(dst, bm, (SkEncodedImageFormat)t, quality);
}
-
-protected:
- /**
- * Encode bitmap 'bm' in the desired format, writing results to
- * stream 'stream', at quality level 'quality' (which can be in
- * range 0-100).
- *
- * This must be overridden by each SkImageEncoder implementation.
- */
- virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) = 0;
};
-
#endif // SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
+
#endif // SkImageEncoder_DEFINED
diff --git a/include/images/SkForceLinking.h b/include/images/SkForceLinking.h
index 5de8918e6f..ca52eeb5e5 100644
--- a/include/images/SkForceLinking.h
+++ b/include/images/SkForceLinking.h
@@ -4,19 +4,4 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
-#include "SkTypes.h"
-
-/**
- * This function's sole purpose is to trick the linker into not discarding
- * SkImageDecoder subclasses just because we do not directly call them.
- * This is necessary in applications that will create image decoders from
- * a stream.
- * Call this function with an expression that evaluates to false to ensure
- * that the linker includes the subclasses.
- * Passing true will result in leaked objects.
- */
-int SkForceLinking(bool doNotPassTrue);
-
-#define __SK_FORCE_IMAGE_DECODER_LINKING \
-SK_UNUSED static int linking_forced = SkForceLinking(false)
+// TODO(halcanary): delete this file.