diff options
author | Romain Guy <romainguy@google.com> | 2012-05-14 19:44:40 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-05-14 19:44:40 -0700 |
commit | e651cc6239616a202f6e96ebc2ed93b4b8b3627c (patch) | |
tree | 7aa90f8cccc91555bd652d0a88a898a026cdc333 /libs/hwui/DisplayListRenderer.h | |
parent | 99a6ddd4cd8762654a575eb4ac3d0e5431d919b8 (diff) | |
download | frameworks_base-e651cc6239616a202f6e96ebc2ed93b4b8b3627c.zip frameworks_base-e651cc6239616a202f6e96ebc2ed93b4b8b3627c.tar.gz frameworks_base-e651cc6239616a202f6e96ebc2ed93b4b8b3627c.tar.bz2 |
Remove all Dalvik allocations from Cavnas.drawBitmap(int[], ...)
Change-Id: Ie28538a2104d21154fdc78a56525e7403f08287d
Diffstat (limited to 'libs/hwui/DisplayListRenderer.h')
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 5ce770d..2f74f5b 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -91,6 +91,7 @@ public: DrawBitmap, DrawBitmapMatrix, DrawBitmapRect, + DrawBitmapData, DrawBitmapMesh, DrawPatch, DrawColor, @@ -422,6 +423,19 @@ private: return (SkBitmap*) getInt(); } + SkBitmap* getBitmapData() { + SkBitmap* bitmap = new SkBitmap; + bitmap->setConfig((SkBitmap::Config) getInt(), getInt(), getInt()); + if (!bitmap->allocPixels()) { + delete bitmap; + return NULL; + } + + bitmap->setPixels((void*) mReader.skip(bitmap->height() * bitmap->rowBytes())); + + return bitmap; + } + SkiaShader* getShader() { return (SkiaShader*) getInt(); } @@ -574,6 +588,7 @@ public: virtual void drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop, float srcRight, float srcBottom, float dstLeft, float dstTop, float dstRight, float dstBottom, SkPaint* paint); + virtual void drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint); virtual void drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight, float* vertices, int* colors, SkPaint* paint); virtual void drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs, @@ -701,16 +716,23 @@ private: void addInts(const int32_t* values, uint32_t count) { mWriter.writeInt(count); - for (uint32_t i = 0; i < count; i++) { - mWriter.writeInt(values[i]); - } + mWriter.write(values, count * sizeof(int32_t)); + } + + void addBitmapData(SkBitmap* bitmap) { + mWriter.writeInt(bitmap->config()); + mWriter.writeInt(bitmap->width()); + mWriter.writeInt(bitmap->height()); + + SkAutoLockPixels alp(*bitmap); + void* src = bitmap->getPixels(); + + mWriter.write(src, bitmap->rowBytes() * bitmap->height()); } void addUInts(const uint32_t* values, int8_t count) { mWriter.writeInt(count); - for (int8_t i = 0; i < count; i++) { - mWriter.writeInt(values[i]); - } + mWriter.write(values, count * sizeof(uint32_t)); } inline void addFloat(float value) { @@ -719,9 +741,7 @@ private: void addFloats(const float* values, int32_t count) { mWriter.writeInt(count); - for (int32_t i = 0; i < count; i++) { - mWriter.writeScalar(values[i]); - } + mWriter.write(values, count * sizeof(float)); } inline void addPoint(float x, float y) { |