Skip to content

Instantly share code, notes, and snippets.

@astojilj
Last active January 4, 2016 20:58
Show Gist options
  • Save astojilj/2175990285e2956c7c1a to your computer and use it in GitHub Desktop.
Save astojilj/2175990285e2956c7c1a to your computer and use it in GitHub Desktop.
1-2-3.patch
I/GFX 1 ( 3269): took 0.001615ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.631077ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.008846ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001693ms for 192*192 texture 4
I/GFX 2 ( 3269): took 0.068923ms for 192*192 texture 4
I/GFX 3 ( 3269): took 0.007769ms for 192*192 texture 4
I/GFX 1 ( 3269): took 0.002769ms for 192*192 texture 4
I/GFX 2 ( 3269): took 0.014462ms for 192*192 texture 4
I/GFX 3 ( 3269): took 0.008308ms for 192*192 texture 4
I/GFX 1 ( 3269): took 0.001769ms for 48*48 texture 4
I/GFX 2 ( 3269): took 0.013077ms for 48*48 texture 4
I/GFX 3 ( 3269): took 0.006384ms for 48*48 texture 4
I/GFX 1 ( 3269): took 0.001616ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.219538ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.009154ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.002462ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.071770ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.007154ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001616ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.489308ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.011308ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.002846ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.141231ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.009769ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001923ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.362385ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.009308ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.003384ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.123154ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.007769ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001462ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.066615ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.007692ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.003461ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.093615ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.008077ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001462ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.121692ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.014923ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001693ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.112077ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.019692ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.002923ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.317923ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.013077ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001615ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.292769ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.008846ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.002693ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.074307ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.013462ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001385ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.137693ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.008924ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001538ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.147231ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.008231ms for 2320*1024 texture 4
I/GFX 1 ( 3269): took 0.001538ms for 2320*1024 texture 4
I/GFX 2 ( 3269): took 0.147539ms for 2320*1024 texture 4
I/GFX 3 ( 3269): took 0.008154ms for 2320*1024 texture 4
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 2124d65..d3ab3a9 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -229,6 +229,29 @@ static GrTexture* set_key_and_return(GrTexture* tex, const GrUniqueKey& key) {
return tex;
}
+#define SKGR_DEBUG
+#ifdef SKGR_DEBUG
+
+#include <android/log.h>
+
+#include <time.h>
+
+using namespace std;
+static double elapsed(timespec start, timespec end)
+{
+ return (end.tv_sec-start.tv_sec)*1000 + (end.tv_nsec-start.tv_nsec) * 0.000001;
+}
+
+#define ELAPSE_START timespec time1, time2; clock_gettime(CLOCK_MONOTONIC, &time1);
+
+#define ELAPSE_END(a, ...) clock_gettime(CLOCK_MONOTONIC, &time2); \
+ double elapsedMiliseconds = elapsed(time1, time2); \
+ __android_log_print(ANDROID_LOG_INFO, a, "took %fms for %d*%d texture %d", elapsedMiliseconds, __VA_ARGS__);
+#else
+#define ELAPSE_START
+#define ELAPSE_END(a, ...)
+#endif
+
/*
* We have a 5 ways to try to return a texture (in sorted order)
*
@@ -247,8 +270,52 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
}
}
+ // 2. Ask the generator to natively create one
+ {
+ ELAPSE_START
+ {
+ ScopedGenerator generator(this);
+ SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
+ if (GrTexture* tex = generator->generateTexture(ctx, &subset)) {
+ return set_key_and_return(tex, key);
+ }
+ }
+ ELAPSE_END("GFX 1", fInfo.width(), fInfo.height(), fInfo.colorType());
+ }
+
+ const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo);
+
+ // 3. Ask the generator to return a compressed form that the GPU might support
+ {
+ ELAPSE_START
+ {
+ SkAutoTUnref<SkData> data(this->refEncoded());
+ if (data) {
+ GrTexture* tex = load_compressed_into_texture(ctx, data, desc);
+ if (tex) {
+ return set_key_and_return(tex, key);
+ }
+ }
+ }
+ ELAPSE_END("GFX 2", fInfo.width(), fInfo.height(), fInfo.colorType());
+ }
+
+ // 4. Ask the generator to return YUV planes, which the GPU can convert
+ {
+ ELAPSE_START
{
ScopedGenerator generator(this);
+ Generator_GrYUVProvider provider(generator);
+ GrTexture* tex = provider.refAsTexture(ctx, desc, true);
+ if (tex) {
+ return set_key_and_return(tex, key);
+ }
+ }
+ ELAPSE_END("GFX 3", fInfo.width(), fInfo.height(), fInfo.colorType());
+ }
+
+/* {
+ ScopedGenerator generator(this);
// 2. Ask the generator to natively create one
if (generator->getContentFlags() & SkImageGenerator::kCanGenerateTexture_ContentFlag) {
@@ -280,7 +347,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
}
}
}
-
+*/
// 5. Ask the generator to return RGB(A) data, which the GPU can convert
SkBitmap bitmap;
if (this->tryLockAsBitmap(&bitmap, client, chint)) {
(END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment