diff options
| author | 2014-01-02 16:46:18 -0800 | |
|---|---|---|
| committer | 2014-01-02 16:52:32 -0800 | |
| commit | 564acf7c9bff822f608cda0d5df0a64a9f9aaefd (patch) | |
| tree | 93a3203fc99098dedd4df5660c96d6800c97ae93 | |
| parent | e459367a3a49cbe94dfe38c50369431614dddc9c (diff) | |
Fix Clang warnings/errors
Fix several build warnings (struct != class, int != size_t) and errors
(variable leng non-POD arrays).
Change-Id: I70b4e784365514303d8954bfcb1f39d7c22c1321
| -rw-r--r-- | libs/hwui/AmbientShadow.cpp | 8 | ||||
| -rw-r--r-- | libs/hwui/Android.mk | 2 | ||||
| -rw-r--r-- | libs/hwui/DisplayList.cpp | 4 | ||||
| -rw-r--r-- | libs/hwui/Layer.h | 3 | ||||
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 14 | ||||
| -rw-r--r-- | libs/hwui/OpenGLRenderer.h | 8 | ||||
| -rw-r--r-- | libs/hwui/Patch.h | 3 | ||||
| -rw-r--r-- | libs/hwui/PathCache.h | 2 | ||||
| -rw-r--r-- | libs/hwui/PathTessellator.cpp | 4 | ||||
| -rw-r--r-- | libs/hwui/Program.cpp | 2 | ||||
| -rw-r--r-- | libs/hwui/Rect.h | 16 | ||||
| -rw-r--r-- | libs/hwui/Renderer.h | 2 | ||||
| -rw-r--r-- | libs/hwui/SkiaColorFilter.h | 12 | ||||
| -rw-r--r-- | libs/hwui/SkiaShader.h | 3 | ||||
| -rw-r--r-- | libs/hwui/Vertex.h | 3 |
15 files changed, 50 insertions, 36 deletions
diff --git a/libs/hwui/AmbientShadow.cpp b/libs/hwui/AmbientShadow.cpp index 923571efd541..1f5d26c4dad4 100644 --- a/libs/hwui/AmbientShadow.cpp +++ b/libs/hwui/AmbientShadow.cpp @@ -18,6 +18,7 @@ #include <math.h> #include <utils/Log.h> +#include <utils/Vector.h> #include "AmbientShadow.h" #include "Vertex.h" @@ -60,10 +61,11 @@ void AmbientShadow::createAmbientShadow(const Vector3* vertices, int vertexCount Vector2 centroid; calculatePolygonCentroid(vertices, vertexCount, centroid); - Vector2 dir[rays]; + Vector<Vector2> dir; // TODO: use C++11 unique_ptr + dir.setCapacity(rays); float rayDist[rays]; float rayHeight[rays]; - calculateRayDirections(rays, dir); + calculateRayDirections(rays, dir.editArray()); // Calculate the length and height of the points along the edge. // @@ -105,7 +107,7 @@ void AmbientShadow::createAmbientShadow(const Vector3* vertices, int vertexCount for (int i = 0; i < rays; i++) { Vector2 normal(1.0f, 0.0f); - calculateNormal(rays, i, dir, rayDist, normal); + calculateNormal(rays, i, dir.array(), rayDist, normal); float opacity = strength * (0.5f) / (1 + rayHeight[i] / heightFactor); diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk index 9d3123214fba..4f0d15a15361 100644 --- a/libs/hwui/Android.mk +++ b/libs/hwui/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) # Only build libhwui when USE_OPENGL_RENDERER is # defined in the current device/board configuration ifeq ($(USE_OPENGL_RENDERER),true) - LOCAL_SRC_FILES:= \ + LOCAL_SRC_FILES := \ utils/Blur.cpp \ utils/SortedListImpl.cpp \ thread/TaskManager.cpp \ diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp index caed2b17f723..2fe141b156d4 100644 --- a/libs/hwui/DisplayList.cpp +++ b/libs/hwui/DisplayList.cpp @@ -610,14 +610,14 @@ void DisplayList::iterate3dChildren(ChildrenSelectMode mode, OpenGLRenderer& ren handler(op, PROPERTY_SAVECOUNT, mClipToBounds); int rootRestoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); - for (int i = 0; i < m3dNodes.size(); i++) { + for (size_t i = 0; i < m3dNodes.size(); i++) { const float zValue = m3dNodes.keyAt(i); if (mode == kPositiveZChildren && zValue < 0.0f) continue; if (mode == kNegativeZChildren && zValue > 0.0f) break; const Vector<DrawDisplayListOp*>& nodesAtZ = m3dNodes[i]; - for (int j = 0; j < nodesAtZ.size(); j++) { + for (size_t j = 0; j < nodesAtZ.size(); j++) { DrawDisplayListOp* op = nodesAtZ[j]; if (mode == kPositiveZChildren) { /* draw shadow on renderer with parent matrix applied, passing in the child's total matrix diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index b70042f33155..471a4a6084c1 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -49,7 +49,8 @@ class DeferStateStruct; /** * A layer has dimensions and is backed by an OpenGL texture or FBO. */ -struct Layer { +class Layer { +public: Layer(const uint32_t layerWidth, const uint32_t layerHeight); ~Layer(); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index ac4e71dbd145..545d3b6270ec 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1795,7 +1795,8 @@ void OpenGLRenderer::setupDrawTextureTransformUniforms(mat4& transform) { GL_FALSE, &transform.data[0]); } -void OpenGLRenderer::setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLuint vbo) { +void OpenGLRenderer::setupDrawMesh(const GLvoid* vertices, + const GLvoid* texCoords, GLuint vbo) { bool force = false; if (!vertices || vbo) { force = mCaches.bindMeshBuffer(vbo == 0 ? mCaches.meshBuffer : vbo); @@ -1811,7 +1812,8 @@ void OpenGLRenderer::setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLuint v mCaches.unbindIndicesBuffer(); } -void OpenGLRenderer::setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLvoid* colors) { +void OpenGLRenderer::setupDrawMesh(const GLvoid* vertices, + const GLvoid* texCoords, const GLvoid* colors) { bool force = mCaches.unbindMeshBuffer(); GLsizei stride = sizeof(ColorTextureVertex); @@ -1828,7 +1830,8 @@ void OpenGLRenderer::setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLvoid* mCaches.unbindIndicesBuffer(); } -void OpenGLRenderer::setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords, GLuint vbo) { +void OpenGLRenderer::setupDrawMeshIndices(const GLvoid* vertices, + const GLvoid* texCoords, GLuint vbo) { bool force = false; // If vbo is != 0 we want to treat the vertices parameter as an offset inside // a VBO. However, if vertices is set to NULL and vbo == 0 then we want to @@ -2049,8 +2052,9 @@ status_t OpenGLRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int mes const uint32_t count = meshWidth * meshHeight * 6; - ColorTextureVertex mesh[count]; - ColorTextureVertex* vertex = mesh; + Vector<ColorTextureVertex> mesh; // TODO: use C++11 unique_ptr + mesh.setCapacity(count); + ColorTextureVertex* vertex = mesh.editArray(); bool cleanupColors = false; if (!colors) { diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index b4725d4e9b23..ceb0dfd2df96 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -861,7 +861,7 @@ private: * transformations are stored in the modelView matrix and uploaded to the shader. * * @param offset Set to true if the the matrix should be fudged (translated) slightly to disambiguate - * geometry pixel positioning. See Vertex::gGeometryFudgeFactor. + * geometry pixel positioning. See Vertex::GeometryFudgeFactor(). * * @param ignoreTransform Set to true if l,t,r,b coordinates already in layer space, * currentTransform() will be ignored. (e.g. when drawing clip in layer coordinates to stencil, @@ -879,9 +879,9 @@ private: void setupDrawTextureTransform(); void setupDrawTextureTransformUniforms(mat4& transform); void setupDrawTextGammaUniforms(); - void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0); - void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLvoid* colors); - void setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords, GLuint vbo = 0); + void setupDrawMesh(const GLvoid* vertices, const GLvoid* texCoords = NULL, GLuint vbo = 0); + void setupDrawMesh(const GLvoid* vertices, const GLvoid* texCoords, const GLvoid* colors); + void setupDrawMeshIndices(const GLvoid* vertices, const GLvoid* texCoords, GLuint vbo = 0); void setupDrawIndexedVertices(GLvoid* vertices); void accountForClear(SkXfermode::Mode mode); diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h index 763a78565dec..489064b07cca 100644 --- a/libs/hwui/Patch.h +++ b/libs/hwui/Patch.h @@ -36,7 +36,8 @@ namespace uirenderer { // 9-patch structures /////////////////////////////////////////////////////////////////////////////// -struct Patch { +class Patch { +public: Patch(); ~Patch(); diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h index 16d20a81c199..721e6691be69 100644 --- a/libs/hwui/PathCache.h +++ b/libs/hwui/PathCache.h @@ -32,7 +32,7 @@ class SkBitmap; class SkCanvas; class SkPaint; class SkPath; -class SkRect; +struct SkRect; namespace android { namespace uirenderer { diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp index fd2f636e5aa3..e366a046ca9f 100644 --- a/libs/hwui/PathTessellator.cpp +++ b/libs/hwui/PathTessellator.cpp @@ -162,8 +162,8 @@ public: void expandBoundsForStrokeAA(SkRect& bounds) const { float outset = halfStrokeWidth; if (outset == 0) outset = 0.5f; - bounds.outset(outset * inverseScaleX + Vertex::gGeometryFudgeFactor, - outset * inverseScaleY + Vertex::gGeometryFudgeFactor); + bounds.outset(outset * inverseScaleX + Vertex::GeometryFudgeFactor(), + outset * inverseScaleY + Vertex::GeometryFudgeFactor()); } }; diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp index 7814a01ad929..a679552aa757 100644 --- a/libs/hwui/Program.cpp +++ b/libs/hwui/Program.cpp @@ -173,7 +173,7 @@ void Program::set(const mat4& projectionMatrix, const mat4& modelViewMatrix, // up and to the left. // This offset value is based on an assumption that some hardware may use as // little as 12.4 precision, so we offset by slightly more than 1/16. - p.translate(Vertex::gGeometryFudgeFactor, Vertex::gGeometryFudgeFactor); + p.translate(Vertex::GeometryFudgeFactor(), Vertex::GeometryFudgeFactor()); glUniformMatrix4fv(projection, 1, GL_FALSE, &p.data[0]); } mProjection = projectionMatrix; diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index 83b3436fae2f..c2301490c26f 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -190,19 +190,19 @@ public: * from this inset will only incur similarly small errors in output, due to transparency * in extreme outside of the geometry. */ - left = floorf(left + Vertex::gGeometryFudgeFactor); - top = floorf(top + Vertex::gGeometryFudgeFactor); - right = ceilf(right - Vertex::gGeometryFudgeFactor); - bottom = ceilf(bottom - Vertex::gGeometryFudgeFactor); + left = floorf(left + Vertex::GeometryFudgeFactor()); + top = floorf(top + Vertex::GeometryFudgeFactor()); + right = ceilf(right - Vertex::GeometryFudgeFactor()); + bottom = ceilf(bottom - Vertex::GeometryFudgeFactor()); } else { /* For other geometry, we do the regular rounding in order to snap, but also outset the * bounds by a fudge factor. This ensures that ambiguous geometry (e.g. a non-AA Rect * with top left at (0.5, 0.5)) will err on the side of a larger damage rect. */ - left = floorf(left + 0.5f - Vertex::gGeometryFudgeFactor); - top = floorf(top + 0.5f - Vertex::gGeometryFudgeFactor); - right = floorf(right + 0.5f + Vertex::gGeometryFudgeFactor); - bottom = floorf(bottom + 0.5f + Vertex::gGeometryFudgeFactor); + left = floorf(left + 0.5f - Vertex::GeometryFudgeFactor()); + top = floorf(top + 0.5f - Vertex::GeometryFudgeFactor()); + right = floorf(right + 0.5f + Vertex::GeometryFudgeFactor()); + bottom = floorf(bottom + 0.5f + Vertex::GeometryFudgeFactor()); } } diff --git a/libs/hwui/Renderer.h b/libs/hwui/Renderer.h index faf663a60390..3f57873b59f9 100644 --- a/libs/hwui/Renderer.h +++ b/libs/hwui/Renderer.h @@ -27,7 +27,7 @@ namespace android { class Functor; -class Res_png_9patch; +struct Res_png_9patch; namespace uirenderer { diff --git a/libs/hwui/SkiaColorFilter.h b/libs/hwui/SkiaColorFilter.h index 2feb834e540c..c222a2d3418e 100644 --- a/libs/hwui/SkiaColorFilter.h +++ b/libs/hwui/SkiaColorFilter.h @@ -36,7 +36,8 @@ namespace uirenderer { * Represents a Skia color filter. A color filter modifies a ProgramDescription * and sets uniforms on the resulting shaders. */ -struct SkiaColorFilter { +class SkiaColorFilter { +public: /** * Type of Skia color filter in use. */ @@ -80,7 +81,8 @@ private: /** * A color filter that multiplies the source color with a matrix and adds a vector. */ -struct SkiaColorMatrixFilter: public SkiaColorFilter { +class SkiaColorMatrixFilter: public SkiaColorFilter { +public: ANDROID_API SkiaColorMatrixFilter(SkColorFilter *skFilter, float* matrix, float* vector); ~SkiaColorMatrixFilter(); @@ -96,7 +98,8 @@ private: * A color filters that multiplies the source color with a fixed value and adds * another fixed value. Ignores the alpha channel of both arguments. */ -struct SkiaLightingFilter: public SkiaColorFilter { +class SkiaLightingFilter: public SkiaColorFilter { +public: ANDROID_API SkiaLightingFilter(SkColorFilter *skFilter, int multiply, int add); void describe(ProgramDescription& description, const Extensions& extensions); @@ -111,7 +114,8 @@ private: * A color filters that blends the source color with a specified destination color * and PorterDuff blending mode. */ -struct SkiaBlendFilter: public SkiaColorFilter { +class SkiaBlendFilter: public SkiaColorFilter { +public: ANDROID_API SkiaBlendFilter(SkColorFilter *skFilter, int color, SkXfermode::Mode mode); void describe(ProgramDescription& description, const Extensions& extensions); diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h index 9fc99a47aca5..d71f8ee5fcdc 100644 --- a/libs/hwui/SkiaShader.h +++ b/libs/hwui/SkiaShader.h @@ -43,7 +43,8 @@ class Caches; * Represents a Skia shader. A shader will modify the GL context and active * program to recreate the original effect. */ -struct SkiaShader { +class SkiaShader { +public: /** * Type of Skia shader in use. */ diff --git a/libs/hwui/Vertex.h b/libs/hwui/Vertex.h index 351ce71bbc00..5d7a19921e35 100644 --- a/libs/hwui/Vertex.h +++ b/libs/hwui/Vertex.h @@ -33,7 +33,8 @@ struct Vertex { * Program::set()), and used to make geometry damage rect calculation conservative (see * Rect::snapGeometryToPixelBoundaries()) */ - static const float gGeometryFudgeFactor = 0.0656f; + static float GeometryFudgeFactor() { return 0.0656f; } + float x, y; |