| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "DMPDFTask.h" | 8 #include "DMPDFTask.h" |
| 9 #include "DMPDFRasterizeTask.h" | 9 #include "DMPDFRasterizeTask.h" |
| 10 #include "DMUtil.h" | 10 #include "DMUtil.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 void PDFTask::draw() { | 68 void PDFTask::draw() { |
| 69 SkAutoTDelete<SkStreamAsset> pdfData; | 69 SkAutoTDelete<SkStreamAsset> pdfData; |
| 70 bool rasterize = true; | 70 bool rasterize = true; |
| 71 if (fGM.get()) { | 71 if (fGM.get()) { |
| 72 rasterize = 0 == (fGM->getFlags() & skiagm::GM::kSkipPDFRasterization_Fl
ag); | 72 rasterize = 0 == (fGM->getFlags() & skiagm::GM::kSkipPDFRasterization_Fl
ag); |
| 73 SinglePagePDF pdf(fGM->width(), fGM->height()); | 73 SinglePagePDF pdf(fGM->width(), fGM->height()); |
| 74 CanvasPreflight(pdf.canvas()); |
| 74 //TODO(mtklein): GM doesn't do this. Why not? | 75 //TODO(mtklein): GM doesn't do this. Why not? |
| 75 //pdf.canvas()->concat(fGM->getInitialTransform()); | 76 //pdf.canvas()->concat(fGM->getInitialTransform()); |
| 76 fGM->draw(pdf.canvas()); | 77 fGM->draw(pdf.canvas()); |
| 77 pdfData.reset(pdf.end()); | 78 pdfData.reset(pdf.end()); |
| 78 } else { | 79 } else { |
| 79 SinglePagePDF pdf(fPicture->cullRect().width(), fPicture->cullRect().hei
ght()); | 80 SinglePagePDF pdf(fPicture->cullRect().width(), fPicture->cullRect().hei
ght()); |
| 81 CanvasPreflight(pdf.canvas()); |
| 80 fPicture->playback(pdf.canvas()); | 82 fPicture->playback(pdf.canvas()); |
| 81 pdfData.reset(pdf.end()); | 83 pdfData.reset(pdf.end()); |
| 82 } | 84 } |
| 83 | 85 |
| 84 SkASSERT(pdfData.get()); | 86 SkASSERT(pdfData.get()); |
| 85 if (rasterize) { | 87 if (rasterize) { |
| 86 this->spawnChild(SkNEW_ARGS(PDFRasterizeTask, | 88 this->spawnChild(SkNEW_ARGS(PDFRasterizeTask, |
| 87 (*this, pdfData->duplicate(), fRasterize))); | 89 (*this, pdfData->duplicate(), fRasterize))); |
| 88 } | 90 } |
| 89 const char* sourceType = fGM.get() ? "GM" : "SKP"; | 91 const char* sourceType = fGM.get() ? "GM" : "SKP"; |
| 90 this->spawnChild(SkNEW_ARGS(WriteTask, | 92 this->spawnChild(SkNEW_ARGS(WriteTask, |
| 91 (*this, sourceType, pdfData->duplicate(), ".pdf"
))); | 93 (*this, sourceType, pdfData->duplicate(), ".pdf"
))); |
| 92 } | 94 } |
| 93 | 95 |
| 94 bool PDFTask::shouldSkip() const { | 96 bool PDFTask::shouldSkip() const { |
| 95 if (!FLAGS_pdf) { | 97 if (!FLAGS_pdf) { |
| 96 return true; | 98 return true; |
| 97 } | 99 } |
| 98 if (fGM.get() && 0 != (fGM->getFlags() & skiagm::GM::kSkipPDF_Flag)) { | 100 if (fGM.get() && 0 != (fGM->getFlags() & skiagm::GM::kSkipPDF_Flag)) { |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 return false; | 103 return false; |
| 102 } | 104 } |
| 103 | 105 |
| 104 } // namespace DM | 106 } // namespace DM |
| OLD | NEW |