void check() const { if (!sourced() && !indexed()) { throw std::runtime_error("Session has no backing data."); } }
bool all_indexed() { bool allIndexed = true; for (size_t rNum = 0; rNum < m_nFiles; ++rNum) if (!indexed(rNum)) allIndexed = false; return allIndexed; }
void loadIndex(const char *indexFilename, std::vector<std::vector<uint32_t>> &index) { std::ifstream indexFile(indexFilename); while (!indexFile.eof()) { uint32_t length; indexFile.read(reinterpret_cast<char *>(&length), sizeof(uint32_t)); std::vector<uint32_t> indexed(length); indexFile.read(reinterpret_cast<char *>(indexed.data()), sizeof(uint32_t) * length); index.push_back(indexed); } indexFile.close(); }
bool QueryPlan::queryBoundsExactOrderSuffix() const { if ( !indexed() || !_frs.matchPossible() || !_frs.mustBeExactMatchRepresentation() ) { return false; } BSONObj idxKey = indexKey(); BSONObjIterator index( idxKey ); BSONObjIterator order( _order ); int coveredNonUniversalRanges = 0; while( index.more() ) { const FieldRange& indexFieldRange = _frs.range( (*index).fieldName() ); if ( !indexFieldRange.isPointIntervalSet() ) { if ( !indexFieldRange.universal() ) { // The last indexed range may be a non point set containing a single interval. // SERVER-5777 if ( indexFieldRange.intervals().size() > 1 ) { return false; } ++coveredNonUniversalRanges; } break; } ++coveredNonUniversalRanges; if ( order.more() && str::equals( (*index).fieldName(), (*order).fieldName() ) ) { ++order; } ++index; } if ( coveredNonUniversalRanges != _frs.numNonUniversalRanges() ) { return false; } while( index.more() && order.more() ) { if ( !str::equals( (*index).fieldName(), (*order).fieldName() ) ) { return false; } if ( ( elementDirection( *index ) < 0 ) != ( elementDirection( *order ) < 0 ) ) { return false; } ++order; ++index; } return !order.more(); }
QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition) { QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform()); QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); QVector<QRgb> colors(256); for (int i=0; i<256; ++i) colors[i] = qRgba(0, 0, 0, i); indexed.setColorTable(colors); for (int y=0; y<im.height(); ++y) { uint *src = (uint*) im.scanLine(y); uchar *dst = indexed.scanLine(y); for (int x=0; x<im.width(); ++x) { *dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.); ++dst; ++src; } } return indexed; }
QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph) { const glyph_metrics_t br = boundingBox(glyph); QImage im(qRound(br.width)+2, qRound(br.height)+2, QImage::Format_RGB32); im.fill(0); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) uint cgflags = kCGImageAlphaNoneSkipFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) cgflags |= kCGBitmapByteOrder32Host; #endif #else CGImageAlphaInfo cgflags = kCGImageAlphaNoneSkipFirst; #endif CGContextRef ctx = CGBitmapContextCreate(im.bits(), im.width(), im.height(), 8, im.bytesPerLine(), colorspace, cgflags); CGColorSpaceRelease(colorspace); CGContextSetFontSize(ctx, fontDef.pixelSize); CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias)); CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx); CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0); CGAffineTransformConcat(cgMatrix, oldTextMatrix); if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0)); cgMatrix = CGAffineTransformConcat(cgMatrix, multiEngine->transform); CGContextSetTextMatrix(ctx, cgMatrix); CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); CGContextSetTextDrawingMode(ctx, kCGTextFill); CGContextSetFont(ctx, cgFont); qreal pos_x = -br.x.toReal()+1, pos_y = im.height()+br.y.toReal(); CGContextSetTextPosition(ctx, pos_x, pos_y); CGSize advance; advance.width = 0; advance.height = 0; CGGlyph cgGlyph = glyph; CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1); if (synthesisFlags & QFontEngine::SynthesizedBold) { CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y); CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1); } CGContextRelease(ctx); QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); QVector<QRgb> colors(256); for (int i=0; i<256; ++i) colors[i] = qRgba(0, 0, 0, i); indexed.setColorTable(colors); for (int y=0; y<im.height(); ++y) { uint *src = (uint*) im.scanLine(y); uchar *dst = indexed.scanLine(y); for (int x=0; x<im.width(); ++x) { *dst = qGray(*src); ++dst; ++src; } } return indexed; }
// // * - type ... calgray, calrgb, cielab, icc, [palette] // * - white = x, z // * - black = x, y, z // * - range = amin, amax, bmin, bmax (cielab) // * - gamma = val [,val, val] (calgray [,calrgb]) // * - matrix = 9 vals (calrgb) // * - profile = file-path (icc based) // * - name = sRGB .. some predefined name IColorSpaceMan::cs_handle_pair_t ColorSpaceManImpl::color_space_load(Char const* spec_str) { ParseArgs pargs(&g_cs_kwds, &g_cs_names); ParsedResult pres(parse_options(spec_str, pargs)); unsigned name = pres.explicit_value(); if (name == ParsedResult::NO_EXPL_VALUE) throw exception_invalid_value(msg_invalid_cs_spec()) << JAGLOC; cs_str_spec_t spec(name, pres); cs_handle_pair_t result; switch (name) { case CSN_SRGB: result.first = register_icc_from_memory(binres::icc_srgb, binres::icc_srgb_size, 3); break; case CSN_ADOBE_RGB: result.first = register_icc_from_memory(binres::icc_adobe_rgb, binres::icc_adobe_rgb_size, 3); break; case CSN_BYID: if (!spec.id) throw exception_invalid_value(msg_invalid_cs_spec()) << JAGLOC; result.first = ColorSpaceHandle( handle_from_id<RESOURCE_COLOR_SPACE>(spec.id)); break; case CSN_DEVICE_RGB: result.first = ColorSpaceHandle(CS_DEVICE_RGB); break; case CSN_DEVICE_GRAY: result.first = ColorSpaceHandle(CS_DEVICE_GRAY); break; case CSN_DEVICE_CMYK: result.first = ColorSpaceHandle(CS_DEVICE_CMYK); break; case CSN_CALGRAY: { intrusive_ptr<ICIECalGray> gray(define_calgray()); set_cie_base(spec, *gray); if (!spec.gamma.empty()) gray->gamma(spec.gamma[0]); result.first = color_space_load(gray); break; } case CSN_CALRGB: { intrusive_ptr<ICIECalRGB> rgb(define_calrgb()); set_cie_base(spec, *rgb); if (!spec.gamma.empty()) { JAG_ASSERT(spec.gamma.size()==3); rgb->gamma(spec.gamma[0], spec.gamma[1], spec.gamma[2]); } if (!spec.matrix.empty()) { JAG_ASSERT(spec.matrix.size()==9); rgb->matrix(spec.matrix[0], spec.matrix[1], spec.matrix[2], spec.matrix[3], spec.matrix[4], spec.matrix[5], spec.matrix[6], spec.matrix[7], spec.matrix[8]); } result.first = color_space_load(rgb); break; } case CSN_CIELAB: { intrusive_ptr<ICIELab> lab(define_cielab()); set_cie_base(spec, *lab); if (!spec.range.empty()) { JAG_ASSERT(4 == spec.range.size()); lab->range(spec.range[0], spec.range[1], spec.range[2], spec.range[3]); } result.first = color_space_load(lab); break; } case CSN_ICC: { if (-1==spec.components || spec.icc_profile.empty()) throw exception_invalid_value(msg_invalid_cs_spec()) << JAGLOC; intrusive_ptr<IICCBased> icc(define_iccbased()); icc->num_components(spec.components); icc->icc_profile(spec.icc_profile.c_str()); result.first = color_space_load(icc); break; } default: ; } // switch JAG_ASSERT(is_valid(result.first)); // is it palette? if (!spec.palette.empty()) { intrusive_ptr<IPalette> indexed(define_indexed()); indexed->set( id_from_handle<ColorSpace>(result.first), &spec.palette[0], static_cast<UInt>(spec.palette.size())); result.second = result.first; result.first = color_space_load(indexed); } return result; }