• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ size函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中size函数的典型用法代码示例。如果您正苦于以下问题:C++ size函数的具体用法?C++ size怎么用?C++ size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: assert

    reference operator[]( size_t n )
    {
        assert(n < size());

        return reference( *this, n, queue);
    }
开发者ID:nagyist,项目名称:clSPARSE,代码行数:6,代码来源:clvector.hpp


示例2: size

void eWindow::hide() {
	if (m_animation_mode & 0x10)
		m_desktop->sendHide(position(), size());
	eWidget::hide();
}
开发者ID:hd75hd,项目名称:enigma2,代码行数:5,代码来源:ewindow.cpp


示例3: size

void WebPage::createWindow() {
  QSize size(1680, 1050);
  setViewportSize(size);
}
开发者ID:BadAllOff,项目名称:capybara-webkit,代码行数:4,代码来源:WebPage.cpp


示例4: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(test_result_contains_object, WithSphere) {
    const auto result = hitTest.sphereTest({0.f, 0.f, 0.f}, 1.f);
    BOOST_ASSERT(result.size() == 1);
    BOOST_CHECK_EQUAL(result[0].object, object);
}
开发者ID:rwengine,项目名称:openrw,代码行数:5,代码来源:test_HitTest.cpp


示例5: getType

string ofParameterGroup::getType(int position) const {
    if(position>=size()) return "";
    else return obj->parameters[position]->type();
}
开发者ID:Dariusz-L,项目名称:openFrameworks-FlasCC,代码行数:4,代码来源:ofParameterGroup.cpp


示例6: grow

objVectorOop objVectorOopClass::grow(fint delta, bool mustAllocate) {
  objVectorOop v= (objVectorOop) slotsOopClass::grow(size(), delta,
                                                     mustAllocate);
  if (oop(v) != failedAllocationOop) v->set_length(length() + delta);
  return v;
}
开发者ID:AaronNGray,项目名称:self,代码行数:6,代码来源:objVectorOop.cpp


示例7: main

int main(int argc, char* argv[])
{
    // check for correct number of args
    if (argc != 2 && argc != 3)
    {
        printf("Usage: speller [dictionary] text\n");
        return 1;
    }

    // structs for timing data
    struct rusage before, after;

    // benchmarks
    double time_load = 0.0, time_check = 0.0, time_size = 0.0, time_unload = 0.0;

    // determine dictionary to use
    char* dictionary = (argc == 3) ? argv[1] : DICTIONARY;
    
    // load dictionary
    getrusage(RUSAGE_SELF, &before);
    bool loaded = load(dictionary);
    getrusage(RUSAGE_SELF, &after);

    // abort if dictionary not loaded
    if (!loaded)
    {
        printf("Could not load %s.\n", dictionary);
        return 1;
    }

    // calculate time to load dictionary
    time_load = calculate(&before, &after);

    // try to open text
    char* text = (argc == 3) ? argv[2] : argv[1];
    FILE* fp = fopen(text, "r");
    if (fp == NULL)
    {
        printf("Could not open %s.\n", text);
        unload();
        return 1;
    }

    // prepare to report misspellings
    printf("\nMISSPELLED WORDS\n\n");

    // prepare to spell-check
    int index = 0, misspellings = 0, words = 0;
    char word[LENGTH+1];

    // spell-check each word in text
    for (int c = fgetc(fp); c != EOF; c = fgetc(fp))
    {
        // allow only alphabetical characters and apostrophes
        if (isalpha(c) || (c == '\'' && index > 0))
        {
            // append character to word
            word[index] = c;
            index++;

            // ignore alphabetical strings too long to be words
            if (index > LENGTH)
            {
                // consume remainder of alphabetical string
                while ((c = fgetc(fp)) != EOF && isalpha(c));

                // prepare for new word
                index = 0;
            }
        }

        // ignore words with numbers (like MS Word can)
        else if (isdigit(c))
        {
            // consume remainder of alphanumeric string
            while ((c = fgetc(fp)) != EOF && isalnum(c));

            // prepare for new word
            index = 0;
        }

        // we must have found a whole word
        else if (index > 0)
        {
            // terminate current word
            word[index] = '\0';

            // update counter
            words++;

            // check word's spelling
            getrusage(RUSAGE_SELF, &before);
            bool misspelled = !check(word);
            getrusage(RUSAGE_SELF, &after);

            // update benchmark
            time_check += calculate(&before, &after);

            // print word if misspelled
            if (misspelled)
//.........这里部分代码省略.........
开发者ID:tomjacob,项目名称:CS50,代码行数:101,代码来源:speller.c


示例8: Cancel

void RWsTextCursor::SetL(const TWsWinCmdSetTextCursor &aSet, TBool aClipped)
	{
	if (aSet.cursor.iType < TTextCursor::ETypeFirst ||
        (aSet.cursor.iType > TTextCursor::ETypeLast &&        
         aSet.cursor.iType <= TTextCursor::ETypeLastBasic) ||
		(aSet.cursor.iFlags&static_cast<TUint>(ETextCursorPrivateFlags)))
		{
		Cancel();
		iGroupWin->OwnerPanic(EWservPanicInvalidTextCursor);
		}
	else
		{
		CWsClientWindow* win = NULL;
		iGroupWin->WsOwner()->HandleToClientWindow(aSet.window, &win);

		// Check window is a child of the group window
		CWsWindowBase* searchWin = NULL;
		for(searchWin=win; searchWin->WinType()!=EWinTypeGroup; searchWin=searchWin->BaseParent())
			{}
		if (iGroupWin != searchWin)
			{
			Cancel();
			iGroupWin->OwnerPanic(EWservPanicWindow);
			}

		TPoint pos(aSet.pos.iX, aSet.pos.iY-aSet.cursor.iAscent);
		TSize size(aSet.cursor.iWidth, aSet.cursor.iHeight);
		TUint flags = aSet.cursor.iFlags;
		TInt type = aSet.cursor.iType;
		TRect clipRect = iClipRect;
		TRgb color = aSet.cursor.iColor;
		CWsCustomTextCursor* customTextCursor = iCustomTextCursor;
		TBool changed = EFalse;

		TPoint clipOrigo;
		TSize clipSize;

		if (type > TTextCursor::ETypeLastBasic)
			{
			changed = ETrue;

			customTextCursor = CWsClient::FindCustomTextCursor(type);
			if (!customTextCursor)
				{
				Cancel();
				iGroupWin->OwnerPanic(EWservPanicNoCustomTextCursor);
				return;
				}
			
			if( !customTextCursor->HasSpriteMember() )
				{
				iGroupWin->OwnerPanic(EWservPanicNoSpriteMember);
				return;
				}
			
			TInt yAdjust=0;
			switch (customTextCursor->Alignment())
				{
				case RWsSession::ECustomTextCursorAlignTop:
					break;
				case RWsSession::ECustomTextCursorAlignBaseline:
					yAdjust = aSet.cursor.iAscent-1;
					break;
				case RWsSession::ECustomTextCursorAlignBottom:
					yAdjust = aSet.cursor.iHeight-1;
					break;
				default:
					Cancel();
					iGroupWin->OwnerPanic(EWservPanicCustomTextCursorAlign);
					return;
				}
			pos.iY += yAdjust;
			// Start with a clipping rect to be the whole window
			// relative cursor pos and shrink down to what we want
			clipOrigo = -pos;
			clipSize = win->Size();
			if (flags & TTextCursor::EFlagClipHorizontal)
				{
				clipOrigo.iX = 0;
				clipSize.iWidth = size.iWidth;
				}
			if (flags & TTextCursor::EFlagClipVertical)
				{
				clipOrigo.iY = -yAdjust;
				clipSize.iHeight = aSet.cursor.iHeight;
				}
			}
		else
			{
			customTextCursor = NULL;
			}

		if (aClipped)
			{
			flags|=ETextCursorFlagClipped;
			clipRect=aSet.rect;
			}

		if (pos != iPos || size != iSize || iType != type ||
			flags != iFlags || clipRect != iClipRect || color != iColor ||
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:TCURSOR.CPP


示例9: kill

void kill(Treap *t) {
    if (!size(t)) return;
    kill(t->l);
    kill(t->r);
    delete t;
}
开发者ID:jackyliuxx,项目名称:codebook,代码行数:6,代码来源:treap.cpp


示例10: size

DecoratorDialog::~DecoratorDialog() {
  previous_size = size();
}
开发者ID:SciBoy,项目名称:douml,代码行数:3,代码来源:DecoratorDialog.cpp


示例11: pull

void pull(Treap *t) {
    push(t->l);
    push(t->r);
    t->size = size(t->l) + size(t->r) + 1;
}
开发者ID:jackyliuxx,项目名称:codebook,代码行数:5,代码来源:treap.cpp


示例12: push

void push(Treap *t) {
    if (!size(t)) return;
}
开发者ID:jackyliuxx,项目名称:codebook,代码行数:3,代码来源:treap.cpp


示例13: end

 iterator end()
 {
     return iterator(*this, size(), queue);
 }
开发者ID:nagyist,项目名称:clSPARSE,代码行数:4,代码来源:clvector.hpp


示例14: test

void test(RandomForestImage& randomForest, const std::string& folderTesting,
        const std::string& folderPrediction, const bool useDepthFilling,
        const bool writeProbabilityImages) {

    auto filenames = listImageFilenames(folderTesting);
    if (filenames.empty()) {
        throw std::runtime_error(std::string("found no files in ") + folderTesting);
    }

    CURFIL_INFO("got " << filenames.size() << " files for prediction");

    CURFIL_INFO("label/color map:");
    const auto labelColorMap = randomForest.getLabelColorMap();
    for (const auto& labelColor : labelColorMap) {
        const auto color = LabelImage::decodeLabel(labelColor.first);
        CURFIL_INFO("label: " << static_cast<int>(labelColor.first) << ", color: RGB(" << color << ")");
    }

  //  tbb::mutex totalMutex;
    utils::Average averageAccuracy;
    utils::Average averageAccuracyWithoutVoid;

    size_t i = 0;

    const bool useCIELab = randomForest.getConfiguration().isUseCIELab();
    CURFIL_INFO("CIELab: " << useCIELab);
    CURFIL_INFO("DepthFilling: " << useDepthFilling);

    const bool useDepthImages = randomForest.getConfiguration().isUseDepthImages();
    CURFIL_INFO("useDepthImages: " << useDepthImages);

    bool onGPU = randomForest.getConfiguration().getAccelerationMode() == GPU_ONLY;

    size_t grainSize = 1;
    if (!onGPU) {
        grainSize = filenames.size();
    }

    bool writeImages = true;
    if (folderPrediction.empty()) {
        CURFIL_WARNING("no prediction folder given. will not write images");
        writeImages = false;
    }

    std::vector<LabelType> ignoredLabels;
    for (const std::string colorString : randomForest.getConfiguration().getIgnoredColors()) {
    	ignoredLabels.push_back(LabelImage::encodeColor(RGBColor(colorString)));
    }

    const LabelType numClasses = randomForest.getNumClasses();
    ConfusionMatrix totalConfusionMatrix(numClasses, ignoredLabels);
    double totalPredictionTime = 0;
    {
  //  tbb::parallel_for(tbb::blocked_range<size_t>(0, filenames.size(), grainSize),
  //          [&](const tbb::blocked_range<size_t>& range) {
                for(size_t fileNr = 0; fileNr != filenames.size(); fileNr++) {
                    const std::string& filename = filenames[fileNr];
                    const auto imageLabelPair = loadImagePair(filename, useCIELab, useDepthImages, useDepthFilling);
                    const RGBDImage& testImage = imageLabelPair.getRGBDImage();
                    const LabelImage& groundTruth = imageLabelPair.getLabelImage();
                    LabelImage prediction(testImage.getWidth(), testImage.getHeight());

                    for(int y = 0; y < groundTruth.getHeight(); y++) {
                        for(int x = 0; x < groundTruth.getWidth(); x++) {
                            const LabelType label = groundTruth.getLabel(x, y);
                            if (label >= numClasses) {
                                const auto msg = (boost::format("illegal label in ground truth image '%s' at pixel (%d,%d): %d RGB(%3d,%3d,%3d) (numClasses: %d)")
                                        % filename
                                        % x % y
                                        % static_cast<int>(label)
                                        % LabelImage::decodeLabel(label)[0]
                                        % LabelImage::decodeLabel(label)[1]
                                        % LabelImage::decodeLabel(label)[2]
                                        % static_cast<int>(numClasses)
                                ).str();
                                throw std::runtime_error(msg);
                            }
                        }
                    }

                    boost::filesystem::path fn(testImage.getFilename());
                    const std::string basepath = folderPrediction + "/" + boost::filesystem::basename(fn);

                    cuv::ndarray<float, cuv::host_memory_space> probabilities;
                    utils::Timer timer2;
                    prediction = randomForest.predict(testImage, &probabilities, onGPU, useDepthImages);
                    totalPredictionTime += timer2.getMilliseconds();

#ifndef NDEBUG
            for(LabelType label = 0; label < randomForest.getNumClasses(); label++) {
                if (!randomForest.shouldIgnoreLabel(label)) {
                    continue;
                }

                // ignored classes must not be predicted as we did not sample them
                for(size_t y = 0; y < probabilities.shape(1); y++) {
                    for(size_t x = 0; x < probabilities.shape(2); x++) {
                        const float& probability = probabilities(label, y, x);
                        assert(probability == 0.0);
                    }
//.........这里部分代码省略.........
开发者ID:jhhsia,项目名称:curfil,代码行数:101,代码来源:predict.cpp


示例15: stateSaver

void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
    const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
{
    if (!nativeImageForCurrentFrame())
        return;

    if (!patternTransform.isInvertible())
        return;

    CGContextRef context = ctxt->platformContext();
    GraphicsContextStateSaver stateSaver(*ctxt);
    CGContextClipToRect(context, destRect);
    ctxt->setCompositeOperation(op, blendMode);
    CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
    CGContextScaleCTM(context, 1, -1);
    
    // Compute the scaled tile size.
    float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d());
    
    // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being
    // the origin).
    float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.
    float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);

    CGImageRef tileImage = nativeImageForCurrentFrame();
    float h = CGImageGetHeight(tileImage);

    RetainPtr<CGImageRef> subImage;
    if (tileRect.size() == size())
        subImage = tileImage;
    else {
        // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
        // because sub-images are only used for border-image, which only renders when the image is fully decoded.
        ASSERT(h == height());
        subImage = adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
    }

    // Adjust the color space.
    subImage = Image::imageWithColorSpace(subImage.get(), styleColorSpace);

    // Leopard has an optimized call for the tiling of image patterns, but we can only use it if the image has been decoded enough that
    // its buffer is the same size as the overall image.  Because a partially decoded CGImageRef with a smaller width or height than the
    // overall image buffer needs to tile with "gaps", we can't use the optimized tiling call in that case.
    // FIXME: We cannot use CGContextDrawTiledImage with scaled tiles on Leopard, because it suffers from rounding errors.  Snow Leopard is ok.
    float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
    float w = CGImageGetWidth(tileImage);
    if (w == size().width() && h == size().height() && !spaceSize().width() && !spaceSize().height())
        CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get());
    else {
        // On Leopard and newer, this code now only runs for partially decoded images whose buffers do not yet match the overall size of the image.
        static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, patternReleaseCallback };
        CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY);
        matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
        // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
        matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h);
#if PLATFORM(IOS)
        matrix = CGAffineTransformScale(matrix, 1, -1);
        matrix = CGAffineTransformTranslate(matrix, 0, -h);
#endif
        CGImageRef platformImage = CGImageRetain(subImage.get());
        RetainPtr<CGPatternRef> pattern = adoptCF(CGPatternCreate(platformImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()), matrix,
            tileRect.width() + spaceSize().width() * (1 / narrowPrecisionToFloat(patternTransform.a())),
            tileRect.height() + spaceSize().height() * (1 / narrowPrecisionToFloat(patternTransform.d())),
            kCGPatternTilingConstantSpacing, true, &patternCallbacks));
        
        if (!pattern)
            return;

        RetainPtr<CGColorSpaceRef> patternSpace = adoptCF(CGColorSpaceCreatePattern(0));

        CGFloat alpha = 1;
        RetainPtr<CGColorRef> color = adoptCF(CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha));
        CGContextSetFillColorSpace(context, patternSpace.get());

        // FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
        wkSetBaseCTM(context, CGAffineTransformIdentity);
        CGContextSetPatternPhase(context, CGSizeZero);

        CGContextSetFillColorWithColor(context, color.get());
        CGContextFillRect(context, CGContextGetClipBoundingBox(context));
    }

    stateSaver.restore();

    if (imageObserver())
        imageObserver()->didDraw(this);
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:87,代码来源:ImageCG.cpp


示例16: getNumberOfOutputBands

bool rspfGeneralRasterTileSource::getTile(rspfImageData* result,
                                           rspf_uint32 resLevel)
{
   bool status = false;
   
   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel)  &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);
      if (status)
      {
         if(getOutputScalarType() == RSPF_USHORT11)
         {
            //---
            // Temp fix:
            // The overview handler could return a tile of RSPF_UINT16 if
            // the max sample value was not set to 2047.
            //---
            result->setScalarType(RSPF_USHORT11);
         }
      }
      
      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         //---
         // Subtract any sub image offset to get the zero based image space
         // rectangle.
         //---
         rspfIrect tile_rect = result->getImageRectangle();
         
         // This should be the zero base image rectangle for this res level.
         rspfIrect image_rect = getImageRectangle(resLevel);
         
         //---
         // See if any point of the requested tile is in the image.
         //---
         if ( tile_rect.intersects(image_rect) )
         {
            // Make the tile rectangle zero base.
            result->setImageRectangle(tile_rect);

            // Initialize the tile if needed as we're going to stuff it.
            if (result->getDataObjectStatus() == RSPF_NULL)
            {
               result->initialize();
            }

            rspfIrect clip_rect = tile_rect.clipToRect(image_rect);

            if ( ! tile_rect.completely_within(m_bufferRect) )
            {
               // A new buffer must be loaded.
               if ( !tile_rect.completely_within(clip_rect) )
               {
                  //---
                  // Start with a blank tile since the whole tile buffer will
                  // not be
                  // filled.
                  //---
                  result->makeBlank();
               }

               // Reallocate the buffer if needed.
               if ( m_bufferSizeInPixels != result->getSize() )
               {
                  allocateBuffer( result );
               }

               rspfIpt size(static_cast<rspf_int32>(result->getWidth()),
                             static_cast<rspf_int32>(result->getHeight()));

               if( !fillBuffer(clip_rect.ul(), size) )
               {
                  rspfNotify(rspfNotifyLevel_WARN)
                     << "Error from fill buffer..."
                     << std::endl;
                  //---
                  // Error in filling buffer.
                  //---
                  setErrorStatus();
                  status = false;
               }
            }
            
            result->loadTile(m_buffer,
                             m_bufferRect,
                             clip_rect,
                             m_bufferInterleave);
            result->validate();
//.........这里部分代码省略.........
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:101,代码来源:rspfGeneralRasterTileSource.cpp


示例17: ScriptPlace

bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const SimpleFontData* fontData, GlyphBuffer* glyphBuffer)
{
    // Determine the string for this item.
    const UChar* str = cp + m_items[i].iCharPos;
    int len = m_items[i+1].iCharPos - m_items[i].iCharPos;
    SCRIPT_ITEM item = m_items[i];

    // Set up buffers to hold the results of shaping the item.
    Vector<WORD> glyphs;
    Vector<WORD> clusters;
    Vector<SCRIPT_VISATTR> visualAttributes;
    clusters.resize(len);
     
    // Shape the item.
    // The recommended size for the glyph buffer is 1.5 * the character length + 16 in the uniscribe docs.
    // Apparently this is a good size to avoid having to make repeated calls to ScriptShape.
    glyphs.resize(1.5 * len + 16);
    visualAttributes.resize(glyphs.size());

    if (!shape(str, len, item, fontData, glyphs, clusters, visualAttributes))
        return true;

    // We now have a collection of glyphs.
    Vector<GOFFSET> offsets;
    Vector<int> advances;
    offsets.resize(glyphs.size());
    advances.resize(glyphs.size());
    int glyphCount = 0;
    HRESULT placeResult = ScriptPlace(0, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(),
                                      &item.a, advances.data(), offsets.data(), 0);
    if (placeResult == E_PENDING) {
        // The script cache isn't primed with enough info yet.  We need to select our HFONT into
        // a DC and pass the DC in to ScriptPlace.
        HWndDC hdc(0);
        HFONT hfont = fontData->platformData().hfont();
        HFONT oldFont = (HFONT)SelectObject(hdc, hfont);
        placeResult = ScriptPlace(hdc, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(),
                                  &item.a, advances.data(), offsets.data(), 0);
        SelectObject(hdc, oldFont);
    }
    
    if (FAILED(placeResult) || glyphs.isEmpty())
        return true;

    // Convert all chars that should be treated as spaces to use the space glyph.
    // We also create a map that allows us to quickly go from space glyphs back to their corresponding characters.
    Vector<int> spaceCharacters(glyphs.size());
    spaceCharacters.fill(-1);

    const float cLogicalScale = fontData->platformData().useGDI() ? 1.0f : 32.0f;
    float spaceWidth = fontData->spaceWidth() - fontData->syntheticBoldOffset();
    unsigned logicalSpaceWidth = spaceWidth * cLogicalScale;

    for (int k = 0; k < len; k++) {
        UChar ch = *(str + k);
        bool treatAsSpace = Font::treatAsSpace(ch);
        bool treatAsZeroWidthSpace = Font::treatAsZeroWidthSpace(ch);
        if (treatAsSpace || treatAsZeroWidthSpace) {
            // Substitute in the space glyph at the appropriate place in the glyphs
            // array.
            glyphs[clusters[k]] = fontData->spaceGlyph();
            advances[clusters[k]] = treatAsSpace ? logicalSpaceWidth : 0;
            if (treatAsSpace)
                spaceCharacters[clusters[k]] = m_currentCharacter + k + item.iCharPos;
        }
    }

    // Populate our glyph buffer with this information.
    bool hasExtraSpacing = m_font.letterSpacing() || m_font.wordSpacing() || m_padding;
    
    float leftEdge = m_runWidthSoFar;

    for (unsigned k = 0; k < glyphs.size(); k++) {
        Glyph glyph = glyphs[k];
        float advance = advances[k] / cLogicalScale;
        float offsetX = offsets[k].du / cLogicalScale;
        float offsetY = offsets[k].dv / cLogicalScale;

        // Match AppKit's rules for the integer vs. non-integer rendering modes.
        float roundedAdvance = roundf(advance);
        if (!m_font.isPrinterFont() && !fontData->isSystemFont()) {
            advance = roundedAdvance;
            offsetX = roundf(offsetX);
            offsetY = roundf(offsetY);
        }

        advance += fontData->syntheticBoldOffset();

        if (hasExtraSpacing) {
            // If we're a glyph with an advance, go ahead and add in letter-spacing.
            // That way we weed out zero width lurkers.  This behavior matches the fast text code path.
            if (advance && m_font.letterSpacing())
                advance += m_font.letterSpacing();

            // Handle justification and word-spacing.
            int characterIndex = spaceCharacters[k];
            // characterIndex is left at the initial value of -1 for glyphs that do not map back to treated-as-space characters.
            if (characterIndex != -1) {
                // Account for padding. WebCore uses space padding to justify text.
                // We distribute the specified padding over the available spaces in the run.
//.........这里部分代码省略.........
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:101,代码来源:UniscribeController.cpp


示例18: AddHealthPackage

	void ManagerModel::OnUpdate(const float dt) {
		//Exit if score is over rhs.
		if (GetScore() >= maxScore) {
			mWonRound = true;
		}

		//Add health package if time delta is right
		timerHealthPackage -= dt;
		if (timerHealthPackage <= 0) {
			timerHealthPackage = timePeriodSpawnHealtPackage;
			AddHealthPackage();
		}

		//Collision
		ColissionWall();
		auto collisions = CollisionEntities();
		if (collisions.size() > 0) {
			ProcessCollisions(collisions);
		}

		for (Entity *e : mEntities) {
			e->OnUpdate();
			if (e->Type() == ENTITY_PLAYER) {
				for (auto view : mViews) {
					bool btnIsPressed = view->OnPlayerUpdatedAnimation((Player*)e);
					((Player*)e)->OnUpdateAnimation(btnIsPressed, dt);

					((Player*)e)->OnUpdatePhysics(dt);
					view->OnPlayerUpdatedPhysics((Player*)e);

					SetHealth(((Player*)e)->mHealth);
				}
			} else if (e->Type() == ENTITY_BULLET) {
				for (auto view : mViews) {
					((Shot*)e)->OnUpdatedPhysics(dt);
					view->OnShotUpdatePhysics((Shot*)e);
				}
			} else if (e->Type() == ENTITY_ASTEROID) {
				for (auto view : mViews) {
					((Asteroid*)e)->OnUpdateAnimation(dt);
					view->OnAsteroidUpdatedAnimation(((Asteroid*)e));

					((Asteroid*)e)->OnUpdatePhysics(dt);
					view->OnAsteroidUpdatedPhysics((Asteroid*)e);
				}
			} else if (e->Type() == ENTITY_EXPLOSION) {
				for (auto view : mViews) {
					((Explosion*)e)->OnUpdateAnimation(dt);
					view->OnExplosionUpdateAnimation((Explosion*)e);
				}
			} else if (e->Type() == ENTITY_HEALTHPACKAGE) {
				for (auto view : mViews) {
					((HealthPackage*)e)->OnUpdatePhysics(dt);
					view->OnHealthPackageUpdatedPhysics((HealthPackage*)e);
				}
			} else if (e->Type() == ENTITY_ENEMIEBOSS) {
				for (auto *view : mViews) {
					((EnemieBoss*)e)->OnUpdateAnimation(dt, DelayEnemieBossMove(((EnemieBoss*)e), dt));
					view->OnEnemieBossUpdatedAnimation((EnemieBoss*)e);

					((EnemieBoss*)e)->OnUpdatePhysics(dt);
					view->OnEnemieBossUpdatedPhysics((EnemieBoss*)e);
				}
			} else if (e->Type() == ENTITY_BULLETENEMIEBOSS) {
				for (auto view : mViews) {
					((EnemieBossShot*)e)->OnUpdatedPhysics(dt);
					view->OnEnemieBossShotUpdatePhysics((EnemieBossShot*)e);
				}
			}
		}

		EvalRequestNewBullet(dt);
		RemoveDeadExplosion();
	}
开发者ID:syvjohan,项目名称:Games,代码行数:74,代码来源:ManagerModel.cpp


示例19: name64

void KernelExplorer::Update()
{
	m_tree->DeleteAllItems();
	const u32 total_memory_usage = vm::get(vm::user_space)->used.load();

	const auto& root = m_tree->AddRoot(fmt::format("Process, ID = 0x00000001, Total Memory Usage = 0x%x (%0.2f MB)", total_memory_usage, (float)total_memory_usage / (1024 * 1024)));

	union name64
	{
		u64 u64_data;
		char string[8];

		name64(u64 data)
			: u64_data(data & 0x00ffffffffffffffull)
		{
		}

		const char* operator &() const
		{
			return string;
		}
	};

	// TODO: FileSystem

	// Semaphores
	const auto sema_map = idm::get_map<lv2_sema_t>();

	if (sema_map.size())
	{
		const auto& node = m_tree->AppendItem(root, fmt::format("Semaphores (%zu)", sema_map.size()));

		for (const auto& data : sema_map)
		{
			const auto& sema = *data.second;

			m_tree->AppendItem(node, fmt::format("Semaphore: ID = 0x%08x '%s', Count = %d, Max Count = %d, Waiters = %#zu", data.first,
				&name64(sema.name), sema.value.load(), sema.max, sema.sq.size()));
		}
	}

	// Mutexes
	const auto mutex_map = idm::get_map<lv2_mutex_t>();

	if (mutex_map.size())
	{
		const auto& node = m_tree->AppendItem(root, fmt::format("Mutexes (%zu)", mutex_map.size()));

		for (const auto& data : mutex_map)
		{
			const auto& mutex = *data.second;

			m_tree->AppendItem(node, fmt::format("Mutex: ID = 0x%08x '%s'", data.first,
				&name64(mutex.name)));
		}
	}

	// Lightweight Mutexes
	const auto lwm_map = idm::get_map<lv2_lwmutex_t>();

	if (lwm_map.size())
	{
		const auto& node = m_tree->AppendItem(root, fmt::format("Lightweight Mutexes (%zu)", lwm_map.size()));

		for (const auto& data : lwm_map)
		{
			const auto& lwm = *data.second;

			m_tree->AppendItem(node, fmt::format("LWMutex: ID = 0x%08x '%s'", data.first,
				&name64(lwm.name)));
		}
	}

	// Condition Variables
	const auto cond_map = idm::get_map<lv2_cond_t>();

	if (cond_map.size())
	{
		const auto& node = m_tree->AppendItem(root, fmt::format("Condition Variables (%zu)", cond_map.size()));

		for (const auto& data : cond_map)
		{
			const auto& cond = *data.second;

			m_tree->AppendItem(node, fmt::format("Cond: ID = 0x%08x '%s'", data.first,
				&name64(cond.name)));
		}
	}

	// Lightweight Condition Variables
	const auto lwc_map = idm::get_map<lv2_lwcond_t>();

	if (lwc_map.size())
	{
		const auto& node = m_tree->AppendItem(root, fmt::format("Lightweight Condition Variables (%zu)", lwc_map.size()));

		for (const auto& data : lwc_map)
		{
			const auto& lwc = *data.second;

//.........这里部分代码省略.........
开发者ID:Bigpet,项目名称:rpcs3,代码行数:101,代码来源:KernelExplorer.cpp


示例20: assert

bool Scenes::Menu::initialize()
{
	Shader.reset(new PMX::PMXShader);
	assert(Shader);
	if (!Shader->InitializeBuffers(Renderer->GetDevice(), nullptr))
		return false;
	Shader->SetLightCount(1);
	Shader->SetLights(DirectX::XMVectorSplatOne(), DirectX::XMVectorSplatOne(), DirectX::XMVectorSplatOne(), DirectX::XMVectorSet(-1.0f, -1.0f, 1.0f, 0.0f), DirectX::XMVectorZero(), 0);

	auto &Viewport = Renderer->getViewport();
	Camera.reset(new Renderer::Camera(DirectX::XM_PIDIV4, (float)Viewport.Width / (float)Viewport.Height, Renderer::SCREEN_NEAR, Renderer::SCREEN_DEPTH));
	assert(Camera);
	Camera->SetPosition(0, 10.0f, 0.0f);

	Frustum.reset(new Renderer::ViewFrustum);
	assert(Frustum);

	// Create a list of motions to be used as idle animations
	fs::directory_iterator EndIterator;
	fs::path MotionPath(L"./Data/Motions/Idle/");
	for (fs::directory_iterator Entry(MotionPath); Entry != EndIterator; Entry++) {
		if (fs::is_regular_file(Entry->status()) && Entry->path().extension().wstring().compare(L".vmd") == 0) {
			KnownMotions.emplace_back(Entry->path().generic_wstring());
		}
	}

	DirectX::XMMATRIX View, Projection;
	Camera->setFocalDistance(-35.0f);
	Camera->update(0.0f);
	Camera->getViewMatrix(View);
	Camera->getProjectionMatrix(Projection);

	Frustum->Construct(Renderer::SCREEN_DEPTH, Projection, View);

	Shader->SetEyePosition(Camera->GetPosition());
	Shader->SetMatrices(DirectX::XMMatrixIdentity(), View, Projection);

	// Initializes the model
	// Pause the physics environment, to prevent resource race
	Physics->pause();
	// Select a model to be displayed
#if 1
	auto ModelList = ModelHandler->getKnownModels();
	do {
		size_t Index = RandomGenerator() % ModelList.size();
		for (auto &ModelPath : ModelList) {
			if (Index-- == 0) {
				Model = ModelHandler->loadModel(ModelPath.first, Physics);
				ModelList.erase(ModelPath.first);
				break;
			}
		}
	} while (!Model);
#else
	Model = ModelHandler->loadModel(L"Tda式改変WIMミク ver.2.9", Physics);
	Model->SetDebugFlags(PMX::Model::DebugFlags::RenderBones);
#endif
	Model->SetShader(Shader);

	if (!Model->Initialize(Renderer, Physics))
		return false;
	Physics->resume();

	return true;
}
开发者ID:shirayukikitsune,项目名称:xbeat,代码行数:65,代码来源:MenuScene.cpp



注:本文中的size函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sizeCclosure函数代码示例发布时间:2022-05-30
下一篇:
C++ sit函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap