Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/pdf/SkPDFDevice.cpp

Issue 24265006: pdf: drawPath should pass the computed matrix, instead of default matrix stored in draw. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 noEffectPaint.setStyle(SkPaint::kFill_Style); 952 noEffectPaint.setStyle(SkPaint::kFill_Style);
953 } else { 953 } else {
954 noEffectPaint.setStyle(SkPaint::kStroke_Style); 954 noEffectPaint.setStyle(SkPaint::kStroke_Style);
955 noEffectPaint.setStrokeWidth(0); 955 noEffectPaint.setStrokeWidth(0);
956 } 956 }
957 drawPath(d, *pathPtr, noEffectPaint, NULL, true); 957 drawPath(d, *pathPtr, noEffectPaint, NULL, true);
958 return; 958 return;
959 } 959 }
960 960
961 #ifdef SK_PDF_USE_PATHOPS 961 #ifdef SK_PDF_USE_PATHOPS
962 if (handleInversePath(d, origPath, paint, pathIsMutable)) { 962 if (handleInversePath(d, origPath, paint, pathIsMutable, &matrix)) {
963 return; 963 return;
964 } 964 }
965 #endif 965 #endif
966 966
967 if (handleRectAnnotation(pathPtr->getBounds(), *d.fMatrix, paint)) { 967 if (handleRectAnnotation(pathPtr->getBounds(), matrix, paint)) {
968 return; 968 return;
969 } 969 }
970 970
971 ScopedContentEntry content(this, d, paint); 971 ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint);
972 if (!content.entry()) { 972 if (!content.entry()) {
973 return; 973 return;
974 } 974 }
975 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), 975 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(),
976 &content.entry()->fContent); 976 &content.entry()->fContent);
977 SkPDFUtils::PaintPath(paint.getStyle(), pathPtr->getFillType(), 977 SkPDFUtils::PaintPath(paint.getStyle(), pathPtr->getFillType(),
978 &content.entry()->fContent); 978 &content.entry()->fContent);
979 } 979 }
980 980
981 void SkPDFDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 981 void SkPDFDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 1358
1359 #ifdef SK_PDF_USE_PATHOPS 1359 #ifdef SK_PDF_USE_PATHOPS
1360 /* Draws an inverse filled path by using Path Ops to compute the positive 1360 /* Draws an inverse filled path by using Path Ops to compute the positive
1361 * inverse using the current clip as the inverse bounds. 1361 * inverse using the current clip as the inverse bounds.
1362 * Return true if this was an inverse path and was properly handled, 1362 * Return true if this was an inverse path and was properly handled,
1363 * otherwise returns false and the normal drawing routine should continue, 1363 * otherwise returns false and the normal drawing routine should continue,
1364 * either as a (incorrect) fallback or because the path was not inverse 1364 * either as a (incorrect) fallback or because the path was not inverse
1365 * in the first place. 1365 * in the first place.
1366 */ 1366 */
1367 bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, 1367 bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath,
1368 const SkPaint& paint, bool pathIsMutable) { 1368 const SkPaint& paint, bool pathIsMutable,
1369 const SkMatrix* matrix) {
1369 if (!origPath.isInverseFillType()) { 1370 if (!origPath.isInverseFillType()) {
1370 return false; 1371 return false;
1371 } 1372 }
1372 1373
1373 if (d.fClip->isEmpty()) { 1374 if (d.fClip->isEmpty()) {
1374 return false; 1375 return false;
1375 } 1376 }
1376 1377
1377 SkPath modifiedPath; 1378 SkPath modifiedPath;
1378 SkPath* pathPtr = const_cast<SkPath*>(&origPath); 1379 SkPath* pathPtr = const_cast<SkPath*>(&origPath);
(...skipping 13 matching lines...) Expand all
1392 modifiedPath.toggleInverseFillType(); 1393 modifiedPath.toggleInverseFillType();
1393 drawPath(d, modifiedPath, paint, NULL, true); 1394 drawPath(d, modifiedPath, paint, NULL, true);
1394 return true; 1395 return true;
1395 } 1396 }
1396 } 1397 }
1397 1398
1398 // Get bounds of clip in current transform space 1399 // Get bounds of clip in current transform space
1399 // (clip bounds are given in device space). 1400 // (clip bounds are given in device space).
1400 SkRect bounds; 1401 SkRect bounds;
1401 SkMatrix transformInverse; 1402 SkMatrix transformInverse;
1402 if (!d.fMatrix->invert(&transformInverse)) { 1403 const SkMatrix matrixToUse = matrix ? *matrix : *d.fMatrix;
1404 if (!matrixToUse.invert(&transformInverse)) {
1403 return false; 1405 return false;
1404 } 1406 }
1405 bounds.set(d.fClip->getBounds()); 1407 bounds.set(d.fClip->getBounds());
1406 transformInverse.mapRect(&bounds); 1408 transformInverse.mapRect(&bounds);
1407 1409
1408 // Extend the bounds by the line width (plus some padding) 1410 // Extend the bounds by the line width (plus some padding)
1409 // so the edge doesn't cause a visible stroke. 1411 // so the edge doesn't cause a visible stroke.
1410 bounds.outset(paint.getStrokeWidth() + SK_Scalar1, 1412 bounds.outset(paint.getStrokeWidth() + SK_Scalar1,
1411 paint.getStrokeWidth() + SK_Scalar1); 1413 paint.getStrokeWidth() + SK_Scalar1);
1412 1414
1413 if (!calculate_inverse_path(bounds, *pathPtr, &modifiedPath)) { 1415 if (!calculate_inverse_path(bounds, *pathPtr, &modifiedPath)) {
1414 return false; 1416 return false;
1415 } 1417 }
1416 1418
1417 drawPath(d, modifiedPath, noInversePaint, NULL, true); 1419 drawPath(d, modifiedPath, noInversePaint, matrix, true);
vandebo (ex-Chrome) 2013/09/20 18:57:56 This isn't the prePathMatrix, this is the total ma
1418 return true; 1420 return true;
1419 } 1421 }
1420 #endif 1422 #endif
1421 1423
1422 bool SkPDFDevice::handleRectAnnotation(const SkRect& r, const SkMatrix& matrix, 1424 bool SkPDFDevice::handleRectAnnotation(const SkRect& r, const SkMatrix& matrix,
1423 const SkPaint& p) { 1425 const SkPaint& p) {
1424 SkAnnotation* annotationInfo = p.getAnnotation(); 1426 SkAnnotation* annotationInfo = p.getAnnotation();
1425 if (!annotationInfo) { 1427 if (!annotationInfo) {
1426 return false; 1428 return false;
1427 } 1429 }
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 } 1940 }
1939 1941
1940 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, 1942 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
1941 SkCanvas::Config8888) { 1943 SkCanvas::Config8888) {
1942 return false; 1944 return false;
1943 } 1945 }
1944 1946
1945 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { 1947 bool SkPDFDevice::allowImageFilter(SkImageFilter*) {
1946 return false; 1948 return false;
1947 } 1949 }
OLDNEW
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698