gfx::Rect Compositor::ClipRectInLayersCoordinates(gfx::Rect aClip) const { gfx::Rect result; aClip = aClip + GetCurrentRenderTarget()->GetOrigin(); gfx::IntSize destSize = GetWidgetSize(); switch (mScreenRotation) { case ROTATION_0: result = aClip; break; case ROTATION_90: result = gfx::Rect(aClip.y, destSize.width - aClip.x - aClip.width, aClip.height, aClip.width); break; case ROTATION_270: result = gfx::Rect(destSize.height - aClip.y - aClip.height, aClip.x, aClip.height, aClip.width); break; case ROTATION_180: result = gfx::Rect(destSize.width - aClip.x - aClip.width, destSize.height - aClip.y - aClip.height, aClip.width, aClip.height); break; // ScreenRotation has a sentinel value, need to catch it in the switch // statement otherwise the build fails (-WError) default: {} } return result; }
gfx::IntRect Compositor::ComputeBackdropCopyRect(const gfx::Rect& aRect, const gfx::IntRect& aClipRect, const gfx::Matrix4x4& aTransform, gfx::Matrix4x4* aOutTransform, gfx::Rect* aOutLayerQuad) { // Compute the clip. gfx::IntPoint rtOffset = GetCurrentRenderTarget()->GetOrigin(); gfx::IntSize rtSize = GetCurrentRenderTarget()->GetSize(); gfx::IntRect renderBounds(0, 0, rtSize.width, rtSize.height); renderBounds.IntersectRect(renderBounds, aClipRect); renderBounds.MoveBy(rtOffset); // Apply the layer transform. gfx::RectDouble dest = aTransform.TransformAndClipBounds( gfx::RectDouble(aRect.x, aRect.y, aRect.width, aRect.height), gfx::RectDouble(renderBounds.x, renderBounds.y, renderBounds.width, renderBounds.height)); dest -= rtOffset; // Ensure we don't round out to -1, which trips up Direct3D. dest.IntersectRect(dest, gfx::RectDouble(0, 0, rtSize.width, rtSize.height)); if (aOutLayerQuad) { *aOutLayerQuad = gfx::Rect(dest.x, dest.y, dest.width, dest.height); } // Round out to integer. gfx::IntRect result; dest.RoundOut(); dest.ToIntRect(&result); // Create a transform from adjusted clip space to render target space, // translate it for the backdrop rect, then transform it into the backdrop's // uv-space. gfx::Matrix4x4 transform; transform.PostScale(rtSize.width, rtSize.height, 1.0); transform.PostTranslate(-result.x, -result.y, 0.0); transform.PostScale(1 / float(result.width), 1 / float(result.height), 1.0); *aOutTransform = transform; return result; }
void Device_OpenGL::PopRenderTarget() { if (renderTargetStack.size() > 0) { renderTargetStack.pop_back(); } if (renderTargetStack.size() > 0) { glBindFramebuffer(GL_FRAMEBUFFER, GetCurrentRenderTarget()->id); } else { glBindFramebuffer(GL_FRAMEBUFFER, 0); } }
gfx::Rect Compositor::ClipRectInLayersCoordinates(gfx::Rect aClip) const { gfx::Rect result; switch (mScreenRotation) { case ROTATION_90: case ROTATION_270: result = gfx::Rect(aClip.y, aClip.x, aClip.height, aClip.width); break; case ROTATION_0: case ROTATION_180: default: result = aClip; break; } return result + GetCurrentRenderTarget()->GetOrigin(); }
gfx::IntRect Compositor::ComputeBackdropCopyRect(const gfx::Rect& aRect, const gfx::Rect& aClipRect, const gfx::Matrix4x4& aTransform) { gfx::Rect renderBounds = mRenderBounds; // Compute the clip. gfx::IntPoint offset = GetCurrentRenderTarget()->GetOrigin(); renderBounds.IntersectRect(renderBounds, aClipRect); renderBounds.MoveBy(offset); // Apply the layer transform. gfx::Rect dest = aTransform.TransformAndClipBounds(aRect, renderBounds); dest -= offset; // Round out to integer. gfx::IntRect result; dest.RoundOut(); dest.ToIntRect(&result); return result; }