diff options
author | Zachary Turner <zturner@google.com> | 2017-10-06 21:25:44 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-10-06 21:25:44 +0000 |
commit | c3ab013aa1fb94a0e89a01502f69be34ed6c0575 (patch) | |
tree | 103ef2f091e6c0aadf0f8754acef7514457ba111 /llvm/tools/llvm-rc/ResourceFileWriter.h | |
parent | b6b210e61f906b1b2bf8b247224cdeb5a1a21071 (diff) | |
download | bcm5719-llvm-c3ab013aa1fb94a0e89a01502f69be34ed6c0575.tar.gz bcm5719-llvm-c3ab013aa1fb94a0e89a01502f69be34ed6c0575.zip |
[llvm-rc] Serialize CURSOR and ICON resources to .res
This is part 6 of llvm-rc serialization.
This adds ability to output cursors and icons as resources.
Unfortunately, we can't just copy .cur or .ico files to output - as each
file might contain multiple images, each of them needs to be unpacked
and stored as a separate resource. This forces us to parse cursor and
icon contents. (Fortunately, these formats are pretty similar and can be
processed by mostly common code).
As test files are binary, here is a short explanation of .cur and .ico
files stored:
cursor.cur, cursor-8.cur, cursor-32.cur are sample correct cursor files,
differing in their bit depth.
icon-old.ico, icon-new.ico are sample correct icon files;
icon-png.ico is a sample correct icon file in PNG format (instead of
usual BMP);
cursor-eof.cur is an incorrect cursor file - this is cursor.cur with
some of its final bytes removed.
cursor-bad-offset.cur is an incorrect cursor file - image header states
that image data begins at offset 0xFFFFFFFF.
Sample correct cursors and icons were created by Nico Weber.
Patch by Marek Sokolowski
Differential Revision: https://reviews.llvm.org/D37878
llvm-svn: 315109
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceFileWriter.h')
-rw-r--r-- | llvm/tools/llvm-rc/ResourceFileWriter.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.h b/llvm/tools/llvm-rc/ResourceFileWriter.h index 1370c6168d2..8093dfe7968 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.h +++ b/llvm/tools/llvm-rc/ResourceFileWriter.h @@ -25,14 +25,16 @@ namespace rc { class ResourceFileWriter : public Visitor { public: ResourceFileWriter(std::unique_ptr<raw_fd_ostream> Stream) - : FS(std::move(Stream)) { + : FS(std::move(Stream)), IconCursorID(1) { assert(FS && "Output stream needs to be provided to the serializator"); } Error visitNullResource(const RCResource *) override; Error visitAcceleratorsResource(const RCResource *) override; + Error visitCursorResource(const RCResource *) override; Error visitDialogResource(const RCResource *) override; Error visitHTMLResource(const RCResource *) override; + Error visitIconResource(const RCResource *) override; Error visitMenuResource(const RCResource *) override; Error visitCaptionStmt(const CaptionStmt *) override; @@ -76,6 +78,13 @@ private: bool IsLastItem); Error writeAcceleratorsBody(const RCResource *); + // CursorResource and IconResource + Error visitIconOrCursorResource(const RCResource *); + Error visitIconOrCursorGroup(const RCResource *); + Error visitSingleIconOrCursor(const RCResource *); + Error writeSingleIconOrCursorBody(const RCResource *); + Error writeIconOrCursorGroupBody(const RCResource *); + // DialogResource Error writeSingleDialogControl(const Control &, bool IsExtended); Error writeDialogBody(const RCResource *); @@ -120,6 +129,10 @@ private: Error appendFile(StringRef Filename); void padStream(uint64_t Length); + + // Icon and cursor IDs are allocated starting from 1 and increasing for + // each icon/cursor dumped. This maintains the current ID to be allocated. + uint16_t IconCursorID; }; } // namespace rc |