add registrar for gif movie
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 18 Jun 2009 17:53:12 +0000 (17:53 +0000)
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 18 Jun 2009 17:53:12 +0000 (17:53 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@221 2bbb7eff-a529-9590-31e7-b0007b416f81

src/images/SkMovie_gif.cpp

index ca9c81271267427d47a67117c77f9d3cc85fc724..253c242499551a1a712f0ae408e14a976cfefb60 100644 (file)
@@ -38,19 +38,6 @@ private:
     SavedImage* fCurrSavedImage;
 };
 
-SkMovie* SkMovie_GIF_Factory(SkStream* stream) {
-    char buf[GIF_STAMP_LEN];
-    if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
-        if (memcmp(GIF_STAMP,   buf, GIF_STAMP_LEN) == 0 ||
-                memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
-                memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
-            stream->rewind();
-            return SkNEW_ARGS(SkGIFMovie, (stream));
-        }
-    }
-    return NULL;
-}
-
 static int Decode(GifFileType* fileType, GifByteType* out, int size) {
     SkStream* stream = (SkStream*) fileType->UserData;
     return (int) stream->read(out, size);
@@ -222,3 +209,22 @@ bool SkGIFMovie::onGetBitmap(SkBitmap* bm)
     }
     return true;
 }
+
+///////////////////////////////////////////////////////////////////////////////
+
+#include "SkTRegistry.h"
+
+SkMovie* Factory(SkStream* stream) {
+    char buf[GIF_STAMP_LEN];
+    if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
+        if (memcmp(GIF_STAMP,   buf, GIF_STAMP_LEN) == 0 ||
+                       memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
+                       memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
+            stream->rewind();
+            return SkNEW_ARGS(SkGIFMovie, (stream));
+        }
+    }
+    return NULL;
+}
+
+static SkTRegistry<SkMovie*, SkStream*> gReg(Factory);