summaryrefslogtreecommitdiff
path: root/libs/hwui/tests/unit/VectorDrawableTests.cpp
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2017-05-26 09:12:46 -0400
committerMike Reed <reed@google.com>2017-05-26 10:01:35 -0400
commit2653f8324a1793738ceda73911b71a1ca2ea4f9c (patch)
treea5f9bc40251940ac19b0cc4ec42430e0f1bbdc6f /libs/hwui/tests/unit/VectorDrawableTests.cpp
parent412849937337b24957be8a1a5577661cf59da400 (diff)
don't need custom shader to track ref-counts
Test: hwui_unit_tests Change-Id: Ibe67a86489e0e65251e3c0a4ddc2f72bf528f8b5
Diffstat (limited to 'libs/hwui/tests/unit/VectorDrawableTests.cpp')
-rw-r--r--libs/hwui/tests/unit/VectorDrawableTests.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp
index 6f264e1ebf62..1c2156765fe6 100644
--- a/libs/hwui/tests/unit/VectorDrawableTests.cpp
+++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp
@@ -382,47 +382,24 @@ TEST(VectorDrawable, groupProperties) {
}
-static SkShader* createShader(bool* isDestroyed) {
- class TestShader : public SkShader {
- public:
- TestShader(bool* isDestroyed) : SkShader(), mDestroyed(isDestroyed) {
- }
- ~TestShader() {
- *mDestroyed = true;
- }
-
- Factory getFactory() const override { return nullptr; }
- private:
- bool* mDestroyed;
- };
- return new TestShader(isDestroyed);
-}
-
TEST(VectorDrawable, drawPathWithoutIncrementingShaderRefCount) {
VectorDrawable::FullPath path("m1 1", 4);
SkBitmap bitmap;
- SkImageInfo info = SkImageInfo::Make(5, 5, kN32_SkColorType, kPremul_SkAlphaType);
- bitmap.setInfo(info);
- bitmap.allocPixels(info);
+ bitmap.allocN32Pixels(5, 5, false);
SkCanvas canvas(bitmap);
- bool shaderIsDestroyed = false;
-
+ sk_sp<SkShader> shader = SkShader::MakeColorShader(SK_ColorBLACK);
// Initial ref count is 1
- SkShader* shader = createShader(&shaderIsDestroyed);
+ EXPECT_TRUE(shader->unique());
// Setting the fill gradient increments the ref count of the shader by 1
- path.mutateStagingProperties()->setFillGradient(shader);
+ path.mutateStagingProperties()->setFillGradient(shader.get());
+ EXPECT_FALSE(shader->unique());
path.draw(&canvas, true);
// Resetting the fill gradient decrements the ref count of the shader by 1
path.mutateStagingProperties()->setFillGradient(nullptr);
- // Expect ref count to be 1 again, i.e. nothing else to have a ref to the shader now. Unref()
- // again should bring the ref count to zero and consequently trigger detor.
- shader->unref();
-
- // Verify that detor is called.
- EXPECT_TRUE(shaderIsDestroyed);
+ EXPECT_TRUE(shader->unique());
}
}; // namespace uirenderer