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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 17027003: Add flag bits for partial GrContext reset (Closed)
Patch Set: add flags for partial resetContext Created 7 years, 6 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 unified diff | Download patch
« include/gpu/GrContext.h ('K') | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(int 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::kGrState_Misc) {
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
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::kGrState_AA)
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::kGrState_Texture) {
331 fHWActiveTextureUnitIdx = -1;
332 for (int s = 0; s < fHWBoundTextures.count(); ++s) {
333 fHWBoundTextures[s] = NULL;
334 }
335 }
328 336
329 fHWBlendState.invalidate(); 337 if (resetBits & GrContext::kGrState_Blend)
338 fHWBlendState.invalidate();
330 339
340 if (resetBits & GrContext::kGrState_View) {
341 fHWScissorSettings.invalidate();
342 fHWViewport.invalidate();
343 }
344
345 if (resetBits & GrContext::kGrState_Stencil) {
346 fHWStencilSettings.invalidate();
347 fHWStencilTestEnabled = kUnknown_TriState;
348 }
349
350 // Vertex
351 if (resetBits & GrContext::kGrState_Vertex)
352 fHWGeometryState.invalidate();
353
354 if (resetBits & GrContext::kGrState_RenderTarget)
355 fHWBoundRenderTarget = NULL;
356
357 if (resetBits & GrContext::kGrState_PathStencil) {
358 fHWPathStencilMatrixState.invalidate();
359 if (this->caps()->pathStencilingSupport()) {
360 // we don't use the model view matrix.
361 GL_CALL(MatrixMode(GR_GL_MODELVIEW));
362 GL_CALL(LoadIdentity());
363 }
364 }
365
366 // we assume these values
367 if (resetBits & GrContext::kGrState_PixelStore) {
368 if (this->glCaps().unpackRowLengthSupport()) {
369 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
370 }
371 if (this->glCaps().packRowLengthSupport()) {
372 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
373 }
374 if (this->glCaps().unpackFlipYSupport()) {
375 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
376 }
377 if (this->glCaps().packFlipYSupport()) {
378 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE));
379 }
380 }
381
382 if (resetBits & GrContext::kGrState_Program) {
383 fHWProgramID = 0;
384 fSharedGLProgramState.invalidate();
385 }
386 }
387
388 void GrGpuGL::resetTextureBinding() {
331 for (int s = 0; s < fHWBoundTextures.count(); ++s) { 389 for (int s = 0; s < fHWBoundTextures.count(); ++s) {
332 fHWBoundTextures[s] = NULL; 390 fHWBoundTextures[s] = NULL;
333 } 391 }
334
335 fHWScissorSettings.invalidate();
336
337 fHWViewport.invalidate();
338
339 fHWStencilSettings.invalidate();
340 fHWStencilTestEnabled = kUnknown_TriState;
341
342 fHWGeometryState.invalidate();
343
344 fHWBoundRenderTarget = NULL;
345
346 fHWPathStencilMatrixState.invalidate();
347 if (this->caps()->pathStencilingSupport()) {
348 // we don't use the model view matrix.
349 GL_CALL(MatrixMode(GR_GL_MODELVIEW));
350 GL_CALL(LoadIdentity());
351 }
352
353 // we assume these values
354 if (this->glCaps().unpackRowLengthSupport()) {
355 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
356 }
357 if (this->glCaps().packRowLengthSupport()) {
358 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
359 }
360 if (this->glCaps().unpackFlipYSupport()) {
361 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
362 }
363 if (this->glCaps().packFlipYSupport()) {
364 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE));
365 }
366
367 fHWProgramID = 0;
368 fSharedGLProgramState.invalidate();
369 } 392 }
370 393
371 namespace { 394 namespace {
372 395
373 GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) { 396 GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) {
374 // By default, GrRenderTargets are GL's normal orientation so that they 397 // By default, GrRenderTargets are GL's normal orientation so that they
375 // can be drawn to by the outside world without the client having 398 // can be drawn to by the outside world without the client having
376 // to render upside down. 399 // to render upside down.
377 if (kDefault_GrSurfaceOrigin == origin) { 400 if (kDefault_GrSurfaceOrigin == origin) {
378 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; 401 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin;
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 this->setVertexArrayID(gpu, 0); 2518 this->setVertexArrayID(gpu, 0);
2496 } 2519 }
2497 int attrCount = gpu->glCaps().maxVertexAttributes(); 2520 int attrCount = gpu->glCaps().maxVertexAttributes();
2498 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2521 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2499 fDefaultVertexArrayAttribState.resize(attrCount); 2522 fDefaultVertexArrayAttribState.resize(attrCount);
2500 } 2523 }
2501 attribState = &fDefaultVertexArrayAttribState; 2524 attribState = &fDefaultVertexArrayAttribState;
2502 } 2525 }
2503 return attribState; 2526 return attribState;
2504 } 2527 }
OLDNEW
« include/gpu/GrContext.h ('K') | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698