aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2016-10-20 12:35:23 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-20 17:31:35 +0000
commit313c4635e3f1005e6807f5b0ad52805f30902d66 (patch)
tree4e1580f7246f70fa7235982e6d17ec0461f8ad6a /src/codec/SkCodec.cpp
parentff6a07f4dedc67237cb26500d3617194a1ae5a9c (diff)
Safely handle unsupported color xforms in SkCodec
(1) The transformation code *should* support any src SkColorSpace that we successfully parse. This is agreed upon internally and by clients. The fact that we currently don't is just a bug... (2) We cannot and will not support all SkColorSpaces as dsts. So if we fail to make a SkColorSpaceXform, we should assume that it was caused by a bad dst color space. The correct response in this case is to return kInvalidConversion. I've rewritten the CL to do this. The fact that weird src spaces will sometimes trigger a kInvalidConversion is just a bug that is being actively worked on. TBR=reed@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3661 Change-Id: Iac2b45120507ec71b1b3d555c61931f7348dad9e Reviewed-on: https://skia-review.googlesource.com/3661 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Robert Aftias <raftias@google.com>
Diffstat (limited to 'src/codec/SkCodec.cpp')
-rw-r--r--src/codec/SkCodec.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 84afc2bdee..b6ce65e7b2 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -9,6 +9,7 @@
#include "SkCodec.h"
#include "SkCodecPriv.h"
#include "SkColorSpace.h"
+#include "SkColorSpaceXform.h"
#include "SkData.h"
#include "SkGifCodec.h"
#include "SkHalf.h"
@@ -483,3 +484,15 @@ void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t row
}
}
}
+
+bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo) {
+ fColorXform = nullptr;
+ if (needs_color_xform(dstInfo, fSrcInfo)) {
+ fColorXform = SkColorSpaceXform::New(fSrcInfo.colorSpace(), dstInfo.colorSpace());
+ if (!fColorXform) {
+ return false;
+ }
+ }
+
+ return true;
+}