diff options
author | msarett <msarett@google.com> | 2016-02-11 10:35:48 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-11 10:35:48 -0800 |
commit | 17315c20e7a87d6e92fdc4623d2e27303037a051 (patch) | |
tree | d29c74c43c3bbaf1d2bc8901c5beb68bf2161a4c /src/codec/SkBmpRLECodec.cpp | |
parent | f62a8b786c0e17a3818d0bdc8dbf1c627b063e1b (diff) |
Avoid initializing memory twice on incomplete RLE bmps
BUG=skia:4582
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1689983002
Review URL: https://codereview.chromium.org/1689983002
Diffstat (limited to 'src/codec/SkBmpRLECodec.cpp')
-rw-r--r-- | src/codec/SkBmpRLECodec.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp index 57707d60c9..05691cc079 100644 --- a/src/codec/SkBmpRLECodec.cpp +++ b/src/codec/SkBmpRLECodec.cpp @@ -520,8 +520,13 @@ private: SkBmpRLECodec* fCodec; }; -SkSampler* SkBmpRLECodec::getSampler(bool createIfNecessary) { - if (!fSampler && createIfNecessary) { +SkSampler* SkBmpRLECodec::getSampler(bool /*createIfNecessary*/) { + // We will always create an SkBmpRLESampler if one is requested. + // This allows clients to always use the SkBmpRLESampler's + // version of fill(), which does nothing since RLE decodes have + // already filled pixel memory. This seems fine, since creating + // an SkBmpRLESampler is pretty inexpensive. + if (!fSampler) { fSampler.reset(new SkBmpRLESampler(this)); } |