OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 |
| 7 #include "xfa/fxgraphics/cfx_pattern.h" |
| 8 |
| 9 CFX_Pattern::CFX_Pattern() : m_type(FX_PATTERN_None) { |
| 10 m_matrix.SetIdentity(); |
| 11 } |
| 12 |
| 13 CFX_Pattern::~CFX_Pattern() { |
| 14 m_type = FX_PATTERN_None; |
| 15 } |
| 16 |
| 17 FX_ERR CFX_Pattern::Create(CFX_DIBitmap* bitmap, |
| 18 const FX_FLOAT xStep, |
| 19 const FX_FLOAT yStep, |
| 20 CFX_Matrix* matrix) { |
| 21 if (!bitmap) |
| 22 return FX_ERR_Parameter_Invalid; |
| 23 if (m_type != FX_PATTERN_None) |
| 24 return FX_ERR_Property_Invalid; |
| 25 |
| 26 m_type = FX_PATTERN_Bitmap; |
| 27 m_bitmapInfo.bitmap = bitmap; |
| 28 m_bitmapInfo.x1Step = xStep; |
| 29 m_bitmapInfo.y1Step = yStep; |
| 30 if (matrix) { |
| 31 m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, |
| 32 matrix->f); |
| 33 } |
| 34 return FX_ERR_Succeeded; |
| 35 } |
| 36 |
| 37 FX_ERR CFX_Pattern::Create(FX_HatchStyle hatchStyle, |
| 38 const FX_ARGB foreArgb, |
| 39 const FX_ARGB backArgb, |
| 40 CFX_Matrix* matrix) { |
| 41 if (hatchStyle < FX_HATCHSTYLE_Horizontal || |
| 42 hatchStyle > FX_HATCHSTYLE_SolidDiamond) { |
| 43 return FX_ERR_Parameter_Invalid; |
| 44 } |
| 45 if (m_type != FX_PATTERN_None) { |
| 46 return FX_ERR_Property_Invalid; |
| 47 } |
| 48 m_type = FX_PATTERN_Hatch; |
| 49 m_hatchInfo.hatchStyle = hatchStyle; |
| 50 m_hatchInfo.foreArgb = foreArgb; |
| 51 m_hatchInfo.backArgb = backArgb; |
| 52 if (matrix) { |
| 53 m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, |
| 54 matrix->f); |
| 55 } |
| 56 return FX_ERR_Succeeded; |
| 57 } |
OLD | NEW |