summaryrefslogtreecommitdiff
path: root/libs/hwui/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/tests')
-rw-r--r--libs/hwui/tests/common/TestContext.cpp74
-rw-r--r--libs/hwui/tests/common/TestContext.h11
-rw-r--r--libs/hwui/tests/common/TestUtils.h1
-rw-r--r--libs/hwui/tests/common/scenes/BitmapShaders.cpp9
-rw-r--r--libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp11
-rw-r--r--libs/hwui/tests/common/scenes/ListOfFadedTextAnimation.cpp4
-rw-r--r--libs/hwui/tests/common/scenes/ListViewAnimation.cpp4
-rw-r--r--libs/hwui/tests/common/scenes/MagnifierAnimation.cpp2
-rw-r--r--libs/hwui/tests/common/scenes/OvalAnimation.cpp2
-rw-r--r--libs/hwui/tests/common/scenes/RectGridAnimation.cpp4
-rw-r--r--libs/hwui/tests/common/scenes/SaveLayerAnimation.cpp2
-rw-r--r--libs/hwui/tests/common/scenes/ShapeAnimation.cpp18
-rw-r--r--libs/hwui/tests/common/scenes/SimpleColorMatrixAnimation.cpp20
-rw-r--r--libs/hwui/tests/common/scenes/SimpleGradientAnimation.cpp4
-rw-r--r--libs/hwui/tests/common/scenes/TestSceneBase.h1
-rw-r--r--libs/hwui/tests/common/scenes/TvApp.cpp4
-rw-r--r--libs/hwui/tests/macrobench/TestSceneRunner.cpp20
-rw-r--r--libs/hwui/tests/microbench/DisplayListCanvasBench.cpp3
-rw-r--r--libs/hwui/tests/microbench/main.cpp5
-rwxr-xr-xlibs/hwui/tests/scripts/skp-capture.sh78
-rw-r--r--libs/hwui/tests/unit/ABitmapTests.cpp46
-rw-r--r--libs/hwui/tests/unit/CacheManagerTests.cpp8
-rw-r--r--libs/hwui/tests/unit/FatVectorTests.cpp2
-rw-r--r--libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp65
-rw-r--r--libs/hwui/tests/unit/RenderNodeDrawableTests.cpp43
-rw-r--r--libs/hwui/tests/unit/SkiaBehaviorTests.cpp4
-rw-r--r--libs/hwui/tests/unit/SkiaCanvasTests.cpp5
-rw-r--r--libs/hwui/tests/unit/SkiaDisplayListTests.cpp7
-rw-r--r--libs/hwui/tests/unit/SkiaPipelineTests.cpp90
-rw-r--r--libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp3
-rw-r--r--libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp163
-rw-r--r--libs/hwui/tests/unit/VectorDrawableTests.cpp8
-rw-r--r--libs/hwui/tests/unit/main.cpp3
33 files changed, 278 insertions, 446 deletions
diff --git a/libs/hwui/tests/common/TestContext.cpp b/libs/hwui/tests/common/TestContext.cpp
index 0a54aca4970d..06f158f25fc5 100644
--- a/libs/hwui/tests/common/TestContext.cpp
+++ b/libs/hwui/tests/common/TestContext.cpp
@@ -22,43 +22,50 @@ namespace android {
namespace uirenderer {
namespace test {
-static const int IDENT_DISPLAYEVENT = 1;
-
-static android::DisplayInfo DUMMY_DISPLAY{
- 1080, // w
- 1920, // h
- 320.0, // xdpi
- 320.0, // ydpi
- 60.0, // fps
- 2.0, // density
- 0, // orientation
- false, // secure?
- 0, // appVsyncOffset
- 0, // presentationDeadline
-};
-
-DisplayInfo getInternalDisplay() {
-#if !HWUI_NULL_GPU
- DisplayInfo display;
- const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken();
- LOG_ALWAYS_FATAL_IF(token == nullptr,
- "Failed to get display info because internal display is disconnected\n");
- status_t status = SurfaceComposerClient::getDisplayInfo(token, &display);
- LOG_ALWAYS_FATAL_IF(status, "Failed to get display info\n");
- return display;
+const DisplayInfo& getDisplayInfo() {
+ static DisplayInfo info = [] {
+ DisplayInfo info;
+#if HWUI_NULL_GPU
+ info.density = 2.f;
#else
- return DUMMY_DISPLAY;
+ const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken();
+ LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__);
+
+ const status_t status = SurfaceComposerClient::getDisplayInfo(token, &info);
+ LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get display info", __FUNCTION__);
#endif
+ return info;
+ }();
+
+ return info;
}
-// Initialize to a dummy default
-android::DisplayInfo gDisplay = DUMMY_DISPLAY;
+const DisplayConfig& getActiveDisplayConfig() {
+ static DisplayConfig config = [] {
+ DisplayConfig config;
+#if HWUI_NULL_GPU
+ config.resolution = ui::Size(1080, 1920);
+ config.xDpi = config.yDpi = 320.f;
+ config.refreshRate = 60.f;
+#else
+ const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken();
+ LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__);
+
+ const status_t status = SurfaceComposerClient::getActiveDisplayConfig(token, &config);
+ LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get active display config", __FUNCTION__);
+#endif
+ return config;
+ }();
+
+ return config;
+}
TestContext::TestContext() {
mLooper = new Looper(true);
mSurfaceComposerClient = new SurfaceComposerClient();
- mLooper->addFd(mDisplayEventReceiver.getFd(), IDENT_DISPLAYEVENT, Looper::EVENT_INPUT, nullptr,
- nullptr);
+
+ constexpr int EVENT_ID = 1;
+ mLooper->addFd(mDisplayEventReceiver.getFd(), EVENT_ID, Looper::EVENT_INPUT, nullptr, nullptr);
}
TestContext::~TestContext() {}
@@ -79,8 +86,10 @@ void TestContext::createSurface() {
}
void TestContext::createWindowSurface() {
- mSurfaceControl = mSurfaceComposerClient->createSurface(String8("HwuiTest"), gDisplay.w,
- gDisplay.h, PIXEL_FORMAT_RGBX_8888);
+ const ui::Size& resolution = getActiveDisplayResolution();
+ mSurfaceControl =
+ mSurfaceComposerClient->createSurface(String8("HwuiTest"), resolution.getWidth(),
+ resolution.getHeight(), PIXEL_FORMAT_RGBX_8888);
SurfaceComposerClient::Transaction t;
t.setLayer(mSurfaceControl, 0x7FFFFFF).show(mSurfaceControl).apply();
@@ -94,7 +103,8 @@ void TestContext::createOffscreenSurface() {
producer->setMaxDequeuedBufferCount(3);
producer->setAsyncMode(true);
mConsumer = new BufferItemConsumer(consumer, GRALLOC_USAGE_HW_COMPOSER, 4);
- mConsumer->setDefaultBufferSize(gDisplay.w, gDisplay.h);
+ const ui::Size& resolution = getActiveDisplayResolution();
+ mConsumer->setDefaultBufferSize(resolution.getWidth(), resolution.getHeight());
mSurface = new Surface(producer);
}
diff --git a/libs/hwui/tests/common/TestContext.h b/libs/hwui/tests/common/TestContext.h
index 116d4de8090a..a012ecb1a1d3 100644
--- a/libs/hwui/tests/common/TestContext.h
+++ b/libs/hwui/tests/common/TestContext.h
@@ -23,20 +23,25 @@
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/SurfaceControl.h>
+#include <ui/DisplayConfig.h>
#include <ui/DisplayInfo.h>
#include <utils/Looper.h>
#include <atomic>
#include <thread>
+#define dp(x) ((x) * android::uirenderer::test::getDisplayInfo().density)
+
namespace android {
namespace uirenderer {
namespace test {
-extern DisplayInfo gDisplay;
-#define dp(x) ((x)*android::uirenderer::test::gDisplay.density)
+const DisplayInfo& getDisplayInfo();
+const DisplayConfig& getActiveDisplayConfig();
-DisplayInfo getInternalDisplay();
+inline const ui::Size& getActiveDisplayResolution() {
+ return getActiveDisplayConfig().resolution;
+}
class TestContext {
public:
diff --git a/libs/hwui/tests/common/TestUtils.h b/libs/hwui/tests/common/TestUtils.h
index e7124df72beb..91a808df3657 100644
--- a/libs/hwui/tests/common/TestUtils.h
+++ b/libs/hwui/tests/common/TestUtils.h
@@ -29,6 +29,7 @@
#include <gtest/gtest.h>
#include <memory>
+#include <unordered_map>
namespace android {
namespace uirenderer {
diff --git a/libs/hwui/tests/common/scenes/BitmapShaders.cpp b/libs/hwui/tests/common/scenes/BitmapShaders.cpp
index 510766073b08..c4067af388e3 100644
--- a/libs/hwui/tests/common/scenes/BitmapShaders.cpp
+++ b/libs/hwui/tests/common/scenes/BitmapShaders.cpp
@@ -15,6 +15,7 @@
*/
#include <SkImagePriv.h>
+#include "hwui/Paint.h"
#include "TestSceneBase.h"
#include "tests/common/BitmapAllocationTestUtils.h"
#include "utils/Color.h"
@@ -43,17 +44,15 @@ public:
skCanvas.drawRect(SkRect::MakeXYWH(100, 100, 100, 100), skPaint);
});
- SkPaint paint;
+ Paint paint;
sk_sp<SkImage> image = hwuiBitmap->makeImage();
sk_sp<SkShader> repeatShader =
- image->makeShader(SkShader::TileMode::kRepeat_TileMode,
- SkShader::TileMode::kRepeat_TileMode, nullptr);
+ image->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat);
paint.setShader(std::move(repeatShader));
canvas.drawRoundRect(0, 0, 500, 500, 50.0f, 50.0f, paint);
sk_sp<SkShader> mirrorShader =
- image->makeShader(SkShader::TileMode::kMirror_TileMode,
- SkShader::TileMode::kMirror_TileMode, nullptr);
+ image->makeShader(SkTileMode::kMirror, SkTileMode::kMirror);
paint.setShader(std::move(mirrorShader));
canvas.drawRoundRect(0, 600, 500, 1100, 50.0f, 50.0f, paint);
}
diff --git a/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp b/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp
index 2af955fbb711..5886ea39acce 100644
--- a/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp
+++ b/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp
@@ -50,7 +50,7 @@ public:
pixels[4000 + 4 * i + 3] = 255;
}
buffer->unlock();
- sk_sp<Bitmap> hardwareBitmap(Bitmap::createFrom(buffer, kRGBA_8888_SkColorType,
+ sk_sp<Bitmap> hardwareBitmap(Bitmap::createFrom(buffer->toAHardwareBuffer(),
SkColorSpace::MakeSRGB()));
sk_sp<SkShader> hardwareShader(createBitmapShader(*hardwareBitmap));
@@ -60,12 +60,12 @@ public:
colors[0] = Color::Black;
colors[1] = Color::White;
sk_sp<SkShader> gradientShader = SkGradientShader::MakeRadial(
- center, 50, colors, nullptr, 2, SkShader::TileMode::kRepeat_TileMode);
+ center, 50, colors, nullptr, 2, SkTileMode::kRepeat);
sk_sp<SkShader> compositeShader(
- SkShader::MakeComposeShader(hardwareShader, gradientShader, SkBlendMode::kDstATop));
+ SkShaders::Blend(SkBlendMode::kDstATop, hardwareShader, gradientShader));
- SkPaint paint;
+ Paint paint;
paint.setShader(std::move(compositeShader));
canvas.drawRoundRect(0, 0, 400, 200, 10.0f, 10.0f, paint);
}
@@ -74,7 +74,6 @@ public:
sk_sp<SkShader> createBitmapShader(Bitmap& bitmap) {
sk_sp<SkImage> image = bitmap.makeImage();
- return image->makeShader(SkShader::TileMode::kClamp_TileMode,
- SkShader::TileMode::kClamp_TileMode);
+ return image->makeShader();
}
};
diff --git a/libs/hwui/tests/common/scenes/ListOfFadedTextAnimation.cpp b/libs/hwui/tests/common/scenes/ListOfFadedTextAnimation.cpp
index ecaaf487e4f8..a9449b62a1f8 100644
--- a/libs/hwui/tests/common/scenes/ListOfFadedTextAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/ListOfFadedTextAnimation.cpp
@@ -44,12 +44,12 @@ class ListOfFadedTextAnimation : public TestListViewSceneBase {
SkColor colors[2] = {Color::Black, Color::Transparent};
sk_sp<SkShader> s(
- SkGradientShader::MakeLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode));
+ SkGradientShader::MakeLinear(pts, colors, NULL, 2, SkTileMode::kClamp));
SkMatrix matrix;
matrix.setScale(1, length);
matrix.postRotate(-90);
- SkPaint fadingPaint;
+ Paint fadingPaint;
fadingPaint.setShader(s->makeWithLocalMatrix(matrix));
fadingPaint.setBlendMode(SkBlendMode::kDstOut);
canvas.drawRect(0, 0, length, itemHeight, fadingPaint);
diff --git a/libs/hwui/tests/common/scenes/ListViewAnimation.cpp b/libs/hwui/tests/common/scenes/ListViewAnimation.cpp
index feb881f654f8..d031923a112b 100644
--- a/libs/hwui/tests/common/scenes/ListViewAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/ListViewAnimation.cpp
@@ -53,7 +53,7 @@ class ListViewAnimation : public TestListViewSceneBase {
char charToShow = 'A' + (rand() % 26);
const SkPoint pos = {SkIntToScalar(size / 2),
/*approximate centering*/ SkFloatToScalar(size * 0.7f)};
- canvas.drawSimpleText(&charToShow, 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
+ canvas.drawSimpleText(&charToShow, 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
return bitmap;
}
@@ -79,7 +79,7 @@ class ListViewAnimation : public TestListViewSceneBase {
static sk_sp<Bitmap> filledBox(createBoxBitmap(true));
static sk_sp<Bitmap> strokedBox(createBoxBitmap(false));
// TODO: switch to using round rect clipping, once merging correctly handles that
- SkPaint roundRectPaint;
+ Paint roundRectPaint;
roundRectPaint.setAntiAlias(true);
roundRectPaint.setColor(Color::White);
canvas.drawRoundRect(0, 0, itemWidth, itemHeight, dp(6), dp(6), roundRectPaint);
diff --git a/libs/hwui/tests/common/scenes/MagnifierAnimation.cpp b/libs/hwui/tests/common/scenes/MagnifierAnimation.cpp
index f6cff1c643a1..f4fce277454d 100644
--- a/libs/hwui/tests/common/scenes/MagnifierAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/MagnifierAnimation.cpp
@@ -70,7 +70,7 @@ public:
magnifier->getSkBitmap(&temp);
constexpr int x = 90;
constexpr int y = 325;
- RenderProxy::copySurfaceInto(renderTarget, x, y, x + magnifier->width(),
+ RenderProxy::copySurfaceInto(renderTarget.get(), x, y, x + magnifier->width(),
y + magnifier->height(), &temp);
}
}
diff --git a/libs/hwui/tests/common/scenes/OvalAnimation.cpp b/libs/hwui/tests/common/scenes/OvalAnimation.cpp
index 4ff868b9d068..402c1ece2146 100644
--- a/libs/hwui/tests/common/scenes/OvalAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/OvalAnimation.cpp
@@ -28,7 +28,7 @@ public:
void createContent(int width, int height, Canvas& canvas) override {
canvas.drawColor(Color::White, SkBlendMode::kSrcOver);
card = TestUtils::createNode(0, 0, 200, 200, [](RenderProperties& props, Canvas& canvas) {
- SkPaint paint;
+ Paint paint;
paint.setAntiAlias(true);
paint.setColor(Color::Black);
canvas.drawOval(0, 0, 200, 200, paint);
diff --git a/libs/hwui/tests/common/scenes/RectGridAnimation.cpp b/libs/hwui/tests/common/scenes/RectGridAnimation.cpp
index 6a3b6a57b28a..80b5cc191089 100644
--- a/libs/hwui/tests/common/scenes/RectGridAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/RectGridAnimation.cpp
@@ -37,11 +37,11 @@ public:
SkRegion region;
for (int xOffset = 0; xOffset < 200; xOffset += 2) {
for (int yOffset = 0; yOffset < 200; yOffset += 2) {
- region.op(xOffset, yOffset, xOffset + 1, yOffset + 1, SkRegion::kUnion_Op);
+ region.op({xOffset, yOffset, xOffset + 1, yOffset + 1}, SkRegion::kUnion_Op);
}
}
- SkPaint paint;
+ Paint paint;
paint.setColor(0xff00ffff);
canvas.drawRegion(region, paint);
});
diff --git a/libs/hwui/tests/common/scenes/SaveLayerAnimation.cpp b/libs/hwui/tests/common/scenes/SaveLayerAnimation.cpp
index 02dd42ff2ae8..97bfba34c790 100644
--- a/libs/hwui/tests/common/scenes/SaveLayerAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/SaveLayerAnimation.cpp
@@ -45,7 +45,7 @@ public:
canvas.save(SaveFlags::MatrixClip);
canvas.translate(0, 400);
canvas.saveLayerAlpha(100, 100, 300, 300, 128, SaveFlags::Flags(0)); // unclipped
- SkPaint paint;
+ Paint paint;
paint.setAntiAlias(true);
paint.setColor(Color::Green_700);
canvas.drawCircle(200, 200, 200, paint);
diff --git a/libs/hwui/tests/common/scenes/ShapeAnimation.cpp b/libs/hwui/tests/common/scenes/ShapeAnimation.cpp
index d189a9379c33..70a1557dcf6a 100644
--- a/libs/hwui/tests/common/scenes/ShapeAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/ShapeAnimation.cpp
@@ -30,14 +30,14 @@ public:
void createContent(int width, int height, Canvas& canvas) override {
card = TestUtils::createNode(
0, 0, width, height, [width](RenderProperties& props, Canvas& canvas) {
- std::function<void(Canvas&, float, const SkPaint&)> ops[] = {
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ std::function<void(Canvas&, float, const Paint&)> ops[] = {
+ [](Canvas& canvas, float size, const Paint& paint) {
canvas.drawArc(0, 0, size, size, 50, 189, true, paint);
},
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ [](Canvas& canvas, float size, const Paint& paint) {
canvas.drawOval(0, 0, size, size, paint);
},
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ [](Canvas& canvas, float size, const Paint& paint) {
SkPath diamondPath;
diamondPath.moveTo(size / 2, 0);
diamondPath.lineTo(size, size / 2);
@@ -46,18 +46,18 @@ public:
diamondPath.close();
canvas.drawPath(diamondPath, paint);
},
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ [](Canvas& canvas, float size, const Paint& paint) {
float data[] = {0, 0, size, size, 0, size, size, 0};
canvas.drawLines(data, sizeof(data) / sizeof(float), paint);
},
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ [](Canvas& canvas, float size, const Paint& paint) {
float data[] = {0, 0, size, size, 0, size, size, 0};
canvas.drawPoints(data, sizeof(data) / sizeof(float), paint);
},
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ [](Canvas& canvas, float size, const Paint& paint) {
canvas.drawRect(0, 0, size, size, paint);
},
- [](Canvas& canvas, float size, const SkPaint& paint) {
+ [](Canvas& canvas, float size, const Paint& paint) {
float rad = size / 4;
canvas.drawRoundRect(0, 0, size, size, rad, rad, paint);
}};
@@ -66,7 +66,7 @@ public:
// each combination of strokeWidth + style gets a column
int outerCount = canvas.save(SaveFlags::MatrixClip);
- SkPaint paint;
+ Paint paint;
paint.setAntiAlias(true);
SkPaint::Style styles[] = {SkPaint::kStroke_Style, SkPaint::kFill_Style,
SkPaint::kStrokeAndFill_Style};
diff --git a/libs/hwui/tests/common/scenes/SimpleColorMatrixAnimation.cpp b/libs/hwui/tests/common/scenes/SimpleColorMatrixAnimation.cpp
index ff0cb3705cb8..a0bc5aa245d5 100644
--- a/libs/hwui/tests/common/scenes/SimpleColorMatrixAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/SimpleColorMatrixAnimation.cpp
@@ -52,21 +52,13 @@ private:
return TestUtils::createNode(
x, y, x + width, y + height,
[width, height](RenderProperties& props, Canvas& canvas) {
- SkPaint paint;
- float matrix[20] = {0};
-
+ Paint paint;
// Simple scale/translate case where R, G, and B are all treated equivalently
- matrix[SkColorMatrix::kR_Scale] = 1.1f;
- matrix[SkColorMatrix::kG_Scale] = 1.1f;
- matrix[SkColorMatrix::kB_Scale] = 1.1f;
- matrix[SkColorMatrix::kA_Scale] = 0.5f;
-
- matrix[SkColorMatrix::kR_Trans] = 5.0f;
- matrix[SkColorMatrix::kG_Trans] = 5.0f;
- matrix[SkColorMatrix::kB_Trans] = 5.0f;
- matrix[SkColorMatrix::kA_Trans] = 10.0f;
+ SkColorMatrix cm;
+ cm.setScale(1.1f, 1.1f, 1.1f, 0.5f);
+ cm.postTranslate(5.0f/255, 5.0f/255, 5.0f/255, 10.0f/255);
- paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
+ paint.setColorFilter(SkColorFilters::Matrix(cm));
// set a shader so it's not likely for the matrix to be optimized away (since a
// clever
@@ -75,7 +67,7 @@ private:
SkPoint pts[] = {SkPoint::Make(0, 0), SkPoint::Make(width, height)};
SkColor colors[2] = {Color::DeepPurple_500, Color::DeepOrange_500};
paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, 2,
- SkShader::kClamp_TileMode));
+ SkTileMode::kClamp));
// overdraw several times to emphasize shader cost
for (int i = 0; i < 10; i++) {
diff --git a/libs/hwui/tests/common/scenes/SimpleGradientAnimation.cpp b/libs/hwui/tests/common/scenes/SimpleGradientAnimation.cpp
index 016c65c17c4c..57a260c8d234 100644
--- a/libs/hwui/tests/common/scenes/SimpleGradientAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/SimpleGradientAnimation.cpp
@@ -51,13 +51,13 @@ private:
[width, height](RenderProperties& props, Canvas& canvas) {
float pos[] = {0, 1};
SkPoint pts[] = {SkPoint::Make(0, 0), SkPoint::Make(width, height)};
- SkPaint paint;
+ Paint paint;
// overdraw several times to emphasize shader cost
for (int i = 0; i < 10; i++) {
// use i%2 start position to pick 2 color combo with black in it
SkColor colors[3] = {Color::Transparent, Color::Black, Color::Cyan_500};
paint.setShader(SkGradientShader::MakeLinear(pts, colors + (i % 2), pos, 2,
- SkShader::kClamp_TileMode));
+ SkTileMode::kClamp));
canvas.drawRect(i, i, width, height, paint);
}
});
diff --git a/libs/hwui/tests/common/scenes/TestSceneBase.h b/libs/hwui/tests/common/scenes/TestSceneBase.h
index 6f76a502ae3e..24d35857c60d 100644
--- a/libs/hwui/tests/common/scenes/TestSceneBase.h
+++ b/libs/hwui/tests/common/scenes/TestSceneBase.h
@@ -17,6 +17,7 @@
#pragma once
#include "hwui/Canvas.h"
+#include "hwui/Paint.h"
#include "RenderNode.h"
#include "tests/common/TestContext.h"
#include "tests/common/TestScene.h"
diff --git a/libs/hwui/tests/common/scenes/TvApp.cpp b/libs/hwui/tests/common/scenes/TvApp.cpp
index 229c7f392629..bac887053d2f 100644
--- a/libs/hwui/tests/common/scenes/TvApp.cpp
+++ b/libs/hwui/tests/common/scenes/TvApp.cpp
@@ -217,9 +217,9 @@ private:
std::unique_ptr<Canvas> canvas(Canvas::create_recording_canvas(
image->stagingProperties().getWidth(), image->stagingProperties().getHeight(),
image.get()));
- SkPaint paint;
+ Paint paint;
sk_sp<SkColorFilter> filter(
- SkColorFilter::MakeModeFilter((curFrame % 150) << 24, SkBlendMode::kSrcATop));
+ SkColorFilters::Blend((curFrame % 150) << 24, SkBlendMode::kSrcATop));
paint.setColorFilter(filter);
sk_sp<Bitmap> bitmap = mCachedBitmaps[ci];
canvas->drawBitmap(*bitmap, 0, 0, &paint);
diff --git a/libs/hwui/tests/macrobench/TestSceneRunner.cpp b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
index 9c845f04e820..801cb7d9e8c5 100644
--- a/libs/hwui/tests/macrobench/TestSceneRunner.cpp
+++ b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
@@ -109,16 +109,14 @@ void outputBenchmarkReport(const TestScene::Info& info, const TestScene::Options
void run(const TestScene::Info& info, const TestScene::Options& opts,
benchmark::BenchmarkReporter* reporter) {
- // Switch to the real display
- gDisplay = getInternalDisplay();
-
Properties::forceDrawFrame = true;
TestContext testContext;
testContext.setRenderOffscreen(opts.renderOffscreen);
// create the native surface
- const int width = gDisplay.w;
- const int height = gDisplay.h;
+ const ui::Size& resolution = getActiveDisplayResolution();
+ const int width = resolution.getWidth();
+ const int height = resolution.getHeight();
sp<Surface> surface = testContext.surface();
std::unique_ptr<TestScene> scene(info.createScene(opts));
@@ -133,7 +131,7 @@ void run(const TestScene::Info& info, const TestScene::Options& opts,
ContextFactory factory;
std::unique_ptr<RenderProxy> proxy(new RenderProxy(false, rootNode.get(), &factory));
proxy->loadSystemProperties();
- proxy->setSurface(surface);
+ proxy->setSurface(surface.get());
float lightX = width / 2.0;
proxy->setLightAlpha(255 * 0.075, 255 * 0.15);
proxy->setLightGeometry((Vector3){lightX, dp(-200.0f), dp(800.0f)}, dp(800.0f));
@@ -146,7 +144,7 @@ void run(const TestScene::Info& info, const TestScene::Options& opts,
}
for (int i = 0; i < warmupFrameCount; i++) {
testContext.waitForVsync();
- nsecs_t vsync = systemTime(CLOCK_MONOTONIC);
+ nsecs_t vsync = systemTime(SYSTEM_TIME_MONOTONIC);
UiFrameInfoBuilder(proxy->frameInfo()).setVsync(vsync, vsync);
proxy->syncAndDrawFrame();
}
@@ -161,10 +159,10 @@ void run(const TestScene::Info& info, const TestScene::Options& opts,
ModifiedMovingAverage<double> avgMs(opts.reportFrametimeWeight);
- nsecs_t start = systemTime(CLOCK_MONOTONIC);
+ nsecs_t start = systemTime(SYSTEM_TIME_MONOTONIC);
for (int i = 0; i < opts.count; i++) {
testContext.waitForVsync();
- nsecs_t vsync = systemTime(CLOCK_MONOTONIC);
+ nsecs_t vsync = systemTime(SYSTEM_TIME_MONOTONIC);
{
ATRACE_NAME("UI-Draw Frame");
UiFrameInfoBuilder(proxy->frameInfo()).setVsync(vsync, vsync);
@@ -173,7 +171,7 @@ void run(const TestScene::Info& info, const TestScene::Options& opts,
}
if (opts.reportFrametimeWeight) {
proxy->fence();
- nsecs_t done = systemTime(CLOCK_MONOTONIC);
+ nsecs_t done = systemTime(SYSTEM_TIME_MONOTONIC);
avgMs.add((done - vsync) / 1000000.0);
if (i % 10 == 9) {
printf("Average frametime %.3fms\n", avgMs.average());
@@ -181,7 +179,7 @@ void run(const TestScene::Info& info, const TestScene::Options& opts,
}
}
proxy->fence();
- nsecs_t end = systemTime(CLOCK_MONOTONIC);
+ nsecs_t end = systemTime(SYSTEM_TIME_MONOTONIC);
if (reporter) {
outputBenchmarkReport(info, opts, reporter, proxy.get(), (end - start) / (double)s2ns(1));
diff --git a/libs/hwui/tests/microbench/DisplayListCanvasBench.cpp b/libs/hwui/tests/microbench/DisplayListCanvasBench.cpp
index 70423a70157b..4ce6c32470ea 100644
--- a/libs/hwui/tests/microbench/DisplayListCanvasBench.cpp
+++ b/libs/hwui/tests/microbench/DisplayListCanvasBench.cpp
@@ -18,6 +18,7 @@
#include "DisplayList.h"
#include "hwui/Canvas.h"
+#include "hwui/Paint.h"
#include "pipeline/skia/SkiaDisplayList.h"
#include "tests/common/TestUtils.h"
@@ -93,7 +94,7 @@ void BM_DisplayListCanvas_record_simpleBitmapView(benchmark::State& benchState)
std::unique_ptr<Canvas> canvas(Canvas::create_recording_canvas(100, 100));
delete canvas->finishRecording();
- SkPaint rectPaint;
+ Paint rectPaint;
sk_sp<Bitmap> iconBitmap(TestUtils::createBitmap(80, 80));
while (benchState.KeepRunning()) {
diff --git a/libs/hwui/tests/microbench/main.cpp b/libs/hwui/tests/microbench/main.cpp
index b5abf5bc5efa..9c4d25968d60 100644
--- a/libs/hwui/tests/microbench/main.cpp
+++ b/libs/hwui/tests/microbench/main.cpp
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-#include "debug/GlesDriver.h"
-#include "debug/NullGlesDriver.h"
-
#include "hwui/Typeface.h"
#include <benchmark/benchmark.h>
@@ -24,10 +21,8 @@
#include <memory>
using namespace android;
-using namespace android::uirenderer;
int main(int argc, char** argv) {
- debug::GlesDriver::replace(std::make_unique<debug::NullGlesDriver>());
benchmark::Initialize(&argc, argv);
Typeface::setRobotoTypefaceForTest();
benchmark::RunSpecifiedBenchmarks();
diff --git a/libs/hwui/tests/scripts/skp-capture.sh b/libs/hwui/tests/scripts/skp-capture.sh
index 54fa22929586..4b46fbf86818 100755
--- a/libs/hwui/tests/scripts/skp-capture.sh
+++ b/libs/hwui/tests/scripts/skp-capture.sh
@@ -4,6 +4,12 @@
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+#
+# Before this can be used, the device must be rooted and the filesystem must be writable by Skia
+# - These steps are necessary once after flashing to enable capture -
+# adb root
+# adb remount
+# adb reboot
if [ -z "$1" ]; then
printf 'Usage:\n skp-capture.sh PACKAGE_NAME OPTIONAL_FRAME_COUNT\n\n'
@@ -20,20 +26,27 @@ if ! command -v adb > /dev/null 2>&1; then
exit 2
fi
fi
-phase1_timeout_seconds=15
-phase2_timeout_seconds=60
+phase1_timeout_seconds=60
+phase2_timeout_seconds=300
package="$1"
-filename="$(date '+%H%M%S').skp"
+extension="skp"
+if (( "$2" > 1 )); then # 2nd arg is number of frames
+ extension="mskp" # use different extension for multi frame files.
+fi
+filename="$(date '+%H%M%S').${extension}"
remote_path="/data/data/${package}/cache/${filename}"
local_path_prefix="$(date '+%Y-%m-%d_%H%M%S')_${package}"
-local_path="${local_path_prefix}.skp"
+local_path="${local_path_prefix}.${extension}"
enable_capture_key='debug.hwui.capture_skp_enabled'
enable_capture_value=$(adb shell "getprop '${enable_capture_key}'")
-#printf 'captureflag=' "$enable_capture_value" '\n'
+
+# TODO(nifong): check if filesystem is writable here with "avbctl get-verity"
+# result will either start with "verity is disabled" or "verity is enabled"
+
if [ -z "$enable_capture_value" ]; then
- printf 'Capture SKP property need to be enabled first. Please use\n'
- printf "\"adb shell setprop debug.hwui.capture_skp_enabled true\" and then restart\n"
- printf "the process.\n\n"
+ printf 'debug.hwui.capture_skp_enabled was found to be disabled, enabling it now.\n'
+ printf " restart the process you want to capture on the device, then retry this script.\n\n"
+ adb shell "setprop '${enable_capture_key}' true"
exit 1
fi
if [ ! -z "$2" ]; then
@@ -57,12 +70,18 @@ banner() {
printf ' %s' "$*"
printf '\n=====================\n'
}
-banner '...WAITING...'
-adb_test_exist() {
- test '0' = "$(adb shell "test -e \"$1\"; echo \$?")";
+banner '...WAITING FOR APP INTERACTION...'
+# Waiting for nonzero file is an indication that the pipeline has both opened the file and written
+# the header. With multiple frames this does not occur until the last frame has been recorded,
+# so we continue to show the "waiting for app interaction" message as long as the app still requires
+# interaction to draw more frames.
+adb_test_file_nonzero() {
+ # grab first byte of `du` output
+ X="$(adb shell "du \"$1\" 2> /dev/null | dd bs=1 count=1 2> /dev/null")"
+ test "$X" && test "$X" -ne 0
}
timeout=$(( $(date +%s) + $phase1_timeout_seconds))
-while ! adb_test_exist "$remote_path"; do
+while ! adb_test_file_nonzero "$remote_path"; do
spin 0.05
if [ $(date +%s) -gt $timeout ] ; then
printf '\bTimed out.\n'
@@ -72,20 +91,27 @@ while ! adb_test_exist "$remote_path"; do
done
printf '\b'
-#read -n1 -r -p "Press any key to continue..." key
+# Disable further capturing
+adb shell "setprop '${filename_key}' ''"
banner '...SAVING...'
-adb_test_file_nonzero() {
- # grab first byte of `du` output
- X="$(adb shell "du \"$1\" 2> /dev/null | dd bs=1 count=1 2> /dev/null")"
- test "$X" && test "$X" -ne 0
+# return the size of a file in bytes
+adb_filesize() {
+ adb shell "wc -c \"$1\"" 2> /dev/null | awk '{print $1}'
}
-#adb_filesize() {
-# adb shell "wc -c \"$1\"" 2> /dev/null | awk '{print $1}'
-#}
timeout=$(( $(date +%s) + $phase2_timeout_seconds))
-while ! adb_test_file_nonzero "$remote_path"; do
+last_size='0' # output of last size check command
+unstable=true # false once the file size stops changing
+counter=0 # used to perform size check only 1/sec though we update spinner 20/sec
+# loop until the file size is unchanged for 1 second.
+while [ $unstable != 0 ] ; do
spin 0.05
+ counter=$(( $counter+1 ))
+ if ! (( $counter % 20)) ; then
+ new_size=$(adb_filesize "$remote_path")
+ unstable=$(($(adb_filesize "$remote_path") != last_size))
+ last_size=$new_size
+ fi
if [ $(date +%s) -gt $timeout ] ; then
printf '\bTimed out.\n'
adb shell "setprop '${filename_key}' ''"
@@ -94,7 +120,7 @@ while ! adb_test_file_nonzero "$remote_path"; do
done
printf '\b'
-adb shell "setprop '${filename_key}' ''"
+printf "SKP file serialized: %s\n" $(echo $last_size | numfmt --to=iec)
i=0; while [ $i -lt 10 ]; do spin 0.10; i=$(($i + 1)); done; echo
@@ -105,12 +131,4 @@ if ! [ -f "$local_path" ] ; then
fi
adb shell rm "$remote_path"
printf '\nSKP saved to file:\n %s\n\n' "$local_path"
-if [ ! -z "$2" ]; then
- bridge="_"
- adb shell "setprop 'debug.hwui.capture_skp_frames' ''"
- for i in $(seq 2 $2); do
- adb pull "${remote_path}_${i}" "${local_path_prefix}_${i}.skp"
- adb shell rm "${remote_path}_${i}"
- done
-fi
diff --git a/libs/hwui/tests/unit/ABitmapTests.cpp b/libs/hwui/tests/unit/ABitmapTests.cpp
new file mode 100644
index 000000000000..8e2f7e09d406
--- /dev/null
+++ b/libs/hwui/tests/unit/ABitmapTests.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include "android/graphics/bitmap.h"
+#include "apex/TypeCast.h"
+#include "hwui/Bitmap.h"
+#include "tests/common/TestUtils.h"
+
+using namespace android;
+using namespace android::uirenderer;
+
+TEST(ABitmap, notifyPixelsChanged) {
+ // generate a bitmap and its public API handle
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(1, 1));
+ ABitmap* abmp = android::TypeCast::toABitmap(bitmap.get());
+
+ // verify that notification changes the genID
+ uint32_t genID = bitmap->getGenerationID();
+ ABitmap_notifyPixelsChanged(abmp);
+ ASSERT_TRUE(bitmap->getGenerationID() != genID);
+
+ // mark the bitmap as immutable
+ ASSERT_FALSE(bitmap->isImmutable());
+ bitmap->setImmutable();
+ ASSERT_TRUE(bitmap->isImmutable());
+
+ // attempt to notify that the pixels have changed
+ genID = bitmap->getGenerationID();
+ ABitmap_notifyPixelsChanged(abmp);
+ ASSERT_TRUE(bitmap->getGenerationID() == genID);
+}
diff --git a/libs/hwui/tests/unit/CacheManagerTests.cpp b/libs/hwui/tests/unit/CacheManagerTests.cpp
index 3f1ef93c878c..c83a3c88cbdd 100644
--- a/libs/hwui/tests/unit/CacheManagerTests.cpp
+++ b/libs/hwui/tests/unit/CacheManagerTests.cpp
@@ -33,7 +33,8 @@ static size_t getCacheUsage(GrContext* grContext) {
}
RENDERTHREAD_SKIA_PIPELINE_TEST(CacheManager, trimMemory) {
- DisplayInfo displayInfo = DeviceInfo::get()->displayInfo();
+ int32_t width = DeviceInfo::get()->getWidth();
+ int32_t height = DeviceInfo::get()->getHeight();
GrContext* grContext = renderThread.getGrContext();
ASSERT_TRUE(grContext != nullptr);
@@ -42,7 +43,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(CacheManager, trimMemory) {
std::vector<sk_sp<SkSurface>> surfaces;
while (getCacheUsage(grContext) <= renderThread.cacheManager().getBackgroundCacheSize()) {
- SkImageInfo info = SkImageInfo::MakeA8(displayInfo.w, displayInfo.h);
+ SkImageInfo info = SkImageInfo::MakeA8(width, height);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(grContext, SkBudgeted::kYes, info);
surface->getCanvas()->drawColor(SK_AlphaTRANSPARENT);
@@ -52,8 +53,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(CacheManager, trimMemory) {
}
// create an image and pin it so that we have something with a unique key in the cache
- sk_sp<Bitmap> bitmap =
- Bitmap::allocateHeapBitmap(SkImageInfo::MakeA8(displayInfo.w, displayInfo.h));
+ sk_sp<Bitmap> bitmap = Bitmap::allocateHeapBitmap(SkImageInfo::MakeA8(width, height));
sk_sp<SkImage> image = bitmap->makeImage();
ASSERT_TRUE(SkImage_pinAsTexture(image.get(), grContext));
diff --git a/libs/hwui/tests/unit/FatVectorTests.cpp b/libs/hwui/tests/unit/FatVectorTests.cpp
index 8523e6c9e973..6585a6249b44 100644
--- a/libs/hwui/tests/unit/FatVectorTests.cpp
+++ b/libs/hwui/tests/unit/FatVectorTests.cpp
@@ -15,7 +15,7 @@
*/
#include <gtest/gtest.h>
-#include <utils/FatVector.h>
+#include <ui/FatVector.h>
#include <tests/common/TestUtils.h>
diff --git a/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp b/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp
deleted file mode 100644
index dac888cd79ca..000000000000
--- a/libs/hwui/tests/unit/GpuMemoryTrackerTests.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <GpuMemoryTracker.h>
-#include <gtest/gtest.h>
-
-#include "renderthread/EglManager.h"
-#include "renderthread/RenderThread.h"
-#include "tests/common/TestUtils.h"
-
-#include <utils/StrongPointer.h>
-
-using namespace android;
-using namespace android::uirenderer;
-using namespace android::uirenderer::renderthread;
-
-class TestGPUObject : public GpuMemoryTracker {
-public:
- TestGPUObject() : GpuMemoryTracker(GpuObjectType::Texture) {}
-
- void changeSize(int newSize) { notifySizeChanged(newSize); }
-};
-
-// Other tests may have created a renderthread and EGL context.
-// This will destroy the EGLContext on RenderThread if it exists so that the
-// current thread can spoof being a GPU thread
-static void destroyEglContext() {
- if (TestUtils::isRenderThreadRunning()) {
- TestUtils::runOnRenderThread([](RenderThread& thread) { thread.destroyRenderingContext(); });
- }
-}
-
-TEST(GpuMemoryTracker, sizeCheck) {
- destroyEglContext();
-
- GpuMemoryTracker::onGpuContextCreated();
- ASSERT_EQ(0, GpuMemoryTracker::getTotalSize(GpuObjectType::Texture));
- ASSERT_EQ(0, GpuMemoryTracker::getInstanceCount(GpuObjectType::Texture));
- {
- TestGPUObject myObj;
- ASSERT_EQ(1, GpuMemoryTracker::getInstanceCount(GpuObjectType::Texture));
- myObj.changeSize(500);
- ASSERT_EQ(500, GpuMemoryTracker::getTotalSize(GpuObjectType::Texture));
- myObj.changeSize(1000);
- ASSERT_EQ(1000, GpuMemoryTracker::getTotalSize(GpuObjectType::Texture));
- myObj.changeSize(300);
- ASSERT_EQ(300, GpuMemoryTracker::getTotalSize(GpuObjectType::Texture));
- }
- ASSERT_EQ(0, GpuMemoryTracker::getTotalSize(GpuObjectType::Texture));
- ASSERT_EQ(0, GpuMemoryTracker::getInstanceCount(GpuObjectType::Texture));
- GpuMemoryTracker::onGpuContextDestroyed();
-}
diff --git a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
index c813cd945905..3632be06c45f 100644
--- a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
+++ b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
@@ -24,6 +24,7 @@
#include "DamageAccumulator.h"
#include "FatalTestCanvas.h"
#include "IContextFactory.h"
+#include "hwui/Paint.h"
#include "RecordingCanvas.h"
#include "SkiaCanvas.h"
#include "pipeline/skia/SkiaDisplayList.h"
@@ -59,7 +60,7 @@ TEST(RenderNodeDrawable, create) {
namespace {
static void drawOrderedRect(Canvas* canvas, uint8_t expectedDrawOrder) {
- SkPaint paint;
+ Paint paint;
// order put in blue channel, transparent so overlapped content doesn't get rejected
paint.setColor(SkColorSetARGB(1, 0, 0, expectedDrawOrder));
canvas->drawRect(0, 0, 100, 100, paint);
@@ -211,7 +212,7 @@ TEST(RenderNodeDrawable, saveLayerClipAndMatrixRestore) {
ASSERT_EQ(SkRect::MakeLTRB(0, 0, 400, 800), getRecorderClipBounds(recorder));
EXPECT_TRUE(getRecorderMatrix(recorder).isIdentity());
- SkPaint paint;
+ Paint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorGREEN);
recorder.drawRect(0.0f, 400.0f, 400.0f, 800.0f, paint);
@@ -291,7 +292,7 @@ RENDERTHREAD_TEST(RenderNodeDrawable, projectionReorder) {
properties.setTranslationX(SCROLL_X);
properties.setTranslationY(SCROLL_Y);
- SkPaint paint;
+ Paint paint;
paint.setColor(SK_ColorWHITE);
canvas.drawRect(0, 0, 100, 100, paint);
},
@@ -302,7 +303,7 @@ RENDERTHREAD_TEST(RenderNodeDrawable, projectionReorder) {
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
properties.setProjectBackwards(true);
properties.setClipToBounds(false);
- SkPaint paint;
+ Paint paint;
paint.setColor(SK_ColorDKGRAY);
canvas.drawRect(-10, -10, 60, 60, paint);
},
@@ -310,7 +311,7 @@ RENDERTHREAD_TEST(RenderNodeDrawable, projectionReorder) {
auto child = TestUtils::createSkiaNode(
0, 50, 100, 100,
[&projectingRipple](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
+ Paint paint;
paint.setColor(SK_ColorBLUE);
canvas.drawRect(0, 0, 100, 50, paint);
canvas.drawRenderNode(projectingRipple.get());
@@ -375,14 +376,14 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, emptyReceiver) {
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
properties.setProjectBackwards(true);
properties.setClipToBounds(false);
- SkPaint paint;
+ Paint paint;
canvas.drawRect(0, 0, 100, 100, paint);
},
"P");
auto child = TestUtils::createSkiaNode(
0, 0, 100, 100,
[&projectingRipple](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
+ Paint paint;
canvas.drawRect(0, 0, 100, 100, paint);
canvas.drawRenderNode(projectingRipple.get());
},
@@ -483,7 +484,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, projectionHwLayer) {
properties.setTranslationX(SCROLL_X);
properties.setTranslationY(SCROLL_Y);
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, Paint());
},
"B"); // B
auto projectingRipple = TestUtils::createSkiaNode(
@@ -491,14 +492,14 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, projectionHwLayer) {
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
properties.setProjectBackwards(true);
properties.setClipToBounds(false);
- canvas.drawOval(100, 100, 300, 300, SkPaint()); // drawn mostly out of layer bounds
+ canvas.drawOval(100, 100, 300, 300, Paint()); // 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());
+ canvas.drawArc(0, 0, LAYER_WIDTH, LAYER_HEIGHT, 0.0f, 280.0f, true, Paint());
},
"C"); // C
auto parent = TestUtils::createSkiaNode(
@@ -578,7 +579,7 @@ RENDERTHREAD_TEST(RenderNodeDrawable, projectionChildScroll) {
0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
properties.setProjectionReceiver(true);
- canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, SkPaint());
+ canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, Paint());
},
"B"); // B
auto projectingRipple = TestUtils::createSkiaNode(
@@ -591,7 +592,7 @@ RENDERTHREAD_TEST(RenderNodeDrawable, projectionChildScroll) {
properties.setTranslationY(SCROLL_Y);
properties.setProjectBackwards(true);
properties.setClipToBounds(false);
- canvas.drawOval(0, 0, 200, 200, SkPaint());
+ canvas.drawOval(0, 0, 200, 200, Paint());
},
"R"); // R
auto child = TestUtils::createSkiaNode(
@@ -946,7 +947,7 @@ RENDERTHREAD_TEST(RenderNodeDrawable, simple) {
[](RenderProperties& props, SkiaRecordingCanvas& canvas) {
sk_sp<Bitmap> bitmap(TestUtils::createBitmap(25, 25));
canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
- SkPaint());
+ Paint());
canvas.drawBitmap(*bitmap, 10, 10, nullptr);
});
@@ -1022,7 +1023,7 @@ TEST(RenderNodeDrawable, renderNode) {
auto child = TestUtils::createSkiaNode(
10, 10, 110, 110, [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
+ Paint paint;
paint.setColor(SK_ColorWHITE);
canvas.drawRect(0, 0, 100, 100, paint);
});
@@ -1030,7 +1031,7 @@ TEST(RenderNodeDrawable, renderNode) {
auto parent = TestUtils::createSkiaNode(
0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[&child](RenderProperties& props, SkiaRecordingCanvas& canvas) {
- SkPaint paint;
+ Paint paint;
paint.setColor(SK_ColorDKGRAY);
canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
@@ -1065,7 +1066,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, layerComposeQuality) {
auto layerNode = TestUtils::createSkiaNode(
0, 0, LAYER_WIDTH, LAYER_HEIGHT,
[](RenderProperties& properties, SkiaRecordingCanvas& canvas) {
- canvas.drawPaint(SkPaint());
+ canvas.drawPaint(Paint());
});
layerNode->animatorProperties().mutateLayerProperties().setType(LayerType::RenderLayer);
@@ -1096,10 +1097,8 @@ TEST(ReorderBarrierDrawable, testShadowMatrix) {
int getDrawCounter() { return mDrawCounter; }
virtual void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override {
- // expect to draw 2 RenderNodeDrawable, 1 StartReorderBarrierDrawable,
- // 1 EndReorderBarrierDrawable
- mDrawCounter++;
- SkCanvas::onDrawDrawable(drawable, matrix);
+ // Do not expect this to be called. See RecordingCanvas.cpp DrawDrawable for context.
+ EXPECT_TRUE(false);
}
virtual void didTranslate(SkScalar dx, SkScalar dy) override {
@@ -1159,8 +1158,8 @@ TEST(ReorderBarrierDrawable, testShadowMatrix) {
// 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);
- EXPECT_EQ(9, canvas.getDrawCounter());
+ drawable.draw(&canvas);
+ EXPECT_EQ(5, canvas.getDrawCounter());
}
// Draw a vector drawable twice but with different bounds and verify correct bounds are used.
diff --git a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
index df5f45618070..7951537e1525 100644
--- a/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
+++ b/libs/hwui/tests/unit/SkiaBehaviorTests.cpp
@@ -48,14 +48,14 @@ TEST(SkiaBehavior, lightingColorFilter_simplify) {
SkColor observedColor;
SkBlendMode observedMode;
- ASSERT_TRUE(filter->asColorMode(&observedColor, &observedMode));
+ ASSERT_TRUE(filter->asAColorMode(&observedColor, &observedMode));
EXPECT_EQ(0xFF223344, observedColor);
EXPECT_EQ(SkBlendMode::kModulate, observedMode);
}
{
sk_sp<SkColorFilter> failFilter(SkColorMatrixFilter::MakeLightingFilter(0x11223344, 0x1));
- EXPECT_FALSE(failFilter->asColorMode(nullptr, nullptr));
+ EXPECT_FALSE(failFilter->asAColorMode(nullptr, nullptr));
}
}
diff --git a/libs/hwui/tests/unit/SkiaCanvasTests.cpp b/libs/hwui/tests/unit/SkiaCanvasTests.cpp
index f6178aff0c2e..fcc64fdd0be6 100644
--- a/libs/hwui/tests/unit/SkiaCanvasTests.cpp
+++ b/libs/hwui/tests/unit/SkiaCanvasTests.cpp
@@ -16,6 +16,7 @@
#include "tests/common/TestUtils.h"
+#include <hwui/Paint.h>
#include <SkBlurDrawLooper.h>
#include <SkCanvasStateUtils.h>
#include <SkPicture.h>
@@ -32,7 +33,7 @@ TEST(SkiaCanvas, drawShadowLayer) {
// clear to white
canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrc);
- SkPaint paint;
+ Paint paint;
// it is transparent to ensure that we still draw the rect since it has a looper
paint.setColor(SK_ColorTRANSPARENT);
// this is how view's shadow layers are implemented
@@ -78,7 +79,7 @@ TEST(SkiaCanvas, colorSpaceXform) {
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
// Playback to a software sRGB canvas. The result should be fully red.
- canvas.asSkCanvas()->drawPicture(picture);
+ canvas.drawPicture(*picture);
ASSERT_EQ(0xFF0000FF, *skBitmap.getAddr32(0, 0));
}
diff --git a/libs/hwui/tests/unit/SkiaDisplayListTests.cpp b/libs/hwui/tests/unit/SkiaDisplayListTests.cpp
index 6fb164a99ae4..d08aea668b2a 100644
--- a/libs/hwui/tests/unit/SkiaDisplayListTests.cpp
+++ b/libs/hwui/tests/unit/SkiaDisplayListTests.cpp
@@ -208,10 +208,9 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaDisplayList, prepareListAndChildren_vdOffscr
test::TestContext testContext;
testContext.setRenderOffscreen(true);
auto surface = testContext.surface();
- int width, height;
- surface->query(NATIVE_WINDOW_WIDTH, &width);
- surface->query(NATIVE_WINDOW_HEIGHT, &height);
- canvasContext->setSurface(std::move(surface));
+ int width = ANativeWindow_getWidth(surface.get());
+ int height = ANativeWindow_getHeight(surface.get());
+ canvasContext->setSurface(surface.get());
TreeInfo info(TreeInfo::MODE_FULL, *canvasContext.get());
DamageAccumulator damageAccumulator;
diff --git a/libs/hwui/tests/unit/SkiaPipelineTests.cpp b/libs/hwui/tests/unit/SkiaPipelineTests.cpp
index a671bdada09a..e7a889d08cfd 100644
--- a/libs/hwui/tests/unit/SkiaPipelineTests.cpp
+++ b/libs/hwui/tests/unit/SkiaPipelineTests.cpp
@@ -23,12 +23,14 @@
#include "AnimationContext.h"
#include "DamageAccumulator.h"
#include "IContextFactory.h"
+#include "hwui/Paint.h"
#include "SkiaCanvas.h"
#include "pipeline/skia/SkiaDisplayList.h"
#include "pipeline/skia/SkiaOpenGLPipeline.h"
#include "pipeline/skia/SkiaRecordingCanvas.h"
#include "pipeline/skia/SkiaUtils.h"
#include "renderthread/CanvasContext.h"
+#include "tests/common/TestContext.h"
#include "tests/common/TestUtils.h"
#include <gui/BufferItemConsumer.h>
@@ -59,43 +61,10 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrame) {
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);
- });
-
- LayerUpdateQueue layerUpdateQueue;
- SkRect dirty = SkRectMakeLargest();
- std::vector<sp<RenderNode>> renderNodes;
- renderNodes.push_back(redNode);
- bool opaque = true;
- 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
- sp<VectorDrawableRoot> dirtyVD(new VectorDrawableRoot(new VectorDrawable::Group()));
- dirtyVD->mutateProperties()->setScaledSize(5, 5);
- pipeline->getVectorDrawables()->push_back(dirtyVD.get());
- }
-
- // 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, contentDrawBounds, surface,
- SkMatrix::I());
- 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;
+ Paint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
greenPaint.setStyle(SkPaint::kFill_Style);
bottomHalfGreenCanvas.drawRect(0, 1, 2, 2, greenPaint);
@@ -293,7 +262,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, deferRenderNodeScene) {
};
std::vector<sp<RenderNode>> nodes;
- SkPaint transparentPaint;
+ Paint transparentPaint;
transparentPaint.setAlpha(128);
// backdrop
@@ -424,21 +393,50 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, clip_replace) {
EXPECT_EQ(1, surface->canvas()->mDrawCounter);
}
-static sp<Surface> createDummySurface() {
- sp<IGraphicBufferProducer> producer;
- sp<IGraphicBufferConsumer> consumer;
- BufferQueue::createBufferQueue(&producer, &consumer);
- producer->setMaxDequeuedBufferCount(1);
- producer->setAsyncMode(true);
- return new Surface(producer);
-}
-
RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, context_lost) {
- auto surface = createDummySurface();
+ test::TestContext context;
+ auto surface = context.surface();
auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
EXPECT_FALSE(pipeline->isSurfaceReady());
- EXPECT_TRUE(pipeline->setSurface(surface.get(), SwapBehavior::kSwap_default, ColorMode::SRGB, 0));
+ EXPECT_TRUE(pipeline->setSurface(surface.get(), SwapBehavior::kSwap_default));
EXPECT_TRUE(pipeline->isSurfaceReady());
renderThread.destroyRenderingContext();
EXPECT_FALSE(pipeline->isSurfaceReady());
}
+
+RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, pictureCallback) {
+ // create a pipeline and add a picture callback
+ auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread);
+ int callbackCount = 0;
+ pipeline->setPictureCapturedCallback(
+ [&callbackCount](sk_sp<SkPicture>&& picture) { callbackCount += 1; });
+
+ // create basic red frame and render it
+ auto redNode = TestUtils::createSkiaNode(
+ 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) {
+ redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver);
+ });
+ LayerUpdateQueue layerUpdateQueue;
+ SkRect dirty = SkRectMakeLargest();
+ std::vector<sp<RenderNode>> renderNodes;
+ renderNodes.push_back(redNode);
+ bool opaque = true;
+ android::uirenderer::Rect contentDrawBounds(0, 0, 1, 1);
+ auto surface = SkSurface::MakeRasterN32Premul(1, 1);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface,
+ SkMatrix::I());
+
+ // verify the callback was called
+ EXPECT_EQ(1, callbackCount);
+
+ // render a second frame and check the callback count
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface,
+ SkMatrix::I());
+ EXPECT_EQ(2, callbackCount);
+
+ // unset the callback, render another frame, check callback was not invoked
+ pipeline->setPictureCapturedCallback(nullptr);
+ pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface,
+ SkMatrix::I());
+ EXPECT_EQ(2, callbackCount);
+}
diff --git a/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp b/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp
index 635429dea359..eec25c6bd40d 100644
--- a/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp
+++ b/libs/hwui/tests/unit/SkiaRenderPropertiesTests.cpp
@@ -24,6 +24,7 @@
#include "DamageAccumulator.h"
#include "FatalTestCanvas.h"
#include "IContextFactory.h"
+#include "hwui/Paint.h"
#include "SkiaCanvas.h"
#include "pipeline/skia/SkiaDisplayList.h"
#include "pipeline/skia/SkiaPipeline.h"
@@ -60,7 +61,7 @@ static void testProperty(std::function<void(RenderProperties&)> propSetupCallbac
0, 0, CANVAS_WIDTH, CANVAS_HEIGHT,
[propSetupCallback](RenderProperties& props, SkiaRecordingCanvas& canvas) {
propSetupCallback(props);
- SkPaint paint;
+ Paint paint;
paint.setColor(SK_ColorWHITE);
canvas.drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, paint);
});
diff --git a/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp b/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp
deleted file mode 100644
index 0c95fdd42851..000000000000
--- a/libs/hwui/tests/unit/VectorDrawableAtlasTests.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include <GrRectanizer.h>
-#include "pipeline/skia/VectorDrawableAtlas.h"
-#include "tests/common/TestUtils.h"
-
-using namespace android;
-using namespace android::uirenderer;
-using namespace android::uirenderer::renderthread;
-using namespace android::uirenderer::skiapipeline;
-
-RENDERTHREAD_SKIA_PIPELINE_TEST(VectorDrawableAtlas, addGetRemove) {
- 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)
- 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
- for (uint32_t i = 0; i < MAX_RECTS; i++) {
- VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
- if (0 == i) {
- atlasSurface = VDRects[0].surface;
- }
- 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 intersect
- if (atlasSurface.get() == VDRects[i].surface.get()) {
- for (uint32_t j = 0; j < i; j++) {
- if (atlasSurface.get() == VDRects[j].surface.get()) {
- ASSERT_FALSE(VDRects[i].rect.intersect(VDRects[j].rect));
- }
- }
- }
- }
-
- // 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());
-
- // 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);
- ASSERT_EQ(VDRects[i].key, VDRect.key);
- ASSERT_EQ(VDRects[i].surface.get(), VDRect.surface.get());
- ASSERT_EQ(VDRects[i].rect, VDRect.rect);
- 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++) {
- VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
- ASSERT_TRUE(VDRects[i].key != INVALID_ATLAS_KEY);
- ASSERT_EQ(VDRects[i].surface.get(), atlasSurface.get());
- ASSERT_TRUE(VDRects[i].rect.width() == 10 && VDRects[i].rect.height() == 10);
- for (uint32_t j = 0; j < i; j++) {
- ASSERT_FALSE(VDRects[i].rect.intersect(VDRects[j].rect));
- }
- }
-}
-
-RENDERTHREAD_SKIA_PIPELINE_TEST(VectorDrawableAtlas, disallowSharedSurface) {
- 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)
- 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
- 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
- for (uint32_t j = 0; j < i; j++) {
- ASSERT_NE(VDRects[i].surface.get(), VDRects[j].surface.get());
- }
- }
-}
-
-RENDERTHREAD_SKIA_PIPELINE_TEST(VectorDrawableAtlas, repack) {
- 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)
- 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
- for (uint32_t i = 0; i < MAX_RECTS; i++) {
- VDRects[i] = atlas.requestNewEntry(10, 10, renderThread.getGrContext());
- if (0 == i) {
- atlasSurface = VDRects[0].surface;
- }
- ASSERT_TRUE(VDRects[i].key != INVALID_ATLAS_KEY);
- }
-
- 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++) {
- ASSERT_NE(VDRects[i].key, VDRects[0].key);
- ASSERT_EQ(VDRects[i].surface.get(), atlasSurface.get());
- }
-
- // 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);
- atlas.releaseEntry(VDRect.key);
- }
-
- 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++) {
- AtlasEntry entry = atlas.requestNewEntry(4, 4, renderThread.getGrContext());
- ASSERT_TRUE(entry.key != INVALID_ATLAS_KEY);
- }
-
- ASSERT_TRUE(atlas.isFragmented());
-
- atlas.repackIfNeeded(renderThread.getGrContext());
-
- ASSERT_FALSE(atlas.isFragmented());
-} \ No newline at end of file
diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp
index 5db002862fcd..6d4c57413f00 100644
--- a/libs/hwui/tests/unit/VectorDrawableTests.cpp
+++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp
@@ -85,9 +85,9 @@ const static TestData sTestDataSet[] = {
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->arcTo(10.0, 10.0, 0.0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 10.0,
+ outPath->arcTo(10.0, 10.0, 0.0, SkPath::kLarge_ArcSize, SkPathDirection::kCW, 10.0,
10.0);
- outPath->arcTo(10.0, 10.0, 0.0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 20.0,
+ outPath->arcTo(10.0, 10.0, 0.0, SkPath::kLarge_ArcSize, SkPathDirection::kCW, 20.0,
20.0);
}},
@@ -159,7 +159,7 @@ const static TestData sTestDataSet[] = {
},
[](SkPath* outPath) {
outPath->moveTo(300.0, 70.0);
- outPath->arcTo(230.0, 230.0, 0.0, SkPath::kLarge_ArcSize, SkPath::kCCW_Direction,
+ outPath->arcTo(230.0, 230.0, 0.0, SkPath::kLarge_ArcSize, SkPathDirection::kCCW,
301.0, 70.0);
outPath->close();
outPath->moveTo(300.0, 70.0);
@@ -395,7 +395,7 @@ TEST(VectorDrawable, drawPathWithoutIncrementingShaderRefCount) {
bitmap.allocN32Pixels(5, 5, false);
SkCanvas canvas(bitmap);
- sk_sp<SkShader> shader = SkShader::MakeColorShader(SK_ColorBLACK);
+ sk_sp<SkShader> shader = SkShaders::Color(SK_ColorBLACK);
// Initial ref count is 1
EXPECT_TRUE(shader->unique());
diff --git a/libs/hwui/tests/unit/main.cpp b/libs/hwui/tests/unit/main.cpp
index 83d888c310f0..402cb5814366 100644
--- a/libs/hwui/tests/unit/main.cpp
+++ b/libs/hwui/tests/unit/main.cpp
@@ -18,8 +18,6 @@
#include "gtest/gtest.h"
#include "Properties.h"
-#include "debug/GlesDriver.h"
-#include "debug/NullGlesDriver.h"
#include "hwui/Typeface.h"
#include "tests/common/LeakChecker.h"
@@ -65,7 +63,6 @@ int main(int argc, char* argv[]) {
}
// Replace the default GLES driver
- debug::GlesDriver::replace(std::make_unique<debug::NullGlesDriver>());
Properties::isolatedProcess = true;
// Run the tests