]> git.saurik.com Git - android/aapt.git/commitdiff
am 84be06e4: resolved conflicts for merge of ea9e6d24 to honeycomb-plus-aosp
authorXavier Ducrohet <xav@android.com>
Thu, 21 Jul 2011 00:49:26 +0000 (17:49 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Thu, 21 Jul 2011 00:49:26 +0000 (17:49 -0700)
* commit '84be06e4ce0778fbf0c1ac72f94795ef8433439b':
  Added Caching for PreProcessed PNGs

1  2 
Resource.cpp

diff --combined Resource.cpp
index 1d97a4e15c21f40ed0787d5e6cfa8196477775d7,2d5138bab3fa9997496e2a08491f7093c4ed4057..cb6484fcf2af7a921c5fa38894d14eed06dc4b7b
  #include "ResourceTable.h"
  #include "Images.h"
  
+ #include "CrunchCache.h"
+ #include "FileFinder.h"
+ #include "CacheUpdater.h"
  #define NOISY(x) // x
  
  // ==========================================================================
@@@ -293,18 -297,19 +297,19 @@@ static status_t makeFileResources(Bundl
  static status_t preProcessImages(Bundle* bundle, const sp<AaptAssets>& assets,
                            const sp<ResourceTypeSet>& set, const char* type)
  {
-     ResourceDirIterator it(set, String8(type));
-     Vector<sp<AaptFile> > newNameFiles;
-     Vector<String8> newNamePaths;
      bool hasErrors = false;
-     ssize_t res;
-     while ((res=it.next()) == NO_ERROR) {
-         res = preProcessImage(bundle, assets, it.getFile(), NULL);
-         if (res < NO_ERROR) {
-             hasErrors = true;
+     ssize_t res = NO_ERROR;
+     if (bundle->getUseCrunchCache() == false) {
+         ResourceDirIterator it(set, String8(type));
+         Vector<sp<AaptFile> > newNameFiles;
+         Vector<String8> newNamePaths;
+         while ((res=it.next()) == NO_ERROR) {
+             res = preProcessImage(bundle, assets, it.getFile(), NULL);
+             if (res < NO_ERROR) {
+                 hasErrors = true;
+             }
          }
      }
      return (hasErrors || (res < NO_ERROR)) ? UNKNOWN_ERROR : NO_ERROR;
  }
  
@@@ -754,6 -759,35 +759,35 @@@ status_t massageManifest(Bundle* bundle
              } \
          } while (0)
  
+ status_t updatePreProcessedCache(Bundle* bundle)
+ {
+     #if BENCHMARK
+     fprintf(stdout, "BENCHMARK: Starting PNG PreProcessing \n");
+     long startPNGTime = clock();
+     #endif /* BENCHMARK */
+     String8 source(bundle->getResourceSourceDirs()[0]);
+     String8 dest(bundle->getCrunchedOutputDir());
+     FileFinder* ff = new SystemFileFinder();
+     CrunchCache cc(source,dest,ff);
+     CacheUpdater* cu = new SystemCacheUpdater(bundle);
+     size_t numFiles = cc.crunch(cu);
+     if (bundle->getVerbose())
+         fprintf(stdout, "Crunched %d PNG files to update cache\n", (int)numFiles);
+     delete ff;
+     delete cu;
+     #if BENCHMARK
+     fprintf(stdout, "BENCHMARK: End PNG PreProcessing. Time Elapsed: %f ms \n"
+             ,(clock() - startPNGTime)/1000.0);
+     #endif /* BENCHMARK */
+     return 0;
+ }
  status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
  {
      // First, look for a package file to parse.  This is required to
@@@ -2210,11 -2244,6 +2244,11 @@@ writeProguardForLayouts(ProguardKeepSet
              }
          }
      }
 +    // Handle the overlays
 +    sp<AaptAssets> overlay = assets->getOverlay();
 +    if (overlay.get()) {
 +        return writeProguardForLayouts(keep, overlay);
 +    }
      return NO_ERROR;
  }