12to11/shaders.txt
oldosfan 4d2e85d002 Implement wp_viewporter support and fix scaling for fractional values
* 12to11.c (XLMain): Initialize wp_viewporter.
* Imakefile (ETAGS): Remove unused variable.
(SRCS, OBJS): Add wp_viewporter.c and wp_viewporter.o.
(GENHEADERS): Remove unnecessary headers.
(viewporter): New scanner target.
* README: Document support for wp_viewporter.
* compositor.h (struct _ViewportExt): New forward declaration.
(struct _DrawParams): New fields for cropping and stretching.
(struct _RenderFuncs): Describe how composite works.
(struct _BufferFuncs): Make update_buffer_for_damage take
DrawParams as an argument.
(struct _State): New fields for viewporting.
(struct _Surface): New field `viewport' and associated input
delta.
(struct _XdgRoleImplementationFuncs): New field
`is_window_mapped'.  Do not commit while unmapped.
* dmabuf.c (XLInitDmabuf): Remove outdated comment.
* dnd.c (HandleMotion): Use TruncateWindowToSurface.
* egl.c (struct _EglBuffer): Add 3x3 reverse transformation
matrix.
(struct _CompositeProgram): Rename `scale' to `source'.
(Index): New macro.
(PickBetterVisual, FindVisual): Compensate for EGL picking a
non-RGBA visual.
(EglCompileCompositeProgram): Look for source, not scale.
(ComputeTransformMatrix): New function.
(Composite): Compute transformation matrix and draw using that.
(BufferFromDmaBuf, BufferFromShm): Copy identity transform and
stop setting scale.
(ReverseTransformToBox): New function.
(UpdateShmBufferIncrementally): Accept DrawParams and invert
damage according to that.
(UpdateBuffer, UpdateBufferForDamage): Pass draw params to the
incremental buffer update function.
* fns.c (XLExtendRegion): New function.
* frame_clock.c (CurrentHighPrecisionTimestamp): Delete
function.
(HighPrecisionTimestamp, HighPrecisionTimestamp32): New
functions.
(PostEndFrame): Handle X server time truncation to 32 bits.
(XLFrameClockFreeze): Remove trailing whitespace.
* picture_renderer.c (GetSourceX, GetSourceY, CompareStretch):
New functions.
(MaybeApplyTransform): Check more values before applying
transformations.  Then, handle stretch and offset.
* positioner.c (GetAdjustmentOffset, ApplyConstraintAdjustment)
(XLPositionerCalculateGeometry): Scale coordinates using new
functions.
* renderer.c (RenderUpdateBufferForDamage): Accept DrawParams
instead of scale.
* shaders.txt (Composite Rectangle Fragment Shader RGBA)
(Composite Rectangle Fragment Shader RGBX)
(Composite Rectangle Fragment Shader External): Stop
transforming texcoords.
(Composite Rectangle Vertex Shader): Transform texcoords in the
vertex shader instead.
* subcompositor.c (IsViewported, SetViewported,
ClearViewported): New functions.
(struct _View): New fields for tracking viewports and fractional
offsets.
(ViewAttachBuffer): Do not garbage upon buffer size change if a
viewport is set.
(ViewMoveFractional): New function.
(ViewDamage): Describe what the damage is and is not transformed
by.
(GetContentScale): New function.
(ViewWidth, ViewHeight): Apply viewport.
(ViewSetScale): Use ViewAfterSizeUpdate instead of duplicating
code.
(ViewSetViewport, ViewClearViewport): New functions.
(ViewComputeTransform): Compute transform for viewports.  New
arg draw; use it to determine whether or not to include a
fractional offset.
(IntersectBoxes): Fix intersection calculation.
(SubcompositorUpdate): Don't keep calling ViewWidth and
ViewHeight in a loop.
(SubcompositorExpose): Adjust for changes to buffer damage
uploading.
* subsurface.c (MoveFractional): New function.  Handle
fractional offsets after scaling.
(MaybeUpdateOutputs, AfterParentCommit, Setup, Rescale): Use
that function to move the subsurface instead.
* surface.c (ApplyScale): Update comment.
(ApplyViewport, CheckViewportValues): New functions.
(HandleScaleChanged): Apply the viewport as well upon scale
change.
(ApplyDamage): Improve damage calculation for viewported
surfaces.
(SavePendingState, InternalCommit): Save and commit viewport
state; check old values upon buffer commit.
(InitState): Initialize viewport to initial values.
(XLSurfaceRunFrameCallbacks): Handle overflows of 32-bit time at
the 49-day mark.
(SurfaceToWindow, ScaleToWindow, WindowToSurface, ScaleToSurface)
(TruncateScaleToWindow, TruncateScaleToWindow)
(TruncateWindowToSurface, TruncateScaleToSurface): New functions
for handling scale.
* xdg_popup.c (MoveWindow, IsWindowMapped, XLGetXdgPopup):
* xdg_surface.c (IsRoleMapped, Commit, Subframe)
(GetResizeDimensions, XLXdgRoleCalcNewWindowSize):
* xdg_toplevel.c (IsWindowMapped, NoteConfigureTime, SendStates)
(RecordStateSize, HandleWindowGeometryChange, NoteWindowPreResize)
(XLGetXdgToplevel): Use them instead of manually multiplying
with the factor.
2022-09-30 01:17:47 +00:00

106 lines
2 KiB
GLSL

// -*- glsl -*-
// File containing GLSL shaders used to generate shaders.h.
// At the start of each shader, write // followed by two equals signs,
// followed by a space, the name of the shader and a newline.
// Following that, write the shader code.
// To terminate a shader, write // followed by another two equals
// signs, this time without a trailing name or whitespace.
//== Clear Rectangle Vertex Shader
attribute vec2 pos;
void
main (void)
{
gl_Position = vec4 (pos.x, pos.y, 1.0, 1.0);
}
//==
//== Clear Rectangle Fragment Shader
void
main (void)
{
gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);
}
//==
//== Composite Rectangle Vertex Shader
attribute vec2 pos;
attribute vec2 texcoord;
varying vec2 v_texcoord;
uniform mat3 source;
void
main (void)
{
gl_Position = vec4 (pos.x, pos.y, 1.0, 1.0);
v_texcoord = (source * vec3 (texcoord, 1.0)).xy;
}
//==
//== Composite Rectangle Fragment Shader RGBA
precision mediump float;
uniform sampler2D texture;
uniform bool invert_y;
varying vec2 v_texcoord;
void
main (void)
{
vec2 texcoord;
texcoord = v_texcoord;
if (invert_y)
texcoord = vec2 (texcoord.x, 1.0 - texcoord.y);
gl_FragColor = texture2D (texture, texcoord);
}
//==
//== Composite Rectangle Fragment Shader RGBX
precision mediump float;
uniform sampler2D texture;
uniform mat3 source;
uniform bool invert_y;
varying vec2 v_texcoord;
void
main (void)
{
vec2 texcoord;
texcoord = v_texcoord;
if (invert_y)
texcoord = vec2 (texcoord.x, 1.0 - texcoord.y);
gl_FragColor = vec4 (texture2D (texture, texcoord).rgb, 1.0);
}
//==
//== Composite Rectangle Fragment Shader External
#extension GL_OES_EGL_image_external : require
precision mediump float;
uniform samplerExternalOES texture;
uniform mat3 source;
uniform bool invert_y;
varying vec2 v_texcoord;
void
main (void)
{
vec2 texcoord;
texcoord = v_texcoord;
if (invert_y)
texcoord = vec2 (texcoord.x, 1.0 - texcoord.y);
gl_FragColor = texture2D (texture, texcoord);
}
//==