Chromium Code Reviews| 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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 } | 277 } |
| 278 } else { | 278 } else { |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const { | 283 bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const { |
| 284 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL); | 284 return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void GrGpuGL::onResetContext() { | 287 void GrGpuGL::onResetContext(uint32_t resetBits) { |
| 288 | 288 |
| 289 // we don't use the zb at all | 289 // we don't use the zb at all |
| 290 GL_CALL(Disable(GR_GL_DEPTH_TEST)); | 290 if (resetBits & GrContext::kMisc_GLBackendState) { |
| 291 GL_CALL(DepthMask(GR_GL_FALSE)); | 291 GL_CALL(Disable(GR_GL_DEPTH_TEST)); |
| 292 GL_CALL(DepthMask(GR_GL_FALSE)); | |
| 292 | 293 |
| 293 fHWDrawFace = GrDrawState::kInvalid_DrawFace; | 294 fHWDrawFace = GrDrawState::kInvalid_DrawFace; |
| 294 fHWDitherEnabled = kUnknown_TriState; | 295 fHWDitherEnabled = kUnknown_TriState; |
| 295 | 296 |
| 296 if (kDesktop_GrGLBinding == this->glBinding()) { | 297 if (kDesktop_GrGLBinding == this->glBinding()) { |
| 297 // Desktop-only state that we never change | 298 // Desktop-only state that we never change |
| 298 if (!this->glCaps().isCoreProfile()) { | 299 if (!this->glCaps().isCoreProfile()) { |
| 299 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); | 300 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); |
| 300 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); | 301 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); |
| 301 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); | 302 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); |
| 302 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); | 303 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); |
| 303 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); | 304 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); |
| 304 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP)); | 305 GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP)); |
| 306 } | |
| 307 // The windows NVIDIA driver has GL_ARB_imaging in the extension str ing when using a core | |
|
bsalomon
2013/06/26 19:03:07
Nit: can you wrap this comment to 100 col lines?
| |
| 308 // profile. This seems like a bug since the core spec removes any me ntion of GL_ARB_imaging. | |
| 309 if (this->glCaps().imagingSupport() && !this->glCaps().isCoreProfile ()) { | |
| 310 GL_CALL(Disable(GR_GL_COLOR_TABLE)); | |
| 311 } | |
| 312 GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL)); | |
| 313 // Since ES doesn't support glPointSize at all we always use the VS to | |
| 314 // set the point size | |
| 315 GL_CALL(Enable(GR_GL_VERTEX_PROGRAM_POINT_SIZE)); | |
| 316 | |
| 317 // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It is n't | |
| 318 // currently part of our gl interface. There are probably others as | |
| 319 // well. | |
| 305 } | 320 } |
| 306 // The windows NVIDIA driver has GL_ARB_imaging in the extension string when using a core | 321 fHWWriteToColor = kUnknown_TriState; |
| 307 // profile. This seems like a bug since the core spec removes any mentio n of GL_ARB_imaging. | 322 // we only ever use lines in hairline mode |
| 308 if (this->glCaps().imagingSupport() && !this->glCaps().isCoreProfile()) { | 323 GL_CALL(LineWidth(1)); |
| 309 GL_CALL(Disable(GR_GL_COLOR_TABLE)); | 324 } |
| 310 } | |
| 311 GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL)); | |
| 312 // Since ES doesn't support glPointSize at all we always use the VS to | |
| 313 // set the point size | |
| 314 GL_CALL(Enable(GR_GL_VERTEX_PROGRAM_POINT_SIZE)); | |
| 315 | 325 |
| 316 // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It isn't | 326 if (resetBits & GrContext::kAA_GLBackendState) |
| 317 // currently part of our gl interface. There are probably others as | 327 fHWAAState.invalidate(); |
| 318 // well. | |
| 319 } | |
| 320 fHWAAState.invalidate(); | |
| 321 fHWWriteToColor = kUnknown_TriState; | |
| 322 | |
| 323 // we only ever use lines in hairline mode | |
| 324 GL_CALL(LineWidth(1)); | |
| 325 | 328 |
| 326 // invalid | 329 // invalid |
| 327 fHWActiveTextureUnitIdx = -1; | 330 if (resetBits & GrContext::kTextureBinding_GLBackendState) { |
| 328 | 331 fHWActiveTextureUnitIdx = -1; |
| 329 fHWBlendState.invalidate(); | 332 for (int s = 0; s < fHWBoundTextures.count(); ++s) { |
| 330 | 333 fHWBoundTextures[s] = NULL; |
| 331 for (int s = 0; s < fHWBoundTextures.count(); ++s) { | 334 } |
| 332 fHWBoundTextures[s] = NULL; | |
| 333 } | 335 } |
| 334 | 336 |
| 335 fHWScissorSettings.invalidate(); | 337 if (resetBits & GrContext::kBlend_GLBackendState) |
| 338 fHWBlendState.invalidate(); | |
| 336 | 339 |
| 337 fHWViewport.invalidate(); | 340 if (resetBits & GrContext::kView_GLBackendState) { |
| 341 fHWScissorSettings.invalidate(); | |
| 342 fHWViewport.invalidate(); | |
| 343 } | |
| 338 | 344 |
| 339 fHWStencilSettings.invalidate(); | 345 if (resetBits & GrContext::kStencil_GLBackendState) { |
| 340 fHWStencilTestEnabled = kUnknown_TriState; | 346 fHWStencilSettings.invalidate(); |
| 347 fHWStencilTestEnabled = kUnknown_TriState; | |
| 348 } | |
| 341 | 349 |
| 342 fHWGeometryState.invalidate(); | 350 // Vertex |
| 351 if (resetBits & GrContext::kVertex_GLBackendState) | |
| 352 fHWGeometryState.invalidate(); | |
| 343 | 353 |
| 344 fHWBoundRenderTarget = NULL; | 354 if (resetBits & GrContext::kRenderTarget_GLBackendState) |
| 355 fHWBoundRenderTarget = NULL; | |
| 345 | 356 |
| 346 fHWPathStencilMatrixState.invalidate(); | 357 if (resetBits & GrContext::kPathStencil_GLBackendState) { |
| 347 if (this->caps()->pathStencilingSupport()) { | 358 fHWPathStencilMatrixState.invalidate(); |
| 348 // we don't use the model view matrix. | 359 if (this->caps()->pathStencilingSupport()) { |
| 349 GL_CALL(MatrixMode(GR_GL_MODELVIEW)); | 360 // we don't use the model view matrix. |
| 350 GL_CALL(LoadIdentity()); | 361 GL_CALL(MatrixMode(GR_GL_MODELVIEW)); |
| 362 GL_CALL(LoadIdentity()); | |
| 363 } | |
| 351 } | 364 } |
| 352 | 365 |
| 353 // we assume these values | 366 // we assume these values |
| 354 if (this->glCaps().unpackRowLengthSupport()) { | 367 if (resetBits & GrContext::kPixelStore_GLBackendState) { |
| 355 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); | 368 if (this->glCaps().unpackRowLengthSupport()) { |
| 356 } | 369 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); |
| 357 if (this->glCaps().packRowLengthSupport()) { | 370 } |
| 358 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0)); | 371 if (this->glCaps().packRowLengthSupport()) { |
| 359 } | 372 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0)); |
| 360 if (this->glCaps().unpackFlipYSupport()) { | 373 } |
| 361 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); | 374 if (this->glCaps().unpackFlipYSupport()) { |
| 362 } | 375 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); |
| 363 if (this->glCaps().packFlipYSupport()) { | 376 } |
| 364 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE)); | 377 if (this->glCaps().packFlipYSupport()) { |
| 378 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE)); | |
| 379 } | |
| 365 } | 380 } |
| 366 | 381 |
| 367 fHWProgramID = 0; | 382 if (resetBits & GrContext::kProgram_GLBackendState) { |
| 368 fSharedGLProgramState.invalidate(); | 383 fHWProgramID = 0; |
| 384 fSharedGLProgramState.invalidate(); | |
| 385 } | |
| 369 } | 386 } |
| 370 | 387 |
| 371 namespace { | 388 namespace { |
| 372 | 389 |
| 373 GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) { | 390 GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) { |
| 374 // By default, GrRenderTargets are GL's normal orientation so that they | 391 // By default, GrRenderTargets are GL's normal orientation so that they |
| 375 // can be drawn to by the outside world without the client having | 392 // can be drawn to by the outside world without the client having |
| 376 // to render upside down. | 393 // to render upside down. |
| 377 if (kDefault_GrSurfaceOrigin == origin) { | 394 if (kDefault_GrSurfaceOrigin == origin) { |
| 378 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; | 395 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; |
| (...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2495 this->setVertexArrayID(gpu, 0); | 2512 this->setVertexArrayID(gpu, 0); |
| 2496 } | 2513 } |
| 2497 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2514 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2498 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2515 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2499 fDefaultVertexArrayAttribState.resize(attrCount); | 2516 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2500 } | 2517 } |
| 2501 attribState = &fDefaultVertexArrayAttribState; | 2518 attribState = &fDefaultVertexArrayAttribState; |
| 2502 } | 2519 } |
| 2503 return attribState; | 2520 return attribState; |
| 2504 } | 2521 } |
| OLD | NEW |