int poor_stretched_font_rep::index_glyph (string s, font_metric& fnm, font_glyphs& fng) { int c= base->index_glyph (s, fnm, fng); if (c < 0) return c; fnm= stretched (fnm, 1.0, factor); fng= stretched (fng, 1.0, factor); return c; }
const Quad& Quad::drawFrame(double innerThickness, double outerThickness, const ColorF& color) const { const double offset = (outerThickness - innerThickness) * 0.5; const Quad t = stretched(offset); Siv3DEngine::GetRenderer2D()->addLineString(LineStyle::SquareCap, &t.p0, 4, none, static_cast<float>(innerThickness + outerThickness), outerThickness == 0.0, color.toFloat4(), true); return *this; }
void TracingThread::run() { if( !manual_seed ) { seeds.RemoveAllPts(); seeds.AddPt(IM->SeedPt.Pt[current_seed_index]); } if( stopped ) return; if( seeds.NP == 0 ) { emit_traced_signal(true); return; } if( !options.parallel_tracing ) { //SnakeClass *snake; //snake = new SnakeClass; temp_snake.Set_Seed_Point(seeds); temp_snake.BranchPt.RemoveAllPts(); temp_snake.SetImage(IM); temp_snake.SetTracedSnakes(Snakes); temp_snake.collision = 0; //seed expansion for initializing the tracing if( temp_snake.Cu.GetSize() < 3 ) { temp_snake.Expand_Seed_Point(3); } else { temp_snake.Cu.curveinterp_3D(options.pt_distance); //initialize the radius temp_snake.Ru.clear(); for( int j = 0; j < temp_snake.Cu.GetSize(); j++ ) { temp_snake.Cu.Pt[j].Print(); temp_snake.Ru.push_back(1); } } int i = 0; int struggle_label = 0; bool invalid = false; ImageType::IndexType idx; idx[0] = temp_snake.Cu.GetMiddlePt().x; idx[1] = temp_snake.Cu.GetMiddlePt().y; idx[2] = temp_snake.Cu.GetMiddlePt().z; //initialize the radius temp_snake.Ru.clear(); temp_snake.Ru1.clear(); for( int j = 0; j < temp_snake.Cu.GetSize(); j++ ) { temp_snake.Ru.push_back(2); //temp_snake.Ru1.push_back(2); } if( options.tracing_model == 3 ) { for( int j = 0; j < temp_snake.Cu.GetSize(); j++ ) { temp_snake.Ru1.push_back(2); } } while( i < options.iter_num && struggle_label <= options.struggle_th && !temp_snake.hit_boundary ) { float old_dist = temp_snake.Cu.GetLength(); if( options.tracing_model == 3 ) temp_snake.OpenSnakeStretch_5D( options.alpha, options.stretch_iter, options.pt_distance, options.beta, options.kappa, options.gamma, options.stretchingRatio, options.collision_dist, options.minimum_length, options.automatic_merging, options.max_angle, options.freeze_body, options.s_force, 0, options.tracing_model, options.coding_method, options.sigma_ratio, options.border); else temp_snake.OpenSnakeStretch_4D( options.alpha, options.stretch_iter, options.pt_distance, options.beta, options.kappa, options.gamma, options.stretchingRatio, options.collision_dist, options.minimum_length, options.automatic_merging, options.max_angle, options.freeze_body, options.s_force, 0, options.tracing_model, options.coding_method, options.sigma_ratio, options.border); if( temp_snake.Cu.NP < 3 ) { invalid = true; break; } float new_dist = temp_snake.Cu.GetLength(); if( new_dist > old_dist * ( 1 - options.struggle_dist ) && new_dist < old_dist * ( 1 + options.struggle_dist ) ) struggle_label++; else struggle_label = 0; if( temp_snake.Cu.GetLength() > options.minimum_length ) { IM->ImCoding( temp_snake.Cu, temp_snake.Ru, 1, true ); } i++; emit stretched(temp_snake); if(ToSuspend) { mutex.lock(); condition.wait(&mutex); mutex.unlock(); } } if( !invalid ) { if( manual_seed ) { if( temp_snake.Cu.GetLength() > options.minimum_length ) { if( temp_snake.BranchPt.NP != 0 ) Snakes->branch_points.AddPtList(temp_snake.BranchPt); temp_snake.Nail_Branch(); Snakes->AddSnake_Coding(temp_snake); IM->ImRefresh_TracingImage(); IM->ImComputeForegroundModel(temp_snake.Cu, temp_snake.Ru); } else { invalid = true; } } else { if( temp_snake.Check_Validity( options.minimum_length, 0, options.automatic_merging ) ) { if( temp_snake.BranchPt.NP != 0 ) Snakes->branch_points.AddPtList(temp_snake.BranchPt); temp_snake.Nail_Branch(); Snakes->AddSnake_Coding(temp_snake); IM->ImRefresh_TracingImage(); IM->ImComputeForegroundModel(temp_snake.Cu, temp_snake.Ru); } else { invalid = true; } } } if( !manual_seed ) { //IM->visit_label[IM->current_seed_idx] = 1; IM->visit_label[current_seed_index] = 1; } //emit snakeTraced(Snakes); if( invalid ) emit_traced_signal(false); else emit_traced_signal(true); } else //Parallel Tracing { } }
// creates a new texture that is the input texture scaled up. If optionalKey is valid it will be // set on the new texture. stretch controls whether the scaling is done using nearest or bilerp // filtering and the size to stretch the texture to. GrTexture* stretch_texture(GrTexture* inputTexture, const SkGrStretch& stretch, SkPixelRef* pixelRef, const GrUniqueKey& optionalKey) { SkASSERT(SkGrStretch::kNone_Type != stretch.fType); GrContext* context = inputTexture->getContext(); SkASSERT(context); const GrCaps* caps = context->caps(); // Either it's a cache miss or the original wasn't cached to begin with. GrSurfaceDesc rtDesc = inputTexture->desc(); rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; rtDesc.fWidth = stretch.fWidth; rtDesc.fHeight = stretch.fHeight; rtDesc.fConfig = GrMakePixelConfigUncompressed(rtDesc.fConfig); // If the config isn't renderable try converting to either A8 or an 32 bit config. Otherwise, // fail. if (!caps->isConfigRenderable(rtDesc.fConfig, false)) { if (GrPixelConfigIsAlphaOnly(rtDesc.fConfig)) { if (caps->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { rtDesc.fConfig = kAlpha_8_GrPixelConfig; } else if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) { rtDesc.fConfig = kSkia8888_GrPixelConfig; } else { return nullptr; } } else if (kRGB_GrColorComponentFlags == (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(rtDesc.fConfig))) { if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) { rtDesc.fConfig = kSkia8888_GrPixelConfig; } else { return nullptr; } } else { return nullptr; } } SkAutoTUnref<GrTexture> stretched(GrCreateTextureForPixels(context, optionalKey, rtDesc, pixelRef, nullptr,0)); if (!stretched) { return nullptr; } GrPaint paint; // If filtering is not desired then we want to ensure all texels in the resampled image are // copies of texels from the original. GrTextureParams params(SkShader::kClamp_TileMode, SkGrStretch::kBilerp_Type == stretch.fType ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_FilterMode); paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params); SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight)); SkRect localRect = SkRect::MakeWH(1.f, 1.f); SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); if (!drawContext) { return nullptr; } drawContext->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect, localRect); return stretched.detach(); }
glyph poor_stretched_font_rep::get_glyph (string s) { glyph gl= base->get_glyph (s); return stretched (gl, 1.0, factor); }