Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "core/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1131 for (int col = min_col; col <= max_col; col++) { | 1131 for (int col = min_col; col <= max_col; col++) { |
| 1132 for (int row = min_row; row <= max_row; row++) { | 1132 for (int row = min_row; row <= max_row; row++) { |
| 1133 int start_x, start_y; | 1133 int start_x, start_y; |
| 1134 if (bAligned) { | 1134 if (bAligned) { |
| 1135 start_x = FXSYS_round(mtPattern2Device.e) + col * width - clip_box.left; | 1135 start_x = FXSYS_round(mtPattern2Device.e) + col * width - clip_box.left; |
| 1136 start_y = FXSYS_round(mtPattern2Device.f) + row * height - clip_box.top; | 1136 start_y = FXSYS_round(mtPattern2Device.f) + row * height - clip_box.top; |
| 1137 } else { | 1137 } else { |
| 1138 FX_FLOAT orig_x = col * pPattern->x_step(); | 1138 FX_FLOAT orig_x = col * pPattern->x_step(); |
| 1139 FX_FLOAT orig_y = row * pPattern->y_step(); | 1139 FX_FLOAT orig_y = row * pPattern->y_step(); |
| 1140 mtPattern2Device.Transform(orig_x, orig_y); | 1140 mtPattern2Device.Transform(orig_x, orig_y); |
| 1141 start_x = FXSYS_round(orig_x + left_offset) - clip_box.left; | 1141 |
| 1142 start_y = FXSYS_round(orig_y + top_offset) - clip_box.top; | 1142 pdfium::base::CheckedNumeric<int> safeStartX = |
| 1143 FXSYS_round(orig_x + left_offset); | |
| 1144 pdfium::base::CheckedNumeric<int> safeStartY = | |
| 1145 FXSYS_round(orig_y + top_offset); | |
| 1146 | |
| 1147 safeStartX -= clip_box.left; | |
| 1148 safeStartY -= clip_box.top; | |
| 1149 if (!safeStartX.IsValid() || !safeStartY.IsValid()) | |
| 1150 return; | |
| 1151 | |
| 1152 start_x = safeStartX.ValueOrDefault(0); | |
|
Lei Zhang
2016/09/07 21:44:32
Can't these be ValueOrDie() since we know we won't
| |
| 1153 start_y = safeStartY.ValueOrDefault(0); | |
| 1143 } | 1154 } |
| 1144 if (width == 1 && height == 1) { | 1155 if (width == 1 && height == 1) { |
| 1145 if (start_x < 0 || start_x >= clip_box.Width() || start_y < 0 || | 1156 if (start_x < 0 || start_x >= clip_box.Width() || start_y < 0 || |
| 1146 start_y >= clip_box.Height()) { | 1157 start_y >= clip_box.Height()) { |
| 1147 continue; | 1158 continue; |
| 1148 } | 1159 } |
| 1149 uint32_t* dest_buf = | 1160 uint32_t* dest_buf = |
| 1150 (uint32_t*)(screen.GetBuffer() + screen.GetPitch() * start_y + | 1161 (uint32_t*)(screen.GetBuffer() + screen.GetPitch() * start_y + |
| 1151 start_x * 4); | 1162 start_x * 4); |
| 1152 if (pPattern->colored()) | 1163 if (pPattern->colored()) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1195 } | 1206 } |
| 1196 } | 1207 } |
| 1197 if (bStroke) { | 1208 if (bStroke) { |
| 1198 const CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1209 const CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
| 1199 if (StrokeColor.IsPattern()) { | 1210 if (StrokeColor.IsPattern()) { |
| 1200 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1211 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
| 1201 bStroke = FALSE; | 1212 bStroke = FALSE; |
| 1202 } | 1213 } |
| 1203 } | 1214 } |
| 1204 } | 1215 } |
| OLD | NEW |