Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
diff --git a/libs/hwui/renderstate/Blend.cpp b/libs/hwui/renderstate/Blend.cpp
index b1ca4a2..5bef01c 100644
--- a/libs/hwui/renderstate/Blend.cpp
+++ b/libs/hwui/renderstate/Blend.cpp
@@ -52,49 +52,42 @@
// In this array, the index of each Blender equals the value of the first
// entry. For instance, gBlends[1] == gBlends[SkBlendMode::kSrc]
-const Blender kBlends[] = {
- { SkBlendMode::kClear, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kSrc, GL_ONE, GL_ZERO },
- { SkBlendMode::kDst, GL_ZERO, GL_ONE },
- { SkBlendMode::kSrcOver, GL_ONE, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kDstOver, GL_ONE_MINUS_DST_ALPHA, GL_ONE },
- { SkBlendMode::kSrcIn, GL_DST_ALPHA, GL_ZERO },
- { SkBlendMode::kDstIn, GL_ZERO, GL_SRC_ALPHA },
- { SkBlendMode::kSrcOut, GL_ONE_MINUS_DST_ALPHA, GL_ZERO },
- { SkBlendMode::kDstOut, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kSrcATop, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kDstATop, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA },
- { SkBlendMode::kXor, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kPlus, GL_ONE, GL_ONE },
- { SkBlendMode::kModulate, GL_ZERO, GL_SRC_COLOR },
- { SkBlendMode::kScreen, GL_ONE, GL_ONE_MINUS_SRC_COLOR }
-};
+const Blender kBlends[] = {{SkBlendMode::kClear, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kSrc, GL_ONE, GL_ZERO},
+ {SkBlendMode::kDst, GL_ZERO, GL_ONE},
+ {SkBlendMode::kSrcOver, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kDstOver, GL_ONE_MINUS_DST_ALPHA, GL_ONE},
+ {SkBlendMode::kSrcIn, GL_DST_ALPHA, GL_ZERO},
+ {SkBlendMode::kDstIn, GL_ZERO, GL_SRC_ALPHA},
+ {SkBlendMode::kSrcOut, GL_ONE_MINUS_DST_ALPHA, GL_ZERO},
+ {SkBlendMode::kDstOut, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kSrcATop, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kDstATop, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA},
+ {SkBlendMode::kXor, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kPlus, GL_ONE, GL_ONE},
+ {SkBlendMode::kModulate, GL_ZERO, GL_SRC_COLOR},
+ {SkBlendMode::kScreen, GL_ONE, GL_ONE_MINUS_SRC_COLOR}};
// This array contains the swapped version of each SkBlendMode. For instance
// this array's SrcOver blending mode is actually DstOver. You can refer to
// createLayer() for more information on the purpose of this array.
-const Blender kBlendsSwap[] = {
- { SkBlendMode::kClear, GL_ONE_MINUS_DST_ALPHA, GL_ZERO },
- { SkBlendMode::kSrc, GL_ZERO, GL_ONE },
- { SkBlendMode::kDst, GL_ONE, GL_ZERO },
- { SkBlendMode::kSrcOver, GL_ONE_MINUS_DST_ALPHA, GL_ONE },
- { SkBlendMode::kDstOver, GL_ONE, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kSrcIn, GL_ZERO, GL_SRC_ALPHA },
- { SkBlendMode::kDstIn, GL_DST_ALPHA, GL_ZERO },
- { SkBlendMode::kSrcOut, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kDstOut, GL_ONE_MINUS_DST_ALPHA, GL_ZERO },
- { SkBlendMode::kSrcATop, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA },
- { SkBlendMode::kDstATop, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kXor, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
- { SkBlendMode::kPlus, GL_ONE, GL_ONE },
- { SkBlendMode::kModulate, GL_DST_COLOR, GL_ZERO },
- { SkBlendMode::kScreen, GL_ONE_MINUS_DST_COLOR, GL_ONE }
-};
+const Blender kBlendsSwap[] = {{SkBlendMode::kClear, GL_ONE_MINUS_DST_ALPHA, GL_ZERO},
+ {SkBlendMode::kSrc, GL_ZERO, GL_ONE},
+ {SkBlendMode::kDst, GL_ONE, GL_ZERO},
+ {SkBlendMode::kSrcOver, GL_ONE_MINUS_DST_ALPHA, GL_ONE},
+ {SkBlendMode::kDstOver, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kSrcIn, GL_ZERO, GL_SRC_ALPHA},
+ {SkBlendMode::kDstIn, GL_DST_ALPHA, GL_ZERO},
+ {SkBlendMode::kSrcOut, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kDstOut, GL_ONE_MINUS_DST_ALPHA, GL_ZERO},
+ {SkBlendMode::kSrcATop, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA},
+ {SkBlendMode::kDstATop, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kXor, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ {SkBlendMode::kPlus, GL_ONE, GL_ONE},
+ {SkBlendMode::kModulate, GL_DST_COLOR, GL_ZERO},
+ {SkBlendMode::kScreen, GL_ONE_MINUS_DST_COLOR, GL_ONE}};
-Blend::Blend()
- : mEnabled(false)
- , mSrcMode(GL_ZERO)
- , mDstMode(GL_ZERO) {
+Blend::Blend() : mEnabled(false), mSrcMode(GL_ZERO), mDstMode(GL_ZERO) {
// gl blending off by default
}
@@ -145,4 +138,3 @@
} /* namespace uirenderer */
} /* namespace android */
-
diff --git a/libs/hwui/renderstate/Blend.h b/libs/hwui/renderstate/Blend.h
index a9de246..7e559ba 100644
--- a/libs/hwui/renderstate/Blend.h
+++ b/libs/hwui/renderstate/Blend.h
@@ -28,6 +28,7 @@
class Blend {
friend class RenderState;
+
public:
// dictates whether to swap src/dst
enum class ModeOrderSwap {
@@ -36,19 +37,18 @@
};
void syncEnabled();
- static void getFactors(SkBlendMode mode, ModeOrderSwap modeUsage,
- GLenum* outSrc, GLenum* outDst);
+ static void getFactors(SkBlendMode mode, ModeOrderSwap modeUsage, GLenum* outSrc,
+ GLenum* outDst);
void setFactors(GLenum src, GLenum dst);
- bool getEnabled() {
- return mEnabled;
- }
+ bool getEnabled() { return mEnabled; }
void getFactors(GLenum* src, GLenum* dst) {
*src = mSrcMode;
*dst = mDstMode;
}
void dump();
+
private:
Blend();
void invalidate();
@@ -60,4 +60,4 @@
} /* namespace uirenderer */
} /* namespace android */
-#endif // RENDERSTATE_BLEND_H
+#endif // RENDERSTATE_BLEND_H
diff --git a/libs/hwui/renderstate/MeshState.cpp b/libs/hwui/renderstate/MeshState.cpp
index 6d02936..4f6c49e 100644
--- a/libs/hwui/renderstate/MeshState.cpp
+++ b/libs/hwui/renderstate/MeshState.cpp
@@ -38,12 +38,12 @@
for (uint32_t i = 0; i < kMaxNumberOfQuads; i++) {
uint16_t quad = i * 4;
int index = i * 6;
- regionIndices[index ] = quad; // top-left
- regionIndices[index + 1] = quad + 1; // top-right
- regionIndices[index + 2] = quad + 2; // bottom-left
- regionIndices[index + 3] = quad + 2; // bottom-left
- regionIndices[index + 4] = quad + 1; // top-right
- regionIndices[index + 5] = quad + 3; // bottom-right
+ regionIndices[index] = quad; // top-left
+ regionIndices[index + 1] = quad + 1; // top-right
+ regionIndices[index + 2] = quad + 2; // bottom-left
+ regionIndices[index + 3] = quad + 2; // bottom-left
+ regionIndices[index + 4] = quad + 1; // top-right
+ regionIndices[index + 5] = quad + 3; // bottom-right
}
glGenBuffers(1, &mQuadListIndices);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mQuadListIndices);
@@ -65,10 +65,10 @@
void MeshState::dump() {
ALOGD("MeshState VBOs: unitQuad %d, current %d", mUnitQuadBuffer, mCurrentBuffer);
ALOGD("MeshState IBOs: quadList %d, current %d", mQuadListIndices, mCurrentIndicesBuffer);
- ALOGD("MeshState vertices: vertex data %p, stride %d",
- mCurrentPositionPointer, mCurrentPositionStride);
- ALOGD("MeshState texCoord: data %p, stride %d",
- mCurrentTexCoordsPointer, mCurrentTexCoordsStride);
+ ALOGD("MeshState vertices: vertex data %p, stride %d", mCurrentPositionPointer,
+ mCurrentPositionStride);
+ ALOGD("MeshState texCoord: data %p, stride %d", mCurrentTexCoordsPointer,
+ mCurrentTexCoordsStride);
}
///////////////////////////////////////////////////////////////////////////////
@@ -89,8 +89,8 @@
return bindMeshBuffer(0);
}
-void MeshState::genOrUpdateMeshBuffer(GLuint* buffer, GLsizeiptr size,
- const void* data, GLenum usage) {
+void MeshState::genOrUpdateMeshBuffer(GLuint* buffer, GLsizeiptr size, const void* data,
+ GLenum usage) {
if (!*buffer) {
glGenBuffers(1, buffer);
}
@@ -98,8 +98,8 @@
glBufferData(GL_ARRAY_BUFFER, size, data, usage);
}
-void MeshState::updateMeshBufferSubData(GLuint buffer, GLintptr offset,
- GLsizeiptr size, const void* data) {
+void MeshState::updateMeshBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr size,
+ const void* data) {
bindMeshBuffer(buffer);
glBufferSubData(GL_ARRAY_BUFFER, offset, size, data);
}
@@ -119,9 +119,8 @@
void MeshState::bindPositionVertexPointer(const GLvoid* vertices, GLsizei stride) {
// update pos coords if !current vbo, since vertices may point into mutable memory (e.g. stack)
- if (mCurrentBuffer == 0
- || vertices != mCurrentPositionPointer
- || stride != mCurrentPositionStride) {
+ if (mCurrentBuffer == 0 || vertices != mCurrentPositionPointer ||
+ stride != mCurrentPositionStride) {
glVertexAttribPointer(Program::kBindingPosition, 2, GL_FLOAT, GL_FALSE, stride, vertices);
mCurrentPositionPointer = vertices;
mCurrentPositionStride = stride;
@@ -130,9 +129,8 @@
void MeshState::bindTexCoordsVertexPointer(const GLvoid* vertices, GLsizei stride) {
// update tex coords if !current vbo, since vertices may point into mutable memory (e.g. stack)
- if (mCurrentBuffer == 0
- || vertices != mCurrentTexCoordsPointer
- || stride != mCurrentTexCoordsStride) {
+ if (mCurrentBuffer == 0 || vertices != mCurrentTexCoordsPointer ||
+ stride != mCurrentTexCoordsStride) {
glVertexAttribPointer(Program::kBindingTexCoords, 2, GL_FLOAT, GL_FALSE, stride, vertices);
mCurrentTexCoordsPointer = vertices;
mCurrentTexCoordsStride = stride;
@@ -179,4 +177,3 @@
} /* namespace uirenderer */
} /* namespace android */
-
diff --git a/libs/hwui/renderstate/MeshState.h b/libs/hwui/renderstate/MeshState.h
index 17ad462..95faf1e 100644
--- a/libs/hwui/renderstate/MeshState.h
+++ b/libs/hwui/renderstate/MeshState.h
@@ -33,10 +33,7 @@
// This array is never used directly but used as a memcpy source in the
// OpenGLRenderer constructor
const TextureVertex kUnitQuadVertices[] = {
- { 0, 0, 0, 0 },
- { 1, 0, 1, 0 },
- { 0, 1, 0, 1 },
- { 1, 1, 1, 1 },
+ {0, 0, 0, 0}, {1, 0, 1, 0}, {0, 1, 0, 1}, {1, 1, 1, 1},
};
const GLsizei kVertexStride = sizeof(Vertex);
@@ -82,15 +79,13 @@
* Binds an attrib to the specified float vertex pointer.
* Assumes a stride of gTextureVertexStride and a size of 2.
*/
- void bindPositionVertexPointer(const GLvoid* vertices,
- GLsizei stride = kTextureVertexStride);
+ void bindPositionVertexPointer(const GLvoid* vertices, GLsizei stride = kTextureVertexStride);
/**
* Binds an attrib to the specified float vertex pointer.
* Assumes a stride of gTextureVertexStride and a size of 2.
*/
- void bindTexCoordsVertexPointer(const GLvoid* vertices,
- GLsizei stride = kTextureVertexStride);
+ void bindTexCoordsVertexPointer(const GLvoid* vertices, GLsizei stride = kTextureVertexStride);
/**
* Resets the vertex pointers.
@@ -111,6 +106,7 @@
///////////////////////////////////////////////////////////////////////////////
GLuint getUnitQuadVBO() { return mUnitQuadBuffer; }
GLuint getQuadListIBO() { return mQuadListIndices; }
+
private:
MeshState();
@@ -134,4 +130,4 @@
} /* namespace uirenderer */
} /* namespace android */
-#endif // RENDERSTATE_MESHSTATE_H
+#endif // RENDERSTATE_MESHSTATE_H
diff --git a/libs/hwui/renderstate/OffscreenBufferPool.cpp b/libs/hwui/renderstate/OffscreenBufferPool.cpp
index ea292d6..a0f5cb9 100644
--- a/libs/hwui/renderstate/OffscreenBufferPool.cpp
+++ b/libs/hwui/renderstate/OffscreenBufferPool.cpp
@@ -33,8 +33,8 @@
// OffscreenBuffer
////////////////////////////////////////////////////////////////////////////////
-OffscreenBuffer::OffscreenBuffer(RenderState& renderState, Caches& caches,
- uint32_t viewportWidth, uint32_t viewportHeight, bool wideColorGamut)
+OffscreenBuffer::OffscreenBuffer(RenderState& renderState, Caches& caches, uint32_t viewportWidth,
+ uint32_t viewportHeight, bool wideColorGamut)
: GpuMemoryTracker(GpuObjectType::OffscreenBuffer)
, renderState(renderState)
, viewportWidth(viewportWidth)
@@ -45,8 +45,8 @@
uint32_t height = computeIdealDimension(viewportHeight);
ATRACE_FORMAT("Allocate %ux%u HW Layer", width, height);
caches.textureState().activateTexture(0);
- texture.resize(width, height,
- wideColorGamut ? GL_RGBA16F : caches.rgbaInternalFormat(), GL_RGBA);
+ texture.resize(width, height, wideColorGamut ? GL_RGBA16F : caches.rgbaInternalFormat(),
+ GL_RGBA);
texture.blend = true;
texture.setWrap(GL_CLAMP_TO_EDGE);
// not setting filter on texture, since it's set when drawing, based on transform
@@ -61,8 +61,8 @@
void OffscreenBuffer::dirty(Rect dirtyArea) {
dirtyArea.doIntersect(0, 0, viewportWidth, viewportHeight);
if (!dirtyArea.isEmpty()) {
- region.orSelf(android::Rect(dirtyArea.left, dirtyArea.top,
- dirtyArea.right, dirtyArea.bottom));
+ region.orSelf(
+ android::Rect(dirtyArea.left, dirtyArea.top, dirtyArea.right, dirtyArea.bottom));
}
}
@@ -78,7 +78,8 @@
const float texX = 1.0f / float(texture.width());
const float texY = 1.0f / float(texture.height());
- FatVector<TextureVertex, 64> meshVector(count * 4); // uses heap if more than 64 vertices needed
+ FatVector<TextureVertex, 64> meshVector(count *
+ 4); // uses heap if more than 64 vertices needed
TextureVertex* mesh = &meshVector[0];
for (size_t i = 0; i < count; i++) {
const android::Rect* r = &rects[i];
@@ -94,10 +95,9 @@
TextureVertex::set(mesh++, r->right, r->bottom, u2, v2);
}
elementCount = count * 6;
- renderState.meshState().genOrUpdateMeshBuffer(&vbo,
- sizeof(TextureVertex) * count * 4,
- &meshVector[0],
- GL_DYNAMIC_DRAW); // TODO: GL_STATIC_DRAW if savelayer
+ renderState.meshState().genOrUpdateMeshBuffer(
+ &vbo, sizeof(TextureVertex) * count * 4, &meshVector[0],
+ GL_DYNAMIC_DRAW); // TODO: GL_STATIC_DRAW if savelayer
}
uint32_t OffscreenBuffer::computeIdealDimension(uint32_t dimension) {
@@ -117,12 +117,11 @@
///////////////////////////////////////////////////////////////////////////////
OffscreenBufferPool::OffscreenBufferPool()
- // 4 screen-sized RGBA_8888 textures
- : mMaxSize(DeviceInfo::multiplyByResolution(4 * 4)) {
-}
+ // 4 screen-sized RGBA_8888 textures
+ : mMaxSize(DeviceInfo::multiplyByResolution(4 * 4)) {}
OffscreenBufferPool::~OffscreenBufferPool() {
- clear(); // TODO: unique_ptr?
+ clear(); // TODO: unique_ptr?
}
int OffscreenBufferPool::Entry::compare(const Entry& lhs, const Entry& rhs) {
@@ -143,8 +142,8 @@
mSize = 0;
}
-OffscreenBuffer* OffscreenBufferPool::get(RenderState& renderState,
- const uint32_t width, const uint32_t height, bool wideColorGamut) {
+OffscreenBuffer* OffscreenBufferPool::get(RenderState& renderState, const uint32_t width,
+ const uint32_t height, bool wideColorGamut) {
OffscreenBuffer* layer = nullptr;
Entry entry(width, height, wideColorGamut);
@@ -159,18 +158,18 @@
layer->viewportHeight = height;
mSize -= layer->getSizeInBytes();
} else {
- layer = new OffscreenBuffer(renderState, Caches::getInstance(),
- width, height, wideColorGamut);
+ layer = new OffscreenBuffer(renderState, Caches::getInstance(), width, height,
+ wideColorGamut);
}
return layer;
}
-OffscreenBuffer* OffscreenBufferPool::resize(OffscreenBuffer* layer,
- const uint32_t width, const uint32_t height) {
+OffscreenBuffer* OffscreenBufferPool::resize(OffscreenBuffer* layer, const uint32_t width,
+ const uint32_t height) {
RenderState& renderState = layer->renderState;
- if (layer->texture.width() == OffscreenBuffer::computeIdealDimension(width)
- && layer->texture.height() == OffscreenBuffer::computeIdealDimension(height)) {
+ if (layer->texture.width() == OffscreenBuffer::computeIdealDimension(width) &&
+ layer->texture.height() == OffscreenBuffer::computeIdealDimension(height)) {
// resize in place
layer->viewportWidth = width;
layer->viewportHeight = height;
@@ -214,5 +213,5 @@
}
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/renderstate/OffscreenBufferPool.h b/libs/hwui/renderstate/OffscreenBufferPool.h
index d9422c9..08ae052 100644
--- a/libs/hwui/renderstate/OffscreenBufferPool.h
+++ b/libs/hwui/renderstate/OffscreenBufferPool.h
@@ -18,10 +18,10 @@
#define ANDROID_HWUI_OFFSCREEN_BUFFER_POOL_H
#include <GpuMemoryTracker.h>
+#include <ui/Region.h>
#include "Caches.h"
#include "Texture.h"
#include "utils/Macros.h"
-#include <ui/Region.h>
#include <set>
@@ -42,8 +42,8 @@
*/
class OffscreenBuffer : GpuMemoryTracker {
public:
- OffscreenBuffer(RenderState& renderState, Caches& caches,
- uint32_t viewportWidth, uint32_t viewportHeight, bool wideColorGamut = false);
+ OffscreenBuffer(RenderState& renderState, Caches& caches, uint32_t viewportWidth,
+ uint32_t viewportHeight, bool wideColorGamut = false);
~OffscreenBuffer();
Rect getTextureCoordinates();
@@ -91,11 +91,11 @@
OffscreenBufferPool();
~OffscreenBufferPool();
- WARN_UNUSED_RESULT OffscreenBuffer* get(RenderState& renderState,
- const uint32_t width, const uint32_t height, bool wideColorGamut = false);
+ WARN_UNUSED_RESULT OffscreenBuffer* get(RenderState& renderState, const uint32_t width,
+ const uint32_t height, bool wideColorGamut = false);
- WARN_UNUSED_RESULT OffscreenBuffer* resize(OffscreenBuffer* layer,
- const uint32_t width, const uint32_t height);
+ WARN_UNUSED_RESULT OffscreenBuffer* resize(OffscreenBuffer* layer, const uint32_t width,
+ const uint32_t height);
void putOrDelete(OffscreenBuffer* layer);
@@ -120,6 +120,7 @@
* Prints out the content of the pool.
*/
void dump();
+
private:
struct Entry {
Entry() {}
@@ -133,36 +134,29 @@
: layer(layer)
, width(layer->texture.width())
, height(layer->texture.height())
- , wideColorGamut(layer->wideColorGamut) {
- }
+ , wideColorGamut(layer->wideColorGamut) {}
static int compare(const Entry& lhs, const Entry& rhs);
- bool operator==(const Entry& other) const {
- return compare(*this, other) == 0;
- }
+ bool operator==(const Entry& other) const { return compare(*this, other) == 0; }
- bool operator!=(const Entry& other) const {
- return compare(*this, other) != 0;
- }
+ bool operator!=(const Entry& other) const { return compare(*this, other) != 0; }
- bool operator<(const Entry& other) const {
- return Entry::compare(*this, other) < 0;
- }
+ bool operator<(const Entry& other) const { return Entry::compare(*this, other) < 0; }
OffscreenBuffer* layer = nullptr;
uint32_t width = 0;
uint32_t height = 0;
bool wideColorGamut = false;
- }; // struct Entry
+ }; // struct Entry
std::multiset<Entry> mPool;
uint32_t mSize = 0;
uint32_t mMaxSize;
-}; // class OffscreenBufferCache
+}; // class OffscreenBufferCache
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
-#endif // ANDROID_HWUI_OFFSCREEN_BUFFER_POOL_H
+#endif // ANDROID_HWUI_OFFSCREEN_BUFFER_POOL_H
diff --git a/libs/hwui/renderstate/PixelBufferState.cpp b/libs/hwui/renderstate/PixelBufferState.cpp
index c23af52..3a6efb8 100644
--- a/libs/hwui/renderstate/PixelBufferState.cpp
+++ b/libs/hwui/renderstate/PixelBufferState.cpp
@@ -18,9 +18,7 @@
namespace android {
namespace uirenderer {
-PixelBufferState::PixelBufferState()
- : mCurrentPixelBuffer(0) {
-}
+PixelBufferState::PixelBufferState() : mCurrentPixelBuffer(0) {}
bool PixelBufferState::bind(GLuint buffer) {
if (mCurrentPixelBuffer != buffer) {
@@ -42,4 +40,3 @@
} /* namespace uirenderer */
} /* namespace android */
-
diff --git a/libs/hwui/renderstate/PixelBufferState.h b/libs/hwui/renderstate/PixelBufferState.h
index 8dab21d..f7ae6c5 100644
--- a/libs/hwui/renderstate/PixelBufferState.h
+++ b/libs/hwui/renderstate/PixelBufferState.h
@@ -22,10 +22,11 @@
namespace uirenderer {
class PixelBufferState {
- friend class Caches; // TODO: move to RenderState
+ friend class Caches; // TODO: move to RenderState
public:
bool bind(GLuint buffer);
bool unbind();
+
private:
PixelBufferState();
GLuint mCurrentPixelBuffer;
@@ -34,4 +35,4 @@
} /* namespace uirenderer */
} /* namespace android */
-#endif // RENDERSTATE_PIXELBUFFERSTATE_H
+#endif // RENDERSTATE_PIXELBUFFERSTATE_H
diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp
index 0ceca33..5e33353 100644
--- a/libs/hwui/renderstate/RenderState.cpp
+++ b/libs/hwui/renderstate/RenderState.cpp
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "renderstate/RenderState.h"
+#include <GpuMemoryTracker.h>
#include "DeferredLayerUpdater.h"
#include "GlLayer.h"
#include "VkLayer.h"
-#include <GpuMemoryTracker.h>
-#include "renderstate/RenderState.h"
#include "renderthread/CanvasContext.h"
#include "renderthread/EglManager.h"
@@ -31,21 +31,18 @@
namespace uirenderer {
RenderState::RenderState(renderthread::RenderThread& thread)
- : mRenderThread(thread)
- , mViewportWidth(0)
- , mViewportHeight(0)
- , mFramebuffer(0) {
+ : mRenderThread(thread), mViewportWidth(0), mViewportHeight(0), mFramebuffer(0) {
mThreadId = pthread_self();
}
RenderState::~RenderState() {
LOG_ALWAYS_FATAL_IF(mBlend || mMeshState || mScissor || mStencil,
- "State object lifecycle not managed correctly");
+ "State object lifecycle not managed correctly");
}
void RenderState::onGLContextCreated() {
LOG_ALWAYS_FATAL_IF(mBlend || mMeshState || mScissor || mStencil,
- "State object lifecycle not managed correctly");
+ "State object lifecycle not managed correctly");
GpuMemoryTracker::onGpuContextCreated();
mBlend = new Blend();
@@ -67,7 +64,7 @@
static void layerLostGlContext(Layer* layer) {
LOG_ALWAYS_FATAL_IF(layer->getApi() != Layer::Api::OpenGL,
- "layerLostGlContext on non GL layer");
+ "layerLostGlContext on non GL layer");
static_cast<GlLayer*>(layer)->onGlContextLost();
}
@@ -94,7 +91,7 @@
void RenderState::onVkContextCreated() {
LOG_ALWAYS_FATAL_IF(mBlend || mMeshState || mScissor || mStencil,
- "State object lifecycle not managed correctly");
+ "State object lifecycle not managed correctly");
GpuMemoryTracker::onGpuContextCreated();
}
@@ -117,9 +114,9 @@
void RenderState::flush(Caches::FlushMode mode) {
switch (mode) {
case Caches::FlushMode::Full:
- // fall through
+ // fall through
case Caches::FlushMode::Moderate:
- // fall through
+ // fall through
case Caches::FlushMode::Layers:
if (mLayerPool) mLayerPool->clear();
break;
@@ -140,7 +137,6 @@
glViewport(0, 0, mViewportWidth, mViewportHeight);
}
-
void RenderState::getViewport(GLsizei* outWidth, GLsizei* outHeight) {
*outWidth = mViewportWidth;
*outHeight = mViewportHeight;
@@ -189,15 +185,13 @@
meshState().disableTexCoordsVertexArray();
debugOverdraw(false, false);
// TODO: We need a way to know whether the functor is sRGB aware (b/32072673)
- if (mCaches->extensions().hasLinearBlending() &&
- mCaches->extensions().hasSRGBWriteControl()) {
+ if (mCaches->extensions().hasLinearBlending() && mCaches->extensions().hasSRGBWriteControl()) {
glDisable(GL_FRAMEBUFFER_SRGB_EXT);
}
}
void RenderState::resumeFromFunctorInvoke() {
- if (mCaches->extensions().hasLinearBlending() &&
- mCaches->extensions().hasSRGBWriteControl()) {
+ if (mCaches->extensions().hasLinearBlending() && mCaches->extensions().hasSRGBWriteControl()) {
glEnable(GL_FRAMEBUFFER_SRGB_EXT);
}
@@ -249,7 +243,7 @@
///////////////////////////////////////////////////////////////////////////////
void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix,
- bool overrideDisableBlending) {
+ bool overrideDisableBlending) {
const Glop::Mesh& mesh = glop.mesh;
const Glop::Mesh::Vertices& vertices = mesh.vertices;
const Glop::Mesh::Indices& indices = mesh.indices;
@@ -266,21 +260,19 @@
fill.program->setColor(fill.color);
}
- fill.program->set(orthoMatrix,
- glop.transform.modelView,
- glop.transform.meshTransform(),
- glop.transform.transformFlags & TransformFlags::OffsetByFudgeFactor);
+ fill.program->set(orthoMatrix, glop.transform.modelView, glop.transform.meshTransform(),
+ glop.transform.transformFlags & TransformFlags::OffsetByFudgeFactor);
// Color filter uniforms
if (fill.filterMode == ProgramDescription::ColorFilterMode::Blend) {
const FloatColor& color = fill.filter.color;
- glUniform4f(mCaches->program().getUniform("colorBlend"),
- color.r, color.g, color.b, color.a);
+ glUniform4f(mCaches->program().getUniform("colorBlend"), color.r, color.g, color.b,
+ color.a);
} else if (fill.filterMode == ProgramDescription::ColorFilterMode::Matrix) {
glUniformMatrix4fv(mCaches->program().getUniform("colorMatrix"), 1, GL_FALSE,
- fill.filter.matrix.matrix);
+ fill.filter.matrix.matrix);
glUniform4fv(mCaches->program().getUniform("colorMatrixVector"), 1,
- fill.filter.matrix.vector);
+ fill.filter.matrix.vector);
}
// Round rect clipping uniforms
@@ -295,15 +287,14 @@
// Divide by the radius to simplify the calculations in the fragment shader
// roundRectPos is also passed from vertex shader relative to top/left & radius
glUniform4f(fill.program->getUniform("roundRectInnerRectLTWH"),
- innerRect.left / roundedOutRadius, innerRect.top / roundedOutRadius,
- (innerRect.right - innerRect.left) / roundedOutRadius,
- (innerRect.bottom - innerRect.top) / roundedOutRadius);
+ innerRect.left / roundedOutRadius, innerRect.top / roundedOutRadius,
+ (innerRect.right - innerRect.left) / roundedOutRadius,
+ (innerRect.bottom - innerRect.top) / roundedOutRadius);
- glUniformMatrix4fv(fill.program->getUniform("roundRectInvTransform"),
- 1, GL_FALSE, &state->matrix.data[0]);
+ glUniformMatrix4fv(fill.program->getUniform("roundRectInvTransform"), 1, GL_FALSE,
+ &state->matrix.data[0]);
- glUniform1f(fill.program->getUniform("roundRectRadius"),
- roundedOutRadius);
+ glUniform1f(fill.program->getUniform("roundRectRadius"), roundedOutRadius);
}
GL_CHECKPOINT(MODERATE);
@@ -333,8 +324,8 @@
}
if (texture.textureTransform) {
- glUniformMatrix4fv(fill.program->getUniform("mainTextureTransform"), 1,
- GL_FALSE, &texture.textureTransform->data[0]);
+ glUniformMatrix4fv(fill.program->getUniform("mainTextureTransform"), 1, GL_FALSE,
+ &texture.textureTransform->data[0]);
}
}
@@ -349,12 +340,13 @@
if (vertices.attribFlags & VertexAttribFlags::Color) {
colorLocation = fill.program->getAttrib("colors");
glEnableVertexAttribArray(colorLocation);
- glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, vertices.stride, vertices.color);
+ glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, vertices.stride,
+ vertices.color);
}
int alphaLocation = -1;
if (vertices.attribFlags & VertexAttribFlags::Alpha) {
// NOTE: alpha vertex position is computed assuming no VBO
- const void* alphaCoords = ((const GLbyte*) vertices.position) + kVertexAlphaOffset;
+ const void* alphaCoords = ((const GLbyte*)vertices.position) + kVertexAlphaOffset;
alphaLocation = fill.program->getAttrib("vtxAlpha");
glEnableVertexAttribArray(alphaLocation);
glVertexAttribPointer(alphaLocation, 1, GL_FLOAT, GL_FALSE, vertices.stride, alphaCoords);
@@ -363,8 +355,9 @@
SkiaShader::apply(*mCaches, fill.skiaShaderData, mViewportWidth, mViewportHeight);
GL_CHECKPOINT(MODERATE);
- Texture* texture = (fill.skiaShaderData.skiaShaderType & kBitmap_SkiaShaderType) ?
- fill.skiaShaderData.bitmapData.bitmapTexture : nullptr;
+ Texture* texture = (fill.skiaShaderData.skiaShaderType & kBitmap_SkiaShaderType)
+ ? fill.skiaShaderData.bitmapData.bitmapTexture
+ : nullptr;
const AutoTexture autoCleanup(texture);
// If we have a shader and a base texture, the base texture is assumed to be an alpha mask
@@ -373,8 +366,8 @@
if (colorSpaceTexture != nullptr) {
if (colorSpaceTexture->hasColorSpaceConversion()) {
const ColorSpaceConnector* connector = colorSpaceTexture->getColorSpaceConnector();
- glUniformMatrix3fv(fill.program->getUniform("colorSpaceMatrix"), 1,
- GL_FALSE, connector->getTransform().asArray());
+ glUniformMatrix3fv(fill.program->getUniform("colorSpaceMatrix"), 1, GL_FALSE,
+ connector->getTransform().asArray());
}
TransferFunctionType transferFunction = colorSpaceTexture->getTransferFunctionType();
@@ -387,15 +380,15 @@
break;
case TransferFunctionType::Full:
glUniform1fv(fill.program->getUniform("transferFunction"), 7,
- reinterpret_cast<const float*>(&source.getTransferParameters().g));
+ reinterpret_cast<const float*>(&source.getTransferParameters().g));
break;
case TransferFunctionType::Limited:
glUniform1fv(fill.program->getUniform("transferFunction"), 5,
- reinterpret_cast<const float*>(&source.getTransferParameters().g));
+ reinterpret_cast<const float*>(&source.getTransferParameters().g));
break;
case TransferFunctionType::Gamma:
glUniform1f(fill.program->getUniform("transferFunctionGamma"),
- source.getTransferParameters().g);
+ source.getTransferParameters().g);
break;
}
}
@@ -421,16 +414,17 @@
GLsizei elementsCount = mesh.elementCount;
const GLbyte* vertexData = static_cast<const GLbyte*>(vertices.position);
while (elementsCount > 0) {
- GLsizei drawCount = std::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6);
+ GLsizei drawCount = std::min(elementsCount, (GLsizei)kMaxNumberOfQuads * 6);
GLsizei vertexCount = (drawCount / 6) * 4;
meshState().bindPositionVertexPointer(vertexData, vertices.stride);
if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
- meshState().bindTexCoordsVertexPointer(
- vertexData + kMeshTextureOffset, vertices.stride);
+ meshState().bindTexCoordsVertexPointer(vertexData + kMeshTextureOffset,
+ vertices.stride);
}
if (mCaches->extensions().getMajorGlVersion() >= 3) {
- glDrawRangeElements(mesh.primitiveMode, 0, vertexCount-1, drawCount, GL_UNSIGNED_SHORT, nullptr);
+ glDrawRangeElements(mesh.primitiveMode, 0, vertexCount - 1, drawCount,
+ GL_UNSIGNED_SHORT, nullptr);
} else {
glDrawElements(mesh.primitiveMode, drawCount, GL_UNSIGNED_SHORT, nullptr);
}
@@ -439,10 +433,13 @@
}
} else if (indices.bufferObject || indices.indices) {
if (mCaches->extensions().getMajorGlVersion() >= 3) {
- // use glDrawRangeElements to reduce CPU overhead (otherwise the driver has to determine the min/max index values)
- glDrawRangeElements(mesh.primitiveMode, 0, mesh.vertexCount-1, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices);
+ // use glDrawRangeElements to reduce CPU overhead (otherwise the driver has to determine
+ // the min/max index values)
+ glDrawRangeElements(mesh.primitiveMode, 0, mesh.vertexCount - 1, mesh.elementCount,
+ GL_UNSIGNED_SHORT, indices.indices);
} else {
- glDrawElements(mesh.primitiveMode, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices);
+ glDrawElements(mesh.primitiveMode, mesh.elementCount, GL_UNSIGNED_SHORT,
+ indices.indices);
}
} else {
glDrawArrays(mesh.primitiveMode, 0, mesh.elementCount);
diff --git a/libs/hwui/renderstate/RenderState.h b/libs/hwui/renderstate/RenderState.h
index 315fa2d..e033cf2 100644
--- a/libs/hwui/renderstate/RenderState.h
+++ b/libs/hwui/renderstate/RenderState.h
@@ -26,14 +26,14 @@
#include "renderstate/Stencil.h"
#include "utils/Macros.h"
-#include <set>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-#include <ui/Region.h>
-#include <utils/Mutex.h>
-#include <utils/Functor.h>
-#include <utils/RefBase.h>
#include <private/hwui/DrawGlInfo.h>
+#include <ui/Region.h>
+#include <utils/Functor.h>
+#include <utils/Mutex.h>
+#include <utils/RefBase.h>
+#include <set>
class GrContext;
@@ -57,6 +57,7 @@
friend class renderthread::RenderThread;
friend class Caches;
friend class renderthread::CacheManager;
+
public:
void onGLContextCreated();
void onGLContextDestroyed();
@@ -79,12 +80,8 @@
void debugOverdraw(bool enable, bool clear);
- void registerLayer(Layer* layer) {
- mActiveLayers.insert(layer);
- }
- void unregisterLayer(Layer* layer) {
- mActiveLayers.erase(layer);
- }
+ void registerLayer(Layer* layer) { mActiveLayers.insert(layer); }
+ void unregisterLayer(Layer* layer) { mActiveLayers.erase(layer); }
void registerCanvasContext(renderthread::CanvasContext* context) {
mRegisteredContexts.insert(context);
@@ -127,7 +124,6 @@
explicit RenderState(renderthread::RenderThread& thread);
~RenderState();
-
renderthread::RenderThread& mRenderThread;
Caches* mCaches = nullptr;
diff --git a/libs/hwui/renderstate/Scissor.cpp b/libs/hwui/renderstate/Scissor.cpp
index 61dd8c3..e37ed02 100644
--- a/libs/hwui/renderstate/Scissor.cpp
+++ b/libs/hwui/renderstate/Scissor.cpp
@@ -23,12 +23,7 @@
namespace uirenderer {
Scissor::Scissor()
- : mEnabled(false)
- , mScissorX(0)
- , mScissorY(0)
- , mScissorWidth(0)
- , mScissorHeight(0) {
-}
+ : mEnabled(false), mScissorX(0), mScissorY(0), mScissorWidth(0), mScissorHeight(0) {}
bool Scissor::setEnabled(bool enabled) {
if (mEnabled != enabled) {
@@ -44,9 +39,8 @@
}
bool Scissor::set(GLint x, GLint y, GLint width, GLint height) {
- if (mEnabled && (x != mScissorX || y != mScissorY
- || width != mScissorWidth || height != mScissorHeight)) {
-
+ if (mEnabled &&
+ (x != mScissorX || y != mScissorY || width != mScissorWidth || height != mScissorHeight)) {
if (x < 0) {
width += x;
x = 0;
@@ -80,10 +74,7 @@
GLint width = std::max(0, ((int)clip.right) - x);
GLint height = std::max(0, (viewportHeight - (int)clip.top) - y);
- if (x != mScissorX
- || y != mScissorY
- || width != mScissorWidth
- || height != mScissorHeight) {
+ if (x != mScissorX || y != mScissorY || width != mScissorWidth || height != mScissorHeight) {
glScissor(x, y, width, height);
mScissorX = x;
@@ -104,10 +95,9 @@
}
void Scissor::dump() {
- ALOGD("Scissor: enabled %d, %d %d %d %d",
- mEnabled, mScissorX, mScissorY, mScissorWidth, mScissorHeight);
+ ALOGD("Scissor: enabled %d, %d %d %d %d", mEnabled, mScissorX, mScissorY, mScissorWidth,
+ mScissorHeight);
}
} /* namespace uirenderer */
} /* namespace android */
-
diff --git a/libs/hwui/renderstate/Scissor.h b/libs/hwui/renderstate/Scissor.h
index f302244..2b04f4e 100644
--- a/libs/hwui/renderstate/Scissor.h
+++ b/libs/hwui/renderstate/Scissor.h
@@ -26,6 +26,7 @@
class Scissor {
friend class RenderState;
+
public:
bool setEnabled(bool enabled);
bool set(GLint x, GLint y, GLint width, GLint height);
@@ -33,6 +34,7 @@
void reset();
bool isEnabled() { return mEnabled; }
void dump();
+
private:
Scissor();
void invalidate();
@@ -46,4 +48,4 @@
} /* namespace uirenderer */
} /* namespace android */
-#endif // RENDERSTATE_SCISSOR_H
+#endif // RENDERSTATE_SCISSOR_H
diff --git a/libs/hwui/renderstate/Stencil.cpp b/libs/hwui/renderstate/Stencil.cpp
index f594421..dc465fc 100644
--- a/libs/hwui/renderstate/Stencil.cpp
+++ b/libs/hwui/renderstate/Stencil.cpp
@@ -136,5 +136,5 @@
ALOGD("Stencil: state %d", mState);
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/renderstate/Stencil.h b/libs/hwui/renderstate/Stencil.h
index 5f7d405..95f3723 100644
--- a/libs/hwui/renderstate/Stencil.h
+++ b/libs/hwui/renderstate/Stencil.h
@@ -78,36 +78,26 @@
/**
* Indicates whether either test or write is enabled.
*/
- bool isEnabled() {
- return mState != StencilState::Disabled;
- }
+ bool isEnabled() { return mState != StencilState::Disabled; }
/**
* Indicates whether testing only is enabled.
*/
- bool isTestEnabled() {
- return mState == StencilState::Test;
- }
+ bool isTestEnabled() { return mState == StencilState::Test; }
- bool isWriteEnabled() {
- return mState == StencilState::Write;
- }
+ bool isWriteEnabled() { return mState == StencilState::Write; }
void dump();
private:
- enum class StencilState {
- Disabled,
- Test,
- Write
- };
+ enum class StencilState { Disabled, Test, Write };
void enable();
StencilState mState = StencilState::Disabled;
-}; // class Stencil
+}; // class Stencil
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
-#endif // ANDROID_HWUI_STENCIL_H
+#endif // ANDROID_HWUI_STENCIL_H
diff --git a/libs/hwui/renderstate/TextureState.cpp b/libs/hwui/renderstate/TextureState.cpp
index f9a1f8c..470b4f5 100644
--- a/libs/hwui/renderstate/TextureState.cpp
+++ b/libs/hwui/renderstate/TextureState.cpp
@@ -19,9 +19,9 @@
#include "utils/TraceUtils.h"
#include <GLES3/gl3.h>
-#include <memory>
-#include <SkCanvas.h>
#include <SkBitmap.h>
+#include <SkCanvas.h>
+#include <memory>
namespace android {
namespace uirenderer {
@@ -30,22 +30,16 @@
static const int SHADOW_LUT_SIZE = 128;
// Must define as many texture units as specified by kTextureUnitsCount
-const GLenum kTextureUnits[] = {
- GL_TEXTURE0,
- GL_TEXTURE1,
- GL_TEXTURE2,
- GL_TEXTURE3
-};
+const GLenum kTextureUnits[] = {GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_TEXTURE3};
-TextureState::TextureState()
- : mTextureUnit(0) {
+TextureState::TextureState() : mTextureUnit(0) {
glActiveTexture(kTextureUnits[0]);
resetBoundTextures();
GLint maxTextureUnits;
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
LOG_ALWAYS_FATAL_IF(maxTextureUnits < kTextureUnitsCount,
- "At least %d texture units are required!", kTextureUnitsCount);
+ "At least %d texture units are required!", kTextureUnitsCount);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}
@@ -86,8 +80,8 @@
void TextureState::activateTexture(GLuint textureUnit) {
LOG_ALWAYS_FATAL_IF(textureUnit >= kTextureUnitsCount,
- "Tried to use texture unit index %d, only %d exist",
- textureUnit, kTextureUnitsCount);
+ "Tried to use texture unit index %d, only %d exist", textureUnit,
+ kTextureUnitsCount);
if (mTextureUnit != textureUnit) {
glActiveTexture(kTextureUnits[textureUnit]);
mTextureUnit = textureUnit;
@@ -151,4 +145,3 @@
} /* namespace uirenderer */
} /* namespace android */
-
diff --git a/libs/hwui/renderstate/TextureState.h b/libs/hwui/renderstate/TextureState.h
index 7296fd3..f1996d4 100644
--- a/libs/hwui/renderstate/TextureState.h
+++ b/libs/hwui/renderstate/TextureState.h
@@ -16,8 +16,8 @@
#ifndef RENDERSTATE_TEXTURESTATE_H
#define RENDERSTATE_TEXTURESTATE_H
-#include "Vertex.h"
#include "Texture.h"
+#include "Vertex.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
@@ -29,9 +29,8 @@
class Texture;
class TextureState {
- friend class Caches; // TODO: move to RenderState
+ friend class Caches; // TODO: move to RenderState
public:
-
void constructTexture(Caches& caches);
/**
@@ -96,4 +95,4 @@
} /* namespace uirenderer */
} /* namespace android */
-#endif // RENDERSTATE_BLEND_H
+#endif // RENDERSTATE_BLEND_H