Merge "Improve time to texture destruction" into oc-dev
am: 1bc0286ef8
Change-Id: I93daab53961a018a2cf8d4e2d4d8300b84bb917e
This commit is contained in:
@@ -223,7 +223,6 @@ void Caches::dumpMemoryUsage(String8 &log) {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Caches::clearGarbage() {
|
void Caches::clearGarbage() {
|
||||||
textureCache.clearGarbage();
|
|
||||||
pathCache.clearGarbage();
|
pathCache.clearGarbage();
|
||||||
patchCache.clearGarbage();
|
patchCache.clearGarbage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,25 +191,14 @@ Texture* TextureCache::get(Bitmap* bitmap) {
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::releaseTexture(uint32_t pixelRefStableID) {
|
bool TextureCache::destroyTexture(uint32_t pixelRefStableID) {
|
||||||
Mutex::Autolock _l(mLock);
|
auto hardwareIter = mHardwareTextures.find(pixelRefStableID);
|
||||||
mGarbage.push_back(pixelRefStableID);
|
if (hardwareIter != mHardwareTextures.end()) {
|
||||||
}
|
hardwareIter->second->deleteTexture();
|
||||||
|
mHardwareTextures.erase(hardwareIter);
|
||||||
void TextureCache::clearGarbage() {
|
return true;
|
||||||
Mutex::Autolock _l(mLock);
|
|
||||||
size_t count = mGarbage.size();
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
uint32_t pixelRefId = mGarbage[i];
|
|
||||||
auto hardwareIter = mHardwareTextures.find(pixelRefId);
|
|
||||||
if (hardwareIter == mHardwareTextures.end()) {
|
|
||||||
mCache.remove(pixelRefId);
|
|
||||||
} else {
|
|
||||||
hardwareIter->second->deleteTexture();
|
|
||||||
mHardwareTextures.erase(hardwareIter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mGarbage.clear();
|
return mCache.remove(pixelRefStableID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::clear() {
|
void TextureCache::clear() {
|
||||||
|
|||||||
@@ -94,14 +94,10 @@ public:
|
|||||||
Texture* get(Bitmap* bitmap);
|
Texture* get(Bitmap* bitmap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the texture associated with the specified pixelRef. This is meant
|
* Removes the texture associated with the specified pixelRef. Must be called from RenderThread
|
||||||
* to be called from threads that are not the EGL context thread.
|
* Returns true if a texture was destroyed, false if no texture with that id was found
|
||||||
*/
|
*/
|
||||||
ANDROID_API void releaseTexture(uint32_t pixelRefStableID);
|
bool destroyTexture(uint32_t pixelRefStableID);
|
||||||
/**
|
|
||||||
* Process deferred removals.
|
|
||||||
*/
|
|
||||||
void clearGarbage();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the cache. This causes all textures to be deleted.
|
* Clears the cache. This causes all textures to be deleted.
|
||||||
@@ -139,9 +135,7 @@ private:
|
|||||||
|
|
||||||
bool mDebugEnabled;
|
bool mDebugEnabled;
|
||||||
|
|
||||||
std::vector<uint32_t> mGarbage;
|
|
||||||
std::unordered_map<uint32_t, std::unique_ptr<Texture>> mHardwareTextures;
|
std::unordered_map<uint32_t, std::unique_ptr<Texture>> mHardwareTextures;
|
||||||
mutable Mutex mLock;
|
|
||||||
}; // class TextureCache
|
}; // class TextureCache
|
||||||
|
|
||||||
}; // namespace uirenderer
|
}; // namespace uirenderer
|
||||||
|
|||||||
@@ -416,9 +416,7 @@ Bitmap::~Bitmap() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (android::uirenderer::Caches::hasInstance()) {
|
android::uirenderer::renderthread::RenderProxy::onBitmapDestroyed(getStableID());
|
||||||
android::uirenderer::Caches::getInstance().textureCache.releaseTexture(getStableID());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bitmap::hasHardwareMipMap() const {
|
bool Bitmap::hasHardwareMipMap() const {
|
||||||
|
|||||||
@@ -122,6 +122,13 @@ void RenderState::flush(Caches::FlushMode mode) {
|
|||||||
mCaches->flush(mode);
|
mCaches->flush(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderState::onBitmapDestroyed(uint32_t pixelRefId) {
|
||||||
|
if (mCaches->textureCache.destroyTexture(pixelRefId)) {
|
||||||
|
glFlush();
|
||||||
|
GL_CHECKPOINT(MODERATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RenderState::setViewport(GLsizei width, GLsizei height) {
|
void RenderState::setViewport(GLsizei width, GLsizei height) {
|
||||||
mViewportWidth = width;
|
mViewportWidth = width;
|
||||||
mViewportHeight = height;
|
mViewportHeight = height;
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
void onVkContextDestroyed();
|
void onVkContextDestroyed();
|
||||||
|
|
||||||
void flush(Caches::FlushMode flushMode);
|
void flush(Caches::FlushMode flushMode);
|
||||||
|
void onBitmapDestroyed(uint32_t pixelRefId);
|
||||||
|
|
||||||
void setViewport(GLsizei width, GLsizei height);
|
void setViewport(GLsizei width, GLsizei height);
|
||||||
void getViewport(GLsizei* outWidth, GLsizei* outHeight);
|
void getViewport(GLsizei* outWidth, GLsizei* outHeight);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "renderthread/EglManager.h"
|
#include "renderthread/EglManager.h"
|
||||||
#include "renderthread/RenderTask.h"
|
#include "renderthread/RenderTask.h"
|
||||||
#include "renderthread/RenderThread.h"
|
#include "renderthread/RenderThread.h"
|
||||||
|
#include "renderstate/RenderState.h"
|
||||||
#include "utils/Macros.h"
|
#include "utils/Macros.h"
|
||||||
#include "utils/TimeUtils.h"
|
#include "utils/TimeUtils.h"
|
||||||
|
|
||||||
@@ -693,6 +694,20 @@ int RenderProxy::copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CREATE_BRIDGE2(onBitmapDestroyed, RenderThread* thread, uint32_t pixelRefId) {
|
||||||
|
args->thread->renderState().onBitmapDestroyed(args->pixelRefId);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderProxy::onBitmapDestroyed(uint32_t pixelRefId) {
|
||||||
|
if (!RenderThread::hasInstance()) return;
|
||||||
|
SETUP_TASK(onBitmapDestroyed);
|
||||||
|
RenderThread& thread = RenderThread::getInstance();
|
||||||
|
args->thread = &thread;
|
||||||
|
args->pixelRefId = pixelRefId;
|
||||||
|
thread.queue(task);
|
||||||
|
}
|
||||||
|
|
||||||
void RenderProxy::post(RenderTask* task) {
|
void RenderProxy::post(RenderTask* task) {
|
||||||
mRenderThread.queue(task);
|
mRenderThread.queue(task);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ public:
|
|||||||
static sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& bitmap);
|
static sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& bitmap);
|
||||||
|
|
||||||
static int copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap);
|
static int copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap);
|
||||||
|
|
||||||
|
static void onBitmapDestroyed(uint32_t pixelRefId);
|
||||||
private:
|
private:
|
||||||
RenderThread& mRenderThread;
|
RenderThread& mRenderThread;
|
||||||
CanvasContext* mContext;
|
CanvasContext* mContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user