diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-01-06 20:16:26 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-01-06 20:16:26 +0000 |
commit | b08eb2b3bce45411494fe00258e4c91248ccd15e (patch) | |
tree | b20617e02fa260e8b09114a72bee7f2ade789323 /src | |
parent | 092590b88dd87d2fca87d38b2003068ffef37f2f (diff) |
separate image encode and decode
remove obsolete build-flag for encode
git-svn-id: http://skia.googlecode.com/svn/trunk@56 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/animator/SkSnapshot.cpp | 3 | ||||
-rw-r--r-- | src/animator/SkSnapshot.h | 3 | ||||
-rw-r--r-- | src/images/SkImageDecoder.cpp | 33 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libjpeg.cpp | 5 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libpng.cpp | 4 | ||||
-rw-r--r-- | src/images/SkImageEncoder.cpp | 48 | ||||
-rw-r--r-- | src/ports/SkImageDecoder_CG.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkImageDecoder_Factory.cpp | 19 | ||||
-rw-r--r-- | src/ports/SkImageDecoder_empty.cpp | 3 | ||||
-rw-r--r-- | src/ports/SkImageEncoder_Factory.cpp | 32 | ||||
-rw-r--r-- | src/xml/SkJSDisplayable.cpp | 4 |
11 files changed, 83 insertions, 75 deletions
diff --git a/src/animator/SkSnapshot.cpp b/src/animator/SkSnapshot.cpp index b65c517b73..0043ca5bd5 100644 --- a/src/animator/SkSnapshot.cpp +++ b/src/animator/SkSnapshot.cpp @@ -17,8 +17,6 @@ #include "SkTypes.h" -#ifdef SK_SUPPORT_IMAGE_ENCODE - #include "SkSnapshot.h" #include "SkAnimateMaker.h" #include "SkCanvas.h" @@ -71,4 +69,3 @@ bool SkSnapshot::draw(SkAnimateMaker& maker) { return false; } -#endif diff --git a/src/animator/SkSnapshot.h b/src/animator/SkSnapshot.h index c459fbbcef..7392edc3d8 100644 --- a/src/animator/SkSnapshot.h +++ b/src/animator/SkSnapshot.h @@ -18,8 +18,6 @@ #ifndef SkSnapShot_DEFINED #define SkSnapShot_DEFINED -#ifdef SK_SUPPORT_IMAGE_ENCODE - #include "SkDrawable.h" #include "SkImageDecoder.h" #include "SkMemberInfo.h" @@ -37,6 +35,5 @@ class SkSnapshot: public SkDrawable { int fSeqVal; }; -#endif // SK_SUPPORT_IMAGE_ENCODE #endif // SkSnapShot_DEFINED diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp index 18b52d689c..2d477ef4aa 100644 --- a/src/images/SkImageDecoder.cpp +++ b/src/images/SkImageDecoder.cpp @@ -155,36 +155,3 @@ bool SkImageDecoder::DecodeStream(SkStream* stream, SkBitmap* bm, return success; } -/////////////////////////////////////////////////////////////////////////////// - -#ifdef SK_SUPPORT_IMAGE_ENCODE - -SkImageEncoder::~SkImageEncoder() {} - -bool SkImageEncoder::encodeStream(SkWStream* stream, const SkBitmap& bm, - int quality) { - quality = SkMin32(100, SkMax32(0, quality)); - return this->onEncode(stream, bm, quality); -} - -bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm, - int quality) { - quality = SkMin32(100, SkMax32(0, quality)); - SkFILEWStream stream(file); - return this->onEncode(&stream, bm, quality); -} - -bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap& bm, Type t, - int quality) { - SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); - return enc.get() && enc.get()->encodeFile(file, bm, quality); -} - -bool SkImageEncoder::EncodeStream(SkWStream* stream, const SkBitmap& bm, Type t, - int quality) { - SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); - return enc.get() && enc.get()->encodeStream(stream, bm, quality); -} - -#endif - diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp index 492de2374f..51339971ac 100644 --- a/src/images/SkImageDecoder_libjpeg.cpp +++ b/src/images/SkImageDecoder_libjpeg.cpp @@ -15,6 +15,7 @@ */ #include "SkImageDecoder.h" +#include "SkImageEncoder.h" #include "SkColorPriv.h" #include "SkDither.h" #include "SkScaledBitmapSampler.h" @@ -501,8 +502,6 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, /////////////////////////////////////////////////////////////////////////////// -#ifdef SK_SUPPORT_IMAGE_ENCODE - #include "SkColorPriv.h" // taken from jcolor.c in libjpeg @@ -795,8 +794,6 @@ SkImageEncoder* SkImageEncoder_JPEG_Factory() { return SkNEW(SkJPEGImageEncoder); } -#endif /* SK_SUPPORT_IMAGE_ENCODE */ - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp index 862ebf1d98..1371ecc77d 100644 --- a/src/images/SkImageDecoder_libpng.cpp +++ b/src/images/SkImageDecoder_libpng.cpp @@ -16,6 +16,7 @@ */ #include "SkImageDecoder.h" +#include "SkImageEncoder.h" #include "SkColor.h" #include "SkColorPriv.h" #include "SkDither.h" @@ -443,8 +444,6 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap, /////////////////////////////////////////////////////////////////////////////// -#ifdef SK_SUPPORT_IMAGE_ENCODE - #include "SkColorPriv.h" #include "SkUnPreMultiply.h" @@ -792,4 +791,3 @@ SkImageEncoder* SkImageEncoder_PNG_Factory() { return SkNEW(SkPNGImageEncoder); } -#endif /* SK_SUPPORT_IMAGE_ENCODE */ diff --git a/src/images/SkImageEncoder.cpp b/src/images/SkImageEncoder.cpp new file mode 100644 index 0000000000..d3599059d9 --- /dev/null +++ b/src/images/SkImageEncoder.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "SkImageEncoder.h" +#include "SkBitmap.h" +#include "SkStream.h" +#include "SkTemplates.h" + +SkImageEncoder::~SkImageEncoder() {} + +bool SkImageEncoder::encodeStream(SkWStream* stream, const SkBitmap& bm, + int quality) { + quality = SkMin32(100, SkMax32(0, quality)); + return this->onEncode(stream, bm, quality); +} + +bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm, + int quality) { + quality = SkMin32(100, SkMax32(0, quality)); + SkFILEWStream stream(file); + return this->onEncode(&stream, bm, quality); +} + +bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap& bm, Type t, + int quality) { + SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); + return enc.get() && enc.get()->encodeFile(file, bm, quality); +} + +bool SkImageEncoder::EncodeStream(SkWStream* stream, const SkBitmap& bm, Type t, + int quality) { + SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t)); + return enc.get() && enc.get()->encodeStream(stream, bm, quality); +} + diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp index 74ff11285f..5594eac91a 100644 --- a/src/ports/SkImageDecoder_CG.cpp +++ b/src/ports/SkImageDecoder_CG.cpp @@ -15,6 +15,7 @@ #include <Carbon/Carbon.h> #include "SkImageDecoder.h" +#include "SkImageEncoder.h" #include "SkMovie.h" #include "SkStream.h" #include "SkTemplates.h" @@ -105,8 +106,6 @@ SkMovie* SkMovie::DecodeStream(SkStream* stream) { ///////////////////////////////////////////////////////////////////////// -#ifdef SK_SUPPORT_IMAGE_ENCODE - static size_t consumer_put(void* info, const void* buffer, size_t count) { SkWStream* stream = reinterpret_cast<SkWStream*>(info); return stream->write(buffer, count) ? count : 0; @@ -195,4 +194,3 @@ SkImageEncoder* SkImageEncoder::Create(Type t) { return SkNEW_ARGS(SkImageEncoder_CG, (t)); } -#endif diff --git a/src/ports/SkImageDecoder_Factory.cpp b/src/ports/SkImageDecoder_Factory.cpp index d0053cfac0..5c45a43ec5 100644 --- a/src/ports/SkImageDecoder_Factory.cpp +++ b/src/ports/SkImageDecoder_Factory.cpp @@ -83,22 +83,3 @@ SkMovie* SkMovie::DecodeStream(SkStream* stream) { return NULL; } -///////////////////////////////////////////////////////////////////////// - -#ifdef SK_SUPPORT_IMAGE_ENCODE - -extern SkImageEncoder* SkImageEncoder_JPEG_Factory(); -extern SkImageEncoder* SkImageEncoder_PNG_Factory(); - -SkImageEncoder* SkImageEncoder::Create(Type t) { - switch (t) { - case kJPEG_Type: - return SkImageEncoder_JPEG_Factory(); - case kPNG_Type: - return SkImageEncoder_PNG_Factory(); - default: - return NULL; - } -} - -#endif diff --git a/src/ports/SkImageDecoder_empty.cpp b/src/ports/SkImageDecoder_empty.cpp index 45eb346115..740af7dbb2 100644 --- a/src/ports/SkImageDecoder_empty.cpp +++ b/src/ports/SkImageDecoder_empty.cpp @@ -89,8 +89,6 @@ SkMovie* SkMovie::DecodeStream(SkStream* stream) { ///////////////////////////////////////////////////////////////////////// -#ifdef SK_SUPPORT_IMAGE_ENCODE - extern SkImageEncoder* SkImageEncoder_JPEG_Factory(); extern SkImageEncoder* SkImageEncoder_PNG_Factory(); @@ -107,4 +105,3 @@ SkImageEncoder* SkImageEncoder::Create(Type t) { } } -#endif diff --git a/src/ports/SkImageEncoder_Factory.cpp b/src/ports/SkImageEncoder_Factory.cpp new file mode 100644 index 0000000000..cdd7c0409f --- /dev/null +++ b/src/ports/SkImageEncoder_Factory.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2009, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "SkImageEncoder.h" + +extern SkImageEncoder* SkImageEncoder_JPEG_Factory(); +extern SkImageEncoder* SkImageEncoder_PNG_Factory(); + +SkImageEncoder* SkImageEncoder::Create(Type t) { + switch (t) { + case kJPEG_Type: + return SkImageEncoder_JPEG_Factory(); + case kPNG_Type: + return SkImageEncoder_PNG_Factory(); + default: + return NULL; + } +} + diff --git a/src/xml/SkJSDisplayable.cpp b/src/xml/SkJSDisplayable.cpp index d52a7c98f0..848b9f97dd 100644 --- a/src/xml/SkJSDisplayable.cpp +++ b/src/xml/SkJSDisplayable.cpp @@ -179,9 +179,7 @@ JS_INIT(Sk, Set) JS_INIT(Sk, Skew) // JS_INIT(Sk, 3D_Camera) // JS_INIT(Sk, 3D_Patch) -#ifdef SK_SUPPORT_IMAGE_ENCODE JS_INIT(Sk, Snapshot) -#endif // JS_INIT(SkDraw, Stroke) JS_INIT(Sk, Text) JS_INIT(Sk, TextOnPath) @@ -451,9 +449,7 @@ void SkJS::InitializeDisplayables(const SkBitmap& bitmap, JSContext *cx, JSObjec SkewInit(cx, obj, proto); // 3D_CameraInit(cx, obj, proto); // 3D_PatchInit(cx, obj, proto); - #ifdef SK_SUPPORT_IMAGE_ENCODE SnapshotInit(cx, obj, proto); - #endif // StrokeInit(cx, obj, proto); TextInit(cx, obj, proto); TextOnPathInit(cx, obj, proto); |