OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
9 | 9 |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 push(); | 430 push(); |
431 SkPDFUtils::AppendTransform(matrix, fContentStream); | 431 SkPDFUtils::AppendTransform(matrix, fContentStream); |
432 currentEntry()->fMatrix = matrix; | 432 currentEntry()->fMatrix = matrix; |
433 } | 433 } |
434 | 434 |
435 void GraphicStackState::updateDrawingState(const GraphicStateEntry& state) { | 435 void GraphicStackState::updateDrawingState(const GraphicStateEntry& state) { |
436 // PDF treats a shader as a color, so we only set one or the other. | 436 // PDF treats a shader as a color, so we only set one or the other. |
437 if (state.fShaderIndex >= 0) { | 437 if (state.fShaderIndex >= 0) { |
438 if (state.fShaderIndex != currentEntry()->fShaderIndex) { | 438 if (state.fShaderIndex != currentEntry()->fShaderIndex) { |
439 SkString resourceName = SkPDFResourceDict::getResourceName( | 439 SkPDFUtils::ApplyPattern(state.fShaderIndex, fContentStream); |
440 SkPDFResourceDict::kPattern_ResourceType, | |
441 state.fShaderIndex); | |
442 fContentStream->writeText("/Pattern CS /Pattern cs /"); | |
443 fContentStream->writeText(resourceName.c_str()); | |
444 fContentStream->writeText(" SCN /"); | |
445 fContentStream->writeText(resourceName.c_str()); | |
446 fContentStream->writeText(" scn\n"); | |
447 currentEntry()->fShaderIndex = state.fShaderIndex; | 440 currentEntry()->fShaderIndex = state.fShaderIndex; |
448 } | 441 } |
449 } else { | 442 } else { |
450 if (state.fColor != currentEntry()->fColor || | 443 if (state.fColor != currentEntry()->fColor || |
451 currentEntry()->fShaderIndex >= 0) { | 444 currentEntry()->fShaderIndex >= 0) { |
452 emit_pdf_color(state.fColor, fContentStream); | 445 emit_pdf_color(state.fColor, fContentStream); |
453 fContentStream->writeText("RG "); | 446 fContentStream->writeText("RG "); |
454 emit_pdf_color(state.fColor, fContentStream); | 447 emit_pdf_color(state.fColor, fContentStream); |
455 fContentStream->writeText("rg\n"); | 448 fContentStream->writeText("rg\n"); |
456 currentEntry()->fColor = state.fColor; | 449 currentEntry()->fColor = state.fColor; |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 SkMatrix identity; | 1404 SkMatrix identity; |
1412 identity.reset(); | 1405 identity.reset(); |
1413 SkDraw draw; | 1406 SkDraw draw; |
1414 draw.fMatrix = &identity; | 1407 draw.fMatrix = &identity; |
1415 draw.fClip = &clipRegion; | 1408 draw.fClip = &clipRegion; |
1416 draw.fClipStack = clipStack; | 1409 draw.fClipStack = clipStack; |
1417 SkPaint stockPaint; | 1410 SkPaint stockPaint; |
1418 this->drawPaint(draw, stockPaint); | 1411 this->drawPaint(draw, stockPaint); |
1419 SkAutoTUnref<SkPDFFormXObject> maskFormXObject(createFormXObjectFromDevice()
); | 1412 SkAutoTUnref<SkPDFFormXObject> maskFormXObject(createFormXObjectFromDevice()
); |
1420 SkAutoTUnref<SkPDFGraphicState> sMaskGS( | 1413 SkAutoTUnref<SkPDFGraphicState> sMaskGS( |
1421 SkPDFGraphicState::GetSMaskGraphicState(maskFormXObject, invertClip)); | 1414 SkPDFGraphicState::GetSMaskGraphicState(maskFormXObject, invertClip, |
| 1415 SkPDFGraphicState::kAlpha_SMaskM
ode)); |
1422 | 1416 |
1423 // Draw the xobject with the clip as a mask. | 1417 // Draw the xobject with the clip as a mask. |
1424 ScopedContentEntry content(this, &fExistingClipStack, fExistingClipRegion, | 1418 ScopedContentEntry content(this, &fExistingClipStack, fExistingClipRegion, |
1425 identity, stockPaint); | 1419 identity, stockPaint); |
1426 if (!content.entry()) { | 1420 if (!content.entry()) { |
1427 return; | 1421 return; |
1428 } | 1422 } |
1429 SkPDFUtils::ApplyGraphicState(addGraphicStateResource(sMaskGS.get()), | 1423 SkPDFUtils::ApplyGraphicState(addGraphicStateResource(sMaskGS.get()), |
1430 &content.entry()->fContent); | 1424 &content.entry()->fContent); |
1431 SkPDFUtils::DrawFormXObject(fXObjectResources.count(), | 1425 SkPDFUtils::DrawFormXObject(fXObjectResources.count(), |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 fExistingClipRegion, identity, | 1561 fExistingClipRegion, identity, |
1568 stockPaint); | 1562 stockPaint); |
1569 if (!inClipContentEntry.entry()) { | 1563 if (!inClipContentEntry.entry()) { |
1570 return; | 1564 return; |
1571 } | 1565 } |
1572 | 1566 |
1573 SkAutoTUnref<SkPDFGraphicState> sMaskGS; | 1567 SkAutoTUnref<SkPDFGraphicState> sMaskGS; |
1574 if (xfermode == SkXfermode::kSrcIn_Mode || | 1568 if (xfermode == SkXfermode::kSrcIn_Mode || |
1575 xfermode == SkXfermode::kSrcOut_Mode) { | 1569 xfermode == SkXfermode::kSrcOut_Mode) { |
1576 sMaskGS.reset(SkPDFGraphicState::GetSMaskGraphicState( | 1570 sMaskGS.reset(SkPDFGraphicState::GetSMaskGraphicState( |
1577 dst, xfermode == SkXfermode::kSrcOut_Mode)); | 1571 dst, |
| 1572 xfermode == SkXfermode::kSrcOut_Mode, |
| 1573 SkPDFGraphicState::kAlpha_SMaskMode)); |
1578 fXObjectResources.push(srcFormXObject.get()); | 1574 fXObjectResources.push(srcFormXObject.get()); |
1579 srcFormXObject.get()->ref(); | 1575 srcFormXObject.get()->ref(); |
1580 } else { | 1576 } else { |
1581 sMaskGS.reset(SkPDFGraphicState::GetSMaskGraphicState( | 1577 sMaskGS.reset(SkPDFGraphicState::GetSMaskGraphicState( |
1582 srcFormXObject.get(), xfermode == SkXfermode::kDstOut_Mode)); | 1578 srcFormXObject.get(), |
| 1579 xfermode == SkXfermode::kDstOut_Mode, |
| 1580 SkPDFGraphicState::kAlpha_SMaskMode)); |
1583 // dst already added to fXObjectResources in drawFormXObjectWithClip. | 1581 // dst already added to fXObjectResources in drawFormXObjectWithClip. |
1584 } | 1582 } |
1585 SkPDFUtils::ApplyGraphicState(addGraphicStateResource(sMaskGS.get()), | 1583 SkPDFUtils::ApplyGraphicState(addGraphicStateResource(sMaskGS.get()), |
1586 &inClipContentEntry.entry()->fContent); | 1584 &inClipContentEntry.entry()->fContent); |
1587 | 1585 |
1588 SkPDFUtils::DrawFormXObject(fXObjectResources.count() - 1, | 1586 SkPDFUtils::DrawFormXObject(fXObjectResources.count() - 1, |
1589 &inClipContentEntry.entry()->fContent); | 1587 &inClipContentEntry.entry()->fContent); |
1590 | 1588 |
1591 sMaskGS.reset(SkPDFGraphicState::GetNoSMaskGraphicState()); | 1589 sMaskGS.reset(SkPDFGraphicState::GetNoSMaskGraphicState()); |
1592 SkPDFUtils::ApplyGraphicState(addGraphicStateResource(sMaskGS.get()), | 1590 SkPDFUtils::ApplyGraphicState(addGraphicStateResource(sMaskGS.get()), |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 } | 1764 } |
1767 | 1765 |
1768 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 1766 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
1769 SkCanvas::Config8888) { | 1767 SkCanvas::Config8888) { |
1770 return false; | 1768 return false; |
1771 } | 1769 } |
1772 | 1770 |
1773 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 1771 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
1774 return false; | 1772 return false; |
1775 } | 1773 } |
OLD | NEW |