SearchPatternManager::SearchPatternManager() { setOperator(SearchPatternManager::Or, "|"); setOperator(SearchPatternManager::Any, "*"); setOperator(SearchPatternManager::And, "+"); setOperator(SearchPatternManager::WithOut, "-"); setOperator(SearchPatternManager::WholeWord, "\""); }
virtual void Paint(gfxContext* aContext, Layer* aMaskLayer) { if (IsHidden()) return; AutoSetOperator setOperator(aContext, GetOperator()); PaintColorTo(mColor, GetEffectiveOpacity(), aContext, aMaskLayer); }
void BasicCanvasLayer::PaintWithOpacity(gfxContext* aContext, float aOpacity, Layer* aMaskLayer) { NS_ASSERTION(BasicManager()->InDrawing(), "Can only draw in drawing phase"); if (!mSurface) { NS_WARNING("No valid surface to draw!"); return; } nsRefPtr<gfxPattern> pat = new gfxPattern(mSurface); pat->SetFilter(mFilter); pat->SetExtend(gfxPattern::EXTEND_PAD); gfxMatrix m; if (mNeedsYFlip) { m = aContext->CurrentMatrix(); aContext->Translate(gfxPoint(0.0, mBounds.height)); aContext->Scale(1.0, -1.0); } // If content opaque, then save off current operator and set to source. // This ensures that alpha is not applied even if the source surface // has an alpha channel gfxContext::GraphicsOperator savedOp; if (GetContentFlags() & CONTENT_OPAQUE) { savedOp = aContext->CurrentOperator(); aContext->SetOperator(gfxContext::OPERATOR_SOURCE); } AutoSetOperator setOperator(aContext, GetOperator()); aContext->NewPath(); // No need to snap here; our transform is already set up to snap our rect aContext->Rectangle(gfxRect(0, 0, mBounds.width, mBounds.height)); aContext->SetPattern(pat); FillWithMask(aContext, aOpacity, aMaskLayer); #if defined (MOZ_X11) && defined (MOZ_EGL_XRENDER_COMPOSITE) if (mGLContext && !mForceReadback) { // Wait for X to complete all operations before continuing // Otherwise gl context could get cleared before X is done. mGLContext->WaitNative(); } #endif // Restore surface operator if (GetContentFlags() & CONTENT_OPAQUE) { aContext->SetOperator(savedOp); } if (mNeedsYFlip) { aContext->SetMatrix(m); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ImageCalculator::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setSelectedCellArrayPath1( reader->readDataArrayPath( "SelectedCellArrayPath1", getSelectedCellArrayPath1() ) ); setOperator( reader->readValue( "Operator", getOperator() ) ); setSelectedCellArrayPath2( reader->readDataArrayPath( "SelectedCellArrayPath2", getSelectedCellArrayPath2() ) ); setNewCellArrayName( reader->readString( "NewCellArrayName", getNewCellArrayName() ) ); reader->closeFilterGroup(); }
RuleConditionDynamic::RuleConditionDynamic( Device * deviceLeft, const std::string & memberLeft, Device * deviceRight, const std::string & memberRight, const Operator * op ) { setDevices(deviceLeft,deviceRight); setMemberIdentifiers(memberLeft,memberRight); setOperator(op); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ImageMath::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setSelectedCellArrayPath( reader->readDataArrayPath( "SelectedCellArrayPath", getSelectedCellArrayPath() ) ); setOperator( reader->readValue( "Operator", getOperator() ) ); setValue( reader->readValue( "Value", getValue() ) ); setSaveAsNewArray( reader->readValue( "SaveAsNewArray", getSaveAsNewArray() ) ); setNewCellArrayName( reader->readString( "NewCellArrayName", getNewCellArrayName() ) ); reader->closeFilterGroup(); }
void CopyableCanvasLayer::PaintWithOpacity(gfxContext* aContext, float aOpacity, Layer* aMaskLayer, gfxContext::GraphicsOperator aOperator) { if (!mSurface) { NS_WARNING("No valid surface to draw!"); return; } nsRefPtr<gfxPattern> pat = new gfxPattern(mSurface); pat->SetFilter(mFilter); pat->SetExtend(gfxPattern::EXTEND_PAD); gfxMatrix m; if (mNeedsYFlip) { m = aContext->CurrentMatrix(); aContext->Translate(gfxPoint(0.0, mBounds.height)); aContext->Scale(1.0, -1.0); } // If content opaque, then save off current operator and set to source. // This ensures that alpha is not applied even if the source surface // has an alpha channel gfxContext::GraphicsOperator savedOp; if (GetContentFlags() & CONTENT_OPAQUE) { savedOp = aContext->CurrentOperator(); aContext->SetOperator(gfxContext::OPERATOR_SOURCE); } AutoSetOperator setOperator(aContext, aOperator); aContext->NewPath(); // No need to snap here; our transform is already set up to snap our rect aContext->Rectangle(gfxRect(0, 0, mBounds.width, mBounds.height)); aContext->SetPattern(pat); FillWithMask(aContext, aOpacity, aMaskLayer); // Restore surface operator if (GetContentFlags() & CONTENT_OPAQUE) { aContext->SetOperator(savedOp); } if (mNeedsYFlip) { aContext->SetMatrix(m); } }
bool CSettingDependencyCondition::Deserialize(const TiXmlNode *node) { if (!CSettingConditionItem::Deserialize(node)) return false; const TiXmlElement *elem = node->ToElement(); if (elem == NULL) return false; m_target = SettingDependencyTargetSetting; const char *strTarget = elem->Attribute(SETTING_XML_ATTR_ON); if (strTarget != NULL && !setTarget(strTarget)) { CLog::Log(LOGWARNING, "CSettingDependencyCondition: unknown target \"%s\"", strTarget); return false; } if (m_target != SettingDependencyTargetSetting && m_name.empty()) { CLog::Log(LOGWARNING, "CSettingDependencyCondition: missing name for dependency"); return false; } if (m_target == SettingDependencyTargetSetting) { if (m_setting.empty()) { CLog::Log(LOGWARNING, "CSettingDependencyCondition: missing setting for dependency"); return false; } m_name = m_setting; } m_operator = SettingDependencyOperatorEquals; const char *strOperator = elem->Attribute(SETTING_XML_ATTR_OPERATOR); if (strOperator != NULL && !setOperator(strOperator)) { CLog::Log(LOGWARNING, "CSettingDependencyCondition: unknown operator \"%s\"", strOperator); return false; } return true; }
already_AddRefed<gfxPattern> BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext, float aOpacity, Layer* aMaskLayer) { if (!mContainer) return nullptr; mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory()); nsRefPtr<gfxASurface> surface; AutoLockImage autoLock(mContainer, getter_AddRefs(surface)); Image *image = autoLock.GetImage(); gfxIntSize size = mSize = autoLock.GetSize(); if (!surface || surface->CairoStatus()) { return nullptr; } nsRefPtr<gfxPattern> pat = new gfxPattern(surface); if (!pat) { return nullptr; } pat->SetFilter(mFilter); // The visible region can extend outside the image, so just draw // within the image bounds. if (aContext) { AutoSetOperator setOperator(aContext, GetOperator()); PaintContext(pat, nsIntRegion(nsIntRect(0, 0, size.width, size.height)), aOpacity, aContext, aMaskLayer); GetContainer()->NotifyPaintedImage(image); } return pat.forget(); }
void FilterTime::onClickedAt (QModelIndex idx) { if (!idx.isValid()) return; if (idx.column() == 1) { QString const & filter_item = m_model->data(m_model->index(idx.row(), 0, QModelIndex()), Qt::DisplayRole).toString(); QString const & mod = m_model->data(idx, Qt::DisplayRole).toString(); E_CmpMode const curr = stringToCmpMod(mod); size_t const i = (curr + 1) % e_max_cmpmod_enum_value; E_CmpMode const new_mode = static_cast<E_CmpMode>(i); m_model->setData(idx, QString(cmpModToString(new_mode))); setOperator(filter_item, new_mode); recompile(); emitFilterChangedSignal(); } else { QStandardItem * item = m_model->itemFromIndex(idx); Q_ASSERT(item); bool const orig_checked = (item->checkState() == Qt::Checked); //Qt::CheckState const checked = orig_checked ? Qt::Unchecked : Qt::Checked; //item->setCheckState(checked); //QString const & mod = m_model->data(m_model->index(idx.row(), 1, QModelIndex()), Qt::DisplayRole).toString(); //E_FilterMode const curr = stringToFltMod(mod.toStdString().c_str()[0]); //bool const is_inclusive = curr == e_Include; ///String const & val = m_model->data(idx, Qt::DisplayRole).toString(); // @TODO: if state really changed //setStringState(val, is_inclusive); //setStringChecked(val, checked); //recompile(); //emitFilterChangedSignal(); } }
void BasicShadowCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer) { NS_ASSERTION(BasicManager()->InDrawing(), "Can only draw in drawing phase"); if (!IsSurfaceDescriptorValid(mFrontSurface)) { return; } AutoOpenSurface autoSurface(OPEN_READ_ONLY, mFrontSurface); nsRefPtr<gfxPattern> pat = new gfxPattern(autoSurface.Get()); pat->SetFilter(mFilter); pat->SetExtend(gfxPattern::EXTEND_PAD); gfxRect r(0, 0, mBounds.width, mBounds.height); gfxMatrix m; if (mNeedsYFlip) { m = aContext->CurrentMatrix(); aContext->Translate(gfxPoint(0.0, mBounds.height)); aContext->Scale(1.0, -1.0); } AutoSetOperator setOperator(aContext, GetOperator()); aContext->NewPath(); // No need to snap here; our transform has already taken care of it aContext->Rectangle(r); aContext->SetPattern(pat); FillWithMask(aContext, GetEffectiveOpacity(), aMaskLayer); if (mNeedsYFlip) { aContext->SetMatrix(m); } }
void BasicThebesLayer::PaintThebes(gfxContext* aContext, Layer* aMaskLayer, LayerManager::DrawThebesLayerCallback aCallback, void* aCallbackData, ReadbackProcessor* aReadback) { PROFILER_LABEL("BasicThebesLayer", "PaintThebes"); NS_ASSERTION(BasicManager()->InDrawing(), "Can only draw in drawing phase"); nsRefPtr<gfxASurface> targetSurface = aContext->CurrentSurface(); if (!mContentClient) { // we pass a null pointer for the Forwarder argument, which means // this will not have a ContentHost on the other side. mContentClient = new ContentClientBasic(nullptr, BasicManager()); } nsTArray<ReadbackProcessor::Update> readbackUpdates; if (aReadback && UsedForReadback()) { aReadback->GetThebesLayerUpdates(this, &readbackUpdates); } //TODO: This is going to copy back pixels that we might end up // drawing over anyway. It would be nice if we could avoid // this duplication. mContentClient->SyncFrontBufferToBackBuffer(); bool canUseOpaqueSurface = CanUseOpaqueSurface(); ContentType contentType = canUseOpaqueSurface ? gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA; float opacity = GetEffectiveOpacity(); if (!BasicManager()->IsRetained()) { NS_ASSERTION(readbackUpdates.IsEmpty(), "Can't do readback for non-retained layer"); mValidRegion.SetEmpty(); mContentClient->Clear(); nsIntRegion toDraw = IntersectWithClip(GetEffectiveVisibleRegion(), aContext); RenderTraceInvalidateStart(this, "FFFF00", toDraw.GetBounds()); if (!toDraw.IsEmpty() && !IsHidden()) { if (!aCallback) { BasicManager()->SetTransactionIncomplete(); return; } aContext->Save(); bool needsClipToVisibleRegion = GetClipToVisibleRegion(); bool needsGroup = opacity != 1.0 || GetOperator() != gfxContext::OPERATOR_OVER || aMaskLayer; nsRefPtr<gfxContext> groupContext; if (needsGroup) { groupContext = BasicManager()->PushGroupForLayer(aContext, this, toDraw, &needsClipToVisibleRegion); if (GetOperator() != gfxContext::OPERATOR_OVER) { needsClipToVisibleRegion = true; } } else { groupContext = aContext; } SetAntialiasingFlags(this, groupContext); aCallback(this, groupContext, toDraw, CLIP_NONE, nsIntRegion(), aCallbackData); if (needsGroup) { BasicManager()->PopGroupToSourceWithCachedSurface(aContext, groupContext); if (needsClipToVisibleRegion) { gfxUtils::ClipToRegion(aContext, toDraw); } AutoSetOperator setOperator(aContext, GetOperator()); PaintWithMask(aContext, opacity, aMaskLayer); } aContext->Restore(); } RenderTraceInvalidateEnd(this, "FFFF00"); return; } { uint32_t flags = 0; #ifndef MOZ_WIDGET_ANDROID if (BasicManager()->CompositorMightResample()) { flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE; } if (!(flags & ThebesLayerBuffer::PAINT_WILL_RESAMPLE)) { if (MayResample()) { flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE; } } #endif if (mDrawAtomically) { flags |= ThebesLayerBuffer::PAINT_NO_ROTATION; } PaintState state = mContentClient->BeginPaintBuffer(this, contentType, flags); mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate); if (state.mContext) { // The area that became invalid and is visible needs to be repainted // (this could be the whole visible area if our buffer switched // from RGB to RGBA, because we might need to repaint with // subpixel AA) state.mRegionToInvalidate.And(state.mRegionToInvalidate, GetEffectiveVisibleRegion()); nsIntRegion extendedDrawRegion = state.mRegionToDraw; SetAntialiasingFlags(this, state.mContext); RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds()); PaintBuffer(state.mContext, state.mRegionToDraw, extendedDrawRegion, state.mRegionToInvalidate, state.mDidSelfCopy, state.mClip, aCallback, aCallbackData); MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PaintThebes", this)); Mutated(); RenderTraceInvalidateEnd(this, "FFFF00"); } else { // It's possible that state.mRegionToInvalidate is nonempty here, // if we are shrinking the valid region to nothing. So use mRegionToDraw // instead. NS_WARN_IF_FALSE(state.mRegionToDraw.IsEmpty(), "No context when we have something to draw, resource exhaustion?"); } } if (BasicManager()->IsTransactionIncomplete()) return; gfxRect clipExtents; clipExtents = aContext->GetClipExtents(); // Pull out the mask surface and transform here, because the mask // is internal to basic layers AutoMaskData mask; gfxASurface* maskSurface = nullptr; const gfxMatrix* maskTransform = nullptr; if (GetMaskData(aMaskLayer, &mask)) { maskSurface = mask.GetSurface(); maskTransform = &mask.GetTransform(); } if (!IsHidden() && !clipExtents.IsEmpty()) { AutoSetOperator setOperator(aContext, GetOperator()); mContentClient->DrawTo(this, aContext, opacity, maskSurface, maskTransform); } for (uint32_t i = 0; i < readbackUpdates.Length(); ++i) { ReadbackProcessor::Update& update = readbackUpdates[i]; nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset(); nsRefPtr<gfxContext> ctx = update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset, update.mSequenceCounter); if (ctx) { NS_ASSERTION(opacity == 1.0, "Should only read back opaque layers"); ctx->Translate(gfxPoint(offset.x, offset.y)); mContentClient->DrawTo(this, ctx, 1.0, maskSurface, maskTransform); update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset); } } }
Lexer::Lexer(){ mTypeToString; mStringToType; mOperatorMap; mOperatorTypes; mKeywordMap; mKeywordTypes; mTokens; mLine; mNextLine; stack; addSymbol("(",SymbolType::SYMBOL_LPARENTHESIS); addSymbol(")",SymbolType::SYMBOL_RPARENTHESIS); addSymbol("[",SymbolType::SYMBOL_LBRACKET); addSymbol("]",SymbolType::SYMBOL_RBRACKET); addSymbol("{",SymbolType::SYMBOL_LBRACE); addSymbol("}",SymbolType::SYMBOL_RBRACE); addSymbol(";",SymbolType::SYMBOL_SEMICOLON); addSymbol(".",SymbolType::SYMBOL_DOT); addSymbol(",",SymbolType::SYMBOL_COMMA); addSymbol(":",SymbolType::SYMBOL_COLON); addSymbol("+",SymbolType::SYMBOL_PLUS); addSymbol("-",SymbolType::SYMBOL_MINUS); addSymbol("/",SymbolType::SYMBOL_DIVIDE); addSymbol("*",SymbolType::SYMBOL_MULTIPLY); addSymbol("%",SymbolType::SYMBOL_MOD); addSymbol("^",SymbolType::SYMBOL_POWER); addSymbol("=",SymbolType::SYMBOL_EQUALS); addSymbol("+=",SymbolType::SYMBOL_PLUSEQUALS); addSymbol("-=",SymbolType::SYMBOL_MINUSEQUALS); addSymbol("/=",SymbolType::SYMBOL_DIVIDEEQUALS); addSymbol("*=",SymbolType::SYMBOL_MULTIPLYEQUALS); addSymbol("%=",SymbolType::SYMBOL_MODEQUALS); addSymbol("^=",SymbolType::SYMBOL_POWEREQUALS); addSymbol("++",SymbolType::SYMBOL_INCREMENT); addSymbol("--",SymbolType::SYMBOL_DECREMENT); addSymbol("//",SymbolType::SYMBOL_COMMENTSINGLE); addSymbol("/*",SymbolType::SYMBOL_COMMENTMULTISTART); addSymbol("*/",SymbolType::SYMBOL_COMMENTMULTIEND); addSymbol("#",SymbolType::SYMBOL_PREPROCESSOR); addSymbol("\"",SymbolType::SYMBOL_STRINGDELIM); setOperator(SymbolType::SYMBOL_COLON); setOperator(SymbolType::SYMBOL_COMMA); setOperator(SymbolType::SYMBOL_DIVIDE); setOperator(SymbolType::SYMBOL_DIVIDEEQUALS); setOperator(SymbolType::SYMBOL_DECREMENT); setOperator(SymbolType::SYMBOL_DOT); setOperator(SymbolType::SYMBOL_INCREMENT); setOperator(SymbolType::SYMBOL_LBRACE); setOperator(SymbolType::SYMBOL_LBRACKET); setOperator(SymbolType::SYMBOL_LPARENTHESIS); setOperator(SymbolType::SYMBOL_MINUS); setOperator(SymbolType::SYMBOL_MINUSEQUALS); setOperator(SymbolType::SYMBOL_MOD); setOperator(SymbolType::SYMBOL_MODEQUALS); setOperator(SymbolType::SYMBOL_MULTIPLY); setOperator(SymbolType::SYMBOL_MULTIPLYEQUALS); setOperator(SymbolType::SYMBOL_PLUS); setOperator(SymbolType::SYMBOL_PLUSEQUALS); setOperator(SymbolType::SYMBOL_POWER); setOperator(SymbolType::SYMBOL_POWEREQUALS); setOperator(SymbolType::SYMBOL_RBRACE); setOperator(SymbolType::SYMBOL_RBRACKET); setOperator(SymbolType::SYMBOL_RPARENTHESIS); setOperator(SymbolType::SYMBOL_SEMICOLON); addKeyword("require",KEYWORD_REQUIRE); addKeyword("imply", KEYWORD_IMPLY); addKeyword("peek", KEYWORD_PEEK); addKeyword("define", KEYWORD_DEFINE); addKeyword("global", KEYWORD_GLOBAL); addKeyword("local", KEYWORD_LOCAL); addKeyword("return", KEYWORD_RETURN); };
virtual void Paint(gfxContext* aContext, Layer* aMaskLayer) { AutoSetOperator setOperator(aContext, GetOperator()); BasicColorLayer::PaintColorTo(mColor, GetEffectiveOpacity(), aContext, aMaskLayer); }