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/fxge/agg/fx_agg_driver.h" | 7 #include "core/fxge/agg/fx_agg_driver.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 277 } |
278 | 278 |
279 void CFX_AggDeviceDriver::SaveState() { | 279 void CFX_AggDeviceDriver::SaveState() { |
280 CFX_ClipRgn* pClip = nullptr; | 280 CFX_ClipRgn* pClip = nullptr; |
281 if (m_pClipRgn) { | 281 if (m_pClipRgn) { |
282 pClip = new CFX_ClipRgn(*m_pClipRgn); | 282 pClip = new CFX_ClipRgn(*m_pClipRgn); |
283 } | 283 } |
284 m_StateStack.Add(pClip); | 284 m_StateStack.Add(pClip); |
285 } | 285 } |
286 | 286 |
287 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { | 287 void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) { |
288 if (m_StateStack.GetSize() == 0) { | |
289 delete m_pClipRgn; | |
290 m_pClipRgn = nullptr; | |
291 return; | |
292 } | |
293 CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1]; | |
294 delete m_pClipRgn; | 288 delete m_pClipRgn; |
295 m_pClipRgn = nullptr; | 289 m_pClipRgn = nullptr; |
| 290 |
| 291 int size = m_StateStack.GetSize(); |
| 292 if (!size) |
| 293 return; |
| 294 |
| 295 CFX_ClipRgn* pSavedClip = m_StateStack[size - 1]; |
296 if (bKeepSaved) { | 296 if (bKeepSaved) { |
297 if (pSavedClip) { | 297 if (pSavedClip) { |
298 m_pClipRgn = new CFX_ClipRgn(*pSavedClip); | 298 m_pClipRgn = new CFX_ClipRgn(*pSavedClip); |
299 } | 299 } |
300 } else { | 300 } else { |
301 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1); | 301 m_StateStack.RemoveAt(size - 1); |
302 m_pClipRgn = pSavedClip; | 302 m_pClipRgn = pSavedClip; |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) { | 306 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) { |
307 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), | 307 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), |
308 rasterizer.max_x() + 1, rasterizer.max_y() + 1); | 308 rasterizer.max_x() + 1, rasterizer.max_y() + 1); |
309 path_rect.Intersect(m_pClipRgn->GetBox()); | 309 path_rect.Intersect(m_pClipRgn->GetBox()); |
310 CFX_DIBitmapRef mask; | 310 CFX_DIBitmapRef mask; |
311 CFX_DIBitmap* pThisLayer = mask.New(); | 311 CFX_DIBitmap* pThisLayer = mask.New(); |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 SetDeviceDriver(pDriver); | 1815 SetDeviceDriver(pDriver); |
1816 return true; | 1816 return true; |
1817 } | 1817 } |
1818 | 1818 |
1819 CFX_FxgeDevice::~CFX_FxgeDevice() { | 1819 CFX_FxgeDevice::~CFX_FxgeDevice() { |
1820 if (m_bOwnedBitmap) { | 1820 if (m_bOwnedBitmap) { |
1821 delete GetBitmap(); | 1821 delete GetBitmap(); |
1822 } | 1822 } |
1823 } | 1823 } |
1824 #endif | 1824 #endif |
OLD | NEW |