summaryrefslogtreecommitdiff
path: root/tools/aapt/Images.cpp
AgeCommit message (Collapse)Author
2023-09-01Move String8 path functions to androidfw and aapt Tomasz Wasilczyk
Test: m checkbuild Bug: 295394788 Change-Id: I9488bc5632cbd47c83f6b5f2df4c87eb324a1e8e
2023-08-18Use String8/16 c_str [tools] Tomasz Wasilczyk
Bug: 295394788 Test: make checkbuild Change-Id: I82d6899d8c15a10b15399c39177290012bb5f13b Merged-In: I82d6899d8c15a10b15399c39177290012bb5f13b
2017-09-26Replace strcpy with memcpy. Yunlian Jiang
This fixes the warning Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. As a side effect, it sliences the warning frameworks/base/tools/aapt/Images.cpp:1270:50: warning: Potential leak of memory pointed to by field 'data' [clang-analyzer-unix.Malloc] frameworks/base/tools/aapt2/compile/Png.cpp:562:42: warning: Potential leak of memory pointed to by field 'data' [clang-analyzer-unix.Malloc]. Bug: None Test: The warning is gone. Change-Id: I25f68ff85bea7069c21549c7deb7920d1877069e
2016-10-14Merge "Fix static-analyzer warning." am: 2fbf30d3fe am: a52992e290 George Burgess IV
am: c88628da5e Change-Id: Iece80dfbd8a5d01ffdcf6edf1decd8078af31511
2016-10-13Fix static-analyzer warning. George Burgess IV
frameworks/base/tools/aapt/Images.cpp:845:17: warning: Assigned value is garbage or undefined row += bpp; Bug: None. Test: The warning is gone. Change-Id: Idf4623d2510111a9188ed39922e109a8db225c76
2016-07-18AAPT: Don't keep processing files that failed to be added Adam Lesinski
AAPT will continue ahead without reporting an error if a file failed to be added to the ResourceTable. This would cause crashes later when the file was assumed to be present. Bug:30200166 Change-Id: Ieb2daf97ccf0345153b6f4598d130a38d108c937
2016-03-16Work-around paletted image decoding bug in SDK_JELLYBEAN Matt Sarett
Because there is a bug decoding paletted images in SDK_JELLYBEAN, we need to avoid encoding paletted images for apps that support SDK_JELLYBEAN and earlier. BUG=27643907 Change-Id: Ib7d51ed87435cd36507915d62b0057c06f18b2b6
2016-02-01Merge "Encode paletted PNGs more efficiently (part 2)" Matt Sarett
2016-02-01Encode paletted PNGs more efficiently (part 2) Matt Sarett
Many PNGs have multiple distinct pixels with zero alpha. This CL allows us to treat all of those pixels as a single zero pixel. This saves space in the color palette and also may help save memory pages when we skip writing zeros. There is also a potential disadvantage: if someone intended to decode this image as unpremultiplied with particular transfer modes where their color components have an effect even though alpha is zero, this will prevent that. At the moment, we do not support unpremul as a source, so this won't affect anyone trying to draw with the view system. This change originated in: https://googleplex-android-review.git.corp.google.com/#/c/854580/ Change-Id: I702c7bd22d431cc7c775ed29bbd73c930f945ca3
2016-02-01Encode paletted PNGs more efficiently Matt Sarett
Saves about 2 MB of encoded size across affected assets. Also will enable more efficient decoding. Specifically, encoded palette values are assumed to be opaque unless alpha values are provided in a tRNS chunk. Before this change, we would wastefully store many opaque alpha values in tRNS chunk. Additionally, the decoder used to need to premultiply all of these opaque colors, because the encoded data indicated that they had alpha. Change-Id: Id21b3b31850c9db6149ced6d20ed5e0ce2d71c5b
2016-01-29Encode paletted PNGs more efficiently Matt Sarett
Saves about 2 MB of encoded size across affected assets. Also will enable more efficient decoding. Specifically, encoded palette values are assumed to be opaque unless alpha values are provided in a tRNS chunk. Before this change, we would wastefully store many opaque alpha values in tRNS chunk. Additionally, the decoder used to need to premultiply all of these opaque colors, because the encoded data indicated that they had alpha. Change-Id: I1d5400f71a0e3cb800fd0fc68a04c8c4069da8ef
2016-01-07Allow ninepatches to be encoded using non-RGBA modes Matt Sarett
The original intention for forcing ninepatches to be encoded as RGBA (with alpha) was to avoid the possibility of the decoder producing 565 output. 565 output is bad for ninepatches because dithering tiny images that we intend to scale later leads to bad results. I would argue that, since the new BitmapFactory does not dither, we might now be ok to allow 565 decodes for ninepatches. However, we will maintain the old behavior by disabling 565 decodes for ninepatch. There are two changes to PNG encodings: (1) Allows ninepatch images to be encoded in any mode. Forcing them to RGBA makes things awkward for the decoder. Currently, BitmapFactory's png decoder checks every pixel for alpha. That way, RGBA images that are actually opaque can be marked as opaque, in order to optimize drawing. We want to remove this complexity from the decoder. (2) Make sure ninepatch chunks are stored in the png header. That way we know immediately that the png is a ninepatch, and can refuse to decode to 565 (if we feel this is best). Change-Id: I724f5dbefb1be7b412f9b362dff83cbc0603f0bf
2015-04-08Re-enable -Wall and -Werror that were lost in a merge Colin Cross
-Wall and -Werror were lost during a merge when they were added to aaptCFLAGS instead of aaptCFlags. Fix the typo, and the warnings that crept in while it was disabled. Change-Id: Ib944b8d6149278e4f3861c1acac277bcd95cc7c2
2015-03-04Stop using namespace std. Dan Albert
The pattern of #include and using namespace std here fails to build with GCC. At first glance it's a GCC bug rather than libc++ doing something wrong. Regardless, it can be worked around by just specifying std:: where appropriate. Bug: 19606303 Change-Id: I5652682eae7ca7559cf2a9307909859013440781
2014-10-17am 3cd840f4: Merge "AAPT: Fix an issue where a resource name was incorrectly ↵ Adam Lesinski
derived on Windows" into lmp-dev * commit '3cd840f4b5a2988700a6b366fa32f4565c319900': AAPT: Fix an issue where a resource name was incorrectly derived on Windows
2014-10-17AAPT: Fix an issue where a resource name was incorrectly derived on Windows Adam Lesinski
Calling String8::getLeaf() will assume the system's file path separator, however the source string was already converted to a unix path. getLeaf() would therefore not find any occurence of '\' and would return the full path. Bug:18036805 Change-Id: Ic2bfac0cc553406740204a296327e266b05c0eff
2014-10-02am 152d9aae: am 31629651: Merge "Frameworks/base: Fix more aapt issues" Andreas Gampe
* commit '152d9aae631381ea28f5701168d372a1486a7502': Frameworks/base: Fix more aapt issues
2014-10-01resolved conflicts for merge of 1dcc75b2 to lmp-dev-plus-aosp Andreas Gampe
Change-Id: I8e1c6ee2025b6acd90803545fb95ab1b98560d92
2014-10-01Frameworks/base: Fix more aapt issues Andreas Gampe
Change-Id: I6da7dc674e9f9e3b0886a3cfd1e3194d6b5ac948
2014-10-01Frameworks/base: Fix AAPT warnings Andreas Gampe
Turn on -Wall -Werror. Fix warnings. Change-Id: I287fb3c1e851c654479bcf9ea8c73bd354a6b2a1
2014-09-22AAPT: Continuation of public/private attribute fix Adam Lesinski
XML files like layouts are now scanned and checked for v21 attributes. If those kinds of attributes are found, then we remove them in the original version and synthesize a new xml file under the v21 configuration. Bug:17520380 Change-Id: Icf984cb96134180a2e35349c1dbf2cef9a8f0bda
2014-08-15Fix nine patch outline radius computation Chris Craik
bug:16852714 Change-Id: I475154c0f324fd2e2c8991415e0d8240c75663d8
2014-07-31Add outline alpha Chris Craik
bug:16140822 bug:16566746 This allows background drawables to alter the opacity of a shadow being cast with their own alpha values. Change-Id: I49698cc7c1bf4b2b55ffe2f82899543ca62bc61c
2014-07-14Implement outline support for nine patches Chris Craik
b/15856895 Nine patches now have outline round rect metadata stored as optional png tags. aapt generates these automatically by inspecting the bitmap pixels to estimate outline bounds and round rect radius, based on opacity. Change-Id: I226e328a97873010d9e1adb797ac48f93a31183c
2014-03-10resolved conflicts for merge of 92860a74 to master Narayan Kamath
Change-Id: I3036ef9f1251c756092dc5ee2c4fed8146855e1e
2014-03-10LP64: Make 9 patches architecture agnostic. Narayan Kamath
The Res_png_9patch struct had several pointer members whose size differed between 32 and 64 bit platforms. These members have been replaced by uint32_t offsets to serialized data. The serialized form for 9patches places a Res_png_9patch object at the beginning of serialized data, followed by int32_t arrays of xDivs, yDivs and colors. Note that these offsets are not strictly required, since they can be computed from the values of numXDivs, numYDivs & numColors, however they are called in tight loops so having them computed once is a beneficial. This change also removed the unused patch_equals function from aapt's Image.cpp. Change-Id: I3b9ac8ae5c05510d41377cae4dff1c69b40c2531
2014-01-27Re-apply several tools fixes lost by the directory rearrangement. Elliott Hughes
Leaks on error in tools/aapt/Images.cpp. https://code.google.com/p/android/issues/detail?id=61552 Two missing fclose calls in tools/aapt/Resource.cpp. https://code.google.com/p/android/issues/detail?id=61553 Missing fclose in tools/aidl/aidl.cpp. https://code.google.com/p/android/issues/detail?id=61554 Change-Id: I56ce144958296961b77354815efc1a245564594b
2014-01-27libpng usage tweaks John Reck
Bug: 10447005 Call png_set_interlace_handling explicitly instead of relying on implicit handling that logs warnings Include filename when printing warnings Change-Id: Ia343427f5522dc8ab1010f8d7017e86f389caf99
2014-01-27Revert "Move frameworks/base/tools/ to frameworks/tools/" Adam Lesinski
This reverts commit 9f6a119c8aa276432ece4fe2118bd8a3c9b1067e.
2013-10-29Fix a variety of small publicly-reported bugs. Elliott Hughes
Possible NULL dereference in cmds/bootanimation/BootAnimation.cpp. https://code.google.com/p/android/issues/detail?id=61556 Missing fclose in core/jni/android_os_Debug.cpp. https://code.google.com/p/android/issues/detail?id=61546 Bad loop guards in core/jni/android_util_Process.cpp. https://code.google.com/p/android/issues/detail?id=61557 Assignment to wrong variable in libs/androidfw/AssetManager.cpp. https://code.google.com/p/android/issues/detail?id=61560 Missing delete[]s in libs/androidfw/ObbFile.cpp. https://code.google.com/p/android/issues/detail?id=61549 Leaks on error in tools/aapt/Images.cpp. https://code.google.com/p/android/issues/detail?id=61552 Two missing fclose calls in tools/aapt/Resource.cpp. https://code.google.com/p/android/issues/detail?id=61553 Missing fclose in tools/aidl/aidl.cpp. https://code.google.com/p/android/issues/detail?id=61554 Change-Id: I5820f3824e72d07a9acb776cf0af3e7443f5694a
2013-08-28Move frameworks/base/tools/ to frameworks/tools/ Mike Lockwood
Change-Id: I3ffafdab27cc4aca256c3a5806b630795b75d5c8
2013-08-26Forward compatibility fixes John Reck
Change-Id: Iaf387a10c387e5e157bb16d120a1e033b3d1a6e8
2013-08-14Fixes for libpng 1.6 John Reck
png_set_filler() now fails if the color type doesn't support a filler (such as RGB_ALPHA) png_set_unknown_chunk location bug was fixed and now enforces proper location setting Change-Id: If3834e3744d9618c308cc442e66d85e9cffcea38
2013-08-13Fix libpng API usage John Reck
Remove usage of deprecated APIs no longer in 1.6 Change-Id: I04cbceba718533312e900e62ddcf3872b61765ec
2012-04-04Embed layout padding in nine patch images Amith Yamasani
- Added a new custom PNG chunk that carries the layout padding ints. - Extract the padding ticks from .9.png images and store in the chunk. - Load the padding information at runtime into Bitmap and NinePatchDrawable. - The new chunk is ordered first so that it doesn't cause a problem in older versions of the platform. Bug: 6087201 Change-Id: I5de46167a1d44b3ec21065b0c165e594b1dc8399
2012-03-17aapt: Preprocess images in parallel. Jeff Brown
Currently hardcoded to use up to 4 threads. This change substantially reduces the amount of time spent preprocessing framework resources to just a few seconds. Change-Id: I02fdd283fb529a152aeb22ac87f278779fd77983
2012-02-17frameworks/base refactoring. Mathias Agopian
step 2: move libutils headers to their new home: androidfw Change-Id: I14624ba23db92a81f2cb929f104386e1fab293ef
2011-10-16New aapt feature to do smarter filtering of configurations. Dianne Hackborn
This adds a --preferred-configurations flag that specifies the specific configurations you would like to have. It is smarter than "-c" because it will avoid stripping a configuration if that would result in there being no value for the resource. It is dumber than "-c" because it can't process as many kinds of resources. It is really only intended for bitmaps and use with density configs. This required re-arranging AaptAssets to group files together by config again, like they used to be. I think this hasn't broken anything. Hopefully. Change-Id: I4e9d12ff6e6dbd1abb8fd4cb1814c6674b19d0e5
2011-07-20Added Caching for PreProcessed PNGs Josiah Gaskin
Added a cache management system for pre-processed PNG files along with unit tests. The cache system will be used if the --no-crunch flag is passed to AAPT during the package phase. The cache can be updated by a call to 'aapt crunch' (see usage statement). Also put in benchmarking code. Change-Id: I58271fb2ee2f5f9075fd74d4ff6f15e7afabd05c
2010-03-12Give an 9-patch error on too many rows and columns Kenny Root
When you have too many rows and columns, there are not enough colors in the 9-patch private metadata to represent them. Instead of crashing aapt, this change gives the user an error message telling them why it's invalid. Change-Id: I5e7bd59472a3a2eafa7cbc263792458cce2b5594
2009-04-20AI 147028: Fix up aapt so it runs cleanly under the valgrind leak checker. Marco Nelissen
Automated import of CL 147028
2009-03-05auto import from //depot/cupcake/@136594 The Android Open Source Project
2009-03-03auto import from //depot/cupcake/@135843 The Android Open Source Project
2009-03-03auto import from //depot/cupcake/@135843 The Android Open Source Project
2009-03-03auto import from //depot/cupcake/@132589 The Android Open Source Project
2009-03-02auto import from //depot/cupcake/@137055 The Android Open Source Project
2009-02-10auto import from //branches/cupcake/...@130745 The Android Open Source Project
2009-01-15auto import from //branches/cupcake/...@126645 The Android Open Source Project
2009-01-09auto import from //branches/cupcake/...@125939 The Android Open Source Project
2008-12-17Code drop from //branches/cupcake/...@124589 The Android Open Source Project