summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/androidfw/ApkAssets.cpp1
-rw-r--r--libs/androidfw/AssetManager2.cpp58
-rw-r--r--libs/androidfw/ResourceTypes.cpp4
-rw-r--r--libs/androidfw/include/androidfw/AssetManager2.h6
-rw-r--r--libs/androidfw/tests/AssetManager2_test.cpp8
-rw-r--r--libs/hwui/DamageAccumulator.cpp8
-rw-r--r--libs/hwui/DisplayListOps.in1
-rw-r--r--libs/hwui/RecordingCanvas.cpp18
-rw-r--r--libs/hwui/RecordingCanvas.h6
-rw-r--r--libs/hwui/SkiaCanvas.cpp2
-rw-r--r--libs/hwui/hwui/Bitmap.cpp2
-rw-r--r--libs/hwui/hwui/MinikinSkia.h2
-rw-r--r--libs/hwui/pipeline/skia/LayerDrawable.cpp25
-rw-r--r--libs/hwui/pipeline/skia/SkiaPipeline.cpp9
-rw-r--r--libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp2
-rw-r--r--libs/hwui/renderthread/CacheManager.cpp11
-rw-r--r--libs/hwui/renderthread/CacheManager.h1
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp44
-rw-r--r--libs/hwui/renderthread/ReliableSurface.cpp2
-rw-r--r--libs/hwui/renderthread/ReliableSurface.h6
-rw-r--r--libs/hwui/service/GraphicsStatsService.cpp6
-rw-r--r--libs/hwui/tests/common/scenes/RectGridAnimation.cpp2
-rw-r--r--libs/input/Android.bp2
-rw-r--r--libs/input/PointerController.cpp6
-rw-r--r--libs/input/SpriteController.cpp51
-rw-r--r--libs/input/SpriteController.h18
-rw-r--r--libs/input/tests/Android.bp2
-rw-r--r--libs/protoutil/include/android/util/ProtoOutputStream.h1
-rw-r--r--libs/protoutil/src/ProtoOutputStream.cpp28
29 files changed, 206 insertions, 126 deletions
diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp
index 9f4a6193b434..cf2ef3070385 100644
--- a/libs/androidfw/ApkAssets.cpp
+++ b/libs/androidfw/ApkAssets.cpp
@@ -116,6 +116,7 @@ std::unique_ptr<const ApkAssets> ApkAssets::LoadImpl(
if (result != 0) {
LOG(ERROR) << "Failed to open APK '" << path << "' " << ::ErrorCodeString(result);
+ ::CloseArchive(unmanaged_handle);
return {};
}
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 01caf011f644..eec49df79630 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -224,6 +224,62 @@ const std::unordered_map<std::string, std::string>*
return &loaded_package->GetOverlayableMap();
}
+bool AssetManager2::GetOverlayablesToString(const android::StringPiece& package_name,
+ std::string* out) const {
+ uint8_t package_id = 0U;
+ for (const auto& apk_assets : apk_assets_) {
+ const LoadedArsc* loaded_arsc = apk_assets->GetLoadedArsc();
+ if (loaded_arsc == nullptr) {
+ continue;
+ }
+
+ const auto& loaded_packages = loaded_arsc->GetPackages();
+ if (loaded_packages.empty()) {
+ continue;
+ }
+
+ const auto& loaded_package = loaded_packages[0];
+ if (loaded_package->GetPackageName() == package_name) {
+ package_id = GetAssignedPackageId(loaded_package.get());
+ break;
+ }
+ }
+
+ if (package_id == 0U) {
+ ANDROID_LOG(ERROR) << base::StringPrintf("No package with name '%s", package_name.data());
+ return false;
+ }
+
+ const size_t idx = package_ids_[package_id];
+ if (idx == 0xff) {
+ return false;
+ }
+
+ std::string output;
+ for (const ConfiguredPackage& package : package_groups_[idx].packages_) {
+ const LoadedPackage* loaded_package = package.loaded_package_;
+ for (auto it = loaded_package->begin(); it != loaded_package->end(); it++) {
+ const OverlayableInfo* info = loaded_package->GetOverlayableInfo(*it);
+ if (info != nullptr) {
+ ResourceName res_name;
+ if (!GetResourceName(*it, &res_name)) {
+ ANDROID_LOG(ERROR) << base::StringPrintf(
+ "Unable to retrieve name of overlayable resource 0x%08x", *it);
+ return false;
+ }
+
+ const std::string name = ToFormattedResourceString(&res_name);
+ output.append(base::StringPrintf(
+ "resource='%s' overlayable='%s' actor='%s' policy='0x%08x'\n",
+ name.c_str(), info->name.c_str(), info->actor.c_str(), info->policy_flags));
+ }
+ }
+ }
+
+ *out = std::move(output);
+ return true;
+}
+
void AssetManager2::SetConfiguration(const ResTable_config& configuration) {
const int diff = configuration_.diff(configuration);
configuration_ = configuration;
@@ -1073,7 +1129,7 @@ void AssetManager2::InvalidateCaches(uint32_t diff) {
}
}
-uint8_t AssetManager2::GetAssignedPackageId(const LoadedPackage* package) {
+uint8_t AssetManager2::GetAssignedPackageId(const LoadedPackage* package) const {
for (auto& package_group : package_groups_) {
for (auto& package2 : package_group.packages_) {
if (package2.loaded_package_ == package) {
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 8a035dbbc0f5..535386920265 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -7402,12 +7402,12 @@ void ResTable::print_value(const Package* pkg, const Res_value& value) const
print_complex(value.data, true);
printf("\n");
} else if (value.dataType >= Res_value::TYPE_FIRST_COLOR_INT
- || value.dataType <= Res_value::TYPE_LAST_COLOR_INT) {
+ && value.dataType <= Res_value::TYPE_LAST_COLOR_INT) {
printf("(color) #%08x\n", value.data);
} else if (value.dataType == Res_value::TYPE_INT_BOOLEAN) {
printf("(boolean) %s\n", value.data ? "true" : "false");
} else if (value.dataType >= Res_value::TYPE_FIRST_INT
- || value.dataType <= Res_value::TYPE_LAST_INT) {
+ && value.dataType <= Res_value::TYPE_LAST_INT) {
printf("(int) 0x%08x or %d\n", value.data, value.data);
} else {
printf("(unknown type) t=0x%02x d=0x%08x (s=0x%04x r=0x%02x)\n",
diff --git a/libs/androidfw/include/androidfw/AssetManager2.h b/libs/androidfw/include/androidfw/AssetManager2.h
index 1e2b36cb1703..de46081a6aa3 100644
--- a/libs/androidfw/include/androidfw/AssetManager2.h
+++ b/libs/androidfw/include/androidfw/AssetManager2.h
@@ -124,6 +124,10 @@ class AssetManager2 {
// This may be nullptr if the APK represented by `cookie` has no resource table.
const DynamicRefTable* GetDynamicRefTableForCookie(ApkAssetsCookie cookie) const;
+ // Returns a string representation of the overlayable API of a package.
+ bool GetOverlayablesToString(const android::StringPiece& package_name,
+ std::string* out) const;
+
const std::unordered_map<std::string, std::string>*
GetOverlayableMapForPackage(uint32_t package_id) const;
@@ -308,7 +312,7 @@ class AssetManager2 {
const ResolvedBag* GetBag(uint32_t resid, std::vector<uint32_t>& child_resids);
// Retrieve the assigned package id of the package if loaded into this AssetManager
- uint8_t GetAssignedPackageId(const LoadedPackage* package);
+ uint8_t GetAssignedPackageId(const LoadedPackage* package) const;
// The ordered list of ApkAssets to search. These are not owned by the AssetManager, and must
// have a longer lifetime.
diff --git a/libs/androidfw/tests/AssetManager2_test.cpp b/libs/androidfw/tests/AssetManager2_test.cpp
index 40c8e46e4d84..15910241518d 100644
--- a/libs/androidfw/tests/AssetManager2_test.cpp
+++ b/libs/androidfw/tests/AssetManager2_test.cpp
@@ -707,7 +707,7 @@ TEST_F(AssetManager2Test, GetLastPathAfterDisablingReturnsEmpty) {
EXPECT_EQ("", resultDisabled);
}
-TEST_F(AssetManager2Test, GetOverlayableMap) {
+TEST_F(AssetManager2Test, GetOverlayablesToString) {
ResTable_config desired_config;
memset(&desired_config, 0, sizeof(desired_config));
@@ -721,6 +721,12 @@ TEST_F(AssetManager2Test, GetOverlayableMap) {
ASSERT_EQ(2, map->size());
ASSERT_EQ(map->at("OverlayableResources1"), "overlay://theme");
ASSERT_EQ(map->at("OverlayableResources2"), "overlay://com.android.overlayable");
+
+ std::string api;
+ ASSERT_TRUE(assetmanager.GetOverlayablesToString("com.android.overlayable", &api));
+ ASSERT_EQ(api.find("not_overlayable"), std::string::npos);
+ ASSERT_NE(api.find("resource='com.android.overlayable:string/overlayable2' overlayable='OverlayableResources1' actor='overlay://theme' policy='0x0000000a'\n"),
+ std::string::npos);
}
} // namespace android
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index 2d2df52073f4..b39f4f20dc0d 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -130,7 +130,7 @@ static inline void mapRect(const Matrix4* matrix, const SkRect& in, SkRect* out)
// calculations. Just give up and expand to DIRTY_MIN/DIRTY_MAX
temp.set(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
}
- out->join(RECT_ARGS(temp));
+ out->join({RECT_ARGS(temp)});
}
void DamageAccumulator::applyMatrix4Transform(DirtyStack* frame) {
@@ -145,7 +145,7 @@ static inline void applyMatrix(const SkMatrix* transform, SkRect* rect) {
// Don't attempt to calculate damage for a perspective transform
// as the numbers this works with can break the perspective
// calculations. Just give up and expand to DIRTY_MIN/DIRTY_MAX
- rect->set(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
+ rect->setLTRB(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
}
}
}
@@ -209,7 +209,7 @@ void DamageAccumulator::applyRenderNodeTransform(DirtyStack* frame) {
// Perform clipping
if (props.getClipDamageToBounds() && !frame->pendingDirty.isEmpty()) {
- if (!frame->pendingDirty.intersect(0, 0, props.getWidth(), props.getHeight())) {
+ if (!frame->pendingDirty.intersect(SkRect::MakeIWH(props.getWidth(), props.getHeight()))) {
frame->pendingDirty.setEmpty();
}
}
@@ -233,7 +233,7 @@ void DamageAccumulator::applyRenderNodeTransform(DirtyStack* frame) {
}
void DamageAccumulator::dirty(float left, float top, float right, float bottom) {
- mHead->pendingDirty.join(left, top, right, bottom);
+ mHead->pendingDirty.join({left, top, right, bottom});
}
void DamageAccumulator::peekAtDirty(SkRect* dest) const {
diff --git a/libs/hwui/DisplayListOps.in b/libs/hwui/DisplayListOps.in
index 2deb5657c877..4a252afc1df3 100644
--- a/libs/hwui/DisplayListOps.in
+++ b/libs/hwui/DisplayListOps.in
@@ -49,3 +49,4 @@ X(DrawVertices)
X(DrawAtlas)
X(DrawShadowRec)
X(DrawVectorDrawable)
+X(DrawWebView)
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index c8eb1ca55910..c0df2faf120a 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -16,6 +16,7 @@
#include "RecordingCanvas.h"
+#include "pipeline/skia/FunctorDrawable.h"
#include "VectorDrawable.h"
#include "SkAndroidFrameworkUtils.h"
@@ -496,6 +497,16 @@ struct DrawVectorDrawable final : Op {
SkPaint paint;
BitmapPalette palette;
};
+struct DrawWebView final : Op {
+ static const auto kType = Type::DrawWebView;
+ DrawWebView(skiapipeline::FunctorDrawable* drawable) : drawable(sk_ref_sp(drawable)) {}
+ sk_sp<skiapipeline::FunctorDrawable> drawable;
+ // We can't invoke SkDrawable::draw directly, because VkFunctorDrawable expects
+ // SkDrawable::onSnapGpuDrawHandler callback instead of SkDrawable::onDraw.
+ // SkCanvas::drawDrawable/SkGpuDevice::drawDrawable has the logic to invoke
+ // onSnapGpuDrawHandler.
+ void draw(SkCanvas* c, const SkMatrix&) const { c->drawDrawable(drawable.get()); }
+};
}
template <typename T, typename... Args>
@@ -680,6 +691,9 @@ void DisplayListData::drawShadowRec(const SkPath& path, const SkDrawShadowRec& r
void DisplayListData::drawVectorDrawable(VectorDrawableRoot* tree) {
this->push<DrawVectorDrawable>(0, tree);
}
+void DisplayListData::drawWebView(skiapipeline::FunctorDrawable* drawable) {
+ this->push<DrawWebView>(0, drawable);
+}
typedef void (*draw_fn)(const void*, SkCanvas*, const SkMatrix&);
typedef void (*void_fn)(const void*);
@@ -986,5 +1000,9 @@ void RecordingCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
fDL->drawVectorDrawable(tree);
}
+void RecordingCanvas::drawWebView(skiapipeline::FunctorDrawable* drawable) {
+ fDL->drawWebView(drawable);
+}
+
} // namespace uirenderer
} // namespace android
diff --git a/libs/hwui/RecordingCanvas.h b/libs/hwui/RecordingCanvas.h
index 16ec877002f7..a79b7c00ba04 100644
--- a/libs/hwui/RecordingCanvas.h
+++ b/libs/hwui/RecordingCanvas.h
@@ -36,6 +36,10 @@
namespace android {
namespace uirenderer {
+namespace skiapipeline {
+class FunctorDrawable;
+}
+
enum class DisplayListOpType : uint8_t {
#define X(T) T,
#include "DisplayListOps.in"
@@ -119,6 +123,7 @@ private:
SkBlendMode, const SkRect*, const SkPaint*);
void drawShadowRec(const SkPath&, const SkDrawShadowRec&);
void drawVectorDrawable(VectorDrawableRoot* tree);
+ void drawWebView(skiapipeline::FunctorDrawable*);
template <typename T, typename... Args>
void* push(size_t, Args&&...);
@@ -203,6 +208,7 @@ public:
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
void drawVectorDrawable(VectorDrawableRoot* tree);
+ void drawWebView(skiapipeline::FunctorDrawable*);
/**
* If "isClipMayBeComplex" returns false, it is guaranteed the current clip is a rectangle.
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 54ac0bd9ff75..23140724ef64 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -163,7 +163,7 @@ static inline SkCanvas::SaveLayerFlags layerFlags(SaveFlags::Flags flags) {
SkCanvas::SaveLayerFlags layerFlags = 0;
if (!(flags & SaveFlags::ClipToLayer)) {
- layerFlags |= SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag;
+ layerFlags |= SkCanvasPriv::kDontClipToLayer_SaveLayerFlag;
}
return layerFlags;
diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp
index a1be5b72a5c5..2ba6fbe76de1 100644
--- a/libs/hwui/hwui/Bitmap.cpp
+++ b/libs/hwui/hwui/Bitmap.cpp
@@ -361,7 +361,7 @@ void Bitmap::getSkBitmap(SkBitmap* outBitmap) {
void Bitmap::getBounds(SkRect* bounds) const {
SkASSERT(bounds);
- bounds->set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
+ bounds->setIWH(width(), height());
}
#ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
diff --git a/libs/hwui/hwui/MinikinSkia.h b/libs/hwui/hwui/MinikinSkia.h
index 90f7d48a47ee..298967689cd9 100644
--- a/libs/hwui/hwui/MinikinSkia.h
+++ b/libs/hwui/hwui/MinikinSkia.h
@@ -20,6 +20,8 @@
#include <SkRefCnt.h>
#include <cutils/compiler.h>
#include <minikin/MinikinFont.h>
+#include <string>
+#include <string_view>
class SkFont;
class SkTypeface;
diff --git a/libs/hwui/pipeline/skia/LayerDrawable.cpp b/libs/hwui/pipeline/skia/LayerDrawable.cpp
index b0173846e582..f839213e9007 100644
--- a/libs/hwui/pipeline/skia/LayerDrawable.cpp
+++ b/libs/hwui/pipeline/skia/LayerDrawable.cpp
@@ -43,41 +43,28 @@ static bool shouldFilterRect(const SkMatrix& matrix, const SkRect& srcRect, cons
if (!matrix.rectStaysRect()) return true;
SkRect dstDevRect = matrix.mapRect(dstRect);
float dstW, dstH;
- bool requiresIntegerTranslate = false;
if (MathUtils::isZero(matrix.getScaleX()) && MathUtils::isZero(matrix.getScaleY())) {
// Has a 90 or 270 degree rotation, although total matrix may also have scale factors
// in m10 and m01. Those scalings are automatically handled by mapRect so comparing
// dimensions is sufficient, but swap width and height comparison.
dstW = dstDevRect.height();
dstH = dstDevRect.width();
- requiresIntegerTranslate = true;
} else {
// Handle H/V flips or 180 rotation matrices. Axes may have been mirrored, but
// dimensions are still safe to compare directly.
dstW = dstDevRect.width();
dstH = dstDevRect.height();
- requiresIntegerTranslate =
- matrix.getScaleX() < -NON_ZERO_EPSILON || matrix.getScaleY() < -NON_ZERO_EPSILON;
}
if (!(MathUtils::areEqual(dstW, srcRect.width()) &&
MathUtils::areEqual(dstH, srcRect.height()))) {
return true;
}
- if (requiresIntegerTranslate) {
- // Device rect and source rect should be integer aligned to ensure there's no difference
- // in how nearest-neighbor sampling is resolved.
- return !(isIntegerAligned(srcRect.x()) &&
- isIntegerAligned(srcRect.y()) &&
- isIntegerAligned(dstDevRect.x()) &&
- isIntegerAligned(dstDevRect.y()));
- } else {
- // As long as src and device rects are translated by the same fractional amount,
- // filtering won't be needed
- return !(MathUtils::areEqual(SkScalarFraction(srcRect.x()),
- SkScalarFraction(dstDevRect.x())) &&
- MathUtils::areEqual(SkScalarFraction(srcRect.y()),
- SkScalarFraction(dstDevRect.y())));
- }
+ // Device rect and source rect should be integer aligned to ensure there's no difference
+ // in how nearest-neighbor sampling is resolved.
+ return !(isIntegerAligned(srcRect.x()) &&
+ isIntegerAligned(srcRect.y()) &&
+ isIntegerAligned(dstDevRect.x()) &&
+ isIntegerAligned(dstDevRect.y()));
}
bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer,
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
index 530926bf8dd0..3010206cdc5b 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -511,13 +511,13 @@ void SkiaPipeline::renderFrameImpl(const LayerUpdateQueue& layers, const SkRect&
}
void SkiaPipeline::dumpResourceCacheUsage() const {
- int resources, maxResources;
- size_t bytes, maxBytes;
+ int resources;
+ size_t bytes;
mRenderThread.getGrContext()->getResourceCacheUsage(&resources, &bytes);
- mRenderThread.getGrContext()->getResourceCacheLimits(&maxResources, &maxBytes);
+ size_t maxBytes = mRenderThread.getGrContext()->getResourceCacheLimit();
SkString log("Resource Cache Usage:\n");
- log.appendf("%8d items out of %d maximum items\n", resources, maxResources);
+ log.appendf("%8d items\n", resources);
log.appendf("%8zu bytes (%.2f MB) out of %.2f MB maximum\n", bytes,
bytes * (1.0f / (1024.0f * 1024.0f)), maxBytes * (1.0f / (1024.0f * 1024.0f)));
@@ -569,6 +569,7 @@ void SkiaPipeline::renderOverdraw(const LayerUpdateQueue& layers, const SkRect&
// Set up the overdraw canvas.
SkImageInfo offscreenInfo = SkImageInfo::MakeA8(surface->width(), surface->height());
sk_sp<SkSurface> offscreen = surface->makeSurface(offscreenInfo);
+ LOG_ALWAYS_FATAL_IF(!offscreen, "Failed to create offscreen SkSurface for overdraw viz.");
SkOverdrawCanvas overdrawCanvas(offscreen->getCanvas());
// Fake a redraw to replay the draw commands. This will increment the alpha channel
diff --git a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
index 0db5133037b0..d67cf8c9c73f 100644
--- a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
+++ b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
@@ -158,7 +158,7 @@ void SkiaRecordingCanvas::drawWebViewFunctor(int functor) {
functorDrawable = mDisplayList->allocateDrawable<GLFunctorDrawable>(functor, asSkCanvas());
}
mDisplayList->mChildFunctors.push_back(functorDrawable);
- drawDrawable(functorDrawable);
+ mRecorder.drawWebView(functorDrawable);
#endif
}
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index 5469a6810c87..dc07f0d84d18 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -39,7 +39,7 @@ namespace renderthread {
// to the screen resolution. This is meant to be a conservative default based on
// that analysis. The 4.0f is used because the default pixel format is assumed to
// be ARGB_8888.
-#define SURFACE_SIZE_MULTIPLIER (12.0f * 4.0f)
+#define SURFACE_SIZE_MULTIPLIER (5.0f * 4.0f)
#define BACKGROUND_RETENTION_PERCENTAGE (0.5f)
CacheManager::CacheManager(const DisplayInfo& display)
@@ -69,8 +69,7 @@ void CacheManager::reset(sk_sp<GrContext> context) {
if (context) {
mGrContext = std::move(context);
- mGrContext->getResourceCacheLimits(&mMaxResources, nullptr);
- mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes);
+ mGrContext->setResourceCacheLimit(mMaxResourceBytes);
}
}
@@ -119,8 +118,8 @@ void CacheManager::trimMemory(TrimMemoryMode mode) {
// limits between the background and max amounts. This causes the unlocked resources
// that have persistent data to be purged in LRU order.
mGrContext->purgeUnlockedResources(true);
- mGrContext->setResourceCacheLimits(mMaxResources, mBackgroundResourceBytes);
- mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes);
+ mGrContext->setResourceCacheLimit(mBackgroundResourceBytes);
+ mGrContext->setResourceCacheLimit(mMaxResourceBytes);
SkGraphics::SetFontCacheLimit(mBackgroundCpuFontCacheBytes);
SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes);
break;
@@ -136,7 +135,7 @@ void CacheManager::trimStaleResources() {
return;
}
mGrContext->flush();
- mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30));
+ mGrContext->performDeferredCleanup(std::chrono::seconds(30));
}
sp<skiapipeline::VectorDrawableAtlas> CacheManager::acquireVectorDrawableAtlas() {
diff --git a/libs/hwui/renderthread/CacheManager.h b/libs/hwui/renderthread/CacheManager.h
index ad251f2364fe..d7977cc4566d 100644
--- a/libs/hwui/renderthread/CacheManager.h
+++ b/libs/hwui/renderthread/CacheManager.h
@@ -71,7 +71,6 @@ private:
sk_sp<GrContext> mGrContext;
#endif
- int mMaxResources = 0;
const size_t mMaxResourceBytes;
const size_t mBackgroundResourceBytes;
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 88a0c6ea3085..93fd0c87a361 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -15,7 +15,17 @@
*/
#include "CanvasContext.h"
+
#include <GpuMemoryTracker.h>
+#include <apex/window.h>
+#include <fcntl.h>
+#include <strings.h>
+#include <sys/stat.h>
+
+#include <algorithm>
+#include <cstdint>
+#include <cstdlib>
+#include <functional>
#include "../Properties.h"
#include "AnimationContext.h"
@@ -32,16 +42,6 @@
#include "utils/TimeUtils.h"
#include "utils/TraceUtils.h"
-#include <strings.h>
-
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <algorithm>
-
-#include <cstdint>
-#include <cstdlib>
-#include <functional>
-
#define TRIM_MEMORY_COMPLETE 80
#define TRIM_MEMORY_UI_HIDDEN 20
@@ -146,7 +146,7 @@ void CanvasContext::setSurface(sp<Surface>&& surface) {
if (surface) {
mNativeSurface = new ReliableSurface{std::move(surface)};
// TODO: Fix error handling & re-shorten timeout
- mNativeSurface->setDequeueTimeout(4000_ms);
+ ANativeWindow_setDequeueTimeout(mNativeSurface.get(), 4000_ms);
mNativeSurface->enableFrameTimestamps(true);
} else {
mNativeSurface = nullptr;
@@ -484,18 +484,16 @@ void CanvasContext::draw() {
swap.swapCompletedTime = systemTime(SYSTEM_TIME_MONOTONIC);
swap.vsyncTime = mRenderThread.timeLord().latestVsync();
if (didDraw) {
- int durationUs;
- nsecs_t dequeueStart = mNativeSurface->getLastDequeueStartTime();
+ nsecs_t dequeueStart = ANativeWindow_getLastDequeueStartTime(mNativeSurface.get());
if (dequeueStart < mCurrentFrameInfo->get(FrameInfoIndex::SyncStart)) {
// Ignoring dequeue duration as it happened prior to frame render start
// and thus is not part of the frame.
swap.dequeueDuration = 0;
} else {
- mNativeSurface->query(NATIVE_WINDOW_LAST_DEQUEUE_DURATION, &durationUs);
- swap.dequeueDuration = us2ns(durationUs);
+ swap.dequeueDuration =
+ ANativeWindow_getLastDequeueDuration(mNativeSurface.get());
}
- mNativeSurface->query(NATIVE_WINDOW_LAST_QUEUE_DURATION, &durationUs);
- swap.queueDuration = us2ns(durationUs);
+ swap.queueDuration = ANativeWindow_getLastQueueDuration(mNativeSurface.get());
} else {
swap.dequeueDuration = 0;
swap.queueDuration = 0;
@@ -648,11 +646,11 @@ void CanvasContext::trimMemory(RenderThread& thread, int level) {
ATRACE_CALL();
if (!thread.getGrContext()) return;
ATRACE_CALL();
- if (level >= TRIM_MEMORY_COMPLETE) {
+ if (level >= TRIM_MEMORY_UI_HIDDEN) {
thread.cacheManager().trimMemory(CacheManager::TrimMemoryMode::Complete);
+ }
+ if (level >= TRIM_MEMORY_COMPLETE) {
thread.destroyRenderingContext();
- } else if (level >= TRIM_MEMORY_UI_HIDDEN) {
- thread.cacheManager().trimMemory(CacheManager::TrimMemoryMode::UiHidden);
}
}
@@ -726,7 +724,7 @@ SkRect CanvasContext::computeDirtyRect(const Frame& frame, SkRect* dirty) {
// New surface needs a full draw
dirty->setEmpty();
} else {
- if (!dirty->isEmpty() && !dirty->intersect(0, 0, frame.width(), frame.height())) {
+ if (!dirty->isEmpty() && !dirty->intersect(SkRect::MakeIWH(frame.width(), frame.height()))) {
ALOGW("Dirty " RECT_STRING " doesn't intersect with 0 0 %d %d ?", SK_RECT_ARGS(*dirty),
frame.width(), frame.height());
dirty->setEmpty();
@@ -735,7 +733,7 @@ SkRect CanvasContext::computeDirtyRect(const Frame& frame, SkRect* dirty) {
}
if (dirty->isEmpty()) {
- dirty->set(0, 0, frame.width(), frame.height());
+ dirty->setIWH(frame.width(), frame.height());
}
// At this point dirty is the area of the window to update. However,
@@ -751,7 +749,7 @@ SkRect CanvasContext::computeDirtyRect(const Frame& frame, SkRect* dirty) {
if (frame.bufferAge() > (int)mSwapHistory.size()) {
// We don't have enough history to handle this old of a buffer
// Just do a full-draw
- dirty->set(0, 0, frame.width(), frame.height());
+ dirty->setIWH(frame.width(), frame.height());
} else {
// At this point we haven't yet added the latest frame
// to the damage history (happens below)
diff --git a/libs/hwui/renderthread/ReliableSurface.cpp b/libs/hwui/renderthread/ReliableSurface.cpp
index a44b80457218..864780fb6ae8 100644
--- a/libs/hwui/renderthread/ReliableSurface.cpp
+++ b/libs/hwui/renderthread/ReliableSurface.cpp
@@ -308,4 +308,4 @@ int ReliableSurface::hook_perform(ANativeWindow* window, int operation, ...) {
return result;
}
-}; // namespace android::uirenderer::renderthread \ No newline at end of file
+}; // namespace android::uirenderer::renderthread
diff --git a/libs/hwui/renderthread/ReliableSurface.h b/libs/hwui/renderthread/ReliableSurface.h
index 7f1a0781dd87..f768df37ba7d 100644
--- a/libs/hwui/renderthread/ReliableSurface.h
+++ b/libs/hwui/renderthread/ReliableSurface.h
@@ -31,16 +31,12 @@ public:
ReliableSurface(sp<Surface>&& surface);
~ReliableSurface();
- void setDequeueTimeout(nsecs_t timeout) { mSurface->setDequeueTimeout(timeout); }
-
int reserveNext();
void allocateBuffers() { mSurface->allocateBuffers(); }
int query(int what, int* value) const { return mSurface->query(what, value); }
- nsecs_t getLastDequeueStartTime() const { return mSurface->getLastDequeueStartTime(); }
-
uint64_t getNextFrameNumber() const { return mSurface->getNextFrameNumber(); }
int getAndClearError() {
@@ -105,4 +101,4 @@ private:
static int hook_queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
};
-}; // namespace android::uirenderer::renderthread \ No newline at end of file
+}; // namespace android::uirenderer::renderthread
diff --git a/libs/hwui/service/GraphicsStatsService.cpp b/libs/hwui/service/GraphicsStatsService.cpp
index 8b5912b2081a..12c5b836f711 100644
--- a/libs/hwui/service/GraphicsStatsService.cpp
+++ b/libs/hwui/service/GraphicsStatsService.cpp
@@ -282,9 +282,9 @@ void dumpAsTextToFd(protos::GraphicsStatsProto* proto, int fd) {
return;
}
dprintf(fd, "\nPackage: %s", proto->package_name().c_str());
- dprintf(fd, "\nVersion: %lld", proto->version_code());
- dprintf(fd, "\nStats since: %lldns", proto->stats_start());
- dprintf(fd, "\nStats end: %lldns", proto->stats_end());
+ dprintf(fd, "\nVersion: %" PRId64, proto->version_code());
+ dprintf(fd, "\nStats since: %" PRId64 "ns", proto->stats_start());
+ dprintf(fd, "\nStats end: %" PRId64 "ns", proto->stats_end());
auto summary = proto->summary();
dprintf(fd, "\nTotal frames rendered: %d", summary.total_frames());
dprintf(fd, "\nJanky frames: %d (%.2f%%)", summary.janky_frames(),
diff --git a/libs/hwui/tests/common/scenes/RectGridAnimation.cpp b/libs/hwui/tests/common/scenes/RectGridAnimation.cpp
index d5ecfaff4f0c..80b5cc191089 100644
--- a/libs/hwui/tests/common/scenes/RectGridAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/RectGridAnimation.cpp
@@ -37,7 +37,7 @@ 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);
}
}
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 16f2917f8df8..6bb896fd7b29 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -20,11 +20,11 @@ cc_library_shared {
],
shared_libs: [
+ "libandroid_runtime",
"libbinder",
"libcutils",
"liblog",
"libutils",
- "libhwui",
"libgui",
"libui",
"libinput",
diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp
index abf083789c23..e4348f2a9b21 100644
--- a/libs/input/PointerController.cpp
+++ b/libs/input/PointerController.cpp
@@ -24,12 +24,6 @@
#include <log/log.h>
-#include <SkBitmap.h>
-#include <SkCanvas.h>
-#include <SkColor.h>
-#include <SkPaint.h>
-#include <SkBlendMode.h>
-
namespace android {
// --- WeakLooperCallback ---
diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp
index fd386e9f7a8a..804644c230b9 100644
--- a/libs/input/SpriteController.cpp
+++ b/libs/input/SpriteController.cpp
@@ -23,11 +23,9 @@
#include <utils/String8.h>
#include <gui/Surface.h>
-#include <SkBitmap.h>
-#include <SkCanvas.h>
-#include <SkColor.h>
-#include <SkPaint.h>
-
+#include <android/graphics/bitmap.h>
+#include <android/graphics/canvas.h>
+#include <android/graphics/paint.h>
#include <android/native_window.h>
namespace android {
@@ -132,8 +130,8 @@ void SpriteController::doUpdateSprites() {
SpriteUpdate& update = updates.editItemAt(i);
if (update.state.surfaceControl == NULL && update.state.wantSurfaceVisible()) {
- update.state.surfaceWidth = update.state.icon.bitmap.width();
- update.state.surfaceHeight = update.state.icon.bitmap.height();
+ update.state.surfaceWidth = update.state.icon.bitmap.getInfo().width;
+ update.state.surfaceHeight = update.state.icon.bitmap.getInfo().height;
update.state.surfaceDrawn = false;
update.state.surfaceVisible = false;
update.state.surfaceControl = obtainSurface(
@@ -154,8 +152,8 @@ void SpriteController::doUpdateSprites() {
}
if (update.state.wantSurfaceVisible()) {
- int32_t desiredWidth = update.state.icon.bitmap.width();
- int32_t desiredHeight = update.state.icon.bitmap.height();
+ int32_t desiredWidth = update.state.icon.bitmap.getInfo().width;
+ int32_t desiredHeight = update.state.icon.bitmap.getInfo().height;
if (update.state.surfaceWidth < desiredWidth
|| update.state.surfaceHeight < desiredHeight) {
needApplyTransaction = true;
@@ -201,26 +199,22 @@ void SpriteController::doUpdateSprites() {
if (status) {
ALOGE("Error %d locking sprite surface before drawing.", status);
} else {
- SkBitmap surfaceBitmap;
- ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
- surfaceBitmap.installPixels(SkImageInfo::MakeN32Premul(outBuffer.width, outBuffer.height),
- outBuffer.bits, bpr);
+ graphics::Paint paint;
+ paint.setBlendMode(ABLEND_MODE_SRC);
- SkCanvas surfaceCanvas(surfaceBitmap);
+ graphics::Canvas canvas(outBuffer, (int32_t) surface->getBuffersDataSpace());
+ canvas.drawBitmap(update.state.icon.bitmap, 0, 0, &paint);
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc);
- surfaceCanvas.drawBitmap(update.state.icon.bitmap, 0, 0, &paint);
+ const int iconWidth = update.state.icon.bitmap.getInfo().width;
+ const int iconHeight = update.state.icon.bitmap.getInfo().height;
- if (outBuffer.width > update.state.icon.bitmap.width()) {
- paint.setColor(0); // transparent fill color
- surfaceCanvas.drawRect(SkRect::MakeLTRB(update.state.icon.bitmap.width(), 0,
- outBuffer.width, update.state.icon.bitmap.height()), paint);
+ if (outBuffer.width > iconWidth) {
+ paint.setBlendMode(ABLEND_MODE_CLEAR); // clear to transparent
+ canvas.drawRect({iconWidth, 0, outBuffer.width, iconHeight}, paint);
}
- if (outBuffer.height > update.state.icon.bitmap.height()) {
- paint.setColor(0); // transparent fill color
- surfaceCanvas.drawRect(SkRect::MakeLTRB(0, update.state.icon.bitmap.height(),
- outBuffer.width, outBuffer.height), paint);
+ if (outBuffer.height > iconHeight) {
+ paint.setBlendMode(ABLEND_MODE_CLEAR); // clear to transparent
+ canvas.drawRect({0, iconHeight, outBuffer.width, outBuffer.height}, paint);
}
status = surface->unlockAndPost();
@@ -398,12 +392,7 @@ void SpriteController::SpriteImpl::setIcon(const SpriteIcon& icon) {
uint32_t dirty;
if (icon.isValid()) {
- SkBitmap* bitmapCopy = &mLocked.state.icon.bitmap;
- if (bitmapCopy->tryAllocPixels(icon.bitmap.info().makeColorType(kN32_SkColorType))) {
- icon.bitmap.readPixels(bitmapCopy->info(), bitmapCopy->getPixels(),
- bitmapCopy->rowBytes(), 0, 0);
- }
-
+ mLocked.state.icon.bitmap = icon.bitmap.copy(ANDROID_BITMAP_FORMAT_RGBA_8888);
if (!mLocked.state.icon.isValid()
|| mLocked.state.icon.hotSpotX != icon.hotSpotX
|| mLocked.state.icon.hotSpotY != icon.hotSpotY) {
diff --git a/libs/input/SpriteController.h b/libs/input/SpriteController.h
index 79a904f5fe65..2513544d4bdf 100644
--- a/libs/input/SpriteController.h
+++ b/libs/input/SpriteController.h
@@ -20,10 +20,9 @@
#include <utils/RefBase.h>
#include <utils/Looper.h>
+#include <android/graphics/bitmap.h>
#include <gui/SurfaceComposerClient.h>
-#include <SkBitmap.h>
-
namespace android {
/*
@@ -56,21 +55,16 @@ struct SpriteTransformationMatrix {
*/
struct SpriteIcon {
inline SpriteIcon() : style(0), hotSpotX(0), hotSpotY(0) { }
- inline SpriteIcon(const SkBitmap& bitmap, int32_t style, float hotSpotX, float hotSpotY) :
+ inline SpriteIcon(const graphics::Bitmap& bitmap, int32_t style, float hotSpotX, float hotSpotY) :
bitmap(bitmap), style(style), hotSpotX(hotSpotX), hotSpotY(hotSpotY) { }
- SkBitmap bitmap;
+ graphics::Bitmap bitmap;
int32_t style;
float hotSpotX;
float hotSpotY;
inline SpriteIcon copy() const {
- SkBitmap bitmapCopy;
- if (bitmapCopy.tryAllocPixels(bitmap.info().makeColorType(kN32_SkColorType))) {
- bitmap.readPixels(bitmapCopy.info(), bitmapCopy.getPixels(), bitmapCopy.rowBytes(),
- 0, 0);
- }
- return SpriteIcon(bitmapCopy, style, hotSpotX, hotSpotY);
+ return SpriteIcon(bitmap.copy(ANDROID_BITMAP_FORMAT_RGBA_8888), style, hotSpotX, hotSpotY);
}
inline void reset() {
@@ -81,7 +75,7 @@ struct SpriteIcon {
}
inline bool isValid() const {
- return !bitmap.isNull() && !bitmap.empty();
+ return bitmap.isValid() && !bitmap.isEmpty();
}
};
@@ -183,7 +177,7 @@ private:
* This structure is designed so that it can be copied during updates so that
* surfaces can be resized and redrawn without blocking the client by holding a lock
* on the sprites for a long time.
- * Note that the SkBitmap holds a reference to a shared (and immutable) pixel ref. */
+ * Note that the SpriteIcon holds a reference to a shared (and immutable) bitmap. */
struct SpriteState {
inline SpriteState() :
dirty(0), visible(false),
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
index e83b2a78d180..b1e3d6fe845a 100644
--- a/libs/input/tests/Android.bp
+++ b/libs/input/tests/Android.bp
@@ -18,9 +18,9 @@ cc_test {
"PointerController_test.cpp",
],
shared_libs: [
+ "libandroid_runtime",
"libinputservice",
"libgui",
- "libhwui",
"libutils",
],
static_libs: [
diff --git a/libs/protoutil/include/android/util/ProtoOutputStream.h b/libs/protoutil/include/android/util/ProtoOutputStream.h
index a6af4757a140..42bf03e6de05 100644
--- a/libs/protoutil/include/android/util/ProtoOutputStream.h
+++ b/libs/protoutil/include/android/util/ProtoOutputStream.h
@@ -98,6 +98,7 @@ public:
bool write(uint64_t fieldId, double val);
bool write(uint64_t fieldId, float val);
bool write(uint64_t fieldId, int val);
+ bool write(uint64_t fieldId, long val);
bool write(uint64_t fieldId, long long val);
bool write(uint64_t fieldId, bool val);
bool write(uint64_t fieldId, std::string val);
diff --git a/libs/protoutil/src/ProtoOutputStream.cpp b/libs/protoutil/src/ProtoOutputStream.cpp
index 6cfa357b580b..ea9b79a0353f 100644
--- a/libs/protoutil/src/ProtoOutputStream.cpp
+++ b/libs/protoutil/src/ProtoOutputStream.cpp
@@ -116,6 +116,34 @@ ProtoOutputStream::write(uint64_t fieldId, int val)
}
bool
+ProtoOutputStream::write(uint64_t fieldId, long val)
+{
+ if (mCompact) return false;
+ const uint32_t id = (uint32_t)fieldId;
+ switch (fieldId & FIELD_TYPE_MASK) {
+ case FIELD_TYPE_DOUBLE: writeDoubleImpl(id, (double)val); break;
+ case FIELD_TYPE_FLOAT: writeFloatImpl(id, (float)val); break;
+ case FIELD_TYPE_INT64: writeInt64Impl(id, (long long)val); break;
+ case FIELD_TYPE_UINT64: writeUint64Impl(id, (uint64_t)val); break;
+ case FIELD_TYPE_INT32: writeInt32Impl(id, (int)val); break;
+ case FIELD_TYPE_FIXED64: writeFixed64Impl(id, (uint64_t)val); break;
+ case FIELD_TYPE_FIXED32: writeFixed32Impl(id, (uint32_t)val); break;
+ case FIELD_TYPE_UINT32: writeUint32Impl(id, (uint32_t)val); break;
+ case FIELD_TYPE_SFIXED32: writeSFixed32Impl(id, (int)val); break;
+ case FIELD_TYPE_SFIXED64: writeSFixed64Impl(id, (long long)val); break;
+ case FIELD_TYPE_SINT32: writeZigzagInt32Impl(id, (int)val); break;
+ case FIELD_TYPE_SINT64: writeZigzagInt64Impl(id, (long long)val); break;
+ case FIELD_TYPE_ENUM: writeEnumImpl(id, (int)val); break;
+ case FIELD_TYPE_BOOL: writeBoolImpl(id, val != 0); break;
+ default:
+ ALOGW("Field type %d is not supported when writing long val.",
+ (int)((fieldId & FIELD_TYPE_MASK) >> FIELD_TYPE_SHIFT));
+ return false;
+ }
+ return true;
+}
+
+bool
ProtoOutputStream::write(uint64_t fieldId, long long val)
{
return internalWrite(fieldId, val, "long long");