Adding CMYK jpeg changes w/o .gyp alterations

http://codereview.appspot.com/5785054/



git-svn-id: http://skia.googlecode.com/svn/trunk@3442 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gm.cpp b/gm/gm.cpp
index f9c0e66..b6f21f8 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -8,6 +8,8 @@
 #include "gm.h"
 using namespace skiagm;
 
+SkString GM::gResourcePath;
+
 GM::GM() {
     fBGColor = SK_ColorWHITE;
 }
diff --git a/gm/gm.h b/gm/gm.h
index b0de922..d75a1c1 100644
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -18,18 +18,18 @@
 #include "SkTRegistry.h"
 
 namespace skiagm {
-	
-	static inline SkISize make_isize(int w, int h) {
-		SkISize sz;
-		sz.set(w, h);
-		return sz;
-	}
+        
+        static inline SkISize make_isize(int w, int h) {
+                SkISize sz;
+                sz.set(w, h);
+                return sz;
+        }
 
     class GM {
     public:
         GM();
         virtual ~GM();
-		
+                
         enum Flags {
             kSkipPDF_Flag       = 1 << 0,
             kSkipPicture_Flag   = 1 << 1
@@ -39,7 +39,7 @@
         void drawBackground(SkCanvas*);
         void drawContent(SkCanvas*);
         
-		SkISize getISize() { return this->onISize(); }
+        SkISize getISize() { return this->onISize(); }
         const char* shortName();
 
         uint32_t getFlags() const {
@@ -53,10 +53,16 @@
         // GM's getISize bounds.
         void drawSizeBounds(SkCanvas*, SkColor);
 
-	protected:
-		virtual void onDraw(SkCanvas*) = 0;
-		virtual void onDrawBackground(SkCanvas*);
-		virtual SkISize onISize() = 0;
+        static void SetResourcePath(const char* resourcePath) { 
+            gResourcePath = resourcePath; 
+        }
+
+    protected:
+        static SkString gResourcePath;
+
+        virtual void onDraw(SkCanvas*) = 0;
+        virtual void onDrawBackground(SkCanvas*);
+        virtual SkISize onISize() = 0;
         virtual SkString onShortName() = 0;
         virtual uint32_t onGetFlags() const { return 0; }
         
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 6f53ce8..61095e1 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -589,9 +589,9 @@
 
 static void usage(const char * argv0) {
     SkDebugf(
-        "%s [-w writePath] [-r readPath] [-d diffPath] [--noreplay]\n"
-        "    [--serialize] [--forceBWtext] [--nopdf] [--nodeferred]\n"
-        "    [--match substring] [--notexturecache]"
+        "%s [-w writePath] [-r readPath] [-d diffPath] [-i resourcePath]\n"
+        "    [--noreplay] [--serialize] [--forceBWtext] [--nopdf] \n"
+        "    [--nodeferred] [--match substring] [--notexturecache]"
 #if SK_MESA
         " [--mesagl]"
 #endif
@@ -601,6 +601,7 @@
 "    readPath: directory to read reference images from;\n"
 "        reports if any pixels mismatch between reference and new images\n");
     SkDebugf("    diffPath: directory to write difference images in.\n");
+    SkDebugf("    resourcePath: directory that stores image resources.\n");
     SkDebugf("    --noreplay: do not exercise SkPicture replay.\n");
     SkDebugf(
 "    --serialize: exercise SkPicture serialization & deserialization.\n");
@@ -660,6 +661,7 @@
     const char* writePath = NULL;   // if non-null, where we write the originals
     const char* readPath = NULL;    // if non-null, were we read from to compare
     const char* diffPath = NULL;    // if non-null, where we write our diffs (from compare)
+    const char* resourcePath = NULL;// if non-null, where we read from for image resources
 
     SkTDArray<const char*> fMatches;
 
@@ -688,6 +690,11 @@
             if (argv < stop && **argv) {
                 diffPath = *argv;
             }
+        } else if (strcmp(*argv, "-i") == 0) {
+            argv++;
+            if (argv < stop && **argv) {
+                resourcePath = *argv;
+            }
         } else if (strcmp(*argv, "--forceBWtext") == 0) {
             gForceBWtext = true;
         } else if (strcmp(*argv, "--noreplay") == 0) {
@@ -709,17 +716,19 @@
             useMesa = true;
 #endif
         } else if (strcmp(*argv, "--notexturecache") == 0) {
-          disableTextureCache = true;
+            disableTextureCache = true;
         } else {
-          usage(commandName);
-          return -1;
+            usage(commandName);
+            return -1;
         }
     }
     if (argv != stop) {
-      usage(commandName);
-      return -1;
+        usage(commandName);
+        return -1;
     }
 
+    GM::SetResourcePath(resourcePath);
+
     int maxW = -1;
     int maxH = -1;
     Iter iter;
@@ -763,6 +772,10 @@
         fprintf(stderr, "writing to %s\n", writePath);
     }
 
+    if (resourcePath) {
+        fprintf(stderr, "reading resources from %s\n", resourcePath);
+    }
+
     // Accumulate success of all tests.
     int testsRun = 0;
     int testsPassed = 0;
@@ -828,10 +841,10 @@
 
             if (doDeferred && !testErrors &&
                 (kGPU_Backend == gRec[i].fBackend ||
-                kRaster_Backend == gRec[i].fBackend)) {
+                 kRaster_Backend == gRec[i].fBackend)) {
                 testErrors |= test_deferred_drawing(gm, gRec[i],
-                                    forwardRenderedBitmap,
-                                    diffPath, gGrContext, rt.get());
+                                                    forwardRenderedBitmap,
+                                                    diffPath, gGrContext, rt.get());
             }
 
             if ((ERROR_NONE == testErrors) && doReplay &&