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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 fShaderResources.unrefAll(); | 800 fShaderResources.unrefAll(); |
801 SkSafeUnref(fAnnotations); | 801 SkSafeUnref(fAnnotations); |
802 SkSafeUnref(fResourceDict); | 802 SkSafeUnref(fResourceDict); |
803 fNamedDestinations.deleteAll(); | 803 fNamedDestinations.deleteAll(); |
804 | 804 |
805 if (clearFontUsage) { | 805 if (clearFontUsage) { |
806 fFontGlyphUsage->reset(); | 806 fFontGlyphUsage->reset(); |
807 } | 807 } |
808 } | 808 } |
809 | 809 |
810 uint32_t SkPDFDevice::getDeviceCapabilities() { | |
811 return kVector_Capability; | |
812 } | |
813 | |
814 void SkPDFDevice::clear(SkColor color) { | 810 void SkPDFDevice::clear(SkColor color) { |
815 this->cleanUp(true); | 811 this->cleanUp(true); |
816 this->init(); | 812 this->init(); |
817 | 813 |
818 SkPaint paint; | 814 SkPaint paint; |
819 paint.setColor(color); | 815 paint.setColor(color); |
820 paint.setStyle(SkPaint::kFill_Style); | 816 paint.setStyle(SkPaint::kFill_Style); |
821 SkMatrix identity; | 817 SkMatrix identity; |
822 identity.reset(); | 818 identity.reset(); |
823 ScopedContentEntry content(this, &fExistingClipStack, fExistingClipRegion, | 819 ScopedContentEntry content(this, &fExistingClipStack, fExistingClipRegion, |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1334 SkXfermode* xmode, const uint16_t indices[], | 1330 SkXfermode* xmode, const uint16_t indices[], |
1335 int indexCount, const SkPaint& paint) { | 1331 int indexCount, const SkPaint& paint) { |
1336 if (d.fClip->isEmpty()) { | 1332 if (d.fClip->isEmpty()) { |
1337 return; | 1333 return; |
1338 } | 1334 } |
1339 // TODO: implement drawVertices | 1335 // TODO: implement drawVertices |
1340 } | 1336 } |
1341 | 1337 |
1342 void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device, | 1338 void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device, |
1343 int x, int y, const SkPaint& paint) { | 1339 int x, int y, const SkPaint& paint) { |
1344 if ((device->getDeviceCapabilities() & kVector_Capability) == 0) { | 1340 // our onCreateDevice() always creates SkPDFDevice subclasses. |
vandebo (ex-Chrome)
2014/03/13 17:21:17
And onCreateDevice() is the only consumer of devic
reed1
2014/03/13 18:15:33
Correct. raster and gpu backends rely on the devic
| |
1345 // If we somehow get a raster device, do what our parent would do. | |
1346 INHERITED::drawDevice(d, device, x, y, paint); | |
1347 return; | |
1348 } | |
1349 | |
1350 // Assume that a vector capable device means that it's a PDF Device. | |
1351 SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); | 1341 SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); |
1352 if (pdfDevice->isContentEmpty()) { | 1342 if (pdfDevice->isContentEmpty()) { |
1353 return; | 1343 return; |
1354 } | 1344 } |
1355 | 1345 |
1356 SkMatrix matrix; | 1346 SkMatrix matrix; |
1357 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); | 1347 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); |
1358 ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint); | 1348 ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint); |
1359 if (!content.entry()) { | 1349 if (!content.entry()) { |
1360 return; | 1350 return; |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2321 } | 2311 } |
2322 | 2312 |
2323 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 2313 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
2324 SkCanvas::Config8888) { | 2314 SkCanvas::Config8888) { |
2325 return false; | 2315 return false; |
2326 } | 2316 } |
2327 | 2317 |
2328 bool SkPDFDevice::allowImageFilter(const SkImageFilter*) { | 2318 bool SkPDFDevice::allowImageFilter(const SkImageFilter*) { |
2329 return false; | 2319 return false; |
2330 } | 2320 } |
OLD | NEW |