OGRErr OGRPGDumpLayer::CreateFeature( OGRFeature *poFeature ) { if( NULL == poFeature ) { CPLError( CE_Failure, CPLE_AppDefined, "NULL pointer to OGRFeature passed to CreateFeature()." ); return OGRERR_FAILURE; } nFeatures ++; // We avoid testing the config option too often. if( bUseCopy == USE_COPY_UNSET ) bUseCopy = CSLTestBoolean( CPLGetConfigOption( "PG_USE_COPY", "NO") ); if( !bUseCopy ) { return CreateFeatureViaInsert( poFeature ); } else { if ( !bCopyActive ) { /* This is a heuristics. If the first feature to be copied has a */ /* FID set (and that a FID column has been identified), then we will */ /* try to copy FID values from features. Otherwise, we will not */ /* do and assume that the FID column is an autoincremented column. */ StartCopy(poFeature->GetFID() != OGRNullFID); } return CreateFeatureViaCopy( poFeature ); } }
OGRErr OGRPGDumpLayer::CreateFeature( OGRFeature *poFeature ) { if( NULL == poFeature ) { CPLError( CE_Failure, CPLE_AppDefined, "NULL pointer to OGRFeature passed to CreateFeature()." ); return OGRERR_FAILURE; } nFeatures ++; // We avoid testing the config option too often. if( bUseCopy == USE_COPY_UNSET ) bUseCopy = CSLTestBoolean( CPLGetConfigOption( "PG_USE_COPY", "NO") ); if( !bUseCopy ) { return CreateFeatureViaInsert( poFeature ); } else { if ( !bCopyActive ) StartCopy(); return CreateFeatureViaCopy( poFeature ); } }
void CVisPPUSim::DoProcessing() { Int lines; // Copy ids; Uint32 copyRGB; Uint32 copyLUT; Uint32 copyGray; Uint32 copyErodedLUT; // Acquire the image buffers const Uint8 * pLUT = (Uint8*)m_iportLUT.GetBuffer(); const Uint32 * pRGBImage = (const Uint32*)m_iportRGBInput.GetBuffer(); Uint8 * pGrayImage = (Uint8*)m_oportGrayOutput.GetBuffer(); Uint8 * pLUTImage = (Uint8*)m_oportLUTOutput.GetBuffer(); // *************************************************************** // Process the image line by line; First convert to gray and do // the LUT lookup. // *************************************************************** // Prologue; copy the RGB lines from the image copyRGB = StartCopy( (Ptr)m_pRGBLine, (Ptr)pRGBImage, m_unResultWidth * 4 ); copyGray = COPY_DONE; copyLUT = COPY_DONE; // Kernel for ( lines = 0; lines < m_unResultHeight; lines++) { Uint32 offs = lines * m_unResultWidth; // Convert RGB to gray // -> need RGB input // -> need gray WaitCopy( copyRGB ); WaitCopy( copyGray ); RGBtoGray( m_pRGBLine, (Uint32*)(m_pGrayLine), m_unResultWidth ); // Lookup the RGB pixels; but not on first and last lines. // -> done with gray afterwards // -> done with RGB afterwards // -> done with LUT afterwards WaitCopy( copyLUT ); if ( (lines != 0) && (lines != m_unResultHeight-1) ) LookupPixels( m_pRGBLine, m_pLUTData, m_pGrayLine, pLUT, m_unResultWidth ); else MemSet( m_pLUTData, 0, m_unResultWidth ); if ( lines < m_unResultHeight-1) copyRGB = StartCopy( (Ptr)m_pRGBLine, (Ptr)(pRGBImage + offs + m_unResultWidth), m_unResultWidth * 4 ); copyGray = StartCopy( (Ptr)(pGrayImage + offs), m_pGrayLine, m_unResultWidth ); copyLUT = StartCopy( (Ptr)(pLUTImage + offs), m_pLUTData, m_unResultWidth ); } // Epilogue //WaitCopy( copyRGB ); WaitCopy( copyLUT ); WaitCopy( copyGray ); // *************************************************************** // Erode the image. // *************************************************************** for (int i=0; i<m_nNumErosions ; i++) { // To keep things simple, we'd like to do the erosion in place, // that is the input and output port is the same. That behaviour // implies that we have to copy the new input data before writing // the output data back to the image. // Copy the input data. copyLUT = StartCopy( m_pLUTData, (Ptr)(pLUTImage) , m_unResultWidth * 3); WaitCopy( copyLUT ); for ( lines = 1; lines < m_unResultHeight-1; lines++) { // Erode a line ErodeLine_lut( m_pLUTData, m_pErodedLUTData, m_unResultWidth ); // Copy the next input data. copyLUT = StartCopy( m_pLUTData, (Ptr)(pLUTImage + lines * m_unResultWidth) , m_unResultWidth * 3 ); // Wait for the copy to finish, so that the output can then be written. WaitCopy( copyLUT ); // Copy the result data out copyErodedLUT = StartCopy( (Ptr)(pLUTImage + lines*m_unResultWidth) , m_pErodedLUTData, m_unResultWidth ); WaitCopy( copyErodedLUT ); } } // Clear the most left and right rows. for ( lines = 0; lines < m_unResultHeight; lines++) { pLUTImage[ lines*m_unResultWidth ] = 0; pLUTImage[ lines*m_unResultWidth + m_unResultWidth - 1] = 0; } /* // Convert the image to grayscale StartProfileTask( m_nProfile_1 ); RGBtoGray( pRGBImage, (Uint32*)(pGrayImage), m_unResultWidth*m_unResultHeight ); StopProfileTask( m_nProfile_1 ); // do the LUT conversion StartProfileTask( m_nProfile_2 ); LookupPixels( pRGBImage, pLUTImage, m_unResultWidth*m_unResultHeight ); StopProfileTask( m_nProfile_2 ); // Mask out all grayscale pixels where there is background StartProfileTask( m_nProfile_3 ); for ( Uint32 i=0; i<m_unResultWidth*m_unResultHeight; i++) if ( pLUTImage[i] == 0 ) pGrayImage[i] = 0; StopProfileTask( m_nProfile_3 ); */ /* // Do Erosion for ( int er=0; er<CVisCalibHistogram::NUM_EROSIONS; er++) { for ( Uint32 line=1; line<m_unResultHeight-1; line++) { Uint32 offs = line * m_unResultWidth; ErodeLine( pLUTImage + offs, pErodedImage + offs + m_unResultWidth, m_unResultWidth ); } memcpy( pLUTImage, pErodedImage, m_unResultWidth*m_unResultHeight ); } */ }
void GPodDevice::StartDelete() { StartCopy(nullptr); }
void WmdmDevice::StartDelete() { StartCopy(NULL); }
void MtpDevice::StartDelete() { StartCopy(nullptr); }