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

Side by Side Diff: core/fxcodec/jbig2/JBig2_Image.cpp

Issue 1801383002: Re-enable several MSVC warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "core/fxcodec/jbig2/JBig2_Image.h" 9 #include "core/fxcodec/jbig2/JBig2_Image.h"
10 #include "core/include/fxcrt/fx_coordinates.h" 10 #include "core/include/fxcrt/fx_coordinates.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 658 }
659 } 659 }
660 } 660 }
661 return 1; 661 return 1;
662 } 662 }
663 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, 663 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
664 int32_t x, 664 int32_t x,
665 int32_t y, 665 int32_t y,
666 JBig2ComposeOp op, 666 JBig2ComposeOp op,
667 const FX_RECT* pSrcRect) { 667 const FX_RECT* pSrcRect) {
668 int32_t xs0, ys0, xs1, ys1, xd0, yd0, xd1, yd1, xx, yy, w, h, middleDwords, 668 int32_t xs0 = 0, ys0 = 0, xs1 = 0, ys1 = 0;
dsinclair 2016/03/16 13:23:31 nit: one per line.
Wei Li 2016/03/16 17:51:31 Done.
Tom Sepez 2016/03/16 18:34:59 I didn't see how these could be used uninitialized
Wei Li 2016/03/17 02:24:05 Done.
669 lineLeft; 669 int32_t xd0 = 0, yd0 = 0, xx = 0, yy = 0;
670 FX_DWORD s1, d1, d2, shift, shift1, shift2, tmp, tmp1, tmp2, maskL, maskR, 670 FX_DWORD shift = 0, shift1 = 0, shift2 = 0;
671 maskM; 671 FX_DWORD tmp1 = 0, tmp2 = 0;
672 uint8_t *lineSrc, *lineDst, *sp, *dp; 672 uint8_t* sp = nullptr;
673 int32_t sw, sh; 673 uint8_t* dp = nullptr;
674 FX_DWORD tmp = 0;
674 if (!m_pData) { 675 if (!m_pData) {
675 return FALSE; 676 return FALSE;
676 } 677 }
677 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { 678 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) {
Tom Sepez 2016/03/16 18:34:59 nit: they probably mean >= 1048576, since x wont f
Wei Li 2016/03/17 02:24:05 Ack. I am not certain about the code here, will de
678 return FALSE; 679 return FALSE;
679 } 680 }
680 sw = pSrcRect->Width(); 681 int32_t sw = pSrcRect->Width();
681 sh = pSrcRect->Height(); 682 int32_t sh = pSrcRect->Height();
682 if (y < 0) { 683 if (y < 0) {
683 ys0 = -y; 684 ys0 = -y;
684 } else { 685 } else {
685 ys0 = 0; 686 ys0 = 0;
686 } 687 }
687 if (y + sh > pDst->m_nHeight) { 688 if (y + sh > pDst->m_nHeight) {
688 ys1 = pDst->m_nHeight - y; 689 ys1 = pDst->m_nHeight - y;
689 } else { 690 } else {
690 ys1 = sh; 691 ys1 = sh;
691 } 692 }
692 if (x < 0) { 693 if (x < 0) {
693 xs0 = -x; 694 xs0 = -x;
694 } else { 695 } else {
695 xs0 = 0; 696 xs0 = 0;
696 } 697 }
697 if (x + sw > pDst->m_nWidth) { 698 if (x + sw > pDst->m_nWidth) {
698 xs1 = pDst->m_nWidth - x; 699 xs1 = pDst->m_nWidth - x;
699 } else { 700 } else {
700 xs1 = sw; 701 xs1 = sw;
701 } 702 }
702 if ((ys0 >= ys1) || (xs0 >= xs1)) { 703 if ((ys0 >= ys1) || (xs0 >= xs1)) {
703 return 0; 704 return 0;
704 } 705 }
705 w = xs1 - xs0; 706 int32_t w = xs1 - xs0;
706 h = ys1 - ys0; 707 int32_t h = ys1 - ys0;
707 if (y < 0) { 708 if (y < 0) {
708 yd0 = 0; 709 yd0 = 0;
709 } else { 710 } else {
710 yd0 = y; 711 yd0 = y;
711 } 712 }
712 if (x < 0) { 713 if (x < 0) {
713 xd0 = 0; 714 xd0 = 0;
714 } else { 715 } else {
715 xd0 = x; 716 xd0 = x;
716 } 717 }
717 xd1 = xd0 + w; 718 int32_t xd1 = xd0 + w;
718 yd1 = yd0 + h; 719 int32_t yd1 = yd0 + h;
719 d1 = xd0 & 31; 720 int32_t d1 = xd0 & 31;
720 d2 = xd1 & 31; 721 int32_t d2 = xd1 & 31;
721 s1 = xs0 & 31; 722 int32_t s1 = xs0 & 31;
722 maskL = 0xffffffff >> d1; 723 int32_t maskL = 0xffffffff >> d1;
723 maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32); 724 int32_t maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32);
724 maskM = maskL & maskR; 725 int32_t maskM = maskL & maskR;
725 lineSrc = m_pData + (pSrcRect->top + ys0) * m_nStride + 726 uint8_t* lineSrc = m_pData + (pSrcRect->top + ys0) * m_nStride +
726 (((xs0 + pSrcRect->left) >> 5) << 2); 727 (((xs0 + pSrcRect->left) >> 5) << 2);
727 lineLeft = m_nStride - ((xs0 >> 5) << 2); 728 int32_t lineLeft = m_nStride - ((xs0 >> 5) << 2);
728 lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2); 729 uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
729 if ((xd0 & ~31) == ((xd1 - 1) & ~31)) { 730 if ((xd0 & ~31) == ((xd1 - 1) & ~31)) {
730 if ((xs0 & ~31) == ((xs1 - 1) & ~31)) { 731 if ((xs0 & ~31) == ((xs1 - 1) & ~31)) {
731 if (s1 > d1) { 732 if (s1 > d1) {
732 shift = s1 - d1; 733 shift = s1 - d1;
733 for (yy = yd0; yy < yd1; yy++) { 734 for (yy = yd0; yy < yd1; yy++) {
734 tmp1 = JBIG2_GETDWORD(lineSrc) << shift; 735 tmp1 = JBIG2_GETDWORD(lineSrc) << shift;
735 tmp2 = JBIG2_GETDWORD(lineDst); 736 tmp2 = JBIG2_GETDWORD(lineDst);
736 switch (op) { 737 switch (op) {
737 case JBIG2_COMPOSE_OR: 738 case JBIG2_COMPOSE_OR:
738 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 739 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 814 }
814 lineDst[0] = (uint8_t)(tmp >> 24); 815 lineDst[0] = (uint8_t)(tmp >> 24);
815 lineDst[1] = (uint8_t)(tmp >> 16); 816 lineDst[1] = (uint8_t)(tmp >> 16);
816 lineDst[2] = (uint8_t)(tmp >> 8); 817 lineDst[2] = (uint8_t)(tmp >> 8);
817 lineDst[3] = (uint8_t)tmp; 818 lineDst[3] = (uint8_t)tmp;
818 lineSrc += m_nStride; 819 lineSrc += m_nStride;
819 lineDst += pDst->m_nStride; 820 lineDst += pDst->m_nStride;
820 } 821 }
821 } 822 }
822 } else { 823 } else {
824 int32_t middleDwords = 0;
Tom Sepez 2016/03/16 18:34:59 I don't think this needs to persist between blocks
Wei Li 2016/03/17 02:24:05 Done.
823 if (s1 > d1) { 825 if (s1 > d1) {
824 shift1 = s1 - d1; 826 shift1 = s1 - d1;
825 shift2 = 32 - shift1; 827 shift2 = 32 - shift1;
826 middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 828 middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
827 for (yy = yd0; yy < yd1; yy++) { 829 for (yy = yd0; yy < yd1; yy++) {
828 sp = lineSrc; 830 sp = lineSrc;
829 dp = lineDst; 831 dp = lineDst;
830 if (d1 != 0) { 832 if (d1 != 0) {
831 tmp1 = (JBIG2_GETDWORD(sp) << shift1) | 833 tmp1 = (JBIG2_GETDWORD(sp) << shift1) |
832 (JBIG2_GETDWORD(sp + 4) >> shift2); 834 (JBIG2_GETDWORD(sp + 4) >> shift2);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 dp[2] = (uint8_t)(tmp >> 8); 1092 dp[2] = (uint8_t)(tmp >> 8);
1091 dp[3] = (uint8_t)tmp; 1093 dp[3] = (uint8_t)tmp;
1092 } 1094 }
1093 lineSrc += m_nStride; 1095 lineSrc += m_nStride;
1094 lineDst += pDst->m_nStride; 1096 lineDst += pDst->m_nStride;
1095 } 1097 }
1096 } 1098 }
1097 } 1099 }
1098 return 1; 1100 return 1;
1099 } 1101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698