diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gui/Surface.cpp | 11 | ||||
-rw-r--r-- | libs/hwui/LayerCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/LayerCache.h | 6 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 11 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 6 | ||||
-rw-r--r-- | libs/rs/rsElement.cpp | 38 | ||||
-rw-r--r-- | libs/rs/rsElement.h | 10 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.cpp | 5 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.h | 1 |
9 files changed, 36 insertions, 54 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 54d04aa..ff45fa3 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -351,13 +351,13 @@ int Surface::query(int what, int* value) const { // ---------------------------------------------------------------------------- -status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn) { +status_t Surface::lock(SurfaceInfo* other, Region* inOutDirtyRegion) { ANativeWindow_Buffer outBuffer; ARect temp; ARect* inOutDirtyBounds = NULL; - if (dirtyIn) { - temp = dirtyIn->getBounds(); + if (inOutDirtyRegion) { + temp = inOutDirtyRegion->getBounds(); inOutDirtyBounds = &temp; } @@ -371,6 +371,11 @@ status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn) { other->format = uint32_t(outBuffer.format); other->bits = outBuffer.bits; } + + if (inOutDirtyRegion) { + inOutDirtyRegion->set( static_cast<Rect const&>(temp) ); + } + return err; } diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 0af0177..5298125 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -162,7 +162,7 @@ bool LayerCache::put(Layer* layer) { // TODO: Use an LRU while (mSize + size > mMaxSize) { size_t position = 0; -#if LAYER_REMOVE_BIGGEST +#if LAYER_REMOVE_BIGGEST_FIRST position = mCache.size() - 1; #endif Layer* victim = mCache.itemAt(position).mLayer; diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h index 63bb824..c14c9ca 100644 --- a/libs/hwui/LayerCache.h +++ b/libs/hwui/LayerCache.h @@ -19,6 +19,7 @@ #include "Debug.h" #include "Layer.h" +#include "Properties.h" #include "utils/SortedList.h" namespace android { @@ -28,11 +29,6 @@ namespace uirenderer { // Defines /////////////////////////////////////////////////////////////////////////////// -// Indicates whether to remove the biggest layers first, or the smaller ones -#define LAYER_REMOVE_BIGGEST 0 -// Textures used by layers must have dimensions multiples of this number -#define LAYER_SIZE 64 - // Debug #if DEBUG_LAYERS #define LAYER_LOGD(...) LOGD(__VA_ARGS__) diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index a0f806a..04f3c58 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1476,10 +1476,10 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, const float width = texture->width; const float height = texture->height; - const float u1 = (srcLeft + 0.5f) / width; - const float v1 = (srcTop + 0.5f) / height; - const float u2 = (srcRight - 0.5f) / width; - const float v2 = (srcBottom - 0.5f) / height; + const float u1 = fmax(0.0f, srcLeft / width); + const float v1 = fmax(0.0f, srcTop / height); + const float u2 = fmin(1.0f, srcRight / width); + const float v2 = fmin(1.0f, srcBottom / height); mCaches.unbindMeshBuffer(); resetDrawTextureTexCoords(u1, v1, u2, v2); @@ -1493,7 +1493,8 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, const float y = (int) floorf(dstTop + mSnapshot->transform->getTranslateY() + 0.5f); GLenum filter = GL_NEAREST; - if (u1 > 0.0f || u2 < 1.0f || v1 > 0.0f || v2 < 1.0f) { + // Enable linear filtering if the source rectangle is scaled + if (srcRight - srcLeft != dstRight - dstLeft || srcBottom - srcTop != dstBottom - dstTop) { filter = GL_LINEAR; } texture->setFilter(filter, filter, true); diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 923978f..5bd0d4f 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -31,6 +31,12 @@ // If turned on, text is interpreted as glyphs instead of UTF-16 #define RENDER_TEXT_AS_GLYPHS 1 +// Indicates whether to remove the biggest layers first, or the smaller ones +#define LAYER_REMOVE_BIGGEST_FIRST 0 + +// Textures used by layers must have dimensions multiples of this number +#define LAYER_SIZE 64 + /** * Debug level for app developers. */ diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp index 36bbdf0..d6ab0da 100644 --- a/libs/rs/rsElement.cpp +++ b/libs/rs/rsElement.cpp @@ -284,6 +284,15 @@ void Element::decRefs(const void *ptr) const { } } +Element::Builder::Builder() { + const uint32_t initialCapacity = 32; + mBuilderElementRefs.setCapacity(initialCapacity); + mBuilderElements.setCapacity(initialCapacity); + mBuilderNameStrings.setCapacity(initialCapacity); + mBuilderNameLengths.setCapacity(initialCapacity); + mBuilderArrays.setCapacity(initialCapacity); +} + void Element::Builder::add(const Element *e, const char *nameStr, uint32_t arraySize) { mBuilderElementRefs.push(ObjectBaseRef<const Element>(e)); mBuilderElements.push(e); @@ -303,41 +312,12 @@ ObjectBaseRef<const Element> Element::Builder::create(Context *rsc) { ElementState::ElementState() { - const uint32_t initialCapacity = 32; - mBuilderElements.setCapacity(initialCapacity); - mBuilderNameStrings.setCapacity(initialCapacity); - mBuilderNameLengths.setCapacity(initialCapacity); - mBuilderArrays.setCapacity(initialCapacity); } ElementState::~ElementState() { rsAssert(!mElements.size()); } -void ElementState::elementBuilderBegin() { - mBuilderElements.clear(); - mBuilderNameStrings.clear(); - mBuilderNameLengths.clear(); - mBuilderArrays.clear(); -} - -void ElementState::elementBuilderAdd(const Element *e, const char *nameStr, uint32_t arraySize) { - mBuilderElements.push(e); - mBuilderNameStrings.push(nameStr); - mBuilderNameLengths.push(strlen(nameStr)); - mBuilderArrays.push(arraySize); - -} - -const Element *ElementState::elementBuilderCreate(Context *rsc) { - return Element::create(rsc, mBuilderElements.size(), - &(mBuilderElements.editArray()[0]), - &(mBuilderNameStrings.editArray()[0]), - mBuilderNameLengths.editArray(), - mBuilderArrays.editArray()); -} - - ///////////////////////////////////////// // diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h index c3ef250..bfdec53 100644 --- a/libs/rs/rsElement.h +++ b/libs/rs/rsElement.h @@ -30,6 +30,7 @@ class Element : public ObjectBase { public: class Builder { public: + Builder(); void add(const Element *e, const char *nameStr, uint32_t arraySize); ObjectBaseRef<const Element> create(Context *rsc); private: @@ -135,17 +136,8 @@ public: ElementState(); ~ElementState(); - void elementBuilderBegin(); - void elementBuilderAdd(const Element *e, const char *nameStr, uint32_t arraySize); - const Element *elementBuilderCreate(Context *rsc); - // Cache of all existing elements. Vector<Element *> mElements; -private: - Vector<const Element *> mBuilderElements; - Vector<const char*> mBuilderNameStrings; - Vector<size_t> mBuilderNameLengths; - Vector<uint32_t> mBuilderArrays; }; diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp index 02a76ab..4d02269 100644 --- a/libs/rs/rsLocklessFifo.cpp +++ b/libs/rs/rsLocklessFifo.cpp @@ -21,11 +21,11 @@ using namespace android; using namespace android::renderscript; -LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0) { +LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0), mInitialized(false) { } LocklessCommandFifo::~LocklessCommandFifo() { - if (!mInShutdown) { + if (!mInShutdown && mInitialized) { shutdown(); } if (mBuffer) { @@ -58,6 +58,7 @@ bool LocklessCommandFifo::init(uint32_t sizeInBytes) { mGet = mBuffer; mEnd = mBuffer + (sizeInBytes) - 1; //dumpState("init"); + mInitialized = true; return true; } diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h index 4962ef6..fa53d40 100644 --- a/libs/rs/rsLocklessFifo.h +++ b/libs/rs/rsLocklessFifo.h @@ -47,6 +47,7 @@ protected: uint8_t * mEnd; uint8_t mSize; bool mInShutdown; + bool mInitialized; Signal mSignalToWorker; Signal mSignalToControl; |