QRegion KstViewLegend::clipRegion() { if (!_transparent) { return KstBorderedViewObject::clipRegion(); } if (_clipMask.isNull() && _myClipMask.isNull()) { const QRect cr(contentsRect()); QBitmap bm = _backBuffer.buffer().createHeuristicMask(false); // slow but preserves antialiasing... _myClipMask = QRegion(bm); _myClipMask.translate(cr.topLeft().x(), cr.topLeft().y()); QBitmap bm1(_geom.bottomRight().x() + 1, _geom.bottomRight().y() + 1, true); if (!bm1.isNull()) { KstPainter p; p.setMakingMask(true); p.begin(&bm1); p.setViewXForm(true); KstBorderedViewObject::paintSelf(p, QRegion()); p.end(); _clipMask = QRegion(bm1); } } return _clipMask | _myClipMask; }
QRegion KstViewArrow::clipRegion() { if (_clipMask.isNull()) { _myClipMask = QRegion(); QBitmap bm1(_geom.bottomRight().x(), _geom.bottomRight().y(), true); if (!bm1.isNull()) { KstPainter p; p.setMakingMask(true); p.begin(&bm1); p.setViewXForm(true); KstViewLine::paintSelf(p, QRegion()); p.end(); _clipMask = QRegion(bm1); } QBitmap bm2(_geom.bottomRight().x(), _geom.bottomRight().y(), true); if (!bm2.isNull()) { KstPainter p; p.setMakingMask(true); p.begin(&bm2); p.setViewXForm(true); paintSelf(p, QRegion()); p.end(); _myClipMask = QRegion(bm2); } } return _myClipMask | _clipMask; }
/** * Test that for Jpeg files that use the JFIF colorspace, they are * directly embedded into the PDF (without re-encoding) when that * makes sense. */ DEF_TEST(PDFJpegEmbedTest, r) { const char test[] = "PDFJpegEmbedTest"; SkAutoTUnref<SkData> mandrillData( load_resource(r, test, "mandrill_512_q075.jpg")); SkAutoTUnref<SkData> cmykData(load_resource(r, test, "CMYK.jpg")); if (!mandrillData || !cmykData) { return; } SkDynamicMemoryWStream pdf; SkAutoTUnref<SkDocument> document(SkDocument::CreatePDF(&pdf)); SkCanvas* canvas = document->beginPage(642, 1028); canvas->clear(SK_ColorLTGRAY); SkBitmap bm1(bitmap_from_data(mandrillData)); canvas->drawBitmap(bm1, 65.0, 0.0, NULL); SkBitmap bm2(bitmap_from_data(cmykData)); canvas->drawBitmap(bm2, 0.0, 512.0, NULL); canvas->flush(); document->endPage(); document->close(); SkAutoTUnref<SkData> pdfData(pdf.copyToData()); SkASSERT(pdfData); pdf.reset(); REPORTER_ASSERT(r, is_subset_of(mandrillData, pdfData)); // This JPEG uses a nonstandard colorspace - it can not be // embedded into the PDF directly. REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData)); }
QRegion KstViewPicture::clipRegion() { if (_clipMask.isNull()) { _myClipMask = QRegion(); QBitmap bm1(_geom.bottomRight().x() + 1, _geom.bottomRight().y() + 1, true); if (!bm1.isNull()) { KstPainter p; p.setMakingMask(true); p.begin(&bm1); p.setViewXForm(true); KstBorderedViewObject::paintSelf(p, QRegion()); p.flush(); p.end(); _clipMask = QRegion(bm1); } QBitmap bm2(_geom.bottomRight().x() + 1, _geom.bottomRight().y() + 1, true); if (!bm2.isNull()) { KstPainter p; p.setMakingMask(true); p.begin(&bm2); p.setViewXForm(true); paintSelf(p, QRegion()); p.flush(); p.end(); _myClipMask = QRegion(bm2); } } return _myClipMask | _clipMask; }
/** * Test that for Jpeg files that use the JFIF colorspace, they are * directly embedded into the PDF (without re-encoding) when that * makes sense. */ DEF_TEST(PDFJpegEmbedTest, r) { const char test[] = "PDFJpegEmbedTest"; SkAutoTUnref<SkData> mandrillData( load_resource(r, test, "mandrill_512_q075.jpg")); SkAutoTUnref<SkData> cmykData(load_resource(r, test, "CMYK.jpg")); if (!mandrillData || !cmykData) { return; } SkDynamicMemoryWStream pdf; SkAutoTUnref<SkDocument> document(SkDocument::CreatePDF(&pdf)); SkCanvas* canvas = document->beginPage(642, 1028); canvas->clear(SK_ColorLTGRAY); SkBitmap bm1(bitmap_from_data(mandrillData)); canvas->drawBitmap(bm1, 65.0, 0.0, NULL); SkBitmap bm2(bitmap_from_data(cmykData)); canvas->drawBitmap(bm2, 0.0, 512.0, NULL); canvas->flush(); document->endPage(); document->close(); SkAutoTUnref<SkData> pdfData(pdf.copyToData()); SkASSERT(pdfData); pdf.reset(); // Test disabled, waiting on resolution to http://skbug.com/3180 // REPORTER_ASSERT(r, is_subset_of(mandrillData, pdfData)); // This JPEG uses a nonstandard colorspace - it can not be // embedded into the PDF directly. REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData)); // The following is for debugging purposes only. const char* outputPath = getenv("SKIA_TESTS_PDF_JPEG_EMBED_OUTPUT_PATH"); if (outputPath) { SkFILEWStream output(outputPath); if (output.isValid()) { output.write(pdfData->data(), pdfData->size()); } } }