| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 //TODO(mtklein): GM doesn't do this. Why not? | 74 //TODO(mtklein): GM doesn't do this. Why not? |
| 75 //pdf.canvas()->concat(fGM->getInitialTransform()); | 75 //pdf.canvas()->concat(fGM->getInitialTransform()); |
| 76 fGM->draw(pdf.canvas()); | 76 fGM->draw(pdf.canvas()); |
| 77 pdfData.reset(pdf.end()); | 77 pdfData.reset(pdf.end()); |
| 78 } else { | 78 } else { |
| 79 SinglePagePDF pdf(SkIntToScalar(fPicture->width()), SkIntToScalar(fPictu
re->height())); | 79 SinglePagePDF pdf(fPicture->cullRect().width(), fPicture->cullRect().hei
ght()); |
| 80 fPicture->draw(pdf.canvas()); | 80 fPicture->draw(pdf.canvas()); |
| 81 pdfData.reset(pdf.end()); | 81 pdfData.reset(pdf.end()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 SkASSERT(pdfData.get()); | 84 SkASSERT(pdfData.get()); |
| 85 if (rasterize) { | 85 if (rasterize) { |
| 86 this->spawnChild(SkNEW_ARGS(PDFRasterizeTask, | 86 this->spawnChild(SkNEW_ARGS(PDFRasterizeTask, |
| 87 (*this, pdfData->duplicate(), fRasterize))); | 87 (*this, pdfData->duplicate(), fRasterize))); |
| 88 } | 88 } |
| 89 this->spawnChild(SkNEW_ARGS(WriteTask, | 89 this->spawnChild(SkNEW_ARGS(WriteTask, |
| 90 (*this, pdfData->duplicate(), ".pdf"))); | 90 (*this, pdfData->duplicate(), ".pdf"))); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool PDFTask::shouldSkip() const { | 93 bool PDFTask::shouldSkip() const { |
| 94 if (!FLAGS_pdf) { | 94 if (!FLAGS_pdf) { |
| 95 return true; | 95 return true; |
| 96 } | 96 } |
| 97 if (fGM.get() && 0 != (fGM->getFlags() & skiagm::GM::kSkipPDF_Flag)) { | 97 if (fGM.get() && 0 != (fGM->getFlags() & skiagm::GM::kSkipPDF_Flag)) { |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace DM | 103 } // namespace DM |
| OLD | NEW |