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

Side by Side Diff: core/src/fxge/ge/fx_ge_device.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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
« no previous file with comments | « core/src/fxge/dib/fx_dib_transform.cpp ('k') | core/src/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 CFX_RenderDevice::CFX_RenderDevice() 8 CFX_RenderDevice::CFX_RenderDevice()
9 { 9 {
10 m_pDeviceDriver = NULL; 10 m_pDeviceDriver = NULL;
(...skipping 17 matching lines...) Expand all
28 m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL); 28 m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL);
29 m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); 29 m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS);
30 m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); 30 m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS);
31 if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { 31 if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) {
32 m_ClipBox.left = 0; 32 m_ClipBox.left = 0;
33 m_ClipBox.top = 0; 33 m_ClipBox.top = 0;
34 m_ClipBox.right = m_Width; 34 m_ClipBox.right = m_Width;
35 m_ClipBox.bottom = m_Height; 35 m_ClipBox.bottom = m_Height;
36 } 36 }
37 } 37 }
38 FX_BOOL CFX_RenderDevice::StartRendering() 38 bool CFX_RenderDevice::StartRendering()
39 { 39 {
40 return m_pDeviceDriver->StartRendering(); 40 return m_pDeviceDriver->StartRendering();
41 } 41 }
42 void CFX_RenderDevice::EndRendering() 42 void CFX_RenderDevice::EndRendering()
43 { 43 {
44 m_pDeviceDriver->EndRendering(); 44 m_pDeviceDriver->EndRendering();
45 } 45 }
46 void CFX_RenderDevice::SaveState() 46 void CFX_RenderDevice::SaveState()
47 { 47 {
48 m_pDeviceDriver->SaveState(); 48 m_pDeviceDriver->SaveState();
49 } 49 }
50 void CFX_RenderDevice::RestoreState(FX_BOOL bKeepSaved) 50 void CFX_RenderDevice::RestoreState(bool bKeepSaved)
51 { 51 {
52 m_pDeviceDriver->RestoreState(bKeepSaved); 52 m_pDeviceDriver->RestoreState(bKeepSaved);
53 UpdateClipBox(); 53 UpdateClipBox();
54 } 54 }
55 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const 55 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const
56 { 56 {
57 return m_pDeviceDriver->GetDeviceCaps(caps_id); 57 return m_pDeviceDriver->GetDeviceCaps(caps_id);
58 } 58 }
59 CFX_Matrix CFX_RenderDevice::GetCTM() const 59 CFX_Matrix CFX_RenderDevice::GetCTM() const
60 { 60 {
61 return m_pDeviceDriver->GetCTM(); 61 return m_pDeviceDriver->GetCTM();
62 } 62 }
63 FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, int height) const 63 bool CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, int height) const
64 { 64 {
65 if (m_RenderCaps & FXRC_CMYK_OUTPUT) { 65 if (m_RenderCaps & FXRC_CMYK_OUTPUT) {
66 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FX DIB_Cmyka : FXDIB_Cmyk); 66 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FX DIB_Cmyka : FXDIB_Cmyk);
67 } else if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { 67 } else if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) {
68 return pDIB->Create(width, height, FXDIB_8bppMask); 68 return pDIB->Create(width, height, FXDIB_8bppMask);
69 } else 69 } else
70 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 70 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
71 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FX DIB_Argb : FXDIB_Rgb32); 71 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FX DIB_Argb : FXDIB_Rgb32);
72 #else 72 #else
73 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FX DIB_Argb : FXDIB_Rgb); 73 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FX DIB_Argb : FXDIB_Rgb);
74 #endif 74 #endif
75 } 75 }
76 FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, 76 bool CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
77 const CFX_AffineMatrix* pObject2Device, 77 const CFX_AffineMatrix* pObject2Device,
78 int fill_mode 78 int fill_mode
79 ) 79 )
80 { 80 {
81 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, fill_mode) ) { 81 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, fill_mode) ) {
82 return FALSE; 82 return false;
83 } 83 }
84 UpdateClipBox(); 84 UpdateClipBox();
85 return TRUE; 85 return true;
86 } 86 }
87 FX_BOOL CFX_RenderDevice::SetClip_PathStroke(const CFX_PathData* pPathData, 87 bool CFX_RenderDevice::SetClip_PathStroke(const CFX_PathData* pPathData,
88 const CFX_AffineMatrix* pObject2Device, 88 const CFX_AffineMatrix* pObject2Device,
89 const CFX_GraphStateData* pGraphState 89 const CFX_GraphStateData* pGraphState
90 ) 90 )
91 { 91 {
92 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, pGraphSt ate)) { 92 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, pGraphSt ate)) {
93 return FALSE; 93 return false;
94 } 94 }
95 UpdateClipBox(); 95 UpdateClipBox();
96 return TRUE; 96 return true;
97 } 97 }
98 FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect) 98 bool CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect)
99 { 99 {
100 CFX_PathData path; 100 CFX_PathData path;
101 path.AppendRect((FX_FLOAT)(pRect->left), (FX_FLOAT)(pRect->bottom), (FX_FLOA T)(pRect->right), (FX_FLOAT)(pRect->top)); 101 path.AppendRect((FX_FLOAT)(pRect->left), (FX_FLOAT)(pRect->bottom), (FX_FLOA T)(pRect->right), (FX_FLOAT)(pRect->top));
102 if (!SetClip_PathFill(&path, NULL, FXFILL_WINDING)) { 102 if (!SetClip_PathFill(&path, NULL, FXFILL_WINDING)) {
103 return FALSE; 103 return false;
104 } 104 }
105 UpdateClipBox(); 105 UpdateClipBox();
106 return TRUE; 106 return true;
107 } 107 }
108 void CFX_RenderDevice::UpdateClipBox() 108 void CFX_RenderDevice::UpdateClipBox()
109 { 109 {
110 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) { 110 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) {
111 return; 111 return;
112 } 112 }
113 m_ClipBox.left = 0; 113 m_ClipBox.left = 0;
114 m_ClipBox.top = 0; 114 m_ClipBox.top = 0;
115 m_ClipBox.right = m_Width; 115 m_ClipBox.right = m_Width;
116 m_ClipBox.bottom = m_Height; 116 m_ClipBox.bottom = m_Height;
117 } 117 }
118 FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, 118 bool CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
119 const CFX_AffineMatrix* pObject2Device, 119 const CFX_AffineMatrix* pObject2Device,
120 const CFX_GraphStateData* pGraphState, 120 const CFX_GraphStateData* pGraphState,
121 FX_DWORD fill_color, FX_DWORD stroke_color, i nt fill_mode, 121 FX_DWORD fill_color, FX_DWORD stroke_color, i nt fill_mode,
122 int alpha_flag, void* pIccTransform, int blen d_type) 122 int alpha_flag, void* pIccTransform, int blen d_type)
123 { 123 {
124 uint8_t fill_alpha, stroke_alpha; 124 uint8_t fill_alpha, stroke_alpha;
125 if (FXGETFLAG_COLORTYPE(alpha_flag)) { 125 if (FXGETFLAG_COLORTYPE(alpha_flag)) {
126 fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag); 126 fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag);
127 stroke_alpha = FXGETFLAG_ALPHA_STROKE(alpha_flag); 127 stroke_alpha = FXGETFLAG_ALPHA_STROKE(alpha_flag);
128 } else { 128 } else {
(...skipping 12 matching lines...) Expand all
141 if (pObject2Device) { 141 if (pObject2Device) {
142 pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, y1); 142 pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, y1);
143 pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, y2); 143 pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, y2);
144 } else { 144 } else {
145 x1 = pPoints[0].m_PointX; 145 x1 = pPoints[0].m_PointX;
146 y1 = pPoints[0].m_PointY; 146 y1 = pPoints[0].m_PointY;
147 x2 = pPoints[1].m_PointX; 147 x2 = pPoints[1].m_PointX;
148 y2 = pPoints[1].m_PointY; 148 y2 = pPoints[1].m_PointY;
149 } 149 }
150 DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, alpha_flag, pIcc Transform, blend_type); 150 DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, alpha_flag, pIcc Transform, blend_type);
151 return TRUE; 151 return true;
152 } 152 }
153 if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && stroke_alpha == 0) { 153 if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && stroke_alpha == 0) {
154 CFX_FloatRect rect_f; 154 CFX_FloatRect rect_f;
155 if (!(fill_mode & FXFILL_RECT_AA) && pPathData->IsRect(pObject2Device, & rect_f)) { 155 if (!(fill_mode & FXFILL_RECT_AA) && pPathData->IsRect(pObject2Device, & rect_f)) {
156 FX_RECT rect_i = rect_f.GetOutterRect(); 156 FX_RECT rect_i = rect_f.GetOutterRect();
157 int width = (int)FXSYS_ceil(rect_f.right - rect_f.left); 157 int width = (int)FXSYS_ceil(rect_f.right - rect_f.left);
158 if (width < 1) { 158 if (width < 1) {
159 width = 1; 159 width = 1;
160 if (rect_i.left == rect_i.right) { 160 if (rect_i.left == rect_i.right) {
161 rect_i.right ++; 161 rect_i.right ++;
(...skipping 14 matching lines...) Expand all
176 } 176 }
177 } 177 }
178 if (rect_i.Height() >= height + 1) { 178 if (rect_i.Height() >= height + 1) {
179 if (rect_f.top - (FX_FLOAT)(rect_i.top) > (FX_FLOAT)(rect_i.bott om) - rect_f.bottom) { 179 if (rect_f.top - (FX_FLOAT)(rect_i.top) > (FX_FLOAT)(rect_i.bott om) - rect_f.bottom) {
180 rect_i.top ++; 180 rect_i.top ++;
181 } else { 181 } else {
182 rect_i.bottom --; 182 rect_i.bottom --;
183 } 183 }
184 } 184 }
185 if (FillRect(&rect_i, fill_color, alpha_flag, pIccTransform, blend_t ype)) { 185 if (FillRect(&rect_i, fill_color, alpha_flag, pIccTransform, blend_t ype)) {
186 return TRUE; 186 return true;
187 } 187 }
188 } 188 }
189 } 189 }
190 if((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && !(fill_mode & FX_FILL_TEXT_MODE)) { 190 if((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && !(fill_mode & FX_FILL_TEXT_MODE)) {
191 CFX_PathData newPath; 191 CFX_PathData newPath;
192 FX_BOOL bThin = FALSE; 192 bool bThin = false;
193 if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bTh in, m_pDeviceDriver->GetDriverType())) { 193 if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bTh in, m_pDeviceDriver->GetDriverType())) {
194 CFX_GraphStateData graphState; 194 CFX_GraphStateData graphState;
195 graphState.m_LineWidth = 0.0f; 195 graphState.m_LineWidth = 0.0f;
196 FX_DWORD strokecolor = fill_color; 196 FX_DWORD strokecolor = fill_color;
197 if (bThin) { 197 if (bThin) {
198 if (FXGETFLAG_COLORTYPE(alpha_flag)) { 198 if (FXGETFLAG_COLORTYPE(alpha_flag)) {
199 FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2); 199 FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2);
200 } else { 200 } else {
201 strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x 00ffffff)); 201 strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x 00ffffff));
202 } 202 }
203 } 203 }
204 CFX_AffineMatrix* pMatrix = NULL; 204 CFX_AffineMatrix* pMatrix = NULL;
205 if (pObject2Device && !pObject2Device->IsIdentity()) { 205 if (pObject2Device && !pObject2Device->IsIdentity()) {
206 pMatrix = (CFX_AffineMatrix*)pObject2Device; 206 pMatrix = (CFX_AffineMatrix*)pObject2Device;
207 } 207 }
208 int smooth_path = FX_ZEROAREA_FILL; 208 int smooth_path = FX_ZEROAREA_FILL;
209 if (fill_mode & FXFILL_NOPATHSMOOTH) { 209 if (fill_mode & FXFILL_NOPATHSMOOTH) {
210 smooth_path |= FXFILL_NOPATHSMOOTH; 210 smooth_path |= FXFILL_NOPATHSMOOTH;
211 } 211 }
212 m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokec olor, smooth_path, alpha_flag, pIccTransform, blend_type); 212 m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokec olor, smooth_path, alpha_flag, pIccTransform, blend_type);
213 } 213 }
214 } 214 }
215 if ((fill_mode & 3) && fill_alpha && stroke_alpha < 0xff && (fill_mode & FX_ FILL_STROKE)) { 215 if ((fill_mode & 3) && fill_alpha && stroke_alpha < 0xff && (fill_mode & FX_ FILL_STROKE)) {
216 if (!(m_RenderCaps & FXRC_GET_BITS)) { 216 if (!(m_RenderCaps & FXRC_GET_BITS)) {
217 return FALSE; 217 return false;
218 } 218 }
219 CFX_FloatRect bbox; 219 CFX_FloatRect bbox;
220 if (pGraphState) { 220 if (pGraphState) {
221 bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, pGraphSta te->m_MiterLimit); 221 bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, pGraphSta te->m_MiterLimit);
222 } else { 222 } else {
223 bbox = pPathData->GetBoundingBox(); 223 bbox = pPathData->GetBoundingBox();
224 } 224 }
225 if (pObject2Device) { 225 if (pObject2Device) {
226 bbox.Transform(pObject2Device); 226 bbox.Transform(pObject2Device);
227 } 227 }
228 CFX_Matrix ctm = GetCTM(); 228 CFX_Matrix ctm = GetCTM();
229 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); 229 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a);
230 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); 230 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d);
231 FX_RECT rect = bbox.GetOutterRect(); 231 FX_RECT rect = bbox.GetOutterRect();
232 CFX_DIBitmap bitmap, Backdrop; 232 CFX_DIBitmap bitmap, Backdrop;
233 if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX) , FXSYS_round(rect.Height() * fScaleY))) { 233 if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX) , FXSYS_round(rect.Height() * fScaleY))) {
234 return FALSE; 234 return false;
235 } 235 }
236 if (bitmap.HasAlpha()) { 236 if (bitmap.HasAlpha()) {
237 bitmap.Clear(0); 237 bitmap.Clear(0);
238 Backdrop.Copy(&bitmap); 238 Backdrop.Copy(&bitmap);
239 } else { 239 } else {
240 if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) { 240 if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) {
241 return FALSE; 241 return false;
242 } 242 }
243 Backdrop.Copy(&bitmap); 243 Backdrop.Copy(&bitmap);
244 } 244 }
245 CFX_FxgeDevice bitmap_device; 245 CFX_FxgeDevice bitmap_device;
246 bitmap_device.Attach(&bitmap, 0, FALSE, &Backdrop, TRUE); 246 bitmap_device.Attach(&bitmap, 0, false, &Backdrop, true);
247 CFX_AffineMatrix matrix; 247 CFX_AffineMatrix matrix;
248 if (pObject2Device) { 248 if (pObject2Device) {
249 matrix = *pObject2Device; 249 matrix = *pObject2Device;
250 } 250 }
251 matrix.TranslateI(-rect.left, -rect.top); 251 matrix.TranslateI(-rect.left, -rect.top);
252 matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); 252 matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0);
253 if (!bitmap_device.GetDeviceDriver()->DrawPath(pPathData, &matrix, pGrap hState, fill_color, stroke_color, fill_mode, alpha_flag, pIccTransform, blend_ty pe)) { 253 if (!bitmap_device.GetDeviceDriver()->DrawPath(pPathData, &matrix, pGrap hState, fill_color, stroke_color, fill_mode, alpha_flag, pIccTransform, blend_ty pe)) {
254 return FALSE; 254 return false;
255 } 255 }
256 FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), FXSYS_round( rect.Height() * fScaleY)); 256 FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), FXSYS_round( rect.Height() * fScaleY));
257 return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, rect .top, FXDIB_BLEND_NORMAL); 257 return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, rect .top, FXDIB_BLEND_NORMAL);
258 } 258 }
259 return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, fil l_color, stroke_color, fill_mode, alpha_flag, pIccTransform, blend_type); 259 return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, fil l_color, stroke_color, fill_mode, alpha_flag, pIccTransform, blend_type);
260 } 260 }
261 FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, FX_DWORD color, int alpha_flag, void* pIccTransform) 261 bool CFX_RenderDevice::SetPixel(int x, int y, FX_DWORD color, int alpha_flag, vo id* pIccTransform)
262 { 262 {
263 if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) { 263 if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) {
264 return TRUE; 264 return true;
265 } 265 }
266 FX_RECT rect(x, y, x + 1, y + 1); 266 FX_RECT rect(x, y, x + 1, y + 1);
267 return FillRect(&rect, color, alpha_flag, pIccTransform); 267 return FillRect(&rect, color, alpha_flag, pIccTransform);
268 } 268 }
269 FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, in t alpha_flag, void* pIccTransform, int blend_type) 269 bool CFX_RenderDevice::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, int a lpha_flag, void* pIccTransform, int blend_type)
270 { 270 {
271 if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform, blend_type)) { 271 if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform, blend_type)) {
272 return TRUE; 272 return true;
273 } 273 }
274 if (!(m_RenderCaps & FXRC_GET_BITS)) { 274 if (!(m_RenderCaps & FXRC_GET_BITS)) {
275 return FALSE; 275 return false;
276 } 276 }
277 CFX_DIBitmap bitmap; 277 CFX_DIBitmap bitmap;
278 if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) { 278 if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) {
279 return FALSE; 279 return false;
280 } 280 }
281 if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) { 281 if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) {
282 return FALSE; 282 return false;
283 } 283 }
284 if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, alpha_flag, pIccTransform)) { 284 if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, alpha_flag, pIccTransform)) {
285 return FALSE; 285 return false;
286 } 286 }
287 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); 287 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height());
288 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, F XDIB_BLEND_NORMAL); 288 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, F XDIB_BLEND_NORMAL);
289 return TRUE; 289 return true;
290 } 290 }
291 FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2 , FX_FLOAT y2, FX_DWORD color, 291 bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, F X_FLOAT y2, FX_DWORD color,
292 int fill_mode, int alpha_flag, void* pIccTransform, int blend_type) 292 int fill_mode, int alpha_flag, void* pIccTransform, int blend_type)
293 { 293 {
294 if (((m_RenderCaps & FXRC_ALPHA_PATH) && 294 if (((m_RenderCaps & FXRC_ALPHA_PATH) &&
295 (FXGETFLAG_COLORTYPE(alpha_flag) && FXGETFLAG_ALPHA_FILL(alpha_flag) == 0xff)) || 295 (FXGETFLAG_COLORTYPE(alpha_flag) && FXGETFLAG_ALPHA_FILL(alpha_flag) == 0xff)) ||
296 color >= 0xff000000) 296 color >= 0xff000000)
297 if (m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, alpha_flag, pIccTransform, blend_type)) { 297 if (m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, alpha_flag, pIccTransform, blend_type)) {
298 return TRUE; 298 return true;
299 } 299 }
300 CFX_GraphStateData graph_state; 300 CFX_GraphStateData graph_state;
301 CFX_PathData path; 301 CFX_PathData path;
302 path.SetPointCount(2); 302 path.SetPointCount(2);
303 path.SetPoint(0, x1, y1, FXPT_MOVETO); 303 path.SetPoint(0, x1, y1, FXPT_MOVETO);
304 path.SetPoint(1, x2, y2, FXPT_LINETO); 304 path.SetPoint(1, x2, y2, FXPT_LINETO);
305 return m_pDeviceDriver->DrawPath(&path, NULL, &graph_state, 0, color, fill_m ode, alpha_flag, pIccTransform, blend_type); 305 return m_pDeviceDriver->DrawPath(&path, NULL, &graph_state, 0, color, fill_m ode, alpha_flag, pIccTransform, blend_type);
306 } 306 }
307 FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, vo id* pIccTransform) 307 bool CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform)
308 { 308 {
309 if (!(m_RenderCaps & FXRC_GET_BITS)) { 309 if (!(m_RenderCaps & FXRC_GET_BITS)) {
310 return FALSE; 310 return false;
311 } 311 }
312 return m_pDeviceDriver->GetDIBits(pBitmap, left, top, pIccTransform); 312 return m_pDeviceDriver->GetDIBits(pBitmap, left, top, pIccTransform);
313 } 313 }
314 CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() 314 CFX_DIBitmap* CFX_RenderDevice::GetBackDrop()
315 { 315 {
316 return m_pDeviceDriver->GetBackDrop(); 316 return m_pDeviceDriver->GetBackDrop();
317 } 317 }
318 FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, int left, int top, int blend_mode, 318 bool CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, int left, int top , int blend_mode,
319 void* pIccTransform) 319 void* pIccTransform)
320 { 320 {
321 ASSERT(!pBitmap->IsAlphaMask()); 321 ASSERT(!pBitmap->IsAlphaMask());
322 CFX_AffineMatrix ctm = GetCTM(); 322 CFX_AffineMatrix ctm = GetCTM();
323 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); 323 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a);
324 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); 324 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d);
325 FX_RECT dest_rect(left, top, FXSYS_round(left + pBitmap->GetWidth() / fScale X), FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); 325 FX_RECT dest_rect(left, top, FXSYS_round(left + pBitmap->GetWidth() / fScale X), FXSYS_round(top + pBitmap->GetHeight() / fScaleY));
326 dest_rect.Intersect(m_ClipBox); 326 dest_rect.Intersect(m_ClipBox);
327 if (dest_rect.IsEmpty()) { 327 if (dest_rect.IsEmpty()) {
328 return TRUE; 328 return true;
329 } 329 }
330 FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, 330 FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top,
331 dest_rect.left - left + dest_rect.Width(), dest_rect.top - top + dest_rect.Height()); 331 dest_rect.left - left + dest_rect.Width(), dest_rect.top - top + dest_rect.Height());
332 src_rect.left = FXSYS_round(src_rect.left * fScaleX); 332 src_rect.left = FXSYS_round(src_rect.left * fScaleX);
333 src_rect.top = FXSYS_round(src_rect.top * fScaleY); 333 src_rect.top = FXSYS_round(src_rect.top * fScaleY);
334 src_rect.right = FXSYS_round(src_rect.right * fScaleX); 334 src_rect.right = FXSYS_round(src_rect.right * fScaleX);
335 src_rect.bottom = FXSYS_round(src_rect.bottom * fScaleY); 335 src_rect.bottom = FXSYS_round(src_rect.bottom * fScaleY);
336 if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) || 336 if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) ||
337 (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) { 337 (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) {
338 if (!(m_RenderCaps & FXRC_GET_BITS)) { 338 if (!(m_RenderCaps & FXRC_GET_BITS)) {
339 return FALSE; 339 return false;
340 } 340 }
341 int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX); 341 int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX);
342 int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY); 342 int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY);
343 CFX_DIBitmap background; 343 CFX_DIBitmap background;
344 if (!background.Create(bg_pixel_width, bg_pixel_height, 344 if (!background.Create(bg_pixel_width, bg_pixel_height,
345 (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) { 345 (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) {
346 return FALSE; 346 return false;
347 } 347 }
348 if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left, dest_rect.t op)) { 348 if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left, dest_rect.t op)) {
349 return FALSE; 349 return false;
350 } 350 }
351 if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, 351 if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height,
352 pBitmap, src_rect.left, src_rect.top, 352 pBitmap, src_rect.left, src_rect.top,
353 blend_mode, NULL, FALSE, pIccTransform)) { 353 blend_mode, NULL, false, pIccTransform)) {
354 return FALSE; 354 return false;
355 } 355 }
356 FX_RECT src_rect(0, 0, bg_pixel_width, bg_pixel_height); 356 FX_RECT src_rect(0, 0, bg_pixel_width, bg_pixel_height);
357 return m_pDeviceDriver->SetDIBits(&background, 0, &src_rect, dest_rect.l eft, dest_rect.top, FXDIB_BLEND_NORMAL); 357 return m_pDeviceDriver->SetDIBits(&background, 0, &src_rect, dest_rect.l eft, dest_rect.top, FXDIB_BLEND_NORMAL);
358 } 358 }
359 return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, des t_rect.top, blend_mode, 0, pIccTransform); 359 return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, des t_rect.top, blend_mode, 0, pIccTransform);
360 } 360 }
361 FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, int left, int top, 361 bool CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, int left, int top,
362 int dest_width, int dest_height, FX_DWOR D flags, 362 int dest_width, int dest_height, FX_DWOR D flags,
363 void* pIccTransform, int blend_mode) 363 void* pIccTransform, int blend_mode)
364 { 364 {
365 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); 365 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
366 FX_RECT clip_box = m_ClipBox; 366 FX_RECT clip_box = m_ClipBox;
367 clip_box.Intersect(dest_rect); 367 clip_box.Intersect(dest_rect);
368 if (clip_box.IsEmpty()) { 368 if (clip_box.IsEmpty()) {
369 return TRUE; 369 return true;
370 } 370 }
371 return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, des t_height, &clip_box, flags, 0, pIccTransform, blend_mode); 371 return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, des t_height, &clip_box, flags, 0, pIccTransform, blend_mode);
372 } 372 }
373 FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, int left, int top, FX_DWORD argb, 373 bool CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, int left, int to p, FX_DWORD argb,
374 int alpha_flag, void* pIccTransform) 374 int alpha_flag, void* pIccTransform)
375 { 375 {
376 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); 376 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
377 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, FXDIB _BLEND_NORMAL, alpha_flag, pIccTransform); 377 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, FXDIB _BLEND_NORMAL, alpha_flag, pIccTransform);
378 } 378 }
379 FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, int left, int top, 379 bool CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, int left, in t top,
380 int dest_width, int dest_height, FX_DWORD argb, FX_DWORD flags, 380 int dest_width, int dest_height, FX_DWORD argb, FX_DWORD flags,
381 int alpha_flag, void* pIccTransform) 381 int alpha_flag, void* pIccTransform)
382 { 382 {
383 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); 383 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
384 FX_RECT clip_box = m_ClipBox; 384 FX_RECT clip_box = m_ClipBox;
385 clip_box.Intersect(dest_rect); 385 clip_box.Intersect(dest_rect);
386 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, dest_height, &clip_box, flags, alpha_flag, pIccTransform); 386 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, dest_height, &clip_box, flags, alpha_flag, pIccTransform);
387 } 387 }
388 FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_a lpha, FX_DWORD argb, 388 bool CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alph a, FX_DWORD argb,
389 const CFX_AffineMatrix* pMatrix, FX_DWORD flags, void*& handle, 389 const CFX_AffineMatrix* pMatrix, FX_DWORD flags, void*& handle,
390 int alpha_flag, void* pIccTransform, int b lend_mode) 390 int alpha_flag, void* pIccTransform, int b lend_mode)
391 { 391 {
392 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, fl ags, handle, alpha_flag, pIccTransform, blend_mode); 392 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, fl ags, handle, alpha_flag, pIccTransform, blend_mode);
393 } 393 }
394 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) 394 bool CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause)
395 { 395 {
396 return m_pDeviceDriver->ContinueDIBits(handle, pPause); 396 return m_pDeviceDriver->ContinueDIBits(handle, pPause);
397 } 397 }
398 void CFX_RenderDevice::CancelDIBits(void* handle) 398 void CFX_RenderDevice::CancelDIBits(void* handle)
399 { 399 {
400 m_pDeviceDriver->CancelDIBits(handle); 400 m_pDeviceDriver->CancelDIBits(handle);
401 } 401 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_transform.cpp ('k') | core/src/fxge/ge/fx_ge_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698