Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
diff --git a/libs/hwui/tests/unit/BakedOpDispatcherTests.cpp b/libs/hwui/tests/unit/BakedOpDispatcherTests.cpp
index b0ef11f..09f0b06 100644
--- a/libs/hwui/tests/unit/BakedOpDispatcherTests.cpp
+++ b/libs/hwui/tests/unit/BakedOpDispatcherTests.cpp
@@ -20,8 +20,8 @@
#include <BakedOpRenderer.h>
#include <FrameBuilder.h>
#include <LayerUpdateQueue.h>
-#include <hwui/Paint.h>
#include <RecordedOp.h>
+#include <hwui/Paint.h>
#include <tests/common/TestUtils.h>
#include <utils/Color.h>
@@ -32,19 +32,20 @@
using namespace android::uirenderer;
static BakedOpRenderer::LightInfo sLightInfo;
-const FrameBuilder::LightGeometry sLightGeometry = { {100, 100, 100}, 50};
+const FrameBuilder::LightGeometry sLightGeometry = {{100, 100, 100}, 50};
class ValidatingBakedOpRenderer : public BakedOpRenderer {
public:
- ValidatingBakedOpRenderer(RenderState& renderState, std::function<void(const Glop& glop)> validator)
+ ValidatingBakedOpRenderer(RenderState& renderState,
+ std::function<void(const Glop& glop)> validator)
: BakedOpRenderer(Caches::getInstance(), renderState, true, false, sLightInfo)
, mValidator(validator) {
mGlopReceiver = ValidatingGlopReceiver;
}
+
private:
static void ValidatingGlopReceiver(BakedOpRenderer& renderer, const Rect* dirtyBounds,
- const ClipBase* clip, const Glop& glop) {
-
+ const ClipBase* clip, const Glop& glop) {
auto vbor = reinterpret_cast<ValidatingBakedOpRenderer*>(&renderer);
vbor->mValidator(glop);
}
@@ -54,7 +55,8 @@
typedef void (*TestBakedOpReceiver)(BakedOpRenderer&, const BakedOpState&);
static void testUnmergedGlopDispatch(renderthread::RenderThread& renderThread, RecordedOp* op,
- std::function<void(const Glop& glop)> glopVerifier, int expectedGlopCount = 1) {
+ std::function<void(const Glop& glop)> glopVerifier,
+ int expectedGlopCount = 1) {
// Create op, and wrap with basic state.
LinearAllocator allocator;
auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(100, 100));
@@ -62,22 +64,22 @@
ASSERT_NE(nullptr, state);
int glopCount = 0;
- auto glopReceiver = [&glopVerifier, &glopCount, &expectedGlopCount] (const Glop& glop) {
+ auto glopReceiver = [&glopVerifier, &glopCount, &expectedGlopCount](const Glop& glop) {
ASSERT_LE(glopCount++, expectedGlopCount) << expectedGlopCount << "glop(s) expected";
glopVerifier(glop);
};
ValidatingBakedOpRenderer renderer(renderThread.renderState(), glopReceiver);
- // Dispatch based on op type created, similar to Frame/LayerBuilder dispatch behavior
-#define X(Type) \
- [](BakedOpRenderer& renderer, const BakedOpState& state) { \
- BakedOpDispatcher::on##Type(renderer, static_cast<const Type&>(*(state.op)), state); \
- },
+// Dispatch based on op type created, similar to Frame/LayerBuilder dispatch behavior
+#define X(Type) \
+ [](BakedOpRenderer& renderer, const BakedOpState& state) { \
+ BakedOpDispatcher::on##Type(renderer, static_cast<const Type&>(*(state.op)), state); \
+ },
static TestBakedOpReceiver unmergedReceivers[] = BUILD_RENDERABLE_OP_LUT(X);
#undef X
unmergedReceivers[op->opId](renderer, *state);
ASSERT_EQ(expectedGlopCount, glopCount) << "Exactly " << expectedGlopCount
- << "Glop(s) expected";
+ << "Glop(s) expected";
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(BakedOpDispatcher, pathTexture_positionOvalArc) {
@@ -88,7 +90,7 @@
float intervals[] = {1.0f, 1.0f};
strokePaint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
- auto textureGlopVerifier = [] (const Glop& glop) {
+ auto textureGlopVerifier = [](const Glop& glop) {
// validate glop produced by renderPathTexture (so texture, unit quad)
auto texture = glop.fill.texture.texture;
ASSERT_NE(nullptr, texture);
@@ -116,16 +118,15 @@
RENDERTHREAD_OPENGL_PIPELINE_TEST(BakedOpDispatcher, onLayerOp_bufferless) {
SkPaint layerPaint;
layerPaint.setAlpha(128);
- OffscreenBuffer* buffer = nullptr; // no providing a buffer, should hit rect fallback case
+ OffscreenBuffer* buffer = nullptr; // no providing a buffer, should hit rect fallback case
LayerOp op(Rect(10, 10), Matrix4::identity(), nullptr, &layerPaint, &buffer);
- testUnmergedGlopDispatch(renderThread, &op, [] (const Glop& glop) {
- ADD_FAILURE() << "Nothing should happen";
- }, 0);
+ testUnmergedGlopDispatch(renderThread, &op,
+ [](const Glop& glop) { ADD_FAILURE() << "Nothing should happen"; }, 0);
}
static int getGlopTransformFlags(renderthread::RenderThread& renderThread, RecordedOp* op) {
int result = 0;
- testUnmergedGlopDispatch(renderThread, op, [&result] (const Glop& glop) {
+ testUnmergedGlopDispatch(renderThread, op, [&result](const Glop& glop) {
result = glop.transform.transformFlags;
});
return result;
@@ -144,7 +145,7 @@
const float points[4] = {0.5, 0.5, 1.0, 1.0};
PointsOp antiAliasedPointsOp(bounds, Matrix4::identity(), nullptr, &aaPaint, points, 4);
EXPECT_EQ(TransformFlags::None, getGlopTransformFlags(renderThread, &antiAliasedPointsOp))
- << "Expect no offset for AA points.";
+ << "Expect no offset for AA points.";
PointsOp pointsOp(bounds, Matrix4::identity(), nullptr, &paint, points, 4);
EXPECT_EQ(TransformFlags::OffsetByFudgeFactor, getGlopTransformFlags(renderThread, &pointsOp))
<< "Expect an offset for non-AA points.";
@@ -158,21 +159,21 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(BakedOpDispatcher, renderTextWithShadow) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
- android::Paint shadowPaint;
- shadowPaint.setColor(SK_ColorRED);
+ android::Paint shadowPaint;
+ shadowPaint.setColor(SK_ColorRED);
- SkScalar sigma = Blur::convertRadiusToSigma(5);
- shadowPaint.setLooper(SkBlurDrawLooper::Make(SK_ColorWHITE, sigma, 3, 3));
+ SkScalar sigma = Blur::convertRadiusToSigma(5);
+ shadowPaint.setLooper(SkBlurDrawLooper::Make(SK_ColorWHITE, sigma, 3, 3));
- TestUtils::drawUtf8ToCanvas(&canvas, "A", shadowPaint, 25, 25);
- TestUtils::drawUtf8ToCanvas(&canvas, "B", shadowPaint, 50, 50);
- });
+ TestUtils::drawUtf8ToCanvas(&canvas, "A", shadowPaint, 25, 25);
+ TestUtils::drawUtf8ToCanvas(&canvas, "B", shadowPaint, 50, 50);
+ });
- int glopCount = 0;
- auto glopReceiver = [&glopCount] (const Glop& glop) {
+ int glopCount = 0;
+ auto glopReceiver = [&glopCount](const Glop& glop) {
if (glopCount < 2) {
// two white shadows
EXPECT_EQ(FloatColor({1, 1, 1, 1}), glop.fill.color);
@@ -185,8 +186,8 @@
ValidatingBakedOpRenderer renderer(renderThread.renderState(), glopReceiver);
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
@@ -194,15 +195,15 @@
}
static void validateLayerDraw(renderthread::RenderThread& renderThread,
- std::function<void(const Glop& glop)> validator) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- props.mutateLayerProperties().setType(LayerType::RenderLayer);
+ std::function<void(const Glop& glop)> validator) {
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.mutateLayerProperties().setType(LayerType::RenderLayer);
- // provide different blend mode, so decoration draws contrast
- props.mutateLayerProperties().setXferMode(SkBlendMode::kSrc);
- canvas.drawColor(Color::Black, SkBlendMode::kSrcOver);
- });
+ // provide different blend mode, so decoration draws contrast
+ props.mutateLayerProperties().setXferMode(SkBlendMode::kSrc);
+ canvas.drawColor(Color::Black, SkBlendMode::kSrcOver);
+ });
OffscreenBuffer** layerHandle = node->getLayerHandle();
auto syncedNode = TestUtils::getSyncedNode(node);
@@ -211,12 +212,12 @@
OffscreenBuffer layer(renderThread.renderState(), Caches::getInstance(), 100, 100);
*layerHandle = &layer;
{
- LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
+ LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
layerUpdateQueue.enqueueLayerWithDamage(node.get(), Rect(0, 0, 100, 100));
ValidatingBakedOpRenderer renderer(renderThread.renderState(), validator);
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferLayers(layerUpdateQueue);
frameBuilder.deferRenderNode(*syncedNode);
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
@@ -233,8 +234,8 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(BakedOpDispatcher, layerUpdateProperties) {
- for (bool debugOverdraw : { false, true }) {
- for (bool debugLayersUpdates : { false, true }) {
+ for (bool debugOverdraw : {false, true}) {
+ for (bool debugLayersUpdates : {false, true}) {
ScopedProperty<bool> ovdProp(Properties::debugOverdraw, debugOverdraw);
ScopedProperty<bool> lupProp(Properties::debugLayersUpdates, debugLayersUpdates);
@@ -253,8 +254,8 @@
// blend srcover, different from that of layer
EXPECT_EQ(GLenum(GL_ONE), glop.blend.src);
EXPECT_EQ(GLenum(GL_ONE_MINUS_SRC_ALPHA), glop.blend.dst);
- EXPECT_EQ(makeFloatColor(debugLayersUpdates ? 0x7f00ff00 : 0),
- glop.fill.color) << "Should be transparent green if debugLayersUpdates";
+ EXPECT_EQ(makeFloatColor(debugLayersUpdates ? 0x7f00ff00 : 0), glop.fill.color)
+ << "Should be transparent green if debugLayersUpdates";
} else if (glopCount < 7) {
// 3 - 6 - overdraw indicator overlays, if present
EXPECT_TRUE(glop.fill.colorEnabled);
@@ -279,7 +280,7 @@
SkPath path;
path.addRect(SkRect::MakeXYWH(1.5, 3.8, 100, 90));
PathOp op(bounds, Matrix4::identity(), nullptr, &paint, &path);
- testUnmergedGlopDispatch(renderThread, &op, [] (const Glop& glop) {
+ testUnmergedGlopDispatch(renderThread, &op, [](const Glop& glop) {
auto texture = glop.fill.texture.texture;
ASSERT_NE(nullptr, texture);
EXPECT_EQ(1, reinterpret_cast<PathTexture*>(texture)->left);
diff --git a/libs/hwui/tests/unit/BakedOpRendererTests.cpp b/libs/hwui/tests/unit/BakedOpRendererTests.cpp
index 38e106a..1a3ec39 100644
--- a/libs/hwui/tests/unit/BakedOpRendererTests.cpp
+++ b/libs/hwui/tests/unit/BakedOpRendererTests.cpp
@@ -22,11 +22,11 @@
using namespace android::uirenderer;
-const BakedOpRenderer::LightInfo sLightInfo = { 128, 128 };
+const BakedOpRenderer::LightInfo sLightInfo = {128, 128};
RENDERTHREAD_OPENGL_PIPELINE_TEST(BakedOpRenderer, startRepaintLayer_clear) {
- BakedOpRenderer renderer(Caches::getInstance(), renderThread.renderState(),
- true, false, sLightInfo);
+ BakedOpRenderer renderer(Caches::getInstance(), renderThread.renderState(), true, false,
+ sLightInfo);
OffscreenBuffer layer(renderThread.renderState(), Caches::getInstance(), 200u, 200u);
layer.dirty(Rect(200, 200));
@@ -38,9 +38,9 @@
layer.dirty(Rect(200, 200));
{
- renderer.startRepaintLayer(&layer, Rect(100, 200)); // repainting left side
+ renderer.startRepaintLayer(&layer, Rect(100, 200)); // repainting left side
EXPECT_TRUE(layer.region.isRect());
- //ALOGD("bounds %d %d %d %d", RECT_ARGS(layer.region.getBounds()));
+ // ALOGD("bounds %d %d %d %d", RECT_ARGS(layer.region.getBounds()));
EXPECT_EQ(android::Rect(100, 0, 200, 200), layer.region.getBounds())
<< "Left side being repainted, so right side should be clear";
renderer.endLayer();
@@ -48,7 +48,7 @@
// right side is now only dirty portion
{
- renderer.startRepaintLayer(&layer, Rect(100, 0, 200, 200)); // repainting right side
+ renderer.startRepaintLayer(&layer, Rect(100, 0, 200, 200)); // repainting right side
EXPECT_TRUE(layer.region.isEmpty())
<< "Now right side being repainted, so region should be entirely clear";
renderer.endLayer();
diff --git a/libs/hwui/tests/unit/BakedOpStateTests.cpp b/libs/hwui/tests/unit/BakedOpStateTests.cpp
index d51db2e..6f8e249 100644
--- a/libs/hwui/tests/unit/BakedOpStateTests.cpp
+++ b/libs/hwui/tests/unit/BakedOpStateTests.cpp
@@ -38,7 +38,7 @@
ResolvedRenderState state(allocator, *parentSnapshot, recordedOp, false, false);
EXPECT_MATRIX_APPROX_EQ(state.transform, translate10x20);
EXPECT_EQ(Rect(100, 200), state.clipRect());
- EXPECT_EQ(Rect(40, 60, 100, 200), state.clippedBounds); // translated and also clipped
+ EXPECT_EQ(Rect(40, 60, 100, 200), state.clippedBounds); // translated and also clipped
EXPECT_EQ(OpClipSideFlags::Right | OpClipSideFlags::Bottom, state.clipSideFlags);
}
{
@@ -72,14 +72,14 @@
auto parentSnapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(100, 200));
ResolvedRenderState state(allocator, *parentSnapshot, recordedOp, false, false);
EXPECT_EQ(Rect(-10, -20, 90, 180), state.computeLocalSpaceClip())
- << "Local clip rect should be 100x200, offset by -10,-20";
+ << "Local clip rect should be 100x200, offset by -10,-20";
}
{
// recorded with transform + parent transform
auto parentSnapshot = TestUtils::makeSnapshot(translate10x20, Rect(100, 200));
ResolvedRenderState state(allocator, *parentSnapshot, recordedOp, false, false);
EXPECT_EQ(Rect(-10, -20, 80, 160), state.computeLocalSpaceClip())
- << "Local clip rect should be 90x190, offset by -10,-20";
+ << "Local clip rect should be 90x190, offset by -10,-20";
}
}
@@ -96,62 +96,51 @@
};
const static StrokeTestCase sStrokeTestCases[] = {
- {
- 1, HAIRLINE, [](const ResolvedRenderState& state) {
- EXPECT_EQ(Rect(49.5f, 49.5f, 150.5f, 150.5f), state.clippedBounds);
- }
- },
- {
- 1, SEMI_HAIRLINE, [](const ResolvedRenderState& state) {
- EXPECT_TRUE(state.clippedBounds.contains(49.5f, 49.5f, 150.5f, 150.5f));
- EXPECT_TRUE(Rect(49, 49, 151, 151).contains(state.clippedBounds));
- }
- },
- {
- 1, 20, [](const ResolvedRenderState& state) {
- EXPECT_EQ(Rect(40, 40, 160, 160), state.clippedBounds);
- }
- },
+ {1, HAIRLINE,
+ [](const ResolvedRenderState& state) {
+ EXPECT_EQ(Rect(49.5f, 49.5f, 150.5f, 150.5f), state.clippedBounds);
+ }},
+ {1, SEMI_HAIRLINE,
+ [](const ResolvedRenderState& state) {
+ EXPECT_TRUE(state.clippedBounds.contains(49.5f, 49.5f, 150.5f, 150.5f));
+ EXPECT_TRUE(Rect(49, 49, 151, 151).contains(state.clippedBounds));
+ }},
+ {1, 20,
+ [](const ResolvedRenderState& state) {
+ EXPECT_EQ(Rect(40, 40, 160, 160), state.clippedBounds);
+ }},
- // 3x3 scale:
- {
- 3, HAIRLINE, [](const ResolvedRenderState& state) {
- EXPECT_EQ(Rect(149.5f, 149.5f, 200, 200), state.clippedBounds);
- EXPECT_EQ(OpClipSideFlags::Right | OpClipSideFlags::Bottom, state.clipSideFlags);
- }
- },
- {
- 3, SEMI_HAIRLINE, [](const ResolvedRenderState& state) {
- EXPECT_TRUE(state.clippedBounds.contains(149.5f, 149.5f, 200, 200));
- EXPECT_TRUE(Rect(149, 149, 200, 200).contains(state.clippedBounds));
- }
- },
- {
- 3, 20, [](const ResolvedRenderState& state) {
- EXPECT_TRUE(state.clippedBounds.contains(120, 120, 200, 200));
- EXPECT_TRUE(Rect(119, 119, 200, 200).contains(state.clippedBounds));
- }
- },
+ // 3x3 scale:
+ {3, HAIRLINE,
+ [](const ResolvedRenderState& state) {
+ EXPECT_EQ(Rect(149.5f, 149.5f, 200, 200), state.clippedBounds);
+ EXPECT_EQ(OpClipSideFlags::Right | OpClipSideFlags::Bottom, state.clipSideFlags);
+ }},
+ {3, SEMI_HAIRLINE,
+ [](const ResolvedRenderState& state) {
+ EXPECT_TRUE(state.clippedBounds.contains(149.5f, 149.5f, 200, 200));
+ EXPECT_TRUE(Rect(149, 149, 200, 200).contains(state.clippedBounds));
+ }},
+ {3, 20,
+ [](const ResolvedRenderState& state) {
+ EXPECT_TRUE(state.clippedBounds.contains(120, 120, 200, 200));
+ EXPECT_TRUE(Rect(119, 119, 200, 200).contains(state.clippedBounds));
+ }},
- // 0.5f x 0.5f scale
- {
- 0.5f, HAIRLINE, [](const ResolvedRenderState& state) {
- EXPECT_EQ(Rect(24.5f, 24.5f, 75.5f, 75.5f), state.clippedBounds);
- }
- },
- {
- 0.5f, SEMI_HAIRLINE, [](const ResolvedRenderState& state) {
- EXPECT_TRUE(state.clippedBounds.contains(24.5f, 24.5f, 75.5f, 75.5f));
- EXPECT_TRUE(Rect(24, 24, 76, 76).contains(state.clippedBounds));
- }
- },
- {
- 0.5f, 20, [](const ResolvedRenderState& state) {
- EXPECT_TRUE(state.clippedBounds.contains(19.5f, 19.5f, 80.5f, 80.5f));
- EXPECT_TRUE(Rect(19, 19, 81, 81).contains(state.clippedBounds));
- }
- }
-};
+ // 0.5f x 0.5f scale
+ {0.5f, HAIRLINE,
+ [](const ResolvedRenderState& state) {
+ EXPECT_EQ(Rect(24.5f, 24.5f, 75.5f, 75.5f), state.clippedBounds);
+ }},
+ {0.5f, SEMI_HAIRLINE,
+ [](const ResolvedRenderState& state) {
+ EXPECT_TRUE(state.clippedBounds.contains(24.5f, 24.5f, 75.5f, 75.5f));
+ EXPECT_TRUE(Rect(24, 24, 76, 76).contains(state.clippedBounds));
+ }},
+ {0.5f, 20, [](const ResolvedRenderState& state) {
+ EXPECT_TRUE(state.clippedBounds.contains(19.5f, 19.5f, 80.5f, 80.5f));
+ EXPECT_TRUE(Rect(19, 19, 81, 81).contains(state.clippedBounds));
+ }}};
TEST(ResolvedRenderState, construct_expandForStroke) {
LinearAllocator allocator;
@@ -163,8 +152,7 @@
strokedPaint.setStrokeWidth(testCase.strokeWidth);
ClipRect clip(Rect(200, 200));
- RectOp recordedOp(Rect(50, 50, 150, 150),
- Matrix4::identity(), &clip, &strokedPaint);
+ RectOp recordedOp(Rect(50, 50, 150, 150), Matrix4::identity(), &clip, &strokedPaint);
Matrix4 snapshotMatrix;
snapshotMatrix.loadScale(testCase.scale, testCase.scale, 1);
@@ -204,16 +192,18 @@
LinearAllocator allocator;
{
- auto snapshot = TestUtils::makeSnapshot(translate10x20, Rect()); // Note: empty clip
- BakedOpState* bakedState = BakedOpState::tryShadowOpConstruct(allocator, *snapshot, (ShadowOp*)0x1234);
+ auto snapshot = TestUtils::makeSnapshot(translate10x20, Rect()); // Note: empty clip
+ BakedOpState* bakedState =
+ BakedOpState::tryShadowOpConstruct(allocator, *snapshot, (ShadowOp*)0x1234);
EXPECT_EQ(nullptr, bakedState) << "op should be rejected by clip, so not constructed";
EXPECT_EQ(0u, allocator.usedSize()) << "no serialization, even for clip,"
- "since op is quick rejected based on snapshot clip";
+ "since op is quick rejected based on snapshot clip";
}
{
auto snapshot = TestUtils::makeSnapshot(translate10x20, Rect(100, 200));
- BakedOpState* bakedState = BakedOpState::tryShadowOpConstruct(allocator, *snapshot, (ShadowOp*)0x1234);
+ BakedOpState* bakedState =
+ BakedOpState::tryShadowOpConstruct(allocator, *snapshot, (ShadowOp*)0x1234);
ASSERT_NE(nullptr, bakedState) << "NOT rejected by clip, so op should be constructed";
EXPECT_LE(64u, allocator.usedSize()) << "relatively large alloc for non-rejected op";
@@ -232,12 +222,13 @@
paint.setStrokeWidth(0.0f);
ClipRect clip(Rect(100, 200));
RectOp rejectOp(Rect(100, 200), Matrix4::identity(), &clip, &paint);
- auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect()); // Note: empty clip
- auto bakedState = BakedOpState::tryStrokeableOpConstruct(allocator, *snapshot, rejectOp,
- BakedOpState::StrokeBehavior::StyleDefined, false);
+ auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect()); // Note: empty clip
+ auto bakedState = BakedOpState::tryStrokeableOpConstruct(
+ allocator, *snapshot, rejectOp, BakedOpState::StrokeBehavior::StyleDefined, false);
EXPECT_EQ(nullptr, bakedState);
- EXPECT_GT(8u, allocator.usedSize()); // no significant allocation space used for rejected op
+ EXPECT_GT(8u,
+ allocator.usedSize()); // no significant allocation space used for rejected op
}
{
// check simple unscaled expansion
@@ -247,8 +238,8 @@
ClipRect clip(Rect(200, 200));
RectOp rejectOp(Rect(50, 50, 150, 150), Matrix4::identity(), &clip, &paint);
auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(200, 200));
- auto bakedState = BakedOpState::tryStrokeableOpConstruct(allocator, *snapshot, rejectOp,
- BakedOpState::StrokeBehavior::StyleDefined, false);
+ auto bakedState = BakedOpState::tryStrokeableOpConstruct(
+ allocator, *snapshot, rejectOp, BakedOpState::StrokeBehavior::StyleDefined, false);
ASSERT_NE(nullptr, bakedState);
EXPECT_EQ(Rect(45, 45, 155, 155), bakedState->computedState.clippedBounds);
@@ -262,8 +253,8 @@
ClipRect clip(Rect(200, 200));
RectOp rejectOp(Rect(50, 50, 150, 150), Matrix4::identity(), &clip, &paint);
auto snapshot = TestUtils::makeSnapshot(Matrix4::identity(), Rect(200, 200));
- auto bakedState = BakedOpState::tryStrokeableOpConstruct(allocator, *snapshot, rejectOp,
- BakedOpState::StrokeBehavior::Forced, false);
+ auto bakedState = BakedOpState::tryStrokeableOpConstruct(
+ allocator, *snapshot, rejectOp, BakedOpState::StrokeBehavior::Forced, false);
ASSERT_NE(nullptr, bakedState);
EXPECT_EQ(Rect(45, 45, 155, 155), bakedState->computedState.clippedBounds);
@@ -271,5 +262,5 @@
}
}
-} // namespace uirenderer
-} // namespace android
+} // namespace uirenderer
+} // namespace android
diff --git a/libs/hwui/tests/unit/CacheManagerTests.cpp b/libs/hwui/tests/unit/CacheManagerTests.cpp
index 6115162..b1106f0 100644
--- a/libs/hwui/tests/unit/CacheManagerTests.cpp
+++ b/libs/hwui/tests/unit/CacheManagerTests.cpp
@@ -35,7 +35,8 @@
GrContext* grContext = renderThread.getGrContext();
ASSERT_TRUE(grContext != nullptr);
- // create pairs of offscreen render targets and images until we exceed the backgroundCacheSizeLimit
+ // create pairs of offscreen render targets and images until we exceed the
+ // backgroundCacheSizeLimit
std::vector<sk_sp<SkSurface>> surfaces;
while (getCacheUsage(grContext) <= renderThread.cacheManager().getBackgroundCacheSize()) {
diff --git a/libs/hwui/tests/unit/CanvasContextTests.cpp b/libs/hwui/tests/unit/CanvasContextTests.cpp
index ef5ce0d..28cff5b 100644
--- a/libs/hwui/tests/unit/CanvasContextTests.cpp
+++ b/libs/hwui/tests/unit/CanvasContextTests.cpp
@@ -35,8 +35,8 @@
RENDERTHREAD_TEST(CanvasContext, create) {
auto rootNode = TestUtils::createNode(0, 0, 200, 400, nullptr);
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, rootNode.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, rootNode.get(), &contextFactory));
ASSERT_FALSE(canvasContext->hasSurface());
diff --git a/libs/hwui/tests/unit/CanvasStateTests.cpp b/libs/hwui/tests/unit/CanvasStateTests.cpp
index c41313a..4c03811 100644
--- a/libs/hwui/tests/unit/CanvasStateTests.cpp
+++ b/libs/hwui/tests/unit/CanvasStateTests.cpp
@@ -21,14 +21,14 @@
#include "hwui/Canvas.h"
#include "utils/LinearAllocator.h"
-#include <gtest/gtest.h>
-#include <SkPath.h>
#include <SkClipOp.h>
+#include <SkPath.h>
+#include <gtest/gtest.h>
namespace android {
namespace uirenderer {
-class NullClient: public CanvasStateClient {
+class NullClient : public CanvasStateClient {
void onViewportInitialized() override {}
void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {}
GLuint getTargetFbo() const override { return 0; }
@@ -47,8 +47,7 @@
TEST(CanvasState, gettersAndSetters) {
CanvasState state(sNullClient);
- state.initializeSaveStack(200, 200,
- 0, 0, 200, 200, Vector3());
+ state.initializeSaveStack(200, 200, 0, 0, 200, 200, Vector3());
ASSERT_EQ(state.getWidth(), 200);
ASSERT_EQ(state.getHeight(), 200);
@@ -65,8 +64,7 @@
TEST(CanvasState, simpleClipping) {
CanvasState state(sNullClient);
- state.initializeSaveStack(200, 200,
- 0, 0, 200, 200, Vector3());
+ state.initializeSaveStack(200, 200, 0, 0, 200, 200, Vector3());
state.clipRect(0, 0, 100, 100, SkClipOp::kIntersect);
ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(100, 100));
@@ -80,8 +78,7 @@
TEST(CanvasState, complexClipping) {
CanvasState state(sNullClient);
- state.initializeSaveStack(200, 200,
- 0, 0, 200, 200, Vector3());
+ state.initializeSaveStack(200, 200, 0, 0, 200, 200, Vector3());
state.save(SaveFlags::MatrixClip);
{
@@ -116,8 +113,7 @@
TEST(CanvasState, saveAndRestore) {
CanvasState state(sNullClient);
- state.initializeSaveStack(200, 200,
- 0, 0, 200, 200, Vector3());
+ state.initializeSaveStack(200, 200, 0, 0, 200, 200, Vector3());
state.save(SaveFlags::Clip);
{
@@ -125,7 +121,7 @@
ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(10, 10));
}
state.restore();
- ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(200, 200)); // verify restore
+ ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(200, 200)); // verify restore
Matrix4 simpleTranslate;
simpleTranslate.loadTranslate(10, 10, 0);
@@ -140,27 +136,25 @@
TEST(CanvasState, saveAndRestoreButNotTooMuch) {
CanvasState state(sNullClient);
- state.initializeSaveStack(200, 200,
- 0, 0, 200, 200, Vector3());
+ state.initializeSaveStack(200, 200, 0, 0, 200, 200, Vector3());
- state.save(SaveFlags::Matrix); // NOTE: clip not saved
+ state.save(SaveFlags::Matrix); // NOTE: clip not saved
{
state.clipRect(0, 0, 10, 10, SkClipOp::kIntersect);
ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(10, 10));
}
state.restore();
- ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(10, 10)); // verify not restored
+ ASSERT_EQ(state.getRenderTargetClipBounds(), Rect(10, 10)); // verify not restored
Matrix4 simpleTranslate;
simpleTranslate.loadTranslate(10, 10, 0);
- state.save(SaveFlags::Clip); // NOTE: matrix not saved
+ state.save(SaveFlags::Clip); // NOTE: matrix not saved
{
state.translate(10, 10, 0);
EXPECT_TRUE(approxEqual(*state.currentTransform(), simpleTranslate));
}
state.restore();
- EXPECT_TRUE(approxEqual(*state.currentTransform(), simpleTranslate)); // verify not restored
+ EXPECT_TRUE(approxEqual(*state.currentTransform(), simpleTranslate)); // verify not restored
}
-
}
}
diff --git a/libs/hwui/tests/unit/ClipAreaTests.cpp b/libs/hwui/tests/unit/ClipAreaTests.cpp
index d4d7919..450bb67 100644
--- a/libs/hwui/tests/unit/ClipAreaTests.cpp
+++ b/libs/hwui/tests/unit/ClipAreaTests.cpp
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <SkPath.h>
#include <SkRegion.h>
+#include <gtest/gtest.h>
#include "ClipArea.h"
@@ -194,7 +194,8 @@
{
auto origRectClip = area.serializeClip(allocator);
ASSERT_NE(nullptr, origRectClip);
- EXPECT_EQ(origRectClip, area.serializeIntersectedClip(allocator, nullptr, Matrix4::identity()));
+ EXPECT_EQ(origRectClip,
+ area.serializeIntersectedClip(allocator, nullptr, Matrix4::identity()));
}
// rect
@@ -208,11 +209,13 @@
ASSERT_EQ(ClipMode::Rectangle, resolvedClip->mode);
EXPECT_EQ(Rect(100, 100, 200, 200), resolvedClip->rect);
- EXPECT_EQ(resolvedClip, area.serializeIntersectedClip(allocator, &recordedClip, translateScale))
+ EXPECT_EQ(resolvedClip,
+ area.serializeIntersectedClip(allocator, &recordedClip, translateScale))
<< "Must return previous serialization, since input is same";
ClipRect recordedClip2(Rect(100, 100));
- EXPECT_NE(resolvedClip, area.serializeIntersectedClip(allocator, &recordedClip2, translateScale))
+ EXPECT_NE(resolvedClip,
+ area.serializeIntersectedClip(allocator, &recordedClip2, translateScale))
<< "Shouldn't return previous serialization, since matrix location is different";
}
@@ -222,7 +225,8 @@
area.clipRectWithTransform(Rect(200, 200), &rotate, SkRegion::kIntersect_Op);
{
ClipRect recordedClip(Rect(100, 100));
- auto resolvedClip = area.serializeIntersectedClip(allocator, &recordedClip, Matrix4::identity());
+ auto resolvedClip =
+ area.serializeIntersectedClip(allocator, &recordedClip, Matrix4::identity());
ASSERT_NE(nullptr, resolvedClip);
ASSERT_EQ(ClipMode::RectangleList, resolvedClip->mode);
auto clipRectList = reinterpret_cast<const ClipRectList*>(resolvedClip);
@@ -243,8 +247,9 @@
Matrix4 translate10x20;
translate10x20.loadTranslate(10, 20, 0);
- auto resolvedClip = area.serializeIntersectedClip(allocator, &recordedClip,
- translate10x20); // Note: only translate for now, others not handled correctly
+ auto resolvedClip = area.serializeIntersectedClip(
+ allocator, &recordedClip,
+ translate10x20); // Note: only translate for now, others not handled correctly
ASSERT_NE(nullptr, resolvedClip);
ASSERT_EQ(ClipMode::Region, resolvedClip->mode);
auto clipRegion = reinterpret_cast<const ClipRegion*>(resolvedClip);
@@ -267,7 +272,8 @@
ClipRect recordedClip(Rect(100.12, 100.74));
Matrix4 translateScale;
translateScale.loadTranslate(100, 100, 0);
- translateScale.scale(2, 3, 1); // recorded clip will have non-int coords, even after transform
+ translateScale.scale(2, 3,
+ 1); // recorded clip will have non-int coords, even after transform
auto resolvedClip = area.serializeIntersectedClip(allocator, &recordedClip, translateScale);
ASSERT_NE(nullptr, resolvedClip);
EXPECT_EQ(ClipMode::Rectangle, resolvedClip->mode);
@@ -343,5 +349,5 @@
EXPECT_EQ(SkIRect::MakeLTRB(-4, 1, -2, 3), region.getBounds());
}
-} // namespace uirenderer
-} // namespace android
+} // namespace uirenderer
+} // namespace android
diff --git a/libs/hwui/tests/unit/DeferredLayerUpdaterTests.cpp b/libs/hwui/tests/unit/DeferredLayerUpdaterTests.cpp
index 87d897e..b8b5050 100644
--- a/libs/hwui/tests/unit/DeferredLayerUpdaterTests.cpp
+++ b/libs/hwui/tests/unit/DeferredLayerUpdaterTests.cpp
@@ -50,7 +50,6 @@
glLayer->setRenderTarget(GL_TEXTURE_EXTERNAL_OES);
}
-
// the backing layer should now have all the properties applied.
if (layerUpdater->backingLayer()->getApi() == Layer::Api::OpenGL) {
GlLayer* glLayer = static_cast<GlLayer*>(layerUpdater->backingLayer());
diff --git a/libs/hwui/tests/unit/FatVectorTests.cpp b/libs/hwui/tests/unit/FatVectorTests.cpp
index 64b0ba1..8523e6c 100644
--- a/libs/hwui/tests/unit/FatVectorTests.cpp
+++ b/libs/hwui/tests/unit/FatVectorTests.cpp
@@ -22,12 +22,11 @@
using namespace android;
using namespace android::uirenderer;
-template<class VectorType>
+template <class VectorType>
static bool allocationIsInternal(VectorType& v) {
// allocation array (from &v[0] to &v[0] + v.capacity) is
// located within the vector object itself
- return (char*)(&v) <= (char*)(&v[0])
- && (char*)(&v + 1) >= (char*)(&v[0] + v.capacity());
+ return (char*)(&v) <= (char*)(&v[0]) && (char*)(&v + 1) >= (char*)(&v[0] + v.capacity());
}
TEST(FatVector, baseline) {
diff --git a/libs/hwui/tests/unit/FatalTestCanvas.h b/libs/hwui/tests/unit/FatalTestCanvas.h
index 03d9496..9693ce7 100644
--- a/libs/hwui/tests/unit/FatalTestCanvas.h
+++ b/libs/hwui/tests/unit/FatalTestCanvas.h
@@ -16,15 +16,14 @@
#pragma once
-#include <gtest/gtest.h>
#include <SkCanvas.h>
+#include <gtest/gtest.h>
namespace {
class TestCanvasBase : public SkCanvas {
public:
- TestCanvasBase(int width, int height) : SkCanvas(width, height) {
- }
+ TestCanvasBase(int width, int height) : SkCanvas(width, height) {}
void onDrawAnnotation(const SkRect&, const char key[], SkData* value) {
ADD_FAILURE() << "onDrawAnnotation not expected in this test";
}
@@ -32,35 +31,33 @@
ADD_FAILURE() << "onDrawDRRect not expected in this test";
}
void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint& paint) {
+ const SkPaint& paint) {
ADD_FAILURE() << "onDrawText not expected in this test";
}
void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
- const SkPaint& paint) {
+ const SkPaint& paint) {
ADD_FAILURE() << "onDrawPosText not expected in this test";
}
void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) {
+ const SkPaint& paint) {
ADD_FAILURE() << "onDrawPosTextH not expected in this test";
}
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
- const SkMatrix* matrix, const SkPaint& paint) {
+ const SkMatrix* matrix, const SkPaint& paint) {
ADD_FAILURE() << "onDrawTextOnPath not expected in this test";
}
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[],
- const SkRect* cullRect, const SkPaint& paint) {
+ const SkRect* cullRect, const SkPaint& paint) {
ADD_FAILURE() << "onDrawTextRSXform not expected in this test";
}
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) {
ADD_FAILURE() << "onDrawTextBlob not expected in this test";
}
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
- SkBlendMode, const SkPaint& paint) {
+ SkBlendMode, const SkPaint& paint) {
ADD_FAILURE() << "onDrawPatch not expected in this test";
}
- void onDrawPaint(const SkPaint&) {
- ADD_FAILURE() << "onDrawPaint not expected in this test";
- }
+ void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; }
void onDrawRect(const SkRect&, const SkPaint&) {
ADD_FAILURE() << "onDrawRect not expected in this test";
}
@@ -71,7 +68,7 @@
ADD_FAILURE() << "onDrawOval not expected in this test";
}
void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
- const SkPaint&) {
+ const SkPaint&) {
ADD_FAILURE() << "onDrawArc not expected in this test";
}
void onDrawRRect(const SkRRect&, const SkPaint&) {
@@ -84,7 +81,7 @@
ADD_FAILURE() << "onDrawVertices not expected in this test";
}
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
- SkBlendMode, const SkRect* cull, const SkPaint*) {
+ SkBlendMode, const SkRect* cull, const SkPaint*) {
ADD_FAILURE() << "onDrawAtlas not expected in this test";
}
void onDrawPath(const SkPath&, const SkPaint&) {
@@ -94,29 +91,29 @@
ADD_FAILURE() << "onDrawImage not expected in this test";
}
void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
- SrcRectConstraint) {
+ SrcRectConstraint) {
ADD_FAILURE() << "onDrawImageRect not expected in this test";
}
void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) {
ADD_FAILURE() << "onDrawImageNine not expected in this test";
}
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
- const SkPaint*) {
+ const SkPaint*) {
ADD_FAILURE() << "onDrawImageLattice not expected in this test";
}
void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*) {
ADD_FAILURE() << "onDrawBitmap not expected in this test";
}
void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
- SrcRectConstraint) {
+ SrcRectConstraint) {
ADD_FAILURE() << "onDrawBitmapRect not expected in this test";
}
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
- const SkPaint*) {
+ const SkPaint*) {
ADD_FAILURE() << "onDrawBitmapNine not expected in this test";
}
void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst,
- const SkPaint*) {
+ const SkPaint*) {
ADD_FAILURE() << "onDrawBitmapLattice not expected in this test";
}
void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) {
@@ -128,14 +125,11 @@
void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {
ADD_FAILURE() << "onClipRegion not expected in this test";
}
- void onDiscard() {
- ADD_FAILURE() << "onDiscard not expected in this test";
- }
+ void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; }
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) {
ADD_FAILURE() << "onDrawPicture not expected in this test";
}
- int mDrawCounter = 0; //counts how may draw calls of any kind were made to this canvas
+ int mDrawCounter = 0; // counts how may draw calls of any kind were made to this canvas
};
-
}
\ No newline at end of file
diff --git a/libs/hwui/tests/unit/FontRendererTests.cpp b/libs/hwui/tests/unit/FontRendererTests.cpp
index ee20236..c78f131 100644
--- a/libs/hwui/tests/unit/FontRendererTests.cpp
+++ b/libs/hwui/tests/unit/FontRendererTests.cpp
@@ -40,16 +40,16 @@
std::vector<float> positions;
float totalAdvance;
Rect bounds;
- TestUtils::layoutTextUnscaled(paint, "This is a test",
- &glyphs, &positions, &totalAdvance, &bounds);
+ TestUtils::layoutTextUnscaled(paint, "This is a test", &glyphs, &positions, &totalAdvance,
+ &bounds);
for (int radius : {28, 20, 2}) {
- auto result = fontRenderer.renderDropShadow(&paint, glyphs.data(), glyphs.size(),
- radius, positions.data());
+ auto result = fontRenderer.renderDropShadow(&paint, glyphs.data(), glyphs.size(), radius,
+ positions.data());
ASSERT_NE(nullptr, result.image);
EXPECT_FALSE(isZero(result.image, result.width * result.height));
- EXPECT_LE(bounds.getWidth() + radius * 2, (int) result.width);
- EXPECT_LE(bounds.getHeight() + radius * 2, (int) result.height);
+ EXPECT_LE(bounds.getWidth() + radius * 2, (int)result.width);
+ EXPECT_LE(bounds.getHeight() + radius * 2, (int)result.height);
delete result.image;
}
}
diff --git a/libs/hwui/tests/unit/FrameBuilderTests.cpp b/libs/hwui/tests/unit/FrameBuilderTests.cpp
index fcdd814..e56d2f8 100644
--- a/libs/hwui/tests/unit/FrameBuilderTests.cpp
+++ b/libs/hwui/tests/unit/FrameBuilderTests.cpp
@@ -30,7 +30,7 @@
namespace android {
namespace uirenderer {
-const FrameBuilder::LightGeometry sLightGeometry = { {100, 100, 100}, 50};
+const FrameBuilder::LightGeometry sLightGeometry = {{100, 100, 100}, 50};
/**
* Virtual class implemented by each test to redirect static operation / state transitions to
@@ -56,23 +56,21 @@
virtual void startRepaintLayer(OffscreenBuffer*, const Rect& repaintRect) {
ADD_FAILURE() << "Layer repaint not expected in this test";
}
- virtual void endLayer() {
- ADD_FAILURE() << "Layer updates not expected in this test";
- }
+ virtual void endLayer() { ADD_FAILURE() << "Layer updates not expected in this test"; }
virtual void startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) {}
virtual void endFrame(const Rect& repaintRect) {}
- // define virtual defaults for single draw methods
-#define X(Type) \
+// define virtual defaults for single draw methods
+#define X(Type) \
virtual void on##Type(const Type&, const BakedOpState&) { \
- ADD_FAILURE() << #Type " not expected in this test"; \
+ ADD_FAILURE() << #Type " not expected in this test"; \
}
MAP_RENDERABLE_OPS(X)
#undef X
- // define virtual defaults for merged draw methods
-#define X(Type) \
- virtual void onMerged##Type##s(const MergedBakedOpList& opList) { \
+// define virtual defaults for merged draw methods
+#define X(Type) \
+ virtual void onMerged##Type##s(const MergedBakedOpList& opList) { \
ADD_FAILURE() << "Merged " #Type "s not expected in this test"; \
}
MAP_MERGEABLE_OPS(X)
@@ -90,18 +88,18 @@
*/
class TestDispatcher {
public:
- // define single op methods, which redirect to TestRendererBase
-#define X(Type) \
+// define single op methods, which redirect to TestRendererBase
+#define X(Type) \
static void on##Type(TestRendererBase& renderer, const Type& op, const BakedOpState& state) { \
- renderer.on##Type(op, state); \
+ renderer.on##Type(op, state); \
}
MAP_RENDERABLE_OPS(X);
#undef X
- // define merged op methods, which redirect to TestRendererBase
-#define X(Type) \
+// define merged op methods, which redirect to TestRendererBase
+#define X(Type) \
static void onMerged##Type##s(TestRendererBase& renderer, const MergedBakedOpList& opList) { \
- renderer.onMerged##Type##s(opList); \
+ renderer.onMerged##Type##s(opList); \
}
MAP_MERGEABLE_OPS(X);
#undef X
@@ -123,24 +121,22 @@
void onBitmapOp(const BitmapOp& op, const BakedOpState& state) override {
EXPECT_EQ(2, mIndex++);
}
- void endFrame(const Rect& repaintRect) override {
- EXPECT_EQ(3, mIndex++);
- }
+ void endFrame(const Rect& repaintRect) override { EXPECT_EQ(3, mIndex++); }
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- sk_sp<Bitmap> bitmap(TestUtils::createBitmap(25, 25));
- canvas.drawRect(0, 0, 100, 200, SkPaint());
- canvas.drawBitmap(*bitmap, 10, 10, nullptr);
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 200), 100, 200,
- sLightGeometry, Caches::getInstance());
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(25, 25));
+ canvas.drawRect(0, 0, 100, 200, SkPaint());
+ canvas.drawBitmap(*bitmap, 10, 10, nullptr);
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 200), 100, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SimpleTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
- EXPECT_EQ(4, renderer.getIndex()); // 2 ops + start + end
+ EXPECT_EQ(4, renderer.getIndex()); // 2 ops + start + end
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, simpleStroke) {
@@ -156,14 +152,14 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- SkPaint strokedPaint;
- strokedPaint.setStrokeWidth(10);
- canvas.drawPoint(50, 50, strokedPaint);
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 200), 100, 200,
- sLightGeometry, Caches::getInstance());
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPaint strokedPaint;
+ strokedPaint.setStrokeWidth(10);
+ canvas.drawPoint(50, 50, strokedPaint);
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 200), 100, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SimpleStrokeTestRenderer renderer;
@@ -171,7 +167,6 @@
EXPECT_EQ(1, renderer.getIndex());
}
-
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, arcStrokeClip) {
class ArcStrokeClipTestRenderer : public TestRendererBase {
public:
@@ -184,15 +179,15 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.clipRect(25, 25, 175, 175, SkClipOp::kIntersect);
- SkPaint aaPaint;
- aaPaint.setAntiAlias(true);
- canvas.drawArc(25, 25, 175, 175, 40, 180, true, aaPaint);
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.clipRect(25, 25, 175, 175, SkClipOp::kIntersect);
+ SkPaint aaPaint;
+ aaPaint.setAntiAlias(true);
+ canvas.drawArc(25, 25, 175, 175, 40, 180, true, aaPaint);
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
ArcStrokeClipTestRenderer renderer;
@@ -201,15 +196,15 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, simpleRejection) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
+ auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200, [](RenderProperties& props,
+ RecordingCanvas& canvas) {
canvas.save(SaveFlags::MatrixClip);
- canvas.clipRect(200, 200, 400, 400, SkClipOp::kIntersect); // intersection should be empty
+ canvas.clipRect(200, 200, 400, 400, SkClipOp::kIntersect); // intersection should be empty
canvas.drawRect(0, 0, 400, 400, SkPaint());
canvas.restore();
});
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
FailRenderer renderer;
@@ -228,30 +223,30 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
- sk_sp<Bitmap> bitmap(TestUtils::createBitmap(10, 10,
- kAlpha_8_SkColorType)); // Disable merging by using alpha 8 bitmap
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(
+ 10, 10,
+ kAlpha_8_SkColorType)); // Disable merging by using alpha 8 bitmap
- // Alternate between drawing rects and bitmaps, with bitmaps overlapping rects.
- // Rects don't overlap bitmaps, so bitmaps should be brought to front as a group.
- canvas.save(SaveFlags::MatrixClip);
- for (int i = 0; i < LOOPS; i++) {
- canvas.translate(0, 10);
- canvas.drawRect(0, 0, 10, 10, SkPaint());
- canvas.drawBitmap(*bitmap, 5, 0, nullptr);
- }
- canvas.restore();
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ // Alternate between drawing rects and bitmaps, with bitmaps overlapping rects.
+ // Rects don't overlap bitmaps, so bitmaps should be brought to front as a group.
+ canvas.save(SaveFlags::MatrixClip);
+ for (int i = 0; i < LOOPS; i++) {
+ canvas.translate(0, 10);
+ canvas.drawRect(0, 0, 10, 10, SkPaint());
+ canvas.drawBitmap(*bitmap, 5, 0, nullptr);
+ }
+ canvas.restore();
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SimpleBatchingTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
- EXPECT_EQ(2 * LOOPS, renderer.getIndex())
- << "Expect number of ops = 2 * loop count";
+ EXPECT_EQ(2 * LOOPS, renderer.getIndex()) << "Expect number of ops = 2 * loop count";
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, deferRenderNode_translateClip) {
@@ -261,19 +256,19 @@
EXPECT_EQ(0, mIndex++);
EXPECT_EQ(Rect(5, 10, 55, 60), state.computedState.clippedBounds);
EXPECT_EQ(OpClipSideFlags::Right | OpClipSideFlags::Bottom,
- state.computedState.clipSideFlags);
+ state.computedState.clipSideFlags);
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 100, 100, SkPaint());
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 100, 100, SkPaint());
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
- frameBuilder.deferRenderNode(5, 10, Rect(50, 50), // translate + clip node
- *TestUtils::getSyncedNode(node));
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
+ frameBuilder.deferRenderNode(5, 10, Rect(50, 50), // translate + clip node
+ *TestUtils::getSyncedNode(node));
DeferRenderNodeTranslateClipTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
@@ -287,27 +282,27 @@
const Rect& clippedBounds = state.computedState.clippedBounds;
Matrix4 expected;
switch (mIndex++) {
- case 0:
- // background - left side
- EXPECT_EQ(Rect(600, 100, 700, 500), clippedBounds);
- expected.loadTranslate(100, 100, 0);
- break;
- case 1:
- // background - top side
- EXPECT_EQ(Rect(100, 400, 600, 500), clippedBounds);
- expected.loadTranslate(100, 100, 0);
- break;
- case 2:
- // content
- EXPECT_EQ(Rect(100, 100, 700, 500), clippedBounds);
- expected.loadTranslate(-50, -50, 0);
- break;
- case 3:
- // overlay
- EXPECT_EQ(Rect(0, 0, 800, 200), clippedBounds);
- break;
- default:
- ADD_FAILURE() << "Too many rects observed";
+ case 0:
+ // background - left side
+ EXPECT_EQ(Rect(600, 100, 700, 500), clippedBounds);
+ expected.loadTranslate(100, 100, 0);
+ break;
+ case 1:
+ // background - top side
+ EXPECT_EQ(Rect(100, 400, 600, 500), clippedBounds);
+ expected.loadTranslate(100, 100, 0);
+ break;
+ case 2:
+ // content
+ EXPECT_EQ(Rect(100, 100, 700, 500), clippedBounds);
+ expected.loadTranslate(-50, -50, 0);
+ break;
+ case 3:
+ // overlay
+ EXPECT_EQ(Rect(0, 0, 800, 200), clippedBounds);
+ break;
+ default:
+ ADD_FAILURE() << "Too many rects observed";
}
EXPECT_EQ(expected, state.computedState.transform);
}
@@ -318,31 +313,32 @@
transparentPaint.setAlpha(128);
// backdrop
- nodes.push_back(TestUtils::createNode<RecordingCanvas>(100, 100, 700, 500, // 600x400
+ nodes.push_back(TestUtils::createNode<RecordingCanvas>(
+ 100, 100, 700, 500, // 600x400
[&transparentPaint](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 600, 400, transparentPaint);
- }));
+ canvas.drawRect(0, 0, 600, 400, transparentPaint);
+ }));
// content
- Rect contentDrawBounds(150, 150, 650, 450); // 500x300
- nodes.push_back(TestUtils::createNode<RecordingCanvas>(0, 0, 800, 600,
- [&transparentPaint](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 800, 600, transparentPaint);
- }));
+ Rect contentDrawBounds(150, 150, 650, 450); // 500x300
+ nodes.push_back(TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 800, 600, [&transparentPaint](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 800, 600, transparentPaint);
+ }));
// overlay
- nodes.push_back(TestUtils::createNode<RecordingCanvas>(0, 0, 800, 600,
- [&transparentPaint](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 800, 200, transparentPaint);
- }));
+ nodes.push_back(TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 800, 600, [&transparentPaint](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 800, 200, transparentPaint);
+ }));
for (auto& node : nodes) {
TestUtils::syncHierarchyPropertiesAndDisplayList(node);
}
{
- FrameBuilder frameBuilder(SkRect::MakeWH(800, 600), 800, 600,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(800, 600), 800, 600, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNodeScene(nodes, contentDrawBounds);
DeferRenderNodeSceneTestRenderer renderer;
@@ -363,8 +359,8 @@
{
// Validate no crashes if any nodes are missing DisplayLists
- FrameBuilder frameBuilder(SkRect::MakeWH(800, 600), 800, 600,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(800, 600), 800, 600, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNodeScene(nodes, contentDrawBounds);
FailRenderer renderer;
@@ -396,24 +392,22 @@
void startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) override {
EXPECT_EQ(0, mIndex++);
}
- void endFrame(const Rect& repaintRect) override {
- EXPECT_EQ(1, mIndex++);
- }
+ void endFrame(const Rect& repaintRect) override { EXPECT_EQ(1, mIndex++); }
};
- auto node = TestUtils::createNode<RecordingCanvas>(10, 10, 110, 110,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- // no drawn content
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 10, 10, 110, 110, [](RenderProperties& props, RecordingCanvas& canvas) {
+ // no drawn content
+ });
// Draw, but pass node without draw content, so no work is done for primary frame
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
EmptyWithFbo0TestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
EXPECT_EQ(2, renderer.getIndex()) << "No drawing content produced,"
- " but fbo0 update lifecycle should still be observed";
+ " but fbo0 update lifecycle should still be observed";
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, avoidOverdraw_rects) {
@@ -425,17 +419,17 @@
<< "Last rect should occlude others.";
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 200, 200, SkPaint());
- canvas.drawRect(0, 0, 200, 200, SkPaint());
- canvas.drawRect(10, 10, 190, 190, SkPaint());
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 200, 200, SkPaint());
+ canvas.drawRect(0, 0, 200, 200, SkPaint());
+ canvas.drawRect(10, 10, 190, 190, SkPaint());
+ });
// Damage (and therefore clip) is same as last draw, subset of renderable area.
// This means last op occludes other contents, and they'll be rejected to avoid overdraw.
- FrameBuilder frameBuilder(SkRect::MakeLTRB(10, 10, 190, 190), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeLTRB(10, 10, 190, 190), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
EXPECT_EQ(3u, node->getDisplayList()->getOps().size())
@@ -447,38 +441,38 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, avoidOverdraw_bitmaps) {
- static sk_sp<Bitmap> opaqueBitmap(TestUtils::createBitmap(50, 50,
- SkColorType::kRGB_565_SkColorType));
- static sk_sp<Bitmap> transpBitmap(TestUtils::createBitmap(50, 50,
- SkColorType::kAlpha_8_SkColorType));
+ static sk_sp<Bitmap> opaqueBitmap(
+ TestUtils::createBitmap(50, 50, SkColorType::kRGB_565_SkColorType));
+ static sk_sp<Bitmap> transpBitmap(
+ TestUtils::createBitmap(50, 50, SkColorType::kAlpha_8_SkColorType));
class AvoidOverdrawBitmapsTestRenderer : public TestRendererBase {
public:
void onBitmapOp(const BitmapOp& op, const BakedOpState& state) override {
- switch(mIndex++) {
- case 0:
- EXPECT_EQ(opaqueBitmap.get(), op.bitmap);
- break;
- case 1:
- EXPECT_EQ(transpBitmap.get(), op.bitmap);
- break;
- default:
- ADD_FAILURE() << "Only two ops expected.";
+ switch (mIndex++) {
+ case 0:
+ EXPECT_EQ(opaqueBitmap.get(), op.bitmap);
+ break;
+ case 1:
+ EXPECT_EQ(transpBitmap.get(), op.bitmap);
+ break;
+ default:
+ ADD_FAILURE() << "Only two ops expected.";
}
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 50, 50,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 50, 50, SkPaint());
- canvas.drawRect(0, 0, 50, 50, SkPaint());
- canvas.drawBitmap(*transpBitmap, 0, 0, nullptr);
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 50, 50, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 50, 50, SkPaint());
+ canvas.drawRect(0, 0, 50, 50, SkPaint());
+ canvas.drawBitmap(*transpBitmap, 0, 0, nullptr);
- // only the below draws should remain, since they're
- canvas.drawBitmap(*opaqueBitmap, 0, 0, nullptr);
- canvas.drawBitmap(*transpBitmap, 0, 0, nullptr);
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(50, 50), 50, 50,
- sLightGeometry, Caches::getInstance());
+ // only the below draws should remain, since they're
+ canvas.drawBitmap(*opaqueBitmap, 0, 0, nullptr);
+ canvas.drawBitmap(*transpBitmap, 0, 0, nullptr);
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(50, 50), 50, 50, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
EXPECT_EQ(5u, node->getDisplayList()->getOps().size())
@@ -498,32 +492,32 @@
EXPECT_EQ(4u, opList.count);
EXPECT_EQ(Rect(10, 10, 90, 90), opList.clip);
EXPECT_EQ(OpClipSideFlags::Left | OpClipSideFlags::Top | OpClipSideFlags::Right,
- opList.clipSideFlags);
+ opList.clipSideFlags);
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- sk_sp<Bitmap> bitmap(TestUtils::createBitmap(20, 20));
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(20, 20));
- // left side clipped (to inset left half)
- canvas.clipRect(10, 0, 50, 100, SkClipOp::kReplace_deprecated);
- canvas.drawBitmap(*bitmap, 0, 40, nullptr);
+ // left side clipped (to inset left half)
+ canvas.clipRect(10, 0, 50, 100, SkClipOp::kReplace_deprecated);
+ canvas.drawBitmap(*bitmap, 0, 40, nullptr);
- // top side clipped (to inset top half)
- canvas.clipRect(0, 10, 100, 50, SkClipOp::kReplace_deprecated);
- canvas.drawBitmap(*bitmap, 40, 0, nullptr);
+ // top side clipped (to inset top half)
+ canvas.clipRect(0, 10, 100, 50, SkClipOp::kReplace_deprecated);
+ canvas.drawBitmap(*bitmap, 40, 0, nullptr);
- // right side clipped (to inset right half)
- canvas.clipRect(50, 0, 90, 100, SkClipOp::kReplace_deprecated);
- canvas.drawBitmap(*bitmap, 80, 40, nullptr);
+ // right side clipped (to inset right half)
+ canvas.clipRect(50, 0, 90, 100, SkClipOp::kReplace_deprecated);
+ canvas.drawBitmap(*bitmap, 80, 40, nullptr);
- // bottom not clipped, just abutting (inset bottom half)
- canvas.clipRect(0, 50, 100, 90, SkClipOp::kReplace_deprecated);
- canvas.drawBitmap(*bitmap, 40, 70, nullptr);
- });
+ // bottom not clipped, just abutting (inset bottom half)
+ canvas.clipRect(0, 50, 100, 90, SkClipOp::kReplace_deprecated);
+ canvas.drawBitmap(*bitmap, 40, 70, nullptr);
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
ClippedMergingTestRenderer renderer;
@@ -536,23 +530,23 @@
public:
void onTextOp(const TextOp& op, const BakedOpState& state) override { mIndex++; }
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- SkPath path;
- path.addCircle(200, 200, 200, SkPath::kCW_Direction);
- canvas.save(SaveFlags::MatrixClip);
- canvas.clipPath(&path, SkClipOp::kIntersect);
- SkPaint paint;
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- paint.setAntiAlias(true);
- paint.setTextSize(50);
- TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 100);
- TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 200);
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400, [](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPath path;
+ path.addCircle(200, 200, 200, SkPath::kCW_Direction);
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.clipPath(&path, SkClipOp::kIntersect);
+ SkPaint paint;
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ paint.setAntiAlias(true);
+ paint.setTextSize(50);
+ TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 100);
+ TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 200);
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
RegionClipStopsMergeTestRenderer renderer;
@@ -572,17 +566,17 @@
EXPECT_EQ(OpClipSideFlags::None, opList.states[1]->computedState.clipSideFlags);
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
- [](RenderProperties& props, RecordingCanvas& canvas) {
+ auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400, [](RenderProperties& props,
+ RecordingCanvas& canvas) {
SkPaint paint;
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
paint.setAntiAlias(true);
paint.setTextSize(50);
- TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 0); // will be top clipped
- TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 100); // not clipped
+ TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 0); // will be top clipped
+ TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 100); // not clipped
});
- FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
TextMergingTestRenderer renderer;
@@ -603,30 +597,28 @@
EXPECT_EQ(5u, opList.count);
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 2000,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- SkPaint textPaint;
- textPaint.setAntiAlias(true);
- textPaint.setTextSize(20);
- textPaint.setFlags(textPaint.getFlags() | SkPaint::kStrikeThruText_ReserveFlag);
- textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- for (int i = 0; i < LOOPS; i++) {
- TestUtils::drawUtf8ToCanvas(&canvas, "test text", textPaint, 10, 100 * (i + 1));
- }
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 2000, [](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPaint textPaint;
+ textPaint.setAntiAlias(true);
+ textPaint.setTextSize(20);
+ textPaint.setFlags(textPaint.getFlags() | SkPaint::kStrikeThruText_ReserveFlag);
+ textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ for (int i = 0; i < LOOPS; i++) {
+ TestUtils::drawUtf8ToCanvas(&canvas, "test text", textPaint, 10, 100 * (i + 1));
+ }
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 2000), 200, 2000,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 2000), 200, 2000, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
TextStrikethroughTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
- EXPECT_EQ(2 * LOOPS, renderer.getIndex())
- << "Expect number of ops = 2 * loop count";
+ EXPECT_EQ(2 * LOOPS, renderer.getIndex()) << "Expect number of ops = 2 * loop count";
}
-static auto styles = {
- SkPaint::kFill_Style, SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style };
+static auto styles = {SkPaint::kFill_Style, SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style};
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, textStyle) {
class TextStyleTestRenderer : public TestRendererBase {
@@ -659,23 +651,23 @@
EXPECT_EQ(stroke, outsetFill);
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- SkPaint paint;
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- paint.setAntiAlias(true);
- paint.setTextSize(50);
- paint.setStrokeWidth(10);
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400, [](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPaint paint;
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ paint.setAntiAlias(true);
+ paint.setTextSize(50);
+ paint.setStrokeWidth(10);
- // draw 3 copies of the same text overlapping, each with a different style.
- // They'll get merged, but with
- for (auto style : styles) {
- paint.setStyle(style);
- TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 100);
- }
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400,
- sLightGeometry, Caches::getInstance());
+ // draw 3 copies of the same text overlapping, each with a different style.
+ // They'll get merged, but with
+ for (auto style : styles) {
+ paint.setStyle(style);
+ TestUtils::drawUtf8ToCanvas(&canvas, "Test string1", paint, 100, 100);
+ }
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
TextStyleTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
@@ -696,19 +688,19 @@
}
};
- auto layerUpdater = TestUtils::createTextureLayerUpdater(renderThread, 100, 100,
- SkMatrix::MakeTrans(5, 5));
+ auto layerUpdater =
+ TestUtils::createTextureLayerUpdater(renderThread, 100, 100, SkMatrix::MakeTrans(5, 5));
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [&layerUpdater](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.save(SaveFlags::MatrixClip);
- canvas.clipRect(50, 50, 150, 150, SkClipOp::kIntersect);
- canvas.drawLayer(layerUpdater.get());
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [&layerUpdater](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.clipRect(50, 50, 150, 150, SkClipOp::kIntersect);
+ canvas.drawLayer(layerUpdater.get());
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
TextureLayerClipLocalMatrixTestRenderer renderer;
@@ -728,19 +720,19 @@
}
};
- auto layerUpdater = TestUtils::createTextureLayerUpdater(renderThread, 100, 100,
- SkMatrix::MakeTrans(5, 5));
+ auto layerUpdater =
+ TestUtils::createTextureLayerUpdater(renderThread, 100, 100, SkMatrix::MakeTrans(5, 5));
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [&layerUpdater](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.save(SaveFlags::MatrixClip);
- canvas.translate(30, 40);
- canvas.drawLayer(layerUpdater.get());
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [&layerUpdater](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.translate(30, 40);
+ canvas.drawLayer(layerUpdater.get());
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
TextureLayerCombineMatricesTestRenderer renderer;
@@ -749,20 +741,20 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, textureLayer_reject) {
- auto layerUpdater = TestUtils::createTextureLayerUpdater(renderThread, 100, 100,
- SkMatrix::MakeTrans(5, 5));
+ auto layerUpdater =
+ TestUtils::createTextureLayerUpdater(renderThread, 100, 100, SkMatrix::MakeTrans(5, 5));
EXPECT_EQ(Layer::Api::OpenGL, layerUpdater->backingLayer()->getApi());
GlLayer* glLayer = static_cast<GlLayer*>(layerUpdater->backingLayer());
- glLayer->setRenderTarget(GL_NONE); // Should be rejected
+ glLayer->setRenderTarget(GL_NONE); // Should be rejected
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [&layerUpdater](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.drawLayer(layerUpdater.get());
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [&layerUpdater](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.drawLayer(layerUpdater.get());
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
FailRenderer renderer;
@@ -779,14 +771,14 @@
Functor noopFunctor;
// 1 million pixel tall view, scrolled down 80%
- auto scrolledFunctorView = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 1000000,
- [&noopFunctor](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.translate(0, -800000);
- canvas.callDrawGLFunction(&noopFunctor, nullptr);
- });
+ auto scrolledFunctorView = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 1000000, [&noopFunctor](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.translate(0, -800000);
+ canvas.callDrawGLFunction(&noopFunctor, nullptr);
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(scrolledFunctorView));
FunctorTestRenderer renderer;
@@ -804,14 +796,14 @@
}
};
- auto unclippedColorView = TestUtils::createNode<RecordingCanvas>(0, 0, 10, 10,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setClipToBounds(false);
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- });
+ auto unclippedColorView = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 10, 10, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setClipToBounds(false);
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(unclippedColorView));
ColorTestRenderer renderer;
@@ -823,42 +815,42 @@
class RenderNodeTestRenderer : public TestRendererBase {
public:
void onRectOp(const RectOp& op, const BakedOpState& state) override {
- switch(mIndex++) {
- case 0:
- EXPECT_EQ(Rect(200, 200), state.computedState.clippedBounds);
- EXPECT_EQ(SK_ColorDKGRAY, op.paint->getColor());
- break;
- case 1:
- EXPECT_EQ(Rect(50, 50, 150, 150), state.computedState.clippedBounds);
- EXPECT_EQ(SK_ColorWHITE, op.paint->getColor());
- break;
- default:
- ADD_FAILURE();
+ switch (mIndex++) {
+ case 0:
+ EXPECT_EQ(Rect(200, 200), state.computedState.clippedBounds);
+ EXPECT_EQ(SK_ColorDKGRAY, op.paint->getColor());
+ break;
+ case 1:
+ EXPECT_EQ(Rect(50, 50, 150, 150), state.computedState.clippedBounds);
+ EXPECT_EQ(SK_ColorWHITE, op.paint->getColor());
+ break;
+ default:
+ ADD_FAILURE();
}
}
};
- auto child = TestUtils::createNode<RecordingCanvas>(10, 10, 110, 110,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ auto child = TestUtils::createNode<RecordingCanvas>(
+ 10, 10, 110, 110, [](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [&child](RenderProperties& props, RecordingCanvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorDKGRAY);
- canvas.drawRect(0, 0, 200, 200, paint);
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [&child](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPaint paint;
+ paint.setColor(SK_ColorDKGRAY);
+ canvas.drawRect(0, 0, 200, 200, paint);
- canvas.save(SaveFlags::MatrixClip);
- canvas.translate(40, 40);
- canvas.drawRenderNode(child.get());
- canvas.restore();
- });
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.translate(40, 40);
+ canvas.drawRenderNode(child.get());
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
RenderNodeTestRenderer renderer;
@@ -877,15 +869,15 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- sk_sp<Bitmap> bitmap(TestUtils::createBitmap(200, 200));
- canvas.drawBitmap(*bitmap, 0, 0, nullptr);
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(200, 200));
+ canvas.drawBitmap(*bitmap, 0, 0, nullptr);
+ });
// clip to small area, should see in receiver
- FrameBuilder frameBuilder(SkRect::MakeLTRB(10, 20, 30, 40), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeLTRB(10, 20, 30, 40), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
ClippedTestRenderer renderer;
@@ -901,9 +893,7 @@
EXPECT_EQ(180u, height);
return nullptr;
}
- void endLayer() override {
- EXPECT_EQ(2, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(2, mIndex++); }
void onRectOp(const RectOp& op, const BakedOpState& state) override {
EXPECT_EQ(1, mIndex++);
EXPECT_EQ(Rect(10, 10, 190, 190), op.unmappedBounds);
@@ -926,15 +916,15 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(10, 10, 190, 190, 128, SaveFlags::ClipToLayer);
- canvas.drawRect(10, 10, 190, 190, SkPaint());
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.saveLayerAlpha(10, 10, 190, 190, 128, SaveFlags::ClipToLayer);
+ canvas.drawRect(10, 10, 190, 190, SkPaint());
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerSimpleTestRenderer renderer;
@@ -955,13 +945,15 @@
if (index == 0) {
EXPECT_EQ(400u, width);
EXPECT_EQ(400u, height);
- return (OffscreenBuffer*) 0x400;
+ return (OffscreenBuffer*)0x400;
} else if (index == 3) {
EXPECT_EQ(800u, width);
EXPECT_EQ(800u, height);
- return (OffscreenBuffer*) 0x800;
- } else { ADD_FAILURE(); }
- return (OffscreenBuffer*) nullptr;
+ return (OffscreenBuffer*)0x800;
+ } else {
+ ADD_FAILURE();
+ }
+ return (OffscreenBuffer*)nullptr;
}
void endLayer() override {
int index = mIndex++;
@@ -970,26 +962,28 @@
void startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) override {
EXPECT_EQ(7, mIndex++);
}
- void endFrame(const Rect& repaintRect) override {
- EXPECT_EQ(9, mIndex++);
- }
+ void endFrame(const Rect& repaintRect) override { EXPECT_EQ(9, mIndex++); }
void onRectOp(const RectOp& op, const BakedOpState& state) override {
const int index = mIndex++;
if (index == 1) {
- EXPECT_EQ(Rect(400, 400), op.unmappedBounds); // inner rect
+ EXPECT_EQ(Rect(400, 400), op.unmappedBounds); // inner rect
} else if (index == 4) {
- EXPECT_EQ(Rect(800, 800), op.unmappedBounds); // outer rect
- } else { ADD_FAILURE(); }
+ EXPECT_EQ(Rect(800, 800), op.unmappedBounds); // outer rect
+ } else {
+ ADD_FAILURE();
+ }
}
void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
const int index = mIndex++;
if (index == 5) {
EXPECT_EQ((OffscreenBuffer*)0x400, *op.layerHandle);
- EXPECT_EQ(Rect(400, 400), op.unmappedBounds); // inner layer
+ EXPECT_EQ(Rect(400, 400), op.unmappedBounds); // inner layer
} else if (index == 8) {
EXPECT_EQ((OffscreenBuffer*)0x800, *op.layerHandle);
- EXPECT_EQ(Rect(800, 800), op.unmappedBounds); // outer layer
- } else { ADD_FAILURE(); }
+ EXPECT_EQ(Rect(800, 800), op.unmappedBounds); // outer layer
+ } else {
+ ADD_FAILURE();
+ }
}
void recycleTemporaryLayer(OffscreenBuffer* offscreenBuffer) override {
const int index = mIndex++;
@@ -998,26 +992,26 @@
EXPECT_EQ((OffscreenBuffer*)0x400, offscreenBuffer);
} else if (index == 11) {
EXPECT_EQ((OffscreenBuffer*)0x800, offscreenBuffer);
- } else { ADD_FAILURE(); }
+ } else {
+ ADD_FAILURE();
+ }
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 800, 800,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(0, 0, 800, 800, 128, SaveFlags::ClipToLayer);
- {
- canvas.drawRect(0, 0, 800, 800, SkPaint());
- canvas.saveLayerAlpha(0, 0, 400, 400, 128, SaveFlags::ClipToLayer);
- {
- canvas.drawRect(0, 0, 400, 400, SkPaint());
- }
- canvas.restore();
- }
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 800, 800, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.saveLayerAlpha(0, 0, 800, 800, 128, SaveFlags::ClipToLayer);
+ {
+ canvas.drawRect(0, 0, 800, 800, SkPaint());
+ canvas.saveLayerAlpha(0, 0, 400, 400, 128, SaveFlags::ClipToLayer);
+ { canvas.drawRect(0, 0, 400, 400, SkPaint()); }
+ canvas.restore();
+ }
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(800, 800), 800, 800,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(800, 800), 800, 800, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerNestedTestRenderer renderer;
@@ -1026,21 +1020,21 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, saveLayer_contentRejection) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.save(SaveFlags::MatrixClip);
- canvas.clipRect(200, 200, 400, 400, SkClipOp::kIntersect);
- canvas.saveLayerAlpha(200, 200, 400, 400, 128, SaveFlags::ClipToLayer);
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.clipRect(200, 200, 400, 400, SkClipOp::kIntersect);
+ canvas.saveLayerAlpha(200, 200, 400, 400, 128, SaveFlags::ClipToLayer);
- // draw within save layer may still be recorded, but shouldn't be drawn
- canvas.drawRect(200, 200, 400, 400, SkPaint());
+ // draw within save layer may still be recorded, but shouldn't be drawn
+ canvas.drawRect(200, 200, 400, 400, SkPaint());
- canvas.restore();
- canvas.restore();
- });
+ canvas.restore();
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
FailRenderer renderer;
@@ -1077,15 +1071,15 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0));
- canvas.drawRect(0, 0, 200, 200, SkPaint());
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0));
+ canvas.drawRect(0, 0, 200, 200, SkPaint());
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerUnclippedSimpleTestRenderer renderer;
@@ -1110,16 +1104,16 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(10.95f, 10.5f, 189.75f, 189.25f, // values should all round out
- 128, (SaveFlags::Flags)(0));
+ auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200, [](RenderProperties& props,
+ RecordingCanvas& canvas) {
+ canvas.saveLayerAlpha(10.95f, 10.5f, 189.75f, 189.25f, // values should all round out
+ 128, (SaveFlags::Flags)(0));
canvas.drawRect(0, 0, 200, 200, SkPaint());
canvas.restore();
});
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerUnclippedRoundTestRenderer renderer;
@@ -1162,21 +1156,21 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
- int restoreTo = canvas.save(SaveFlags::MatrixClip);
- canvas.scale(2, 2);
- canvas.saveLayerAlpha(0, 0, 5, 5, 128, SaveFlags::MatrixClip);
- canvas.saveLayerAlpha(95, 0, 100, 5, 128, SaveFlags::MatrixClip);
- canvas.saveLayerAlpha(0, 95, 5, 100, 128, SaveFlags::MatrixClip);
- canvas.saveLayerAlpha(95, 95, 100, 100, 128, SaveFlags::MatrixClip);
- canvas.drawRect(0, 0, 100, 100, SkPaint());
- canvas.restoreToCount(restoreTo);
- });
+ int restoreTo = canvas.save(SaveFlags::MatrixClip);
+ canvas.scale(2, 2);
+ canvas.saveLayerAlpha(0, 0, 5, 5, 128, SaveFlags::MatrixClip);
+ canvas.saveLayerAlpha(95, 0, 100, 5, 128, SaveFlags::MatrixClip);
+ canvas.saveLayerAlpha(0, 95, 5, 100, 128, SaveFlags::MatrixClip);
+ canvas.saveLayerAlpha(95, 95, 100, 100, 128, SaveFlags::MatrixClip);
+ canvas.drawRect(0, 0, 100, 100, SkPaint());
+ canvas.restoreToCount(restoreTo);
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerUnclippedMergedClearsTestRenderer renderer;
@@ -1209,17 +1203,17 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- // save smaller than clip, so we get unclipped behavior
- canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0));
- canvas.drawRect(0, 0, 200, 200, SkPaint());
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ // save smaller than clip, so we get unclipped behavior
+ canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0));
+ canvas.drawRect(0, 0, 200, 200, SkPaint());
+ canvas.restore();
+ });
// draw with partial screen dirty, and assert we see that rect later
- FrameBuilder frameBuilder(SkRect::MakeLTRB(50, 50, 150, 150), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeLTRB(50, 50, 150, 150), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerUnclippedClearClipTestRenderer renderer;
@@ -1228,17 +1222,17 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, saveLayerUnclipped_reject) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- // unclipped savelayer + rect both in area that won't intersect with dirty
- canvas.saveLayerAlpha(100, 100, 200, 200, 128, (SaveFlags::Flags)(0));
- canvas.drawRect(100, 100, 200, 200, SkPaint());
- canvas.restore();
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ // unclipped savelayer + rect both in area that won't intersect with dirty
+ canvas.saveLayerAlpha(100, 100, 200, 200, 128, (SaveFlags::Flags)(0));
+ canvas.drawRect(100, 100, 200, 200, SkPaint());
+ canvas.restore();
+ });
// draw with partial screen dirty that doesn't intersect with savelayer
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
FailRenderer renderer;
@@ -1253,7 +1247,7 @@
class SaveLayerUnclippedComplexTestRenderer : public TestRendererBase {
public:
OffscreenBuffer* startTemporaryLayer(uint32_t width, uint32_t height) {
- EXPECT_EQ(0, mIndex++); // savelayer first
+ EXPECT_EQ(0, mIndex++); // savelayer first
return (OffscreenBuffer*)0xabcd;
}
void onCopyToLayerOp(const CopyToLayerOp& op, const BakedOpState& state) override {
@@ -1275,9 +1269,7 @@
int index = mIndex++;
EXPECT_TRUE(index == 4 || index == 10);
}
- void endLayer() override {
- EXPECT_EQ(5, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(5, mIndex++); }
void startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) override {
EXPECT_EQ(6, mIndex++);
}
@@ -1285,28 +1277,27 @@
EXPECT_EQ(9, mIndex++);
EXPECT_EQ((OffscreenBuffer*)0xabcd, *op.layerHandle);
}
- void endFrame(const Rect& repaintRect) override {
- EXPECT_EQ(11, mIndex++);
- }
+ void endFrame(const Rect& repaintRect) override { EXPECT_EQ(11, mIndex++); }
void recycleTemporaryLayer(OffscreenBuffer* offscreenBuffer) override {
EXPECT_EQ(12, mIndex++);
EXPECT_EQ((OffscreenBuffer*)0xabcd, offscreenBuffer);
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 600, 600, // 500x500 triggers clipping
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 600, 600, // 500x500 triggers clipping
[](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(0, 0, 500, 500, 128, (SaveFlags::Flags)0); // unclipped
- canvas.saveLayerAlpha(100, 100, 400, 400, 128, SaveFlags::ClipToLayer); // clipped
- canvas.saveLayerAlpha(200, 200, 300, 300, 128, (SaveFlags::Flags)0); // unclipped
- canvas.drawRect(200, 200, 300, 300, SkPaint());
- canvas.restore();
- canvas.restore();
- canvas.restore();
- });
+ canvas.saveLayerAlpha(0, 0, 500, 500, 128, (SaveFlags::Flags)0); // unclipped
+ canvas.saveLayerAlpha(100, 100, 400, 400, 128, SaveFlags::ClipToLayer); // clipped
+ canvas.saveLayerAlpha(200, 200, 300, 300, 128, (SaveFlags::Flags)0); // unclipped
+ canvas.drawRect(200, 200, 300, 300, SkPaint());
+ canvas.restore();
+ canvas.restore();
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(600, 600), 600, 600,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(600, 600), 600, 600, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
SaveLayerUnclippedComplexTestRenderer renderer;
@@ -1332,27 +1323,23 @@
EXPECT_EQ(Rect(25, 25, 75, 75), state.computedState.clipRect())
<< "Damage rect should be used to clip layer content";
}
- void endLayer() override {
- EXPECT_EQ(2, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(2, mIndex++); }
void startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) override {
EXPECT_EQ(3, mIndex++);
}
void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
EXPECT_EQ(4, mIndex++);
}
- void endFrame(const Rect& repaintRect) override {
- EXPECT_EQ(5, mIndex++);
- }
+ void endFrame(const Rect& repaintRect) override { EXPECT_EQ(5, mIndex++); }
};
- auto node = TestUtils::createNode<RecordingCanvas>(10, 10, 110, 110,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- props.mutateLayerProperties().setType(LayerType::RenderLayer);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 10, 10, 110, 110, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.mutateLayerProperties().setType(LayerType::RenderLayer);
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
OffscreenBuffer** layerHandle = node->getLayerHandle();
// create RenderNode's layer here in same way prepareTree would
@@ -1362,11 +1349,11 @@
auto syncedNode = TestUtils::getSyncedNode(node);
// only enqueue partial damage
- LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
+ LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
layerUpdateQueue.enqueueLayerWithDamage(node.get(), Rect(25, 25, 75, 75));
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferLayers(layerUpdateQueue);
frameBuilder.deferRenderNode(*syncedNode);
@@ -1388,7 +1375,7 @@
class HwLayerComplexTestRenderer : public TestRendererBase {
public:
OffscreenBuffer* startTemporaryLayer(uint32_t width, uint32_t height) {
- EXPECT_EQ(3, mIndex++); // savelayer first
+ EXPECT_EQ(3, mIndex++); // savelayer first
return (OffscreenBuffer*)0xabcd;
}
void startRepaintLayer(OffscreenBuffer* offscreenBuffer, const Rect& repaintRect) override {
@@ -1401,7 +1388,9 @@
// starting outer layer
EXPECT_EQ(200u, offscreenBuffer->viewportWidth);
EXPECT_EQ(200u, offscreenBuffer->viewportHeight);
- } else { ADD_FAILURE(); }
+ } else {
+ ADD_FAILURE();
+ }
}
void onRectOp(const RectOp& op, const BakedOpState& state) override {
int index = mIndex++;
@@ -1411,7 +1400,9 @@
} else if (index == 7) {
// outer layer's rect (grey)
EXPECT_EQ(SK_ColorDKGRAY, op.paint->getColor());
- } else { ADD_FAILURE(); }
+ } else {
+ ADD_FAILURE();
+ }
}
void endLayer() override {
int index = mIndex++;
@@ -1431,49 +1422,49 @@
} else if (index == 11) {
EXPECT_EQ(200u, layer->viewportWidth);
EXPECT_EQ(200u, layer->viewportHeight);
- } else { ADD_FAILURE(); }
+ } else {
+ ADD_FAILURE();
+ }
}
- void endFrame(const Rect& repaintRect) override {
- EXPECT_EQ(12, mIndex++);
- }
+ void endFrame(const Rect& repaintRect) override { EXPECT_EQ(12, mIndex++); }
void recycleTemporaryLayer(OffscreenBuffer* offscreenBuffer) override {
EXPECT_EQ(13, mIndex++);
}
};
- auto child = TestUtils::createNode<RecordingCanvas>(50, 50, 150, 150,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- props.mutateLayerProperties().setType(LayerType::RenderLayer);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ auto child = TestUtils::createNode<RecordingCanvas>(
+ 50, 50, 150, 150, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.mutateLayerProperties().setType(LayerType::RenderLayer);
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
OffscreenBuffer childLayer(renderThread.renderState(), Caches::getInstance(), 100, 100);
*(child->getLayerHandle()) = &childLayer;
RenderNode* childPtr = child.get();
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [childPtr](RenderProperties& props, RecordingCanvas& canvas) {
- props.mutateLayerProperties().setType(LayerType::RenderLayer);
- SkPaint paint;
- paint.setColor(SK_ColorDKGRAY);
- canvas.drawRect(0, 0, 200, 200, paint);
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [childPtr](RenderProperties& props, RecordingCanvas& canvas) {
+ props.mutateLayerProperties().setType(LayerType::RenderLayer);
+ SkPaint paint;
+ paint.setColor(SK_ColorDKGRAY);
+ canvas.drawRect(0, 0, 200, 200, paint);
- canvas.saveLayerAlpha(50, 50, 150, 150, 128, SaveFlags::ClipToLayer);
- canvas.drawRenderNode(childPtr);
- canvas.restore();
- });
+ canvas.saveLayerAlpha(50, 50, 150, 150, 128, SaveFlags::ClipToLayer);
+ canvas.drawRenderNode(childPtr);
+ canvas.restore();
+ });
OffscreenBuffer parentLayer(renderThread.renderState(), Caches::getInstance(), 200, 200);
*(parent->getLayerHandle()) = &parentLayer;
auto syncedNode = TestUtils::getSyncedNode(parent);
- LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
+ LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
layerUpdateQueue.enqueueLayerWithDamage(child.get(), Rect(100, 100));
layerUpdateQueue.enqueueLayerWithDamage(parent.get(), Rect(200, 200));
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferLayers(layerUpdateQueue);
frameBuilder.deferRenderNode(*syncedNode);
@@ -1486,7 +1477,6 @@
*(parent->getLayerHandle()) = nullptr;
}
-
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, buildLayer) {
class BuildLayerTestRenderer : public TestRendererBase {
public:
@@ -1505,9 +1495,7 @@
EXPECT_EQ(Rect(25, 25, 75, 75), state.computedState.clipRect())
<< "Damage rect should be used to clip layer content";
}
- void endLayer() override {
- EXPECT_EQ(2, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(2, mIndex++); }
void startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) override {
ADD_FAILURE() << "Primary frame draw not expected in this test";
}
@@ -1516,11 +1504,11 @@
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(10, 10, 110, 110,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- props.mutateLayerProperties().setType(LayerType::RenderLayer);
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 10, 10, 110, 110, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.mutateLayerProperties().setType(LayerType::RenderLayer);
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ });
OffscreenBuffer** layerHandle = node->getLayerHandle();
// create RenderNode's layer here in same way prepareTree would
@@ -1530,7 +1518,7 @@
TestUtils::syncHierarchyPropertiesAndDisplayList(node);
// only enqueue partial damage
- LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
+ LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
layerUpdateQueue.enqueueLayerWithDamage(node.get(), Rect(25, 25, 75, 75));
// Draw, but pass empty node list, so no work is done for primary frame
@@ -1552,65 +1540,69 @@
canvas->drawRect(0, 0, 100, 100, paint);
}
static void drawOrderedNode(Canvas* canvas, uint8_t expectedDrawOrder, float z) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [expectedDrawOrder](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedRect(&canvas, expectedDrawOrder);
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [expectedDrawOrder](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedRect(&canvas, expectedDrawOrder);
+ });
node->mutateStagingProperties().setTranslationZ(z);
node->setPropertyFieldsDirty(RenderNode::TRANSLATION_Z);
- canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
+ canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
}
-static void drawOrderedNode(Canvas* canvas, uint8_t expectedDrawOrder,
+static void drawOrderedNode(
+ Canvas* canvas, uint8_t expectedDrawOrder,
std::function<void(RenderProperties& props, RecordingCanvas& canvas)> setup) {
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100,
[expectedDrawOrder, setup](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedRect(&canvas, expectedDrawOrder);
- if (setup) {
- setup(props, canvas);
- }
- });
- canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
+ drawOrderedRect(&canvas, expectedDrawOrder);
+ if (setup) {
+ setup(props, canvas);
+ }
+ });
+ canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
}
class ZReorderTestRenderer : public TestRendererBase {
public:
void onRectOp(const RectOp& op, const BakedOpState& state) override {
- int expectedOrder = SkColorGetB(op.paint->getColor()); // extract order from blue channel
+ int expectedOrder = SkColorGetB(op.paint->getColor()); // extract order from blue channel
EXPECT_EQ(expectedOrder, mIndex++) << "An op was drawn out of order";
}
};
-} // end anonymous namespace
+} // end anonymous namespace
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, zReorder) {
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.insertReorderBarrier(true);
- canvas.insertReorderBarrier(false);
- drawOrderedNode(&canvas, 0, 10.0f); // in reorder=false at this point, so played inorder
- drawOrderedRect(&canvas, 1);
- canvas.insertReorderBarrier(true);
- drawOrderedNode(&canvas, 6, 2.0f);
- drawOrderedRect(&canvas, 3);
- drawOrderedNode(&canvas, 4, 0.0f);
- drawOrderedRect(&canvas, 5);
- drawOrderedNode(&canvas, 2, -2.0f);
- drawOrderedNode(&canvas, 7, 2.0f);
- canvas.insertReorderBarrier(false);
- drawOrderedRect(&canvas, 8);
- drawOrderedNode(&canvas, 9, -10.0f); // in reorder=false at this point, so played inorder
- canvas.insertReorderBarrier(true); //reorder a node ahead of drawrect op
- drawOrderedRect(&canvas, 11);
- drawOrderedNode(&canvas, 10, -1.0f);
- canvas.insertReorderBarrier(false);
- canvas.insertReorderBarrier(true); //test with two empty reorder sections
- canvas.insertReorderBarrier(true);
- canvas.insertReorderBarrier(false);
- drawOrderedRect(&canvas, 12);
- });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.insertReorderBarrier(true);
+ canvas.insertReorderBarrier(false);
+ drawOrderedNode(&canvas, 0,
+ 10.0f); // in reorder=false at this point, so played inorder
+ drawOrderedRect(&canvas, 1);
+ canvas.insertReorderBarrier(true);
+ drawOrderedNode(&canvas, 6, 2.0f);
+ drawOrderedRect(&canvas, 3);
+ drawOrderedNode(&canvas, 4, 0.0f);
+ drawOrderedRect(&canvas, 5);
+ drawOrderedNode(&canvas, 2, -2.0f);
+ drawOrderedNode(&canvas, 7, 2.0f);
+ canvas.insertReorderBarrier(false);
+ drawOrderedRect(&canvas, 8);
+ drawOrderedNode(&canvas, 9,
+ -10.0f); // in reorder=false at this point, so played inorder
+ canvas.insertReorderBarrier(true); // reorder a node ahead of drawrect op
+ drawOrderedRect(&canvas, 11);
+ drawOrderedNode(&canvas, 10, -1.0f);
+ canvas.insertReorderBarrier(false);
+ canvas.insertReorderBarrier(true); // test with two empty reorder sections
+ canvas.insertReorderBarrier(true);
+ canvas.insertReorderBarrier(false);
+ drawOrderedRect(&canvas, 12);
+ });
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ZReorderTestRenderer renderer;
@@ -1628,28 +1620,28 @@
Matrix4 expectedMatrix;
switch (index) {
- case 0:
- EXPECT_EQ(Rect(100, 100), op.unmappedBounds);
- EXPECT_EQ(SK_ColorWHITE, op.paint->getColor());
- expectedMatrix.loadIdentity();
- EXPECT_EQ(nullptr, state.computedState.localProjectionPathMask);
- break;
- case 1:
- EXPECT_EQ(Rect(-10, -10, 60, 60), op.unmappedBounds);
- EXPECT_EQ(SK_ColorDKGRAY, op.paint->getColor());
- expectedMatrix.loadTranslate(50 - scrollX, 50 - scrollY, 0);
- ASSERT_NE(nullptr, state.computedState.localProjectionPathMask);
- EXPECT_EQ(Rect(-35, -30, 45, 50),
- Rect(state.computedState.localProjectionPathMask->getBounds()));
- break;
- case 2:
- EXPECT_EQ(Rect(100, 50), op.unmappedBounds);
- EXPECT_EQ(SK_ColorBLUE, op.paint->getColor());
- expectedMatrix.loadTranslate(-scrollX, 50 - scrollY, 0);
- EXPECT_EQ(nullptr, state.computedState.localProjectionPathMask);
- break;
- default:
- ADD_FAILURE();
+ case 0:
+ EXPECT_EQ(Rect(100, 100), op.unmappedBounds);
+ EXPECT_EQ(SK_ColorWHITE, op.paint->getColor());
+ expectedMatrix.loadIdentity();
+ EXPECT_EQ(nullptr, state.computedState.localProjectionPathMask);
+ break;
+ case 1:
+ EXPECT_EQ(Rect(-10, -10, 60, 60), op.unmappedBounds);
+ EXPECT_EQ(SK_ColorDKGRAY, op.paint->getColor());
+ expectedMatrix.loadTranslate(50 - scrollX, 50 - scrollY, 0);
+ ASSERT_NE(nullptr, state.computedState.localProjectionPathMask);
+ EXPECT_EQ(Rect(-35, -30, 45, 50),
+ Rect(state.computedState.localProjectionPathMask->getBounds()));
+ break;
+ case 2:
+ EXPECT_EQ(Rect(100, 50), op.unmappedBounds);
+ EXPECT_EQ(SK_ColorBLUE, op.paint->getColor());
+ expectedMatrix.loadTranslate(-scrollX, 50 - scrollY, 0);
+ EXPECT_EQ(nullptr, state.computedState.localProjectionPathMask);
+ break;
+ default:
+ ADD_FAILURE();
}
EXPECT_EQ(expectedMatrix, state.computedState.transform);
}
@@ -1663,47 +1655,51 @@
* The parent is scrolled by scrollX/scrollY, but this does not affect the background
* (which isn't affected by scroll).
*/
- auto receiverBackground = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setProjectionReceiver(true);
- // scroll doesn't apply to background, so undone via translationX/Y
- // NOTE: translationX/Y only! no other transform properties may be set for a proj receiver!
- properties.setTranslationX(scrollX);
- properties.setTranslationY(scrollY);
+ auto receiverBackground = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& properties, RecordingCanvas& canvas) {
+ properties.setProjectionReceiver(true);
+ // scroll doesn't apply to background, so undone via translationX/Y
+ // NOTE: translationX/Y only! no other transform properties may be set for a proj
+ // receiver!
+ properties.setTranslationX(scrollX);
+ properties.setTranslationY(scrollY);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
- auto projectingRipple = TestUtils::createNode<RecordingCanvas>(50, 0, 100, 50,
- [](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setProjectBackwards(true);
- properties.setClipToBounds(false);
- SkPaint paint;
- paint.setColor(SK_ColorDKGRAY);
- canvas.drawRect(-10, -10, 60, 60, paint);
- });
- auto child = TestUtils::createNode<RecordingCanvas>(0, 50, 100, 100,
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
+ auto projectingRipple = TestUtils::createNode<RecordingCanvas>(
+ 50, 0, 100, 50, [](RenderProperties& properties, RecordingCanvas& canvas) {
+ properties.setProjectBackwards(true);
+ properties.setClipToBounds(false);
+ SkPaint paint;
+ paint.setColor(SK_ColorDKGRAY);
+ canvas.drawRect(-10, -10, 60, 60, paint);
+ });
+ auto child = TestUtils::createNode<RecordingCanvas>(
+ 0, 50, 100, 100,
[&projectingRipple](RenderProperties& properties, RecordingCanvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorBLUE);
- canvas.drawRect(0, 0, 100, 50, paint);
- canvas.drawRenderNode(projectingRipple.get());
- });
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
+ SkPaint paint;
+ paint.setColor(SK_ColorBLUE);
+ canvas.drawRect(0, 0, 100, 50, paint);
+ canvas.drawRenderNode(projectingRipple.get());
+ });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100,
[&receiverBackground, &child](RenderProperties& properties, RecordingCanvas& canvas) {
- // Set a rect outline for the projecting ripple to be masked against.
- properties.mutableOutline().setRoundRect(10, 10, 90, 90, 5, 1.0f);
+ // Set a rect outline for the projecting ripple to be masked against.
+ properties.mutableOutline().setRoundRect(10, 10, 90, 90, 5, 1.0f);
- canvas.save(SaveFlags::MatrixClip);
- canvas.translate(-scrollX, -scrollY); // Apply scroll (note: bg undoes this internally)
- canvas.drawRenderNode(receiverBackground.get());
- canvas.drawRenderNode(child.get());
- canvas.restore();
- });
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.translate(-scrollX,
+ -scrollY); // Apply scroll (note: bg undoes this internally)
+ canvas.drawRenderNode(receiverBackground.get());
+ canvas.drawRenderNode(child.get());
+ canvas.restore();
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ProjectionReorderTestRenderer renderer;
@@ -1723,9 +1719,7 @@
EXPECT_EQ(1, mIndex++);
ASSERT_EQ(nullptr, state.computedState.localProjectionPathMask);
}
- void endLayer() override {
- EXPECT_EQ(2, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(2, mIndex++); }
void onRectOp(const RectOp& op, const BakedOpState& state) override {
EXPECT_EQ(3, mIndex++);
ASSERT_EQ(nullptr, state.computedState.localProjectionPathMask);
@@ -1737,60 +1731,64 @@
expected.loadTranslate(100 - scrollX, 100 - scrollY, 0);
EXPECT_EQ(expected, state.computedState.transform);
EXPECT_EQ(Rect(-85, -80, 295, 300),
- Rect(state.computedState.localProjectionPathMask->getBounds()));
+ Rect(state.computedState.localProjectionPathMask->getBounds()));
}
void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
EXPECT_EQ(5, mIndex++);
ASSERT_EQ(nullptr, state.computedState.localProjectionPathMask);
}
};
- auto receiverBackground = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
- [](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setProjectionReceiver(true);
- // scroll doesn't apply to background, so undone via translationX/Y
- // NOTE: translationX/Y only! no other transform properties may be set for a proj receiver!
- properties.setTranslationX(scrollX);
- properties.setTranslationY(scrollY);
+ auto receiverBackground = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400, [](RenderProperties& properties, RecordingCanvas& canvas) {
+ properties.setProjectionReceiver(true);
+ // scroll doesn't apply to background, so undone via translationX/Y
+ // NOTE: translationX/Y only! no other transform properties may be set for a proj
+ // receiver!
+ properties.setTranslationX(scrollX);
+ properties.setTranslationY(scrollY);
- canvas.drawRect(0, 0, 400, 400, SkPaint());
- });
- auto projectingRipple = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setProjectBackwards(true);
- properties.setClipToBounds(false);
- canvas.drawOval(100, 100, 300, 300, SkPaint()); // drawn mostly out of layer bounds
- });
- auto child = TestUtils::createNode<RecordingCanvas>(100, 100, 300, 300,
+ canvas.drawRect(0, 0, 400, 400, SkPaint());
+ });
+ auto projectingRipple = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& properties, RecordingCanvas& canvas) {
+ properties.setProjectBackwards(true);
+ properties.setClipToBounds(false);
+ canvas.drawOval(100, 100, 300, 300, SkPaint()); // drawn mostly out of layer bounds
+ });
+ auto child = TestUtils::createNode<RecordingCanvas>(
+ 100, 100, 300, 300,
[&projectingRipple](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.mutateLayerProperties().setType(LayerType::RenderLayer);
- canvas.drawRenderNode(projectingRipple.get());
- canvas.drawArc(0, 0, 200, 200, 0.0f, 280.0f, true, SkPaint());
- });
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
+ properties.mutateLayerProperties().setType(LayerType::RenderLayer);
+ canvas.drawRenderNode(projectingRipple.get());
+ canvas.drawArc(0, 0, 200, 200, 0.0f, 280.0f, true, SkPaint());
+ });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400,
[&receiverBackground, &child](RenderProperties& properties, RecordingCanvas& canvas) {
- // Set a rect outline for the projecting ripple to be masked against.
- properties.mutableOutline().setRoundRect(10, 10, 390, 390, 0, 1.0f);
- canvas.translate(-scrollX, -scrollY); // Apply scroll (note: bg undoes this internally)
- canvas.drawRenderNode(receiverBackground.get());
- canvas.drawRenderNode(child.get());
- });
+ // Set a rect outline for the projecting ripple to be masked against.
+ properties.mutableOutline().setRoundRect(10, 10, 390, 390, 0, 1.0f);
+ canvas.translate(-scrollX,
+ -scrollY); // Apply scroll (note: bg undoes this internally)
+ canvas.drawRenderNode(receiverBackground.get());
+ canvas.drawRenderNode(child.get());
+ });
OffscreenBuffer** layerHandle = child->getLayerHandle();
// create RenderNode's layer here in same way prepareTree would, setting windowTransform
OffscreenBuffer layer(renderThread.renderState(), Caches::getInstance(), 200, 200);
Matrix4 windowTransform;
- windowTransform.loadTranslate(100, 100, 0); // total transform of layer's origin
+ windowTransform.loadTranslate(100, 100, 0); // total transform of layer's origin
layer.setWindowTransform(windowTransform);
*layerHandle = &layer;
auto syncedNode = TestUtils::getSyncedNode(parent);
- LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
+ LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
layerUpdateQueue.enqueueLayerWithDamage(child.get(), Rect(200, 200));
- FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferLayers(layerUpdateQueue);
frameBuilder.deferRenderNode(*syncedNode);
@@ -1819,37 +1817,41 @@
EXPECT_TRUE(state.computedState.transform.isIdentity());
}
};
- auto receiverBackground = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
- [](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setProjectionReceiver(true);
- canvas.drawRect(0, 0, 400, 400, SkPaint());
- });
- auto projectingRipple = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& properties, RecordingCanvas& canvas) {
- // scroll doesn't apply to background, so undone via translationX/Y
- // NOTE: translationX/Y only! no other transform properties may be set for a proj receiver!
- properties.setTranslationX(scrollX);
- properties.setTranslationY(scrollY);
- properties.setProjectBackwards(true);
- properties.setClipToBounds(false);
- canvas.drawOval(0, 0, 200, 200, SkPaint());
- });
- auto child = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
+ auto receiverBackground = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400, [](RenderProperties& properties, RecordingCanvas& canvas) {
+ properties.setProjectionReceiver(true);
+ canvas.drawRect(0, 0, 400, 400, SkPaint());
+ });
+ auto projectingRipple = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& properties, RecordingCanvas& canvas) {
+ // scroll doesn't apply to background, so undone via translationX/Y
+ // NOTE: translationX/Y only! no other transform properties may be set for a proj
+ // receiver!
+ properties.setTranslationX(scrollX);
+ properties.setTranslationY(scrollY);
+ properties.setProjectBackwards(true);
+ properties.setClipToBounds(false);
+ canvas.drawOval(0, 0, 200, 200, SkPaint());
+ });
+ auto child = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400,
[&projectingRipple](RenderProperties& properties, RecordingCanvas& canvas) {
- // Record time clip will be ignored by projectee
- canvas.clipRect(100, 100, 300, 300, SkClipOp::kIntersect);
+ // Record time clip will be ignored by projectee
+ canvas.clipRect(100, 100, 300, 300, SkClipOp::kIntersect);
- canvas.translate(-scrollX, -scrollY); // Apply scroll (note: bg undoes this internally)
- canvas.drawRenderNode(projectingRipple.get());
- });
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 400, 400,
+ canvas.translate(-scrollX,
+ -scrollY); // Apply scroll (note: bg undoes this internally)
+ canvas.drawRenderNode(projectingRipple.get());
+ });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 400, 400,
[&receiverBackground, &child](RenderProperties& properties, RecordingCanvas& canvas) {
- canvas.drawRenderNode(receiverBackground.get());
- canvas.drawRenderNode(child.get());
- });
+ canvas.drawRenderNode(receiverBackground.get());
+ canvas.drawRenderNode(child.get());
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(400, 400), 400, 400, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ProjectionChildScrollTestRenderer renderer;
@@ -1859,14 +1861,14 @@
// creates a 100x100 shadow casting node with provided translationZ
static sp<RenderNode> createWhiteRectShadowCaster(float translationZ) {
- return TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [translationZ](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setTranslationZ(translationZ);
- properties.mutableOutline().setRoundRect(0, 0, 100, 100, 0.0f, 1.0f);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ return TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [translationZ](RenderProperties& properties, RecordingCanvas& canvas) {
+ properties.setTranslationZ(translationZ);
+ properties.mutableOutline().setRoundRect(0, 0, 100, 100, 0.0f, 1.0f);
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, shadow) {
@@ -1887,14 +1889,14 @@
}
};
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.insertReorderBarrier(true);
- canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
- });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.insertReorderBarrier(true);
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ShadowTestRenderer renderer;
@@ -1917,9 +1919,7 @@
void onRectOp(const RectOp& op, const BakedOpState& state) override {
EXPECT_EQ(2, mIndex++);
}
- void endLayer() override {
- EXPECT_EQ(3, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(3, mIndex++); }
void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
EXPECT_EQ(4, mIndex++);
}
@@ -1928,19 +1928,20 @@
}
};
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- // save/restore outside of reorderBarrier, so they don't get moved out of place
- canvas.translate(20, 10);
- int count = canvas.saveLayerAlpha(30, 50, 130, 150, 128, SaveFlags::ClipToLayer);
- canvas.insertReorderBarrier(true);
- canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
- canvas.insertReorderBarrier(false);
- canvas.restoreToCount(count);
- });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ // save/restore outside of reorderBarrier, so they don't get moved out of place
+ canvas.translate(20, 10);
+ int count = canvas.saveLayerAlpha(30, 50, 130, 150, 128, SaveFlags::ClipToLayer);
+ canvas.insertReorderBarrier(true);
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
+ canvas.insertReorderBarrier(false);
+ canvas.restoreToCount(count);
+ });
FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- (FrameBuilder::LightGeometry) {{ 100, 100, 100 }, 50}, Caches::getInstance());
+ (FrameBuilder::LightGeometry){{100, 100, 100}, 50},
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ShadowSaveLayerTestRenderer renderer;
@@ -1963,38 +1964,37 @@
void onRectOp(const RectOp& op, const BakedOpState& state) override {
EXPECT_EQ(2, mIndex++);
}
- void endLayer() override {
- EXPECT_EQ(3, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(3, mIndex++); }
void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
EXPECT_EQ(4, mIndex++);
}
};
- auto parent = TestUtils::createNode<RecordingCanvas>(50, 60, 150, 160,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- props.mutateLayerProperties().setType(LayerType::RenderLayer);
- canvas.insertReorderBarrier(true);
- canvas.save(SaveFlags::MatrixClip);
- canvas.translate(20, 10);
- canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
- canvas.restore();
- });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 50, 60, 150, 160, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.mutateLayerProperties().setType(LayerType::RenderLayer);
+ canvas.insertReorderBarrier(true);
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.translate(20, 10);
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
+ canvas.restore();
+ });
OffscreenBuffer** layerHandle = parent->getLayerHandle();
// create RenderNode's layer here in same way prepareTree would, setting windowTransform
OffscreenBuffer layer(renderThread.renderState(), Caches::getInstance(), 100, 100);
Matrix4 windowTransform;
- windowTransform.loadTranslate(50, 60, 0); // total transform of layer's origin
+ windowTransform.loadTranslate(50, 60, 0); // total transform of layer's origin
layer.setWindowTransform(windowTransform);
*layerHandle = &layer;
auto syncedNode = TestUtils::getSyncedNode(parent);
- LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
+ LayerUpdateQueue layerUpdateQueue; // Note: enqueue damage post-sync, so bounds are valid
layerUpdateQueue.enqueueLayerWithDamage(parent.get(), Rect(100, 100));
FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- (FrameBuilder::LightGeometry) {{ 100, 100, 100 }, 30}, Caches::getInstance());
+ (FrameBuilder::LightGeometry){{100, 100, 100}, 30},
+ Caches::getInstance());
frameBuilder.deferLayers(layerUpdateQueue);
frameBuilder.deferRenderNode(*syncedNode);
@@ -2018,14 +2018,15 @@
EXPECT_TRUE(index == 2 || index == 3);
}
};
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 200, 200,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.insertReorderBarrier(true);
- canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
- canvas.drawRenderNode(createWhiteRectShadowCaster(5.0001f).get());
- });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 200, 200, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.insertReorderBarrier(true);
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0001f).get());
+ });
FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- (FrameBuilder::LightGeometry) {{ 100, 100, 100 }, 50}, Caches::getInstance());
+ (FrameBuilder::LightGeometry){{100, 100, 100}, 50},
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ShadowLayeringTestRenderer renderer;
@@ -2045,17 +2046,18 @@
EXPECT_EQ(1, mIndex++);
}
};
- auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- // Apply a clip before the reorder barrier/shadow casting child is drawn.
- // This clip must be applied to the shadow cast by the child.
- canvas.clipRect(25, 25, 75, 75, SkClipOp::kIntersect);
- canvas.insertReorderBarrier(true);
- canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
- });
+ auto parent = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ // Apply a clip before the reorder barrier/shadow casting child is drawn.
+ // This clip must be applied to the shadow cast by the child.
+ canvas.clipRect(25, 25, 75, 75, SkClipOp::kIntersect);
+ canvas.insertReorderBarrier(true);
+ canvas.drawRenderNode(createWhiteRectShadowCaster(5.0f).get());
+ });
FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- (FrameBuilder::LightGeometry) {{ 100, 100, 100 }, 50}, Caches::getInstance());
+ (FrameBuilder::LightGeometry){{100, 100, 100}, 50},
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(parent));
ShadowClippingTestRenderer renderer;
@@ -2063,11 +2065,13 @@
EXPECT_EQ(2, renderer.getIndex());
}
-static void testProperty(std::function<void(RenderProperties&)> propSetupCallback,
+static void testProperty(
+ std::function<void(RenderProperties&)> propSetupCallback,
std::function<void(const RectOp&, const BakedOpState&)> opValidateCallback) {
class PropertyTestRenderer : public TestRendererBase {
public:
- explicit PropertyTestRenderer(std::function<void(const RectOp&, const BakedOpState&)> callback)
+ explicit PropertyTestRenderer(
+ std::function<void(const RectOp&, const BakedOpState&)> callback)
: mCallback(callback) {}
void onRectOp(const RectOp& op, const BakedOpState& state) override {
EXPECT_EQ(mIndex++, 0);
@@ -2076,16 +2080,16 @@
std::function<void(const RectOp&, const BakedOpState&)> mCallback;
};
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [propSetupCallback](RenderProperties& props, RecordingCanvas& canvas) {
- propSetupCallback(props);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [propSetupCallback](RenderProperties& props, RecordingCanvas& canvas) {
+ propSetupCallback(props);
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
PropertyTestRenderer renderer(opValidateCallback);
@@ -2094,78 +2098,89 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropOverlappingRenderingAlpha) {
- testProperty([](RenderProperties& properties) {
- properties.setAlpha(0.5f);
- properties.setHasOverlappingRendering(false);
- }, [](const RectOp& op, const BakedOpState& state) {
- EXPECT_EQ(0.5f, state.alpha) << "Alpha should be applied directly to op";
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.setAlpha(0.5f);
+ properties.setHasOverlappingRendering(false);
+ },
+ [](const RectOp& op, const BakedOpState& state) {
+ EXPECT_EQ(0.5f, state.alpha) << "Alpha should be applied directly to op";
+ });
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropClipping) {
- testProperty([](RenderProperties& properties) {
- properties.setClipToBounds(true);
- properties.setClipBounds(Rect(10, 20, 300, 400));
- }, [](const RectOp& op, const BakedOpState& state) {
- EXPECT_EQ(Rect(10, 20, 100, 100), state.computedState.clippedBounds)
- << "Clip rect should be intersection of node bounds and clip bounds";
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.setClipToBounds(true);
+ properties.setClipBounds(Rect(10, 20, 300, 400));
+ },
+ [](const RectOp& op, const BakedOpState& state) {
+ EXPECT_EQ(Rect(10, 20, 100, 100), state.computedState.clippedBounds)
+ << "Clip rect should be intersection of node bounds and clip bounds";
+ });
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropRevealClip) {
- testProperty([](RenderProperties& properties) {
- properties.mutableRevealClip().set(true, 50, 50, 25);
- }, [](const RectOp& op, const BakedOpState& state) {
- ASSERT_NE(nullptr, state.roundRectClipState);
- EXPECT_TRUE(state.roundRectClipState->highPriority);
- EXPECT_EQ(25, state.roundRectClipState->radius);
- EXPECT_EQ(Rect(50, 50, 50, 50), state.roundRectClipState->innerRect);
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.mutableRevealClip().set(true, 50, 50, 25);
+ },
+ [](const RectOp& op, const BakedOpState& state) {
+ ASSERT_NE(nullptr, state.roundRectClipState);
+ EXPECT_TRUE(state.roundRectClipState->highPriority);
+ EXPECT_EQ(25, state.roundRectClipState->radius);
+ EXPECT_EQ(Rect(50, 50, 50, 50), state.roundRectClipState->innerRect);
+ });
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropOutlineClip) {
- testProperty([](RenderProperties& properties) {
- properties.mutableOutline().setShouldClip(true);
- properties.mutableOutline().setRoundRect(10, 20, 30, 40, 5.0f, 0.5f);
- }, [](const RectOp& op, const BakedOpState& state) {
- ASSERT_NE(nullptr, state.roundRectClipState);
- EXPECT_FALSE(state.roundRectClipState->highPriority);
- EXPECT_EQ(5, state.roundRectClipState->radius);
- EXPECT_EQ(Rect(15, 25, 25, 35), state.roundRectClipState->innerRect);
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.mutableOutline().setShouldClip(true);
+ properties.mutableOutline().setRoundRect(10, 20, 30, 40, 5.0f, 0.5f);
+ },
+ [](const RectOp& op, const BakedOpState& state) {
+ ASSERT_NE(nullptr, state.roundRectClipState);
+ EXPECT_FALSE(state.roundRectClipState->highPriority);
+ EXPECT_EQ(5, state.roundRectClipState->radius);
+ EXPECT_EQ(Rect(15, 25, 25, 35), state.roundRectClipState->innerRect);
+ });
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropTransform) {
- testProperty([](RenderProperties& properties) {
- properties.setLeftTopRightBottom(10, 10, 110, 110);
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.setLeftTopRightBottom(10, 10, 110, 110);
- SkMatrix staticMatrix = SkMatrix::MakeScale(1.2f, 1.2f);
- properties.setStaticMatrix(&staticMatrix);
+ SkMatrix staticMatrix = SkMatrix::MakeScale(1.2f, 1.2f);
+ properties.setStaticMatrix(&staticMatrix);
- // ignored, since static overrides animation
- SkMatrix animationMatrix = SkMatrix::MakeTrans(15, 15);
- properties.setAnimationMatrix(&animationMatrix);
+ // ignored, since static overrides animation
+ SkMatrix animationMatrix = SkMatrix::MakeTrans(15, 15);
+ properties.setAnimationMatrix(&animationMatrix);
- properties.setTranslationX(10);
- properties.setTranslationY(20);
- properties.setScaleX(0.5f);
- properties.setScaleY(0.7f);
- }, [](const RectOp& op, const BakedOpState& state) {
- Matrix4 matrix;
- matrix.loadTranslate(10, 10, 0); // left, top
- matrix.scale(1.2f, 1.2f, 1); // static matrix
- // ignore animation matrix, since static overrides it
+ properties.setTranslationX(10);
+ properties.setTranslationY(20);
+ properties.setScaleX(0.5f);
+ properties.setScaleY(0.7f);
+ },
+ [](const RectOp& op, const BakedOpState& state) {
+ Matrix4 matrix;
+ matrix.loadTranslate(10, 10, 0); // left, top
+ matrix.scale(1.2f, 1.2f, 1); // static matrix
+ // ignore animation matrix, since static overrides it
- // translation xy
- matrix.translate(10, 20);
+ // translation xy
+ matrix.translate(10, 20);
- // scale xy (from default pivot - center)
- matrix.translate(50, 50);
- matrix.scale(0.5f, 0.7f, 1);
- matrix.translate(-50, -50);
- EXPECT_MATRIX_APPROX_EQ(matrix, state.computedState.transform)
- << "Op draw matrix must match expected combination of transformation properties";
- });
+ // scale xy (from default pivot - center)
+ matrix.translate(50, 50);
+ matrix.scale(0.5f, 0.7f, 1);
+ matrix.translate(-50, -50);
+ EXPECT_MATRIX_APPROX_EQ(matrix, state.computedState.transform)
+ << "Op draw matrix must match expected combination of transformation "
+ "properties";
+ });
}
struct SaveLayerAlphaData {
@@ -2186,11 +2201,10 @@
* (for efficiency, and to fit in layer size constraints) based on parent clip.
*/
void testSaveLayerAlphaClip(SaveLayerAlphaData* outObservedData,
- std::function<void(RenderProperties&)> propSetupCallback) {
+ std::function<void(RenderProperties&)> propSetupCallback) {
class SaveLayerAlphaClipTestRenderer : public TestRendererBase {
public:
- explicit SaveLayerAlphaClipTestRenderer(SaveLayerAlphaData* outData)
- : mOutData(outData) {}
+ explicit SaveLayerAlphaClipTestRenderer(SaveLayerAlphaData* outData) : mOutData(outData) {}
OffscreenBuffer* startTemporaryLayer(uint32_t width, uint32_t height) override {
EXPECT_EQ(0, mIndex++);
@@ -2204,9 +2218,7 @@
mOutData->rectClippedBounds = state.computedState.clippedBounds;
mOutData->rectMatrix = state.computedState.transform;
}
- void endLayer() override {
- EXPECT_EQ(2, mIndex++);
- }
+ void endLayer() override { EXPECT_EQ(2, mIndex++); }
void onLayerOp(const LayerOp& op, const BakedOpState& state) override {
EXPECT_EQ(3, mIndex++);
mOutData->drawLayerMatrix = state.computedState.transform;
@@ -2214,27 +2226,29 @@
void recycleTemporaryLayer(OffscreenBuffer* offscreenBuffer) override {
EXPECT_EQ(4, mIndex++);
}
+
private:
SaveLayerAlphaData* mOutData;
};
ASSERT_GT(10000, DeviceInfo::get()->maxTextureSize())
<< "Node must be bigger than max texture size to exercise saveLayer codepath";
- auto node = TestUtils::createNode<RecordingCanvas>(0, 0, 10000, 10000,
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 10000, 10000,
[&propSetupCallback](RenderProperties& properties, RecordingCanvas& canvas) {
- properties.setHasOverlappingRendering(true);
- properties.setAlpha(0.5f); // force saveLayer, since too big for HW layer
- // apply other properties
- propSetupCallback(properties);
+ properties.setHasOverlappingRendering(true);
+ properties.setAlpha(0.5f); // force saveLayer, since too big for HW layer
+ // apply other properties
+ propSetupCallback(properties);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 10000, 10000, paint);
- });
- auto syncedNode = TestUtils::getSyncedNode(node); // sync before querying height
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 10000, 10000, paint);
+ });
+ auto syncedNode = TestUtils::getSyncedNode(node); // sync before querying height
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*syncedNode);
SaveLayerAlphaClipTestRenderer renderer(outObservedData);
@@ -2247,8 +2261,8 @@
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropSaveLayerAlphaClipBig) {
SaveLayerAlphaData observedData;
testSaveLayerAlphaClip(&observedData, [](RenderProperties& properties) {
- properties.setTranslationX(10); // offset rendering content
- properties.setTranslationY(-2000); // offset rendering content
+ properties.setTranslationX(10); // offset rendering content
+ properties.setTranslationY(-2000); // offset rendering content
});
EXPECT_EQ(190u, observedData.layerWidth);
EXPECT_EQ(200u, observedData.layerHeight);
@@ -2260,7 +2274,7 @@
<< "expect content to be translated as part of being clipped";
expected.loadTranslate(10, 0, 0);
EXPECT_MATRIX_APPROX_EQ(expected, observedData.drawLayerMatrix)
- << "expect drawLayer to be translated as part of being clipped";
+ << "expect drawLayer to be translated as part of being clipped";
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, renderPropSaveLayerAlphaRotate) {
@@ -2306,14 +2320,14 @@
<< "Expect resolved clip to be intersection of viewport clip and clip op";
}
};
- auto node = TestUtils::createNode<RecordingCanvas>(20, 20, 30, 30,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- canvas.clipRect(0, -20, 10, 30, SkClipOp::kReplace_deprecated);
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- });
+ auto node = TestUtils::createNode<RecordingCanvas>(
+ 20, 20, 30, 30, [](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.clipRect(0, -20, 10, 30, SkClipOp::kReplace_deprecated);
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ });
- FrameBuilder frameBuilder(SkRect::MakeLTRB(10, 10, 40, 40), 50, 50,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeLTRB(10, 10, 40, 40), 50, 50, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
ClipReplaceTestRenderer renderer;
@@ -2329,21 +2343,22 @@
|
R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectionReceiver(true);
+ }); // nodeB
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2360,22 +2375,24 @@
|
R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, RecordingCanvas& canvas) { //drawn as 2
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) { //drawn as 3
- props.setProjectionReceiver(true);
- } ); //nodeE
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 3, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // drawn as 2
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // drawn as 3
+ props.setProjectionReceiver(true);
+ }); // nodeE
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2391,20 +2408,21 @@
|
R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 255, [](RenderProperties& props, RecordingCanvas& canvas) {
- //not having a projection receiver is an undefined behavior
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 255,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ // not having a projection receiver is an undefined behavior
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2420,20 +2438,21 @@
|
R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectionReceiver(true);
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectionReceiver(true);
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2442,21 +2461,23 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, projectionReorderSameNodeReceivable) {
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 255, [](RenderProperties& props, RecordingCanvas& canvas) {
- //having a node that is projected on itself is an undefined/unexpected behavior
- props.setProjectionReceiver(true);
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 255,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ // having a node that is projected on itself is an
+ // undefined/unexpected behavior
+ props.setProjectionReceiver(true);
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2465,9 +2486,9 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(FrameBuilder, projectionReorderProjectedSibling) {
- //TODO: this test together with the next "projectionReorderProjectedSibling2" likely expose a
- //bug in HWUI. First test draws R, while the second test does not draw R for a nearly identical
- //tree setup. The correct behaviour is to not draw R, because the receiver cannot be a sibling
+ // TODO: this test together with the next "projectionReorderProjectedSibling2" likely expose a
+ // bug in HWUI. First test draws R, while the second test does not draw R for a nearly identical
+ // tree setup. The correct behaviour is to not draw R, because the receiver cannot be a sibling
/* R is backward projected on B. R is not expected to be drawn (see Sibling2 outcome below),
but for some reason it is drawn.
A
@@ -2475,21 +2496,21 @@
/ | \
B C R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) {
- } ); //nodeC
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectionReceiver(true);
+ }); // nodeB
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, RecordingCanvas& canvas) {}); // nodeC
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2506,23 +2527,27 @@
/ | \
B C R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) { //G
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) { //B
- props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) { //C
- } ); //nodeC
- drawOrderedNode(&canvas, 255, [](RenderProperties& props, RecordingCanvas& canvas) { //R
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeG
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // G
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // B
+ props.setProjectionReceiver(true);
+ }); // nodeB
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // C
+ }); // nodeC
+ drawOrderedNode(&canvas, 255,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // R
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeG
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2540,21 +2565,23 @@
|
R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectionReceiver(true);
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) {
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- } ); //nodeB
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) {
+ props.setProjectionReceiver(true);
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props,
+ RecordingCanvas& canvas) {
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeB
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2570,24 +2597,28 @@
/ \
G R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) { //B
- props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) { //C
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, RecordingCanvas& canvas) { //G
- props.setProjectionReceiver(true);
- } ); //nodeG
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) { //R
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // B
+ props.setProjectionReceiver(true);
+ }); // nodeB
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // C
+ drawOrderedNode(&canvas, 3,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // G
+ props.setProjectionReceiver(true);
+ }); // nodeG
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // R
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2603,24 +2634,28 @@
/ \
G R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) { //B
- props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) { //C
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) { //G
- props.setProjectionReceiver(true);
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeG
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, RecordingCanvas& canvas) { //R
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // B
+ props.setProjectionReceiver(true);
+ }); // nodeB
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // C
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // G
+ props.setProjectionReceiver(true);
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeG
+ drawOrderedNode(&canvas, 3,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // R
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2638,26 +2673,31 @@
|
R
*/
- auto nodeA = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
- [](RenderProperties& props, RecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, RecordingCanvas& canvas) { //B
- props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, RecordingCanvas& canvas) { //C
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, RecordingCanvas& canvas) { //G
- props.setProjectionReceiver(true);
- } ); //nodeG
- drawOrderedNode(&canvas, 4, [](RenderProperties& props, RecordingCanvas& canvas) { //D
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, RecordingCanvas& canvas) { //R
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeD
- } ); //nodeC
- }); //nodeA
+ auto nodeA = TestUtils::createNode<RecordingCanvas>(
+ 0, 0, 100, 100, [](RenderProperties& props, RecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // B
+ props.setProjectionReceiver(true);
+ }); // nodeB
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // C
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, RecordingCanvas& canvas) { // G
+ props.setProjectionReceiver(true);
+ }); // nodeG
+ drawOrderedNode(
+ &canvas, 4, [](RenderProperties& props, RecordingCanvas& canvas) { // D
+ drawOrderedNode(&canvas, 3, [](RenderProperties& props,
+ RecordingCanvas& canvas) { // R
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeD
+ }); // nodeC
+ }); // nodeA
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometry, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometry,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(nodeA));
ZReorderTestRenderer renderer;
@@ -2665,5 +2705,5 @@
EXPECT_EQ(5, renderer.getIndex());
}
-} // namespace uirenderer
-} // namespace android
+} // namespace uirenderer
+} // namespace android
diff --git a/libs/hwui/tests/unit/GlopBuilderTests.cpp b/libs/hwui/tests/unit/GlopBuilderTests.cpp
index caeb6bf..c8bfc99 100644
--- a/libs/hwui/tests/unit/GlopBuilderTests.cpp
+++ b/libs/hwui/tests/unit/GlopBuilderTests.cpp
@@ -28,8 +28,7 @@
static void expectFillEq(Glop::Fill& expectedFill, Glop::Fill& builtFill) {
EXPECT_EQ(expectedFill.colorEnabled, builtFill.colorEnabled);
- if (expectedFill.colorEnabled)
- EXPECT_EQ(expectedFill.color, builtFill.color);
+ if (expectedFill.colorEnabled) EXPECT_EQ(expectedFill.color, builtFill.color);
EXPECT_EQ(expectedFill.filterMode, builtFill.filterMode);
if (expectedFill.filterMode == ProgramDescription::ColorFilterMode::Blend) {
@@ -38,15 +37,15 @@
Glop::Fill::Filter::Matrix& expectedMatrix = expectedFill.filter.matrix;
Glop::Fill::Filter::Matrix& builtMatrix = expectedFill.filter.matrix;
EXPECT_TRUE(std::memcmp(expectedMatrix.matrix, builtMatrix.matrix,
- sizeof(Glop::Fill::Filter::Matrix::matrix)));
+ sizeof(Glop::Fill::Filter::Matrix::matrix)));
EXPECT_TRUE(std::memcmp(expectedMatrix.vector, builtMatrix.vector,
- sizeof(Glop::Fill::Filter::Matrix::vector)));
+ sizeof(Glop::Fill::Filter::Matrix::vector)));
}
EXPECT_EQ(expectedFill.skiaShaderData.skiaShaderType, builtFill.skiaShaderData.skiaShaderType);
EXPECT_EQ(expectedFill.texture.clamp, builtFill.texture.clamp);
EXPECT_EQ(expectedFill.texture.filter, builtFill.texture.filter);
- EXPECT_TRUE((expectedFill.texture.texture && builtFill.texture.texture)
- || (!expectedFill.texture.texture && !builtFill.texture.texture));
+ EXPECT_TRUE((expectedFill.texture.texture && builtFill.texture.texture) ||
+ (!expectedFill.texture.texture && !builtFill.texture.texture));
if (expectedFill.texture.texture) {
EXPECT_EQ(expectedFill.texture.texture->target(), builtFill.texture.texture->target());
}
@@ -97,22 +96,23 @@
static std::unique_ptr<Glop> blackUnitQuadGlop(RenderState& renderState) {
std::unique_ptr<Glop> glop(new Glop());
- glop->blend = { GL_ZERO, GL_ZERO };
+ glop->blend = {GL_ZERO, GL_ZERO};
glop->mesh.elementCount = 4;
glop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
glop->mesh.indices.indices = nullptr;
glop->mesh.indices.bufferObject = GL_ZERO;
- glop->mesh.vertices = {
- renderState.meshState().getUnitQuadVBO(),
- VertexAttribFlags::None,
- nullptr, nullptr, nullptr,
- kTextureVertexStride };
+ glop->mesh.vertices = {renderState.meshState().getUnitQuadVBO(),
+ VertexAttribFlags::None,
+ nullptr,
+ nullptr,
+ nullptr,
+ kTextureVertexStride};
glop->transform.modelView.loadIdentity();
glop->fill.colorEnabled = true;
glop->fill.color.set(Color::Black);
glop->fill.skiaShaderData.skiaShaderType = kNone_SkiaShaderType;
glop->fill.filterMode = ProgramDescription::ColorFilterMode::None;
- glop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
+ glop->fill.texture = {nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr};
return glop;
}
diff --git a/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp b/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp
index 8cbd24e..9bfb082 100644
--- a/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp
+++ b/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp
@@ -14,9 +14,8 @@
* limitations under the License.
*/
-
-#include <gtest/gtest.h>
#include <GpuMemoryTracker.h>
+#include <gtest/gtest.h>
#include "renderthread/EglManager.h"
#include "renderthread/RenderThread.h"
@@ -32,9 +31,7 @@
public:
TestGPUObject() : GpuMemoryTracker(GpuObjectType::Texture) {}
- void changeSize(int newSize) {
- notifySizeChanged(newSize);
- }
+ void changeSize(int newSize) { notifySizeChanged(newSize); }
};
// Other tests may have created a renderthread and EGL context.
@@ -42,9 +39,7 @@
// current thread can spoof being a GPU thread
static void destroyEglContext() {
if (TestUtils::isRenderThreadRunning()) {
- TestUtils::runOnRenderThread([](RenderThread& thread) {
- thread.eglManager().destroy();
- });
+ TestUtils::runOnRenderThread([](RenderThread& thread) { thread.eglManager().destroy(); });
}
}
diff --git a/libs/hwui/tests/unit/GradientCacheTests.cpp b/libs/hwui/tests/unit/GradientCacheTests.cpp
index a3b346f..6710c71 100644
--- a/libs/hwui/tests/unit/GradientCacheTests.cpp
+++ b/libs/hwui/tests/unit/GradientCacheTests.cpp
@@ -28,12 +28,12 @@
GradientCache cache(extensions);
ASSERT_LT(1000u, cache.getMaxSize()) << "Expect non-trivial size";
- SkColor colors[] = { 0xFF00FF00, 0xFFFF0000, 0xFF0000FF };
- float positions[] = { 1, 2, 3 };
+ SkColor colors[] = {0xFF00FF00, 0xFFFF0000, 0xFF0000FF};
+ float positions[] = {1, 2, 3};
Texture* texture = cache.get(colors, positions, 3);
ASSERT_TRUE(texture);
ASSERT_FALSE(texture->cleanup);
- ASSERT_EQ((uint32_t) texture->objectSize(), cache.getSize());
+ ASSERT_EQ((uint32_t)texture->objectSize(), cache.getSize());
ASSERT_TRUE(cache.getSize());
cache.clear();
ASSERT_EQ(cache.getSize(), 0u);
diff --git a/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp b/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp
index fda3a79..30c3b4e 100644
--- a/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp
+++ b/libs/hwui/tests/unit/GraphicsStatsServiceTests.cpp
@@ -20,10 +20,10 @@
#include <frameworks/base/core/proto/android/service/graphicsstats.pb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
using namespace android;
@@ -35,8 +35,8 @@
// < 1023 because we need room for the null terminator
if (r <= 0 || r > 1023) {
int err = errno;
- fprintf(stderr, "Failed to read from /proc/self/exe; r=%zd, err=%d (%s)\n",
- r, err, strerror(err));
+ fprintf(stderr, "Failed to read from /proc/self/exe; r=%zd, err=%d (%s)\n", r, err,
+ strerror(err));
exit(EXIT_FAILURE);
}
while (--r > 0) {
@@ -88,8 +88,8 @@
EXPECT_EQ(20, loadedProto.summary().janky_frames());
EXPECT_EQ(100, loadedProto.summary().total_frames());
EXPECT_EQ(mockData.editFrameCounts().size() + mockData.editSlowFrameCounts().size(),
- (size_t) loadedProto.histogram_size());
- for (size_t i = 0; i < (size_t) loadedProto.histogram_size(); i++) {
+ (size_t)loadedProto.histogram_size());
+ for (size_t i = 0; i < (size_t)loadedProto.histogram_size(); i++) {
int expectedCount, expectedBucket;
if (i < mockData.editFrameCounts().size()) {
expectedCount = ((i % 10) + 1) * 2;
@@ -144,8 +144,8 @@
EXPECT_EQ(20 + 50, loadedProto.summary().janky_frames());
EXPECT_EQ(100 + 500, loadedProto.summary().total_frames());
EXPECT_EQ(mockData.editFrameCounts().size() + mockData.editSlowFrameCounts().size(),
- (size_t) loadedProto.histogram_size());
- for (size_t i = 0; i < (size_t) loadedProto.histogram_size(); i++) {
+ (size_t)loadedProto.histogram_size());
+ for (size_t i = 0; i < (size_t)loadedProto.histogram_size(); i++) {
int expectedCount, expectedBucket;
if (i < mockData.editFrameCounts().size()) {
expectedCount = ((i % 10) + 1) * 2;
diff --git a/libs/hwui/tests/unit/LayerUpdateQueueTests.cpp b/libs/hwui/tests/unit/LayerUpdateQueueTests.cpp
index 91c7514..217d63f 100644
--- a/libs/hwui/tests/unit/LayerUpdateQueueTests.cpp
+++ b/libs/hwui/tests/unit/LayerUpdateQueueTests.cpp
@@ -51,9 +51,9 @@
EXPECT_EQ(a.get(), queue.entries()[0].renderNode.get());
EXPECT_EQ(Rect(25, 25, 75, 75), queue.entries()[0].damage);
EXPECT_EQ(b.get(), queue.entries()[1].renderNode.get());
- EXPECT_EQ(Rect(100, 100, 200, 200), queue.entries()[1].damage); // clipped to bounds
+ EXPECT_EQ(Rect(100, 100, 200, 200), queue.entries()[1].damage); // clipped to bounds
EXPECT_EQ(c.get(), queue.entries()[2].renderNode.get());
- EXPECT_EQ(Rect(0, 0, 1, 1), queue.entries()[2].damage); // rounded out
+ EXPECT_EQ(Rect(0, 0, 1, 1), queue.entries()[2].damage); // rounded out
}
TEST(LayerUpdateQueue, enqueueUnion) {
@@ -81,6 +81,5 @@
EXPECT_TRUE(queue.entries().empty());
}
-
};
};
diff --git a/libs/hwui/tests/unit/LeakCheckTests.cpp b/libs/hwui/tests/unit/LeakCheckTests.cpp
index 19d7ef5..20ec084 100644
--- a/libs/hwui/tests/unit/LeakCheckTests.cpp
+++ b/libs/hwui/tests/unit/LeakCheckTests.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include "BakedOpRenderer.h"
#include "BakedOpDispatcher.h"
+#include "BakedOpRenderer.h"
#include "FrameBuilder.h"
#include "LayerUpdateQueue.h"
#include "RecordingCanvas.h"
@@ -26,12 +26,11 @@
using namespace android;
using namespace android::uirenderer;
-const FrameBuilder::LightGeometry sLightGeometery = { {100, 100, 100}, 50};
-const BakedOpRenderer::LightInfo sLightInfo = { 128, 128 };
+const FrameBuilder::LightGeometry sLightGeometery = {{100, 100, 100}, 50};
+const BakedOpRenderer::LightInfo sLightInfo = {128, 128};
RENDERTHREAD_OPENGL_PIPELINE_TEST(LeakCheck, saveLayer_overdrawRejection) {
- auto node = TestUtils::createNode(0, 0, 100, 100,
- [](RenderProperties& props, Canvas& canvas) {
+ auto node = TestUtils::createNode(0, 0, 100, 100, [](RenderProperties& props, Canvas& canvas) {
canvas.saveLayerAlpha(0, 0, 100, 100, 128, SaveFlags::ClipToLayer);
canvas.drawRect(0, 0, 100, 100, SkPaint());
canvas.restore();
@@ -42,16 +41,15 @@
RenderState& renderState = renderThread.renderState();
Caches& caches = Caches::getInstance();
- FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100,
- sLightGeometery, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(100, 100), 100, 100, sLightGeometery,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
BakedOpRenderer renderer(caches, renderState, true, false, sLightInfo);
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(LeakCheck, saveLayerUnclipped_simple) {
- auto node = TestUtils::createNode(0, 0, 200, 200,
- [](RenderProperties& props, Canvas& canvas) {
+ auto node = TestUtils::createNode(0, 0, 200, 200, [](RenderProperties& props, Canvas& canvas) {
canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0));
canvas.drawRect(0, 0, 200, 200, SkPaint());
canvas.restore();
@@ -59,8 +57,8 @@
RenderState& renderState = renderThread.renderState();
Caches& caches = Caches::getInstance();
- FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200,
- sLightGeometery, Caches::getInstance());
+ FrameBuilder frameBuilder(SkRect::MakeWH(200, 200), 200, 200, sLightGeometery,
+ Caches::getInstance());
frameBuilder.deferRenderNode(*TestUtils::getSyncedNode(node));
BakedOpRenderer renderer(caches, renderState, true, false, sLightInfo);
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
diff --git a/libs/hwui/tests/unit/LinearAllocatorTests.cpp b/libs/hwui/tests/unit/LinearAllocatorTests.cpp
index ffcbf12..1038da3 100644
--- a/libs/hwui/tests/unit/LinearAllocatorTests.cpp
+++ b/libs/hwui/tests/unit/LinearAllocatorTests.cpp
@@ -43,7 +43,7 @@
}
TEST(LinearAllocator, dtor) {
- int destroyed[10] = { 0 };
+ int destroyed[10] = {0};
{
LinearAllocator la;
for (int i = 0; i < 5; i++) {
@@ -111,7 +111,6 @@
EXPECT_LT(lastLocation, &v[0]);
EXPECT_GT(lastLocation + 20, &v[0]);
-
}
TEST(LsaVector, dtorCheck) {
@@ -126,7 +125,7 @@
vector.emplace_back(new TestUtils::SignalingDtor(&destroyed));
}
EXPECT_EQ(0, destroyed);
- EXPECT_EQ(size, (int) vector.size());
+ EXPECT_EQ(size, (int)vector.size());
}
EXPECT_EQ(size, destroyed);
}
diff --git a/libs/hwui/tests/unit/MatrixTests.cpp b/libs/hwui/tests/unit/MatrixTests.cpp
index eddab87..16a396e 100644
--- a/libs/hwui/tests/unit/MatrixTests.cpp
+++ b/libs/hwui/tests/unit/MatrixTests.cpp
@@ -32,8 +32,7 @@
ASSERT_TRUE(empty.isEmpty());
scaleMatrix.mapRect(empty);
EXPECT_EQ(Rect(170, 215, 250, 1015), empty);
- EXPECT_FALSE(empty.isEmpty())
- << "Empty 'line' rect doesn't remain empty when skewed.";
+ EXPECT_FALSE(empty.isEmpty()) << "Empty 'line' rect doesn't remain empty when skewed.";
}
TEST(Matrix, mapRect_emptyRotate) {
@@ -45,6 +44,5 @@
Rect lineRect(0, 100);
ASSERT_TRUE(lineRect.isEmpty());
skewMatrix.mapRect(lineRect);
- EXPECT_FALSE(lineRect.isEmpty())
- << "Empty 'line' rect doesn't remain empty when rotated.";
+ EXPECT_FALSE(lineRect.isEmpty()) << "Empty 'line' rect doesn't remain empty when rotated.";
}
diff --git a/libs/hwui/tests/unit/MeshStateTests.cpp b/libs/hwui/tests/unit/MeshStateTests.cpp
index 511d6d2..1573fd3 100644
--- a/libs/hwui/tests/unit/MeshStateTests.cpp
+++ b/libs/hwui/tests/unit/MeshStateTests.cpp
@@ -16,8 +16,8 @@
#include <debug/MockGlesDriver.h>
#include <debug/ScopedReplaceDriver.h>
-#include <gtest/gtest.h>
#include <gmock/gmock.h>
+#include <gtest/gtest.h>
#include <renderstate/MeshState.h>
#include <tests/common/TestUtils.h>
@@ -32,5 +32,6 @@
EXPECT_CALL(mockGlDriver, glBufferData_(_, _, _, _));
GLuint buffer = 0;
- renderThread.renderState().meshState().genOrUpdateMeshBuffer(&buffer, 10, nullptr, GL_DYNAMIC_DRAW);
+ renderThread.renderState().meshState().genOrUpdateMeshBuffer(&buffer, 10, nullptr,
+ GL_DYNAMIC_DRAW);
}
diff --git a/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp b/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp
index 308fef3..0d47367 100644
--- a/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp
+++ b/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <Rect.h>
+#include <gtest/gtest.h>
#include <renderstate/OffscreenBufferPool.h>
#include <tests/common/TestUtils.h>
@@ -56,12 +56,10 @@
RENDERTHREAD_OPENGL_PIPELINE_TEST(OffscreenBuffer, getTextureCoordinates) {
OffscreenBuffer layerAligned(renderThread.renderState(), Caches::getInstance(), 256u, 256u);
- EXPECT_EQ(Rect(0, 1, 1, 0),
- layerAligned.getTextureCoordinates());
+ EXPECT_EQ(Rect(0, 1, 1, 0), layerAligned.getTextureCoordinates());
OffscreenBuffer layerUnaligned(renderThread.renderState(), Caches::getInstance(), 200u, 225u);
- EXPECT_EQ(Rect(0, 225.0f / 256.0f, 200.0f / 256.0f, 0),
- layerUnaligned.getTextureCoordinates());
+ EXPECT_EQ(Rect(0, 225.0f / 256.0f, 200.0f / 256.0f, 0), layerUnaligned.getTextureCoordinates());
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(OffscreenBuffer, dirty) {
@@ -221,7 +219,7 @@
auto hugeLayer = pool.get(renderThread.renderState(), pool.getMaxSize() / 64, 64);
EXPECT_GT(hugeLayer->getSizeInBytes(), pool.getMaxSize());
pool.putOrDelete(hugeLayer);
- EXPECT_EQ(0u, pool.getCount()); // failed to put (so was destroyed instead)
+ EXPECT_EQ(0u, pool.getCount()); // failed to put (so was destroyed instead)
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(OffscreenBufferPool, clear) {
@@ -244,4 +242,3 @@
EXPECT_EQ(0, GpuMemoryTracker::getInstanceCount(GpuObjectType::OffscreenBuffer));
}
-
diff --git a/libs/hwui/tests/unit/OpDumperTests.cpp b/libs/hwui/tests/unit/OpDumperTests.cpp
index 01840d7..ef30e87 100644
--- a/libs/hwui/tests/unit/OpDumperTests.cpp
+++ b/libs/hwui/tests/unit/OpDumperTests.cpp
@@ -16,8 +16,8 @@
#include <gtest/gtest.h>
-#include "tests/common/TestUtils.h"
#include "OpDumper.h"
+#include "tests/common/TestUtils.h"
using namespace android;
using namespace android::uirenderer;
diff --git a/libs/hwui/tests/unit/PathInterpolatorTests.cpp b/libs/hwui/tests/unit/PathInterpolatorTests.cpp
index d7cb23a..d888012 100644
--- a/libs/hwui/tests/unit/PathInterpolatorTests.cpp
+++ b/libs/hwui/tests/unit/PathInterpolatorTests.cpp
@@ -37,55 +37,36 @@
{0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f},
},
- {
- {
- 0.0f, 0.5f, 0.5178955f, 0.5341797f, 0.5489991f, 0.5625f, 0.5748291f,
- 0.5861328f, 0.60625005f, 0.62402344f, 0.640625f, 0.675f, 0.6951172f,
- 0.71875f, 0.7470703f, 0.78125f, 0.82246095f, 0.84606934f, 0.871875f,
- 0.9000244f, 0.93066406f, 0.96394044f, 1.0f
- },
- {
- 0.0f, 0.0f, 0.0028686523f, 0.011230469f, 0.024719238f, 0.04296875f,
- 0.06561279f, 0.092285156f, 0.15625f, 0.2319336f, 0.31640625f, 0.5f,
- 0.5932617f, 0.68359375f, 0.7680664f, 0.84375f, 0.90771484f, 0.9343872f,
- 0.95703125f, 0.97528076f, 0.98876953f, 0.99713135f, 1.0f
- },
- {
- 0.0f, 0.03375840187072754f, 0.13503384590148926f, 0.23630905151367188f,
- 0.336834192276001f, 0.4508626461029053f, 0.564141035079956f,
- 0.6781694889068604f, 0.7921979427337646f, 0.9054763317108154f, 1.0f
- },
- {
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0459827296435833f,
- 0.5146934390068054f, 0.8607426285743713f, 0.9776809215545654f, 1.0f
+ {{0.0f, 0.5f, 0.5178955f, 0.5341797f, 0.5489991f, 0.5625f,
+ 0.5748291f, 0.5861328f, 0.60625005f, 0.62402344f, 0.640625f, 0.675f,
+ 0.6951172f, 0.71875f, 0.7470703f, 0.78125f, 0.82246095f, 0.84606934f,
+ 0.871875f, 0.9000244f, 0.93066406f, 0.96394044f, 1.0f},
+ {0.0f, 0.0f, 0.0028686523f, 0.011230469f, 0.024719238f, 0.04296875f,
+ 0.06561279f, 0.092285156f, 0.15625f, 0.2319336f, 0.31640625f, 0.5f,
+ 0.5932617f, 0.68359375f, 0.7680664f, 0.84375f, 0.90771484f, 0.9343872f,
+ 0.95703125f, 0.97528076f, 0.98876953f, 0.99713135f, 1.0f},
+ {0.0f, 0.03375840187072754f, 0.13503384590148926f, 0.23630905151367188f,
+ 0.336834192276001f, 0.4508626461029053f, 0.564141035079956f, 0.6781694889068604f,
+ 0.7921979427337646f, 0.9054763317108154f, 1.0f},
+ {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0459827296435833f, 0.5146934390068054f,
+ 0.8607426285743713f, 0.9776809215545654f, 1.0f
- }
+ }
},
- {
- {
- 0.0f, 0.017895509f, 0.034179688f, 0.048999026f, 0.0625f, 0.0748291f,
- 0.08613282f, 0.10625f, 0.12402344f, 0.140625f, 0.17500001f, 0.19511719f,
- 0.21875f, 0.24707031f, 0.28125f, 0.32246095f, 0.34606934f, 0.371875f,
- 0.4000244f, 0.43066406f, 0.46394044f, 0.5f, 1.0f
- },
- {
- 0.0f, 0.0028686523f, 0.011230469f, 0.024719238f, 0.04296875f, 0.06561279f,
- 0.092285156f, 0.15625f, 0.2319336f, 0.31640625f, 0.5f, 0.5932617f,
- 0.68359375f, 0.7680664f, 0.84375f, 0.90771484f, 0.9343872f, 0.95703125f,
- 0.97528076f, 0.98876953f, 0.99713135f, 1.0f, 1.0f
- },
- {
- 0.0f, 0.102020263671875f, 0.20330810546875f, 0.3165740966796875f,
- 0.43060302734375f, 0.5318756103515625f, 0.6331634521484375f,
- 0.746429443359375f, 0.84771728515625f, 0.9617462158203125f, 1.0f
- },
- {
- 0.0f, 0.14280107617378235f, 0.6245699524879456f, 0.8985776901245117f,
- 0.9887426495552063f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f
- }
- },
-
+ {{0.0f, 0.017895509f, 0.034179688f, 0.048999026f, 0.0625f, 0.0748291f,
+ 0.08613282f, 0.10625f, 0.12402344f, 0.140625f, 0.17500001f, 0.19511719f,
+ 0.21875f, 0.24707031f, 0.28125f, 0.32246095f, 0.34606934f, 0.371875f,
+ 0.4000244f, 0.43066406f, 0.46394044f, 0.5f, 1.0f},
+ {0.0f, 0.0028686523f, 0.011230469f, 0.024719238f, 0.04296875f, 0.06561279f,
+ 0.092285156f, 0.15625f, 0.2319336f, 0.31640625f, 0.5f, 0.5932617f,
+ 0.68359375f, 0.7680664f, 0.84375f, 0.90771484f, 0.9343872f, 0.95703125f,
+ 0.97528076f, 0.98876953f, 0.99713135f, 1.0f, 1.0f},
+ {0.0f, 0.102020263671875f, 0.20330810546875f, 0.3165740966796875f, 0.43060302734375f,
+ 0.5318756103515625f, 0.6331634521484375f, 0.746429443359375f, 0.84771728515625f,
+ 0.9617462158203125f, 1.0f},
+ {0.0f, 0.14280107617378235f, 0.6245699524879456f, 0.8985776901245117f, 0.9887426495552063f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}},
};
@@ -98,13 +79,12 @@
}
TEST(Interpolator, pathInterpolation) {
- for (const TestData& data: sTestDataSet) {
+ for (const TestData& data : sTestDataSet) {
PathInterpolator interpolator(getX(data), getY(data));
for (size_t i = 0; i < data.inFraction.size(); i++) {
EXPECT_FLOAT_EQ(data.outFraction[i], interpolator.interpolate(data.inFraction[i]));
}
}
}
-
}
}
diff --git a/libs/hwui/tests/unit/RecordingCanvasTests.cpp b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
index dab1f89..5aae15f 100644
--- a/libs/hwui/tests/unit/RecordingCanvasTests.cpp
+++ b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
@@ -32,7 +32,7 @@
namespace uirenderer {
static void playbackOps(const DisplayList& displayList,
- std::function<void(const RecordedOp&)> opReceiver) {
+ std::function<void(const RecordedOp&)> opReceiver) {
for (auto& chunk : displayList.getChunks()) {
for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
RecordedOp* op = displayList.getOps()[opIndex];
@@ -42,7 +42,7 @@
}
static void validateSingleOp(std::unique_ptr<DisplayList>& dl,
- std::function<void(const RecordedOp& op)> opValidator) {
+ std::function<void(const RecordedOp& op)> opValidator) {
ASSERT_EQ(1u, dl->getOps().size()) << "Must be exactly one op";
opValidator(*(dl->getOps()[0]));
}
@@ -82,7 +82,7 @@
canvas.save(SaveFlags::MatrixClip);
canvas.clipRect(0, 0, 100, 100, SkClipOp::kIntersect);
canvas.clipRect(100, 100, 200, 200, SkClipOp::kIntersect);
- canvas.drawRect(0, 0, 50, 50, SkPaint()); // rejected at record time
+ canvas.drawRect(0, 0, 50, 50, SkPaint()); // rejected at record time
canvas.restore();
});
ASSERT_EQ(0u, dl->getOps().size()) << "Must be zero ops. Rect should be rejected.";
@@ -120,16 +120,16 @@
EXPECT_EQ(RecordedOpId::ArcOp, ops[0]->opId);
EXPECT_EQ(Rect(200, 200), ops[0]->unmappedBounds);
- EXPECT_EQ(RecordedOpId::OvalOp, ops[1]->opId)
- << "Circular arcs should be converted to ovals";
+ EXPECT_EQ(RecordedOpId::OvalOp, ops[1]->opId) << "Circular arcs should be converted to ovals";
EXPECT_EQ(Rect(100, 100), ops[1]->unmappedBounds);
}
OPENGL_PIPELINE_TEST(RecordingCanvas, drawLines) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 200, [](RecordingCanvas& canvas) {
SkPaint paint;
- paint.setStrokeWidth(20); // doesn't affect recorded bounds - would be resolved at bake time
- float points[] = { 0, 0, 20, 10, 30, 40, 90 }; // NB: only 1 valid line
+ paint.setStrokeWidth(
+ 20); // doesn't affect recorded bounds - would be resolved at bake time
+ float points[] = {0, 0, 20, 10, 30, 40, 90}; // NB: only 1 valid line
canvas.drawLines(&points[0], 7, paint);
});
@@ -143,9 +143,8 @@
}
OPENGL_PIPELINE_TEST(RecordingCanvas, drawRect) {
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 200, [](RecordingCanvas& canvas) {
- canvas.drawRect(10, 20, 90, 180, SkPaint());
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 100, 200, [](RecordingCanvas& canvas) { canvas.drawRect(10, 20, 90, 180, SkPaint()); });
ASSERT_EQ(1u, dl->getOps().size()) << "Must be exactly one op";
auto op = *(dl->getOps()[0]);
@@ -168,7 +167,7 @@
});
ASSERT_EQ(1u, dl->getOps().size()) << "Must be exactly one op";
ASSERT_EQ(RecordedOpId::RectOp, dl->getOps()[0]->opId)
- << "Non-rounded rects should be converted";
+ << "Non-rounded rects should be converted";
}
OPENGL_PIPELINE_TEST(RecordingCanvas, drawGlyphs) {
@@ -221,17 +220,17 @@
ASSERT_EQ(8u, ops.size());
int index = 0;
- EXPECT_EQ(RecordedOpId::TextOp, ops[index++]->opId); // no underline or strikethrough
+ EXPECT_EQ(RecordedOpId::TextOp, ops[index++]->opId); // no underline or strikethrough
EXPECT_EQ(RecordedOpId::TextOp, ops[index++]->opId);
- EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // strikethrough only
+ EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // strikethrough only
EXPECT_EQ(RecordedOpId::TextOp, ops[index++]->opId);
- EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // underline only
+ EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // underline only
EXPECT_EQ(RecordedOpId::TextOp, ops[index++]->opId);
- EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // underline
- EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // strikethrough
+ EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // underline
+ EXPECT_EQ(RecordedOpId::RectOp, ops[index++]->opId); // strikethrough
}
OPENGL_PIPELINE_TEST(RecordingCanvas, drawGlyphs_forceAlignLeft) {
@@ -329,15 +328,14 @@
}
RENDERTHREAD_OPENGL_PIPELINE_TEST(RecordingCanvas, textureLayer) {
- auto layerUpdater = TestUtils::createTextureLayerUpdater(renderThread, 100, 100,
- SkMatrix::MakeTrans(5, 5));
+ auto layerUpdater =
+ TestUtils::createTextureLayerUpdater(renderThread, 100, 100, SkMatrix::MakeTrans(5, 5));
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200,
- [&layerUpdater](RecordingCanvas& canvas) {
- canvas.drawLayer(layerUpdater.get());
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 200, 200,
+ [&layerUpdater](RecordingCanvas& canvas) { canvas.drawLayer(layerUpdater.get()); });
- validateSingleOp(dl, [] (const RecordedOp& op) {
+ validateSingleOp(dl, [](const RecordedOp& op) {
ASSERT_EQ(RecordedOpId::TextureLayerOp, op.opId);
ASSERT_TRUE(op.localMatrix.isIdentity()) << "Op must not apply matrix at record time.";
});
@@ -352,26 +350,26 @@
int count = 0;
playbackOps(*dl, [&count](const RecordedOp& op) {
Matrix4 expectedMatrix;
- switch(count++) {
- case 0:
- EXPECT_EQ(RecordedOpId::BeginLayerOp, op.opId);
- EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
- EXPECT_EQ(nullptr, op.localClip);
- EXPECT_TRUE(op.localMatrix.isIdentity());
- break;
- case 1:
- EXPECT_EQ(RecordedOpId::RectOp, op.opId);
- EXPECT_CLIP_RECT(Rect(180, 160), op.localClip);
- EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
- expectedMatrix.loadTranslate(-10, -20, 0);
- EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix);
- break;
- case 2:
- EXPECT_EQ(RecordedOpId::EndLayerOp, op.opId);
- // Don't bother asserting recording state data - it's not used
- break;
- default:
- ADD_FAILURE();
+ switch (count++) {
+ case 0:
+ EXPECT_EQ(RecordedOpId::BeginLayerOp, op.opId);
+ EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
+ EXPECT_EQ(nullptr, op.localClip);
+ EXPECT_TRUE(op.localMatrix.isIdentity());
+ break;
+ case 1:
+ EXPECT_EQ(RecordedOpId::RectOp, op.opId);
+ EXPECT_CLIP_RECT(Rect(180, 160), op.localClip);
+ EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
+ expectedMatrix.loadTranslate(-10, -20, 0);
+ EXPECT_MATRIX_APPROX_EQ(expectedMatrix, op.localMatrix);
+ break;
+ case 2:
+ EXPECT_EQ(RecordedOpId::EndLayerOp, op.opId);
+ // Don't bother asserting recording state data - it's not used
+ break;
+ default:
+ ADD_FAILURE();
}
});
EXPECT_EQ(3, count);
@@ -379,14 +377,14 @@
OPENGL_PIPELINE_TEST(RecordingCanvas, saveLayer_rounding) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 100, [](RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(10.25f, 10.75f, 89.25f, 89.75f, 128, SaveFlags::ClipToLayer);
- canvas.drawRect(20, 20, 80, 80, SkPaint());
- canvas.restore();
- });
- int count = 0;
- playbackOps(*dl, [&count](const RecordedOp& op) {
- Matrix4 expectedMatrix;
- switch(count++) {
+ canvas.saveLayerAlpha(10.25f, 10.75f, 89.25f, 89.75f, 128, SaveFlags::ClipToLayer);
+ canvas.drawRect(20, 20, 80, 80, SkPaint());
+ canvas.restore();
+ });
+ int count = 0;
+ playbackOps(*dl, [&count](const RecordedOp& op) {
+ Matrix4 expectedMatrix;
+ switch (count++) {
case 0:
EXPECT_EQ(RecordedOpId::BeginLayerOp, op.opId);
EXPECT_EQ(Rect(10, 10, 90, 90), op.unmappedBounds) << "Expect bounds rounded out";
@@ -402,9 +400,9 @@
break;
default:
ADD_FAILURE();
- }
- });
- EXPECT_EQ(3, count);
+ }
+ });
+ EXPECT_EQ(3, count);
}
OPENGL_PIPELINE_TEST(RecordingCanvas, saveLayer_missingRestore) {
@@ -424,31 +422,31 @@
OPENGL_PIPELINE_TEST(RecordingCanvas, saveLayer_simpleUnclipped) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
- canvas.saveLayerAlpha(10, 20, 190, 180, 128, (SaveFlags::Flags)0); // unclipped
+ canvas.saveLayerAlpha(10, 20, 190, 180, 128, (SaveFlags::Flags)0); // unclipped
canvas.drawRect(10, 20, 190, 180, SkPaint());
canvas.restore();
});
int count = 0;
playbackOps(*dl, [&count](const RecordedOp& op) {
- switch(count++) {
- case 0:
- EXPECT_EQ(RecordedOpId::BeginUnclippedLayerOp, op.opId);
- EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
- EXPECT_EQ(nullptr, op.localClip);
- EXPECT_TRUE(op.localMatrix.isIdentity());
- break;
- case 1:
- EXPECT_EQ(RecordedOpId::RectOp, op.opId);
- EXPECT_EQ(nullptr, op.localClip);
- EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
- EXPECT_TRUE(op.localMatrix.isIdentity());
- break;
- case 2:
- EXPECT_EQ(RecordedOpId::EndUnclippedLayerOp, op.opId);
- // Don't bother asserting recording state data - it's not used
- break;
- default:
- ADD_FAILURE();
+ switch (count++) {
+ case 0:
+ EXPECT_EQ(RecordedOpId::BeginUnclippedLayerOp, op.opId);
+ EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
+ EXPECT_EQ(nullptr, op.localClip);
+ EXPECT_TRUE(op.localMatrix.isIdentity());
+ break;
+ case 1:
+ EXPECT_EQ(RecordedOpId::RectOp, op.opId);
+ EXPECT_EQ(nullptr, op.localClip);
+ EXPECT_EQ(Rect(10, 20, 190, 180), op.unmappedBounds);
+ EXPECT_TRUE(op.localMatrix.isIdentity());
+ break;
+ case 2:
+ EXPECT_EQ(RecordedOpId::EndUnclippedLayerOp, op.opId);
+ // Don't bother asserting recording state data - it's not used
+ break;
+ default:
+ ADD_FAILURE();
}
});
EXPECT_EQ(3, count);
@@ -458,7 +456,7 @@
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
canvas.save(SaveFlags::MatrixClip);
canvas.clipRect(10, 20, 190, 180, SkClipOp::kIntersect);
- canvas.saveLayerAlpha(10, 20, 190, 180, 128, (SaveFlags::Flags)0); // unclipped
+ canvas.saveLayerAlpha(10, 20, 190, 180, 128, (SaveFlags::Flags)0); // unclipped
canvas.drawRect(10, 20, 190, 180, SkPaint());
canvas.restore();
canvas.restore();
@@ -487,7 +485,7 @@
if (count++ == 1) {
Matrix4 expectedMatrix;
EXPECT_EQ(RecordedOpId::RectOp, op.opId);
- EXPECT_CLIP_RECT(Rect(100, 100), op.localClip) // Recorded clip rect should be
+ EXPECT_CLIP_RECT(Rect(100, 100), op.localClip) // Recorded clip rect should be
// intersection of viewport and saveLayer bounds, in layer space;
EXPECT_EQ(Rect(400, 400), op.unmappedBounds);
expectedMatrix.loadTranslate(-100, -100, 0);
@@ -564,7 +562,7 @@
OPENGL_PIPELINE_TEST(RecordingCanvas, saveLayer_rejectBegin) {
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
canvas.save(SaveFlags::MatrixClip);
- canvas.translate(0, -20); // avoid identity case
+ canvas.translate(0, -20); // avoid identity case
// empty clip rect should force layer + contents to be rejected
canvas.clipRect(0, -20, 200, -20, SkClipOp::kIntersect);
canvas.saveLayerAlpha(0, 0, 200, 200, 128, SaveFlags::ClipToLayer);
@@ -577,37 +575,38 @@
}
OPENGL_PIPELINE_TEST(RecordingCanvas, drawRenderNode_rejection) {
- auto child = TestUtils::createNode(50, 50, 150, 150,
- [](RenderProperties& props, Canvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ auto child =
+ TestUtils::createNode(50, 50, 150, 150, [](RenderProperties& props, Canvas& canvas) {
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [&child](RecordingCanvas& canvas) {
- canvas.clipRect(0, 0, 0, 0, SkClipOp::kIntersect); // empty clip, reject node
- canvas.drawRenderNode(child.get()); // shouldn't crash when rejecting node...
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 200, 200, [&child](RecordingCanvas& canvas) {
+ canvas.clipRect(0, 0, 0, 0, SkClipOp::kIntersect); // empty clip, reject node
+ canvas.drawRenderNode(child.get()); // shouldn't crash when rejecting node...
+ });
ASSERT_TRUE(dl->isEmpty());
}
OPENGL_PIPELINE_TEST(RecordingCanvas, drawRenderNode_projection) {
- sp<RenderNode> background = TestUtils::createNode(50, 50, 150, 150,
- [](RenderProperties& props, Canvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ sp<RenderNode> background =
+ TestUtils::createNode(50, 50, 150, 150, [](RenderProperties& props, Canvas& canvas) {
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
{
background->mutateStagingProperties().setProjectionReceiver(false);
// NO RECEIVER PRESENT
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200,
- [&background](RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 100, 100, SkPaint());
- canvas.drawRenderNode(background.get());
- canvas.drawRect(0, 0, 100, 100, SkPaint());
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 200, 200, [&background](RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 100, 100, SkPaint());
+ canvas.drawRenderNode(background.get());
+ canvas.drawRect(0, 0, 100, 100, SkPaint());
+ });
EXPECT_EQ(-1, dl->projectionReceiveIndex)
<< "no projection receiver should have been observed";
}
@@ -615,18 +614,17 @@
background->mutateStagingProperties().setProjectionReceiver(true);
// RECEIVER PRESENT
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200,
- [&background](RecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 100, 100, SkPaint());
- canvas.drawRenderNode(background.get());
- canvas.drawRect(0, 0, 100, 100, SkPaint());
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 200, 200, [&background](RecordingCanvas& canvas) {
+ canvas.drawRect(0, 0, 100, 100, SkPaint());
+ canvas.drawRenderNode(background.get());
+ canvas.drawRect(0, 0, 100, 100, SkPaint());
+ });
ASSERT_EQ(3u, dl->getOps().size()) << "Must be three ops";
auto op = dl->getOps()[1];
EXPECT_EQ(RecordedOpId::RenderNodeOp, op->opId);
- EXPECT_EQ(1, dl->projectionReceiveIndex)
- << "correct projection receiver not identified";
+ EXPECT_EQ(1, dl->projectionReceiveIndex) << "correct projection receiver not identified";
// verify the behavior works even though projection receiver hasn't been sync'd yet
EXPECT_TRUE(background->stagingProperties().isProjectionReceiver());
@@ -718,17 +716,18 @@
OPENGL_PIPELINE_TEST(RecordingCanvas, refPaint) {
SkPaint paint;
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [&paint](RecordingCanvas& canvas) {
- paint.setColor(SK_ColorBLUE);
- // first two should use same paint
- canvas.drawRect(0, 0, 200, 10, paint);
- SkPaint paintCopy(paint);
- canvas.drawRect(0, 10, 200, 20, paintCopy);
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 200, 200, [&paint](RecordingCanvas& canvas) {
+ paint.setColor(SK_ColorBLUE);
+ // first two should use same paint
+ canvas.drawRect(0, 0, 200, 10, paint);
+ SkPaint paintCopy(paint);
+ canvas.drawRect(0, 10, 200, 20, paintCopy);
- // only here do we use different paint ptr
- paint.setColor(SK_ColorRED);
- canvas.drawRect(0, 20, 200, 30, paint);
- });
+ // only here do we use different paint ptr
+ paint.setColor(SK_ColorRED);
+ canvas.drawRect(0, 20, 200, 30, paint);
+ });
auto ops = dl->getOps();
ASSERT_EQ(3u, ops.size());
@@ -745,56 +744,58 @@
OPENGL_PIPELINE_TEST(RecordingCanvas, refBitmap) {
sk_sp<Bitmap> bitmap(TestUtils::createBitmap(100, 100));
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 100, [&bitmap](RecordingCanvas& canvas) {
- canvas.drawBitmap(*bitmap, 0, 0, nullptr);
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 100, 100,
+ [&bitmap](RecordingCanvas& canvas) { canvas.drawBitmap(*bitmap, 0, 0, nullptr); });
auto& bitmaps = dl->getBitmapResources();
EXPECT_EQ(1u, bitmaps.size());
}
OPENGL_PIPELINE_TEST(RecordingCanvas, refBitmapInShader_bitmapShader) {
sk_sp<Bitmap> bitmap = TestUtils::createBitmap(100, 100);
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 100, [&bitmap](RecordingCanvas& canvas) {
- SkPaint paint;
- SkBitmap skBitmap;
- bitmap->getSkBitmap(&skBitmap);
- sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(skBitmap, kNever_SkCopyPixelsMode);
- sk_sp<SkShader> shader = image->makeShader(
- SkShader::TileMode::kClamp_TileMode,
- SkShader::TileMode::kClamp_TileMode,
- nullptr);
- paint.setShader(std::move(shader));
- canvas.drawRoundRect(0, 0, 100, 100, 20.0f, 20.0f, paint);
- });
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 100, 100, [&bitmap](RecordingCanvas& canvas) {
+ SkPaint paint;
+ SkBitmap skBitmap;
+ bitmap->getSkBitmap(&skBitmap);
+ sk_sp<SkImage> image =
+ SkMakeImageFromRasterBitmap(skBitmap, kNever_SkCopyPixelsMode);
+ sk_sp<SkShader> shader =
+ image->makeShader(SkShader::TileMode::kClamp_TileMode,
+ SkShader::TileMode::kClamp_TileMode, nullptr);
+ paint.setShader(std::move(shader));
+ canvas.drawRoundRect(0, 0, 100, 100, 20.0f, 20.0f, paint);
+ });
auto& bitmaps = dl->getBitmapResources();
EXPECT_EQ(1u, bitmaps.size());
}
OPENGL_PIPELINE_TEST(RecordingCanvas, refBitmapInShader_composeShader) {
sk_sp<Bitmap> bitmap = TestUtils::createBitmap(100, 100);
- auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 100, [&bitmap](RecordingCanvas& canvas) {
- SkPaint paint;
- SkBitmap skBitmap;
- bitmap->getSkBitmap(&skBitmap);
- sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(skBitmap, kNever_SkCopyPixelsMode);
- sk_sp<SkShader> shader1 = image->makeShader(
- SkShader::TileMode::kClamp_TileMode,
- SkShader::TileMode::kClamp_TileMode,
- nullptr);
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(
+ 100, 100, [&bitmap](RecordingCanvas& canvas) {
+ SkPaint paint;
+ SkBitmap skBitmap;
+ bitmap->getSkBitmap(&skBitmap);
+ sk_sp<SkImage> image =
+ SkMakeImageFromRasterBitmap(skBitmap, kNever_SkCopyPixelsMode);
+ sk_sp<SkShader> shader1 =
+ image->makeShader(SkShader::TileMode::kClamp_TileMode,
+ SkShader::TileMode::kClamp_TileMode, nullptr);
- SkPoint center;
- center.set(50, 50);
- SkColor colors[2];
- colors[0] = Color::Black;
- colors[1] = Color::White;
- sk_sp<SkShader> shader2 = SkGradientShader::MakeRadial(center, 50, colors, nullptr, 2,
- SkShader::TileMode::kRepeat_TileMode);
+ SkPoint center;
+ center.set(50, 50);
+ SkColor colors[2];
+ colors[0] = Color::Black;
+ colors[1] = Color::White;
+ sk_sp<SkShader> shader2 = SkGradientShader::MakeRadial(
+ center, 50, colors, nullptr, 2, SkShader::TileMode::kRepeat_TileMode);
- sk_sp<SkShader> composeShader = SkShader::MakeComposeShader(std::move(shader1), std::move(shader2),
- SkBlendMode::kMultiply);
- paint.setShader(std::move(composeShader));
- canvas.drawRoundRect(0, 0, 100, 100, 20.0f, 20.0f, paint);
- });
+ sk_sp<SkShader> composeShader = SkShader::MakeComposeShader(
+ std::move(shader1), std::move(shader2), SkBlendMode::kMultiply);
+ paint.setShader(std::move(composeShader));
+ canvas.drawRoundRect(0, 0, 100, 100, 20.0f, 20.0f, paint);
+ });
auto& bitmaps = dl->getBitmapResources();
EXPECT_EQ(1u, bitmaps.size());
}
@@ -849,5 +850,5 @@
ASSERT_EQ(2, count);
}
-} // namespace uirenderer
-} // namespace android
+} // namespace uirenderer
+} // namespace android
diff --git a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
index d182d78..dff259f 100644
--- a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
+++ b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
@@ -14,25 +14,24 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <VectorDrawable.h>
+#include <gtest/gtest.h>
+#include <SkClipStack.h>
+#include <SkLiteRecorder.h>
+#include <SkSurface_Base.h>
+#include <string.h>
#include "AnimationContext.h"
#include "DamageAccumulator.h"
+#include "FatalTestCanvas.h"
#include "IContextFactory.h"
+#include "SkiaCanvas.h"
#include "pipeline/skia/SkiaDisplayList.h"
-#include "pipeline/skia/SkiaPipeline.h"
#include "pipeline/skia/SkiaOpenGLPipeline.h"
+#include "pipeline/skia/SkiaPipeline.h"
#include "pipeline/skia/SkiaRecordingCanvas.h"
#include "renderthread/CanvasContext.h"
#include "tests/common/TestUtils.h"
-#include "SkiaCanvas.h"
-#include <SkSurface_Base.h>
-#include <SkLiteRecorder.h>
-#include <SkClipStack.h>
-#include "FatalTestCanvas.h"
-#include <string.h>
-
using namespace android;
using namespace android::uirenderer;
@@ -40,8 +39,8 @@
using namespace android::uirenderer::skiapipeline;
TEST(RenderNodeDrawable, create) {
- auto rootNode = TestUtils::createNode(0, 0, 200, 400,
- [](RenderProperties& props, Canvas& canvas) {
+ auto rootNode =
+ TestUtils::createNode(0, 0, 200, 400, [](RenderProperties& props, Canvas& canvas) {
canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
});
@@ -66,47 +65,50 @@
}
static void drawOrderedNode(Canvas* canvas, uint8_t expectedDrawOrder, float z) {
- auto node = TestUtils::createSkiaNode(0, 0, 100, 100,
+ auto node = TestUtils::createSkiaNode(
+ 0, 0, 100, 100,
[expectedDrawOrder, z](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedRect(&canvas, expectedDrawOrder);
- props.setTranslationZ(z);
- });
- canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
+ drawOrderedRect(&canvas, expectedDrawOrder);
+ props.setTranslationZ(z);
+ });
+ canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
}
-static void drawOrderedNode(Canvas* canvas, uint8_t expectedDrawOrder,
+static void drawOrderedNode(
+ Canvas* canvas, uint8_t expectedDrawOrder,
std::function<void(RenderProperties& props, SkiaRecordingCanvas& canvas)> setup) {
- auto node = TestUtils::createSkiaNode(0, 0, 100, 100,
+ auto node = TestUtils::createSkiaNode(
+ 0, 0, 100, 100,
[expectedDrawOrder, setup](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedRect(&canvas, expectedDrawOrder);
- if (setup) {
- setup(props, canvas);
- }
- });
- canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
+ drawOrderedRect(&canvas, expectedDrawOrder);
+ if (setup) {
+ setup(props, canvas);
+ }
+ });
+ canvas->drawRenderNode(node.get()); // canvas takes reference/sole ownership
}
class ZReorderCanvas : public SkCanvas {
public:
ZReorderCanvas(int width, int height) : SkCanvas(width, height) {}
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
- int expectedOrder = SkColorGetB(paint.getColor()); // extract order from blue channel
+ int expectedOrder = SkColorGetB(paint.getColor()); // extract order from blue channel
EXPECT_EQ(expectedOrder, mDrawCounter++) << "An op was drawn out of order";
}
int getIndex() { return mDrawCounter; }
+
protected:
int mDrawCounter = 0;
};
-} // end anonymous namespace
+} // end anonymous namespace
TEST(RenderNodeDrawable, zReorder) {
-
- auto parent = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ auto parent = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
canvas.insertReorderBarrier(true);
canvas.insertReorderBarrier(false);
- drawOrderedNode(&canvas, 0, 10.0f); // in reorder=false at this point, so played inorder
+ drawOrderedNode(&canvas, 0, 10.0f); // in reorder=false at this point, so played inorder
drawOrderedRect(&canvas, 1);
canvas.insertReorderBarrier(true);
drawOrderedNode(&canvas, 6, 2.0f);
@@ -117,37 +119,36 @@
drawOrderedNode(&canvas, 7, 2.0f);
canvas.insertReorderBarrier(false);
drawOrderedRect(&canvas, 8);
- drawOrderedNode(&canvas, 9, -10.0f); // in reorder=false at this point, so played inorder
- canvas.insertReorderBarrier(true); //reorder a node ahead of drawrect op
+ drawOrderedNode(&canvas, 9, -10.0f); // in reorder=false at this point, so played inorder
+ canvas.insertReorderBarrier(true); // reorder a node ahead of drawrect op
drawOrderedRect(&canvas, 11);
drawOrderedNode(&canvas, 10, -1.0f);
canvas.insertReorderBarrier(false);
- canvas.insertReorderBarrier(true); //test with two empty reorder sections
+ canvas.insertReorderBarrier(true); // test with two empty reorder sections
canvas.insertReorderBarrier(true);
canvas.insertReorderBarrier(false);
drawOrderedRect(&canvas, 12);
});
- //create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
+ // create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
ZReorderCanvas canvas(100, 100);
RenderNodeDrawable drawable(parent.get(), &canvas, false);
canvas.drawDrawable(&drawable);
EXPECT_EQ(13, canvas.getIndex());
}
-TEST(RenderNodeDrawable, composeOnLayer)
-{
+TEST(RenderNodeDrawable, composeOnLayer) {
auto surface = SkSurface::MakeRasterN32Premul(1, 1);
SkCanvas& canvas = *surface->getCanvas();
canvas.drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
- auto rootNode = TestUtils::createSkiaNode(0, 0, 1, 1,
- [](RenderProperties& props, SkiaRecordingCanvas& recorder) {
- recorder.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
- });
+ auto rootNode = TestUtils::createSkiaNode(
+ 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& recorder) {
+ recorder.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
+ });
- //attach a layer to the render node
+ // attach a layer to the render node
auto surfaceLayer = SkSurface::MakeRasterN32Premul(1, 1);
auto canvas2 = surfaceLayer->getCanvas();
canvas2->drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
@@ -182,39 +183,38 @@
}
}
-TEST(RenderNodeDrawable, saveLayerClipAndMatrixRestore)
-{
+TEST(RenderNodeDrawable, saveLayerClipAndMatrixRestore) {
auto surface = SkSurface::MakeRasterN32Premul(400, 800);
SkCanvas& canvas = *surface->getCanvas();
canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorWHITE);
- auto rootNode = TestUtils::createSkiaNode(0, 0, 400, 800,
- [](RenderProperties& props, SkiaRecordingCanvas& recorder) {
- SkPaint layerPaint;
- ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 800), getRecorderClipBounds(recorder));
- EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
+ auto rootNode = TestUtils::createSkiaNode(
+ 0, 0, 400, 800, [](RenderProperties& props, SkiaRecordingCanvas& recorder) {
+ SkPaint layerPaint;
+ ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 800), getRecorderClipBounds(recorder));
+ EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
- //note we don't pass SaveFlags::MatrixClip, but matrix and clip will be saved
- recorder.saveLayer(0, 0, 400, 400, &layerPaint, SaveFlags::ClipToLayer);
- ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 400), getRecorderClipBounds(recorder));
- EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
+ // note we don't pass SaveFlags::MatrixClip, but matrix and clip will be saved
+ recorder.saveLayer(0, 0, 400, 400, &layerPaint, SaveFlags::ClipToLayer);
+ ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 400), getRecorderClipBounds(recorder));
+ EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
- recorder.clipRect(50, 50, 350, 350, SkClipOp::kIntersect);
- ASSERT_EQ(SkRect::MakeLTRB(50, 50, 350, 350), getRecorderClipBounds(recorder));
+ recorder.clipRect(50, 50, 350, 350, SkClipOp::kIntersect);
+ ASSERT_EQ(SkRect::MakeLTRB(50, 50, 350, 350), getRecorderClipBounds(recorder));
- recorder.translate(300.0f, 400.0f);
- EXPECT_EQ(SkMatrix::MakeTrans(300.0f, 400.0f), getRecorderMatrix(recorder));
+ recorder.translate(300.0f, 400.0f);
+ EXPECT_EQ(SkMatrix::MakeTrans(300.0f, 400.0f), getRecorderMatrix(recorder));
- recorder.restore();
- ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 800), getRecorderClipBounds(recorder));
- EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
+ recorder.restore();
+ ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 800), getRecorderClipBounds(recorder));
+ EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setColor(SK_ColorGREEN);
- recorder.drawRect(0.0f, 400.0f, 400.0f, 800.0f, paint);
- });
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setColor(SK_ColorGREEN);
+ recorder.drawRect(0.0f, 400.0f, 400.0f, 800.0f, paint);
+ });
RenderNodeDrawable drawable(rootNode.get(), &canvas, true);
canvas.drawDrawable(&drawable);
@@ -228,7 +228,7 @@
return new AnimationContext(clock);
}
};
-} // end anonymous namespace
+} // end anonymous namespace
RENDERTHREAD_TEST(RenderNodeDrawable, projectionReorder) {
static const int SCROLL_X = 5;
@@ -238,33 +238,36 @@
ProjectionTestCanvas(int width, int height) : SkCanvas(width, height) {}
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
const int index = mDrawCounter++;
- SkMatrix expectedMatrix;;
+ SkMatrix expectedMatrix;
+ ;
switch (index) {
- case 0: //this is node "B"
- EXPECT_EQ(SkRect::MakeWH(100, 100), rect);
- EXPECT_EQ(SK_ColorWHITE, paint.getColor());
- expectedMatrix.reset();
- EXPECT_EQ(SkRect::MakeLTRB(0, 0, 100, 100), TestUtils::getClipBounds(this));
- break;
- case 1: //this is node "P"
- EXPECT_EQ(SkRect::MakeLTRB(-10, -10, 60, 60), rect);
- EXPECT_EQ(SK_ColorDKGRAY, paint.getColor());
- expectedMatrix.setTranslate(50 - SCROLL_X, 50 - SCROLL_Y);
- EXPECT_EQ(SkRect::MakeLTRB(-35, -30, 45, 50), TestUtils::getLocalClipBounds(this));
- break;
- case 2: //this is node "C"
- EXPECT_EQ(SkRect::MakeWH(100, 50), rect);
- EXPECT_EQ(SK_ColorBLUE, paint.getColor());
- expectedMatrix.setTranslate(-SCROLL_X, 50 - SCROLL_Y);
- EXPECT_EQ(SkRect::MakeLTRB(0, 40, 95, 90), TestUtils::getClipBounds(this));
- break;
- default:
- ADD_FAILURE();
+ case 0: // this is node "B"
+ EXPECT_EQ(SkRect::MakeWH(100, 100), rect);
+ EXPECT_EQ(SK_ColorWHITE, paint.getColor());
+ expectedMatrix.reset();
+ EXPECT_EQ(SkRect::MakeLTRB(0, 0, 100, 100), TestUtils::getClipBounds(this));
+ break;
+ case 1: // this is node "P"
+ EXPECT_EQ(SkRect::MakeLTRB(-10, -10, 60, 60), rect);
+ EXPECT_EQ(SK_ColorDKGRAY, paint.getColor());
+ expectedMatrix.setTranslate(50 - SCROLL_X, 50 - SCROLL_Y);
+ EXPECT_EQ(SkRect::MakeLTRB(-35, -30, 45, 50),
+ TestUtils::getLocalClipBounds(this));
+ break;
+ case 2: // this is node "C"
+ EXPECT_EQ(SkRect::MakeWH(100, 50), rect);
+ EXPECT_EQ(SK_ColorBLUE, paint.getColor());
+ expectedMatrix.setTranslate(-SCROLL_X, 50 - SCROLL_Y);
+ EXPECT_EQ(SkRect::MakeLTRB(0, 40, 95, 90), TestUtils::getClipBounds(this));
+ break;
+ default:
+ ADD_FAILURE();
}
EXPECT_EQ(expectedMatrix, getTotalMatrix());
}
int getIndex() { return mDrawCounter; }
+
protected:
int mDrawCounter = 0;
};
@@ -277,59 +280,70 @@
* The parent is scrolled by SCROLL_X/SCROLL_Y, but this does not affect the background
* (which isn't affected by scroll).
*/
- auto receiverBackground = TestUtils::createSkiaNode(0, 0, 100, 100,
+ auto receiverBackground = TestUtils::createSkiaNode(
+ 0, 0, 100, 100,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- properties.setProjectionReceiver(true);
- // scroll doesn't apply to background, so undone via translationX/Y
- // NOTE: translationX/Y only! no other transform properties may be set for a proj receiver!
- properties.setTranslationX(SCROLL_X);
- properties.setTranslationY(SCROLL_Y);
+ properties.setProjectionReceiver(true);
+ // scroll doesn't apply to background, so undone via translationX/Y
+ // NOTE: translationX/Y only! no other transform properties may be set for a proj
+ // receiver!
+ properties.setTranslationX(SCROLL_X);
+ properties.setTranslationY(SCROLL_Y);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- }, "B");
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ },
+ "B");
- auto projectingRipple = TestUtils::createSkiaNode(50, 0, 100, 50,
+ auto projectingRipple = TestUtils::createSkiaNode(
+ 50, 0, 100, 50,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- properties.setProjectBackwards(true);
- properties.setClipToBounds(false);
- SkPaint paint;
- paint.setColor(SK_ColorDKGRAY);
- canvas.drawRect(-10, -10, 60, 60, paint);
- }, "P");
- auto child = TestUtils::createSkiaNode(0, 50, 100, 100,
+ properties.setProjectBackwards(true);
+ properties.setClipToBounds(false);
+ SkPaint paint;
+ paint.setColor(SK_ColorDKGRAY);
+ canvas.drawRect(-10, -10, 60, 60, paint);
+ },
+ "P");
+ auto child = TestUtils::createSkiaNode(
+ 0, 50, 100, 100,
[&projectingRipple](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorBLUE);
- canvas.drawRect(0, 0, 100, 50, paint);
- canvas.drawRenderNode(projectingRipple.get());
- }, "C");
- auto parent = TestUtils::createSkiaNode(0, 0, 100, 100,
- [&receiverBackground, &child](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- // Set a rect outline for the projecting ripple to be masked against.
- properties.mutableOutline().setRoundRect(10, 10, 90, 90, 5, 1.0f);
+ SkPaint paint;
+ paint.setColor(SK_ColorBLUE);
+ canvas.drawRect(0, 0, 100, 50, paint);
+ canvas.drawRenderNode(projectingRipple.get());
+ },
+ "C");
+ auto parent = TestUtils::createSkiaNode(
+ 0, 0, 100, 100,
+ [&receiverBackground, &child](RenderProperties& properties,
+ SkiaRecordingCanvas& canvas) {
+ // Set a rect outline for the projecting ripple to be masked against.
+ properties.mutableOutline().setRoundRect(10, 10, 90, 90, 5, 1.0f);
- canvas.save(SaveFlags::MatrixClip);
- canvas.translate(-SCROLL_X, -SCROLL_Y); // Apply scroll (note: bg undoes this internally)
- canvas.drawRenderNode(receiverBackground.get());
- canvas.drawRenderNode(child.get());
- canvas.restore();
- }, "A");
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.translate(-SCROLL_X,
+ -SCROLL_Y); // Apply scroll (note: bg undoes this internally)
+ canvas.drawRenderNode(receiverBackground.get());
+ canvas.drawRenderNode(child.get());
+ canvas.restore();
+ },
+ "A");
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, parent.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, parent.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;
parent->prepareTree(info);
- //parent(A) -> (receiverBackground, child)
- //child(C) -> (rect[0, 0, 100, 50], projectingRipple)
- //projectingRipple(P) -> (rect[-10, -10, 60, 60]) -> projects backwards
- //receiverBackground(B) -> (rect[0, 0, 100, 100]) -> projection receiver
+ // parent(A) -> (receiverBackground, child)
+ // child(C) -> (rect[0, 0, 100, 50], projectingRipple)
+ // projectingRipple(P) -> (rect[-10, -10, 60, 60]) -> projects backwards
+ // receiverBackground(B) -> (rect[0, 0, 100, 100]) -> projection receiver
- //create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
+ // create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
ProjectionTestCanvas canvas(100, 100);
RenderNodeDrawable drawable(parent.get(), &canvas, true);
canvas.drawDrawable(&drawable);
@@ -353,17 +367,17 @@
class ProjectionTestCanvas : public SkCanvas {
public:
ProjectionTestCanvas(int* drawCounter)
- : SkCanvas(CANVAS_WIDTH, CANVAS_HEIGHT)
- , mDrawCounter(drawCounter)
- {}
+ : SkCanvas(CANVAS_WIDTH, CANVAS_HEIGHT), mDrawCounter(drawCounter) {}
void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
- const SkPaint&) override {
- EXPECT_EQ(0, (*mDrawCounter)++); //part of painting the layer
- EXPECT_EQ(SkRect::MakeLTRB(0, 0, LAYER_WIDTH, LAYER_HEIGHT), TestUtils::getClipBounds(this));
+ const SkPaint&) override {
+ EXPECT_EQ(0, (*mDrawCounter)++); // part of painting the layer
+ EXPECT_EQ(SkRect::MakeLTRB(0, 0, LAYER_WIDTH, LAYER_HEIGHT),
+ TestUtils::getClipBounds(this));
}
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
EXPECT_EQ(1, (*mDrawCounter)++);
- EXPECT_EQ(SkRect::MakeLTRB(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT), TestUtils::getClipBounds(this));
+ EXPECT_EQ(SkRect::MakeLTRB(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT),
+ TestUtils::getClipBounds(this));
}
void onDrawOval(const SkRect&, const SkPaint&) override {
EXPECT_EQ(2, (*mDrawCounter)++);
@@ -378,69 +392,73 @@
class ProjectionLayer : public SkSurface_Base {
public:
ProjectionLayer(int* drawCounter)
- : SkSurface_Base(SkImageInfo::MakeN32Premul(LAYER_WIDTH, LAYER_HEIGHT), nullptr)
- , mDrawCounter(drawCounter) {
- }
+ : SkSurface_Base(SkImageInfo::MakeN32Premul(LAYER_WIDTH, LAYER_HEIGHT), nullptr)
+ , mDrawCounter(drawCounter) {}
void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override {
EXPECT_EQ(3, (*mDrawCounter)++);
EXPECT_EQ(SkRect::MakeLTRB(100 - SCROLL_X, 100 - SCROLL_Y, 300 - SCROLL_X,
- 300 - SCROLL_Y), TestUtils::getClipBounds(this->getCanvas()));
+ 300 - SCROLL_Y),
+ TestUtils::getClipBounds(this->getCanvas()));
}
- SkCanvas* onNewCanvas() override {
- return new ProjectionTestCanvas(mDrawCounter);
- }
- sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override {
- return nullptr;
- }
- sk_sp<SkImage> onNewImageSnapshot() override {
- return nullptr;
- }
+ SkCanvas* onNewCanvas() override { return new ProjectionTestCanvas(mDrawCounter); }
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override { return nullptr; }
+ sk_sp<SkImage> onNewImageSnapshot() override { return nullptr; }
void onCopyOnWrite(ContentChangeMode) override {}
int* mDrawCounter;
};
- auto receiverBackground = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ auto receiverBackground = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- properties.setProjectionReceiver(true);
- // scroll doesn't apply to background, so undone via translationX/Y
- // NOTE: translationX/Y only! no other transform properties may be set for a proj receiver!
- properties.setTranslationX(SCROLL_X);
- properties.setTranslationY(SCROLL_Y);
+ properties.setProjectionReceiver(true);
+ // scroll doesn't apply to background, so undone via translationX/Y
+ // NOTE: translationX/Y only! no other transform properties may be set for a proj
+ // receiver!
+ properties.setTranslationX(SCROLL_X);
+ properties.setTranslationY(SCROLL_Y);
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
- }, "B"); //B
- auto projectingRipple = TestUtils::createSkiaNode(0, 0, LAYER_WIDTH, LAYER_HEIGHT,
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
+ },
+ "B"); // B
+ auto projectingRipple = TestUtils::createSkiaNode(
+ 0, 0, LAYER_WIDTH, LAYER_HEIGHT,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- properties.setProjectBackwards(true);
- properties.setClipToBounds(false);
- canvas.drawOval(100, 100, 300, 300, SkPaint()); // drawn mostly out of layer bounds
- }, "R"); //R
- auto child = TestUtils::createSkiaNode(100, 100, 300, 300,
+ properties.setProjectBackwards(true);
+ properties.setClipToBounds(false);
+ canvas.drawOval(100, 100, 300, 300, SkPaint()); // drawn mostly out of layer bounds
+ },
+ "R"); // R
+ auto child = TestUtils::createSkiaNode(
+ 100, 100, 300, 300,
[&projectingRipple](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- canvas.drawRenderNode(projectingRipple.get());
- canvas.drawArc(0, 0, LAYER_WIDTH, LAYER_HEIGHT, 0.0f, 280.0f, true, SkPaint());
- }, "C"); //C
- auto parent = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ canvas.drawRenderNode(projectingRipple.get());
+ canvas.drawArc(0, 0, LAYER_WIDTH, LAYER_HEIGHT, 0.0f, 280.0f, true, SkPaint());
+ },
+ "C"); // C
+ auto parent = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[&receiverBackground, &child](RenderProperties& properties,
- SkiaRecordingCanvas& canvas) {
- // Set a rect outline for the projecting ripple to be masked against.
- properties.mutableOutline().setRoundRect(10, 10, 390, 390, 0, 1.0f);
- canvas.translate(-SCROLL_X, -SCROLL_Y); // Apply scroll (note: bg undoes this internally)
- canvas.drawRenderNode(receiverBackground.get());
- canvas.drawRenderNode(child.get());
- }, "A"); //A
+ SkiaRecordingCanvas& canvas) {
+ // Set a rect outline for the projecting ripple to be masked against.
+ properties.mutableOutline().setRoundRect(10, 10, 390, 390, 0, 1.0f);
+ canvas.translate(-SCROLL_X,
+ -SCROLL_Y); // Apply scroll (note: bg undoes this internally)
+ canvas.drawRenderNode(receiverBackground.get());
+ canvas.drawRenderNode(child.get());
+ },
+ "A"); // A
- //prepareTree is required to find, which receivers have backward projected nodes
+ // prepareTree is required to find, which receivers have backward projected nodes
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, parent.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, parent.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;
parent->prepareTree(info);
int drawCounter = 0;
- //set a layer after prepareTree to avoid layer logic there
+ // set a layer after prepareTree to avoid layer logic there
child->animatorProperties().mutateLayerProperties().setType(LayerType::RenderLayer);
sk_sp<SkSurface> surfaceLayer1(new ProjectionLayer(&drawCounter));
child->setLayerSurface(surfaceLayer1);
@@ -450,10 +468,10 @@
LayerUpdateQueue layerUpdateQueue;
layerUpdateQueue.enqueueLayerWithDamage(child.get(),
- android::uirenderer::Rect(LAYER_WIDTH, LAYER_HEIGHT));
+ android::uirenderer::Rect(LAYER_WIDTH, LAYER_HEIGHT));
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
pipeline->renderLayersImpl(layerUpdateQueue, true, false);
- EXPECT_EQ(1, drawCounter); //assert index 0 is drawn on the layer
+ EXPECT_EQ(1, drawCounter); // assert index 0 is drawn on the layer
RenderNodeDrawable drawable(parent.get(), surfaceLayer1->getCanvas(), true);
surfaceLayer1->getCanvas()->drawDrawable(&drawable);
@@ -490,40 +508,50 @@
int mDrawCounter = 0;
};
- auto receiverBackground = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ auto receiverBackground = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- properties.setProjectionReceiver(true);
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
- }, "B"); //B
- auto projectingRipple = TestUtils::createSkiaNode(0, 0, 200, 200,
+ properties.setProjectionReceiver(true);
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
+ },
+ "B"); // B
+ auto projectingRipple = TestUtils::createSkiaNode(
+ 0, 0, 200, 200,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- // scroll doesn't apply to background, so undone via translationX/Y
- // NOTE: translationX/Y only! no other transform properties may be set for a proj receiver!
- properties.setTranslationX(SCROLL_X);
- properties.setTranslationY(SCROLL_Y);
- properties.setProjectBackwards(true);
- properties.setClipToBounds(false);
- canvas.drawOval(0, 0, 200, 200, SkPaint());
- }, "R"); //R
- auto child = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ // scroll doesn't apply to background, so undone via translationX/Y
+ // NOTE: translationX/Y only! no other transform properties may be set for a proj
+ // receiver!
+ properties.setTranslationX(SCROLL_X);
+ properties.setTranslationY(SCROLL_Y);
+ properties.setProjectBackwards(true);
+ properties.setClipToBounds(false);
+ canvas.drawOval(0, 0, 200, 200, SkPaint());
+ },
+ "R"); // R
+ auto child = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[&projectingRipple](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- // Record time clip will be ignored by projectee
- canvas.clipRect(100, 100, 300, 300, SkClipOp::kIntersect);
+ // Record time clip will be ignored by projectee
+ canvas.clipRect(100, 100, 300, 300, SkClipOp::kIntersect);
- canvas.translate(-SCROLL_X, -SCROLL_Y); // Apply scroll (note: bg undoes this internally)
- canvas.drawRenderNode(projectingRipple.get());
- }, "C"); //C
- auto parent = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
- [&receiverBackground, &child](RenderProperties& properties,
- SkiaRecordingCanvas& canvas) {
- canvas.drawRenderNode(receiverBackground.get());
- canvas.drawRenderNode(child.get());
- }, "A"); //A
+ canvas.translate(-SCROLL_X,
+ -SCROLL_Y); // Apply scroll (note: bg undoes this internally)
+ canvas.drawRenderNode(projectingRipple.get());
+ },
+ "C"); // C
+ auto parent =
+ TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ [&receiverBackground, &child](RenderProperties& properties,
+ SkiaRecordingCanvas& canvas) {
+ canvas.drawRenderNode(receiverBackground.get());
+ canvas.drawRenderNode(child.get());
+ },
+ "A"); // A
- //prepareTree is required to find, which receivers have backward projected nodes
+ // prepareTree is required to find, which receivers have backward projected nodes
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, parent.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, parent.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;
@@ -536,17 +564,16 @@
}
namespace {
-static int drawNode(RenderThread& renderThread, const sp<RenderNode>& renderNode)
-{
+static int drawNode(RenderThread& renderThread, const sp<RenderNode>& renderNode) {
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, renderNode.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, renderNode.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;
renderNode->prepareTree(info);
- //create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
+ // create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
ZReorderCanvas canvas(100, 100);
RenderNodeDrawable drawable(renderNode.get(), &canvas, false);
canvas.drawDrawable(&drawable);
@@ -562,18 +589,18 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectionReceiver(true);
- } ); //nodeB
+ }); // nodeB
drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(3, drawNode(renderThread, nodeA));
}
@@ -586,19 +613,21 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //drawn as 2
+ drawOrderedNode(&canvas, 3, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) { // drawn as 2
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //drawn as 3
- props.setProjectionReceiver(true);
- } ); //nodeE
- }); //nodeA
+ }); // nodeR
+ }); // nodeC
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // drawn as 3
+ props.setProjectionReceiver(true);
+ }); // nodeE
+ }); // nodeA
EXPECT_EQ(4, drawNode(renderThread, nodeA));
}
@@ -610,17 +639,17 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 255, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- //not having a projection receiver is an undefined behavior
+ // not having a projection receiver is an undefined behavior
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(2, drawNode(renderThread, nodeA));
}
@@ -632,17 +661,17 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectionReceiver(true);
drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(3, drawNode(renderThread, nodeA));
}
@@ -654,22 +683,22 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, nullptr); //nodeB
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, nullptr); // nodeB
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 255, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- //having a node that is projected on itself is an undefined/unexpected behavior
+ // having a node that is projected on itself is an undefined/unexpected behavior
props.setProjectionReceiver(true);
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(2, drawNode(renderThread, nodeA));
}
-//Note: the outcome for this test is different in HWUI
+// Note: the outcome for this test is different in HWUI
RENDERTHREAD_TEST(RenderNodeDrawable, projectionReorderProjectedSibling) {
/* R is set to project on B, but R is not drawn because projecting on a sibling is not allowed.
A
@@ -677,18 +706,18 @@
/ | \
B C R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- } ); //nodeC
+ }); // nodeB
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) {}); // nodeC
drawOrderedNode(&canvas, 255, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- }); //nodeA
+ }); // nodeR
+ }); // nodeA
EXPECT_EQ(2, drawNode(renderThread, nodeA));
}
@@ -701,20 +730,20 @@
/ | \
B C R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- } ); //nodeC
+ }); // nodeB
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) {}); // nodeC
drawOrderedNode(&canvas, 255, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectBackwards(true);
props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeG
- }); //nodeA
+ }); // nodeR
+ }); // nodeG
+ }); // nodeA
EXPECT_EQ(3, drawNode(renderThread, nodeA));
}
@@ -728,18 +757,19 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
props.setProjectionReceiver(true);
drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- } ); //nodeB
- }); //nodeA
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeB
+ }); // nodeA
EXPECT_EQ(3, drawNode(renderThread, nodeA));
}
@@ -751,21 +781,23 @@
/ \
G R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //B
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // B
props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //C
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //G
- props.setProjectionReceiver(true);
- } ); //nodeG
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //R
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ }); // nodeB
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // C
+ drawOrderedNode(&canvas, 3,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // G
+ props.setProjectionReceiver(true);
+ }); // nodeG
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // R
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(4, drawNode(renderThread, nodeA));
}
@@ -777,21 +809,23 @@
/ \
G R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //B
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // B
props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //C
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //G
- props.setProjectionReceiver(true);
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeG
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //R
- } ); //nodeR
- } ); //nodeC
- }); //nodeA
+ }); // nodeB
+ drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // C
+ drawOrderedNode(&canvas, 1,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // G
+ props.setProjectionReceiver(true);
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeG
+ drawOrderedNode(&canvas, 3,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // R
+ }); // nodeR
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(4, drawNode(renderThread, nodeA));
}
@@ -805,23 +839,26 @@
|
R
*/
- auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //B
+ auto nodeA = TestUtils::createSkiaNode(0, 0, 100, 100, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) {
+ drawOrderedNode(&canvas, 0, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // B
props.setProjectionReceiver(true);
- } ); //nodeB
- drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //C
- drawOrderedNode(&canvas, 2, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //G
- props.setProjectionReceiver(true);
- } ); //nodeG
- drawOrderedNode(&canvas, 4, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //D
- drawOrderedNode(&canvas, 3, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { //R
- props.setProjectBackwards(true);
- props.setClipToBounds(false);
- } ); //nodeR
- } ); //nodeD
- } ); //nodeC
- }); //nodeA
+ }); // nodeB
+ drawOrderedNode(&canvas, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // C
+ drawOrderedNode(&canvas, 2,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // G
+ props.setProjectionReceiver(true);
+ }); // nodeG
+ drawOrderedNode(&canvas, 4,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) { // D
+ drawOrderedNode(&canvas, 3, [](RenderProperties& props,
+ SkiaRecordingCanvas& canvas) { // R
+ props.setProjectBackwards(true);
+ props.setClipToBounds(false);
+ }); // nodeR
+ }); // nodeD
+ }); // nodeC
+ }); // nodeA
EXPECT_EQ(5, drawNode(renderThread, nodeA));
}
@@ -830,8 +867,7 @@
static const int CANVAS_HEIGHT = 200;
class SimpleTestCanvas : public TestCanvasBase {
public:
- SimpleTestCanvas() : TestCanvasBase(CANVAS_WIDTH, CANVAS_HEIGHT) {
- }
+ SimpleTestCanvas() : TestCanvasBase(CANVAS_WIDTH, CANVAS_HEIGHT) {}
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
EXPECT_EQ(0, mDrawCounter++);
}
@@ -841,11 +877,12 @@
};
auto node = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- sk_sp<Bitmap> bitmap(TestUtils::createBitmap(25, 25));
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
- canvas.drawBitmap(*bitmap, 10, 10, nullptr);
- });
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(25, 25));
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ SkPaint());
+ canvas.drawBitmap(*bitmap, 10, 10, nullptr);
+ });
SimpleTestCanvas canvas;
RenderNodeDrawable drawable(node.get(), &canvas, true);
@@ -858,33 +895,32 @@
static const int CANVAS_HEIGHT = 200;
class ColorTestCanvas : public TestCanvasBase {
public:
- ColorTestCanvas() : TestCanvasBase(CANVAS_WIDTH, CANVAS_HEIGHT) {
- }
+ ColorTestCanvas() : TestCanvasBase(CANVAS_WIDTH, CANVAS_HEIGHT) {}
void onDrawPaint(const SkPaint&) {
switch (mDrawCounter++) {
- case 0:
- EXPECT_EQ(SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT),
- TestUtils::getClipBounds(this));
- break;
- case 1:
- EXPECT_EQ(SkRect::MakeWH(10, 10), TestUtils::getClipBounds(this));
- break;
- default:
- ADD_FAILURE();
+ case 0:
+ EXPECT_EQ(SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT),
+ TestUtils::getClipBounds(this));
+ break;
+ case 1:
+ EXPECT_EQ(SkRect::MakeWH(10, 10), TestUtils::getClipBounds(this));
+ break;
+ default:
+ ADD_FAILURE();
}
}
};
- auto unclippedColorView = TestUtils::createSkiaNode(0, 0, 10, 10,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- props.setClipToBounds(false);
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- });
+ auto unclippedColorView = TestUtils::createSkiaNode(
+ 0, 0, 10, 10, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ props.setClipToBounds(false);
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ });
- auto clippedColorView = TestUtils::createSkiaNode(0, 0, 10, 10,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- });
+ auto clippedColorView = TestUtils::createSkiaNode(
+ 0, 0, 10, 10, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ });
ColorTestCanvas canvas;
RenderNodeDrawable drawable(unclippedColorView.get(), &canvas, true);
@@ -900,42 +936,43 @@
static const int CANVAS_HEIGHT = 200;
class RenderNodeTestCanvas : public TestCanvasBase {
public:
- RenderNodeTestCanvas() : TestCanvasBase(CANVAS_WIDTH, CANVAS_HEIGHT) {
- }
+ RenderNodeTestCanvas() : TestCanvasBase(CANVAS_WIDTH, CANVAS_HEIGHT) {}
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
- switch(mDrawCounter++) {
- case 0:
- EXPECT_EQ(SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), TestUtils::getClipBounds(this));
- EXPECT_EQ(SK_ColorDKGRAY, paint.getColor());
- break;
- case 1:
- EXPECT_EQ(SkRect::MakeLTRB(50, 50, 150, 150), TestUtils::getClipBounds(this));
- EXPECT_EQ(SK_ColorWHITE, paint.getColor());
- break;
- default:
- ADD_FAILURE();
+ switch (mDrawCounter++) {
+ case 0:
+ EXPECT_EQ(SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT),
+ TestUtils::getClipBounds(this));
+ EXPECT_EQ(SK_ColorDKGRAY, paint.getColor());
+ break;
+ case 1:
+ EXPECT_EQ(SkRect::MakeLTRB(50, 50, 150, 150), TestUtils::getClipBounds(this));
+ EXPECT_EQ(SK_ColorWHITE, paint.getColor());
+ break;
+ default:
+ ADD_FAILURE();
}
}
};
- auto child = TestUtils::createSkiaNode(10, 10, 110, 110,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, 100, 100, paint);
- });
+ auto child = TestUtils::createSkiaNode(
+ 10, 10, 110, 110, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
- auto parent = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ auto parent = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[&child](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
- paint.setColor(SK_ColorDKGRAY);
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
+ SkPaint paint;
+ paint.setColor(SK_ColorDKGRAY);
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
- canvas.save(SaveFlags::MatrixClip);
- canvas.translate(40, 40);
- canvas.drawRenderNode(child.get());
- canvas.restore();
- });
+ canvas.save(SaveFlags::MatrixClip);
+ canvas.translate(40, 40);
+ canvas.drawRenderNode(child.get());
+ canvas.restore();
+ });
RenderNodeTestCanvas canvas;
RenderNodeDrawable drawable(parent.get(), &canvas, true);
@@ -943,7 +980,6 @@
EXPECT_EQ(2, canvas.mDrawCounter);
}
-
TEST(ReorderBarrierDrawable, testShadowMatrix) {
static const int CANVAS_WIDTH = 100;
static const int CANVAS_HEIGHT = 100;
@@ -954,7 +990,6 @@
static const float CASTER_WIDTH = 20.0f;
static const float CASTER_HEIGHT = 20.0f;
-
class ShadowTestCanvas : public SkCanvas {
public:
ShadowTestCanvas(int width, int height) : SkCanvas(width, height) {}
@@ -978,30 +1013,32 @@
// matrix.
mDrawCounter++;
EXPECT_EQ(SkMatrix::MakeTrans(CASTER_X, CASTER_Y), matrix);
- EXPECT_EQ(SkMatrix::MakeTrans(CASTER_X+TRANSLATE_X, CASTER_Y+TRANSLATE_Y),
- getTotalMatrix());
+ EXPECT_EQ(SkMatrix::MakeTrans(CASTER_X + TRANSLATE_X, CASTER_Y + TRANSLATE_Y),
+ getTotalMatrix());
}
+
protected:
int mDrawCounter = 0;
};
- auto parent = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ auto parent = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.translate(TRANSLATE_X, TRANSLATE_Y);
- canvas.insertReorderBarrier(true);
+ canvas.translate(TRANSLATE_X, TRANSLATE_Y);
+ canvas.insertReorderBarrier(true);
- auto node = TestUtils::createSkiaNode(CASTER_X, CASTER_Y, CASTER_X + CASTER_WIDTH,
- CASTER_Y + CASTER_HEIGHT,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- props.setElevation(42);
- props.mutableOutline().setRoundRect(0, 0, 20, 20, 5, 1);
- props.mutableOutline().setShouldClip(true);
- });
- canvas.drawRenderNode(node.get());
- canvas.insertReorderBarrier(false);
- });
+ auto node = TestUtils::createSkiaNode(
+ CASTER_X, CASTER_Y, CASTER_X + CASTER_WIDTH, CASTER_Y + CASTER_HEIGHT,
+ [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ props.setElevation(42);
+ props.mutableOutline().setRoundRect(0, 0, 20, 20, 5, 1);
+ props.mutableOutline().setShouldClip(true);
+ });
+ canvas.drawRenderNode(node.get());
+ canvas.insertReorderBarrier(false);
+ });
- //create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
+ // create a canvas not backed by any device/pixels, but with dimensions to avoid quick rejection
ShadowTestCanvas canvas(CANVAS_WIDTH, CANVAS_HEIGHT);
RenderNodeDrawable drawable(parent.get(), &canvas, false);
canvas.drawDrawable(&drawable);
diff --git a/libs/hwui/tests/unit/RenderNodeTests.cpp b/libs/hwui/tests/unit/RenderNodeTests.cpp
index eda4a9d..0795208 100644
--- a/libs/hwui/tests/unit/RenderNodeTests.cpp
+++ b/libs/hwui/tests/unit/RenderNodeTests.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <VectorDrawable.h>
+#include <gtest/gtest.h>
#include "AnimationContext.h"
#include "DamageAccumulator.h"
@@ -32,21 +32,20 @@
class ContextFactory : public android::uirenderer::IContextFactory {
public:
- android::uirenderer::AnimationContext* createAnimationContext
- (android::uirenderer::renderthread::TimeLord& clock) override {
+ android::uirenderer::AnimationContext* createAnimationContext(
+ android::uirenderer::renderthread::TimeLord& clock) override {
return new android::uirenderer::AnimationContext(clock);
}
};
TEST(RenderNode, hasParents) {
- auto child = TestUtils::createNode(0, 0, 200, 400,
- [](RenderProperties& props, Canvas& canvas) {
+ auto child = TestUtils::createNode(0, 0, 200, 400, [](RenderProperties& props, Canvas& canvas) {
canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
});
auto parent = TestUtils::createNode(0, 0, 200, 400,
- [&child](RenderProperties& props, Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ [&child](RenderProperties& props, Canvas& canvas) {
+ canvas.drawRenderNode(child.get());
+ });
TestUtils::syncHierarchyPropertiesAndDisplayList(parent);
@@ -67,14 +66,13 @@
}
TEST(RenderNode, validity) {
- auto child = TestUtils::createNode(0, 0, 200, 400,
- [](RenderProperties& props, Canvas& canvas) {
+ auto child = TestUtils::createNode(0, 0, 200, 400, [](RenderProperties& props, Canvas& canvas) {
canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
});
auto parent = TestUtils::createNode(0, 0, 200, 400,
- [&child](RenderProperties& props, Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ [&child](RenderProperties& props, Canvas& canvas) {
+ canvas.drawRenderNode(child.get());
+ });
EXPECT_TRUE(child->isValid());
EXPECT_TRUE(parent->isValid());
@@ -111,9 +109,8 @@
EXPECT_TRUE(child->isValid());
EXPECT_TRUE(child->nothingToDraw());
- TestUtils::recordNode(*parent, [&child](Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ TestUtils::recordNode(*parent,
+ [&child](Canvas& canvas) { canvas.drawRenderNode(child.get()); });
TestUtils::syncHierarchyPropertiesAndDisplayList(parent);
@@ -131,18 +128,17 @@
}
TEST(RenderNode, multiTreeValidity) {
- auto child = TestUtils::createNode(0, 0, 200, 400,
- [](RenderProperties& props, Canvas& canvas) {
+ auto child = TestUtils::createNode(0, 0, 200, 400, [](RenderProperties& props, Canvas& canvas) {
canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
});
auto parent1 = TestUtils::createNode(0, 0, 200, 400,
- [&child](RenderProperties& props, Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ [&child](RenderProperties& props, Canvas& canvas) {
+ canvas.drawRenderNode(child.get());
+ });
auto parent2 = TestUtils::createNode(0, 0, 200, 400,
- [&child](RenderProperties& props, Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ [&child](RenderProperties& props, Canvas& canvas) {
+ canvas.drawRenderNode(child.get());
+ });
EXPECT_TRUE(child->isValid());
EXPECT_TRUE(parent1->isValid());
@@ -200,14 +196,12 @@
});
TestUtils::syncHierarchyPropertiesAndDisplayList(child);
- TestUtils::recordNode(*parent1, [&child](Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ TestUtils::recordNode(*parent1,
+ [&child](Canvas& canvas) { canvas.drawRenderNode(child.get()); });
TestUtils::syncHierarchyPropertiesAndDisplayList(parent1);
- TestUtils::recordNode(*parent2, [&child](Canvas& canvas) {
- canvas.drawRenderNode(child.get());
- });
+ TestUtils::recordNode(*parent2,
+ [&child](Canvas& canvas) { canvas.drawRenderNode(child.get()); });
TestUtils::syncHierarchyPropertiesAndDisplayList(parent2);
EXPECT_TRUE(child->isValid());
@@ -240,9 +234,8 @@
class DecRefOnReleased : public GlFunctorLifecycleListener {
public:
explicit DecRefOnReleased(int* refcnt) : mRefCnt(refcnt) {}
- void onGlFunctorReleased(Functor* functor) override {
- *mRefCnt -= 1;
- }
+ void onGlFunctorReleased(Functor* functor) override { *mRefCnt -= 1; }
+
private:
int* mRefCnt;
};
@@ -251,8 +244,7 @@
sp<DecRefOnReleased> listener(new DecRefOnReleased(&refcnt));
Functor noopFunctor;
- auto node = TestUtils::createNode(0, 0, 200, 400,
- [&](RenderProperties& props, Canvas& canvas) {
+ auto node = TestUtils::createNode(0, 0, 200, 400, [&](RenderProperties& props, Canvas& canvas) {
refcnt++;
canvas.callDrawGLFunction(&noopFunctor, listener.get());
});
@@ -277,17 +269,17 @@
RENDERTHREAD_TEST(RenderNode, prepareTree_nullableDisplayList) {
auto rootNode = TestUtils::createNode(0, 0, 200, 400, nullptr);
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, rootNode.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, rootNode.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;
{
- auto nonNullDLNode = TestUtils::createNode(0, 0, 200, 400,
- [](RenderProperties& props, Canvas& canvas) {
- canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
- });
+ auto nonNullDLNode =
+ TestUtils::createNode(0, 0, 200, 400, [](RenderProperties& props, Canvas& canvas) {
+ canvas.drawColor(Color::Red_500, SkBlendMode::kSrcOver);
+ });
TestUtils::syncHierarchyPropertiesAndDisplayList(nonNullDLNode);
EXPECT_TRUE(nonNullDLNode->getDisplayList());
nonNullDLNode->prepareTree(info);
@@ -304,17 +296,16 @@
}
RENDERTHREAD_TEST(RenderNode, prepareTree_HwLayer_AVD_enqueueDamage) {
-
VectorDrawable::Group* group = new VectorDrawable::Group();
sp<VectorDrawableRoot> vectorDrawable(new VectorDrawableRoot(group));
- auto rootNode = TestUtils::createNode(0, 0, 200, 400,
- [&](RenderProperties& props, Canvas& canvas) {
- canvas.drawVectorDrawable(vectorDrawable.get());
- });
+ auto rootNode =
+ TestUtils::createNode(0, 0, 200, 400, [&](RenderProperties& props, Canvas& canvas) {
+ canvas.drawVectorDrawable(vectorDrawable.get());
+ });
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, rootNode.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, rootNode.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_RT_ONLY, *canvasContext.get());
DamageAccumulator damageAccumulator;
LayerUpdateQueue layerUpdateQueue;
diff --git a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
index 85b12ba..bc742b0 100644
--- a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
+++ b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
@@ -16,13 +16,13 @@
#include "tests/common/TestUtils.h"
-#include <gtest/gtest.h>
#include <SkBlurDrawLooper.h>
#include <SkColorMatrixFilter.h>
#include <SkColorSpace.h>
#include <SkImagePriv.h>
#include <SkPathOps.h>
#include <SkShader.h>
+#include <gtest/gtest.h>
using namespace android;
using namespace android::uirenderer;
@@ -42,15 +42,13 @@
TEST(SkiaBehavior, CreateBitmapShader1x1) {
SkBitmap origBitmap = createSkBitmap(1, 1);
sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(origBitmap, kNever_SkCopyPixelsMode);
- sk_sp<SkShader> s = image->makeShader(
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- nullptr);
+ sk_sp<SkShader> s =
+ image->makeShader(SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, nullptr);
SkBitmap bitmap;
SkShader::TileMode xy[2];
ASSERT_TRUE(s->isABitmap(&bitmap, nullptr, xy))
- << "1x1 bitmap shader must query as bitmap shader";
+ << "1x1 bitmap shader must query as bitmap shader";
EXPECT_EQ(origBitmap.pixelRef(), bitmap.pixelRef());
}
@@ -63,8 +61,7 @@
TEST(SkiaBehavior, lightingColorFilter_simplify) {
{
- sk_sp<SkColorFilter> filter(
- SkColorMatrixFilter::MakeLightingFilter(0x11223344, 0));
+ sk_sp<SkColorFilter> filter(SkColorMatrixFilter::MakeLightingFilter(0x11223344, 0));
SkColor observedColor;
SkBlendMode observedMode;
@@ -74,8 +71,7 @@
}
{
- sk_sp<SkColorFilter> failFilter(
- SkColorMatrixFilter::MakeLightingFilter(0x11223344, 0x1));
+ sk_sp<SkColorFilter> failFilter(SkColorMatrixFilter::MakeLightingFilter(0x11223344, 0x1));
EXPECT_FALSE(failFilter->asColorMode(nullptr, nullptr));
}
}
diff --git a/libs/hwui/tests/unit/SkiaCanvasTests.cpp b/libs/hwui/tests/unit/SkiaCanvasTests.cpp
index d84b83d..4138f59 100644
--- a/libs/hwui/tests/unit/SkiaCanvasTests.cpp
+++ b/libs/hwui/tests/unit/SkiaCanvasTests.cpp
@@ -16,12 +16,12 @@
#include "tests/common/TestUtils.h"
-#include <gtest/gtest.h>
#include <RecordingCanvas.h>
#include <SkBlurDrawLooper.h>
#include <SkCanvasStateUtils.h>
#include <SkPicture.h>
#include <SkPictureRecorder.h>
+#include <gtest/gtest.h>
using namespace android;
using namespace android::uirenderer;
@@ -88,7 +88,7 @@
sk_sp<Bitmap> adobeBitmap = Bitmap::allocateHeapBitmap(adobeInfo);
SkBitmap adobeSkBitmap;
adobeBitmap->getSkBitmap(&adobeSkBitmap);
- *adobeSkBitmap.getAddr32(0, 0) = 0xFF0000F0; // Opaque, almost fully-red
+ *adobeSkBitmap.getAddr32(0, 0) = 0xFF0000F0; // Opaque, almost fully-red
SkImageInfo info = adobeInfo.makeColorSpace(nullptr);
sk_sp<Bitmap> bitmap = Bitmap::allocateHeapBitmap(info);
diff --git a/libs/hwui/tests/unit/SkiaDisplayListTests.cpp b/libs/hwui/tests/unit/SkiaDisplayListTests.cpp
index dd8f4b4..88d6dcf 100644
--- a/libs/hwui/tests/unit/SkiaDisplayListTests.cpp
+++ b/libs/hwui/tests/unit/SkiaDisplayListTests.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <VectorDrawable.h>
+#include <gtest/gtest.h>
#include "AnimationContext.h"
#include "DamageAccumulator.h"
@@ -79,7 +79,7 @@
// detach the list that you just attempted to reuse
availableList = renderNode->detachAvailableList();
ASSERT_EQ(availableList.get(), &skiaDL);
- availableList.release(); // prevents an invalid free since our DL is stack allocated
+ availableList.release(); // prevents an invalid free since our DL is stack allocated
// after detaching there should return no available list
availableList = renderNode->detachAvailableList();
@@ -115,8 +115,8 @@
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaDisplayList, prepareListAndChildren) {
auto rootNode = TestUtils::createNode(0, 0, 200, 400, nullptr);
ContextFactory contextFactory;
- std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
- renderThread, false, rootNode.get(), &contextFactory));
+ std::unique_ptr<CanvasContext> canvasContext(
+ CanvasContext::create(renderThread, false, rootNode.get(), &contextFactory));
TreeInfo info(TreeInfo::MODE_FULL, *canvasContext.get());
DamageAccumulator damageAccumulator;
info.damageAccumulator = &damageAccumulator;
@@ -126,13 +126,13 @@
// prepare with a clean VD
VectorDrawableRoot cleanVD(new VectorDrawable::Group());
skiaDL.mVectorDrawables.push_back(&cleanVD);
- cleanVD.getBitmapUpdateIfDirty(); // this clears the dirty bit
+ cleanVD.getBitmapUpdateIfDirty(); // this clears the dirty bit
ASSERT_FALSE(cleanVD.isDirty());
ASSERT_FALSE(cleanVD.getPropertyChangeWillBeConsumed());
TestUtils::MockTreeObserver observer;
ASSERT_FALSE(skiaDL.prepareListAndChildren(observer, info, false,
- [](RenderNode*, TreeObserver&, TreeInfo&, bool) {}));
+ [](RenderNode*, TreeObserver&, TreeInfo&, bool) {}));
ASSERT_TRUE(cleanVD.getPropertyChangeWillBeConsumed());
// prepare again this time adding a dirty VD
@@ -142,7 +142,7 @@
ASSERT_TRUE(dirtyVD.isDirty());
ASSERT_FALSE(dirtyVD.getPropertyChangeWillBeConsumed());
ASSERT_TRUE(skiaDL.prepareListAndChildren(observer, info, false,
- [](RenderNode*, TreeObserver&, TreeInfo&, bool) {}));
+ [](RenderNode*, TreeObserver&, TreeInfo&, bool) {}));
ASSERT_TRUE(dirtyVD.getPropertyChangeWillBeConsumed());
// prepare again this time adding a RenderNode and a callback
@@ -151,13 +151,15 @@
SkCanvas dummyCanvas;
skiaDL.mChildNodes.emplace_back(renderNode.get(), &dummyCanvas);
bool hasRun = false;
- ASSERT_TRUE(skiaDL.prepareListAndChildren(observer, info, false,
- [&hasRun, renderNode, infoPtr](RenderNode* n, TreeObserver& observer, TreeInfo& i, bool r) {
- hasRun = true;
- ASSERT_EQ(renderNode.get(), n);
- ASSERT_EQ(infoPtr, &i);
- ASSERT_FALSE(r);
- }));
+ ASSERT_TRUE(skiaDL.prepareListAndChildren(
+ observer, info, false,
+ [&hasRun, renderNode, infoPtr](RenderNode* n, TreeObserver& observer, TreeInfo& i,
+ bool r) {
+ hasRun = true;
+ ASSERT_EQ(renderNode.get(), n);
+ ASSERT_EQ(infoPtr, &i);
+ ASSERT_FALSE(r);
+ }));
ASSERT_TRUE(hasRun);
canvasContext->destroy();
@@ -169,7 +171,5 @@
sp<RenderNode> renderNode = new RenderNode();
SkCanvas dummyCanvas;
skiaDL.mChildNodes.emplace_back(renderNode.get(), &dummyCanvas);
- skiaDL.updateChildren([renderNode](RenderNode* n) {
- ASSERT_EQ(renderNode.get(), n);
- });
+ skiaDL.updateChildren([renderNode](RenderNode* n) { ASSERT_EQ(renderNode.get(), n); });
}
diff --git a/libs/hwui/tests/unit/SkiaPipelineTests.cpp b/libs/hwui/tests/unit/SkiaPipelineTests.cpp
index f430ce6..8fdb0e3 100644
--- a/libs/hwui/tests/unit/SkiaPipelineTests.cpp
+++ b/libs/hwui/tests/unit/SkiaPipelineTests.cpp
@@ -14,22 +14,22 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <VectorDrawable.h>
+#include <gtest/gtest.h>
-#include "AnimationContext.h"
-#include "DamageAccumulator.h"
-#include "IContextFactory.h"
-#include "pipeline/skia/SkiaDisplayList.h"
-#include "pipeline/skia/SkiaRecordingCanvas.h"
-#include "pipeline/skia/SkiaOpenGLPipeline.h"
-#include "renderthread/CanvasContext.h"
-#include "tests/common/TestUtils.h"
-#include "SkiaCanvas.h"
#include <SkClipStack.h>
#include <SkLiteRecorder.h>
#include <SkSurface_Base.h>
#include <string.h>
+#include "AnimationContext.h"
+#include "DamageAccumulator.h"
+#include "IContextFactory.h"
+#include "SkiaCanvas.h"
+#include "pipeline/skia/SkiaDisplayList.h"
+#include "pipeline/skia/SkiaOpenGLPipeline.h"
+#include "pipeline/skia/SkiaRecordingCanvas.h"
+#include "renderthread/CanvasContext.h"
+#include "tests/common/TestUtils.h"
using namespace android;
using namespace android::uirenderer;
@@ -37,10 +37,10 @@
using namespace android::uirenderer::skiapipeline;
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrame) {
- auto redNode = TestUtils::createSkiaNode(0, 0, 1, 1,
- [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
- redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
- });
+ auto redNode = TestUtils::createSkiaNode(
+ 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
+ redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
+ });
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeLargest();
std::vector<sp<RenderNode>> renderNodes;
@@ -51,17 +51,16 @@
auto surface = SkSurface::MakeRasterN32Premul(1, 1);
surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes,
- opaque, false, contentDrawBounds, surface);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorRED);
}
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, testOnPrepareTree) {
-
- auto redNode = TestUtils::createSkiaNode(0, 0, 1, 1,
- [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
- redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
- });
+ auto redNode = TestUtils::createSkiaNode(
+ 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
+ redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
+ });
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeLargest();
@@ -71,33 +70,33 @@
android::uirenderer::Rect contentDrawBounds(0, 0, 1, 1);
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
{
- //add a pointer to a deleted vector drawable object in the pipeline
+ // add a pointer to a deleted vector drawable object in the pipeline
sp<VectorDrawableRoot> dirtyVD(new VectorDrawableRoot(new VectorDrawable::Group()));
- dirtyVD->mutateProperties()->setScaledSize(5,5);
+ dirtyVD->mutateProperties()->setScaledSize(5, 5);
pipeline->getVectorDrawables()->push_back(dirtyVD.get());
}
- //pipeline should clean list of dirty vector drawables before prepare tree
+ // pipeline should clean list of dirty vector drawables before prepare tree
pipeline->onPrepareTree();
auto surface = SkSurface::MakeRasterN32Premul(1, 1);
surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
- //drawFrame will crash if "SkiaPipeline::onPrepareTree" did not clean invalid VD pointer
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes,
- opaque, false, contentDrawBounds, surface);
+ // drawFrame will crash if "SkiaPipeline::onPrepareTree" did not clean invalid VD pointer
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorRED);
}
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrameCheckOpaque) {
- auto halfGreenNode = TestUtils::createSkiaNode(0, 0, 2, 2,
- [](RenderProperties& props, SkiaRecordingCanvas& bottomHalfGreenCanvas) {
- SkPaint greenPaint;
- greenPaint.setColor(SK_ColorGREEN);
- greenPaint.setStyle(SkPaint::kFill_Style);
- bottomHalfGreenCanvas.drawRect(0, 1, 2, 2, greenPaint);
- });
+ auto halfGreenNode = TestUtils::createSkiaNode(
+ 0, 0, 2, 2, [](RenderProperties& props, SkiaRecordingCanvas& bottomHalfGreenCanvas) {
+ SkPaint greenPaint;
+ greenPaint.setColor(SK_ColorGREEN);
+ greenPaint.setStyle(SkPaint::kFill_Style);
+ bottomHalfGreenCanvas.drawRect(0, 1, 2, 2, greenPaint);
+ });
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeLargest();
std::vector<sp<RenderNode>> renderNodes;
@@ -107,21 +106,21 @@
auto surface = SkSurface::MakeRasterN32Premul(2, 2);
surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes,
- true, false, contentDrawBounds, surface);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, true, false, contentDrawBounds,
+ surface);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
ASSERT_EQ(TestUtils::getColor(surface, 0, 1), SK_ColorGREEN);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes,
- false, false, contentDrawBounds, surface);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, false, false, contentDrawBounds,
+ surface);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned int)SK_ColorTRANSPARENT);
ASSERT_EQ(TestUtils::getColor(surface, 0, 1), SK_ColorGREEN);
}
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrameCheckDirtyRect) {
- auto redNode = TestUtils::createSkiaNode(0, 0, 2, 2,
- [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
- redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
- });
+ auto redNode = TestUtils::createSkiaNode(
+ 0, 0, 2, 2, [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
+ redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
+ });
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeXYWH(0, 1, 2, 1);
std::vector<sp<RenderNode>> renderNodes;
@@ -131,8 +130,8 @@
auto surface = SkSurface::MakeRasterN32Premul(2, 2);
surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes,
- true, false, contentDrawBounds, surface);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, true, false, contentDrawBounds,
+ surface);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
ASSERT_EQ(TestUtils::getColor(surface, 1, 0), SK_ColorBLUE);
ASSERT_EQ(TestUtils::getColor(surface, 0, 1), SK_ColorRED);
@@ -140,27 +139,27 @@
}
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderLayer) {
- auto redNode = TestUtils::createSkiaNode(0, 0, 1, 1,
- [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
- redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
- });
+ auto redNode = TestUtils::createSkiaNode(
+ 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
+ redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
+ });
auto surfaceLayer1 = SkSurface::MakeRasterN32Premul(1, 1);
surfaceLayer1->getCanvas()->drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surfaceLayer1, 0, 0), SK_ColorWHITE);
redNode->setLayerSurface(surfaceLayer1);
- //create a 2nd 2x2 layer and add it to the queue as well.
- //make the layer's dirty area one half of the layer and verify only the dirty half is updated.
- auto blueNode = TestUtils::createSkiaNode(0, 0, 2, 2,
- [](RenderProperties& props, SkiaRecordingCanvas& blueCanvas) {
- blueCanvas.drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
- });
+ // create a 2nd 2x2 layer and add it to the queue as well.
+ // make the layer's dirty area one half of the layer and verify only the dirty half is updated.
+ auto blueNode = TestUtils::createSkiaNode(
+ 0, 0, 2, 2, [](RenderProperties& props, SkiaRecordingCanvas& blueCanvas) {
+ blueCanvas.drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver);
+ });
auto surfaceLayer2 = SkSurface::MakeRasterN32Premul(2, 2);
surfaceLayer2->getCanvas()->drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
ASSERT_EQ(TestUtils::getColor(surfaceLayer2, 0, 0), SK_ColorWHITE);
blueNode->setLayerSurface(surfaceLayer2);
- //attach both layers to the update queue
+ // attach both layers to the update queue
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeLargest();
layerUpdateQueue.enqueueLayerWithDamage(redNode.get(), dirty);
@@ -170,7 +169,7 @@
bool opaque = true;
FrameBuilder::LightGeometry lightGeometry;
lightGeometry.radius = 1.0f;
- lightGeometry.center = { 0.0f, 0.0f, 0.0f };
+ lightGeometry.center = {0.0f, 0.0f, 0.0f};
BakedOpRenderer::LightInfo lightInfo;
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
pipeline->renderLayers(lightGeometry, &layerUpdateQueue, opaque, false, lightInfo);
@@ -185,16 +184,16 @@
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderOverdraw) {
ScopedProperty<bool> prop(Properties::debugOverdraw, true);
- auto whiteNode = TestUtils::createSkiaNode(0, 0, 1, 1,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- });
+ auto whiteNode = TestUtils::createSkiaNode(
+ 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ });
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeXYWH(0, 0, 1, 1);
std::vector<sp<RenderNode>> renderNodes;
renderNodes.push_back(whiteNode);
bool opaque = true;
- //empty contentDrawBounds is avoiding backdrop/content logic, which would lead to less overdraw
+ // empty contentDrawBounds is avoiding backdrop/content logic, which would lead to less overdraw
android::uirenderer::Rect contentDrawBounds(0, 0, 0, 0);
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
auto surface = SkSurface::MakeRasterN32Premul(1, 1);
@@ -204,39 +203,39 @@
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE);
// Single draw, should be white.
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque,
- false, contentDrawBounds, surface);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorWHITE);
// 1 Overdraw, should be blue blended onto white.
renderNodes.push_back(whiteNode);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque,
- false, contentDrawBounds, surface);
- ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned) 0xffd0d0ff);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
+ ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned)0xffd0d0ff);
// 2 Overdraw, should be green blended onto white
renderNodes.push_back(whiteNode);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque,
- false, contentDrawBounds, surface);
- ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned) 0xffd0ffd0);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
+ ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned)0xffd0ffd0);
// 3 Overdraw, should be pink blended onto white.
renderNodes.push_back(whiteNode);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque,
- false, contentDrawBounds, surface);
- ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned) 0xffffc0c0);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
+ ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned)0xffffc0c0);
// 4 Overdraw, should be red blended onto white.
renderNodes.push_back(whiteNode);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque,
- false, contentDrawBounds, surface);
- ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned) 0xffff8080);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
+ ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned)0xffff8080);
// 5 Overdraw, should be red blended onto white.
renderNodes.push_back(whiteNode);
- pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque,
- false, contentDrawBounds, surface);
- ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned) 0xffff8080);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, false, contentDrawBounds,
+ surface);
+ ASSERT_EQ(TestUtils::getColor(surface, 0, 0), (unsigned)0xffff8080);
}
namespace {
@@ -246,15 +245,9 @@
DeferLayer() : SkSurface_Base(T().imageInfo(), nullptr) {}
virtual ~DeferLayer() {}
- SkCanvas* onNewCanvas() override {
- return new T();
- }
- sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override {
- return nullptr;
- }
- sk_sp<SkImage> onNewImageSnapshot() override {
- return nullptr;
- }
+ SkCanvas* onNewCanvas() override { return new T(); }
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override { return nullptr; }
+ sk_sp<SkImage> onNewImageSnapshot() override { return nullptr; }
T* canvas() { return static_cast<T*>(getCanvas()); }
void onCopyOnWrite(ContentChangeMode) override {}
};
@@ -267,28 +260,28 @@
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
SkMatrix expected;
switch (mDrawCounter++) {
- case 0:
- // background - left side
- EXPECT_EQ(SkRect::MakeLTRB(600, 100, 700, 500), TestUtils::getClipBounds(this));
- expected.setTranslate(100, 100);
- break;
- case 1:
- // background - top side
- EXPECT_EQ(SkRect::MakeLTRB(100, 400, 600, 500), TestUtils::getClipBounds(this));
- expected.setTranslate(100, 100);
- break;
- case 2:
- // content
- EXPECT_EQ(SkRect::MakeLTRB(100, 100, 700, 500), TestUtils::getClipBounds(this));
- expected.setTranslate(-50, -50);
- break;
- case 3:
- // overlay
- EXPECT_EQ(SkRect::MakeLTRB(0, 0, 800, 600), TestUtils::getClipBounds(this));
- expected.reset();
- break;
- default:
- ADD_FAILURE() << "Too many rects observed";
+ case 0:
+ // background - left side
+ EXPECT_EQ(SkRect::MakeLTRB(600, 100, 700, 500), TestUtils::getClipBounds(this));
+ expected.setTranslate(100, 100);
+ break;
+ case 1:
+ // background - top side
+ EXPECT_EQ(SkRect::MakeLTRB(100, 400, 600, 500), TestUtils::getClipBounds(this));
+ expected.setTranslate(100, 100);
+ break;
+ case 2:
+ // content
+ EXPECT_EQ(SkRect::MakeLTRB(100, 100, 700, 500), TestUtils::getClipBounds(this));
+ expected.setTranslate(-50, -50);
+ break;
+ case 3:
+ // overlay
+ EXPECT_EQ(SkRect::MakeLTRB(0, 0, 800, 600), TestUtils::getClipBounds(this));
+ expected.reset();
+ break;
+ default:
+ ADD_FAILURE() << "Too many rects observed";
}
EXPECT_EQ(expected, getTotalMatrix());
}
@@ -300,23 +293,26 @@
transparentPaint.setAlpha(128);
// backdrop
- nodes.push_back(TestUtils::createSkiaNode(100, 100, 700, 500, // 600x400
+ nodes.push_back(TestUtils::createSkiaNode(
+ 100, 100, 700, 500, // 600x400
[&transparentPaint](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 600, 400, transparentPaint);
- }));
+ canvas.drawRect(0, 0, 600, 400, transparentPaint);
+ }));
// content
- android::uirenderer::Rect contentDrawBounds(150, 150, 650, 450); // 500x300
- nodes.push_back(TestUtils::createSkiaNode(0, 0, 800, 600,
+ android::uirenderer::Rect contentDrawBounds(150, 150, 650, 450); // 500x300
+ nodes.push_back(TestUtils::createSkiaNode(
+ 0, 0, 800, 600,
[&transparentPaint](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 800, 600, transparentPaint);
- }));
+ canvas.drawRect(0, 0, 800, 600, transparentPaint);
+ }));
// overlay
- nodes.push_back(TestUtils::createSkiaNode(0, 0, 800, 600,
+ nodes.push_back(TestUtils::createSkiaNode(
+ 0, 0, 800, 600,
[&transparentPaint](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.drawRect(0, 0, 800, 200, transparentPaint);
- }));
+ canvas.drawRect(0, 0, 800, 200, transparentPaint);
+ }));
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeWH(800, 600);
@@ -331,8 +327,7 @@
static const int CANVAS_HEIGHT = 200;
class ClippedTestCanvas : public SkCanvas {
public:
- ClippedTestCanvas() : SkCanvas(CANVAS_WIDTH, CANVAS_HEIGHT) {
- }
+ ClippedTestCanvas() : SkCanvas(CANVAS_WIDTH, CANVAS_HEIGHT) {}
void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*) override {
EXPECT_EQ(0, mDrawCounter++);
EXPECT_EQ(SkRect::MakeLTRB(10, 20, 30, 40), TestUtils::getClipBounds(this));
@@ -342,18 +337,19 @@
};
std::vector<sp<RenderNode>> nodes;
- nodes.push_back(TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ nodes.push_back(TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- sk_sp<Bitmap> bitmap(TestUtils::createBitmap(CANVAS_WIDTH, CANVAS_HEIGHT));
- canvas.drawBitmap(*bitmap, 0, 0, nullptr);
- }));
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(CANVAS_WIDTH, CANVAS_HEIGHT));
+ canvas.drawBitmap(*bitmap, 0, 0, nullptr);
+ }));
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeLTRB(10, 20, 30, 40);
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
sk_sp<DeferLayer<ClippedTestCanvas>> surface(new DeferLayer<ClippedTestCanvas>());
pipeline->renderFrame(layerUpdateQueue, dirty, nodes, true, false,
- SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface);
+ SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface);
EXPECT_EQ(1, surface->canvas()->mDrawCounter);
}
@@ -362,8 +358,7 @@
static const int CANVAS_HEIGHT = 50;
class ClipReplaceTestCanvas : public SkCanvas {
public:
- ClipReplaceTestCanvas() : SkCanvas(CANVAS_WIDTH, CANVAS_HEIGHT) {
- }
+ ClipReplaceTestCanvas() : SkCanvas(CANVAS_WIDTH, CANVAS_HEIGHT) {}
void onDrawPaint(const SkPaint&) {
EXPECT_EQ(0, mDrawCounter++);
EXPECT_EQ(SkRect::MakeLTRB(20, 10, 30, 40), TestUtils::getClipBounds(this))
@@ -373,17 +368,17 @@
};
std::vector<sp<RenderNode>> nodes;
- nodes.push_back(TestUtils::createSkiaNode(20, 20, 30, 30,
- [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- canvas.clipRect(0, -20, 10, 30, SkClipOp::kReplace_deprecated);
- canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
- }));
+ nodes.push_back(TestUtils::createSkiaNode(
+ 20, 20, 30, 30, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
+ canvas.clipRect(0, -20, 10, 30, SkClipOp::kReplace_deprecated);
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver);
+ }));
LayerUpdateQueue layerUpdateQueue;
SkRect dirty = SkRect::MakeLTRB(10, 10, 40, 40);
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
sk_sp<DeferLayer<ClipReplaceTestCanvas>> surface(new DeferLayer<ClipReplaceTestCanvas>());
pipeline->renderFrame(layerUpdateQueue, dirty, nodes, true, false,
- SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface);
+ SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface);
EXPECT_EQ(1, surface->canvas()->mDrawCounter);
}
diff --git a/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp b/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp
index 95c6ed6..ad5fdac 100644
--- a/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp
+++ b/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp
@@ -14,23 +14,23 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
#include <VectorDrawable.h>
+#include <gtest/gtest.h>
+#include <SkClipStack.h>
+#include <SkLiteRecorder.h>
+#include <SkSurface_Base.h>
+#include <string.h>
#include "AnimationContext.h"
#include "DamageAccumulator.h"
+#include "FatalTestCanvas.h"
#include "IContextFactory.h"
+#include "SkiaCanvas.h"
#include "pipeline/skia/SkiaDisplayList.h"
#include "pipeline/skia/SkiaPipeline.h"
#include "pipeline/skia/SkiaRecordingCanvas.h"
#include "renderthread/CanvasContext.h"
#include "tests/common/TestUtils.h"
-#include "SkiaCanvas.h"
-#include <SkSurface_Base.h>
-#include <SkLiteRecorder.h>
-#include <SkClipStack.h>
-#include "FatalTestCanvas.h"
-#include <string.h>
using namespace android;
using namespace android::uirenderer;
@@ -40,7 +40,7 @@
namespace {
static void testProperty(std::function<void(RenderProperties&)> propSetupCallback,
- std::function<void(const SkCanvas&)> opValidateCallback) {
+ std::function<void(const SkCanvas&)> opValidateCallback) {
static const int CANVAS_WIDTH = 100;
static const int CANVAS_HEIGHT = 100;
class PropertyTestCanvas : public TestCanvasBase {
@@ -57,79 +57,88 @@
std::function<void(const SkCanvas&)> mCallback;
};
- auto node = TestUtils::createSkiaNode(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
+ auto node = TestUtils::createSkiaNode(
+ 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[propSetupCallback](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- propSetupCallback(props);
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
- });
+ propSetupCallback(props);
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
+ });
PropertyTestCanvas canvas(opValidateCallback);
RenderNodeDrawable drawable(node.get(), &canvas, true);
canvas.drawDrawable(&drawable);
EXPECT_EQ(1, canvas.mDrawCounter);
}
-
}
TEST(RenderNodeDrawable, renderPropClipping) {
- testProperty([](RenderProperties& properties) {
- properties.setClipToBounds(true);
- properties.setClipBounds(android::uirenderer::Rect(10, 20, 300, 400));
- }, [](const SkCanvas& canvas) {
- EXPECT_EQ(SkRect::MakeLTRB(10, 20, 100, 100), TestUtils::getClipBounds(&canvas))
- << "Clip rect should be intersection of node bounds and clip bounds";
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.setClipToBounds(true);
+ properties.setClipBounds(android::uirenderer::Rect(10, 20, 300, 400));
+ },
+ [](const SkCanvas& canvas) {
+ EXPECT_EQ(SkRect::MakeLTRB(10, 20, 100, 100), TestUtils::getClipBounds(&canvas))
+ << "Clip rect should be intersection of node bounds and clip bounds";
+ });
}
TEST(RenderNodeDrawable, renderPropRevealClip) {
- testProperty([](RenderProperties& properties) {
- properties.mutableRevealClip().set(true, 50, 50, 25);
- }, [](const SkCanvas& canvas) {
- EXPECT_EQ(SkRect::MakeLTRB(25, 25, 75, 75), TestUtils::getClipBounds(&canvas));
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.mutableRevealClip().set(true, 50, 50, 25);
+ },
+ [](const SkCanvas& canvas) {
+ EXPECT_EQ(SkRect::MakeLTRB(25, 25, 75, 75), TestUtils::getClipBounds(&canvas));
+ });
}
TEST(RenderNodeDrawable, renderPropOutlineClip) {
- testProperty([](RenderProperties& properties) {
- properties.mutableOutline().setShouldClip(true);
- properties.mutableOutline().setRoundRect(10, 20, 30, 40, 5.0f, 0.5f);
- }, [](const SkCanvas& canvas) {
- EXPECT_EQ(SkRect::MakeLTRB(10, 20, 30, 40), TestUtils::getClipBounds(&canvas));
- });
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.mutableOutline().setShouldClip(true);
+ properties.mutableOutline().setRoundRect(10, 20, 30, 40, 5.0f, 0.5f);
+ },
+ [](const SkCanvas& canvas) {
+ EXPECT_EQ(SkRect::MakeLTRB(10, 20, 30, 40), TestUtils::getClipBounds(&canvas));
+ });
}
TEST(RenderNodeDrawable, renderPropTransform) {
- testProperty([](RenderProperties& properties) {
- properties.setLeftTopRightBottom(10, 10, 110, 110);
+ testProperty(
+ [](RenderProperties& properties) {
+ properties.setLeftTopRightBottom(10, 10, 110, 110);
- SkMatrix staticMatrix = SkMatrix::MakeScale(1.2f, 1.2f);
- properties.setStaticMatrix(&staticMatrix);
+ SkMatrix staticMatrix = SkMatrix::MakeScale(1.2f, 1.2f);
+ properties.setStaticMatrix(&staticMatrix);
- // ignored, since static overrides animation
- SkMatrix animationMatrix = SkMatrix::MakeTrans(15, 15);
- properties.setAnimationMatrix(&animationMatrix);
+ // ignored, since static overrides animation
+ SkMatrix animationMatrix = SkMatrix::MakeTrans(15, 15);
+ properties.setAnimationMatrix(&animationMatrix);
- properties.setTranslationX(10);
- properties.setTranslationY(20);
- properties.setScaleX(0.5f);
- properties.setScaleY(0.7f);
- }, [](const SkCanvas& canvas) {
- Matrix4 matrix;
- matrix.loadTranslate(10, 10, 0); // left, top
- matrix.scale(1.2f, 1.2f, 1); // static matrix
- // ignore animation matrix, since static overrides it
+ properties.setTranslationX(10);
+ properties.setTranslationY(20);
+ properties.setScaleX(0.5f);
+ properties.setScaleY(0.7f);
+ },
+ [](const SkCanvas& canvas) {
+ Matrix4 matrix;
+ matrix.loadTranslate(10, 10, 0); // left, top
+ matrix.scale(1.2f, 1.2f, 1); // static matrix
+ // ignore animation matrix, since static overrides it
- // translation xy
- matrix.translate(10, 20);
+ // translation xy
+ matrix.translate(10, 20);
- // scale xy (from default pivot - center)
- matrix.translate(50, 50);
- matrix.scale(0.5f, 0.7f, 1);
- matrix.translate(-50, -50);
- Matrix4 actual(canvas.getTotalMatrix());
- EXPECT_MATRIX_APPROX_EQ(matrix, actual)
- << "Op draw matrix must match expected combination of transformation properties";
- });
+ // scale xy (from default pivot - center)
+ matrix.translate(50, 50);
+ matrix.scale(0.5f, 0.7f, 1);
+ matrix.translate(-50, -50);
+ Matrix4 actual(canvas.getTotalMatrix());
+ EXPECT_MATRIX_APPROX_EQ(matrix, actual) << "Op draw matrix must match expected "
+ "combination of transformation "
+ "properties";
+ });
}
diff --git a/libs/hwui/tests/unit/SnapshotTests.cpp b/libs/hwui/tests/unit/SnapshotTests.cpp
index 11797a8..9d673c8 100644
--- a/libs/hwui/tests/unit/SnapshotTests.cpp
+++ b/libs/hwui/tests/unit/SnapshotTests.cpp
@@ -32,16 +32,16 @@
LinearAllocator allocator;
ClipRect rect(Rect(0, 0, 75, 75));
{
- auto intersectWithChild = child->serializeIntersectedClip(allocator,
- &rect, Matrix4::identity());
+ auto intersectWithChild =
+ child->serializeIntersectedClip(allocator, &rect, Matrix4::identity());
ASSERT_NE(nullptr, intersectWithChild);
EXPECT_EQ(Rect(50, 50, 75, 75), intersectWithChild->rect) << "Expect intersect with child";
}
rect.intersectWithRoot = true;
{
- auto intersectWithRoot = child->serializeIntersectedClip(allocator,
- &rect, Matrix4::identity());
+ auto intersectWithRoot =
+ child->serializeIntersectedClip(allocator, &rect, Matrix4::identity());
ASSERT_NE(nullptr, intersectWithRoot);
EXPECT_EQ(Rect(10, 10, 75, 75), intersectWithRoot->rect) << "Expect intersect with root";
}
diff --git a/libs/hwui/tests/unit/StringUtilsTests.cpp b/libs/hwui/tests/unit/StringUtilsTests.cpp
index b60e96c..04fbb51 100644
--- a/libs/hwui/tests/unit/StringUtilsTests.cpp
+++ b/libs/hwui/tests/unit/StringUtilsTests.cpp
@@ -34,7 +34,7 @@
auto collection = StringUtils::split("GL_ext1 GL_ext2 GL_ext3");
EXPECT_TRUE(collection.has("GL_ext1"));
- EXPECT_FALSE(collection.has("GL_ext")); // string present, but not in list
+ EXPECT_FALSE(collection.has("GL_ext")); // string present, but not in list
}
TEST(StringUtils, sizePrinter) {
diff --git a/libs/hwui/tests/unit/TestUtilsTests.cpp b/libs/hwui/tests/unit/TestUtilsTests.cpp
index 4905957..742fe42 100644
--- a/libs/hwui/tests/unit/TestUtilsTests.cpp
+++ b/libs/hwui/tests/unit/TestUtilsTests.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include "tests/common/TestUtils.h"
#include "Properties.h"
+#include "tests/common/TestUtils.h"
#include <gtest/gtest.h>
diff --git a/libs/hwui/tests/unit/TextDropShadowCacheTests.cpp b/libs/hwui/tests/unit/TextDropShadowCacheTests.cpp
index 8312bda..78d75d6 100644
--- a/libs/hwui/tests/unit/TextDropShadowCacheTests.cpp
+++ b/libs/hwui/tests/unit/TextDropShadowCacheTests.cpp
@@ -18,8 +18,8 @@
#include "GammaFontRenderer.h"
#include "TextDropShadowCache.h"
-#include "utils/Blur.h"
#include "tests/common/TestUtils.h"
+#include "utils/Blur.h"
#include <SkPaint.h>
@@ -40,15 +40,15 @@
std::vector<float> positions;
float totalAdvance;
uirenderer::Rect bounds;
- TestUtils::layoutTextUnscaled(paint, "This is a test",
- &glyphs, &positions, &totalAdvance, &bounds);
+ TestUtils::layoutTextUnscaled(paint, "This is a test", &glyphs, &positions, &totalAdvance,
+ &bounds);
EXPECT_TRUE(bounds.contains(5, -10, 100, 0)) << "Expect input to be nontrivially sized";
ShadowTexture* texture = cache.get(&paint, glyphs.data(), glyphs.size(), 10, positions.data());
ASSERT_TRUE(texture);
ASSERT_FALSE(texture->cleanup);
- ASSERT_EQ((uint32_t) texture->objectSize(), cache.getSize());
+ ASSERT_EQ((uint32_t)texture->objectSize(), cache.getSize());
ASSERT_TRUE(cache.getSize());
cache.clear();
ASSERT_EQ(cache.getSize(), 0u);
diff --git a/libs/hwui/tests/unit/ThreadBaseTests.cpp b/libs/hwui/tests/unit/ThreadBaseTests.cpp
index 7aad348..1168ff2 100644
--- a/libs/hwui/tests/unit/ThreadBaseTests.cpp
+++ b/libs/hwui/tests/unit/ThreadBaseTests.cpp
@@ -31,7 +31,8 @@
sp<TestThread> ret{new TestThread};
ret->start("TestThread");
return ret;
- }();
+ }
+ ();
return *thread;
}
@@ -41,9 +42,7 @@
TEST(ThreadBase, post) {
std::atomic_bool ran(false);
- queue().post([&ran]() {
- ran = true;
- });
+ queue().post([&ran]() { ran = true; });
for (int i = 0; !ran && i < 1000; i++) {
usleep(1);
}
@@ -55,9 +54,7 @@
std::promise<nsecs_t> ranAtPromise;
auto queuedAt = clock::now();
- queue().postDelayed(100_us, [&]() {
- ranAtPromise.set_value(clock::now());
- });
+ queue().postDelayed(100_us, [&]() { ranAtPromise.set_value(clock::now()); });
auto ranAt = ranAtPromise.get_future().get();
auto ranAfter = ranAt - queuedAt;
ASSERT_TRUE(ranAfter > 90_us) << "Ran after " << ns2us(ranAfter) << "us <= 90us";
@@ -80,15 +77,9 @@
pid_t thisTid = gettid();
pid_t thisPid = getpid();
- auto otherTid = queue().async([]() -> auto {
- return gettid();
- });
- auto otherPid = queue().async([]() -> auto {
- return getpid();
- });
- auto result = queue().async([]() -> auto {
- return 42;
- });
+ auto otherTid = queue().async([]() -> auto { return gettid(); });
+ auto otherPid = queue().async([]() -> auto { return getpid(); });
+ auto result = queue().async([]() -> auto { return 42; });
ASSERT_NE(thisTid, otherTid.get());
ASSERT_EQ(thisPid, otherPid.get());
@@ -104,9 +95,7 @@
};
struct Counter {
- Counter(EventCount* count) : mCount(count) {
- mCount->construct++;
- }
+ Counter(EventCount* count) : mCount(count) { mCount->construct++; }
Counter(const Counter& other) : mCount(other.mCount) {
if (mCount) mCount->copy++;
@@ -149,17 +138,13 @@
}
int lifecycleTestHelper(const sp<VirtualLightRefBase>& test) {
- return queue().runSync([t = test]() -> int {
- return t->getStrongCount();
- });
+ return queue().runSync([t = test]()->int { return t->getStrongCount(); });
}
TEST(ThreadBase, lifecycle) {
sp<VirtualLightRefBase> dummyObject{new VirtualLightRefBase};
ASSERT_EQ(1, dummyObject->getStrongCount());
- ASSERT_EQ(2, queue().runSync([dummyObject]() -> int {
- return dummyObject->getStrongCount();
- }));
+ ASSERT_EQ(2, queue().runSync([dummyObject]() -> int { return dummyObject->getStrongCount(); }));
ASSERT_EQ(1, dummyObject->getStrongCount());
ASSERT_EQ(2, lifecycleTestHelper(dummyObject));
ASSERT_EQ(1, dummyObject->getStrongCount());
diff --git a/libs/hwui/tests/unit/TypefaceTests.cpp b/libs/hwui/tests/unit/TypefaceTests.cpp
index 1f3eaef..aad1fd6 100644
--- a/libs/hwui/tests/unit/TypefaceTests.cpp
+++ b/libs/hwui/tests/unit/TypefaceTests.cpp
@@ -57,17 +57,16 @@
std::shared_ptr<minikin::MinikinFont> font = std::make_shared<MinikinFontSkia>(
std::move(typeface), data, st.st_size, 0, std::vector<minikin::FontVariation>());
return std::make_shared<minikin::FontFamily>(
- std::vector<minikin::Font>({ minikin::Font(std::move(font), minikin::FontStyle()) }));
+ std::vector<minikin::Font>({minikin::Font(std::move(font), minikin::FontStyle())}));
}
std::vector<std::shared_ptr<minikin::FontFamily>> makeSingleFamlyVector(const char* fileName) {
- return std::vector<std::shared_ptr<minikin::FontFamily>>({ buildFamily(fileName) });
+ return std::vector<std::shared_ptr<minikin::FontFamily>>({buildFamily(fileName)});
}
TEST(TypefaceTest, resolveDefault_and_setDefaultTest) {
- std::unique_ptr<Typeface> regular(
- Typeface::createFromFamilies(makeSingleFamlyVector(kRobotoRegular),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ std::unique_ptr<Typeface> regular(Typeface::createFromFamilies(
+ makeSingleFamlyVector(kRobotoRegular), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(regular.get(), Typeface::resolveDefault(regular.get()));
// Keep the original to restore it later.
@@ -112,8 +111,7 @@
EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
// In Java, Typeface.create(Typeface.DEFAULT, Typeface.BOLD_ITALIC);
- std::unique_ptr<Typeface> boldItalic(
- Typeface::createRelative(nullptr, Typeface::kBoldItalic));
+ std::unique_ptr<Typeface> boldItalic(Typeface::createRelative(nullptr, Typeface::kBoldItalic));
EXPECT_EQ(7, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
@@ -141,8 +139,8 @@
EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
// In Java, Typeface.create(Typeface.create("sans-serif-bold"), Typeface.BOLD_ITALIC);
- std::unique_ptr<Typeface>
- boldItalic(Typeface::createRelative(base.get(), Typeface::kBoldItalic));
+ std::unique_ptr<Typeface> boldItalic(
+ Typeface::createRelative(base.get(), Typeface::kBoldItalic));
EXPECT_EQ(10, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
@@ -170,8 +168,8 @@
EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
// In Java, Typeface.create(Typeface.create("sans-serif-light"), Typeface.BOLD_ITALIC);
- std::unique_ptr<Typeface>
- boldItalic(Typeface::createRelative(base.get(), Typeface::kBoldItalic));
+ std::unique_ptr<Typeface> boldItalic(
+ Typeface::createRelative(base.get(), Typeface::kBoldItalic));
EXPECT_EQ(6, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
@@ -200,8 +198,8 @@
// In Java,
// Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.BOLD), Typeface.BOLD_ITALIC);
- std::unique_ptr<Typeface>
- boldItalic(Typeface::createRelative(base.get(), Typeface::kBoldItalic));
+ std::unique_ptr<Typeface> boldItalic(
+ Typeface::createRelative(base.get(), Typeface::kBoldItalic));
EXPECT_EQ(7, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
@@ -232,8 +230,8 @@
// In Java,
// Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC), Typeface.BOLD_ITALIC);
- std::unique_ptr<Typeface>
- boldItalic(Typeface::createRelative(base.get(), Typeface::kBoldItalic));
+ std::unique_ptr<Typeface> boldItalic(
+ Typeface::createRelative(base.get(), Typeface::kBoldItalic));
EXPECT_EQ(7, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
@@ -273,8 +271,8 @@
// Typeface typeface = new Typeface.Builder(invalid).setFallback("sans-serif")
// .setWeight(700).setItalic(false).build();
// Typeface.create(typeface, Typeface.BOLD_ITALIC);
- std::unique_ptr<Typeface>
- boldItalic(Typeface::createRelative(base.get(), Typeface::kBoldItalic));
+ std::unique_ptr<Typeface> boldItalic(
+ Typeface::createRelative(base.get(), Typeface::kBoldItalic));
EXPECT_EQ(7, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
@@ -363,25 +361,22 @@
TEST(TypefaceTest, createFromFamilies_Single_resolveByTable) {
// In Java, new Typeface.Builder("Roboto-Regular.ttf").build();
- std::unique_ptr<Typeface> regular(
- Typeface::createFromFamilies(makeSingleFamlyVector(kRobotoRegular),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ std::unique_ptr<Typeface> regular(Typeface::createFromFamilies(
+ makeSingleFamlyVector(kRobotoRegular), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(4, regular->fStyle.getWeight());
EXPECT_FALSE(regular->fStyle.getItalic());
EXPECT_EQ(Typeface::kNormal, regular->fAPIStyle);
// In Java, new Typeface.Builder("Roboto-Bold.ttf").build();
- std::unique_ptr<Typeface> bold(
- Typeface::createFromFamilies(makeSingleFamlyVector(kRobotoBold),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ std::unique_ptr<Typeface> bold(Typeface::createFromFamilies(
+ makeSingleFamlyVector(kRobotoBold), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(7, bold->fStyle.getWeight());
EXPECT_FALSE(bold->fStyle.getItalic());
EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
// In Java, new Typeface.Builder("Roboto-Italic.ttf").build();
- std::unique_ptr<Typeface> italic(
- Typeface::createFromFamilies(makeSingleFamlyVector(kRobotoItalic),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ std::unique_ptr<Typeface> italic(Typeface::createFromFamilies(
+ makeSingleFamlyVector(kRobotoItalic), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(4, italic->fStyle.getWeight());
EXPECT_TRUE(italic->fStyle.getItalic());
EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
@@ -389,7 +384,7 @@
// In Java, new Typeface.Builder("Roboto-BoldItalic.ttf").build();
std::unique_ptr<Typeface> boldItalic(
Typeface::createFromFamilies(makeSingleFamlyVector(kRobotoBoldItalic),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(7, boldItalic->fStyle.getWeight());
EXPECT_TRUE(boldItalic->fStyle.getItalic());
EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
@@ -398,20 +393,18 @@
TEST(TypefaceTest, createFromFamilies_Family) {
std::vector<std::shared_ptr<minikin::FontFamily>> families = {
buildFamily(kRobotoRegular), buildFamily(kRobotoBold), buildFamily(kRobotoItalic),
- buildFamily(kRobotoBoldItalic)
- };
- std::unique_ptr<Typeface> typeface(Typeface::createFromFamilies(std::move(families),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ buildFamily(kRobotoBoldItalic)};
+ std::unique_ptr<Typeface> typeface(Typeface::createFromFamilies(
+ std::move(families), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(4, typeface->fStyle.getWeight());
EXPECT_FALSE(typeface->fStyle.getItalic());
}
TEST(TypefaceTest, createFromFamilies_Family_withoutRegular) {
std::vector<std::shared_ptr<minikin::FontFamily>> families = {
- buildFamily(kRobotoBold), buildFamily(kRobotoItalic), buildFamily(kRobotoBoldItalic)
- };
- std::unique_ptr<Typeface> typeface(Typeface::createFromFamilies(std::move(families),
- RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
+ buildFamily(kRobotoBold), buildFamily(kRobotoItalic), buildFamily(kRobotoBoldItalic)};
+ std::unique_ptr<Typeface> typeface(Typeface::createFromFamilies(
+ std::move(families), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE));
EXPECT_EQ(7, typeface->fStyle.getWeight());
EXPECT_FALSE(typeface->fStyle.getItalic());
}
diff --git a/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp b/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp
index 17f8176..0c95fdd 100644
--- a/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp
+++ b/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp
@@ -16,9 +16,9 @@
#include <gtest/gtest.h>
-#include "tests/common/TestUtils.h"
#include <GrRectanizer.h>
#include "pipeline/skia/VectorDrawableAtlas.h"
+#include "tests/common/TestUtils.h"
using namespace android;
using namespace android::uirenderer;
@@ -26,16 +26,16 @@
using namespace android::uirenderer::skiapipeline;
RENDERTHREAD_SKIA_PIPELINE_TEST(VectorDrawableAtlas, addGetRemove) {
- VectorDrawableAtlas atlas(100*100);
+ VectorDrawableAtlas atlas(100 * 100);
atlas.prepareForDraw(renderThread.getGrContext());
- //create 150 rects 10x10, which won't fit in the atlas (atlas can fit no more than 100 rects)
+ // create 150 rects 10x10, which won't fit in the atlas (atlas can fit no more than 100 rects)
const int MAX_RECTS = 150;
AtlasEntry VDRects[MAX_RECTS];
sk_sp<SkSurface> atlasSurface;
- //check we are able to allocate new rects
- //check that rects in the atlas do not intersect
+ // check we are able to allocate new rects
+ // check that rects in the atlas do not intersect
for (uint32_t i = 0; i < MAX_RECTS; i++) {
VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
if (0 == i) {
@@ -45,7 +45,7 @@
ASSERT_TRUE(VDRects[i].surface.get() != nullptr);
ASSERT_TRUE(VDRects[i].rect.width() == 10 && VDRects[i].rect.height() == 10);
- //nothing in the atlas should intersect
+ // nothing in the atlas should intersect
if (atlasSurface.get() == VDRects[i].surface.get()) {
for (uint32_t j = 0; j < i; j++) {
if (atlasSurface.get() == VDRects[j].surface.get()) {
@@ -55,16 +55,16 @@
}
}
- //first 1/3 rects should all be in the same surface
- for (uint32_t i = 1; i < MAX_RECTS/3; i++) {
+ // first 1/3 rects should all be in the same surface
+ for (uint32_t i = 1; i < MAX_RECTS / 3; i++) {
ASSERT_NE(VDRects[i].key, VDRects[0].key);
ASSERT_EQ(VDRects[i].surface.get(), atlasSurface.get());
}
- //first rect is using atlas and last is a standalone surface
- ASSERT_NE(VDRects[0].surface.get(), VDRects[MAX_RECTS-1].surface.get());
+ // first rect is using atlas and last is a standalone surface
+ ASSERT_NE(VDRects[0].surface.get(), VDRects[MAX_RECTS - 1].surface.get());
- //check getEntry returns the same surfaces that we had created
+ // check getEntry returns the same surfaces that we had created
for (uint32_t i = 0; i < MAX_RECTS; i++) {
auto VDRect = atlas.getEntry(VDRects[i].key);
ASSERT_TRUE(VDRect.key != INVALID_ATLAS_KEY);
@@ -74,9 +74,9 @@
atlas.releaseEntry(VDRect.key);
}
- //check that any new rects will be allocated in the atlas, even that rectanizer is full.
- //rects in the atlas should not intersect.
- for (uint32_t i = 0; i < MAX_RECTS/3; i++) {
+ // check that any new rects will be allocated in the atlas, even that rectanizer is full.
+ // rects in the atlas should not intersect.
+ for (uint32_t i = 0; i < MAX_RECTS / 3; i++) {
VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
ASSERT_TRUE(VDRects[i].key != INVALID_ATLAS_KEY);
ASSERT_EQ(VDRects[i].surface.get(), atlasSurface.get());
@@ -87,25 +87,24 @@
}
}
-
RENDERTHREAD_SKIA_PIPELINE_TEST(VectorDrawableAtlas, disallowSharedSurface) {
- VectorDrawableAtlas atlas(100*100);
- //don't allow to use a shared surface
+ VectorDrawableAtlas atlas(100 * 100);
+ // don't allow to use a shared surface
atlas.setStorageMode(VectorDrawableAtlas::StorageMode::disallowSharedSurface);
atlas.prepareForDraw(renderThread.getGrContext());
- //create 150 rects 10x10, which won't fit in the atlas (atlas can fit no more than 100 rects)
+ // create 150 rects 10x10, which won't fit in the atlas (atlas can fit no more than 100 rects)
const int MAX_RECTS = 150;
AtlasEntry VDRects[MAX_RECTS];
- //check we are able to allocate new rects
- //check that rects in the atlas use unique surfaces
+ // check we are able to allocate new rects
+ // check that rects in the atlas use unique surfaces
for (uint32_t i = 0; i < MAX_RECTS; i++) {
VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
ASSERT_TRUE(VDRects[i].key != INVALID_ATLAS_KEY);
ASSERT_TRUE(VDRects[i].surface.get() != nullptr);
ASSERT_TRUE(VDRects[i].rect.width() == 10 && VDRects[i].rect.height() == 10);
- //nothing in the atlas should use the same surface
+ // nothing in the atlas should use the same surface
for (uint32_t j = 0; j < i; j++) {
ASSERT_NE(VDRects[i].surface.get(), VDRects[j].surface.get());
}
@@ -113,17 +112,17 @@
}
RENDERTHREAD_SKIA_PIPELINE_TEST(VectorDrawableAtlas, repack) {
- VectorDrawableAtlas atlas(100*100);
+ VectorDrawableAtlas atlas(100 * 100);
ASSERT_FALSE(atlas.isFragmented());
atlas.prepareForDraw(renderThread.getGrContext());
ASSERT_FALSE(atlas.isFragmented());
- //create 150 rects 10x10, which won't fit in the atlas (atlas can fit no more than 100 rects)
+ // create 150 rects 10x10, which won't fit in the atlas (atlas can fit no more than 100 rects)
const int MAX_RECTS = 150;
AtlasEntry VDRects[MAX_RECTS];
sk_sp<SkSurface> atlasSurface;
- //fill the atlas with check we are able to allocate new rects
+ // fill the atlas with check we are able to allocate new rects
for (uint32_t i = 0; i < MAX_RECTS; i++) {
VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
if (0 == i) {
@@ -134,13 +133,13 @@
ASSERT_FALSE(atlas.isFragmented());
- //first 1/3 rects should all be in the same surface
- for (uint32_t i = 1; i < MAX_RECTS/3; i++) {
+ // first 1/3 rects should all be in the same surface
+ for (uint32_t i = 1; i < MAX_RECTS / 3; i++) {
ASSERT_NE(VDRects[i].key, VDRects[0].key);
ASSERT_EQ(VDRects[i].surface.get(), atlasSurface.get());
}
- //release all entries
+ // release all entries
for (uint32_t i = 0; i < MAX_RECTS; i++) {
auto VDRect = atlas.getEntry(VDRects[i].key);
ASSERT_TRUE(VDRect.key != INVALID_ATLAS_KEY);
@@ -149,9 +148,9 @@
ASSERT_FALSE(atlas.isFragmented());
- //allocate 4x4 rects, which will fragment the atlas badly, because each entry occupies a 10x10
- //area
- for (uint32_t i = 0; i < 4*MAX_RECTS; i++) {
+ // allocate 4x4 rects, which will fragment the atlas badly, because each entry occupies a 10x10
+ // area
+ for (uint32_t i = 0; i < 4 * MAX_RECTS; i++) {
AtlasEntry entry = atlas.requestNewEntry(4, 4, renderThread.getGrContext());
ASSERT_TRUE(entry.key != INVALID_ATLAS_KEY);
}
diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp
index 1c21567..a92cbfd 100644
--- a/libs/hwui/tests/unit/VectorDrawableTests.cpp
+++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp
@@ -33,195 +33,239 @@
};
const static TestData sTestDataSet[] = {
- // TestData with scientific notation -2e3 etc.
- {
- // Path
- "M2.000000,22.000000l20.000000,0.000000 1e0-2e3z",
- {
- // Verbs
- {'M', 'l', 'z'},
- // Verb sizes
- {2, 4, 0},
- // Points
- {2, 22, 20, 0, 1, -2000},
- },
- [](SkPath* outPath) {
- outPath->moveTo(2, 22);
- outPath->rLineTo(20, 0);
- outPath->rLineTo(1, -2000);
- outPath->close();
- outPath->moveTo(2, 22);
- }
- },
+ // TestData with scientific notation -2e3 etc.
+ {// Path
+ "M2.000000,22.000000l20.000000,0.000000 1e0-2e3z",
+ {
+ // Verbs
+ {'M', 'l', 'z'},
+ // Verb sizes
+ {2, 4, 0},
+ // Points
+ {2, 22, 20, 0, 1, -2000},
+ },
+ [](SkPath* outPath) {
+ outPath->moveTo(2, 22);
+ outPath->rLineTo(20, 0);
+ outPath->rLineTo(1, -2000);
+ outPath->close();
+ outPath->moveTo(2, 22);
+ }},
- // Comprehensive data, containing all the verbs possible.
- {
- // Path
- "M 1 1 m 2 2, l 3 3 L 3 3 H 4 h4 V5 v5, Q6 6 6 6 q 6 6 6 6t 7 7 T 7 7 C 8 8 8 8 8 8 c 8 8 8 8 8 8 S 9 9 9 9 s 9 9 9 9 A 10 10 0 1 1 10 10 a 10 10 0 1 1 10 10",
- {
- // Verbs
- {'M', 'm', 'l', 'L', 'H', 'h', 'V', 'v', 'Q', 'q', 't', 'T', 'C', 'c', 'S', 's', 'A', 'a'},
- // VerbSizes
- {2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 2, 2, 6, 6, 4, 4, 7, 7},
- // Points
- {1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 7.0, 7.0, 7.0, 7.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 10.0, 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, }
- },
- [](SkPath* outPath) {
- outPath->moveTo(1.0, 1.0);
- outPath->rMoveTo(2.0, 2.0);
- outPath->rLineTo(3.0, 3.0);
- outPath->lineTo(3.0, 3.0);
- outPath->lineTo(4.0, 3.0);
- outPath->rLineTo(4.0, 0);
- outPath->lineTo(8.0, 5.0);
- outPath->rLineTo(0, 5.0);
- outPath->quadTo(6.0, 6.0, 6.0, 6.0);
- outPath->rQuadTo(6.0, 6.0, 6.0, 6.0);
- outPath->rQuadTo(0.0, 0.0, 7.0, 7.0);
- outPath->quadTo(26.0, 26.0, 7.0, 7.0);
- outPath->cubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0);
- outPath->rCubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0);
- outPath->cubicTo(16.0, 16.0, 9.0, 9.0, 9.0, 9.0);
- outPath->rCubicTo(0.0, 0.0, 9.0, 9.0, 9.0, 9.0);
- outPath->cubicTo(18.447775037328352, 20.404243860300607, 17.998389141249767, 22.8911717921705, 16.737515350332117, 24.986664170401575);
- outPath->cubicTo(15.476641559414468, 27.08215654863265, 13.489843598291483, 28.644011882390082, 11.155893964798905, 29.37447073281729);
- outPath->cubicTo(8.821944331306327, 30.1049295832445, 6.299226382436471, 29.954422532383525, 4.0686829203897235, 28.951642951534332);
- outPath->cubicTo(1.838139458342976, 27.94886337068514, 0.05113662931485696, 26.161860541657013, -0.9516429515343354, 23.931317079610267);
- outPath->cubicTo(-1.9544225323835278, 21.70077361756352, -2.1049295832444987, 19.178055668693663, -1.37447073281729, 16.844106035201087);
- outPath->cubicTo(-0.6440118823900814, 14.51015640170851, 0.9178434513673546, 12.523358440585524, 3.0133358295984305, 11.262484649667876);
- outPath->cubicTo(5.108828207829506, 10.001610858750228, 7.5957561396993984, 9.552224962671648, 10.000000000000005, 10.0);
- outPath->cubicTo(10.0, 7.348852265086975, 11.054287646850167, 4.803576729418881, 12.928932188134523, 2.9289321881345254);
- outPath->cubicTo(14.803576729418879, 1.0542876468501696, 17.348852265086972, 4.870079381441987E-16, 19.999999999999996, 0.0);
- outPath->cubicTo(22.65114773491302, -4.870079381441987E-16, 25.19642327058112, 1.0542876468501678, 27.071067811865476, 2.9289321881345227);
- outPath->cubicTo(28.94571235314983, 4.803576729418878, 30.0, 7.348852265086974, 30.0, 9.999999999999998);
- outPath->cubicTo(30.0, 12.651147734913023, 28.94571235314983, 15.19642327058112, 27.071067811865476, 17.071067811865476);
- outPath->cubicTo(25.19642327058112, 18.94571235314983, 22.651147734913028, 20.0, 20.000000000000004, 20.0);
- }
- },
+ // Comprehensive data, containing all the verbs possible.
+ {// Path
+ "M 1 1 m 2 2, l 3 3 L 3 3 H 4 h4 V5 v5, Q6 6 6 6 q 6 6 6 6t 7 7 T 7 7 C 8 8 8 8 8 8 c 8 8 "
+ "8 8 8 8 S 9 9 9 9 s 9 9 9 9 A 10 10 0 1 1 10 10 a 10 10 0 1 1 10 10",
+ {// Verbs
+ {'M', 'm', 'l', 'L', 'H', 'h', 'V', 'v', 'Q', 'q', 't', 'T', 'C', 'c', 'S', 's', 'A',
+ 'a'},
+ // VerbSizes
+ {2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 2, 2, 6, 6, 4, 4, 7, 7},
+ // Points
+ {
+ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 6.0,
+ 6.0, 6.0, 6.0, 6.0, 6.0, 7.0, 7.0, 7.0, 7.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0,
+ 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 10.0,
+ 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 0.0, 1.0, 1.0, 10.0, 10.0,
+ }},
+ [](SkPath* outPath) {
+ outPath->moveTo(1.0, 1.0);
+ outPath->rMoveTo(2.0, 2.0);
+ outPath->rLineTo(3.0, 3.0);
+ outPath->lineTo(3.0, 3.0);
+ outPath->lineTo(4.0, 3.0);
+ outPath->rLineTo(4.0, 0);
+ outPath->lineTo(8.0, 5.0);
+ outPath->rLineTo(0, 5.0);
+ outPath->quadTo(6.0, 6.0, 6.0, 6.0);
+ outPath->rQuadTo(6.0, 6.0, 6.0, 6.0);
+ outPath->rQuadTo(0.0, 0.0, 7.0, 7.0);
+ outPath->quadTo(26.0, 26.0, 7.0, 7.0);
+ outPath->cubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0);
+ outPath->rCubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0);
+ outPath->cubicTo(16.0, 16.0, 9.0, 9.0, 9.0, 9.0);
+ outPath->rCubicTo(0.0, 0.0, 9.0, 9.0, 9.0, 9.0);
+ outPath->cubicTo(18.447775037328352, 20.404243860300607, 17.998389141249767,
+ 22.8911717921705, 16.737515350332117, 24.986664170401575);
+ outPath->cubicTo(15.476641559414468, 27.08215654863265, 13.489843598291483,
+ 28.644011882390082, 11.155893964798905, 29.37447073281729);
+ outPath->cubicTo(8.821944331306327, 30.1049295832445, 6.299226382436471,
+ 29.954422532383525, 4.0686829203897235, 28.951642951534332);
+ outPath->cubicTo(1.838139458342976, 27.94886337068514, 0.05113662931485696,
+ 26.161860541657013, -0.9516429515343354, 23.931317079610267);
+ outPath->cubicTo(-1.9544225323835278, 21.70077361756352, -2.1049295832444987,
+ 19.178055668693663, -1.37447073281729, 16.844106035201087);
+ outPath->cubicTo(-0.6440118823900814, 14.51015640170851, 0.9178434513673546,
+ 12.523358440585524, 3.0133358295984305, 11.262484649667876);
+ outPath->cubicTo(5.108828207829506, 10.001610858750228, 7.5957561396993984,
+ 9.552224962671648, 10.000000000000005, 10.0);
+ outPath->cubicTo(10.0, 7.348852265086975, 11.054287646850167, 4.803576729418881,
+ 12.928932188134523, 2.9289321881345254);
+ outPath->cubicTo(14.803576729418879, 1.0542876468501696, 17.348852265086972,
+ 4.870079381441987E-16, 19.999999999999996, 0.0);
+ outPath->cubicTo(22.65114773491302, -4.870079381441987E-16, 25.19642327058112,
+ 1.0542876468501678, 27.071067811865476, 2.9289321881345227);
+ outPath->cubicTo(28.94571235314983, 4.803576729418878, 30.0, 7.348852265086974, 30.0,
+ 9.999999999999998);
+ outPath->cubicTo(30.0, 12.651147734913023, 28.94571235314983, 15.19642327058112,
+ 27.071067811865476, 17.071067811865476);
+ outPath->cubicTo(25.19642327058112, 18.94571235314983, 22.651147734913028, 20.0,
+ 20.000000000000004, 20.0);
+ }},
- // Check box VectorDrawable path data
- {
- // Path
- "M 0.0,-1.0 l 0.0,0.0 c 0.5522847498,0.0 1.0,0.4477152502 1.0,1.0 l 0.0,0.0 c 0.0,0.5522847498 -0.4477152502,1.0 -1.0,1.0 l 0.0,0.0 c -0.5522847498,0.0 -1.0,-0.4477152502 -1.0,-1.0 l 0.0,0.0 c 0.0,-0.5522847498 0.4477152502,-1.0 1.0,-1.0 Z M 7.0,-9.0 c 0.0,0.0 -14.0,0.0 -14.0,0.0 c -1.1044921875,0.0 -2.0,0.8955078125 -2.0,2.0 c 0.0,0.0 0.0,14.0 0.0,14.0 c 0.0,1.1044921875 0.8955078125,2.0 2.0,2.0 c 0.0,0.0 14.0,0.0 14.0,0.0 c 1.1044921875,0.0 2.0,-0.8955078125 2.0,-2.0 c 0.0,0.0 0.0,-14.0 0.0,-14.0 c 0.0,-1.1044921875 -0.8955078125,-2.0 -2.0,-2.0 c 0.0,0.0 0.0,0.0 0.0,0.0 Z",
- {
- {'M', 'l', 'c', 'l', 'c', 'l', 'c', 'l', 'c', 'Z', 'M', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'Z'},
- {2, 2, 6, 2, 6, 2, 6, 2, 6, 0, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
- {0.0, -1.0, 0.0, 0.0, 0.5522848, 0.0, 1.0, 0.44771525, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5522848, -0.44771525, 1.0, -1.0, 1.0, 0.0, 0.0, -0.5522848, 0.0, -1.0, -0.44771525, -1.0, -1.0, 0.0, 0.0, 0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0, 7.0, -9.0, 0.0, 0.0, -14.0, 0.0, -14.0, 0.0, -1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0, 0.0, 0.0, 0.0, 14.0, 0.0, 14.0, 0.0, 1.1044922, 0.8955078, 2.0, 2.0, 2.0, 0.0, 0.0, 14.0, 0.0, 14.0, 0.0, 1.1044922, 0.0, 2.0, -0.8955078, 2.0, -2.0, 0.0, 0.0, 0.0, -14.0, 0.0, -14.0, 0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- },
- [](SkPath* outPath) {
- outPath->moveTo(0.0, -1.0);
- outPath->rLineTo(0.0, 0.0);
- outPath->rCubicTo(0.5522848, 0.0, 1.0, 0.44771525, 1.0, 1.0);
- outPath->rLineTo(0.0, 0.0);
- outPath->rCubicTo(0.0, 0.5522848, -0.44771525, 1.0, -1.0, 1.0);
- outPath->rLineTo(0.0, 0.0);
- outPath->rCubicTo(-0.5522848, 0.0, -1.0, -0.44771525, -1.0, -1.0);
- outPath->rLineTo(0.0, 0.0);
- outPath->rCubicTo(0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0);
- outPath->close();
- outPath->moveTo(0.0, -1.0);
- outPath->moveTo(7.0, -9.0);
- outPath->rCubicTo(0.0, 0.0, -14.0, 0.0, -14.0, 0.0);
- outPath->rCubicTo(-1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0);
- outPath->rCubicTo(0.0, 0.0, 0.0, 14.0, 0.0, 14.0);
- outPath->rCubicTo(0.0, 1.1044922, 0.8955078, 2.0, 2.0, 2.0);
- outPath->rCubicTo(0.0, 0.0, 14.0, 0.0, 14.0, 0.0);
- outPath->rCubicTo(1.1044922, 0.0, 2.0, -0.8955078, 2.0, -2.0);
- outPath->rCubicTo(0.0, 0.0, 0.0, -14.0, 0.0, -14.0);
- outPath->rCubicTo(0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0);
- outPath->rCubicTo(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- outPath->close();
- outPath->moveTo(7.0, -9.0);
- }
- },
+ // Check box VectorDrawable path data
+ {// Path
+ "M 0.0,-1.0 l 0.0,0.0 c 0.5522847498,0.0 1.0,0.4477152502 1.0,1.0 l 0.0,0.0 c "
+ "0.0,0.5522847498 -0.4477152502,1.0 -1.0,1.0 l 0.0,0.0 c -0.5522847498,0.0 "
+ "-1.0,-0.4477152502 -1.0,-1.0 l 0.0,0.0 c 0.0,-0.5522847498 0.4477152502,-1.0 1.0,-1.0 Z "
+ "M 7.0,-9.0 c 0.0,0.0 -14.0,0.0 -14.0,0.0 c -1.1044921875,0.0 -2.0,0.8955078125 -2.0,2.0 "
+ "c 0.0,0.0 0.0,14.0 0.0,14.0 c 0.0,1.1044921875 0.8955078125,2.0 2.0,2.0 c 0.0,0.0 "
+ "14.0,0.0 14.0,0.0 c 1.1044921875,0.0 2.0,-0.8955078125 2.0,-2.0 c 0.0,0.0 0.0,-14.0 "
+ "0.0,-14.0 c 0.0,-1.1044921875 -0.8955078125,-2.0 -2.0,-2.0 c 0.0,0.0 0.0,0.0 0.0,0.0 Z",
+ {
+ {'M', 'l', 'c', 'l', 'c', 'l', 'c', 'l', 'c', 'Z', 'M',
+ 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'Z'},
+ {2, 2, 6, 2, 6, 2, 6, 2, 6, 0, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
+ {0.0, -1.0, 0.0, 0.0, 0.5522848, 0.0, 1.0,
+ 0.44771525, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5522848,
+ -0.44771525, 1.0, -1.0, 1.0, 0.0, 0.0, -0.5522848,
+ 0.0, -1.0, -0.44771525, -1.0, -1.0, 0.0, 0.0,
+ 0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0, 7.0,
+ -9.0, 0.0, 0.0, -14.0, 0.0, -14.0, 0.0,
+ -1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0, 0.0,
+ 0.0, 0.0, 14.0, 0.0, 14.0, 0.0, 1.1044922,
+ 0.8955078, 2.0, 2.0, 2.0, 0.0, 0.0, 14.0,
+ 0.0, 14.0, 0.0, 1.1044922, 0.0, 2.0, -0.8955078,
+ 2.0, -2.0, 0.0, 0.0, 0.0, -14.0, 0.0,
+ -14.0, 0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ },
+ [](SkPath* outPath) {
+ outPath->moveTo(0.0, -1.0);
+ outPath->rLineTo(0.0, 0.0);
+ outPath->rCubicTo(0.5522848, 0.0, 1.0, 0.44771525, 1.0, 1.0);
+ outPath->rLineTo(0.0, 0.0);
+ outPath->rCubicTo(0.0, 0.5522848, -0.44771525, 1.0, -1.0, 1.0);
+ outPath->rLineTo(0.0, 0.0);
+ outPath->rCubicTo(-0.5522848, 0.0, -1.0, -0.44771525, -1.0, -1.0);
+ outPath->rLineTo(0.0, 0.0);
+ outPath->rCubicTo(0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0);
+ outPath->close();
+ outPath->moveTo(0.0, -1.0);
+ outPath->moveTo(7.0, -9.0);
+ outPath->rCubicTo(0.0, 0.0, -14.0, 0.0, -14.0, 0.0);
+ outPath->rCubicTo(-1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0);
+ outPath->rCubicTo(0.0, 0.0, 0.0, 14.0, 0.0, 14.0);
+ outPath->rCubicTo(0.0, 1.1044922, 0.8955078, 2.0, 2.0, 2.0);
+ outPath->rCubicTo(0.0, 0.0, 14.0, 0.0, 14.0, 0.0);
+ outPath->rCubicTo(1.1044922, 0.0, 2.0, -0.8955078, 2.0, -2.0);
+ outPath->rCubicTo(0.0, 0.0, 0.0, -14.0, 0.0, -14.0);
+ outPath->rCubicTo(0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0);
+ outPath->rCubicTo(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ outPath->close();
+ outPath->moveTo(7.0, -9.0);
+ }},
- // pie1 in progress bar
- {
- "M300,70 a230,230 0 1,0 1,0 z",
- {
- {'M', 'a', 'z', },
- {2, 7, 0, },
- {300.0, 70.0, 230.0, 230.0, 0.0, 1.0, 0.0, 1.0, 0.0, },
- },
- [](SkPath* outPath) {
- outPath->moveTo(300.0, 70.0);
- outPath->cubicTo(239.06697794203706, 70.13246340443499, 180.6164396449267, 94.47383115953485, 137.6004913602211, 137.6302781499585);
- outPath->cubicTo(94.58454307551551, 180.78672514038215, 70.43390412842275, 239.3163266242308, 70.50013586976587, 300.2494566687817);
- outPath->cubicTo(70.56636761110899, 361.1825867133326, 94.84418775550249, 419.65954850554147, 137.9538527586204, 462.72238058830936);
- outPath->cubicTo(181.06351776173827, 505.7852126710772, 239.5668339599056, 529.999456521097, 300.49999999999994, 529.999456521097);
- outPath->cubicTo(361.43316604009436, 529.999456521097, 419.93648223826176, 505.78521267107726, 463.0461472413797, 462.7223805883093);
- outPath->cubicTo(506.1558122444976, 419.65954850554135, 530.433632388891, 361.1825867133324, 530.4998641302341, 300.2494566687815);
- outPath->cubicTo(530.5660958715771, 239.31632662423056, 506.4154569244844, 180.7867251403819, 463.3995086397787, 137.6302781499583);
- outPath->cubicTo(420.383560355073, 94.47383115953468, 361.93302205796255, 70.13246340443492, 300.9999999999996, 70.00000000000003);
- outPath->close();
- outPath->moveTo(300.0, 70.0);
- }
- },
+ // pie1 in progress bar
+ {"M300,70 a230,230 0 1,0 1,0 z",
+ {
+ {
+ 'M', 'a', 'z',
+ },
+ {
+ 2, 7, 0,
+ },
+ {
+ 300.0, 70.0, 230.0, 230.0, 0.0, 1.0, 0.0, 1.0, 0.0,
+ },
+ },
+ [](SkPath* outPath) {
+ outPath->moveTo(300.0, 70.0);
+ outPath->cubicTo(239.06697794203706, 70.13246340443499, 180.6164396449267,
+ 94.47383115953485, 137.6004913602211, 137.6302781499585);
+ outPath->cubicTo(94.58454307551551, 180.78672514038215, 70.43390412842275,
+ 239.3163266242308, 70.50013586976587, 300.2494566687817);
+ outPath->cubicTo(70.56636761110899, 361.1825867133326, 94.84418775550249,
+ 419.65954850554147, 137.9538527586204, 462.72238058830936);
+ outPath->cubicTo(181.06351776173827, 505.7852126710772, 239.5668339599056,
+ 529.999456521097, 300.49999999999994, 529.999456521097);
+ outPath->cubicTo(361.43316604009436, 529.999456521097, 419.93648223826176,
+ 505.78521267107726, 463.0461472413797, 462.7223805883093);
+ outPath->cubicTo(506.1558122444976, 419.65954850554135, 530.433632388891,
+ 361.1825867133324, 530.4998641302341, 300.2494566687815);
+ outPath->cubicTo(530.5660958715771, 239.31632662423056, 506.4154569244844,
+ 180.7867251403819, 463.3995086397787, 137.6302781499583);
+ outPath->cubicTo(420.383560355073, 94.47383115953468, 361.93302205796255,
+ 70.13246340443492, 300.9999999999996, 70.00000000000003);
+ outPath->close();
+ outPath->moveTo(300.0, 70.0);
+ }},
- // Random long data
- {
- // Path
- "M5.3,13.2c-0.1,0.0 -0.3,0.0 -0.4,-0.1c-0.3,-0.2 -0.4,-0.7 -0.2,-1.0c1.3,-1.9 2.9,-3.4 4.9,-4.5c4.1,-2.2 9.3,-2.2 13.4,0.0c1.9,1.1 3.6,2.5 4.9,4.4c0.2,0.3 0.1,0.8 -0.2,1.0c-0.3,0.2 -0.8,0.1 -1.0,-0.2c-1.2,-1.7 -2.6,-3.0 -4.3,-4.0c-3.7,-2.0 -8.3,-2.0 -12.0,0.0c-1.7,0.9 -3.2,2.3 -4.3,4.0C5.7,13.1 5.5,13.2 5.3,13.2z",
- {
- // Verbs
- {'M', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'C', 'z'},
- // Verb sizes
- {2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
- // Points
- {5.3, 13.2, -0.1, 0, -0.3, 0, -0.4, -0.1, -0.3, -0.2, -0.4, -0.7, -0.2, -1, 1.3, -1.9, 2.9, -3.4, 4.9, -4.5, 4.1, -2.2, 9.3, -2.2, 13.4, 0, 1.9, 1.1, 3.6, 2.5, 4.9, 4.4, 0.2, 0.3, 0.1, 0.8, -0.2, 1, -0.3, 0.2, -0.8, 0.1, -1, -0.2, -1.2, -1.7, -2.6, -3, -4.3, -4, -3.7, -2, -8.3, -2, -12, 0, -1.7, 0.9, -3.2, 2.3, -4.3, 4, 5.7, 13.1, 5.5, 13.2, 5.3, 13.2},
- },
- [](SkPath* outPath) {
- outPath->moveTo(5.3, 13.2);
- outPath->rCubicTo(-0.1, 0.0, -0.3, 0.0, -0.4, -0.1);
- outPath->rCubicTo(-0.3, -0.2, -0.4, -0.7, -0.2, -1.0);
- outPath->rCubicTo(1.3, -1.9, 2.9, -3.4, 4.9, -4.5);
- outPath->rCubicTo(4.1, -2.2, 9.3, -2.2, 13.4, 0.0);
- outPath->rCubicTo(1.9, 1.1, 3.6, 2.5, 4.9, 4.4);
- outPath->rCubicTo(0.2, 0.3, 0.1, 0.8, -0.2, 1.0);
- outPath->rCubicTo(-0.3, 0.2, -0.8, 0.1, -1.0, -0.2);
- outPath->rCubicTo(-1.2, -1.7, -2.6, -3.0, -4.3, -4.0);
- outPath->rCubicTo(-3.7, -2.0, -8.3, -2.0, -12.0, 0.0);
- outPath->rCubicTo(-1.7, 0.9, -3.2, 2.3, -4.3, 4.0);
- outPath->cubicTo(5.7, 13.1, 5.5, 13.2, 5.3, 13.2);
- outPath->close();
- outPath->moveTo(5.3, 13.2);
- }
- },
+ // Random long data
+ {// Path
+ "M5.3,13.2c-0.1,0.0 -0.3,0.0 -0.4,-0.1c-0.3,-0.2 -0.4,-0.7 -0.2,-1.0c1.3,-1.9 2.9,-3.4 "
+ "4.9,-4.5c4.1,-2.2 9.3,-2.2 13.4,0.0c1.9,1.1 3.6,2.5 4.9,4.4c0.2,0.3 0.1,0.8 "
+ "-0.2,1.0c-0.3,0.2 -0.8,0.1 -1.0,-0.2c-1.2,-1.7 -2.6,-3.0 -4.3,-4.0c-3.7,-2.0 -8.3,-2.0 "
+ "-12.0,0.0c-1.7,0.9 -3.2,2.3 -4.3,4.0C5.7,13.1 5.5,13.2 5.3,13.2z",
+ {
+ // Verbs
+ {'M', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'C', 'z'},
+ // Verb sizes
+ {2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
+ // Points
+ {5.3, 13.2, -0.1, 0, -0.3, 0, -0.4, -0.1, -0.3, -0.2, -0.4, -0.7, -0.2, -1,
+ 1.3, -1.9, 2.9, -3.4, 4.9, -4.5, 4.1, -2.2, 9.3, -2.2, 13.4, 0, 1.9, 1.1,
+ 3.6, 2.5, 4.9, 4.4, 0.2, 0.3, 0.1, 0.8, -0.2, 1, -0.3, 0.2, -0.8, 0.1,
+ -1, -0.2, -1.2, -1.7, -2.6, -3, -4.3, -4, -3.7, -2, -8.3, -2, -12, 0,
+ -1.7, 0.9, -3.2, 2.3, -4.3, 4, 5.7, 13.1, 5.5, 13.2, 5.3, 13.2},
+ },
+ [](SkPath* outPath) {
+ outPath->moveTo(5.3, 13.2);
+ outPath->rCubicTo(-0.1, 0.0, -0.3, 0.0, -0.4, -0.1);
+ outPath->rCubicTo(-0.3, -0.2, -0.4, -0.7, -0.2, -1.0);
+ outPath->rCubicTo(1.3, -1.9, 2.9, -3.4, 4.9, -4.5);
+ outPath->rCubicTo(4.1, -2.2, 9.3, -2.2, 13.4, 0.0);
+ outPath->rCubicTo(1.9, 1.1, 3.6, 2.5, 4.9, 4.4);
+ outPath->rCubicTo(0.2, 0.3, 0.1, 0.8, -0.2, 1.0);
+ outPath->rCubicTo(-0.3, 0.2, -0.8, 0.1, -1.0, -0.2);
+ outPath->rCubicTo(-1.2, -1.7, -2.6, -3.0, -4.3, -4.0);
+ outPath->rCubicTo(-3.7, -2.0, -8.3, -2.0, -12.0, 0.0);
+ outPath->rCubicTo(-1.7, 0.9, -3.2, 2.3, -4.3, 4.0);
+ outPath->cubicTo(5.7, 13.1, 5.5, 13.2, 5.3, 13.2);
+ outPath->close();
+ outPath->moveTo(5.3, 13.2);
+ }},
- // Extreme case with numbers and decimal points crunched together
- {
- // Path
- "l0.0.0.5.0.0.5-0.5.0.0-.5z",
- {
- // Verbs
- {'l', 'z'},
- // Verb sizes
- {10, 0},
- // Points
- {0, 0, 0.5, 0, 0, 0.5, -0.5, 0, 0, -0.5},
- },
- [](SkPath* outPath) {
- outPath->rLineTo(0.0, 0.0);
- outPath->rLineTo(0.5, 0.0);
- outPath->rLineTo(0.0, 0.5);
- outPath->rLineTo(-0.5, 0.0);
- outPath->rLineTo(0.0, -0.5);
- outPath->close();
- outPath->moveTo(0.0, 0.0);
- }
- },
+ // Extreme case with numbers and decimal points crunched together
+ {// Path
+ "l0.0.0.5.0.0.5-0.5.0.0-.5z",
+ {
+ // Verbs
+ {'l', 'z'},
+ // Verb sizes
+ {10, 0},
+ // Points
+ {0, 0, 0.5, 0, 0, 0.5, -0.5, 0, 0, -0.5},
+ },
+ [](SkPath* outPath) {
+ outPath->rLineTo(0.0, 0.0);
+ outPath->rLineTo(0.5, 0.0);
+ outPath->rLineTo(0.0, 0.5);
+ outPath->rLineTo(-0.5, 0.0);
+ outPath->rLineTo(0.0, -0.5);
+ outPath->close();
+ outPath->moveTo(0.0, 0.0);
+ }},
- // Empty test data
- {
- "",
- {
- // Verbs
- {},
- {},
- {},
- },
- [](SkPath* outPath) {}
- }
+ // Empty test data
+ {"",
+ {
+ // Verbs
+ {},
+ {},
+ {},
+ },
+ [](SkPath* outPath) {}}
};
@@ -231,22 +275,21 @@
};
const StringPath sStringPaths[] = {
- {"3e...3", false}, // Not starting with a verb and ill-formatted float
- {"L.M.F.A.O", false}, // No floats following verbs
- {"m 1 1", true}, // Valid path data
- {"\n \t z", true}, // Valid path data with leading spaces
- {"1-2e34567", false}, // Not starting with a verb and ill-formatted float
- {"f 4 5", false}, // Invalid verb
- {"\r ", false} // Empty string
+ {"3e...3", false}, // Not starting with a verb and ill-formatted float
+ {"L.M.F.A.O", false}, // No floats following verbs
+ {"m 1 1", true}, // Valid path data
+ {"\n \t z", true}, // Valid path data with leading spaces
+ {"1-2e34567", false}, // Not starting with a verb and ill-formatted float
+ {"f 4 5", false}, // Invalid verb
+ {"\r ", false} // Empty string
};
-
static bool hasSameVerbs(const PathData& from, const PathData& to) {
return from.verbs == to.verbs && from.verbSizes == to.verbSizes;
}
TEST(PathParser, parseStringForData) {
- for (TestData testData: sTestDataSet) {
+ for (TestData testData : sTestDataSet) {
PathParser::ParseResult result;
// Test generated path data against the given data.
PathData pathData;
@@ -259,14 +302,14 @@
PathParser::ParseResult result;
PathData pathData;
SkPath skPath;
- PathParser::getPathDataFromAsciiString(&pathData, &result,
- stringPath.stringPath, strlen(stringPath.stringPath));
+ PathParser::getPathDataFromAsciiString(&pathData, &result, stringPath.stringPath,
+ strlen(stringPath.stringPath));
EXPECT_EQ(stringPath.isValid, !result.failureOccurred);
}
}
TEST(VectorDrawableUtils, createSkPathFromPathData) {
- for (TestData testData: sTestDataSet) {
+ for (TestData testData : sTestDataSet) {
SkPath expectedPath;
testData.skPathLamda(&expectedPath);
SkPath actualPath;
@@ -276,7 +319,7 @@
}
TEST(PathParser, parseAsciiStringForSkPath) {
- for (TestData testData: sTestDataSet) {
+ for (TestData testData : sTestDataSet) {
PathParser::ParseResult result;
size_t length = strlen(testData.pathString);
// Check the return value as well as the SkPath generated.
@@ -293,14 +336,14 @@
PathParser::ParseResult result;
SkPath skPath;
PathParser::parseAsciiStringForSkPath(&skPath, &result, stringPath.stringPath,
- strlen(stringPath.stringPath));
+ strlen(stringPath.stringPath));
EXPECT_EQ(stringPath.isValid, !result.failureOccurred);
}
}
TEST(VectorDrawableUtils, morphPathData) {
- for (TestData fromData: sTestDataSet) {
- for (TestData toData: sTestDataSet) {
+ for (TestData fromData : sTestDataSet) {
+ for (TestData toData : sTestDataSet) {
bool canMorph = VectorDrawableUtils::canMorph(fromData.pathData, toData.pathData);
if (fromData.pathData == toData.pathData) {
EXPECT_TRUE(canMorph);
@@ -314,11 +357,11 @@
TEST(VectorDrawableUtils, interpolatePathData) {
// Interpolate path data with itself and every other path data
- for (TestData fromData: sTestDataSet) {
- for (TestData toData: sTestDataSet) {
+ for (TestData fromData : sTestDataSet) {
+ for (TestData toData : sTestDataSet) {
PathData outData;
bool success = VectorDrawableUtils::interpolatePathData(&outData, fromData.pathData,
- toData.pathData, 0.5);
+ toData.pathData, 0.5);
bool expectedToMorph = hasSameVerbs(fromData.pathData, toData.pathData);
EXPECT_EQ(expectedToMorph, success);
}
@@ -335,12 +378,12 @@
PathData outData;
// Interpolate the two path data with different fractions
for (float fraction : fractions) {
- bool success = VectorDrawableUtils::interpolatePathData(
- &outData, fromPathData, toPathData, fraction);
+ bool success = VectorDrawableUtils::interpolatePathData(&outData, fromPathData,
+ toPathData, fraction);
EXPECT_TRUE(success);
for (size_t i = 0; i < outData.points.size(); i++) {
- float expectedResult = fromPathData.points[i] * (1.0 - fraction) +
- toPathData.points[i] * fraction;
+ float expectedResult =
+ fromPathData.points[i] * (1.0 - fraction) + toPathData.points[i] * fraction;
EXPECT_TRUE(MathUtils::areEqual(expectedResult, outData.points[i]));
}
}
@@ -348,7 +391,7 @@
}
TEST(VectorDrawable, groupProperties) {
- //TODO: Also need to test property sync and dirty flag when properties change.
+ // TODO: Also need to test property sync and dirty flag when properties change.
VectorDrawable::Group group;
VectorDrawable::Group::GroupProperties* properties = group.mutateProperties();
// Test default values, change values through setters and verify the change through getters.
@@ -379,7 +422,6 @@
EXPECT_EQ(0.0f, properties->getPivotY());
properties->setPivotY(1.0f);
EXPECT_EQ(1.0f, properties->getPivotY());
-
}
TEST(VectorDrawable, drawPathWithoutIncrementingShaderRefCount) {
@@ -402,5 +444,5 @@
EXPECT_TRUE(shader->unique());
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/tests/unit/main.cpp b/libs/hwui/tests/unit/main.cpp
index cea84c0..406255d 100644
--- a/libs/hwui/tests/unit/main.cpp
+++ b/libs/hwui/tests/unit/main.cpp
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#include "gtest/gtest.h"
#include "gmock/gmock.h"
+#include "gtest/gtest.h"
#include "Caches.h"
#include "debug/GlesDriver.h"
#include "debug/NullGlesDriver.h"
#include "hwui/Typeface.h"
-#include "thread/TaskManager.h"
#include "tests/common/LeakChecker.h"
+#include "thread/TaskManager.h"
#include <signal.h>
@@ -31,17 +31,14 @@
using namespace android::uirenderer;
static auto CRASH_SIGNALS = {
- SIGABRT,
- SIGSEGV,
- SIGBUS,
+ SIGABRT, SIGSEGV, SIGBUS,
};
static map<int, struct sigaction> gSigChain;
static void gtestSigHandler(int sig, siginfo_t* siginfo, void* context) {
auto testinfo = ::testing::UnitTest::GetInstance()->current_test_info();
- printf("[ FAILED ] %s.%s\n", testinfo->test_case_name(),
- testinfo->name());
+ printf("[ FAILED ] %s.%s\n", testinfo->test_case_name(), testinfo->name());
printf("[ FATAL! ] Process crashed, aborting tests!\n");
fflush(stdout);
@@ -53,9 +50,7 @@
class TypefaceEnvironment : public testing::Environment {
public:
- virtual void SetUp() {
- Typeface::setRobotoTypefaceForTest();
- }
+ virtual void SetUp() { Typeface::setRobotoTypefaceForTest(); }
};
int main(int argc, char* argv[]) {
@@ -83,4 +78,3 @@
test::LeakChecker::checkForLeaks();
return ret;
}
-