static bool GetProcessorKey(const GrGeometryProcessor& gp, const GrGLCaps& caps, bool, GrProcessorKeyBuilder* b, uint16_t* keySize) { /* 0 because no transforms on a GP */ return get_meta_key(gp, caps, 0, gen_attrib_key(gp), b, keySize); }
static bool GetProcessorKey(const GrFragmentStage& fps, const GrGLCaps& caps, bool useLocalCoords, GrProcessorKeyBuilder* b, uint16_t* keySize) { /* 0 because no attribs on a fP */ return get_meta_key(*fps.getProcessor(), caps, gen_transform_key(fps, useLocalCoords), 0, b, keySize); }
/* * TODO: A better name for this function would be "compute" instead of "get". */ static bool get_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc, const GrFragmentProcessor& fp, const GrGLCaps& caps, GrProcessorKeyBuilder* b) { for (int i = 0; i < fp.numChildProcessors(); ++i) { if (!get_frag_proc_and_meta_keys(primProc, fp.childProcessor(i), caps, b)) { return false; } } fp.getGLProcessorKey(*caps.glslCaps(), b); //**** use glslCaps here? return get_meta_key(fp, caps, primProc.getTransformKey(fp.coordTransforms(), fp.numTransformsExclChildren()), b); }
JNIEXPORT jstring JNICALL Java_com_weezlabs_ffmpegkit_FFmpegKit_getmetadataprotected(JNIEnv *env, jobject obj, jobjectArray args) { int i = 0; int argc = 0; const char * ret = NULL; char **argv = NULL; jstring *strr = NULL; if (args != NULL) { argc = (env)->GetArrayLength(args); argv = (char **) malloc(sizeof(char *) * argc); strr = (jstring *) malloc(sizeof(jstring) * argc); for(i=0;i<argc;i++) { strr[i] = (jstring)(env)->GetObjectArrayElement(args, i); argv[i] = (char *)(env)->GetStringUTFChars(strr[i], 0); } } LOGI("try metadata get_meta_key: "); try{ COFFEE_TRY_JNI(env, ret = get_meta_key(argc, argv)); } catch(std::exception& e){ LOGE("catch: %s", e.what()); ret = NULL; } for(i=0;i<argc;i++) { (env)->ReleaseStringUTFChars(strr[i], argv[i]); } free(argv); free(strr); jstring jstrRet = NULL; if(ret != NULL){ jstrRet = (env)->NewStringUTF(ret); } return jstrRet; }
bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc, const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline, const GrGLGpu* gpu, const GrBatchTracker& batchTracker) { // The descriptor is used as a cache key. Thus when a field of the // descriptor will not affect program generation (because of the attribute // bindings in use or other descriptor field settings) it should be set // to a canonical value to avoid duplicate programs with different keys. GrGLProgramDesc* glDesc = (GrGLProgramDesc*) desc; GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); // Make room for everything up to the effect keys. glDesc->key().reset(); glDesc->key().push_back_n(kProcessorKeysOffset); GrProcessorKeyBuilder b(&glDesc->key()); primProc.getGLProcessorKey(batchTracker, gpu->glCaps(), &b); if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { glDesc->key().reset(); return false; } for (int s = 0; s < pipeline.numFragmentStages(); ++s) { const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s); const GrFragmentProcessor& fp = *fps.processor(); fp.getGLProcessorKey(gpu->glCaps(), &b); if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTransforms()), &b)) { glDesc->key().reset(); return false; } } const GrXferProcessor& xp = *pipeline.getXferProcessor(); xp.getGLProcessorKey(gpu->glCaps(), &b); if (!get_meta_key(xp, gpu->glCaps(), 0, &b)) { glDesc->key().reset(); return false; } // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------------------------- // Because header is a pointer into the dynamic array, we can't push any new data into the key // below here. KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>(); // make sure any padding in the header is zeroed. memset(header, 0, kHeaderSize); if (pipeline.readsFragPosition()) { header->fFragPosKey = GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget(), gpu->glCaps()); } else { header->fFragPosKey = 0; } header->fColorEffectCnt = pipeline.numColorFragmentStages(); header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages(); glDesc->finalize(); return true; }