本文整理汇总了C++中Compositor类的典型用法代码示例。如果您正苦于以下问题:C++ Compositor类的具体用法?C++ Compositor怎么用?C++ Compositor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Compositor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddVisual
void AddVisual(Point point)
{
Compositor compositor = m_visuals.Compositor();
SolidColorVisual visual = compositor.CreateSolidColorVisual();
static Color colors[] =
{
{ 0xDC, 0x5B, 0x9B, 0xD5 },
{ 0xDC, 0xED, 0x7D, 0x31 },
{ 0xDC, 0x70, 0xAD, 0x47 },
{ 0xDC, 0xFF, 0xC0, 0x00 }
};
static unsigned last = 0;
unsigned next = ++last % _countof(colors);
visual.Color(colors[next]);
visual.Size(Vector2
{
BlockSize,
BlockSize
});
visual.Offset(Vector3
{
point.X - BlockSize / 2.0f,
point.Y - BlockSize / 2.0f,
});
m_visuals.InsertAtTop(visual);
}
示例2: setOutputGeometry
void Compositor::setOutputGeometry(void *c, const QList<QVariant> ¶meters)
{
Compositor *compositor = static_cast<Compositor *>(c);
compositor->m_outputGeometry = parameters.first().toRect();
wl_resource *resource;
wl_list_for_each(resource, &compositor->m_outputResources, link)
compositor->sendOutputGeometry(resource);
}
示例3: if
void Parser::parseCompositor( ParserContext *context,
const QDomElement &element, ComplexType &ct )
{
QName name = element.tagName();
bool isChoice = name.localName() == "choice";
bool isSequence = name.localName() == "sequence";
Compositor compositor;
if ( isChoice ) compositor.setType( Compositor::Choice );
else if ( isSequence ) compositor.setType( Compositor::Sequence );
if ( isChoice || isSequence ) {
Element::List newElements;
QDomElement childElement = element.firstChildElement();
while ( !childElement.isNull() ) {
QName csName = childElement.tagName();
if ( csName.localName() == "element" ) {
Element newElement;
if ( isChoice ) {
newElement = parseElement( context, childElement,
ct.nameSpace(), element );
} else {
if ( isSequence ) {
// occurence attributes can be either in the
// parent (sequence) to on the current element
if ( childElement.hasAttribute("minOccurs") ||
childElement.hasAttribute("maxOccurs")) {
newElement = parseElement( context, childElement,
ct.nameSpace(), childElement );
} else {
newElement = parseElement( context, childElement,
ct.nameSpace(), element );
}
} else {
newElement = parseElement( context, childElement,
ct.nameSpace(), childElement );
}
}
newElements.append( newElement );
compositor.addChild( csName );
} else if ( csName.localName() == "any" ) {
addAny( context, childElement, ct );
} else if ( isChoice ) {
parseCompositor( context, childElement, ct );
} else if ( isSequence ) {
parseCompositor( context, childElement, ct );
}
childElement = childElement.nextSiblingElement();
}
foreach( Element e, newElements ) {
e.setCompositor( compositor );
ct.addElement( e );
}
示例4: get_compositor
void Label::set_font(const char* filename, size_t pixel_size)
{
Compositor* compositor = get_compositor();
font_handle = compositor->get_resource_cache()->create_font(filename, pixel_size);
// cache font_height
size_t height;
int ascender, descender;
compositor->get_renderer()->font_metrics(font_handle, height, ascender, descender);
font_height = static_cast<int32_t>(ascender + descender);
}
示例5: Q_UNUSED
void Compositor::bindOutput(wl_client *client, void *compositorData, uint32_t version, uint32_t id)
{
Q_UNUSED(version);
wl_resource *resource = wl_client_add_object(client, &wl_output_interface, 0, id, compositorData);
Compositor *compositor = static_cast<Compositor *>(compositorData);
registerResource(&compositor->m_outputResources, resource);
compositor->sendOutputGeometry(resource);
compositor->sendOutputMode(resource);
}
示例6: Interface
ClipboardManager::ClipboardManager(Shell *shell)
: Interface(shell)
, Global(shell->compositor(), &orbital_clipboard_manager_interface, 1)
{
Compositor *c = shell->compositor();
for (Seat *s: c->seats()) {
connect(s, &Seat::selection, this, &ClipboardManager::selection);
}
connect(c, &Compositor::seatCreated, [this](Seat *s) {
connect(s, &Seat::selection, this, &ClipboardManager::selection);
});
}
示例7: QObject
Dashboard::Dashboard(Shell *shell)
: QObject(shell)
, m_shell(shell)
, m_visible(true)
{
Compositor *c = shell->compositor();
m_toggleSurfaceBinding = c->createButtonBinding(PointerButton::Middle, KeyboardModifiers::Super);
m_toggleBinding = c->createHotSpotBinding(PointerHotSpot::BottomLeftCorner);
connect(m_toggleSurfaceBinding, &ButtonBinding::triggered, this, &Dashboard::toggleSurface);
connect(m_toggleBinding, &HotSpotBinding::triggered, this, &Dashboard::toggle);
}
示例8: assert
void
ScreenManager::draw(Compositor& compositor)
{
assert(!m_screen_stack.empty());
static Uint32 fps_ticks = SDL_GetTicks();
// draw the actual screen
m_screen_stack.back()->draw(compositor);
// draw effects and hud
auto& context = compositor.make_context(true);
m_menu_manager->draw(context);
if (m_screen_fade)
{
m_screen_fade->draw(context);
}
Console::current()->draw(context);
if (g_config->show_fps)
{
draw_fps(context, m_fps);
}
if (g_config->show_player_pos)
{
draw_player_pos(context);
}
// render everything
compositor.render();
/* Calculate frames per second */
if (g_config->show_fps)
{
static int frame_count = 0;
++frame_count;
if (SDL_GetTicks() - fps_ticks >= 500)
{
m_fps = static_cast<float>(frame_count) / 0.5f;
frame_count = 0;
fps_ticks = SDL_GetTicks();
}
}
}
示例9: DoComposition
int GLWorker::DoComposition(Compositor &compositor, Work *work) {
int ret =
compositor.Composite(work->layers, work->num_layers, work->framebuffer);
int timeline_fd = work->timeline_fd;
work->timeline_fd = -1;
if (ret) {
worker_ret_ = ret;
glFinish();
sw_sync_timeline_inc(timeline_fd, work->num_layers);
close(timeline_fd);
return pthread_cond_signal(&work_done_cond_);
}
unsigned timeline_count = work->num_layers + 1;
worker_ret_ = sw_sync_fence_create(timeline_fd, "GLComposition done fence",
timeline_count);
ret = pthread_cond_signal(&work_done_cond_);
glFinish();
sw_sync_timeline_inc(timeline_fd, timeline_count);
close(timeline_fd);
return ret;
}
示例10: MATH_DEG_TO_RAD
void PostProcessSample::update(float elapsedTime)
{
_modelNode->rotateY(elapsedTime * MATH_DEG_TO_RAD(0.25f));
// Only the last sample will check live updating of material parameters
if (_compositorIndex == _compositors.size() - 1)
{
Compositor* compositor = _compositors[_compositorIndex];
MaterialParameter* elapsedParam = compositor->getMaterial()->getParameter("u_elapsedTime");
if (elapsedParam)
elapsedParam->setValue(elapsedTime);
MaterialParameter* randomParam = compositor->getMaterial()->getParameter("u_random");
if (randomParam)
randomParam->setValue(MATH_RANDOM_0_1());
}
}
示例11: Vector
void
TextScroller::draw(Compositor& compositor)
{
auto& context = compositor.make_context();
context.color().draw_filled_rect(Vector(0, 0), Vector(static_cast<float>(context.get_width()), static_cast<float>(context.get_height())),
Color(0.6f, 0.7f, 0.8f, 0.5f), 0);
context.color().draw_surface_part(background, Rectf(0, 0,
static_cast<float>(background->get_width()),
static_cast<float>(background->get_height())),
Rectf(0, 0,
static_cast<float>(context.get_width()),
static_cast<float>(context.get_height())), 0);
float y = static_cast<float>(context.get_height()) - scroll;
for (auto& line : lines) {
if (y + line->get_height() >= 0 && static_cast<float>(context.get_height()) - y >= 0) {
line->draw(context, Rectf(LEFT_BORDER, y, static_cast<float>(context.get_width()) - 2*LEFT_BORDER, y), LAYER_GUI);
}
y += line->get_height();
}
if(y < 0 && !fading ) {
fading = true;
ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
}
}
示例12: name
void Parser::parseCompositor( ParserContext *context,
const QDomElement &element, ComplexType &ct )
{
const QName name( element.tagName() );
bool isChoice = name.localName() == QLatin1String("choice");
bool isSequence = name.localName() == QLatin1String("sequence");
Compositor compositor;
if ( isChoice ) compositor.setType( Compositor::Choice );
else if ( isSequence ) compositor.setType( Compositor::Sequence );
compositor.setMaxOccurs( readMaxOccurs( element ) );
if ( isChoice || isSequence ) {
Element::List newElements;
QDomElement childElement = element.firstChildElement();
while ( !childElement.isNull() ) {
NSManager namespaceManager( context, childElement );
const QName csName( childElement.tagName() );
if ( csName.localName() == QLatin1String("element") ) {
Element newElement;
if ( isChoice ) {
newElement = parseElement( context, childElement,
ct.nameSpace(), element );
} else {
newElement = parseElement( context, childElement,
ct.nameSpace(), childElement );
}
newElements.append( newElement );
compositor.addChild( csName );
} else if ( csName.localName() == QLatin1String("any") ) {
addAny( context, childElement, ct );
} else if ( isChoice ) {
parseCompositor( context, childElement, ct );
} else if ( isSequence ) {
parseCompositor( context, childElement, ct );
}
childElement = childElement.nextSiblingElement();
}
foreach( Element e, newElements ) {
e.setCompositor( compositor );
ct.addElement( e );
}
示例13: PROFILER_LABEL
void
PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
{
if (!mBuffer || !mBuffer->IsAttached()) {
return;
}
PROFILER_LABEL("PaintedLayerComposite", "RenderLayer",
js::ProfileEntry::Category::GRAPHICS);
Compositor* compositor = mCompositeManager->GetCompositor();
MOZ_ASSERT(mBuffer->GetCompositor() == compositor &&
mBuffer->GetLayer() == this,
"buffer is corrupted");
const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
RefPtr<gfx::DataSourceSurface> surf = mBuffer->GetAsSurface();
if (surf) {
WriteSnapshotToDumpFile(this, surf);
}
}
#endif
RenderWithAllMasks(this, compositor, aClipRect,
[&](EffectChain& effectChain, const Rect& clipRect) {
mBuffer->SetPaintWillResample(MayResample());
mBuffer->Composite(this, effectChain,
GetEffectiveOpacity(),
GetEffectiveTransform(),
GetEffectFilter(),
clipRect,
&visibleRegion);
});
mBuffer->BumpFlashCounter();
compositor->MakeCurrent();
}
示例14: clear
void PostProcessSample::render(float elapsedTime)
{
Rectangle defaultViewport = Game::getInstance()->getViewport();
// Draw into the framebuffer
Game::getInstance()->setViewport(Rectangle(FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT));
FrameBuffer* previousFrameBuffer = _frameBuffer->bind();
clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
_scene->visit(this, &PostProcessSample::drawScene);
// Bind the current compositor
Game::getInstance()->setViewport(defaultViewport);
Compositor* compositor = _compositors[_compositorIndex];
FrameBuffer* compositorDstFrameBuffer = compositor->getDstFrameBuffer();
FrameBuffer* prevToCompositeFrameBuffer = NULL;
if (compositorDstFrameBuffer)
{
prevToCompositeFrameBuffer = compositorDstFrameBuffer->bind();
}
else
{
prevToCompositeFrameBuffer = previousFrameBuffer->bind();
}
Game::getInstance()->clear(CLEAR_COLOR, Vector4(0, 0, 0, 1), 1.0f, 0);
compositor->blit(defaultViewport);
drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
drawTechniqueId(compositor->getTechniqueId());
previousFrameBuffer->bind();
// Draw the pass through compositor at index 0 at quarter of the size and bottom right. dont clear the dest just draw last on top
float quarterWidth = getWidth() / 4;
float quarterHeight = getHeight() / 4;
Rectangle offsetViewport = Rectangle(getWidth() - quarterWidth, 0, quarterWidth, quarterHeight);
Game::getInstance()->setViewport(offsetViewport);
compositor = _compositors[0];
compositor->blit(offsetViewport);
Game::getInstance()->setViewport(defaultViewport);
}
示例15: SetWindow
void SetWindow(CoreWindow const & window)
{
Compositor compositor;
ContainerVisual root = compositor.CreateContainerVisual();
m_target = compositor.CreateTargetForCurrentView();
m_target.Root(root);
m_visuals = root.Children();
window.PointerPressed([&](auto const &, PointerEventArgs const & args)
{
Point point = args.CurrentPoint().Position();
if (args.KeyModifiers() == VirtualKeyModifiers::Control)
{
AddVisual(point);
}
else
{
SelectVisual(point);
}
});
window.PointerMoved([&](auto const &, PointerEventArgs const & args)
{
if (m_selected)
{
Point point = args.CurrentPoint().Position();
m_selected.Offset(Vector3
{
point.X + m_offset.X,
point.Y + m_offset.Y
});
}
});
window.PointerReleased([&](auto const &, auto const &)
{
m_selected = nullptr;
});
}