Loading libs/hwui/Caches.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ void Caches::initStaticProperties() { gpuPixelBuffersEnabled = false; // OpenGL ES 3.0+ specific features if (mExtensions.getMajorGlVersion() >= 3) { if (mExtensions.hasPixelBufferObjects()) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, property, "true") > 0) { gpuPixelBuffersEnabled = !strcmp(property, "true"); Loading libs/hwui/Dither.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ Dither::Dither(): mCaches(NULL), mInitialized(false), mDitherTexture(0) { void Dither::bindDitherTexture() { if (!mInitialized) { bool useFloatTexture = Extensions::getInstance().getMajorGlVersion() >= 3; bool useFloatTexture = Extensions::getInstance().hasFloatTextures(); glGenTextures(1, &mDitherTexture); mCaches->bindTexture(mDitherTexture); Loading libs/hwui/Extensions.h +4 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ public: inline bool has4BitStencil() const { return mHas4BitStencil; } inline bool hasNvSystemTime() const { return mHasNvSystemTime; } inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; } inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; } inline bool hasFloatTextures() const { return mVersionMajor >= 3; } inline int getMajorGlVersion() const { return mVersionMajor; } inline int getMinorGlVersion() const { return mVersionMinor; } Loading libs/hwui/GradientCache.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ GradientCache::GradientCache(): mCache.setOnEntryRemovedListener(this); const Extensions& extensions = Extensions::getInstance(); mUseFloatTexture = extensions.getMajorGlVersion() >= 3; mUseFloatTexture = extensions.hasFloatTextures(); mHasNpot = extensions.hasNPot(); } Loading libs/hwui/Query.h 0 → 100644 +152 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HWUI_QUERY_H #define ANDROID_HWUI_QUERY_H #include <GLES3/gl3.h> #include "Extensions.h" namespace android { namespace uirenderer { /** * A Query instance can be used to perform occlusion queries. If the device * does not support occlusion queries, the result of a query will always be * 0 and the result will always be marked available. * * To run an occlusion query successfully, you must start end end the query: * * Query query; * query.begin(); * // execute OpenGL calls * query.end(); * GLuint result = query.getResult(); */ class Query { public: /** * Possible query targets. */ enum Target { /** * Indicates if any sample passed the depth & stencil tests. */ kTargetSamples = GL_ANY_SAMPLES_PASSED, /** * Indicates if any sample passed the depth & stencil tests. * The implementation may choose to use a less precise version * of the test, potentially resulting in false positives. */ kTargetConservativeSamples = GL_ANY_SAMPLES_PASSED_CONSERVATIVE, }; /** * Creates a new query with the specified target. The default * target is kTargetSamples (of GL_ANY_SAMPLES_PASSED in OpenGL.) */ Query(Target target = kTargetSamples): mActive(false), mTarget(target), mCanQuery(Extensions::getInstance().hasOcclusionQueries()), mQuery(0) { } ~Query() { if (mQuery) { glDeleteQueries(1, &mQuery); } } /** * Begins the query. If the query has already begun or if the device * does not support occlusion queries, calling this method as no effect. * After calling this method successfully, the query is marked active. */ void begin() { if (!mActive && mCanQuery) { if (!mQuery) { glGenQueries(1, &mQuery); } glBeginQuery(mTarget, mQuery); mActive = true; } } /** * Ends the query. If the query has already begun or if the device * does not support occlusion queries, calling this method as no effect. * After calling this method successfully, the query is marked inactive. */ void end() { if (mQuery && mActive) { glEndQuery(mTarget); mActive = false; } } /** * Returns true if the query is active, false otherwise. */ bool isActive() { return mActive; } /** * Returns true if the result of the query is available, * false otherwise. Calling getResult() before the result * is available may result in the calling thread being blocked. * If the device does not support queries, this method always * returns true. */ bool isResultAvailable() { if (!mQuery) return true; GLuint result; glGetQueryObjectuiv(mQuery, GL_QUERY_RESULT_AVAILABLE, &result); return result == GL_TRUE; } /** * Returns the result of the query. If the device does not * support queries this method will return 0. * * Calling this method implicitely calls end() if the query * is currently active. */ GLuint getResult() { if (!mQuery) return 0; end(); GLuint result; glGetQueryObjectuiv(mQuery, GL_QUERY_RESULT, &result); return result; } private: bool mActive; GLenum mTarget; bool mCanQuery; GLuint mQuery; }; // class Query }; // namespace uirenderer }; // namespace android #endif // ANDROID_HWUI_QUERY_H Loading
libs/hwui/Caches.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ void Caches::initStaticProperties() { gpuPixelBuffersEnabled = false; // OpenGL ES 3.0+ specific features if (mExtensions.getMajorGlVersion() >= 3) { if (mExtensions.hasPixelBufferObjects()) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, property, "true") > 0) { gpuPixelBuffersEnabled = !strcmp(property, "true"); Loading
libs/hwui/Dither.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ Dither::Dither(): mCaches(NULL), mInitialized(false), mDitherTexture(0) { void Dither::bindDitherTexture() { if (!mInitialized) { bool useFloatTexture = Extensions::getInstance().getMajorGlVersion() >= 3; bool useFloatTexture = Extensions::getInstance().hasFloatTextures(); glGenTextures(1, &mDitherTexture); mCaches->bindTexture(mDitherTexture); Loading
libs/hwui/Extensions.h +4 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ public: inline bool has4BitStencil() const { return mHas4BitStencil; } inline bool hasNvSystemTime() const { return mHasNvSystemTime; } inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; } inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; } inline bool hasFloatTextures() const { return mVersionMajor >= 3; } inline int getMajorGlVersion() const { return mVersionMajor; } inline int getMinorGlVersion() const { return mVersionMinor; } Loading
libs/hwui/GradientCache.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ GradientCache::GradientCache(): mCache.setOnEntryRemovedListener(this); const Extensions& extensions = Extensions::getInstance(); mUseFloatTexture = extensions.getMajorGlVersion() >= 3; mUseFloatTexture = extensions.hasFloatTextures(); mHasNpot = extensions.hasNPot(); } Loading
libs/hwui/Query.h 0 → 100644 +152 −0 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HWUI_QUERY_H #define ANDROID_HWUI_QUERY_H #include <GLES3/gl3.h> #include "Extensions.h" namespace android { namespace uirenderer { /** * A Query instance can be used to perform occlusion queries. If the device * does not support occlusion queries, the result of a query will always be * 0 and the result will always be marked available. * * To run an occlusion query successfully, you must start end end the query: * * Query query; * query.begin(); * // execute OpenGL calls * query.end(); * GLuint result = query.getResult(); */ class Query { public: /** * Possible query targets. */ enum Target { /** * Indicates if any sample passed the depth & stencil tests. */ kTargetSamples = GL_ANY_SAMPLES_PASSED, /** * Indicates if any sample passed the depth & stencil tests. * The implementation may choose to use a less precise version * of the test, potentially resulting in false positives. */ kTargetConservativeSamples = GL_ANY_SAMPLES_PASSED_CONSERVATIVE, }; /** * Creates a new query with the specified target. The default * target is kTargetSamples (of GL_ANY_SAMPLES_PASSED in OpenGL.) */ Query(Target target = kTargetSamples): mActive(false), mTarget(target), mCanQuery(Extensions::getInstance().hasOcclusionQueries()), mQuery(0) { } ~Query() { if (mQuery) { glDeleteQueries(1, &mQuery); } } /** * Begins the query. If the query has already begun or if the device * does not support occlusion queries, calling this method as no effect. * After calling this method successfully, the query is marked active. */ void begin() { if (!mActive && mCanQuery) { if (!mQuery) { glGenQueries(1, &mQuery); } glBeginQuery(mTarget, mQuery); mActive = true; } } /** * Ends the query. If the query has already begun or if the device * does not support occlusion queries, calling this method as no effect. * After calling this method successfully, the query is marked inactive. */ void end() { if (mQuery && mActive) { glEndQuery(mTarget); mActive = false; } } /** * Returns true if the query is active, false otherwise. */ bool isActive() { return mActive; } /** * Returns true if the result of the query is available, * false otherwise. Calling getResult() before the result * is available may result in the calling thread being blocked. * If the device does not support queries, this method always * returns true. */ bool isResultAvailable() { if (!mQuery) return true; GLuint result; glGetQueryObjectuiv(mQuery, GL_QUERY_RESULT_AVAILABLE, &result); return result == GL_TRUE; } /** * Returns the result of the query. If the device does not * support queries this method will return 0. * * Calling this method implicitely calls end() if the query * is currently active. */ GLuint getResult() { if (!mQuery) return 0; end(); GLuint result; glGetQueryObjectuiv(mQuery, GL_QUERY_RESULT, &result); return result; } private: bool mActive; GLenum mTarget; bool mCanQuery; GLuint mQuery; }; // class Query }; // namespace uirenderer }; // namespace android #endif // ANDROID_HWUI_QUERY_H