Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(946)

Unified Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 674543004: OptState owns program descriptor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLProgramDesc.cpp
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 79088137caa004519ddcd91d2ad13ad000f5ab40..bfbe95f78b73ec6dc19c0960f8db24a62af6a30c 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -4,15 +4,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "GrGLProgramDesc.h"
+
+#include "GrGLProcessor.h"
#include "GrBackendProcessorFactory.h"
#include "GrProcessor.h"
#include "GrGpuGL.h"
#include "GrOptDrawState.h"
-
#include "SkChecksum.h"
+#include "gl/builders/GrGLFragmentShaderBuilder.h"
/**
* The key for an individual coord transform is made up of a matrix type and a bit that
@@ -179,7 +179,7 @@ bool
GrGLProgramDesc::BuildStagedProcessorKey(const typename ProcessorKeyBuilder::StagedProcessor& stage,
const GrGLCaps& caps,
bool requiresLocalCoordAttrib,
- GrGLProgramDesc* desc,
+ GrProgramDesc* desc,
int* offsetAndSizeIndex) {
GrProcessorKeyBuilder b(&desc->fKey);
uint16_t processorKeySize;
@@ -204,7 +204,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
- GrGLProgramDesc* desc) {
+ GrProgramDesc* desc) {
bool inputColorIsUsed = optState.inputColorIsUsed();
bool inputCoverageIsUsed = optState.inputCoverageIsUsed();
@@ -248,7 +248,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
// --------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->header();
+ GLKeyHeader* header = desc->atOffset<GLKeyHeader, kHeaderOffset>();
// make sure any padding in the header is zeroed.
memset(header, 0, kHeaderSize);
@@ -270,11 +270,11 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
GR_GL_NO_CONSTANT_ATTRIBUTES;
if (!inputColorIsUsed) {
- header->fColorInput = kAllOnes_ColorInput;
+ header->fColorInput = GrProgramDesc::kAllOnes_ColorInput;
} else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) {
- header->fColorInput = kUniform_ColorInput;
+ header->fColorInput = GrProgramDesc::kUniform_ColorInput;
} else {
- header->fColorInput = kAttribute_ColorInput;
+ header->fColorInput = GrProgramDesc::kAttribute_ColorInput;
SkASSERT(!header->fUseFragShaderOnly);
}
@@ -282,11 +282,11 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
0xffffffff == optState.getCoverageColor();
if (covIsSolidWhite || !inputCoverageIsUsed) {
- header->fCoverageInput = kAllOnes_ColorInput;
+ header->fCoverageInput = GrProgramDesc::kAllOnes_ColorInput;
} else if (defaultToUniformInputs && !optState.hasCoverageVertexAttribute()) {
- header->fCoverageInput = kUniform_ColorInput;
+ header->fCoverageInput = GrProgramDesc::kUniform_ColorInput;
} else {
- header->fCoverageInput = kAttribute_ColorInput;
+ header->fCoverageInput = GrProgramDesc::kAttribute_ColorInput;
SkASSERT(!header->fUseFragShaderOnly);
}
@@ -319,7 +319,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
int availableAttributeIndex = optState.getVertexAttribCount();
if (optState.hasColorVertexAttribute()) {
header->fColorAttributeIndex = optState.colorVertexAttributeIndex();
- } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) {
+ } else if (GrProgramDesc::kAttribute_ColorInput == header->fColorInput) {
SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
header->fColorAttributeIndex = availableAttributeIndex;
availableAttributeIndex++;
@@ -329,7 +329,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
if (optState.hasCoverageVertexAttribute()) {
header->fCoverageAttributeIndex = optState.coverageVertexAttributeIndex();
- } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) {
+ } else if (GrProgramDesc::kAttribute_ColorInput == header->fCoverageInput) {
SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
header->fCoverageAttributeIndex = availableAttributeIndex;
} else {
@@ -341,23 +341,17 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
header->fColorEffectCnt = optState.numColorStages();
header->fCoverageEffectCnt = optState.numCoverageStages();
- desc->finalize();
+ GrGLProgramDesc::Finalize(desc);
return true;
}
-void GrGLProgramDesc::finalize() {
- int keyLength = fKey.count();
+void GrGLProgramDesc::Finalize(GrProgramDesc* desc) {
bsalomon 2014/10/23 18:10:30 Should this be moved to GrProgramDesc (even if it
+ int keyLength = desc->fKey.count();
SkASSERT(0 == (keyLength % 4));
- *this->atOffset<uint32_t, kLengthOffset>() = SkToU32(keyLength);
+ *(desc->atOffset<uint32_t, GrProgramDesc::kLengthOffset>()) = SkToU32(keyLength);
- uint32_t* checksum = this->atOffset<uint32_t, kChecksumOffset>();
+ uint32_t* checksum = desc->atOffset<uint32_t, GrProgramDesc::kChecksumOffset>();
*checksum = 0;
- *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), keyLength);
+ *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(desc->fKey.begin()), keyLength);
}
-GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) {
- size_t keyLength = other.keyLength();
- fKey.reset(keyLength);
- memcpy(fKey.begin(), other.fKey.begin(), keyLength);
- return *this;
-}

Powered by Google App Engine
This is Rietveld 408576698