Minor modifications to GrProgramDesc.h.
BUG=skia:
Review URL: https://codereview.chromium.org/1100483003
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index 66e0e06..9f636a1 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -12,8 +12,6 @@
#include "GrTypesPriv.h"
#include "SkChecksum.h"
-class GrGLGpu;
-
/** This class describes a program to generate. It also serves as a program cache key. Very little
of this is GL-specific. The GL-specific parts could be factored out into a subclass. */
class GrProgramDesc {
@@ -76,7 +74,7 @@
// This should really only be used internally, base classes should return their own headers
const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); }
-private:
+protected:
template<typename T, size_t OFFSET> T* atOffset() {
return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET);
}
@@ -117,9 +115,11 @@
kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProcessor,
};
- SkSTArray<kPreAllocSize, uint8_t, true> fKey;
+ SkSTArray<kPreAllocSize, uint8_t, true>& key() { return fKey; }
+ const SkSTArray<kPreAllocSize, uint8_t, true>& key() const { return fKey; }
- friend class GrGLProgramDescBuilder;
+private:
+ SkSTArray<kPreAllocSize, uint8_t, true> fKey;
};
#endif
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 73e02b6..96a8ada 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -96,16 +96,18 @@
// 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.
- desc->fKey.reset();
- desc->fKey.push_back_n(kProcessorKeysOffset);
+ glDesc->key().reset();
+ glDesc->key().push_back_n(kProcessorKeysOffset);
- GrProcessorKeyBuilder b(&desc->fKey);
+ GrProcessorKeyBuilder b(&glDesc->key());
primProc.getGLProcessorKey(batchTracker, gpu->glCaps(), &b);
if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) {
- desc->fKey.reset();
+ glDesc->key().reset();
return false;
}
@@ -114,7 +116,7 @@
const GrFragmentProcessor& fp = *fps.processor();
fp.getGLProcessorKey(gpu->glCaps(), &b);
if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTransforms()), &b)) {
- desc->fKey.reset();
+ glDesc->key().reset();
return false;
}
}
@@ -122,14 +124,14 @@
const GrXferProcessor& xp = *pipeline.getXferProcessor();
xp.getGLProcessorKey(gpu->glCaps(), &b);
if (!get_meta_key(xp, gpu->glCaps(), 0, &b)) {
- desc->fKey.reset();
+ 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 = desc->atOffset<KeyHeader, kHeaderOffset>();
+ KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>();
// make sure any padding in the header is zeroed.
memset(header, 0, kHeaderSize);
@@ -144,6 +146,6 @@
header->fColorEffectCnt = pipeline.numColorFragmentStages();
header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages();
- desc->finalize();
+ glDesc->finalize();
return true;
}
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index f237155..a10b0e8 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -14,6 +14,11 @@
#include "GrTypesPriv.h"
class GrGLGpu;
+class GrGLProgramDescBuilder;
+
+class GrGLProgramDesc : public GrProgramDesc {
+ friend class GrGLProgramDescBuilder;
+};
/**
* This class can be used to build a GrProgramDesc. It also provides helpers for accessing
@@ -30,7 +35,7 @@
// Each processor's key is a variable length array of uint32_t.
enum {
// Part 3.
- kHeaderOffset = GrProgramDesc::kHeaderOffset,
+ kHeaderOffset = GrGLProgramDesc::kHeaderOffset,
kHeaderSize = SkAlign4(sizeof(KeyHeader)),
// Part 4.
// This is the offset into the backenend specific part of the key, which includes
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 8188f74..de3cf3f 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -13,6 +13,7 @@
#include "GrTexture.h"
#include "GrGLUtil.h"
+class GrGLGpu;
class GrGLTexture : public GrTexture {