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

Side by Side Diff: core/fxge/agg/fx_agg_driver.cpp

Issue 2017503002: Remove FX_GAMMA() and friends. They do nothing. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Blend Created 4 years, 7 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 | « no previous file | core/fxge/dib/fx_dib_composite.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 "core/fxge/agg/fx_agg_driver.h" 7 #include "core/fxge/agg/fx_agg_driver.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 bGroupKnockout); 193 bGroupKnockout);
194 } 194 }
195 195
196 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, 196 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap,
197 int dither_bits, 197 int dither_bits,
198 FX_BOOL bRgbByteOrder, 198 FX_BOOL bRgbByteOrder,
199 CFX_DIBitmap* pOriDevice, 199 CFX_DIBitmap* pOriDevice,
200 FX_BOOL bGroupKnockout) { 200 FX_BOOL bGroupKnockout) {
201 m_pBitmap = pBitmap; 201 m_pBitmap = pBitmap;
202 m_DitherBits = dither_bits; 202 m_DitherBits = dither_bits;
203 m_pClipRgn = NULL; 203 m_pClipRgn = nullptr;
204 m_pPlatformBitmap = NULL; 204 m_pPlatformBitmap = nullptr;
205 m_pPlatformGraphics = NULL; 205 m_pPlatformGraphics = nullptr;
206 m_pDwRenderTartget = NULL; 206 m_pDwRenderTartget = nullptr;
207 m_bRgbByteOrder = bRgbByteOrder; 207 m_bRgbByteOrder = bRgbByteOrder;
208 m_pOriDevice = pOriDevice; 208 m_pOriDevice = pOriDevice;
209 m_bGroupKnockout = bGroupKnockout; 209 m_bGroupKnockout = bGroupKnockout;
210 m_FillFlags = 0; 210 m_FillFlags = 0;
211 InitPlatform(); 211 InitPlatform();
212 } 212 }
213 213
214 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { 214 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() {
215 delete m_pClipRgn; 215 delete m_pClipRgn;
216 for (int i = 0; i < m_StateStack.GetSize(); i++) 216 for (int i = 0; i < m_StateStack.GetSize(); i++)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 return flags; 271 return flags;
272 } 272 }
273 case FXDC_DITHER_BITS: 273 case FXDC_DITHER_BITS:
274 return m_DitherBits; 274 return m_DitherBits;
275 } 275 }
276 return 0; 276 return 0;
277 } 277 }
278 278
279 void CFX_AggDeviceDriver::SaveState() { 279 void CFX_AggDeviceDriver::SaveState() {
280 CFX_ClipRgn* pClip = NULL; 280 CFX_ClipRgn* pClip = nullptr;
281 if (m_pClipRgn) { 281 if (m_pClipRgn) {
282 pClip = new CFX_ClipRgn(*m_pClipRgn); 282 pClip = new CFX_ClipRgn(*m_pClipRgn);
283 } 283 }
284 m_StateStack.Add(pClip); 284 m_StateStack.Add(pClip);
285 } 285 }
286 286
287 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { 287 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) {
288 if (m_StateStack.GetSize() == 0) { 288 if (m_StateStack.GetSize() == 0) {
289 delete m_pClipRgn; 289 delete m_pClipRgn;
290 m_pClipRgn = NULL; 290 m_pClipRgn = nullptr;
291 return; 291 return;
292 } 292 }
293 CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1]; 293 CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1];
294 delete m_pClipRgn; 294 delete m_pClipRgn;
295 m_pClipRgn = NULL; 295 m_pClipRgn = nullptr;
296 if (bKeepSaved) { 296 if (bKeepSaved) {
297 if (pSavedClip) { 297 if (pSavedClip) {
298 m_pClipRgn = new CFX_ClipRgn(*pSavedClip); 298 m_pClipRgn = new CFX_ClipRgn(*pSavedClip);
299 } 299 }
300 } else { 300 } else {
301 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1); 301 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1);
302 m_pClipRgn = pSavedClip; 302 m_pClipRgn = pSavedClip;
303 } 303 }
304 } 304 }
305 305
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke( 364 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke(
365 const CFX_PathData* pPathData, 365 const CFX_PathData* pPathData,
366 const CFX_Matrix* pObject2Device, 366 const CFX_Matrix* pObject2Device,
367 const CFX_GraphStateData* pGraphState) { 367 const CFX_GraphStateData* pGraphState) {
368 if (!m_pClipRgn) { 368 if (!m_pClipRgn) {
369 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), 369 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH),
370 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); 370 GetDeviceCaps(FXDC_PIXEL_HEIGHT));
371 } 371 }
372 CAgg_PathData path_data; 372 CAgg_PathData path_data;
373 path_data.BuildPath(pPathData, NULL); 373 path_data.BuildPath(pPathData, nullptr);
374 agg::rasterizer_scanline_aa rasterizer; 374 agg::rasterizer_scanline_aa rasterizer;
375 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), 375 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
376 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); 376 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
377 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, 377 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device,
378 pGraphState); 378 pGraphState);
379 rasterizer.filling_rule(agg::fill_non_zero); 379 rasterizer.filling_rule(agg::fill_non_zero);
380 SetClipMask(rasterizer); 380 SetClipMask(rasterizer);
381 return TRUE; 381 return TRUE;
382 } 382 }
383 383
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 template <class Scanline> 1021 template <class Scanline>
1022 void render(const Scanline& sl) { 1022 void render(const Scanline& sl) {
1023 if (!m_pOriDevice && !composite_span) { 1023 if (!m_pOriDevice && !composite_span) {
1024 return; 1024 return;
1025 } 1025 }
1026 int y = sl.y(); 1026 int y = sl.y();
1027 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) { 1027 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) {
1028 return; 1028 return;
1029 } 1029 }
1030 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * y; 1030 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * y;
1031 uint8_t* dest_scan_extra_alpha = NULL; 1031 uint8_t* dest_scan_extra_alpha = nullptr;
1032 CFX_DIBitmap* pAlphaMask = m_pDevice->m_pAlphaMask; 1032 CFX_DIBitmap* pAlphaMask = m_pDevice->m_pAlphaMask;
1033 if (pAlphaMask) { 1033 if (pAlphaMask) {
1034 dest_scan_extra_alpha = 1034 dest_scan_extra_alpha =
1035 pAlphaMask->GetBuffer() + pAlphaMask->GetPitch() * y; 1035 pAlphaMask->GetBuffer() + pAlphaMask->GetPitch() * y;
1036 } 1036 }
1037 uint8_t* ori_scan = NULL; 1037 uint8_t* ori_scan = nullptr;
1038 if (m_pOriDevice) { 1038 if (m_pOriDevice) {
1039 ori_scan = m_pOriDevice->GetBuffer() + m_pOriDevice->GetPitch() * y; 1039 ori_scan = m_pOriDevice->GetBuffer() + m_pOriDevice->GetPitch() * y;
1040 } 1040 }
1041 int Bpp = m_pDevice->GetBPP() / 8; 1041 int Bpp = m_pDevice->GetBPP() / 8;
1042 FX_BOOL bDestAlpha = m_pDevice->HasAlpha() || m_pDevice->IsAlphaMask(); 1042 FX_BOOL bDestAlpha = m_pDevice->HasAlpha() || m_pDevice->IsAlphaMask();
1043 unsigned num_spans = sl.num_spans(); 1043 unsigned num_spans = sl.num_spans();
1044 typename Scanline::const_iterator span = sl.begin(); 1044 typename Scanline::const_iterator span = sl.begin();
1045 while (1) { 1045 while (1) {
1046 int x = span->x; 1046 int x = span->x;
1047 ASSERT(span->len > 0); 1047 ASSERT(span->len > 0);
1048 uint8_t* dest_pos = NULL; 1048 uint8_t* dest_pos = nullptr;
1049 uint8_t* dest_extra_alpha_pos = NULL; 1049 uint8_t* dest_extra_alpha_pos = nullptr;
1050 uint8_t* ori_pos = NULL; 1050 uint8_t* ori_pos = nullptr;
1051 if (Bpp) { 1051 if (Bpp) {
1052 ori_pos = ori_scan ? ori_scan + x * Bpp : NULL; 1052 ori_pos = ori_scan ? ori_scan + x * Bpp : nullptr;
1053 dest_pos = dest_scan + x * Bpp; 1053 dest_pos = dest_scan + x * Bpp;
1054 dest_extra_alpha_pos = 1054 dest_extra_alpha_pos =
1055 dest_scan_extra_alpha ? dest_scan_extra_alpha + x : NULL; 1055 dest_scan_extra_alpha ? dest_scan_extra_alpha + x : nullptr;
1056 } else { 1056 } else {
1057 dest_pos = dest_scan + x / 8; 1057 dest_pos = dest_scan + x / 8;
1058 ori_pos = ori_scan ? ori_scan + x / 8 : NULL; 1058 ori_pos = ori_scan ? ori_scan + x / 8 : nullptr;
1059 } 1059 }
1060 uint8_t* clip_pos = NULL; 1060 uint8_t* clip_pos = nullptr;
1061 if (m_pClipMask) { 1061 if (m_pClipMask) {
1062 clip_pos = m_pClipMask->GetBuffer() + 1062 clip_pos = m_pClipMask->GetBuffer() +
1063 (y - m_ClipBox.top) * m_pClipMask->GetPitch() + x - 1063 (y - m_ClipBox.top) * m_pClipMask->GetPitch() + x -
1064 m_ClipBox.left; 1064 m_ClipBox.left;
1065 } 1065 }
1066 if (ori_pos) { 1066 if (ori_pos) {
1067 CompositeSpan(dest_pos, ori_pos, Bpp, bDestAlpha, x, span->len, 1067 CompositeSpan(dest_pos, ori_pos, Bpp, bDestAlpha, x, span->len,
1068 span->covers, m_ClipBox.left, m_ClipBox.right, clip_pos); 1068 span->covers, m_ClipBox.left, m_ClipBox.right, clip_pos);
1069 } else { 1069 } else {
1070 (this->*composite_span)(dest_pos, Bpp, x, span->len, span->covers, 1070 (this->*composite_span)(dest_pos, Bpp, x, span->len, span->covers,
1071 m_ClipBox.left, m_ClipBox.right, clip_pos, 1071 m_ClipBox.left, m_ClipBox.right, clip_pos,
1072 dest_extra_alpha_pos); 1072 dest_extra_alpha_pos);
1073 } 1073 }
1074 if (--num_spans == 0) { 1074 if (--num_spans == 0) {
1075 break; 1075 break;
1076 } 1076 }
1077 ++span; 1077 ++span;
1078 } 1078 }
1079 } 1079 }
1080 1080
1081 FX_BOOL Init(CFX_DIBitmap* pDevice, 1081 FX_BOOL Init(CFX_DIBitmap* pDevice,
1082 CFX_DIBitmap* pOriDevice, 1082 CFX_DIBitmap* pOriDevice,
1083 const CFX_ClipRgn* pClipRgn, 1083 const CFX_ClipRgn* pClipRgn,
1084 uint32_t color, 1084 uint32_t color,
1085 FX_BOOL bFullCover, 1085 FX_BOOL bFullCover,
1086 FX_BOOL bRgbByteOrder, 1086 FX_BOOL bRgbByteOrder,
1087 int alpha_flag = 0, 1087 int alpha_flag = 0,
1088 void* pIccTransform = NULL) { 1088 void* pIccTransform = nullptr) {
1089 m_pDevice = pDevice; 1089 m_pDevice = pDevice;
1090 m_pClipRgn = pClipRgn; 1090 m_pClipRgn = pClipRgn;
1091 composite_span = NULL; 1091 composite_span = nullptr;
1092 m_bRgbByteOrder = bRgbByteOrder; 1092 m_bRgbByteOrder = bRgbByteOrder;
1093 m_pOriDevice = pOriDevice; 1093 m_pOriDevice = pOriDevice;
1094 if (m_pClipRgn) { 1094 if (m_pClipRgn) {
1095 m_ClipBox = m_pClipRgn->GetBox(); 1095 m_ClipBox = m_pClipRgn->GetBox();
1096 } else { 1096 } else {
1097 m_ClipBox.left = m_ClipBox.top = 0; 1097 m_ClipBox.left = m_ClipBox.top = 0;
1098 m_ClipBox.right = m_pDevice->GetWidth(); 1098 m_ClipBox.right = m_pDevice->GetWidth();
1099 m_ClipBox.bottom = m_pDevice->GetHeight(); 1099 m_ClipBox.bottom = m_pDevice->GetHeight();
1100 } 1100 }
1101 m_pClipMask = NULL; 1101 m_pClipMask = nullptr;
1102 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { 1102 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) {
1103 m_pClipMask = m_pClipRgn->GetMask(); 1103 m_pClipMask = m_pClipRgn->GetMask();
1104 } 1104 }
1105 m_bFullCover = bFullCover; 1105 m_bFullCover = bFullCover;
1106 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); 1106 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
1107 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); 1107 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
1108 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); 1108 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
1109 CCodec_IccModule* pIccModule = NULL; 1109 CCodec_IccModule* pIccModule = nullptr;
1110 if (!CFX_GEModule::Get()->GetCodecModule() || 1110 if (!CFX_GEModule::Get()->GetCodecModule() ||
1111 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { 1111 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
1112 pIccTransform = NULL; 1112 pIccTransform = nullptr;
1113 } else { 1113 } else {
1114 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 1114 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
1115 } 1115 }
1116 if (m_pDevice->GetBPP() == 8) { 1116 if (m_pDevice->GetBPP() == 8) {
1117 ASSERT(!m_bRgbByteOrder); 1117 ASSERT(!m_bRgbByteOrder);
1118 composite_span = &CFX_Renderer::CompositeSpanGray; 1118 composite_span = &CFX_Renderer::CompositeSpanGray;
1119 if (m_pDevice->IsAlphaMask()) { 1119 if (m_pDevice->IsAlphaMask()) {
1120 m_Gray = 255; 1120 m_Gray = 255;
1121 } else { 1121 } else {
1122 if (pIccTransform) { 1122 if (pIccTransform) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 } 1209 }
1210 }; 1210 };
1211 1211
1212 FX_BOOL CFX_AggDeviceDriver::RenderRasterizer( 1212 FX_BOOL CFX_AggDeviceDriver::RenderRasterizer(
1213 agg::rasterizer_scanline_aa& rasterizer, 1213 agg::rasterizer_scanline_aa& rasterizer,
1214 uint32_t color, 1214 uint32_t color,
1215 FX_BOOL bFullCover, 1215 FX_BOOL bFullCover,
1216 FX_BOOL bGroupKnockout, 1216 FX_BOOL bGroupKnockout,
1217 int alpha_flag, 1217 int alpha_flag,
1218 void* pIccTransform) { 1218 void* pIccTransform) {
1219 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : NULL; 1219 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : nullptr;
1220 CFX_Renderer render; 1220 CFX_Renderer render;
1221 if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover, 1221 if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover,
1222 m_bRgbByteOrder, alpha_flag, pIccTransform)) { 1222 m_bRgbByteOrder, alpha_flag, pIccTransform)) {
1223 return FALSE; 1223 return FALSE;
1224 } 1224 }
1225 agg::scanline_u8 scanline; 1225 agg::scanline_u8 scanline;
1226 agg::render_scanlines(rasterizer, scanline, render, 1226 agg::render_scanlines(rasterizer, scanline, render,
1227 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); 1227 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0);
1228 return TRUE; 1228 return TRUE;
1229 } 1229 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) 1263 ? FXGETFLAG_ALPHA_STROKE(alpha_flag)
1264 : FXARGB_A(stroke_color); 1264 : FXARGB_A(stroke_color);
1265 if (pGraphState && stroke_alpha) { 1265 if (pGraphState && stroke_alpha) {
1266 if (fill_mode & FX_ZEROAREA_FILL) { 1266 if (fill_mode & FX_ZEROAREA_FILL) {
1267 CAgg_PathData path_data; 1267 CAgg_PathData path_data;
1268 path_data.BuildPath(pPathData, pObject2Device); 1268 path_data.BuildPath(pPathData, pObject2Device);
1269 agg::rasterizer_scanline_aa rasterizer; 1269 agg::rasterizer_scanline_aa rasterizer;
1270 rasterizer.clip_box(0.0f, 0.0f, 1270 rasterizer.clip_box(0.0f, 0.0f,
1271 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), 1271 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
1272 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); 1272 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
1273 RasterizeStroke(rasterizer, path_data.m_PathData, NULL, pGraphState, 1, 1273 RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1,
1274 FALSE, fill_mode & FX_STROKE_TEXT_MODE); 1274 FALSE, fill_mode & FX_STROKE_TEXT_MODE);
1275 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | 1275 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 |
1276 FXGETFLAG_ALPHA_STROKE(alpha_flag); 1276 FXGETFLAG_ALPHA_STROKE(alpha_flag);
1277 if (!RenderRasterizer(rasterizer, stroke_color, 1277 if (!RenderRasterizer(rasterizer, stroke_color,
1278 fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout, 1278 fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout,
1279 fill_flag, pIccTransform)) { 1279 fill_flag, pIccTransform)) {
1280 return FALSE; 1280 return FALSE;
1281 } 1281 }
1282 return TRUE; 1282 return TRUE;
1283 } 1283 }
(...skipping 28 matching lines...) Expand all
1312 return TRUE; 1312 return TRUE;
1313 } 1313 }
1314 1314
1315 void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, uint32_t argb) { 1315 void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, uint32_t argb) {
1316 if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight()) { 1316 if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight()) {
1317 return; 1317 return;
1318 } 1318 }
1319 uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() + 1319 uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() +
1320 x * pBitmap->GetBPP() / 8; 1320 x * pBitmap->GetBPP() / 8;
1321 if (pBitmap->GetFormat() == FXDIB_Argb) { 1321 if (pBitmap->GetFormat() == FXDIB_Argb) {
1322 FXARGB_SETRGBORDERDIB(pos, ArgbGamma(argb)); 1322 FXARGB_SETRGBORDERDIB(pos, argb);
1323 } else { 1323 } else {
1324 int alpha = FXARGB_A(argb); 1324 int alpha = FXARGB_A(argb);
1325 pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255; 1325 pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255;
1326 pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255; 1326 pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255;
1327 pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255; 1327 pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255;
1328 } 1328 }
1329 } 1329 }
1330 1330
1331 void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap, 1331 void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap,
1332 int left, 1332 int left,
(...skipping 25 matching lines...) Expand all
1358 } else { 1358 } else {
1359 for (int col = 0; col < width; col++) { 1359 for (int col = 0; col < width; col++) {
1360 *dest_scan++ = src_r; 1360 *dest_scan++ = src_r;
1361 *dest_scan++ = src_g; 1361 *dest_scan++ = src_g;
1362 *dest_scan++ = src_b; 1362 *dest_scan++ = src_b;
1363 } 1363 }
1364 } 1364 }
1365 } 1365 }
1366 return; 1366 return;
1367 } 1367 }
1368 src_r = FX_GAMMA(src_r);
1369 src_g = FX_GAMMA(src_g);
1370 src_b = FX_GAMMA(src_b);
1371 for (int row = rect.top; row < rect.bottom; row++) { 1368 for (int row = rect.top; row < rect.bottom; row++) {
1372 uint8_t* dest_scan = pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp; 1369 uint8_t* dest_scan = pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp;
1373 if (bAlpha) { 1370 if (bAlpha) {
1374 for (int col = 0; col < width; col++) { 1371 for (int col = 0; col < width; col++) {
1375 uint8_t back_alpha = dest_scan[3]; 1372 uint8_t back_alpha = dest_scan[3];
1376 if (back_alpha == 0) { 1373 if (back_alpha == 0) {
1377 FXARGB_SETRGBORDERDIB(dest_scan, 1374 FXARGB_SETRGBORDERDIB(dest_scan,
1378 FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); 1375 FXARGB_MAKE(src_alpha, src_r, src_g, src_b));
1379 dest_scan += 4; 1376 dest_scan += 4;
1380 continue; 1377 continue;
1381 } 1378 }
1382 uint8_t dest_alpha = 1379 uint8_t dest_alpha =
1383 back_alpha + src_alpha - back_alpha * src_alpha / 255; 1380 back_alpha + src_alpha - back_alpha * src_alpha / 255;
1384 dest_scan[3] = dest_alpha; 1381 dest_scan[3] = dest_alpha;
1385 int alpha_ratio = src_alpha * 255 / dest_alpha; 1382 int alpha_ratio = src_alpha * 255 / dest_alpha;
1386 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); 1383 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio);
1387 dest_scan++; 1384 dest_scan++;
1388 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); 1385 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio);
1389 dest_scan++; 1386 dest_scan++;
1390 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); 1387 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio);
1391 dest_scan += 2; 1388 dest_scan += 2;
1392 } 1389 }
1393 } else { 1390 } else {
1394 for (int col = 0; col < width; col++) { 1391 for (int col = 0; col < width; col++) {
1395 *dest_scan = FX_GAMMA_INVERSE( 1392 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha);
1396 FXDIB_ALPHA_MERGE(FX_GAMMA(*dest_scan), src_r, src_alpha));
1397 dest_scan++; 1393 dest_scan++;
1398 *dest_scan = FX_GAMMA_INVERSE( 1394 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha);
1399 FXDIB_ALPHA_MERGE(FX_GAMMA(*dest_scan), src_g, src_alpha));
1400 dest_scan++; 1395 dest_scan++;
1401 *dest_scan = FX_GAMMA_INVERSE( 1396 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha);
1402 FXDIB_ALPHA_MERGE(FX_GAMMA(*dest_scan), src_b, src_alpha));
1403 dest_scan++; 1397 dest_scan++;
1404 if (Bpp == 4) { 1398 if (Bpp == 4) {
1405 dest_scan++; 1399 dest_scan++;
1406 } 1400 }
1407 } 1401 }
1408 } 1402 }
1409 } 1403 }
1410 } 1404 }
1411 1405
1412 void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap, 1406 void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap,
1413 int dest_left, 1407 int dest_left,
1414 int dest_top, 1408 int dest_top,
1415 int width, 1409 int width,
1416 int height, 1410 int height,
1417 const CFX_DIBSource* pSrcBitmap, 1411 const CFX_DIBSource* pSrcBitmap,
1418 int src_left, 1412 int src_left,
1419 int src_top) { 1413 int src_top) {
1420 if (!pBitmap) { 1414 if (!pBitmap) {
1421 return; 1415 return;
1422 } 1416 }
1423 pBitmap->GetOverlapRect(dest_left, dest_top, width, height, 1417 pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
1424 pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(), 1418 pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
1425 src_left, src_top, NULL); 1419 src_left, src_top, nullptr);
1426 if (width == 0 || height == 0) { 1420 if (width == 0 || height == 0) {
1427 return; 1421 return;
1428 } 1422 }
1429 int Bpp = pBitmap->GetBPP() / 8; 1423 int Bpp = pBitmap->GetBPP() / 8;
1430 FXDIB_Format dest_format = pBitmap->GetFormat(); 1424 FXDIB_Format dest_format = pBitmap->GetFormat();
1431 FXDIB_Format src_format = pSrcBitmap->GetFormat(); 1425 FXDIB_Format src_format = pSrcBitmap->GetFormat();
1432 int pitch = pBitmap->GetPitch(); 1426 int pitch = pBitmap->GetPitch();
1433 uint8_t* buffer = pBitmap->GetBuffer(); 1427 uint8_t* buffer = pBitmap->GetBuffer();
1434 if (dest_format == src_format) { 1428 if (dest_format == src_format) {
1435 for (int row = 0; row < height; row++) { 1429 for (int row = 0; row < height; row++) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1464 }
1471 } else { 1465 } else {
1472 ASSERT(FALSE); 1466 ASSERT(FALSE);
1473 } 1467 }
1474 } else if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) { 1468 } else if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) {
1475 if (src_format == FXDIB_Rgb) { 1469 if (src_format == FXDIB_Rgb) {
1476 for (int row = 0; row < height; row++) { 1470 for (int row = 0; row < height; row++) {
1477 uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch); 1471 uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch);
1478 uint8_t* src_scan = 1472 uint8_t* src_scan =
1479 (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3; 1473 (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
1480 if (src_format == FXDIB_Argb) { 1474 for (int col = 0; col < width; col++) {
1481 for (int col = 0; col < width; col++) { 1475 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
1482 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, FX_GAMMA(src_scan[0]), 1476 src_scan[2]));
1483 FX_GAMMA(src_scan[1]), 1477 dest_scan += 4;
1484 FX_GAMMA(src_scan[2]))); 1478 src_scan += 3;
1485 dest_scan += 4;
1486 src_scan += 3;
1487 }
1488 } else {
1489 for (int col = 0; col < width; col++) {
1490 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
1491 src_scan[2]));
1492 dest_scan += 4;
1493 src_scan += 3;
1494 }
1495 } 1479 }
1496 } 1480 }
1497 } else if (src_format == FXDIB_Rgb32) { 1481 } else if (src_format == FXDIB_Rgb32) {
1498 ASSERT(dest_format == FXDIB_Argb); 1482 ASSERT(dest_format == FXDIB_Argb);
1499 for (int row = 0; row < height; row++) { 1483 for (int row = 0; row < height; row++) {
1500 uint8_t* dest_scan = dest_buf + row * pitch; 1484 uint8_t* dest_scan = dest_buf + row * pitch;
1501 uint8_t* src_scan = 1485 uint8_t* src_scan =
1502 (uint8_t*)(pSrcBitmap->GetScanline(src_top + row) + src_left * 4); 1486 (uint8_t*)(pSrcBitmap->GetScanline(src_top + row) + src_left * 4);
1503 for (int col = 0; col < width; col++) { 1487 for (int col = 0; col < width; col++) {
1504 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1], 1488 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, 1543 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x,
1560 int y, 1544 int y,
1561 uint32_t color, 1545 uint32_t color,
1562 int alpha_flag, 1546 int alpha_flag,
1563 void* pIccTransform) { 1547 void* pIccTransform) {
1564 if (!m_pBitmap->GetBuffer()) { 1548 if (!m_pBitmap->GetBuffer()) {
1565 return TRUE; 1549 return TRUE;
1566 } 1550 }
1567 if (!CFX_GEModule::Get()->GetCodecModule() || 1551 if (!CFX_GEModule::Get()->GetCodecModule() ||
1568 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { 1552 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
1569 pIccTransform = NULL; 1553 pIccTransform = nullptr;
1570 } 1554 }
1571 if (!m_pClipRgn) { 1555 if (!m_pClipRgn) {
1572 if (m_bRgbByteOrder) { 1556 if (m_bRgbByteOrder) {
1573 RgbByteOrderSetPixel(m_pBitmap, x, y, color); 1557 RgbByteOrderSetPixel(m_pBitmap, x, y, color);
1574 } else { 1558 } else {
1575 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform); 1559 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform);
1576 } 1560 }
1577 } else if (m_pClipRgn->GetBox().Contains(x, y)) { 1561 } else if (m_pClipRgn->GetBox().Contains(x, y)) {
1578 if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { 1562 if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
1579 if (m_bRgbByteOrder) { 1563 if (m_bRgbByteOrder) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Width(), 1616 m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Width(),
1633 draw_rect.Height(), fill_color, alpha_flag, 1617 draw_rect.Height(), fill_color, alpha_flag,
1634 pIccTransform); 1618 pIccTransform);
1635 } 1619 }
1636 return TRUE; 1620 return TRUE;
1637 } 1621 }
1638 m_pBitmap->CompositeMask( 1622 m_pBitmap->CompositeMask(
1639 draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(), 1623 draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(),
1640 (const CFX_DIBitmap*)m_pClipRgn->GetMask(), fill_color, 1624 (const CFX_DIBitmap*)m_pClipRgn->GetMask(), fill_color,
1641 draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top, 1625 draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top,
1642 FXDIB_BLEND_NORMAL, NULL, m_bRgbByteOrder, alpha_flag, pIccTransform); 1626 FXDIB_BLEND_NORMAL, nullptr, m_bRgbByteOrder, alpha_flag, pIccTransform);
1643 return TRUE; 1627 return TRUE;
1644 } 1628 }
1645 1629
1646 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) { 1630 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) {
1647 if (!m_pClipRgn) { 1631 if (!m_pClipRgn) {
1648 pRect->left = pRect->top = 0; 1632 pRect->left = pRect->top = 0;
1649 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); 1633 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH);
1650 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); 1634 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT);
1651 return TRUE; 1635 return TRUE;
1652 } 1636 }
(...skipping 15 matching lines...) Expand all
1668 pBitmap->GetHeight(), m_pBitmap, left, top); 1652 pBitmap->GetHeight(), m_pBitmap, left, top);
1669 } else { 1653 } else {
1670 return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(), 1654 return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(),
1671 pBitmap->GetHeight(), m_pBitmap, left, top, 1655 pBitmap->GetHeight(), m_pBitmap, left, top,
1672 pIccTransform); 1656 pIccTransform);
1673 } 1657 }
1674 return TRUE; 1658 return TRUE;
1675 } 1659 }
1676 FX_RECT rect(left, top, left + pBitmap->GetWidth(), 1660 FX_RECT rect(left, top, left + pBitmap->GetWidth(),
1677 top + pBitmap->GetHeight()); 1661 top + pBitmap->GetHeight());
1678 CFX_DIBitmap* pBack = NULL; 1662 CFX_DIBitmap* pBack = nullptr;
1679 if (m_pOriDevice) { 1663 if (m_pOriDevice) {
1680 pBack = m_pOriDevice->Clone(&rect); 1664 pBack = m_pOriDevice->Clone(&rect);
1681 if (!pBack) { 1665 if (!pBack) {
1682 return TRUE; 1666 return TRUE;
1683 } 1667 }
1684 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), 1668 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(),
1685 m_pBitmap, 0, 0); 1669 m_pBitmap, 0, 0);
1686 } else { 1670 } else {
1687 pBack = m_pBitmap->Clone(&rect); 1671 pBack = m_pBitmap->Clone(&rect);
1688 } 1672 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 SetDeviceDriver(pDriver); 1815 SetDeviceDriver(pDriver);
1832 return true; 1816 return true;
1833 } 1817 }
1834 1818
1835 CFX_FxgeDevice::~CFX_FxgeDevice() { 1819 CFX_FxgeDevice::~CFX_FxgeDevice() {
1836 if (m_bOwnedBitmap) { 1820 if (m_bOwnedBitmap) {
1837 delete GetBitmap(); 1821 delete GetBitmap();
1838 } 1822 }
1839 } 1823 }
1840 #endif 1824 #endif
OLDNEW
« no previous file with comments | « no previous file | core/fxge/dib/fx_dib_composite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698