| 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 "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 /////////////////////////////////////////////////////////////////////////////// | 280 /////////////////////////////////////////////////////////////////////////////// |
| 281 | 281 |
| 282 void GrGLGpu::onResetContext(uint32_t resetBits) { | 282 void GrGLGpu::onResetContext(uint32_t resetBits) { |
| 283 // we don't use the zb at all | 283 // we don't use the zb at all |
| 284 if (resetBits & kMisc_GrGLBackendState) { | 284 if (resetBits & kMisc_GrGLBackendState) { |
| 285 GL_CALL(Disable(GR_GL_DEPTH_TEST)); | 285 GL_CALL(Disable(GR_GL_DEPTH_TEST)); |
| 286 GL_CALL(DepthMask(GR_GL_FALSE)); | 286 GL_CALL(DepthMask(GR_GL_FALSE)); |
| 287 | 287 |
| 288 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; | 288 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; |
| 289 fHWDitherEnabled = kUnknown_TriState; | |
| 290 | 289 |
| 291 if (kGL_GrGLStandard == this->glStandard()) { | 290 if (kGL_GrGLStandard == this->glStandard()) { |
| 292 // Desktop-only state that we never change | 291 // Desktop-only state that we never change |
| 293 if (!this->glCaps().isCoreProfile()) { | 292 if (!this->glCaps().isCoreProfile()) { |
| 294 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); | 293 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); |
| 295 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); | 294 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); |
| 296 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); | 295 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); |
| 297 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); | 296 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); |
| 298 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); | 297 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); |
| 299 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP)); | 298 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 316 | 315 |
| 317 if (kGLES_GrGLStandard == this->glStandard() && | 316 if (kGLES_GrGLStandard == this->glStandard() && |
| 318 this->hasExtension("GL_ARM_shader_framebuffer_fetch")) { | 317 this->hasExtension("GL_ARM_shader_framebuffer_fetch")) { |
| 319 // The arm extension requires specifically enabling MSAA fetching pe
r sample. | 318 // The arm extension requires specifically enabling MSAA fetching pe
r sample. |
| 320 // On some devices this may have a perf hit. Also multiple render t
argets are disabled | 319 // On some devices this may have a perf hit. Also multiple render t
argets are disabled |
| 321 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); | 320 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); |
| 322 } | 321 } |
| 323 fHWWriteToColor = kUnknown_TriState; | 322 fHWWriteToColor = kUnknown_TriState; |
| 324 // we only ever use lines in hairline mode | 323 // we only ever use lines in hairline mode |
| 325 GL_CALL(LineWidth(1)); | 324 GL_CALL(LineWidth(1)); |
| 325 GL_CALL(Disable(GR_GL_DITHER)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 if (resetBits & kMSAAEnable_GrGLBackendState) { | 328 if (resetBits & kMSAAEnable_GrGLBackendState) { |
| 329 fMSAAEnabled = kUnknown_TriState; | 329 fMSAAEnabled = kUnknown_TriState; |
| 330 | 330 |
| 331 // In mixed samples mode coverage modulation allows the coverage to be c
onverted to | 331 // In mixed samples mode coverage modulation allows the coverage to be c
onverted to |
| 332 // "opacity", which can then be blended into the color buffer to accompl
ish antialiasing. | 332 // "opacity", which can then be blended into the color buffer to accompl
ish antialiasing. |
| 333 // Enable coverage modulation suitable for premultiplied alpha colors. | 333 // Enable coverage modulation suitable for premultiplied alpha colors. |
| 334 // This state has no effect when not rendering to a mixed sampled target
. | 334 // This state has no effect when not rendering to a mixed sampled target
. |
| 335 if (this->glCaps().shaderCaps()->mixedSamplesSupport()) { | 335 if (this->glCaps().shaderCaps()->mixedSamplesSupport()) { |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 | 1438 |
| 1439 // See fall through note above | 1439 // See fall through note above |
| 1440 this->disableScissor(); | 1440 this->disableScissor(); |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 bool GrGLGpu::flushGLState(const DrawArgs& args) { | 1443 bool GrGLGpu::flushGLState(const DrawArgs& args) { |
| 1444 GrXferProcessor::BlendInfo blendInfo; | 1444 GrXferProcessor::BlendInfo blendInfo; |
| 1445 const GrPipeline& pipeline = *args.fPipeline; | 1445 const GrPipeline& pipeline = *args.fPipeline; |
| 1446 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); | 1446 args.fPipeline->getXferProcessor()->getBlendInfo(&blendInfo); |
| 1447 | 1447 |
| 1448 this->flushDither(pipeline.isDitherState()); | |
| 1449 this->flushColorWrite(blendInfo.fWriteColor); | 1448 this->flushColorWrite(blendInfo.fWriteColor); |
| 1450 this->flushDrawFace(pipeline.getDrawFace()); | 1449 this->flushDrawFace(pipeline.getDrawFace()); |
| 1451 | 1450 |
| 1452 SkAutoTUnref<GrGLProgram> program(fProgramCache->refProgram(args)); | 1451 SkAutoTUnref<GrGLProgram> program(fProgramCache->refProgram(args)); |
| 1453 if (!program) { | 1452 if (!program) { |
| 1454 GrCapsDebugf(this->caps(), "Failed to create program!\n"); | 1453 GrCapsDebugf(this->caps(), "Failed to create program!\n"); |
| 1455 return false; | 1454 return false; |
| 1456 } | 1455 } |
| 1457 | 1456 |
| 1458 GrGLuint programID = program->programID(); | 1457 GrGLuint programID = program->programID(); |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi
zzle[3])); | 2336 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi
zzle[3])); |
| 2338 } else { | 2337 } else { |
| 2339 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL
int)); | 2338 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL
int)); |
| 2340 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara
ms.fSwizzleRGBA); | 2339 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara
ms.fSwizzleRGBA); |
| 2341 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA,
swizzle)); | 2340 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA,
swizzle)); |
| 2342 } | 2341 } |
| 2343 } | 2342 } |
| 2344 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); | 2343 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); |
| 2345 } | 2344 } |
| 2346 | 2345 |
| 2347 void GrGLGpu::flushDither(bool dither) { | |
| 2348 if (dither) { | |
| 2349 if (kYes_TriState != fHWDitherEnabled) { | |
| 2350 GL_CALL(Enable(GR_GL_DITHER)); | |
| 2351 fHWDitherEnabled = kYes_TriState; | |
| 2352 } | |
| 2353 } else { | |
| 2354 if (kNo_TriState != fHWDitherEnabled) { | |
| 2355 GL_CALL(Disable(GR_GL_DITHER)); | |
| 2356 fHWDitherEnabled = kNo_TriState; | |
| 2357 } | |
| 2358 } | |
| 2359 } | |
| 2360 | |
| 2361 void GrGLGpu::flushColorWrite(bool writeColor) { | 2346 void GrGLGpu::flushColorWrite(bool writeColor) { |
| 2362 if (!writeColor) { | 2347 if (!writeColor) { |
| 2363 if (kNo_TriState != fHWWriteToColor) { | 2348 if (kNo_TriState != fHWWriteToColor) { |
| 2364 GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, | 2349 GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, |
| 2365 GR_GL_FALSE, GR_GL_FALSE)); | 2350 GR_GL_FALSE, GR_GL_FALSE)); |
| 2366 fHWWriteToColor = kNo_TriState; | 2351 fHWWriteToColor = kNo_TriState; |
| 2367 } | 2352 } |
| 2368 } else { | 2353 } else { |
| 2369 if (kYes_TriState != fHWWriteToColor) { | 2354 if (kYes_TriState != fHWWriteToColor) { |
| 2370 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); | 2355 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 } | 2908 } |
| 2924 | 2909 |
| 2925 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); | 2910 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); |
| 2926 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); | 2911 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); |
| 2927 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); | 2912 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
| 2928 | 2913 |
| 2929 GrXferProcessor::BlendInfo blendInfo; | 2914 GrXferProcessor::BlendInfo blendInfo; |
| 2930 blendInfo.reset(); | 2915 blendInfo.reset(); |
| 2931 this->flushBlend(blendInfo); | 2916 this->flushBlend(blendInfo); |
| 2932 this->flushColorWrite(true); | 2917 this->flushColorWrite(true); |
| 2933 this->flushDither(false); | |
| 2934 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 2918 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 2935 this->flushHWAAState(dstRT, false); | 2919 this->flushHWAAState(dstRT, false); |
| 2936 this->disableScissor(); | 2920 this->disableScissor(); |
| 2937 GrStencilSettings stencil; | 2921 GrStencilSettings stencil; |
| 2938 stencil.setDisabled(); | 2922 stencil.setDisabled(); |
| 2939 this->flushStencil(stencil); | 2923 this->flushStencil(stencil); |
| 2940 | 2924 |
| 2941 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 2925 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
| 2942 } | 2926 } |
| 2943 | 2927 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3160 this->setVertexArrayID(gpu, 0); | 3144 this->setVertexArrayID(gpu, 0); |
| 3161 } | 3145 } |
| 3162 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3146 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3163 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3147 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3164 fDefaultVertexArrayAttribState.resize(attrCount); | 3148 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3165 } | 3149 } |
| 3166 attribState = &fDefaultVertexArrayAttribState; | 3150 attribState = &fDefaultVertexArrayAttribState; |
| 3167 } | 3151 } |
| 3168 return attribState; | 3152 return attribState; |
| 3169 } | 3153 } |
| OLD | NEW |