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 "../../../../include/fxge/fx_ge.h" | 7 #include "../../../../include/fxge/fx_ge.h" |
8 #include "../../dib/dib_int.h" | 8 #include "../../dib/dib_int.h" |
9 #include "../../ge/text_int.h" | 9 #include "../../ge/text_int.h" |
10 #include "../../../../include/fxcodec/fx_codec.h" | 10 #include "../../../../include/fxcodec/fx_codec.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 private: | 113 private: |
114 base_ren_type* m_ren; | 114 base_ren_type* m_ren; |
115 color_type m_color; | 115 color_type m_color; |
116 unsigned m_left, m_top; | 116 unsigned m_left, m_top; |
117 }; | 117 }; |
118 } | 118 } |
119 static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, agg::path_s
torage& path_data, | 119 static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, agg::path_s
torage& path_data, |
120 const CFX_AffineMatrix* pObject2Device, | 120 const CFX_AffineMatrix* pObject2Device, |
121 const CFX_GraphStateData* pGraphState, FX_FLOAT scal
e = 1.0f, | 121 const CFX_GraphStateData* pGraphState, FX_FLOAT scal
e = 1.0f, |
122 FX_BOOL bStrokeAdjust = FALSE, FX_BOOL bTextMode = F
ALSE) | 122 bool bStrokeAdjust = false, bool bTextMode = false) |
123 { | 123 { |
124 agg::line_cap_e cap; | 124 agg::line_cap_e cap; |
125 switch (pGraphState->m_LineCap) { | 125 switch (pGraphState->m_LineCap) { |
126 case CFX_GraphStateData::LineCapRound: | 126 case CFX_GraphStateData::LineCapRound: |
127 cap = agg::round_cap; | 127 cap = agg::round_cap; |
128 break; | 128 break; |
129 case CFX_GraphStateData::LineCapSquare: | 129 case CFX_GraphStateData::LineCapSquare: |
130 cap = agg::square_cap; | 130 cap = agg::square_cap; |
131 break; | 131 break; |
132 default: | 132 default: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 dash.dash_start(pGraphState->m_DashPhase * scale); | 178 dash.dash_start(pGraphState->m_DashPhase * scale); |
179 typedef agg::conv_stroke<dash_converter> dash_stroke; | 179 typedef agg::conv_stroke<dash_converter> dash_stroke; |
180 dash_stroke stroke(dash); | 180 dash_stroke stroke(dash); |
181 stroke.line_join(join); | 181 stroke.line_join(join); |
182 stroke.line_cap(cap); | 182 stroke.line_cap(cap); |
183 stroke.miter_limit(pGraphState->m_MiterLimit); | 183 stroke.miter_limit(pGraphState->m_MiterLimit); |
184 stroke.width(width); | 184 stroke.width(width); |
185 rasterizer.add_path_transformed(stroke, pObject2Device); | 185 rasterizer.add_path_transformed(stroke, pObject2Device); |
186 } | 186 } |
187 } | 187 } |
188 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(CFX_DIBitmap* p
Bitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 188 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(CFX_DIBitmap* p
Bitmap, bool bRgbByteOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) |
189 { | 189 { |
190 return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, bGroup
Knockout); | 190 return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, bGroup
Knockout); |
191 } | 191 } |
192 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits,
FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 192 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits,
bool bRgbByteOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) |
193 { | 193 { |
194 m_pBitmap = pBitmap; | 194 m_pBitmap = pBitmap; |
195 m_DitherBits = dither_bits; | 195 m_DitherBits = dither_bits; |
196 m_pClipRgn = NULL; | 196 m_pClipRgn = NULL; |
197 m_pPlatformBitmap = NULL; | 197 m_pPlatformBitmap = NULL; |
198 m_pPlatformGraphics = NULL; | 198 m_pPlatformGraphics = NULL; |
199 m_pDwRenderTartget = NULL; | 199 m_pDwRenderTartget = NULL; |
200 m_bRgbByteOrder = bRgbByteOrder; | 200 m_bRgbByteOrder = bRgbByteOrder; |
201 m_pOriDevice = pOriDevice; | 201 m_pOriDevice = pOriDevice; |
202 m_bGroupKnockout = bGroupKnockout; | 202 m_bGroupKnockout = bGroupKnockout; |
203 m_FillFlags = 0; | 203 m_FillFlags = 0; |
204 InitPlatform(); | 204 InitPlatform(); |
205 } | 205 } |
206 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() | 206 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() |
207 { | 207 { |
208 delete m_pClipRgn; | 208 delete m_pClipRgn; |
209 for (int i = 0; i < m_StateStack.GetSize(); i ++) | 209 for (int i = 0; i < m_StateStack.GetSize(); i ++) |
210 delete (CFX_ClipRgn*)m_StateStack[i]; | 210 delete (CFX_ClipRgn*)m_StateStack[i]; |
211 DestroyPlatform(); | 211 DestroyPlatform(); |
212 } | 212 } |
213 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 213 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
214 void CFX_AggDeviceDriver::InitPlatform() | 214 void CFX_AggDeviceDriver::InitPlatform() |
215 { | 215 { |
216 } | 216 } |
217 void CFX_AggDeviceDriver::DestroyPlatform() | 217 void CFX_AggDeviceDriver::DestroyPlatform() |
218 { | 218 { |
219 } | 219 } |
220 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pC
harPos, CFX_Font* pFont, | 220 bool CFX_AggDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pChar
Pos, CFX_Font* pFont, |
221 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT
font_size, FX_DWORD color, | 221 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT
font_size, FX_DWORD color, |
222 int alpha_flag, void* pIccTransform) | 222 int alpha_flag, void* pIccTransform) |
223 { | 223 { |
224 return FALSE; | 224 return false; |
225 } | 225 } |
226 #endif | 226 #endif |
227 int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) | 227 int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) |
228 { | 228 { |
229 switch (caps_id) { | 229 switch (caps_id) { |
230 case FXDC_DEVICE_CLASS: | 230 case FXDC_DEVICE_CLASS: |
231 return FXDC_DISPLAY; | 231 return FXDC_DISPLAY; |
232 case FXDC_PIXEL_WIDTH: | 232 case FXDC_PIXEL_WIDTH: |
233 return m_pBitmap->GetWidth(); | 233 return m_pBitmap->GetWidth(); |
234 case FXDC_PIXEL_HEIGHT: | 234 case FXDC_PIXEL_HEIGHT: |
(...skipping 25 matching lines...) Expand all Loading... |
260 return 0; | 260 return 0; |
261 } | 261 } |
262 void CFX_AggDeviceDriver::SaveState() | 262 void CFX_AggDeviceDriver::SaveState() |
263 { | 263 { |
264 void* pClip = NULL; | 264 void* pClip = NULL; |
265 if (m_pClipRgn) { | 265 if (m_pClipRgn) { |
266 pClip = new CFX_ClipRgn(*m_pClipRgn); | 266 pClip = new CFX_ClipRgn(*m_pClipRgn); |
267 } | 267 } |
268 m_StateStack.Add(pClip); | 268 m_StateStack.Add(pClip); |
269 } | 269 } |
270 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) | 270 void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) |
271 { | 271 { |
272 if (m_StateStack.GetSize() == 0) { | 272 if (m_StateStack.GetSize() == 0) { |
273 delete m_pClipRgn; | 273 delete m_pClipRgn; |
274 m_pClipRgn = NULL; | 274 m_pClipRgn = NULL; |
275 return; | 275 return; |
276 } | 276 } |
277 CFX_ClipRgn* pSavedClip = (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize()
- 1]; | 277 CFX_ClipRgn* pSavedClip = (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize()
- 1]; |
278 delete m_pClipRgn; | 278 delete m_pClipRgn; |
279 m_pClipRgn = NULL; | 279 m_pClipRgn = NULL; |
280 if (bKeepSaved) { | 280 if (bKeepSaved) { |
(...skipping 19 matching lines...) Expand all Loading... |
300 pThisLayer->Clear(0); | 300 pThisLayer->Clear(0); |
301 agg::rendering_buffer raw_buf(pThisLayer->GetBuffer(), pThisLayer->GetWidth(
), pThisLayer->GetHeight(), pThisLayer->GetPitch()); | 301 agg::rendering_buffer raw_buf(pThisLayer->GetBuffer(), pThisLayer->GetWidth(
), pThisLayer->GetHeight(), pThisLayer->GetPitch()); |
302 agg::pixfmt_gray8 pixel_buf(raw_buf); | 302 agg::pixfmt_gray8 pixel_buf(raw_buf); |
303 agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf); | 303 agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf); |
304 agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> > fin
al_render(base_buf, path_rect.left, path_rect.top); | 304 agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> > fin
al_render(base_buf, path_rect.left, path_rect.top); |
305 final_render.color(agg::gray8(255)); | 305 final_render.color(agg::gray8(255)); |
306 agg::scanline_u8 scanline; | 306 agg::scanline_u8 scanline; |
307 agg::render_scanlines(rasterizer, scanline, final_render, (m_FillFlags & FXF
ILL_NOPATHSMOOTH) != 0); | 307 agg::render_scanlines(rasterizer, scanline, final_render, (m_FillFlags & FXF
ILL_NOPATHSMOOTH) != 0); |
308 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); | 308 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); |
309 } | 309 } |
310 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 310 bool CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
311 const CFX_AffineMatrix* pObject2Device, | 311 const CFX_AffineMatrix* pObject2Device, |
312 int fill_mode | 312 int fill_mode |
313 ) | 313 ) |
314 { | 314 { |
315 m_FillFlags = fill_mode; | 315 m_FillFlags = fill_mode; |
316 if (m_pClipRgn == NULL) { | 316 if (m_pClipRgn == NULL) { |
317 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceC
aps(FXDC_PIXEL_HEIGHT)); | 317 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceC
aps(FXDC_PIXEL_HEIGHT)); |
318 } | 318 } |
319 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { | 319 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
320 CFX_FloatRect rectf; | 320 CFX_FloatRect rectf; |
321 if (pPathData->IsRect(pObject2Device, &rectf)) { | 321 if (pPathData->IsRect(pObject2Device, &rectf)) { |
322 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIX
EL_WIDTH), (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 322 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIX
EL_WIDTH), (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
323 FX_RECT rect = rectf.GetOutterRect(); | 323 FX_RECT rect = rectf.GetOutterRect(); |
324 m_pClipRgn->IntersectRect(rect); | 324 m_pClipRgn->IntersectRect(rect); |
325 return TRUE; | 325 return true; |
326 } | 326 } |
327 } | 327 } |
328 CAgg_PathData path_data; | 328 CAgg_PathData path_data; |
329 path_data.BuildPath(pPathData, pObject2Device); | 329 path_data.BuildPath(pPathData, pObject2Device); |
330 path_data.m_PathData.end_poly(); | 330 path_data.m_PathData.end_poly(); |
331 agg::rasterizer_scanline_aa rasterizer; | 331 agg::rasterizer_scanline_aa rasterizer; |
332 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 332 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
333 rasterizer.add_path(path_data.m_PathData); | 333 rasterizer.add_path(path_data.m_PathData); |
334 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_non_ze
ro : agg::fill_even_odd); | 334 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_non_ze
ro : agg::fill_even_odd); |
335 SetClipMask(rasterizer); | 335 SetClipMask(rasterizer); |
336 return TRUE; | 336 return true; |
337 } | 337 } |
338 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, | 338 bool CFX_AggDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, |
339 const CFX_AffineMatrix* pObject2Device, | 339 const CFX_AffineMatrix* pObject2Device, |
340 const CFX_GraphStateData* pGraphState | 340 const CFX_GraphStateData* pGraphState |
341 ) | 341 ) |
342 { | 342 { |
343 if (m_pClipRgn == NULL) { | 343 if (m_pClipRgn == NULL) { |
344 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceC
aps(FXDC_PIXEL_HEIGHT)); | 344 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceC
aps(FXDC_PIXEL_HEIGHT)); |
345 } | 345 } |
346 CAgg_PathData path_data; | 346 CAgg_PathData path_data; |
347 path_data.BuildPath(pPathData, NULL); | 347 path_data.BuildPath(pPathData, NULL); |
348 agg::rasterizer_scanline_aa rasterizer; | 348 agg::rasterizer_scanline_aa rasterizer; |
349 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 349 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
350 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, pGraphStat
e); | 350 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, pGraphStat
e); |
351 rasterizer.filling_rule(agg::fill_non_zero); | 351 rasterizer.filling_rule(agg::fill_non_zero); |
352 SetClipMask(rasterizer); | 352 SetClipMask(rasterizer); |
353 return TRUE; | 353 return true; |
354 } | 354 } |
355 class CFX_Renderer | 355 class CFX_Renderer |
356 { | 356 { |
357 private: | 357 private: |
358 int m_Alpha, | 358 int m_Alpha, |
359 m_Red, | 359 m_Red, |
360 m_Green, | 360 m_Green, |
361 m_Blue, | 361 m_Blue, |
362 m_Gray; | 362 m_Gray; |
363 FX_DWORD m_Color; | 363 FX_DWORD m_Color; |
364 FX_BOOL» » m_bFullCover; | 364 bool» » m_bFullCover; |
365 FX_BOOL m_bRgbByteOrder; | 365 bool m_bRgbByteOrder; |
366 CFX_DIBitmap* m_pOriDevice; | 366 CFX_DIBitmap* m_pOriDevice; |
367 FX_RECT m_ClipBox; | 367 FX_RECT m_ClipBox; |
368 const CFX_DIBitmap* m_pClipMask; | 368 const CFX_DIBitmap* m_pClipMask; |
369 CFX_DIBitmap* m_pDevice; | 369 CFX_DIBitmap* m_pDevice; |
370 const CFX_ClipRgn* m_pClipRgn; | 370 const CFX_ClipRgn* m_pClipRgn; |
371 void (CFX_Renderer::*composite_span)(uint8_t*, int, int, int, uint8_t*, int,
int, uint8_t*, uint8_t*); | 371 void (CFX_Renderer::*composite_span)(uint8_t*, int, int, int, uint8_t*, int,
int, uint8_t*, uint8_t*); |
372 public: | 372 public: |
373 void prepare(unsigned) {} | 373 void prepare(unsigned) {} |
374 void CompositeSpan(uint8_t* dest_scan, uint8_t* ori_scan, int Bpp, FX_BOOL b
DestAlpha, | 374 void CompositeSpan(uint8_t* dest_scan, uint8_t* ori_scan, int Bpp, bool bDes
tAlpha, |
375 int span_left, int span_len, uint8_t* cover_scan, | 375 int span_left, int span_len, uint8_t* cover_scan, |
376 int clip_left, int clip_right, uint8_t* clip_scan) | 376 int clip_left, int clip_right, uint8_t* clip_scan) |
377 { | 377 { |
378 ASSERT(!m_pDevice->IsCmykImage()); | 378 ASSERT(!m_pDevice->IsCmykImage()); |
379 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 379 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
380 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 380 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); |
381 if (Bpp) { | 381 if (Bpp) { |
382 dest_scan += col_start * Bpp; | 382 dest_scan += col_start * Bpp; |
383 ori_scan += col_start * Bpp; | 383 ori_scan += col_start * Bpp; |
384 } else { | 384 } else { |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 uint8_t* dest_scan_extra_alpha = NULL; | 945 uint8_t* dest_scan_extra_alpha = NULL; |
946 CFX_DIBitmap* pAlphaMask = m_pDevice->m_pAlphaMask; | 946 CFX_DIBitmap* pAlphaMask = m_pDevice->m_pAlphaMask; |
947 if (pAlphaMask) { | 947 if (pAlphaMask) { |
948 dest_scan_extra_alpha = pAlphaMask->GetBuffer() + pAlphaMask->GetPit
ch() * y; | 948 dest_scan_extra_alpha = pAlphaMask->GetBuffer() + pAlphaMask->GetPit
ch() * y; |
949 } | 949 } |
950 uint8_t* ori_scan = NULL; | 950 uint8_t* ori_scan = NULL; |
951 if (m_pOriDevice) { | 951 if (m_pOriDevice) { |
952 ori_scan = m_pOriDevice->GetBuffer() + m_pOriDevice->GetPitch() * y; | 952 ori_scan = m_pOriDevice->GetBuffer() + m_pOriDevice->GetPitch() * y; |
953 } | 953 } |
954 int Bpp = m_pDevice->GetBPP() / 8; | 954 int Bpp = m_pDevice->GetBPP() / 8; |
955 FX_BOOL bDestAlpha = m_pDevice->HasAlpha() || m_pDevice->IsAlphaMask(); | 955 bool bDestAlpha = m_pDevice->HasAlpha() || m_pDevice->IsAlphaMask(); |
956 unsigned num_spans = sl.num_spans(); | 956 unsigned num_spans = sl.num_spans(); |
957 typename Scanline::const_iterator span = sl.begin(); | 957 typename Scanline::const_iterator span = sl.begin(); |
958 while (1) { | 958 while (1) { |
959 int x = span->x; | 959 int x = span->x; |
960 ASSERT(span->len > 0); | 960 ASSERT(span->len > 0); |
961 uint8_t* dest_pos = NULL; | 961 uint8_t* dest_pos = NULL; |
962 uint8_t* dest_extra_alpha_pos = NULL; | 962 uint8_t* dest_extra_alpha_pos = NULL; |
963 uint8_t* ori_pos = NULL; | 963 uint8_t* ori_pos = NULL; |
964 if (Bpp) { | 964 if (Bpp) { |
965 ori_pos = ori_scan ? ori_scan + x * Bpp : NULL; | 965 ori_pos = ori_scan ? ori_scan + x * Bpp : NULL; |
(...skipping 12 matching lines...) Expand all Loading... |
978 } else { | 978 } else { |
979 (this->*composite_span)(dest_pos, Bpp, x, span->len, span->cover
s, m_ClipBox.left, m_ClipBox.right, clip_pos, dest_extra_alpha_pos); | 979 (this->*composite_span)(dest_pos, Bpp, x, span->len, span->cover
s, m_ClipBox.left, m_ClipBox.right, clip_pos, dest_extra_alpha_pos); |
980 } | 980 } |
981 if(--num_spans == 0) { | 981 if(--num_spans == 0) { |
982 break; | 982 break; |
983 } | 983 } |
984 ++span; | 984 ++span; |
985 } | 985 } |
986 } | 986 } |
987 | 987 |
988 FX_BOOL Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_Clip
Rgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder, | 988 bool Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn
* pClipRgn, FX_DWORD color, bool bFullCover, bool bRgbByteOrder, |
989 int alpha_flag = 0, void* pIccTransform = NULL) | 989 int alpha_flag = 0, void* pIccTransform = NULL) |
990 { | 990 { |
991 m_pDevice = pDevice; | 991 m_pDevice = pDevice; |
992 m_pClipRgn = pClipRgn; | 992 m_pClipRgn = pClipRgn; |
993 composite_span = NULL; | 993 composite_span = NULL; |
994 m_bRgbByteOrder = bRgbByteOrder; | 994 m_bRgbByteOrder = bRgbByteOrder; |
995 m_pOriDevice = pOriDevice; | 995 m_pOriDevice = pOriDevice; |
996 if (m_pClipRgn) { | 996 if (m_pClipRgn) { |
997 m_ClipBox = m_pClipRgn->GetBox(); | 997 m_ClipBox = m_pClipRgn->GetBox(); |
998 } else { | 998 } else { |
999 m_ClipBox.left = m_ClipBox.top = 0; | 999 m_ClipBox.left = m_ClipBox.top = 0; |
1000 m_ClipBox.right = m_pDevice->GetWidth(); | 1000 m_ClipBox.right = m_pDevice->GetWidth(); |
1001 m_ClipBox.bottom = m_pDevice->GetHeight(); | 1001 m_ClipBox.bottom = m_pDevice->GetHeight(); |
1002 } | 1002 } |
1003 m_pClipMask = NULL; | 1003 m_pClipMask = NULL; |
1004 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { | 1004 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { |
1005 m_pClipMask = m_pClipRgn->GetMask(); | 1005 m_pClipMask = m_pClipRgn->GetMask(); |
1006 } | 1006 } |
1007 m_bFullCover = bFullCover; | 1007 m_bFullCover = bFullCover; |
1008 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); | 1008 bool bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); |
1009 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); | 1009 bool bDeviceCMYK = pDevice->IsCmykImage(); |
1010 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(colo
r); | 1010 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(colo
r); |
1011 ICodec_IccModule* pIccModule = NULL; | 1011 ICodec_IccModule* pIccModule = NULL; |
1012 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetC
odecModule()->GetIccModule()) { | 1012 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetC
odecModule()->GetIccModule()) { |
1013 pIccTransform = NULL; | 1013 pIccTransform = NULL; |
1014 } else { | 1014 } else { |
1015 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 1015 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
1016 } | 1016 } |
1017 if (m_pDevice->GetBPP() == 8) { | 1017 if (m_pDevice->GetBPP() == 8) { |
1018 ASSERT(!m_bRgbByteOrder); | 1018 ASSERT(!m_bRgbByteOrder); |
1019 composite_span = &CFX_Renderer::CompositeSpanGray; | 1019 composite_span = &CFX_Renderer::CompositeSpanGray; |
1020 if (m_pDevice->IsAlphaMask()) { | 1020 if (m_pDevice->IsAlphaMask()) { |
1021 m_Gray = 255; | 1021 m_Gray = 255; |
1022 } else { | 1022 } else { |
1023 if (pIccTransform) { | 1023 if (pIccTransform) { |
1024 uint8_t gray; | 1024 uint8_t gray; |
1025 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(col
or); | 1025 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(col
or); |
1026 pIccModule->TranslateScanline(pIccTransform, &gray, (const u
int8_t*)&color, 1); | 1026 pIccModule->TranslateScanline(pIccTransform, &gray, (const u
int8_t*)&color, 1); |
1027 m_Gray = gray; | 1027 m_Gray = gray; |
1028 } else { | 1028 } else { |
1029 if (bObjectCMYK) { | 1029 if (bObjectCMYK) { |
1030 uint8_t r, g, b; | 1030 uint8_t r, g, b; |
1031 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMVal
ue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), | 1031 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMVal
ue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), |
1032 r, g, b); | 1032 r, g, b); |
1033 m_Gray = FXRGB2GRAY(r, g, b); | 1033 m_Gray = FXRGB2GRAY(r, g, b); |
1034 } else { | 1034 } else { |
1035 m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FX
ARGB_B(color)); | 1035 m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FX
ARGB_B(color)); |
1036 } | 1036 } |
1037 } | 1037 } |
1038 } | 1038 } |
1039 return TRUE; | 1039 return true; |
1040 } | 1040 } |
1041 if (bDeviceCMYK) { | 1041 if (bDeviceCMYK) { |
1042 ASSERT(!m_bRgbByteOrder); | 1042 ASSERT(!m_bRgbByteOrder); |
1043 composite_span = &CFX_Renderer::CompositeSpanCMYK; | 1043 composite_span = &CFX_Renderer::CompositeSpanCMYK; |
1044 if (bObjectCMYK) { | 1044 if (bObjectCMYK) { |
1045 m_Color = FXCMYK_TODIB(color); | 1045 m_Color = FXCMYK_TODIB(color); |
1046 if (pIccTransform) { | 1046 if (pIccTransform) { |
1047 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Co
lor, (const uint8_t*)&m_Color, 1); | 1047 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Co
lor, (const uint8_t*)&m_Color, 1); |
1048 } | 1048 } |
1049 } else { | 1049 } else { |
1050 if (!pIccTransform) { | 1050 if (!pIccTransform) { |
1051 return FALSE; | 1051 return false; |
1052 } | 1052 } |
1053 color = FXARGB_TODIB(color); | 1053 color = FXARGB_TODIB(color); |
1054 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color,
(const uint8_t*)&color, 1); | 1054 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color,
(const uint8_t*)&color, 1); |
1055 } | 1055 } |
1056 m_Red = ((uint8_t*)&m_Color)[0]; | 1056 m_Red = ((uint8_t*)&m_Color)[0]; |
1057 m_Green = ((uint8_t*)&m_Color)[1]; | 1057 m_Green = ((uint8_t*)&m_Color)[1]; |
1058 m_Blue = ((uint8_t*)&m_Color)[2]; | 1058 m_Blue = ((uint8_t*)&m_Color)[2]; |
1059 m_Gray = ((uint8_t*)&m_Color)[3]; | 1059 m_Gray = ((uint8_t*)&m_Color)[3]; |
1060 } else { | 1060 } else { |
1061 composite_span = (pDevice->GetFormat() == FXDIB_Argb) ? &CFX_Rendere
r::CompositeSpanARGB : &CFX_Renderer::CompositeSpanRGB; | 1061 composite_span = (pDevice->GetFormat() == FXDIB_Argb) ? &CFX_Rendere
r::CompositeSpanARGB : &CFX_Renderer::CompositeSpanRGB; |
(...skipping 28 matching lines...) Expand all Loading... |
1090 } else { | 1090 } else { |
1091 m_Color = FXARGB_TODIB(color); | 1091 m_Color = FXARGB_TODIB(color); |
1092 } | 1092 } |
1093 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); | 1093 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); |
1094 } | 1094 } |
1095 } | 1095 } |
1096 } | 1096 } |
1097 if (m_pDevice->GetBPP() == 1) { | 1097 if (m_pDevice->GetBPP() == 1) { |
1098 composite_span = &CFX_Renderer::CompositeSpan1bpp; | 1098 composite_span = &CFX_Renderer::CompositeSpan1bpp; |
1099 } | 1099 } |
1100 return TRUE; | 1100 return true; |
1101 } | 1101 } |
1102 }; | 1102 }; |
1103 FX_BOOL CFX_AggDeviceDriver::RenderRasterizer(agg::rasterizer_scanline_aa& raste
rizer, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout, | 1103 bool CFX_AggDeviceDriver::RenderRasterizer(agg::rasterizer_scanline_aa& rasteriz
er, FX_DWORD color, bool bFullCover, bool bGroupKnockout, |
1104 int alpha_flag, void* pIccTransform) | 1104 int alpha_flag, void* pIccTransform) |
1105 { | 1105 { |
1106 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : NULL; | 1106 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : NULL; |
1107 CFX_Renderer render; | 1107 CFX_Renderer render; |
1108 if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover, m_bRgbByteOrd
er, alpha_flag, pIccTransform)) { | 1108 if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover, m_bRgbByteOrd
er, alpha_flag, pIccTransform)) { |
1109 return FALSE; | 1109 return false; |
1110 } | 1110 } |
1111 agg::scanline_u8 scanline; | 1111 agg::scanline_u8 scanline; |
1112 agg::render_scanlines(rasterizer, scanline, render, (m_FillFlags & FXFILL_NO
PATHSMOOTH) != 0); | 1112 agg::render_scanlines(rasterizer, scanline, render, (m_FillFlags & FXFILL_NO
PATHSMOOTH) != 0); |
1113 return TRUE; | 1113 return true; |
1114 } | 1114 } |
1115 FX_BOOL»CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, | 1115 bool» CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, |
1116 const CFX_AffineMatrix* pObject2Device, | 1116 const CFX_AffineMatrix* pObject2Device, |
1117 const CFX_GraphStateData* pGraphState, | 1117 const CFX_GraphStateData* pGraphState, |
1118 FX_DWORD fill_color, | 1118 FX_DWORD fill_color, |
1119 FX_DWORD stroke_color, | 1119 FX_DWORD stroke_color, |
1120 int fill_mode, | 1120 int fill_mode, |
1121 int alpha_flag, | 1121 int alpha_flag, |
1122 void* pIccTransform, | 1122 void* pIccTransform, |
1123 int blend_type | 1123 int blend_type |
1124 ) | 1124 ) |
1125 { | 1125 { |
1126 if (blend_type != FXDIB_BLEND_NORMAL) { | 1126 if (blend_type != FXDIB_BLEND_NORMAL) { |
1127 return FALSE; | 1127 return false; |
1128 } | 1128 } |
1129 if (GetBuffer() == NULL) { | 1129 if (GetBuffer() == NULL) { |
1130 return TRUE; | 1130 return true; |
1131 } | 1131 } |
1132 m_FillFlags = fill_mode; | 1132 m_FillFlags = fill_mode; |
1133 if ((fill_mode & 3) && fill_color) { | 1133 if ((fill_mode & 3) && fill_color) { |
1134 CAgg_PathData path_data; | 1134 CAgg_PathData path_data; |
1135 path_data.BuildPath(pPathData, pObject2Device); | 1135 path_data.BuildPath(pPathData, pObject2Device); |
1136 agg::rasterizer_scanline_aa rasterizer; | 1136 agg::rasterizer_scanline_aa rasterizer; |
1137 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDT
H)), (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1137 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDT
H)), (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
1138 rasterizer.add_path(path_data.m_PathData); | 1138 rasterizer.add_path(path_data.m_PathData); |
1139 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_no
n_zero : agg::fill_even_odd); | 1139 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_no
n_zero : agg::fill_even_odd); |
1140 if (!RenderRasterizer(rasterizer, fill_color, fill_mode & FXFILL_FULLCOV
ER, FALSE, alpha_flag, pIccTransform)) { | 1140 if (!RenderRasterizer(rasterizer, fill_color, fill_mode & FXFILL_FULLCOV
ER, false, alpha_flag, pIccTransform)) { |
1141 return FALSE; | 1141 return false; |
1142 } | 1142 } |
1143 } | 1143 } |
1144 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STROKE(
alpha_flag) : FXARGB_A(stroke_color); | 1144 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STROKE(
alpha_flag) : FXARGB_A(stroke_color); |
1145 if (pGraphState && stroke_alpha) { | 1145 if (pGraphState && stroke_alpha) { |
1146 if (fill_mode & FX_ZEROAREA_FILL) { | 1146 if (fill_mode & FX_ZEROAREA_FILL) { |
1147 CAgg_PathData path_data; | 1147 CAgg_PathData path_data; |
1148 path_data.BuildPath(pPathData, pObject2Device); | 1148 path_data.BuildPath(pPathData, pObject2Device); |
1149 agg::rasterizer_scanline_aa rasterizer; | 1149 agg::rasterizer_scanline_aa rasterizer; |
1150 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_
WIDTH)), (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1150 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_
WIDTH)), (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
1151 RasterizeStroke(rasterizer, path_data.m_PathData, NULL, pGraphState,
1, FALSE, fill_mode & FX_STROKE_TEXT_MODE); | 1151 RasterizeStroke(rasterizer, path_data.m_PathData, NULL, pGraphState,
1, false, fill_mode & FX_STROKE_TEXT_MODE); |
1152 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | FXGETFLAG_ALP
HA_STROKE(alpha_flag); | 1152 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | FXGETFLAG_ALP
HA_STROKE(alpha_flag); |
1153 if (!RenderRasterizer(rasterizer, stroke_color, fill_mode & FXFILL_F
ULLCOVER, m_bGroupKnockout, fill_flag, pIccTransform)) { | 1153 if (!RenderRasterizer(rasterizer, stroke_color, fill_mode & FXFILL_F
ULLCOVER, m_bGroupKnockout, fill_flag, pIccTransform)) { |
1154 return FALSE; | 1154 return false; |
1155 } | 1155 } |
1156 return TRUE; | 1156 return true; |
1157 } | 1157 } |
1158 CFX_AffineMatrix matrix1, matrix2; | 1158 CFX_AffineMatrix matrix1, matrix2; |
1159 if (pObject2Device) { | 1159 if (pObject2Device) { |
1160 matrix1.a = FX_MAX(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject
2Device->b)); | 1160 matrix1.a = FX_MAX(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject
2Device->b)); |
1161 matrix1.d = matrix1.a; | 1161 matrix1.d = matrix1.a; |
1162 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matri
x1.a, | 1162 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matri
x1.a, |
1163 pObject2Device->c / matrix1.d, pObject2Device->d / matri
x1.d, | 1163 pObject2Device->c / matrix1.d, pObject2Device->d / matri
x1.d, |
1164 0, 0); | 1164 0, 0); |
1165 CFX_AffineMatrix mtRervese; | 1165 CFX_AffineMatrix mtRervese; |
1166 mtRervese.SetReverse(matrix2); | 1166 mtRervese.SetReverse(matrix2); |
1167 matrix1 = *pObject2Device; | 1167 matrix1 = *pObject2Device; |
1168 matrix1.Concat(mtRervese); | 1168 matrix1.Concat(mtRervese); |
1169 } | 1169 } |
1170 CAgg_PathData path_data; | 1170 CAgg_PathData path_data; |
1171 path_data.BuildPath(pPathData, &matrix1); | 1171 path_data.BuildPath(pPathData, &matrix1); |
1172 agg::rasterizer_scanline_aa rasterizer; | 1172 agg::rasterizer_scanline_aa rasterizer; |
1173 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDT
H)), (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1173 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDT
H)), (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
1174 RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState,
matrix1.a, FALSE, fill_mode & FX_STROKE_TEXT_MODE); | 1174 RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState,
matrix1.a, false, fill_mode & FX_STROKE_TEXT_MODE); |
1175 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | FXGETFLAG_ALPHA_S
TROKE(alpha_flag); | 1175 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | FXGETFLAG_ALPHA_S
TROKE(alpha_flag); |
1176 if (!RenderRasterizer(rasterizer, stroke_color, fill_mode & FXFILL_FULLC
OVER, m_bGroupKnockout, fill_flag, pIccTransform)) { | 1176 if (!RenderRasterizer(rasterizer, stroke_color, fill_mode & FXFILL_FULLC
OVER, m_bGroupKnockout, fill_flag, pIccTransform)) { |
1177 return FALSE; | 1177 return false; |
1178 } | 1178 } |
1179 } | 1179 } |
1180 return TRUE; | 1180 return true; |
1181 } | 1181 } |
1182 void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, FX_DWORD argb) | 1182 void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, FX_DWORD argb) |
1183 { | 1183 { |
1184 if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight())
{ | 1184 if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight())
{ |
1185 return; | 1185 return; |
1186 } | 1186 } |
1187 uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() + x
* pBitmap->GetBPP() / 8; | 1187 uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() + x
* pBitmap->GetBPP() / 8; |
1188 if (pBitmap->GetFormat() == FXDIB_Argb) { | 1188 if (pBitmap->GetFormat() == FXDIB_Argb) { |
1189 FXARGB_SETRGBORDERDIB(pos, ArgbGamma(argb)); | 1189 FXARGB_SETRGBORDERDIB(pos, ArgbGamma(argb)); |
1190 } else { | 1190 } else { |
1191 int alpha = FXARGB_A(argb); | 1191 int alpha = FXARGB_A(argb); |
1192 pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255; | 1192 pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255; |
1193 pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255; | 1193 pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255; |
1194 pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255; | 1194 pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255; |
1195 } | 1195 } |
1196 } | 1196 } |
1197 void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap, int left, int top, int wid
th, int height, FX_ARGB argb) | 1197 void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap, int left, int top, int wid
th, int height, FX_ARGB argb) |
1198 { | 1198 { |
1199 int src_alpha = FXARGB_A(argb); | 1199 int src_alpha = FXARGB_A(argb); |
1200 if (src_alpha == 0) { | 1200 if (src_alpha == 0) { |
1201 return; | 1201 return; |
1202 } | 1202 } |
1203 FX_RECT rect(left, top, left + width, top + height); | 1203 FX_RECT rect(left, top, left + width, top + height); |
1204 rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 1204 rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
1205 width = rect.Width(); | 1205 width = rect.Width(); |
1206 int src_r = FXARGB_R(argb), src_g = FXARGB_G(argb), src_b = FXARGB_B(argb); | 1206 int src_r = FXARGB_R(argb), src_g = FXARGB_G(argb), src_b = FXARGB_B(argb); |
1207 int Bpp = pBitmap->GetBPP() / 8; | 1207 int Bpp = pBitmap->GetBPP() / 8; |
1208 FX_BOOL bAlpha = pBitmap->HasAlpha(); | 1208 bool bAlpha = pBitmap->HasAlpha(); |
1209 int dib_argb = FXARGB_TOBGRORDERDIB(argb); | 1209 int dib_argb = FXARGB_TOBGRORDERDIB(argb); |
1210 uint8_t* pBuffer = pBitmap->GetBuffer(); | 1210 uint8_t* pBuffer = pBitmap->GetBuffer(); |
1211 if (src_alpha == 255) { | 1211 if (src_alpha == 255) { |
1212 for (int row = rect.top; row < rect.bottom; row ++) { | 1212 for (int row = rect.top; row < rect.bottom; row ++) { |
1213 uint8_t* dest_scan = pBuffer + row * pBitmap->GetPitch() + rect.left
* Bpp; | 1213 uint8_t* dest_scan = pBuffer + row * pBitmap->GetPitch() + rect.left
* Bpp; |
1214 if (Bpp == 4) { | 1214 if (Bpp == 4) { |
1215 FX_DWORD* scan = (FX_DWORD*)dest_scan; | 1215 FX_DWORD* scan = (FX_DWORD*)dest_scan; |
1216 for (int col = 0; col < width; col ++) { | 1216 for (int col = 0; col < width; col ++) { |
1217 *scan ++ = dib_argb; | 1217 *scan ++ = dib_argb; |
1218 } | 1218 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 uint8_t* dest_scan = dest_buf + row * pitch; | 1307 uint8_t* dest_scan = dest_buf + row * pitch; |
1308 uint8_t* src_scan = (uint8_t*)pSrcBitmap->GetScanline(src_top +
row) + src_left * 4; | 1308 uint8_t* src_scan = (uint8_t*)pSrcBitmap->GetScanline(src_top +
row) + src_left * 4; |
1309 for (int col = 0; col < width; col ++) { | 1309 for (int col = 0; col < width; col ++) { |
1310 *dest_scan++ = src_scan[2]; | 1310 *dest_scan++ = src_scan[2]; |
1311 *dest_scan++ = src_scan[1]; | 1311 *dest_scan++ = src_scan[1]; |
1312 *dest_scan++ = src_scan[0]; | 1312 *dest_scan++ = src_scan[0]; |
1313 src_scan += 4; | 1313 src_scan += 4; |
1314 } | 1314 } |
1315 } | 1315 } |
1316 } else { | 1316 } else { |
1317 ASSERT(FALSE); | 1317 ASSERT(false); |
1318 } | 1318 } |
1319 } else if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) { | 1319 } else if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) { |
1320 if (src_format == FXDIB_Rgb) { | 1320 if (src_format == FXDIB_Rgb) { |
1321 for (int row = 0; row < height; row ++) { | 1321 for (int row = 0; row < height; row ++) { |
1322 uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch); | 1322 uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch); |
1323 uint8_t* src_scan = (uint8_t*)pSrcBitmap->GetScanline(src_top +
row) + src_left * 3; | 1323 uint8_t* src_scan = (uint8_t*)pSrcBitmap->GetScanline(src_top +
row) + src_left * 3; |
1324 if (src_format == FXDIB_Argb) { | 1324 if (src_format == FXDIB_Argb) { |
1325 for (int col = 0; col < width; col ++) { | 1325 for (int col = 0; col < width; col ++) { |
1326 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, FX_GAMMA(src_
scan[0]), FX_GAMMA(src_scan[1]), FX_GAMMA(src_scan[2]))); | 1326 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, FX_GAMMA(src_
scan[0]), FX_GAMMA(src_scan[1]), FX_GAMMA(src_scan[2]))); |
1327 dest_scan += 4; | 1327 dest_scan += 4; |
(...skipping 13 matching lines...) Expand all Loading... |
1341 uint8_t* dest_scan = dest_buf + row * pitch; | 1341 uint8_t* dest_scan = dest_buf + row * pitch; |
1342 uint8_t* src_scan = (uint8_t*)(pSrcBitmap->GetScanline(src_top +
row) + src_left * 4); | 1342 uint8_t* src_scan = (uint8_t*)(pSrcBitmap->GetScanline(src_top +
row) + src_left * 4); |
1343 for (int col = 0; col < width; col++) { | 1343 for (int col = 0; col < width; col++) { |
1344 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_
scan[1], src_scan[2])); | 1344 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_
scan[1], src_scan[2])); |
1345 src_scan += 4; | 1345 src_scan += 4; |
1346 dest_scan += 4; | 1346 dest_scan += 4; |
1347 } | 1347 } |
1348 } | 1348 } |
1349 } | 1349 } |
1350 } else { | 1350 } else { |
1351 ASSERT(FALSE); | 1351 ASSERT(false); |
1352 } | 1352 } |
1353 } | 1353 } |
1354 FX_ARGB _DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) | 1354 FX_ARGB _DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) |
1355 { | 1355 { |
1356 uint8_t r, g, b; | 1356 uint8_t r, g, b; |
1357 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), FXSYS_GetYV
alue(cmyk), FXSYS_GetKValue(cmyk), | 1357 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), FXSYS_GetYV
alue(cmyk), FXSYS_GetKValue(cmyk), |
1358 r, g, b); | 1358 r, g, b); |
1359 return ArgbEncode(alpha, r, g, b); | 1359 return ArgbEncode(alpha, r, g, b); |
1360 } | 1360 } |
1361 FX_BOOL _DibSetPixel(CFX_DIBitmap* pDevice, int x, int y, FX_DWORD color, int al
pha_flag, void* pIccTransform) | 1361 bool _DibSetPixel(CFX_DIBitmap* pDevice, int x, int y, FX_DWORD color, int alpha
_flag, void* pIccTransform) |
1362 { | 1362 { |
1363 FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag); | 1363 bool bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag); |
1364 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); | 1364 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); |
1365 if (pIccTransform) { | 1365 if (pIccTransform) { |
1366 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 1366 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
1367 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); | 1367 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
1368 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, (uint8_t*
)&color, 1); | 1368 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, (uint8_t*
)&color, 1); |
1369 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); | 1369 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
1370 if (!pDevice->IsCmykImage()) { | 1370 if (!pDevice->IsCmykImage()) { |
1371 color = (color & 0xffffff) | (alpha << 24); | 1371 color = (color & 0xffffff) | (alpha << 24); |
1372 } | 1372 } |
1373 } else { | 1373 } else { |
1374 if (pDevice->IsCmykImage()) { | 1374 if (pDevice->IsCmykImage()) { |
1375 if (!bObjCMYK) { | 1375 if (!bObjCMYK) { |
1376 return FALSE; | 1376 return false; |
1377 } | 1377 } |
1378 } else { | 1378 } else { |
1379 if (bObjCMYK) { | 1379 if (bObjCMYK) { |
1380 color = _DefaultCMYK2ARGB(color, alpha); | 1380 color = _DefaultCMYK2ARGB(color, alpha); |
1381 } | 1381 } |
1382 } | 1382 } |
1383 } | 1383 } |
1384 pDevice->SetPixel(x, y, color); | 1384 pDevice->SetPixel(x, y, color); |
1385 if (pDevice->m_pAlphaMask) { | 1385 if (pDevice->m_pAlphaMask) { |
1386 pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24); | 1386 pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24); |
1387 } | 1387 } |
1388 return TRUE; | 1388 return true; |
1389 } | 1389 } |
1390 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, int y, FX_DWORD color, int alpha_fl
ag, void* pIccTransform) | 1390 bool CFX_AggDeviceDriver::SetPixel(int x, int y, FX_DWORD color, int alpha_flag,
void* pIccTransform) |
1391 { | 1391 { |
1392 if (m_pBitmap->GetBuffer() == NULL) { | 1392 if (m_pBitmap->GetBuffer() == NULL) { |
1393 return TRUE; | 1393 return true; |
1394 } | 1394 } |
1395 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec
Module()->GetIccModule()) { | 1395 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec
Module()->GetIccModule()) { |
1396 pIccTransform = NULL; | 1396 pIccTransform = NULL; |
1397 } | 1397 } |
1398 if (m_pClipRgn == NULL) { | 1398 if (m_pClipRgn == NULL) { |
1399 if (m_bRgbByteOrder) { | 1399 if (m_bRgbByteOrder) { |
1400 RgbByteOrderSetPixel(m_pBitmap, x, y, color); | 1400 RgbByteOrderSetPixel(m_pBitmap, x, y, color); |
1401 } else { | 1401 } else { |
1402 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransfor
m); | 1402 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransfor
m); |
1403 } | 1403 } |
1404 } else if (m_pClipRgn->GetBox().Contains(x, y)) { | 1404 } else if (m_pClipRgn->GetBox().Contains(x, y)) { |
1405 if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { | 1405 if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { |
1406 if (m_bRgbByteOrder) { | 1406 if (m_bRgbByteOrder) { |
1407 RgbByteOrderSetPixel(m_pBitmap, x, y, color); | 1407 RgbByteOrderSetPixel(m_pBitmap, x, y, color); |
1408 } else { | 1408 } else { |
1409 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTran
sform); | 1409 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTran
sform); |
1410 } | 1410 } |
1411 } else if (m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { | 1411 } else if (m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { |
1412 const CFX_DIBitmap* pMask = m_pClipRgn->GetMask(); | 1412 const CFX_DIBitmap* pMask = m_pClipRgn->GetMask(); |
1413 FX_BOOL bCMYK = FXGETFLAG_COLORTYPE(alpha_flag); | 1413 bool bCMYK = FXGETFLAG_COLORTYPE(alpha_flag); |
1414 int new_alpha = bCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(
color); | 1414 int new_alpha = bCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(
color); |
1415 new_alpha = new_alpha * pMask->GetScanline(y)[x] / 255; | 1415 new_alpha = new_alpha * pMask->GetScanline(y)[x] / 255; |
1416 if (m_bRgbByteOrder) { | 1416 if (m_bRgbByteOrder) { |
1417 RgbByteOrderSetPixel(m_pBitmap, x, y, (color & 0xffffff) | (new_
alpha << 24)); | 1417 RgbByteOrderSetPixel(m_pBitmap, x, y, (color & 0xffffff) | (new_
alpha << 24)); |
1418 return TRUE; | 1418 return true; |
1419 } | 1419 } |
1420 if (bCMYK) { | 1420 if (bCMYK) { |
1421 FXSETFLAG_ALPHA_FILL(alpha_flag, new_alpha); | 1421 FXSETFLAG_ALPHA_FILL(alpha_flag, new_alpha); |
1422 } else { | 1422 } else { |
1423 color = (color & 0xffffff) | (new_alpha << 24); | 1423 color = (color & 0xffffff) | (new_alpha << 24); |
1424 } | 1424 } |
1425 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransfor
m); | 1425 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransfor
m); |
1426 } | 1426 } |
1427 } | 1427 } |
1428 return TRUE; | 1428 return true; |
1429 } | 1429 } |
1430 FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color,
int alpha_flag, void* pIccTransform, int blend_type) | 1430 bool CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, in
t alpha_flag, void* pIccTransform, int blend_type) |
1431 { | 1431 { |
1432 if (blend_type != FXDIB_BLEND_NORMAL) { | 1432 if (blend_type != FXDIB_BLEND_NORMAL) { |
1433 return FALSE; | 1433 return false; |
1434 } | 1434 } |
1435 if (m_pBitmap->GetBuffer() == NULL) { | 1435 if (m_pBitmap->GetBuffer() == NULL) { |
1436 return TRUE; | 1436 return true; |
1437 } | 1437 } |
1438 FX_RECT clip_rect; | 1438 FX_RECT clip_rect; |
1439 GetClipBox(&clip_rect); | 1439 GetClipBox(&clip_rect); |
1440 FX_RECT draw_rect = clip_rect; | 1440 FX_RECT draw_rect = clip_rect; |
1441 if (pRect) { | 1441 if (pRect) { |
1442 draw_rect.Intersect(*pRect); | 1442 draw_rect.Intersect(*pRect); |
1443 } | 1443 } |
1444 if (draw_rect.IsEmpty()) { | 1444 if (draw_rect.IsEmpty()) { |
1445 return TRUE; | 1445 return true; |
1446 } | 1446 } |
1447 if (m_pClipRgn == NULL || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { | 1447 if (m_pClipRgn == NULL || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { |
1448 if (m_bRgbByteOrder) { | 1448 if (m_bRgbByteOrder) { |
1449 RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top,
draw_rect.Width(), draw_rect.Height(), fill_color); | 1449 RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top,
draw_rect.Width(), draw_rect.Height(), fill_color); |
1450 } else { | 1450 } else { |
1451 m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Wi
dth(), draw_rect.Height(), fill_color, alpha_flag, pIccTransform); | 1451 m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Wi
dth(), draw_rect.Height(), fill_color, alpha_flag, pIccTransform); |
1452 } | 1452 } |
1453 return TRUE; | 1453 return true; |
1454 } | 1454 } |
1455 m_pBitmap->CompositeMask(draw_rect.left, draw_rect.top, draw_rect.Width(), d
raw_rect.Height(), (const CFX_DIBitmap*)m_pClipRgn->GetMask(), | 1455 m_pBitmap->CompositeMask(draw_rect.left, draw_rect.top, draw_rect.Width(), d
raw_rect.Height(), (const CFX_DIBitmap*)m_pClipRgn->GetMask(), |
1456 fill_color, draw_rect.left - clip_rect.left, draw_r
ect.top - clip_rect.top, FXDIB_BLEND_NORMAL, NULL, m_bRgbByteOrder, alpha_flag,
pIccTransform); | 1456 fill_color, draw_rect.left - clip_rect.left, draw_r
ect.top - clip_rect.top, FXDIB_BLEND_NORMAL, NULL, m_bRgbByteOrder, alpha_flag,
pIccTransform); |
1457 return TRUE; | 1457 return true; |
1458 } | 1458 } |
1459 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) | 1459 bool CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) |
1460 { | 1460 { |
1461 if (m_pClipRgn == NULL) { | 1461 if (m_pClipRgn == NULL) { |
1462 pRect->left = pRect->top = 0; | 1462 pRect->left = pRect->top = 0; |
1463 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); | 1463 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); |
1464 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); | 1464 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); |
1465 return TRUE; | 1465 return true; |
1466 } | 1466 } |
1467 *pRect = m_pClipRgn->GetBox(); | 1467 *pRect = m_pClipRgn->GetBox(); |
1468 return TRUE; | 1468 return true; |
1469 } | 1469 } |
1470 FX_BOOL»CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top,
void* pIccTransform, FX_BOOL bDEdge) | 1470 bool» CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top,
void* pIccTransform, bool bDEdge) |
1471 { | 1471 { |
1472 if (m_pBitmap->GetBuffer() == NULL) { | 1472 if (m_pBitmap->GetBuffer() == NULL) { |
1473 return TRUE; | 1473 return true; |
1474 } | 1474 } |
1475 if (bDEdge) { | 1475 if (bDEdge) { |
1476 if (m_bRgbByteOrder) { | 1476 if (m_bRgbByteOrder) { |
1477 RgbByteOrderTransferBitmap(pBitmap, 0, 0, pBitmap->GetWidth(), pBitm
ap->GetHeight(), m_pBitmap, left, top); | 1477 RgbByteOrderTransferBitmap(pBitmap, 0, 0, pBitmap->GetWidth(), pBitm
ap->GetHeight(), m_pBitmap, left, top); |
1478 } else { | 1478 } else { |
1479 return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(), pBitmap->G
etHeight(), m_pBitmap, left, top, pIccTransform); | 1479 return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(), pBitmap->G
etHeight(), m_pBitmap, left, top, pIccTransform); |
1480 } | 1480 } |
1481 return TRUE; | 1481 return true; |
1482 } | 1482 } |
1483 FX_RECT rect(left, top, left + pBitmap->GetWidth(), top + pBitmap->GetHeight
()); | 1483 FX_RECT rect(left, top, left + pBitmap->GetWidth(), top + pBitmap->GetHeight
()); |
1484 CFX_DIBitmap *pBack = NULL; | 1484 CFX_DIBitmap *pBack = NULL; |
1485 if (m_pOriDevice) { | 1485 if (m_pOriDevice) { |
1486 pBack = m_pOriDevice->Clone(&rect); | 1486 pBack = m_pOriDevice->Clone(&rect); |
1487 if (!pBack) { | 1487 if (!pBack) { |
1488 return TRUE; | 1488 return true; |
1489 } | 1489 } |
1490 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), m_pB
itmap, 0, 0); | 1490 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), m_pB
itmap, 0, 0); |
1491 } else { | 1491 } else { |
1492 pBack = m_pBitmap->Clone(&rect); | 1492 pBack = m_pBitmap->Clone(&rect); |
1493 } | 1493 } |
1494 if (!pBack) { | 1494 if (!pBack) { |
1495 return TRUE; | 1495 return true; |
1496 } | 1496 } |
1497 FX_BOOL bRet = TRUE; | 1497 bool bRet = true; |
1498 left = left >= 0 ? 0 : left; | 1498 left = left >= 0 ? 0 : left; |
1499 top = top >= 0 ? 0 : top; | 1499 top = top >= 0 ? 0 : top; |
1500 if (m_bRgbByteOrder) { | 1500 if (m_bRgbByteOrder) { |
1501 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), p
Back, left, top); | 1501 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), p
Back, left, top); |
1502 } else { | 1502 } else { |
1503 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack,
left, top, pIccTransform); | 1503 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack,
left, top, pIccTransform); |
1504 } | 1504 } |
1505 delete pBack; | 1505 delete pBack; |
1506 return bRet; | 1506 return bRet; |
1507 } | 1507 } |
1508 FX_BOOL»CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD ar
gb, const FX_RECT* pSrcRect, int left, int top, int blend_type, | 1508 bool» CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD ar
gb, const FX_RECT* pSrcRect, int left, int top, int blend_type, |
1509 int alpha_flag, void* pIccTransform) | 1509 int alpha_flag, void* pIccTransform) |
1510 { | 1510 { |
1511 if (m_pBitmap->GetBuffer() == NULL) { | 1511 if (m_pBitmap->GetBuffer() == NULL) { |
1512 return TRUE; | 1512 return true; |
1513 } | 1513 } |
1514 if (pBitmap->IsAlphaMask()) | 1514 if (pBitmap->IsAlphaMask()) |
1515 return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(), pSrcRect->
Height(), pBitmap, argb, | 1515 return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(), pSrcRect->
Height(), pBitmap, argb, |
1516 pSrcRect->left, pSrcRect->top, blend_typ
e, m_pClipRgn, m_bRgbByteOrder, alpha_flag, pIccTransform); | 1516 pSrcRect->left, pSrcRect->top, blend_typ
e, m_pClipRgn, m_bRgbByteOrder, alpha_flag, pIccTransform); |
1517 return m_pBitmap->CompositeBitmap(left, top, pSrcRect->Width(), pSrcRect->He
ight(), pBitmap, | 1517 return m_pBitmap->CompositeBitmap(left, top, pSrcRect->Width(), pSrcRect->He
ight(), pBitmap, |
1518 pSrcRect->left, pSrcRect->top, blend_type,
m_pClipRgn, m_bRgbByteOrder, pIccTransform); | 1518 pSrcRect->left, pSrcRect->top, blend_type,
m_pClipRgn, m_bRgbByteOrder, pIccTransform); |
1519 } | 1519 } |
1520 FX_BOOL»CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWOR
D argb, int dest_left, int dest_top, | 1520 bool» CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWOR
D argb, int dest_left, int dest_top, |
1521 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag
s, | 1521 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag
s, |
1522 int alpha_flag, void* pIccTransform, int blend_type) | 1522 int alpha_flag, void* pIccTransform, int blend_type) |
1523 { | 1523 { |
1524 if (m_pBitmap->GetBuffer() == NULL) { | 1524 if (m_pBitmap->GetBuffer() == NULL) { |
1525 return TRUE; | 1525 return true; |
1526 } | 1526 } |
1527 if (dest_width == pSource->GetWidth() && dest_height == pSource->GetHeight()
) { | 1527 if (dest_width == pSource->GetWidth() && dest_height == pSource->GetHeight()
) { |
1528 FX_RECT rect(0, 0, dest_width, dest_height); | 1528 FX_RECT rect(0, 0, dest_width, dest_height); |
1529 return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type,
alpha_flag, pIccTransform); | 1529 return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type,
alpha_flag, pIccTransform); |
1530 } | 1530 } |
1531 FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width, dest_top + de
st_height); | 1531 FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width, dest_top + de
st_height); |
1532 dest_rect.Normalize(); | 1532 dest_rect.Normalize(); |
1533 FX_RECT dest_clip = dest_rect; | 1533 FX_RECT dest_clip = dest_rect; |
1534 dest_clip.Intersect(*pClipRect); | 1534 dest_clip.Intersect(*pClipRect); |
1535 CFX_BitmapComposer composer; | 1535 CFX_BitmapComposer composer; |
1536 composer.Compose(m_pBitmap, m_pClipRgn, 255, argb, dest_clip, FALSE, FALSE,
FALSE, m_bRgbByteOrder, alpha_flag, pIccTransform, blend_type); | 1536 composer.Compose(m_pBitmap, m_pClipRgn, 255, argb, dest_clip, false, false,
false, m_bRgbByteOrder, alpha_flag, pIccTransform, blend_type); |
1537 dest_clip.Offset(-dest_rect.left, -dest_rect.top); | 1537 dest_clip.Offset(-dest_rect.left, -dest_rect.top); |
1538 CFX_ImageStretcher stretcher; | 1538 CFX_ImageStretcher stretcher; |
1539 if (stretcher.Start(&composer, pSource, dest_width, dest_height, dest_clip,
flags)) { | 1539 if (stretcher.Start(&composer, pSource, dest_width, dest_height, dest_clip,
flags)) { |
1540 stretcher.Continue(NULL); | 1540 stretcher.Continue(NULL); |
1541 } | 1541 } |
1542 return TRUE; | 1542 return true; |
1543 } | 1543 } |
1544 FX_BOOL»CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitma
p_alpha, FX_DWORD argb, | 1544 bool» CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitma
p_alpha, FX_DWORD argb, |
1545 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, void*& handle, | 1545 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, void*& handle, |
1546 int alpha_flag, void* pIccTransform, int blend_type) | 1546 int alpha_flag, void* pIccTransform, int blend_type) |
1547 { | 1547 { |
1548 if (m_pBitmap->GetBuffer() == NULL) { | 1548 if (m_pBitmap->GetBuffer() == NULL) { |
1549 return TRUE; | 1549 return true; |
1550 } | 1550 } |
1551 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; | 1551 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; |
1552 pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix
, render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform); | 1552 pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix
, render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform); |
1553 handle = pRenderer; | 1553 handle = pRenderer; |
1554 return TRUE; | 1554 return true; |
1555 } | 1555 } |
1556 FX_BOOL»CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) | 1556 bool» CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) |
1557 { | 1557 { |
1558 if (m_pBitmap->GetBuffer() == NULL) { | 1558 if (m_pBitmap->GetBuffer() == NULL) { |
1559 return TRUE; | 1559 return true; |
1560 } | 1560 } |
1561 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); | 1561 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); |
1562 } | 1562 } |
1563 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) | 1563 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) |
1564 { | 1564 { |
1565 if (m_pBitmap->GetBuffer() == NULL) { | 1565 if (m_pBitmap->GetBuffer() == NULL) { |
1566 return; | 1566 return; |
1567 } | 1567 } |
1568 delete (CFX_ImageRenderer*)pHandle; | 1568 delete (CFX_ImageRenderer*)pHandle; |
1569 } | 1569 } |
1570 CFX_FxgeDevice::CFX_FxgeDevice() | 1570 CFX_FxgeDevice::CFX_FxgeDevice() |
1571 { | 1571 { |
1572 m_bOwnedBitmap = FALSE; | 1572 m_bOwnedBitmap = false; |
1573 } | 1573 } |
1574 FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL b
RgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 1574 bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, bool bRgbByt
eOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) |
1575 { | 1575 { |
1576 if (pBitmap == NULL) { | 1576 if (pBitmap == NULL) { |
1577 return FALSE; | 1577 return false; |
1578 } | 1578 } |
1579 SetBitmap(pBitmap); | 1579 SetBitmap(pBitmap); |
1580 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bi
ts, bRgbByteOrder, pOriDevice, bGroupKnockout); | 1580 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bi
ts, bRgbByteOrder, pOriDevice, bGroupKnockout); |
1581 SetDeviceDriver(pDriver); | 1581 SetDeviceDriver(pDriver); |
1582 return TRUE; | 1582 return true; |
1583 } | 1583 } |
1584 FX_BOOL CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, int d
ither_bits, CFX_DIBitmap* pOriDevice) | 1584 bool CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, int dith
er_bits, CFX_DIBitmap* pOriDevice) |
1585 { | 1585 { |
1586 m_bOwnedBitmap = TRUE; | 1586 m_bOwnedBitmap = true; |
1587 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 1587 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
1588 if (!pBitmap->Create(width, height, format)) { | 1588 if (!pBitmap->Create(width, height, format)) { |
1589 delete pBitmap; | 1589 delete pBitmap; |
1590 return FALSE; | 1590 return false; |
1591 } | 1591 } |
1592 SetBitmap(pBitmap); | 1592 SetBitmap(pBitmap); |
1593 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bi
ts, FALSE, pOriDevice, FALSE); | 1593 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bi
ts, false, pOriDevice, false); |
1594 SetDeviceDriver(pDriver); | 1594 SetDeviceDriver(pDriver); |
1595 return TRUE; | 1595 return true; |
1596 } | 1596 } |
1597 CFX_FxgeDevice::~CFX_FxgeDevice() | 1597 CFX_FxgeDevice::~CFX_FxgeDevice() |
1598 { | 1598 { |
1599 if (m_bOwnedBitmap) { | 1599 if (m_bOwnedBitmap) { |
1600 delete GetBitmap(); | 1600 delete GetBitmap(); |
1601 } | 1601 } |
1602 } | 1602 } |
OLD | NEW |