aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-03-18 15:48:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 15:48:49 -0700
commitd15750c0c7766ecab7022ea9b2f9e89a9132cbc2 (patch)
treee697c7285402a9b32a1b5b390e20e73a253081c0 /samplecode
parent07ec54d8e6c0e7e6ea11cde867c00bd29da79063 (diff)
Remove uses of SkImageDecoder from samplecode
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/DecodeFile.h31
-rw-r--r--samplecode/SampleAll.cpp8
-rw-r--r--samplecode/SampleBitmapRect.cpp1
-rw-r--r--samplecode/SampleCamera.cpp4
-rw-r--r--samplecode/SampleConcavePaths.cpp1
-rw-r--r--samplecode/SampleEmboss.cpp1
-rw-r--r--samplecode/SampleFilter2.cpp8
-rw-r--r--samplecode/SampleHairline.cpp2
-rw-r--r--samplecode/SampleIdentityScale.cpp13
-rw-r--r--samplecode/SampleLayers.cpp2
-rwxr-xr-xsamplecode/SampleLighting.cpp6
-rw-r--r--samplecode/SampleLines.cpp5
-rw-r--r--samplecode/SamplePatch.cpp6
-rw-r--r--samplecode/SamplePath.cpp1
-rw-r--r--samplecode/SamplePathClip.cpp1
-rw-r--r--samplecode/SamplePdfFileViewer.cpp1
-rw-r--r--samplecode/SamplePictFile.cpp4
-rw-r--r--samplecode/SamplePoints.cpp1
-rw-r--r--samplecode/SampleRegion.cpp1
-rw-r--r--samplecode/SampleShaders.cpp4
-rw-r--r--samplecode/SampleSlides.cpp4
-rw-r--r--samplecode/SampleSubpixelTranslate.cpp13
-rw-r--r--samplecode/SampleText.cpp1
-rw-r--r--samplecode/SampleTextAlpha.cpp1
-rw-r--r--samplecode/SampleTextBox.cpp1
-rw-r--r--samplecode/SampleUnpremul.cpp17
-rw-r--r--samplecode/SampleVertices.cpp1
-rw-r--r--samplecode/SampleXfermodesBlur.cpp2
28 files changed, 61 insertions, 80 deletions
diff --git a/samplecode/DecodeFile.h b/samplecode/DecodeFile.h
new file mode 100644
index 0000000000..26d5d2dc26
--- /dev/null
+++ b/samplecode/DecodeFile.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBitmap.h"
+#include "SkCodec.h"
+#include "SkData.h"
+
+inline bool decode_file(const char* filename, SkBitmap* bitmap,
+ SkColorType colorType = kN32_SkColorType, bool requireUnpremul = false) {
+ SkASSERT(kIndex_8_SkColorType != colorType);
+ SkAutoTUnref<SkData> data(SkData::NewFromFileName(filename));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+ if (!codec) {
+ return false;
+ }
+
+ SkImageInfo info = codec->getInfo().makeColorType(colorType);
+ if (requireUnpremul && kPremul_SkAlphaType == info.alphaType()) {
+ info = info.makeAlphaType(kUnpremul_SkAlphaType);
+ }
+
+ if (!bitmap->tryAllocPixels(info)) {
+ return false;
+ }
+
+ return SkCodec::kSuccess == codec->getPixels(info, bitmap->getPixels(), bitmap->rowBytes());
+}
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 7c0557fc40..2bbe29f383 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -21,7 +21,6 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h"
-#include "SkImageDecoder.h"
#include "SkLayerRasterizer.h"
#include "SkMath.h"
#include "SkPath.h"
@@ -37,6 +36,7 @@
#include "SkXfermode.h"
#include <math.h>
+#include "DecodeFile.h"
static inline SkPMColor rgb2gray(SkPMColor c) {
unsigned r = SkGetPackedR32(c);
@@ -511,9 +511,9 @@ protected:
}
virtual void startTest() {
- SkImageDecoder::DecodeFile("/Users/caryclark/Desktop/bugcirc.gif", &fBug);
- SkImageDecoder::DecodeFile("/Users/caryclark/Desktop/tbcirc.gif", &fTb);
- SkImageDecoder::DecodeFile("/Users/caryclark/Desktop/05psp04.gif", &fTx);
+ decode_file("/Users/caryclark/Desktop/bugcirc.gif", &fBug);
+ decode_file("/Users/caryclark/Desktop/tbcirc.gif", &fTb);
+ decode_file("/Users/caryclark/Desktop/05psp04.gif", &fTx);
}
void drawRaster(SkCanvas* canvas) {
diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp
index 490c6a45c3..0576234576 100644
--- a/samplecode/SampleBitmapRect.cpp
+++ b/samplecode/SampleBitmapRect.cpp
@@ -11,7 +11,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
diff --git a/samplecode/SampleCamera.cpp b/samplecode/SampleCamera.cpp
index b860917f3f..ed6cc52829 100644
--- a/samplecode/SampleCamera.cpp
+++ b/samplecode/SampleCamera.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "SkAnimTimer.h"
#include "SkView.h"
@@ -17,7 +18,6 @@
#include "SkShader.h"
#include "SkUtils.h"
#include "SkRandom.h"
-#include "SkImageDecoder.h"
class CameraView : public SampleView {
SkTDArray<SkShader*> fShaders;
@@ -33,7 +33,7 @@ public:
SkString str;
str.printf("/skimages/elephant%d.jpeg", i);
SkBitmap bm;
- if (SkImageDecoder::DecodeFile(str.c_str(), &bm)) {
+ if (decode_file(str.c_str(), &bm)) {
SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm.height()) };
SkRect dst = { -150, -150, 150, 150 };
SkMatrix matrix;
diff --git a/samplecode/SampleConcavePaths.cpp b/samplecode/SampleConcavePaths.cpp
index fb5447efc7..abdf707523 100644
--- a/samplecode/SampleConcavePaths.cpp
+++ b/samplecode/SampleConcavePaths.cpp
@@ -11,7 +11,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
diff --git a/samplecode/SampleEmboss.cpp b/samplecode/SampleEmboss.cpp
index f219cdda24..6e33e05e79 100644
--- a/samplecode/SampleEmboss.cpp
+++ b/samplecode/SampleEmboss.cpp
@@ -13,7 +13,6 @@
#include "SkEmbossMaskFilter.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleFilter2.cpp b/samplecode/SampleFilter2.cpp
index 3663f11971..8c93563c40 100644
--- a/samplecode/SampleFilter2.cpp
+++ b/samplecode/SampleFilter2.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
@@ -35,12 +35,10 @@ public:
fBitmaps = new SkBitmap[fBitmapCount];
for (int i = 0; i < fBitmapCount/2; i++) {
- SkImageDecoder::DecodeFile(gNames[i], &fBitmaps[i], kN32_SkColorType,
- SkImageDecoder::kDecodePixels_Mode, nullptr);
+ decode_file(gNames[i], &fBitmaps[i]);
}
for (int i = fBitmapCount/2; i < fBitmapCount; i++) {
- SkImageDecoder::DecodeFile(gNames[i-fBitmapCount/2], &fBitmaps[i], kRGB_565_SkColorType,
- SkImageDecoder::kDecodePixels_Mode, nullptr);
+ decode_file(gNames[i-fBitmapCount/2], &fBitmaps[i], kRGB_565_SkColorType);
}
fCurrIndex = 0;
diff --git a/samplecode/SampleHairline.cpp b/samplecode/SampleHairline.cpp
index 74715331c6..fef44f53ce 100644
--- a/samplecode/SampleHairline.cpp
+++ b/samplecode/SampleHairline.cpp
@@ -12,7 +12,6 @@
#include "SkCornerPathEffect.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
@@ -26,7 +25,6 @@
#include "SkStream.h"
#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
static SkRandom gRand;
diff --git a/samplecode/SampleIdentityScale.cpp b/samplecode/SampleIdentityScale.cpp
index 5a4e39d36b..b6af3ce34f 100644
--- a/samplecode/SampleIdentityScale.cpp
+++ b/samplecode/SampleIdentityScale.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "gm.h"
#include "Resources.h"
@@ -12,7 +13,6 @@
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkStream.h"
@@ -25,16 +25,7 @@ class IdentityScaleView : public SampleView {
public:
IdentityScaleView(const char imageFilename[]) {
SkString resourcePath = GetResourcePath(imageFilename);
- SkImageDecoder* codec = nullptr;
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
+ if (!decode_file(resourcePath.c_str(), &fBM)) {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
}
diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp
index 118356872a..b31c839fac 100644
--- a/samplecode/SampleLayers.cpp
+++ b/samplecode/SampleLayers.cpp
@@ -14,7 +14,7 @@
#include "SkColorPriv.h"
#include "SkDevice.h"
#include "SkGradientShader.h"
-#include "SkImageDecoder.h"
+#include "SkImage.h"
#include "SkInterpolator.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
diff --git a/samplecode/SampleLighting.cpp b/samplecode/SampleLighting.cpp
index 566ed7f909..fa88e3ecd6 100755
--- a/samplecode/SampleLighting.cpp
+++ b/samplecode/SampleLighting.cpp
@@ -5,11 +5,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "Resources.h"
#include "SkCanvas.h"
-#include "SkImageDecoder.h"
#include "SkLightingShader.h"
#include "SkPoint3.h"
@@ -39,9 +39,9 @@ public:
LightingView() {
SkString diffusePath = GetResourcePath("brickwork-texture.jpg");
- SkImageDecoder::DecodeFile(diffusePath.c_str(), &fDiffuseBitmap);
+ decode_file(diffusePath.c_str(), &fDiffuseBitmap);
SkString normalPath = GetResourcePath("brickwork_normal-map.jpg");
- SkImageDecoder::DecodeFile(normalPath.c_str(), &fNormalBitmap);
+ decode_file(normalPath.c_str(), &fNormalBitmap);
fLightAngle = 0.0f;
fColorFactor = 0.0f;
diff --git a/samplecode/SampleLines.cpp b/samplecode/SampleLines.cpp
index da5fa57681..08a9e86c4b 100644
--- a/samplecode/SampleLines.cpp
+++ b/samplecode/SampleLines.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkCornerPathEffect.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
@@ -25,7 +25,6 @@
#include "SkStream.h"
#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
class LinesView : public SampleView {
public:
@@ -63,7 +62,7 @@ protected:
void onDrawContent(SkCanvas* canvas) override {
SkBitmap bm;
- SkImageDecoder::DecodeFile("/kill.gif", &bm);
+ decode_file("/kill.gif", &bm);
canvas->drawBitmap(bm, 0, 0, nullptr);
this->drawRings(canvas);
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 3ce350ac47..641e1e98f3 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "SkAnimTimer.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
@@ -31,8 +31,8 @@
static sk_sp<SkShader> make_shader0(SkIPoint* size) {
SkBitmap bm;
-// SkImageDecoder::DecodeFile("/skimages/progressivejpg.jpg", &bm);
- SkImageDecoder::DecodeFile("/skimages/logo.png", &bm);
+// decode_file("/skimages/progressivejpg.jpg", &bm);
+ decode_file("/skimages/logo.png", &bm);
size->set(bm.width(), bm.height());
return SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode);
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 9ef1c851d8..fec3b5e226 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -12,7 +12,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp
index 09f1c9705c..02a613a72f 100644
--- a/samplecode/SamplePathClip.cpp
+++ b/samplecode/SamplePathClip.cpp
@@ -10,7 +10,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
diff --git a/samplecode/SamplePdfFileViewer.cpp b/samplecode/SamplePdfFileViewer.cpp
index 950d42b3fd..a36b29f42f 100644
--- a/samplecode/SamplePdfFileViewer.cpp
+++ b/samplecode/SamplePdfFileViewer.cpp
@@ -15,7 +15,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkPath.h"
#include "SkPicture.h"
diff --git a/samplecode/SamplePictFile.cpp b/samplecode/SamplePictFile.cpp
index b456aef1bf..c1958c8973 100644
--- a/samplecode/SamplePictFile.cpp
+++ b/samplecode/SamplePictFile.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "SkDumpCanvas.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkPath.h"
#include "SkPicture.h"
@@ -153,7 +153,7 @@ private:
sk_sp<SkPicture> pic;
SkBitmap bm;
- if (SkImageDecoder::DecodeFile(path, &bm)) {
+ if (decode_file(path, &bm)) {
bm.setImmutable();
SkPictureRecorder recorder;
SkCanvas* can = recorder.beginRecording(SkIntToScalar(bm.width()),
diff --git a/samplecode/SamplePoints.cpp b/samplecode/SamplePoints.cpp
index 6b3f82d682..0bfe28f850 100644
--- a/samplecode/SamplePoints.cpp
+++ b/samplecode/SamplePoints.cpp
@@ -10,7 +10,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleRegion.cpp b/samplecode/SampleRegion.cpp
index 639203b8bc..1934dc74cb 100644
--- a/samplecode/SampleRegion.cpp
+++ b/samplecode/SampleRegion.cpp
@@ -13,7 +13,6 @@
#include "SkRegion.h"
#include "SkShader.h"
#include "SkUtils.h"
-#include "SkImageDecoder.h"
#include <math.h>
diff --git a/samplecode/SampleShaders.cpp b/samplecode/SampleShaders.cpp
index 71ddc2ec69..2ea6f0a68f 100644
--- a/samplecode/SampleShaders.cpp
+++ b/samplecode/SampleShaders.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkShader.h"
@@ -45,7 +45,7 @@ public:
SkBitmap fBitmap;
ShaderView() {
- SkImageDecoder::DecodeFile("/skimages/logo.gif", &fBitmap);
+ decode_file("/skimages/logo.gif", &fBitmap);
SkPoint pts[2];
SkColor colors[2];
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index 38fd7402c7..ca0d9df13f 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -304,7 +304,7 @@ static void textonpath_slide(SkCanvas* canvas) {
///////////////////////////////////////////////////////////////////////////////
-#include "SkImageDecoder.h"
+#include "DecodeFile.h"
#include "SkOSFile.h"
#include "SkRandom.h"
#include "SkStream.h"
@@ -312,7 +312,7 @@ static void textonpath_slide(SkCanvas* canvas) {
static sk_sp<SkShader> make_shader0(SkIPoint* size) {
SkBitmap bm;
- SkImageDecoder::DecodeFile("/skimages/logo.gif", &bm);
+ decode_file("/skimages/logo.gif", &bm);
size->set(bm.width(), bm.height());
return SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode);
diff --git a/samplecode/SampleSubpixelTranslate.cpp b/samplecode/SampleSubpixelTranslate.cpp
index 7e067a6dd4..3bb90562fa 100644
--- a/samplecode/SampleSubpixelTranslate.cpp
+++ b/samplecode/SampleSubpixelTranslate.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "DecodeFile.h"
#include "gm.h"
#include "Resources.h"
@@ -12,7 +13,6 @@
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
#include "SkRandom.h"
#include "SkStream.h"
@@ -27,16 +27,7 @@ public:
: fHorizontalVelocity(horizontalVelocity),
fVerticalVelocity(verticalVelocity) {
SkString resourcePath = GetResourcePath(imageFilename);
- SkImageDecoder* codec = nullptr;
- SkFILEStream stream(resourcePath.c_str());
- if (stream.isValid()) {
- codec = SkImageDecoder::Factory(&stream);
- }
- if (codec) {
- stream.rewind();
- codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
- delete codec;
- } else {
+ if (!decode_file(resourcePath.c_str(), &fBM)) {
fBM.allocN32Pixels(1, 1);
*(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
}
diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp
index 239c4daf36..6dca10017a 100644
--- a/samplecode/SampleText.cpp
+++ b/samplecode/SampleText.cpp
@@ -12,7 +12,6 @@
#include "SkWriteBuffer.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleTextAlpha.cpp b/samplecode/SampleTextAlpha.cpp
index d8fd1044d6..6e2e950669 100644
--- a/samplecode/SampleTextAlpha.cpp
+++ b/samplecode/SampleTextAlpha.cpp
@@ -12,7 +12,6 @@
#include "SkDevice.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleTextBox.cpp b/samplecode/SampleTextBox.cpp
index 61a18e2e3f..aedeaf6ce8 100644
--- a/samplecode/SampleTextBox.cpp
+++ b/samplecode/SampleTextBox.cpp
@@ -12,7 +12,6 @@
#include "SkColorShader.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp
index 4e3e1fae97..fb9735c017 100644
--- a/samplecode/SampleUnpremul.cpp
+++ b/samplecode/SampleUnpremul.cpp
@@ -8,14 +8,13 @@
#include "gm.h"
#include "sk_tool_utils.h"
+#include "DecodeFile.h"
#include "Resources.h"
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
-#include "SkForceLinking.h"
-#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkStream.h"
#include "SkString.h"
@@ -24,8 +23,6 @@
#include "SkUtils.h"
#include "SkView.h"
-__SK_FORCE_IMAGE_DECODER_LINKING;
-
/**
* Interprets c as an unpremultiplied color, and returns the
* premultiplied equivalent.
@@ -167,17 +164,7 @@ private:
fDecodeSucceeded = false;
return;
}
- SkFILEStream stream(fCurrFile.c_str());
- SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream));
- if (nullptr == decoder.get()) {
- fDecodeSucceeded = false;
- return;
- }
- if (!fPremul) {
- decoder->setRequireUnpremultipliedColors(true);
- }
- fDecodeSucceeded = decoder->decode(&stream, &fBitmap, kN32_SkColorType,
- SkImageDecoder::kDecodePixels_Mode) != SkImageDecoder::kFailure;
+ fDecodeSucceeded = decode_file(fCurrFile.c_str(), &fBitmap, kN32_SkColorType, !fPremul);
this->inval(nullptr);
}
diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp
index a8dcd22bb3..985ef608ec 100644
--- a/samplecode/SampleVertices.cpp
+++ b/samplecode/SampleVertices.cpp
@@ -10,7 +10,6 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp
index 867398d4b6..52419a06d0 100644
--- a/samplecode/SampleXfermodesBlur.cpp
+++ b/samplecode/SampleXfermodesBlur.cpp
@@ -12,7 +12,6 @@
#include "SkCornerPathEffect.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkImageDecoder.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkRegion.h"
@@ -26,7 +25,6 @@
#include "SkStream.h"
#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
#include "SkBlurMaskFilter.h"
static void setNamedTypeface(SkPaint* paint, const char name[]) {