Subversion Repositories tpanel

Rev

Rev 339 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 339 Rev 401
Line 15... Line 15...
15
 * along with this program; if not, write to the Free Software Foundation,
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
17
 */
18
#include <string>
18
#include <string>
19
#include <vector>
19
#include <vector>
-
 
20
#include <algorithm>
20
 
21
 
21
#include <include/core/SkImage.h>
22
#include <include/core/SkImage.h>
22
#include <include/core/SkCanvas.h>
23
#include <include/core/SkCanvas.h>
23
#include <include/core/SkPixmap.h>
24
#include <include/core/SkPixmap.h>
24
#include <include/core/SkBitmap.h>
25
#include <include/core/SkBitmap.h>
Line 33... Line 34...
33
#include "terror.h"
34
#include "terror.h"
34
 
35
 
35
using namespace Border;
36
using namespace Border;
36
using std::string;
37
using std::string;
37
using std::vector;
38
using std::vector;
-
 
39
using std::min;
38
 
40
 
39
/**
41
/**
40
 * The following table defines some of the system borders. It is mostly a
42
 * The following table defines some of the system borders. It is mostly a
41
 * fallback table but defines whether a border should be calculated internaly
43
 * fallback table but defines whether a border should be calculated internaly
42
 * or constructed out of the images in the system border folder. The later is
44
 * or constructed out of the images in the system border folder. The later is
Line 644... Line 646...
644
 * @param mask      A bitmap containg the border image. This must be of the
646
 * @param mask      A bitmap containg the border image. This must be of the
645
 *                  same size as \b bm.
647
 *                  same size as \b bm.
646
 * @param ep        The side (left, right, top, bottom, outside) who should be
648
 * @param ep        The side (left, right, top, bottom, outside) who should be
647
 *                  filtered. The option "outside" filters all four sides.
649
 *                  filtered. The option "outside" filters all four sides.
648
 */
650
 */
649
void TIntBorder::erasePart(SkBitmap *bm, const SkBitmap& mask, ERASE_PART_t ep)
651
void TIntBorder::erasePart(SkBitmap *bm, const SkBitmap& mask, ERASE_PART_t ep, int fwidth)
650
{
652
{
651
    DECL_TRACER("TIntBorder::erasePart(SkBitmap *bm, const SkBitmap& mask, ERASE_PART_t ep)");
653
    DECL_TRACER("TIntBorder::erasePart(SkBitmap *bm, const SkBitmap& mask, ERASE_PART_t ep, int fwidth)");
652
 
654
 
653
    if (!bm || bm->empty() || ep == ERASE_NONE)
655
    if (!bm || bm->empty() || ep == ERASE_NONE)
654
        return;
656
        return;
655
 
657
 
656
    int x, y;
658
    int x, y;
657
    int width = bm->info().width();
659
    int width = bm->info().width();
658
    int height = bm->info().height();
660
    int height = bm->info().height();
-
 
661
    int tmpHeight, tmpWidth;
-
 
662
 
-
 
663
    tmpWidth = (fwidth > 0 ? min(fwidth, width) : width);
-
 
664
    tmpHeight = (fwidth > 0 ? min(fwidth, height) : height);
659
 
665
 
660
    switch(ep)
666
    switch(ep)
661
    {
667
    {
662
        case ERASE_LEFT_RIGHT:
668
        case ERASE_LEFT_RIGHT:
663
            for (y = 0; y < height; ++y)
669
            for (y = 0; y < height; ++y)
664
            {
670
            {
665
                for (x = 0; x < width; ++x)
671
                for (x = 0; x < tmpWidth; ++x)
666
                {
672
                {
667
                    SkColor *wpix = bm->getAddr32(x, y);
673
                    SkColor *wpix = bm->getAddr32(x, y);
668
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
674
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
669
 
675
 
670
                    if (alpha == 0)
676
                    if (alpha == 0)
Line 676... Line 682...
676
        break;
682
        break;
677
 
683
 
678
        case ERASE_RIGHT_LEFT:
684
        case ERASE_RIGHT_LEFT:
679
            for (y = 0; y < height; ++y)
685
            for (y = 0; y < height; ++y)
680
            {
686
            {
681
                for (x = width - 1; x >= 0; --x)
687
                for (x = width - 1; x >= (width - tmpWidth); --x)
682
                {
688
                {
683
                    SkColor *wpix = bm->getAddr32(x, y);;
689
                    SkColor *wpix = bm->getAddr32(x, y);;
684
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
690
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
685
 
691
 
686
                    if (alpha == 0)
692
                    if (alpha == 0)
Line 692... Line 698...
692
        break;
698
        break;
693
 
699
 
694
        case ERASE_TOP_DOWN:
700
        case ERASE_TOP_DOWN:
695
            for (x = 0; x < width; ++x)
701
            for (x = 0; x < width; ++x)
696
            {
702
            {
697
                for (y = 0; y < height; ++y)
703
                for (y = 0; y < tmpHeight; ++y)
698
                {
704
                {
699
                    SkColor *wpix = bm->getAddr32(x, y);;
705
                    SkColor *wpix = bm->getAddr32(x, y);;
700
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
706
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
701
 
707
 
702
                    if (alpha == 0)
708
                    if (alpha == 0)
Line 708... Line 714...
708
        break;
714
        break;
709
 
715
 
710
        case ERASE_BOTTOM_UP:
716
        case ERASE_BOTTOM_UP:
711
            for (x = 0; x < width; ++x)
717
            for (x = 0; x < width; ++x)
712
            {
718
            {
713
                for (y = height - 1; y >= 0; --y)
719
                for (y = height - 1; y >= (height - tmpHeight); --y)
714
                {
720
                {
715
                    SkColor *wpix = bm->getAddr32(x, y);;
721
                    SkColor *wpix = bm->getAddr32(x, y);
716
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
722
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
717
 
723
 
718
                    if (alpha == 0)
724
                    if (alpha == 0)
719
                        *wpix = SK_ColorTRANSPARENT;
725
                        *wpix = SK_ColorTRANSPARENT;
720
                    else
726
                    else
Line 724... Line 730...
724
        break;
730
        break;
725
 
731
 
726
        case ERASE_OUTSIDE:
732
        case ERASE_OUTSIDE:
727
            for (y = 0; y < height; ++y)
733
            for (y = 0; y < height; ++y)
728
            {
734
            {
729
                for (x = 0; x < width; ++x)         // from left
735
                for (x = 0; x < tmpWidth; ++x)         // from left
730
                {
736
                {
731
                    SkColor *wpix = bm->getAddr32(x, y);
737
                    SkColor *wpix = bm->getAddr32(x, y);
732
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
738
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
733
 
739
 
734
                    if (alpha == 0)
740
                    if (alpha == 0)
735
                        *wpix = SK_ColorTRANSPARENT;
741
                        *wpix = SK_ColorTRANSPARENT;
736
                    else
742
                    else
737
                        break;
743
                        break;
738
                }
744
                }
739
 
745
 
740
                for (x = width - 1; x >= 0; --x)    // from right
746
                for (x = width - 1; x >= (width - tmpWidth); --x)    // from right
741
                {
747
                {
742
                    SkColor *wpix = bm->getAddr32(x, y);;
748
                    SkColor *wpix = bm->getAddr32(x, y);
743
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
749
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
744
 
750
 
745
                    if (alpha == 0)
751
                    if (alpha == 0)
746
                        *wpix = SK_ColorTRANSPARENT;
752
                        *wpix = SK_ColorTRANSPARENT;
747
                    else
753
                    else
748
                        break;
754
                        break;
749
                }
755
                }
-
 
756
            }
750
 
757
 
-
 
758
            for (x = 0; x < width; ++x)
-
 
759
            {
751
                for (y = 0; y < height; ++y)        // from top
760
                for (y = 0; y < tmpHeight; ++y)        // from top
752
                {
761
                {
753
                    SkColor *wpix = bm->getAddr32(x, y);;
762
                    SkColor *wpix = bm->getAddr32(x, y);
754
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
763
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
755
 
764
 
756
                    if (alpha == 0)
765
                    if (alpha == 0)
757
                        *wpix = SK_ColorTRANSPARENT;
766
                        *wpix = SK_ColorTRANSPARENT;
758
                    else
767
                    else
759
                        break;
768
                        break;
760
                }
769
                }
761
 
770
 
762
                for (y = height - 1; y >= 0; --y)   // from bottom
771
                for (y = height - 1; y >= (height - tmpHeight); --y)   // from bottom
763
                {
772
                {
764
                    SkColor *wpix = bm->getAddr32(x, y);;
773
                    SkColor *wpix = bm->getAddr32(x, y);
765
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
774
                    SkColor alpha = SkColorGetA(mask.getColor(x, y));
766
 
775
 
767
                    if (alpha == 0)
776
                    if (alpha == 0)
768
                        *wpix = SK_ColorTRANSPARENT;
777
                        *wpix = SK_ColorTRANSPARENT;
769
                    else
778
                    else