SkPDF: Use DeviceGray for alpha masks.

See https://groups.google.com/forum/#!topic/pdf-dev/qmdjg3w7D8E

BUG=chromium:742058
Change-Id: Ia8c204a92cb2b9fc33fab60826a95e359db65f08
Reviewed-on: https://skia-review.googlesource.com/26822
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Hal Canary 2017-07-26 09:16:01 -04:00 committed by Skia Commit-Bot
parent d902042c73
commit b4bd5ef99c
2 changed files with 6 additions and 4 deletions

View File

@ -869,7 +869,7 @@ void SkPDFDevice::internalDrawPathWithFilter(const SkClipStack& clipStack,
void SkPDFDevice::addSMaskGraphicState(sk_sp<SkPDFDevice> maskDevice,
SkDynamicMemoryWStream* contentStream) {
sk_sp<SkPDFDict> sMaskGS = SkPDFGraphicState::GetSMaskGraphicState(
maskDevice->makeFormXObjectFromDevice(), false,
maskDevice->makeFormXObjectFromDevice(true), false,
SkPDFGraphicState::kLuminosity_SMaskMode, this->getCanon());
SkPDFUtils::ApplyGraphicState(this->addGraphicStateResource(sMaskGS.get()), contentStream);
}
@ -1885,7 +1885,7 @@ void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) const {
}
}
sk_sp<SkPDFObject> SkPDFDevice::makeFormXObjectFromDevice() {
sk_sp<SkPDFObject> SkPDFDevice::makeFormXObjectFromDevice(bool alpha) {
SkMatrix inverseTransform = SkMatrix::I();
if (!fInitialTransform.isIdentity()) {
if (!fInitialTransform.invert(&inverseTransform)) {
@ -1893,9 +1893,10 @@ sk_sp<SkPDFObject> SkPDFDevice::makeFormXObjectFromDevice() {
inverseTransform.reset();
}
}
const char* colorSpace = alpha ? "DeviceGray" : nullptr;
sk_sp<SkPDFObject> xobject =
SkPDFMakeFormXObject(this->content(), this->copyMediaBox(),
this->makeResourceDict(), inverseTransform, nullptr);
this->makeResourceDict(), inverseTransform, colorSpace);
// We always draw the form xobjects that we create back into the device, so
// we simply preserve the font usage instead of pulling it out and merging
// it back in later.

View File

@ -212,7 +212,8 @@ private:
void init();
void cleanUp();
sk_sp<SkPDFObject> makeFormXObjectFromDevice();
// Set alpha to true if making a transparency group form x-objects.
sk_sp<SkPDFObject> makeFormXObjectFromDevice(bool alpha = false);
void drawFormXObjectWithMask(int xObjectIndex,
sk_sp<SkPDFObject> mask,