};
uint32_t
-GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords) const {
+GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords,
+ int numCoords) const {
uint32_t totalKey = 0;
- for (int t = 0; t < coords.count(); ++t) {
+ for (int t = 0; t < numCoords; ++t) {
uint32_t key = 0;
const GrCoordTransform* coordTransform = coords[t];
if (coordTransform->getMatrix().hasPerspective()) {
size_t getVertexStride() const { return fVertexStride; }
/**
- * Gets a transformKey from an array of coord transforms
+ * Computes a transformKey from an array of coord transforms. Will only look at the first
+ * <numCoords> transforms in the array.
+ *
+ * TODO: A better name for this function would be "compute" instead of "get".
*/
- uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>&) const;
+ uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords,
+ int numCoords) const;
/**
* Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this geometry
* processor's GL backend implementation.
+ *
+ * TODO: A better name for this function would be "compute" instead of "get".
*/
virtual void getGLProcessorKey(const GrBatchTracker& bt,
const GrGLSLCaps& caps,
* which must be different for every GrProcessor subclass. It can fail if an effect uses too many
* textures, transforms, etc, for the space allotted in the meta-key. NOTE, both FPs and GPs share
* this function because it is hairy, though FPs do not have attribs, and GPs do not have transforms
+ *
+ * TODO: A better name for this function would be "compute" instead of "get".
*/
static bool get_meta_key(const GrProcessor& proc,
const GrGLCaps& caps,
return true;
}
+/*
+ * 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);
+}
+
bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline,
for (int s = 0; s < pipeline.numFragmentStages(); ++s) {
const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s);
const GrFragmentProcessor& fp = *fps.processor();
-
- fp.getGLProcessorKey(*gpu->glCaps().glslCaps(), &b);
-
- //**** use glslCaps here?
- if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTransforms()), &b)) {
+ if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) {
glDesc->key().reset();
return false;
}