Commit Graph

8274 Commits

Author SHA1 Message Date
Benjamin Otte
a86359af2b wayland: Create drop contexts on demand
Instead of creating and reusing the same one from start to finish.
2018-04-27 14:32:28 +02:00
Benjamin Otte
ae7a677346 cairocontext: Remove fallback implementations
Now that all Cairo contexts are ported to managing cairo surfaces
themselves, the old fallback code that didi the managing is no longer
needed.

Also clarify the behavior of gdk_cairo_context_cairo_create() wrt the
vfunc by doing the early exit and the clipping outside of it.
2018-04-24 23:24:55 +02:00
Руслан Ижбулатов
7002f08cc1 GDK W32: Switch to GdkCairoContext
* Remove DC refcounting (we trust GDK to always do
  begin_frame/end_frame calls in pairs)
* Now that there's no GDK-provided double-buffer up the stack,
  double-buffering is implemented here
  (though it's disabled by default - in my tests it didn't provide
   any visual improvements, but did decrease performance).
* For some reason delaying window resizes until the point where
  we need to blit the double-buffer into the window leads
  to visual glitches, so doulbe-buffered windows are resized
  in begin_frame, same as non-double-buffered ones.
* New code to clear the paint region, for all drawing modes.
  Hopefully, it isn't duplicated anywhere up the stack.
* GL has its own context now, so remove any GL-related comments.
* Layered windows are still used (because cairo actually works
  better with them)
* A bit more code re-use for layered windows
* Some functions that were local to gdksurface-win32.c are made
  usable for the whole backend
* Drag-indicator drawing is temporarily commented out to match
  a similar change in X11 backend
2018-04-24 23:24:55 +02:00
Alexander Larsson
a329de63ea broadway: Add and use GdkBroadwayDrawContext 2018-04-24 23:24:55 +02:00
Alexander Larsson
99c46f263e broadway: Add basic GdkCairoContext implementation 2018-04-24 23:17:14 +02:00
Alexander Larsson
9421cb8b3a broadway: Call _gdk_surface_update_size when resizing surface 2018-04-24 23:17:14 +02:00
Benjamin Otte
83ea0b3714 drawcontext: Only pass the region that matters
We used to pass 2 regions to GdkDrawCotnext.end_frame() but code was
confusing what they meant. So we now don't do that anymore and only pass
the region that matters: The frame region.
2018-04-24 23:16:58 +02:00
Benjamin Otte
fd686afeb2 drawcontext: Add gdk_draw_context_in_frame() API
This makes the previous gdk_draw_context_is_drawing() function public
under a new name.

I decided against the old name because we use the term "frame" for a
drawing operation, so I wanted to have this boolean flag reuse the term.
2018-04-24 23:16:58 +02:00
Benjamin Otte
6aa89f2163 drawcontext: Move variable into private struct
... and get rid of duplicate variable in the process.
2018-04-24 23:16:58 +02:00
Benjamin Otte
a865621519 gdk: Move begin/end_frame() functions
As they require a draw context and the draw context is already bound to
the surface, it makes much more sense and reduces abiguity by moving
these APIs to the draw context.

As a side effect, we simplify GdkSurface APIs to a point where
GdkSurface now does not concern itself with drawing anymore at all,
apart from being the object that creates draw contexts.
2018-04-24 23:16:58 +02:00
Benjamin Otte
48fc18c37b gdk: Get rid of GdkDrawingContext
All information is kept in GdkDrawContext these days, so use that one.
2018-04-24 23:16:58 +02:00
Benjamin Otte
c6ae0ff2d1 gdk: Get rid of gdk_drawing_context_get_clip()
Use the identical gdk_draw_context_get_frame_region() instead.
2018-04-24 23:16:58 +02:00
Benjamin Otte
dbe4f1d766 gdk: Add gdk_draw_context_get_frame_region()
This does the same as gdk_drawing_context_get_clip().
2018-04-24 23:16:58 +02:00
Benjamin Otte
e7d6648f46 gdk: Remove gdk_gl_context_get_damage()
Remove it only form public API, because we still use the vfunc to figure
out the damage area in begin_frame().
2018-04-24 23:16:58 +02:00
Benjamin Otte
4aac0760b3 wayland: Rewrite Cairo rendering
Also, split it into its own file - which was the original reason for
looking at this code, the rewrite was an unintentional side effect.

This changes the context to create surfaces on demand.
So whenever the compositor holds onto a surface while GDK wants to
render, it just creates a new surface. If the compositor releases
surfaces, we will retain one for the next frame to be rendered, but free
all extra ones.
This way, we should get to a stage where we have exactly as many
surfaces as needed and never allocate/free any.
2018-04-24 23:16:58 +02:00
Benjamin Otte
03e6cefe73 x11: Move implementation of Cairo context backends
Also, don't implement SurfaceClass.ref_cairo_surface() anymore. This
means calls to it will crash now. But as they only happen in the generic
GdkCairoContext implementation, we shouldn't be affected by that.

Plus, once all backends have been ported, that call is going away
anyway.
2018-04-24 23:16:13 +02:00
Benjamin Otte
c48d78525e surface: Merge function into only caller 2018-04-24 23:16:13 +02:00
Benjamin Otte
899674d445 gdk: Remove GDK_DEBUG=cairo-image
This is the default now - at least until cairo rendering gets split
into backends.
2018-04-24 23:16:13 +02:00
Benjamin Otte
54a83d0288 surface: Fold function into only user 2018-04-24 23:16:12 +02:00
Benjamin Otte
7a6871ea5f cairocontext: Turn cairo_create() function into a vfunc 2018-04-24 23:16:12 +02:00
Benjamin Otte
a6553b0e20 gdk: Remove unused GL setting 2018-04-24 23:16:12 +02:00
Benjamin Otte
813e9c95fb gdk: Add Cairo context implementations for all backends
And make the GdkCairoContext as abstract.

The idea of this and thje following commits is to get rid of all
Cairo code in gdksurface.c (and $backend/gdksurface-$backend.c)
by moving that code into the Cairo context files.
In particular, the GdkSurfaceClass.begin_frame/end_frame()
functions (which are currently exclusively used by the Cairo code
should end up being moved to GdkDrawContextClass.begin/end_frame().

This has multiple benefits:

1. It unifies code between the different drawing contexts.
   GL lives in GLContext, Vulkan in VulkanContext and Cairo in
   CairoContext. In turn, this makes it way easier to reason about
   what's going on in surface-specific code. Currently pretty much
   all backends do things wrong when they want to sync to drawing
   or to the frame clock.

2. It makes the API of GdkSurface smaller. No drawing code (apart
   from creating the contexts) needs to remain.

3. It confines Cairo to the Drawcontext, thereby making it way
   more obvious when backends are still using it in situations
   where it may now conflict with OpenGL (like when doing the dnd
   failed animation or in the APIs that I'm removing in this
   branch).

4. We have 2 very different types of Cairo contexts: The X/win32
   model, where we have a natively supported Cairo backend but do
   double buffering ourselves and use similar surfaces and the
   Wayland/Broadway model where we use image surfaces without any
   Cairo backend support and have to submit the buffers manually.
   By not sharing code between those 2 versions, we can make the
   actual code way smaller. We also get around the need to create
   1x1 image surfaces in the Wayland backend where we pretend
   there's a native Cairo surface.
2018-04-24 23:16:12 +02:00
Benjamin Otte
a83487a0c4 cairocontext: Move a function
A function of GdkDrawingContext is only used when drawing with Cairo, so
move it to GdkCairoContext.
2018-04-24 23:16:12 +02:00
Benjamin Otte
52de880c1c gdk: Move Cairo code from surface to CairoContext
This just moves code, no actual changes to functionality are happening.
2018-04-24 23:16:12 +02:00
Benjamin Otte
f396786051 gdk: Add GdkCairoContext
This does nothing but disallow passing NULL to gdk_surface_begin_paint()
and instead require this context.

The ultimate goal is to split out Cairo drawing into its own source file
so it doesn't clutter up the generic rendering path.
2018-04-24 23:16:12 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Emmanuele Bassi
fc57d3b5a3 wayland: Allow a NULL inhibitors hash table
The shortcuts inhibitors hash table is created when we create a
GdkWaylandWindow implementation for a GdkWindow, and it's destroyed once
we finalize the instance. The fake "root" window we create for the
Wayland display does not have a backing native window, so the shortcuts
inhibitors hash table is set to NULL; this causes a critical error
message when calling g_hash_table_destroy() on it. The finalization of
the root window happens when we close a display connection.

We should use g_clear_pointer(), instead, as it's NULL safe.

Without this change, the displayclose test fails, as all warnings are
considered fatal.
2018-04-23 10:57:07 +01:00
Timm Bäder
8d11e7685a build: Remove 'name' kwarg from has_function calls
They cause warnings with later meson versions.
2018-04-21 19:30:12 +02:00
Timm Bäder
5b453ecd19 Always use #ifdef for G_ENABLE_DEBUG
Release builds don't define it to 0, they just don't define it. Avoid
the compilation warning we get otherwise.
2018-04-21 19:18:20 +02:00
Benjamin Otte
fc6018f192 wayland: Don't freeze the frame clock too early
We can't freeze the frame clock on commit, but only after-paint,
otherwise the frameclock will resume in the paint stage.

So freeze the frame clock at the end of the frame if we are waiting for
a frame callback.

Note; The diff is only lage because of indentation changes due to
avoiding early returns in favor of a branch.
2018-04-13 02:16:10 +02:00
Benjamin Otte
4aab8e970b gdk: Remove gdk_surface_create_similar_image_surface()
It's unused.
2018-04-12 14:04:33 +02:00
Benjamin Otte
7ef8696a7d gdk: Remove gdk_cairo_surface_create_from_pixbuf()
It's unused and people should use textures and snapshots anyway.
2018-04-12 14:04:20 +02:00
Benjamin Otte
3a1c69dce6 gdk: Remove gdk_cairo_get_drawing_context()
It's unused.
2018-04-12 14:03:40 +02:00
Benjamin Otte
770866f265 texture: Add gdk_texture_save_to_png()
It's needed for debugging Timm's code, so better have it here than
hidden in my random-patch vault.
2018-04-12 14:02:59 +02:00
Benjamin Otte
39d930c065 drawingcontext: Remove unused APIs 2018-04-12 14:02:59 +02:00
Руслан Ижбулатов
20f12f9ed7 GDK W32: Fix a missing weak referencing
The changes in a82d67bb7d didn't
preserve a g_object_weak_ref() call that we need to ensure the
objects in hash map don't become stale. Fix this.
2018-04-11 16:39:34 +00:00
Emmanuele Bassi
a2a99d27c9 Simplify the Wayland code generation
Instead of going through an ancillary script to strip away the
`WL_EXPORT` annotation from the generated code, we should bump up the
required version of Wayland, and use the `private-code` argument for
wayland-scanner, which does the right thing for us.
2018-04-11 15:06:43 +01:00
Benjamin Otte
adc0159bdb wayland: Factor out frame timings request code
Also call the code everywhere we draw and not just with Cairo.
2018-04-10 15:13:38 +02:00
Timm Bäder
f24d0725ca vulkancontext: Add new error enum 2018-04-10 09:53:48 +02:00
Timm Bäder
09f04633ca gdk: Protect against negative GDK_SCALE values
Using those should not happen.
2018-04-10 09:43:47 +02:00
Руслан Ижбулатов
27d9f233d4 GDK W32: use clock after_paint signal for timing updates
* Previous commit had misleading info. The code was
added to begin_paint() instead of end_paint(). Though
that did not affect its performance in any visible way.
* Company advised to move the code to an "after_paint" signal
handler, so that it works on all renderers, not just Cairo.
This change caused high fluctuation in FPS values in fishbowl
when it is put in a situation where it cannot achieve 60fps
(such as using Cairo renderer at ultra-high resolution).
This seems to be deliberate and not a bug.
2018-04-09 20:21:16 +00:00
Руслан Ижбулатов
c7ef697029 GDK W32: set update frequency and timestamp
There is no easily apparent way of being notified when frame updates
happene exactly, so we just query frame info at the end of each paint.
If we query too often (faster than DWM refresh rate), we just get
the same values twice in a row, but that is, hopefully, highly unlikely.
2018-04-09 19:07:10 +00:00
Sébastien Villemot
bb8debe925 gdk_x11_display_get_monitor: fix monitor number test logic
When asked for a nonexistent (positive) monitor number,
gdk_x11_display_get_monitor would (at best) return an uninitialized pointer,
instead of returning NULL.
2018-04-09 18:07:14 +02:00
Benjamin Otte
bb8f6f87ae glcontext: Store the buffer age regions in the GL context
That way, we can store the right region there: The actual painted area
instead of the exposed area (which is way too small).

Also, the GL context is the only user of this data, so storing it there
seems way smarter.
2018-04-09 01:00:31 +02:00
Benjamin Otte
c8e38c6065 vulkan: Use new resize vfunc to recreate swapchain
... instead of checking sizes for every frame.
2018-04-09 01:00:31 +02:00
Benjamin Otte
a115f59950 drawcontext: Add a surface_resized() vfunc
Call this vfunc whenever the surface's size has changed.
2018-04-09 01:00:31 +02:00
Benjamin Otte
7ed0c85c61 surface: Track all draw contexts created for the surface 2018-04-09 01:00:31 +02:00
Rico Tzschichholz
ff738269b6 Fix some g-i annotation warnings 2018-04-06 16:26:17 +02:00
Benjamin Otte
c74854fe49 paintable: Introduce gdk_paintable_new_empty()
Also, use it where appropriate.
2018-04-05 14:56:39 +02:00
Benjamin Otte
f1f27ce0c2 broadway: Improve error message
This error message is printed into the journal if a GTK app can't
connect to eithre Wayland or X11. Make it at least mention who is not
capable of connecting to a server.

Unrelated, we might want to improve our error reporting when a GTK app
can't start, so that debugging issues with system startup / login get
easier to resolve.
2018-04-05 14:56:38 +02:00