From 9b98c1b7d099249384782807731dd5f8256f3f60 Mon Sep 17 00:00:00 2001 From: "jvanverth@google.com" Date: Fri, 1 Mar 2013 18:54:50 +0000 Subject: Make global static variable kVertexAttribs in GrAARectRenderer local to functions. Chrome was choking on this static variable because it's global and initialized using a constructor. Moved it inside the two functions that use it, so it's no longer global. In addition, made the constructors for GrVertexAttrib inline so hopefully they will be optimized away. git-svn-id: http://skia.googlecode.com/svn/trunk@7930 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrAARectRenderer.cpp | 16 ++++++++++------ src/gpu/GrDrawState.h | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 741b83d080..9bf61958dd 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -30,12 +30,6 @@ static void set_inset_fan(GrPoint* pts, size_t stride, r.fRight - dx, r.fBottom - dy, stride); } -// position + color/coverage -static const GrVertexAttrib kVertexAttribs[] = { - GrVertexAttrib(kVec2f_GrVertexAttribType, 0), - GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) -}; - }; void GrAARectRenderer::reset() { @@ -134,6 +128,11 @@ void GrAARectRenderer::fillAARect(GrGpu* gpu, bool useVertexCoverage) { GrDrawState* drawState = target->drawState(); + // position + color/coverage + static const GrVertexAttrib kVertexAttribs[] = { + GrVertexAttrib(kVec2f_GrVertexAttribType, 0), + GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) + }; GrAttribBindings bindings; GrDrawState::AttribIndex attribIndex; aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex); @@ -213,6 +212,11 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, return; } + // position + color/coverage + static const GrVertexAttrib kVertexAttribs[] = { + GrVertexAttrib(kVec2f_GrVertexAttribType, 0), + GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) + }; GrAttribBindings bindings; GrDrawState::AttribIndex attribIndex; aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex); diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index 53c575d3af..b4d130648b 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -38,9 +38,9 @@ enum GrVertexAttribType { static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; struct GrVertexAttrib { - GrVertexAttrib() {} - GrVertexAttrib(GrVertexAttribType type, size_t offset) : - fType(type), fOffset(offset) {} + inline GrVertexAttrib() {} + inline GrVertexAttrib(GrVertexAttribType type, size_t offset) : + fType(type), fOffset(offset) {} bool operator==(const GrVertexAttrib& other) const { return fType == other.fType && fOffset == other.fOffset; }; -- cgit v1.2.3