aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpu.cpp
diff options
context:
space:
mode:
authorGravatar digit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-16 22:03:26 +0000
committerGravatar digit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-16 22:03:26 +0000
commit9b482c4d3312e33f852407889bbb86980936824c (patch)
tree4f7a3750efc25504f930ea0a5f8e9711d747fc67 /src/gpu/GrGpu.cpp
parent128cd221b1d4fc55d0a05362a22cc7a7cc74995d (diff)
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
Diffstat (limited to 'src/gpu/GrGpu.cpp')
-rw-r--r--src/gpu/GrGpu.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 57769e9f4e..a14de7361d 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -343,15 +343,17 @@ const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
////////////////////////////////////////////////////////////////////////////////
-// stencil settings to use when clip is in stencil
-GR_STATIC_CONST_SAME_STENCIL(gClipStencilSettings,
- kKeep_StencilOp,
- kKeep_StencilOp,
- kAlwaysIfInClip_StencilFunc,
- 0x0000,
- 0x0000,
- 0x0000);
-const GrStencilSettings& GrGpu::gClipStencilSettings = ::gClipStencilSettings;
+const GrStencilSettings* GrGpu::GetClipStencilSettings(void) {
+ // stencil settings to use when clip is in stencil
+ GR_STATIC_CONST_SAME_STENCIL_STRUCT(sClipStencilSettings,
+ kKeep_StencilOp,
+ kKeep_StencilOp,
+ kAlwaysIfInClip_StencilFunc,
+ 0x0000,
+ 0x0000,
+ 0x0000);
+ return GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&sClipStencilSettings);
+}
// mapping of clip-respecting stencil funcs to normal stencil funcs
// mapping depends on whether stencil-clipping is in effect.