diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/Animator.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 38 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 3 |
4 files changed, 45 insertions, 5 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 6aad5fb..7d4da01 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -102,7 +102,7 @@ static status_t validate_chunk(const ResChunk_header* chunk, if (headerSize >= minSize) { if (headerSize <= size) { if (((headerSize|size)&0x3) == 0) { - if ((ssize_t)size <= (dataEnd-((const uint8_t*)chunk))) { + if ((size_t)size <= (size_t)(dataEnd-((const uint8_t*)chunk))) { return NO_ERROR; } ALOGW("%s data size 0x%x extends beyond resource end %p.", diff --git a/libs/hwui/Animator.cpp b/libs/hwui/Animator.cpp index 6a3003e..a033f86 100644 --- a/libs/hwui/Animator.cpp +++ b/libs/hwui/Animator.cpp @@ -199,13 +199,18 @@ float CanvasPropertyPaintAnimator::getValue() const { return -1; } +static uint8_t to_uint8(float value) { + int c = (int) (value + .5f); + return static_cast<uint8_t>( c < 0 ? 0 : c > 255 ? 255 : c ); +} + void CanvasPropertyPaintAnimator::setValue(float value) { switch (mField) { case STROKE_WIDTH: mProperty->value.setStrokeWidth(value); return; case ALPHA: - mProperty->value.setAlpha(value); + mProperty->value.setAlpha(to_uint8(value)); return; } LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 5a23158..5754536 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -98,6 +98,8 @@ public: bool enableDirtyRegions(EGLSurface surface); + void setTextureAtlas(const sp<GraphicBuffer>& buffer, int64_t* map, size_t mapSize); + private: GlobalContext(); // GlobalContext is never destroyed, method is purposely not implemented @@ -118,6 +120,10 @@ private: bool mCanSetDirtyRegions; EGLSurface mCurrentSurface; + + sp<GraphicBuffer> mAtlasBuffer; + int64_t* mAtlasMap; + size_t mAtlasMapSize; }; GlobalContext* GlobalContext::sContext = 0; @@ -135,7 +141,9 @@ GlobalContext::GlobalContext() , mEglContext(EGL_NO_CONTEXT) , mPBufferSurface(EGL_NO_SURFACE) , mRequestDirtyRegions(load_dirty_regions_property()) - , mCurrentSurface(EGL_NO_SURFACE) { + , mCurrentSurface(EGL_NO_SURFACE) + , mAtlasMap(NULL) + , mAtlasMapSize(0) { mCanSetDirtyRegions = mRequestDirtyRegions; ALOGD("Render dirty regions requested: %s", mRequestDirtyRegions ? "true" : "false"); } @@ -201,9 +209,28 @@ void GlobalContext::createContext() { "Failed to create context, error = %s", egl_error_str()); } +void GlobalContext::setTextureAtlas(const sp<GraphicBuffer>& buffer, + int64_t* map, size_t mapSize) { + + // Already initialized + if (mAtlasBuffer.get()) { + ALOGW("Multiple calls to setTextureAtlas!"); + delete map; + return; + } + + mAtlasBuffer = buffer; + mAtlasMap = map; + mAtlasMapSize = mapSize; + + if (hasContext()) { + usePBufferSurface(); + initAtlas(); + } +} + void GlobalContext::initAtlas() { - // TODO implement - // For now just run without an atlas + Caches::getInstance().assetAtlas.init(mAtlasBuffer, mAtlasMap, mAtlasMapSize); } void GlobalContext::usePBufferSurface() { @@ -533,6 +560,11 @@ void CanvasContext::requireGlContext() { } } +void CanvasContext::setTextureAtlas(const sp<GraphicBuffer>& buffer, + int64_t* map, size_t mapSize) { + GlobalContext::get()->setTextureAtlas(buffer, map, mapSize); +} + } /* namespace renderthread */ } /* namespace uirenderer */ } /* namespace android */ diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index dcb9858..a793d42 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -70,6 +70,9 @@ public: Layer* createRenderLayer(int width, int height); Layer* createTextureLayer(); + ANDROID_API static void setTextureAtlas(const sp<GraphicBuffer>& buffer, + int64_t* map, size_t mapSize); + private: void processLayerUpdates(const Vector<DeferredLayerUpdater*>* layerUpdaters, TreeInfo& info); void prepareTree(TreeInfo& info); |