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

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

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