OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); | 150 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); |
151 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); | 151 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); |
152 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); | 152 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); |
153 | 153 |
154 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope | 154 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope |
155 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); | 155 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); |
156 } | 156 } |
157 | 157 |
158 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
159 | 159 |
160 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions&
options, | 160 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, GrContext* context) { |
161 GrContext* context) { | |
162 SkAutoTUnref<const GrGLInterface> glInterface( | 161 SkAutoTUnref<const GrGLInterface> glInterface( |
163 reinterpret_cast<const GrGLInterface*>(backendContext)); | 162 reinterpret_cast<const GrGLInterface*>(backendContext)); |
164 if (!glInterface) { | 163 if (!glInterface) { |
165 glInterface.reset(GrGLDefaultInterface()); | 164 glInterface.reset(GrGLDefaultInterface()); |
166 } else { | 165 } else { |
167 glInterface->ref(); | 166 glInterface->ref(); |
168 } | 167 } |
169 if (!glInterface) { | 168 if (!glInterface) { |
170 return NULL; | 169 return NULL; |
171 } | 170 } |
172 GrGLContext* glContext = GrGLContext::Create(glInterface, options); | 171 GrGLContext* glContext = GrGLContext::Create(glInterface); |
173 if (glContext) { | 172 if (glContext) { |
174 return SkNEW_ARGS(GrGLGpu, (glContext, context)); | 173 return SkNEW_ARGS(GrGLGpu, (glContext, context)); |
175 } | 174 } |
176 return NULL; | 175 return NULL; |
177 } | 176 } |
178 | 177 |
179 static bool gPrintStartupSpew; | 178 static bool gPrintStartupSpew; |
180 | 179 |
181 GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) | 180 GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) |
182 : GrGpu(context) | 181 : GrGpu(context) |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 GrXferProcessor::BlendInfo blendInfo; | 1429 GrXferProcessor::BlendInfo blendInfo; |
1431 const GrPipeline& pipeline = *args.fPipeline; | 1430 const GrPipeline& pipeline = *args.fPipeline; |
1432 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); | 1431 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); |
1433 | 1432 |
1434 this->flushDither(pipeline.isDitherState()); | 1433 this->flushDither(pipeline.isDitherState()); |
1435 this->flushColorWrite(blendInfo.fWriteColor); | 1434 this->flushColorWrite(blendInfo.fWriteColor); |
1436 this->flushDrawFace(pipeline.getDrawFace()); | 1435 this->flushDrawFace(pipeline.getDrawFace()); |
1437 | 1436 |
1438 fCurrentProgram.reset(fProgramCache->getProgram(args)); | 1437 fCurrentProgram.reset(fProgramCache->getProgram(args)); |
1439 if (NULL == fCurrentProgram.get()) { | 1438 if (NULL == fCurrentProgram.get()) { |
1440 GrCapsDebugf(this->caps(), "Failed to create program!\n"); | 1439 GrContextDebugf(this->getContext(), "Failed to create program!\n"); |
1441 return false; | 1440 return false; |
1442 } | 1441 } |
1443 | 1442 |
1444 fCurrentProgram.get()->ref(); | 1443 fCurrentProgram.get()->ref(); |
1445 | 1444 |
1446 GrGLuint programID = fCurrentProgram->programID(); | 1445 GrGLuint programID = fCurrentProgram->programID(); |
1447 if (fHWProgramID != programID) { | 1446 if (fHWProgramID != programID) { |
1448 GL_CALL(UseProgram(programID)); | 1447 GL_CALL(UseProgram(programID)); |
1449 fHWProgramID = programID; | 1448 fHWProgramID = programID; |
1450 } | 1449 } |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 this->setVertexArrayID(gpu, 0); | 2890 this->setVertexArrayID(gpu, 0); |
2892 } | 2891 } |
2893 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2892 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2894 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2893 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2895 fDefaultVertexArrayAttribState.resize(attrCount); | 2894 fDefaultVertexArrayAttribState.resize(attrCount); |
2896 } | 2895 } |
2897 attribState = &fDefaultVertexArrayAttribState; | 2896 attribState = &fDefaultVertexArrayAttribState; |
2898 } | 2897 } |
2899 return attribState; | 2898 return attribState; |
2900 } | 2899 } |
OLD | NEW |