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

Side by Side Diff: src/device/xps/SkXPSDevice.cpp

Issue 1135053002: stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix xpsdevice Created 5 years, 7 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
« no previous file with comments | « src/core/SkStrokerPriv.cpp ('k') | src/effects/SkCornerPathEffect.cpp » ('j') | 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 "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #ifndef UNICODE 10 #ifndef UNICODE
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 stop.fX = SkScalarMul(end.fX - start.fX, stopOffsets[i]); 505 stop.fX = SkScalarMul(end.fX - start.fX, stopOffsets[i]);
506 stop.fY = SkScalarMul(end.fY - start.fY, stopOffsets[i]); 506 stop.fY = SkScalarMul(end.fY - start.fY, stopOffsets[i]);
507 507
508 SkPoint stopTransformed; 508 SkPoint stopTransformed;
509 transform.mapXY(stop.fX, stop.fY, &stopTransformed); 509 transform.mapXY(stop.fX, stop.fY, &stopTransformed);
510 510
511 //Manhattan distance between transformed start and stop. 511 //Manhattan distance between transformed start and stop.
512 SkScalar startToStop = (stopTransformed.fX - startTransformed.fX) 512 SkScalar startToStop = (stopTransformed.fX - startTransformed.fX)
513 + (stopTransformed.fY - startTransformed.fY); 513 + (stopTransformed.fY - startTransformed.fY);
514 //Percentage along transformed line. 514 //Percentage along transformed line.
515 stopOffsets[i] = SkScalarDiv(startToStop, startToEnd); 515 stopOffsets[i] = startToStop / startToEnd;
516 } 516 }
517 } 517 }
518 518
519 HRESULT SkXPSDevice::createXpsTransform(const SkMatrix& matrix, 519 HRESULT SkXPSDevice::createXpsTransform(const SkMatrix& matrix,
520 IXpsOMMatrixTransform** xpsTransform) { 520 IXpsOMMatrixTransform** xpsTransform) {
521 SkScalar affine[6]; 521 SkScalar affine[6];
522 if (!matrix.asAffine(affine)) { 522 if (!matrix.asAffine(affine)) {
523 *xpsTransform = NULL; 523 *xpsTransform = NULL;
524 return S_FALSE; 524 return S_FALSE;
525 } 525 }
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 xpsFigure.get(), xpsFigures)); 1389 xpsFigure.get(), xpsFigures));
1390 } 1390 }
1391 return S_OK; 1391 return S_OK;
1392 } 1392 }
1393 1393
1394 void SkXPSDevice::convertToPpm(const SkMaskFilter* filter, 1394 void SkXPSDevice::convertToPpm(const SkMaskFilter* filter,
1395 SkMatrix* matrix, 1395 SkMatrix* matrix,
1396 SkVector* ppuScale, 1396 SkVector* ppuScale,
1397 const SkIRect& clip, SkIRect* clipIRect) { 1397 const SkIRect& clip, SkIRect* clipIRect) {
1398 //This action is in unit space, but the ppm is specified in physical space. 1398 //This action is in unit space, but the ppm is specified in physical space.
1399 ppuScale->fX = SkScalarDiv(this->fCurrentPixelsPerMeter.fX, 1399 ppuScale->set(fCurrentPixelsPerMeter.fX / fCurrentUnitsPerMeter.fX,
1400 this->fCurrentUnitsPerMeter.fX); 1400 fCurrentPixelsPerMeter.fY / fCurrentUnitsPerMeter.fY);
1401 ppuScale->fY = SkScalarDiv(this->fCurrentPixelsPerMeter.fY,
1402 this->fCurrentUnitsPerMeter.fY);
1403 1401
1404 matrix->postScale(ppuScale->fX, ppuScale->fY); 1402 matrix->postScale(ppuScale->fX, ppuScale->fY);
1405 1403
1406 const SkIRect& irect = clip; 1404 const SkIRect& irect = clip;
1407 SkRect clipRect = SkRect::MakeLTRB( 1405 SkRect clipRect = SkRect::MakeLTRB(
1408 SkScalarMul(SkIntToScalar(irect.fLeft), ppuScale->fX), 1406 SkScalarMul(SkIntToScalar(irect.fLeft), ppuScale->fX),
1409 SkScalarMul(SkIntToScalar(irect.fTop), ppuScale->fY), 1407 SkScalarMul(SkIntToScalar(irect.fTop), ppuScale->fY),
1410 SkScalarMul(SkIntToScalar(irect.fRight), ppuScale->fX), 1408 SkScalarMul(SkIntToScalar(irect.fRight), ppuScale->fX),
1411 SkScalarMul(SkIntToScalar(irect.fBottom), ppuScale->fY)); 1409 SkScalarMul(SkIntToScalar(irect.fBottom), ppuScale->fY));
1412 clipRect.roundOut(clipIRect); 1410 clipRect.roundOut(clipIRect);
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 CLSID_XpsOMObjectFactory, 2267 CLSID_XpsOMObjectFactory,
2270 NULL, 2268 NULL,
2271 CLSCTX_INPROC_SERVER, 2269 CLSCTX_INPROC_SERVER,
2272 IID_PPV_ARGS(&this->fXpsFactory)), 2270 IID_PPV_ARGS(&this->fXpsFactory)),
2273 "Could not create factory for layer."); 2271 "Could not create factory for layer.");
2274 2272
2275 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), 2273 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
2276 "Could not create canvas for layer."); 2274 "Could not create canvas for layer.");
2277 } 2275 }
2278 2276
OLDNEW
« no previous file with comments | « src/core/SkStrokerPriv.cpp ('k') | src/effects/SkCornerPathEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698