Exemple #1
0
void
ShadowLayerForwarder::RemoveChild(ShadowableLayer* aContainer,
                                  ShadowableLayer* aChild)
{
  mTxn->AddEdit(OpRemoveChild(NULL, Shadow(aContainer),
                              NULL, Shadow(aChild)));
}
Exemple #2
0
Color PointLight::Illuminate(const Point3& p, const Point3& N) const
{
	Color returnColor = Color(0.0f);
	if (size > 0)
	{
		CircleSampler randomCircleSampler = CircleSampler(SHADOW_SAMPLE_COUNT, SHADOW_SAMPLE_COUNT, size, p, position);
		randomCircleSampler.generateSamples();
		Point3 randomVectorW;
		Point3 vectorU = Point3(0.0f, 0.0f, 0.0f);
		Point3 vectorV = Point3(0.0f, 0.0f, 0.0f);
		Point3 lightDir;
		lightDir = -1 * Direction(p);
		Ray sampleRay;
		Point3 offset;
		Point3 samplePosition;
		getOrthoNormalBasisVector(lightDir, vectorU, vectorV);
		for (int i = 0; i < randomCircleSampler.getCurrentSampleCount(); ++i)
		{
			offset = randomCircleSampler.getSample(i).getOffset();
			samplePosition = position + offset.x*vectorU + offset.y*vectorV;
			sampleRay.dir = samplePosition + lightDir /*Direction(samplePosition)*/;
			sampleRay.p = p;
			randomCircleSampler.setSampleColor(i, Shadow(sampleRay)* intensity);
			randomCircleSampler.setIsSampleHit(i, true);
		}

		returnColor = randomCircleSampler.getAveragedSampleListColor();
	}
	else
		returnColor = Shadow(Ray(p,position-p),1) * intensity;

	//delete randomCircleSampler;
	return returnColor;
}
Exemple #3
0
void
ShadowLayerForwarder::InsertAfter(ShadowableLayer* aContainer,
                                  ShadowableLayer* aChild,
                                  ShadowableLayer* aAfter)
{
  if (aAfter)
    mTxn->AddEdit(OpInsertAfter(NULL, Shadow(aContainer),
                                NULL, Shadow(aChild),
                                NULL, Shadow(aAfter)));
  else
    mTxn->AddEdit(OpAppendChild(NULL, Shadow(aContainer),
                                NULL, Shadow(aChild)));
}
Exemple #4
0
void
ShadowLayerForwarder::PaintedCanvas(ShadowableLayer* aCanvas,
                                    const SurfaceDescriptor& aNewFrontSurface)
{
    mTxn->AddPaint(OpPaintCanvas(NULL, Shadow(aCanvas),
                                 aNewFrontSurface));
}
Exemple #5
0
void
ShadowLayerForwarder::PaintedImage(ShadowableLayer* aImage,
                                   const SharedImage& aNewFrontImage)
{
  mTxn->AddPaint(OpPaintImage(NULL, Shadow(aImage),
                              aNewFrontImage));
}
Exemple #6
0
void
ShadowLayerForwarder::DestroyedThebesBuffer(ShadowableLayer* aThebes,
        const SurfaceDescriptor& aBackBufferToDestroy)
{
    mTxn->AddEdit(OpDestroyThebesFrontBuffer(NULL, Shadow(aThebes)));
    mTxn->AddBufferToDestroy(aBackBufferToDestroy);
}
Exemple #7
0
// Initialize a CFontDescription object with the attributes that
// make a font unique.
BOOL CTextStyle::GetFontDescription(CFontDescription* pFontDescription)
{
	BOOL fResult = FALSE;

	// Get the typeface number.
	int nTypeface = ((PMGFontServer*)(Database()->get_font_server()))->font_record_to_face(Font());
	if (nTypeface != -1)
	{
		// Compute the style (bold, italic) of the typeface.
		int nFontStyle = 0;
		if (Bold())
		{
			nFontStyle |= FONT_STYLE_Bold;
		}
		if (Italic())
		{
			nFontStyle |= FONT_STYLE_Italic;
		}

		// Initialize the font description.
		pFontDescription->m_nTypeface = typeface_for_fstyle(nTypeface, (FONT_STYLE)nFontStyle);
		pFontDescription->m_lPointSize = Size();
		pFontDescription->m_lHorizontalExpansion = Expansion();
		pFontDescription->m_Fill = Fill();
		pFontDescription->m_Outline = Outline();
		pFontDescription->m_Shadow = Shadow();

		fResult = TRUE;
	}

	return fResult;
}
Exemple #8
0
const LightStage::LightPointer LightStage::addLight(model::LightPointer light) {
  //  Shadow stageShadow{light};
    LightPointer stageLight = std::make_shared<Light>(Shadow(light));
    stageLight->light = light;
    lights.push_back(stageLight);
    return stageLight;
}
Exemple #9
0
void
ShadowLayerForwarder::PaintedTiledLayerBuffer(ShadowableLayer* aLayer,
                                              BasicTiledLayerBuffer* aTiledLayerBuffer)
{
  if (XRE_GetProcessType() != GeckoProcessType_Default)
    NS_RUNTIMEABORT("PaintedTiledLayerBuffer must be made IPC safe (not share pointers)");
  mTxn->AddNoSwapPaint(OpPaintTiledLayerBuffer(NULL, Shadow(aLayer),
                                         uintptr_t(aTiledLayerBuffer)));
}
Exemple #10
0
void
ShadowLayerForwarder::CreatedImageBuffer(ShadowableLayer* aImage,
        nsIntSize aSize,
        const SharedImage& aTempFrontImage)
{
    mTxn->AddEdit(OpCreateImageBuffer(NULL, Shadow(aImage),
                                      aSize,
                                      aTempFrontImage));
}
Exemple #11
0
void
ShadowLayerForwarder::CreatedCanvasBuffer(ShadowableLayer* aCanvas,
        nsIntSize aSize,
        const SurfaceDescriptor& aTempFrontSurface,
        bool aNeedYFlip)
{
    mTxn->AddEdit(OpCreateCanvasBuffer(NULL, Shadow(aCanvas),
                                       aSize,
                                       aTempFrontSurface,
                                       aNeedYFlip));
}
Exemple #12
0
/*
 *  Draw polygon or shadow volume
 *    P[] array of vertexes making up the polygon
 *    N[] array of normals (not used with shadows)
 *    T[] array of texture coordinates (not used with shadows)
 *    n   number of vertexes
 *  Killer fact: the order of points MUST be CCW
 */
void DrawPolyShadow(Point P[],Point N[],Point T[],int n)
{
   int k;
   //  Draw polygon with normals and textures
   if (light)
   {
      glBegin(GL_POLYGON);
      for (k=0;k<n;k++)
      {
         glNormal3f(N[k].x,N[k].y,N[k].z);
         glTexCoord2f(T[k].x,T[k].y);
         glVertex3f(P[k].x,P[k].y,P[k].z);
      }
      glEnd();
   }
   //  Draw shadow volume
   else
   {
      //  Check if polygon is visible
      int vis = 0;
      for (k=0;k<n;k++)
         vis = vis | (N[k].x*(Lp.x-P[k].x) + N[k].y*(Lp.y-P[k].y) + N[k].z*(Lp.z-P[k].z) >= 0);
      //  Draw shadow volume only for those polygons facing the light
      if (vis)
      {
         //  Shadow coordinates (at infinity)
         Point S[MAXN];
         if (n>MAXN) Fatal("Too many points in polygon %d\n",n);
         //  Project shadow
         for (k=0;k<n;k++)
            S[k] = Shadow(P[k]);
         //  Front face
         glBegin(GL_POLYGON);
         for (k=0;k<n;k++)
            glVertex3f(P[k].x,P[k].y,P[k].z);
         glEnd();
         //  Back face
         glBegin(GL_POLYGON);
         for (k=n-1;k>=0;k--)
            glVertex3f(S[k].x,S[k].y,S[k].z);
         glEnd();
         //  Sides
         glBegin(GL_QUAD_STRIP);
         for (k=0;k<=n;k++)
         {
            glVertex3f(P[k%n].x,P[k%n].y,P[k%n].z);
            glVertex3f(S[k%n].x,S[k%n].y,S[k%n].z);
         }
         glEnd();
      }
   }
}
Exemple #13
0
void
ShadowLayerForwarder::PaintedThebesBuffer(ShadowableLayer* aThebes,
                                          const nsIntRegion& aUpdatedRegion,
                                          const nsIntRect& aBufferRect,
                                          const nsIntPoint& aBufferRotation,
                                          const SurfaceDescriptor& aNewFrontBuffer)
{
  mTxn->AddPaint(OpPaintThebesBuffer(NULL, Shadow(aThebes),
                                     ThebesBuffer(aNewFrontBuffer,
                                                  aBufferRect,
                                                  aBufferRotation),
                                     aUpdatedRegion));
}
void SmartDrawSphere(SDL_Surface* screen, LightSource light, Sphere S, int width, int height)
{
	for (int y=S.center_.z_-S.r_;y<=S.center_.z_+S.r_;++y)
		for (int x=-(int)sqrt(S.r_*S.r_-(y-S.center_.x_)*(y-S.center_.x_))-1;x<(int)sqrt(S.r_*S.r_-(y-S.center_.x_)*(y-S.center_.x_))+1;++x)
		{
			Vector sol = Solution(Vector(x*5,1000,y*5),Vector(0,0,0),S);
		if (sol!=Vector(0,0,0))
		{
			Color c1=S.color_;
			//sol=sol*5;
			putpixel(screen,width/2+x*5,y*5+height/2,Shadow(light,sol,S).GetUint32());
			SDL_UpdateRect(screen,width/2+x*5,sol.z_+height/2,1,1);
		}
		}
}
void DrawSphere(SDL_Surface* screen, Sphere s, int width, int height, LightSource light)
{
	for (int x=0;x<width;x++) for (int y=0;y<height;y++)
	{
		if (x>width/2+70) if (y>height/2+20) 
			s=s;
		Vector sol = Solution(Vector(x-width/2,1000,y-height/2),Vector(0,0,0),s);
		if (sol!=Vector(0,0,0))
		{
			Color c1=s.color_;
			putpixel(screen,x,y,Shadow(light,sol,s).GetUint32());
			SDL_UpdateRect(screen,x,y,1,1);
		}
	}
	//SDL_UpdateRect(screen,0,0,1024,600);
}
Exemple #16
0
void
ShadowLayerForwarder::CreatedThebesBuffer(ShadowableLayer* aThebes,
        const nsIntRegion& aFrontValidRegion,
        const nsIntRect& aBufferRect,
        const SurfaceDescriptor& aTempFrontBuffer)
{
    OptionalThebesBuffer buffer = null_t();
    if (IsSurfaceDescriptorValid(aTempFrontBuffer)) {
        buffer = ThebesBuffer(aTempFrontBuffer,
                              aBufferRect,
                              nsIntPoint(0, 0));
    }
    mTxn->AddEdit(OpCreateThebesBuffer(NULL, Shadow(aThebes),
                                       buffer,
                                       aFrontValidRegion));
}
Exemple #17
0
void FolderTree::DisplayObject()
{
	//if(!TopScreen) TopScreen=new SaveScreen;
	if (ModalMode == MODALTREE_FREE)
	{
		string strSelFolder(Tree->GetCurDir());
		//Tree->Update(UPDATE_KEEP_SELECTION);
		Tree->Update(0);
		Tree->GoToFile(strSelFolder);
	}

	Tree->Redraw();
	Shadow();
	DrawEdit();

	if (!IsFullScreen)
	{
		m_windowKeyBar->SetPosition(0,ScrY,ScrX,ScrY);
		m_windowKeyBar->Show();
	}
	else
		m_windowKeyBar->Hide();
}
Exemple #18
0
void CTextStyle::FromOldStyle(const TextStyle& style)
{
	// Set some defaults.
	SetDefault();

	// Copy the style information over.
	Font(style.get_face());
	Size(MakeFixed(style.get_size(), style.get_size_fraction()));
	BaseSize(MakeFixed(style.get_base_size(), style.get_base_size_fraction()));
	Expansion(DivFixed(MakeFixed(style.get_base_size(), style.get_base_size_fraction()),
							 MakeFixed(FONT_EXPANSION_UNIT)));
	Fill(style.get_pattern(), style.get_color());
	Outline(style.get_outline(), style.get_color());
	Shadow(style.get_shadow(), style.get_color());
	m_Character.m_nEffectsVersion = 1;
	XFlipped(style.get_xflipped());
	YFlipped(style.get_yflipped());
//	Color(style.get_color());

	Alignment(style.get_line_alignment());
	VerticalAlignment(style.get_vertical_alignment());
	// Left and right margin should be zero (default) unless set by user.
	// This fixes a problem converting old warp text boxes - they should
	// always have zero margins!
	LeftMargin(0);
	RightMargin(0);
//	LeftMargin(PageToInches(style.get_left_margin()));
//	RightMargin(PageToInches(style.get_right_margin()));
	LeadingType(LEADING_lines);
	Leading(MakeFixed(0.875));

	Underline(style.UnderlineStyle());

	// Update our metrics.
	UpdateFontMetrics();
}
Exemple #19
0
PRBool
ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
{
    NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
    NS_ABORT_IF_FALSE(!mTxn->Finished(), "forgot BeginTransaction?");

    AutoTxnEnd _(mTxn);

    if (mTxn->Empty()) {
        MOZ_LAYERS_LOG(("[LayersForwarder] 0-length cset (?), skipping Update()"));
        return PR_TRUE;
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));

    for (PRUint32 i = 0; i < mTxn->mDyingBuffers.Length(); ++i) {
        DestroySharedSurface(&mTxn->mDyingBuffers[i]);
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));

    // We purposely add attribute-change ops to the final changeset
    // before we add paint ops.  This allows layers to record the
    // attribute changes before new pixels arrive, which can be useful
    // for setting up back/front buffers.
    for (ShadowableLayerSet::const_iterator it = mTxn->mMutants.begin();
            it != mTxn->mMutants.end(); ++it) {
        ShadowableLayer* shadow = *it;
        Layer* mutant = shadow->AsLayer();
        NS_ABORT_IF_FALSE(!!mutant, "unshadowable layer?");

        LayerAttributes attrs;
        CommonLayerAttributes& common = attrs.common();
        common.visibleRegion() = mutant->GetVisibleRegion();
        common.transform() = mutant->GetTransform();
        common.contentFlags() = mutant->GetContentFlags();
        common.opacity() = mutant->GetOpacity();
        common.useClipRect() = !!mutant->GetClipRect();
        common.clipRect() = (common.useClipRect() ?
                             *mutant->GetClipRect() : nsIntRect());
        common.isFixedPosition() = mutant->GetIsFixedPosition();
        common.useTileSourceRect() = !!mutant->GetTileSourceRect();
        common.tileSourceRect() = (common.useTileSourceRect() ?
                                   *mutant->GetTileSourceRect() : nsIntRect());
        attrs.specific() = null_t();
        mutant->FillSpecificAttributes(attrs.specific());

        mTxn->AddEdit(OpSetLayerAttributes(NULL, Shadow(shadow), attrs));
    }

    AutoInfallibleTArray<Edit, 10> cset;
    size_t nCsets = mTxn->mCset.size() + mTxn->mPaints.size();
    NS_ABORT_IF_FALSE(nCsets > 0, "should have bailed by now");

    cset.SetCapacity(nCsets);
    if (!mTxn->mCset.empty()) {
        cset.AppendElements(&mTxn->mCset.front(), mTxn->mCset.size());
    }
    // Paints after non-paint ops, including attribute changes.  See
    // above.
    if (!mTxn->mPaints.empty()) {
        cset.AppendElements(&mTxn->mPaints.front(), mTxn->mPaints.size());
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
    PlatformSyncBeforeUpdate();

    MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
    if (!mShadowManager->SendUpdate(cset, aReplies)) {
        MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
        return PR_FALSE;
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
    return PR_TRUE;
}
Exemple #20
0
// helper function not part of the class.
Shadow projectTile(int col, int row) {
    float topLeft = (float)(col) / (float)(row + 2);
    float bottomRight = (float)(col + 1) / (float)(row + 1);
    return Shadow(topLeft, bottomRight);
}
Exemple #21
0
void
ShadowLayerForwarder::DestroyedImageBuffer(ShadowableLayer* aImage)
{
    mTxn->AddEdit(OpDestroyImageFrontBuffer(NULL, Shadow(aImage)));
}
Exemple #22
0
bool
ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
{
  SAMPLE_LABEL("ShadowLayerForwarder", "EndTranscation");
  RenderTraceScope rendertrace("Foward Transaction", "000091");
  NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
  NS_ABORT_IF_FALSE(!mTxn->Finished(), "forgot BeginTransaction?");

  AutoTxnEnd _(mTxn);

  if (mTxn->Empty()) {
    MOZ_LAYERS_LOG(("[LayersForwarder] 0-length cset (?), skipping Update()"));
    return true;
  }

  MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));

  for (PRUint32 i = 0; i < mTxn->mDyingBuffers.Length(); ++i) {
    DestroySharedSurface(&mTxn->mDyingBuffers[i]);
  }

  MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));

  // We purposely add attribute-change ops to the final changeset
  // before we add paint ops.  This allows layers to record the
  // attribute changes before new pixels arrive, which can be useful
  // for setting up back/front buffers.
  RenderTraceScope rendertrace2("Foward Transaction", "000092");
  for (ShadowableLayerSet::const_iterator it = mTxn->mMutants.begin();
       it != mTxn->mMutants.end(); ++it) {
    ShadowableLayer* shadow = *it;
    Layer* mutant = shadow->AsLayer();
    NS_ABORT_IF_FALSE(!!mutant, "unshadowable layer?");

    LayerAttributes attrs;
    CommonLayerAttributes& common = attrs.common();
    common.visibleRegion() = mutant->GetVisibleRegion();
    common.transform() = mutant->GetTransform();
    common.contentFlags() = mutant->GetContentFlags();
    common.opacity() = mutant->GetOpacity();
    common.useClipRect() = !!mutant->GetClipRect();
    common.clipRect() = (common.useClipRect() ?
                         *mutant->GetClipRect() : nsIntRect());
    common.isFixedPosition() = mutant->GetIsFixedPosition();
    if (Layer* maskLayer = mutant->GetMaskLayer()) {
      common.maskLayerChild() = Shadow(maskLayer->AsShadowableLayer());
    } else {
      common.maskLayerChild() = NULL;
    }
    common.maskLayerParent() = NULL;
    attrs.specific() = null_t();
    mutant->FillSpecificAttributes(attrs.specific());

    mTxn->AddEdit(OpSetLayerAttributes(NULL, Shadow(shadow), attrs));
  }

  AutoInfallibleTArray<Edit, 10> cset;
  size_t nCsets = mTxn->mCset.size() + mTxn->mPaints.size();
  NS_ABORT_IF_FALSE(nCsets > 0, "should have bailed by now");

  cset.SetCapacity(nCsets);
  if (!mTxn->mCset.empty()) {
    cset.AppendElements(&mTxn->mCset.front(), mTxn->mCset.size());
  }
  // Paints after non-paint ops, including attribute changes.  See
  // above.
  if (!mTxn->mPaints.empty()) {
    cset.AppendElements(&mTxn->mPaints.front(), mTxn->mPaints.size());
  }

  MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
  PlatformSyncBeforeUpdate();

  if (mTxn->mSwapRequired) {
    MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
    RenderTraceScope rendertrace3("Forward Transaction", "000093");
    if (!mShadowManager->SendUpdate(cset, mIsFirstPaint, aReplies)) {
      MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
      return false;
    }
  } else {
    // If we don't require a swap we can call SendUpdateNoSwap which
    // assumes that aReplies is empty (DEBUG assertion)
    MOZ_LAYERS_LOG(("[LayersForwarder] sending no swap transaction..."));
    RenderTraceScope rendertrace3("Forward NoSwap Transaction", "000093");
    if (!mShadowManager->SendUpdateNoSwap(cset, mIsFirstPaint)) {
      MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
      return false;
    }
  }

  mIsFirstPaint = false;
  MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
  return true;
}
Exemple #23
0
void
ShadowLayerForwarder::DestroyedCanvasBuffer(ShadowableLayer* aCanvas)
{
    mTxn->AddEdit(OpDestroyCanvasFrontBuffer(NULL, Shadow(aCanvas)));
}
Exemple #24
0
static void
CreatedLayer(Transaction* aTxn, ShadowableLayer* aLayer)
{
  aTxn->AddEdit(OpCreateT(NULL, Shadow(aLayer)));
}
Exemple #25
0
void
ShadowLayerForwarder::SetRoot(ShadowableLayer* aRoot)
{
  mTxn->AddEdit(OpSetRoot(NULL, Shadow(aRoot)));
}