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

Side by Side Diff: src/core/SkScalerContext.cpp

Issue 2276583003: SkScalerContextRec::computeMatrices to return status. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/core/SkScalerContext.h ('k') | src/ports/SkFontHost_mac.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 8
9 #include "SkScalerContext.h" 9 #include "SkScalerContext.h"
10 #include "SkAutoPixmapStorage.h" 10 #include "SkAutoPixmapStorage.h"
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 680
681 void SkScalerContextRec::getSingleMatrix(SkMatrix* m) const { 681 void SkScalerContextRec::getSingleMatrix(SkMatrix* m) const {
682 this->getLocalMatrix(m); 682 this->getLocalMatrix(m);
683 683
684 // now concat the device matrix 684 // now concat the device matrix
685 SkMatrix deviceMatrix; 685 SkMatrix deviceMatrix;
686 this->getMatrixFrom2x2(&deviceMatrix); 686 this->getMatrixFrom2x2(&deviceMatrix);
687 m->postConcat(deviceMatrix); 687 m->postConcat(deviceMatrix);
688 } 688 }
689 689
690 void SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector * s, SkMatrix* sA, 690 bool SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector * s, SkMatrix* sA,
691 SkMatrix* GsA, SkMatrix* G_inv, SkMatri x* A_out) 691 SkMatrix* GsA, SkMatrix* G_inv, SkMatri x* A_out)
692 { 692 {
693 // A is the 'total' matrix. 693 // A is the 'total' matrix.
694 SkMatrix A; 694 SkMatrix A;
695 this->getSingleMatrix(&A); 695 this->getSingleMatrix(&A);
696 696
697 // The caller may find the 'total' matrix useful when dealing directly with EM sizes. 697 // The caller may find the 'total' matrix useful when dealing directly with EM sizes.
698 if (A_out) { 698 if (A_out) {
699 *A_out = A; 699 *A_out = A;
700 } 700 }
(...skipping 15 matching lines...) Expand all
716 { 716 {
717 s->fX = SK_Scalar1; 717 s->fX = SK_Scalar1;
718 s->fY = SK_Scalar1; 718 s->fY = SK_Scalar1;
719 sA->setScale(0, 0); 719 sA->setScale(0, 0);
720 if (GsA) { 720 if (GsA) {
721 GsA->setScale(0, 0); 721 GsA->setScale(0, 0);
722 } 722 }
723 if (G_inv) { 723 if (G_inv) {
724 G_inv->reset(); 724 G_inv->reset();
725 } 725 }
726 return; 726 return false;
727 } 727 }
728 728
729 // GA is the matrix A with rotation removed. 729 // GA is the matrix A with rotation removed.
730 SkMatrix GA; 730 SkMatrix GA;
731 bool skewedOrFlipped = A.getSkewX() || A.getSkewY() || A.getScaleX() < 0 || A.getScaleY() < 0; 731 bool skewedOrFlipped = A.getSkewX() || A.getSkewY() || A.getScaleX() < 0 || A.getScaleY() < 0;
732 if (skewedOrFlipped) { 732 if (skewedOrFlipped) {
733 // h is where A maps the horizontal baseline. 733 // h is where A maps the horizontal baseline.
734 SkPoint h = SkPoint::Make(SK_Scalar1, 0); 734 SkPoint h = SkPoint::Make(SK_Scalar1, 0);
735 A.mapPoints(&h, 1); 735 A.mapPoints(&h, 1);
736 736
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 *sA = A; 796 *sA = A;
797 sA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY)); 797 sA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY));
798 } 798 }
799 799
800 // The 'remainingWithoutRotation' matrix GsA is the non-rotational part of A without the scale. 800 // The 'remainingWithoutRotation' matrix GsA is the non-rotational part of A without the scale.
801 if (GsA) { 801 if (GsA) {
802 *GsA = GA; 802 *GsA = GA;
803 // G is rotational so reorders with the scale. 803 // G is rotational so reorders with the scale.
804 GsA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY)); 804 GsA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY));
805 } 805 }
806
807 return true;
806 } 808 }
807 809
808 SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() { 810 SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() {
809 // Why fPost2x2 can be used here. 811 // Why fPost2x2 can be used here.
810 // getSingleMatrix multiplies in getLocalMatrix, which consists of 812 // getSingleMatrix multiplies in getLocalMatrix, which consists of
811 // * fTextSize (a scale, which has no effect) 813 // * fTextSize (a scale, which has no effect)
812 // * fPreScaleX (a scale in x, which has no effect) 814 // * fPreScaleX (a scale in x, which has no effect)
813 // * fPreSkewX (has no effect, but would on vertical text alignment). 815 // * fPreSkewX (has no effect, but would on vertical text alignment).
814 // In other words, making the text bigger, stretching it along the 816 // In other words, making the text bigger, stretching it along the
815 // horizontal axis, or fake italicizing it does not move the baseline. 817 // horizontal axis, or fake italicizing it does not move the baseline.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 SkScalerContext* SkTypeface::createScalerContext(const SkScalerContextEffects& e ffects, 862 SkScalerContext* SkTypeface::createScalerContext(const SkScalerContextEffects& e ffects,
861 const SkDescriptor* desc, 863 const SkDescriptor* desc,
862 bool allowFailure) const { 864 bool allowFailure) const {
863 SkScalerContext* c = this->onCreateScalerContext(effects, desc); 865 SkScalerContext* c = this->onCreateScalerContext(effects, desc);
864 866
865 if (!c && !allowFailure) { 867 if (!c && !allowFailure) {
866 c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), effects, de sc); 868 c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), effects, de sc);
867 } 869 }
868 return c; 870 return c;
869 } 871 }
OLDNEW
« no previous file with comments | « src/core/SkScalerContext.h ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698