Remove on static initializer in GrGpu.cpp
authordigit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 16 Feb 2012 22:03:26 +0000 (22:03 +0000)
committerdigit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 16 Feb 2012 22:03:26 +0000 (22:03 +0000)
commit9b482c4d3312e33f852407889bbb86980936824c
tree4f7a3750efc25504f930ea0a5f8e9711d747fc67
parent128cd221b1d4fc55d0a05362a22cc7a7cc74995d
Remove on static initializer in GrGpu.cpp

This is another go for the patch that was initially
submitted at http://codereview.appspot.com/5504073/ but
crashed the 'gm' unit test.

A problem with the previous implementation is that the
GrStencilSettings ::isDisabled() and ::doesWrite() methods can
modify the object's fFlags member if it is 0, and this will
crash at runtime when doing this for a static constant
object/structure.

I'm not sure why this wasn't triggered previously.

We solve the issue by modifying the implementation of
GR_STATIC_CONST_STENCIL and GR_STATIC_CONST_STENCIL macros to
compute the correct default values for fFlags (which prevents
any member modifications in the above methods).

This requires moving the definition of the disabled/write flags
out of the GrStencilSettings class definition's private section.
Note that the flags are renamed to avoid any confusion and
conflicts, i.e.:

  SkIsDisabled_Flag  -> SkIsDisabled_StencilFlag
  SkNotDisabled_Flag -> SkNotDisabled_StencilFlag
  ...
Review URL: https://codereview.appspot.com/5616051

git-svn-id: http://skia.googlecode.com/svn/trunk@3214 2bbb7eff-a529-9590-31e7-b0007b416f81
src/gpu/GrGpu.cpp
src/gpu/GrGpu.h
src/gpu/GrStencil.h
src/gpu/gl/GrGpuGL.cpp