Revert of SkImage_Codec is Lazy (https://codereview.chromium.org/460823002/)

Reason for revert:
breaks chromium - no SkDecodingImageGenerator::Create

Original issue's description:
> SkImage_Codec is Lazy
>
> Committed: https://skia.googlesource.com/skia/+/e36f499110da8c2e2aa05227bee6deb967309ead

R=reed@google.com
TBR=reed@google.com
NOTREECHECKS=true
NOTRY=true

Author: halcanary@google.com

Review URL: https://codereview.chromium.org/461043002
diff --git a/gyp/core.gyp b/gyp/core.gyp
index afbc78a..64cc79b 100644
--- a/gyp/core.gyp
+++ b/gyp/core.gyp
@@ -20,7 +20,6 @@
         '../include/ports',
         '../include/utils',
         '../include/xml',
-        '../include/images',
         '../src/core',
         '../src/sfnt',
         '../src/image',
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 7a8d0ac..a6d5635 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -222,6 +222,7 @@
 
         '<(skia_src_path)/image/SkImage.cpp',
         '<(skia_src_path)/image/SkImagePriv.cpp',
+        '<(skia_src_path)/image/SkImage_Codec.cpp',
 #        '<(skia_src_path)/image/SkImage_Gpu.cpp',
         '<(skia_src_path)/image/SkImage_Raster.cpp',
         '<(skia_src_path)/image/SkSurface.cpp',
diff --git a/src/image/SkImage_Codec.cpp b/src/image/SkImage_Codec.cpp
new file mode 100644
index 0000000..21c844d
--- /dev/null
+++ b/src/image/SkImage_Codec.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkImageDecoder.h"
+#include "SkImage_Base.h"
+#include "SkBitmap.h"
+#include "SkCanvas.h"
+#include "SkData.h"
+
+class SkImage_Codec : public SkImage_Base {
+public:
+    static SkImage* NewEmpty();
+
+    SkImage_Codec(SkData* encodedData, int width, int height);
+    virtual ~SkImage_Codec();
+
+    virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_OVERRIDE;
+    virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&,
+                                  const SkPaint*) const SK_OVERRIDE;
+
+private:
+    SkData*     fEncodedData;
+    SkBitmap    fBitmap;
+
+    typedef SkImage_Base INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkImage_Codec::SkImage_Codec(SkData* data, int width, int height) : INHERITED(width, height) {
+    fEncodedData = data;
+    fEncodedData->ref();
+}
+
+SkImage_Codec::~SkImage_Codec() {
+    fEncodedData->unref();
+}
+
+void SkImage_Codec::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const {
+    if (!fBitmap.pixelRef()) {
+        // todo: this needs to be thread-safe
+        SkBitmap* bitmap = const_cast<SkBitmap*>(&fBitmap);
+        if (!SkImageDecoder::DecodeMemory(fEncodedData->bytes(), fEncodedData->size(), bitmap)) {
+            return;
+        }
+    }
+    canvas->drawBitmap(fBitmap, x, y, paint);
+}
+
+void SkImage_Codec::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
+                                     const SkPaint* paint) const {
+    if (!fBitmap.pixelRef()) {
+        // todo: this needs to be thread-safe
+        SkBitmap* bitmap = const_cast<SkBitmap*>(&fBitmap);
+        if (!SkImageDecoder::DecodeMemory(fEncodedData->bytes(), fEncodedData->size(), bitmap)) {
+            return;
+        }
+    }
+    canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkImage* SkImage::NewEncodedData(SkData* data) {
+    if (NULL == data) {
+        return NULL;
+    }
+
+    SkBitmap bitmap;
+    if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap, kUnknown_SkColorType,
+                                      SkImageDecoder::kDecodeBounds_Mode)) {
+        return NULL;
+    }
+
+    return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height()));
+}
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 4841dae..e4768af 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -10,7 +10,6 @@
 #include "SkBitmap.h"
 #include "SkCanvas.h"
 #include "SkData.h"
-#include "SkDecodingImageGenerator.h"
 #include "SkMallocPixelRef.h"
 
 class SkImage_Raster : public SkImage_Base {
@@ -70,10 +69,6 @@
                                   SkShader::TileMode,
                                   const SkMatrix* localMatrix) const SK_OVERRIDE;
 
-    SkImage_Raster(const SkBitmap& bitmap)
-        :INHERITED(bitmap.width(), bitmap.height())
-        , fBitmap(bitmap) { }
-
 private:
     SkImage_Raster() : INHERITED(0, 0) {}
 
@@ -211,17 +206,3 @@
 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
     return ((SkImage_Raster*)image)->getPixelRef();
 }
-
-SkImage* SkImage::NewEncodedData(SkData* data) {
-    if (NULL == data) {
-        return NULL;
-    }
-    SkBitmap bitmap;
-    if (!SkInstallDiscardablePixelRef(
-                SkDecodingImageGenerator::Create(
-                        data, SkDecodingImageGenerator::Options()),
-                &bitmap)) {
-        return NULL;
-    }
-    return SkNEW_ARGS(SkImage_Raster, (bitmap));
-}