void ImagePaintEngine::drawPreTransformedPolygons(const FixedMultiPolygon &polygons) { agg::rasterizer_scanline_aa<> ras; for (const FixedPolygon &polygon : polygons) { if (polygon.size() < 3) continue; auto i = polygon.begin(); ras.move_to(i->x, i->y); ++i; for (; i != polygon.end(); ++i) ras.line_to(i->x, i->y); } BlendOp *op = BlendMode(state()->blendMode).op(); switch (state()->brush.spreadType()) { case Malachite::SpreadTypePad: drawWithSpreadType<agg::rasterizer_scanline_aa<>, Malachite::SpreadTypePad>(&ras, &_bitmap, op, *state()); return; case Malachite::SpreadTypeRepeat: drawWithSpreadType<agg::rasterizer_scanline_aa<>, Malachite::SpreadTypeRepeat>(&ras, &_bitmap, op, *state()); return; case Malachite::SpreadTypeReflective: drawWithSpreadType<agg::rasterizer_scanline_aa<>, Malachite::SpreadTypeReflective>(&ras, &_bitmap, op, *state()); return; default: return; } }
bool Init( int width, int height ) { mSize = Point( width, height ); mDecl = new VertexDeclaration( ); mDecl->AddElement( VertexElement( 0, VDeclSemantic::POSITION, VDeclType::FLOAT3, 0 ) ); mDecl->AddElement( VertexElement( 0, VDeclSemantic::TEXCOORD, VDeclType::FLOAT2, 0 ) ); mDecl->AddElement( VertexElement( 0, VDeclSemantic::COLOUR, VDeclType::COLOUR, 0 ) ); mMat[0] = new Material( ); mMat[0]->mAlphaBlend = true; mMat[0]->mAlphaTest = true; mMat[0]->mDepthWrite = true; mMat[0]->mDepthBuffer = false; mMat[0]->AddTextureStage( TextureStage( 0, BlendMode( BlendOp::MODULATE, BlendArg::TEXTURE, BlendArg::DIFFUSE ), BlendMode( BlendOp::SELECTARGUMENT1, BlendArg::TEXTURE ) ) ); mMat[1] = new Material( ); mMat[1]->mAlphaBlend = true; mMat[1]->mAlphaTest = false; mMat[1]->mDepthWrite = true; mMat[1]->mDepthBuffer = false; mMat[1]->AddTextureStage( TextureStage( 0, BlendMode( BlendOp::SELECTARGUMENT1, BlendArg::DIFFUSE ), BlendMode( BlendOp::SELECTARGUMENT1, BlendArg::TEXTURE ) ) ); mDefaultFont = new Halia::Font( ); mDefaultFont->Init( "Tahoma", 16 ); return true; };
void fastuidraw::gl::detail::PainterBackendGL::DrawCommand:: add_entry(unsigned int indices_written) { unsigned int count; const PainterIndex *offset(nullptr); if (m_draws.empty()) { m_draws.push_back(BlendMode()); } FASTUIDRAWassert(indices_written >= m_indices_written); count = indices_written - m_indices_written; offset += m_indices_written; m_draws.back().add_entry(count, offset); m_indices_written = indices_written; }
void IRenderNode::setRenderOption( RenderOption option , DWORD val ) { switch ( option ) { case CFRO_Z_TEST : val = ( val ) ? D3DZB_TRUE : D3DZB_FALSE; break; case CFRO_ZBIAS : { float bias = 0.1f * val; val = *((DWORD*)&bias); } break; case CFRO_SRC_BLEND : case CFRO_DEST_BLEND : val = D3DTypeMapping::convert( BlendMode(val) ); break; case CFRO_ALPHA_BLENGING : if ( val ) addFlag( NODE_TRANSLUCENT_OBJ ); else removeFlag( NODE_TRANSLUCENT_OBJ ); break; case CFRO_CULL_FACE: val = D3DTypeMapping::convert( CullFace( val ) ); break; case CFRO_Z_BUFFER_WRITE : case CFRO_LIGHTING : case CFRO_FOG : break; default: assert(0); } if ( D3DTypeMapping::getDefaultValue( option ) == val ) mUsageRenderOption &= ~ BIT( option ); else mUsageRenderOption |= BIT( option ); mRenderOption[ option ] = val; }
void ImagePaintEngine::drawPreTransformedImage(const QPoint &point, const Image &image, const QRect &imageMaskRect) { QRect dstRect = _image->rect(); QRect srcRect = (image.rect() & imageMaskRect).translated(point); QRect targetRect = dstRect & srcRect; if (targetRect.isEmpty()) return; BlendOp *op = BlendMode(state()->blendMode).op(); if (!op) return; for (int y = targetRect.top(); y <= targetRect.bottom(); ++y) { QPoint p(targetRect.left(), y); if (state()->opacity == 1.0) op->blend(targetRect.width(), _bitmap.pixelPointer(p), image.constPixelPointer(p - point)); else op->blend(targetRect.width(), _bitmap.pixelPointer(p), image.constPixelPointer(p - point), state()->opacity); } }
bool DX9RenderSystem::Init( HWND hwnd, int width, int height, bool fullscreen, int msquality ) { mSize.x = width; mSize.y = height; mD3d = Direct3DCreate9( D3D_SDK_VERSION ); D3DPRESENT_PARAMETERS pp = { 0 }; pp.SwapEffect = D3DSWAPEFFECT_DISCARD; pp.EnableAutoDepthStencil = TRUE; pp.AutoDepthStencilFormat = D3DFMT_D24X8; pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if( msquality >= 0 ) { pp.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; pp.MultiSampleQuality = msquality; } if( fullscreen ) { pp.Windowed = false; pp.BackBufferCount = 1; pp.BackBufferWidth = width; pp.BackBufferHeight = height; pp.BackBufferFormat = D3DFMT_X8R8G8B8; } else { D3DDISPLAYMODE currentmode; if( FAILED(mD3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, ¤tmode )) ) return false; // Set up windowed formatting pp.Windowed = true; pp.BackBufferCount = 1; pp.BackBufferFormat = currentmode.Format; } UINT adapterid = D3DADAPTER_DEFAULT; D3DDEVTYPE rendertype = D3DDEVTYPE_HAL; int adaptercount = (int)mD3d->GetAdapterCount( ); for( int i = 0; i < adaptercount; i++ ) { D3DADAPTER_IDENTIFIER9 info; mD3d->GetAdapterIdentifier( i, 0, &info ); if( strstr( info.Description, "PerfHUD" ) ) { adapterid = i; rendertype = D3DDEVTYPE_REF; printf( "PerfHUD found on adapter %d (%s)\n", i, info.Description ); } } if( FAILED(mD3d->CreateDevice( adapterid, rendertype, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &mDevice )) ) return false; for( int i = 0; i < 8; i++ ) mDevice->SetSamplerState( i, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC ); // Initialize 2d Rendering Stuff m2dDecl = new VertexDeclaration( ); m2dDecl->AddElement( VertexElement( 0, VDeclSemantic::POSITION, VDeclType::FLOAT3, 0 ) ); m2dDecl->AddElement( VertexElement( 0, VDeclSemantic::TEXCOORD, VDeclType::FLOAT2, 0 ) ); m2dDecl->AddElement( VertexElement( 0, VDeclSemantic::COLOUR, VDeclType::COLOUR, 0 ) ); m2dMat = new Material( ); m2dMat->mAlphaBlend = true; m2dMat->mAlphaTest = true; m2dMat->mDepthWrite = true; m2dMat->mDepthBuffer = false; m2dMat->AddTextureStage( TextureStage( 0, BlendMode( BlendOp::SELECTARGUMENT1, BlendArg::TEXTURE, BlendArg::DIFFUSE ), BlendMode( BlendOp::SELECTARGUMENT1, BlendArg::TEXTURE, BlendArg::DIFFUSE ) ) ); return true; };