mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 00:38:06 +02:00
Merge branch 'drop-backends' into 'master'
Remove old backends See merge request cairo/cairo!285
This commit is contained in:
commit
1781e59c57
87 changed files with 14 additions and 41395 deletions
|
|
@ -72,10 +72,8 @@ fedora image:
|
|||
glib2-devel
|
||||
librsvg2-devel
|
||||
gtk2-devel
|
||||
libdrm-devel
|
||||
poppler-glib-devel
|
||||
pixman-devel
|
||||
cogl-devel
|
||||
systemd-devel
|
||||
systemd-udev
|
||||
mesa-libEGL
|
||||
|
|
@ -265,11 +263,13 @@ meson vs2017 amd64:
|
|||
extends: '.build meson windows'
|
||||
variables:
|
||||
ARCH: 'amd64'
|
||||
when: 'manual'
|
||||
|
||||
meson vs2017 x86:
|
||||
extends: '.build meson windows'
|
||||
variables:
|
||||
ARCH: 'x86'
|
||||
when: 'manual'
|
||||
|
||||
meson android arm64 fedora:
|
||||
# TODO: should probably build our own image here some day
|
||||
|
|
|
|||
16
README
16
README
|
|
@ -7,7 +7,7 @@ Cairo is a 2D graphics library with support for multiple output
|
|||
devices. Currently supported output targets include the X Window
|
||||
System (via both Xlib and XCB), quartz, win32, and image buffers,
|
||||
as well as PDF, PostScript, and SVG file output. Experimental backends
|
||||
include OpenGL, BeOS, OS/2, and DirectFB.
|
||||
include OpenGL.
|
||||
|
||||
Cairo is designed to produce consistent output on all output media
|
||||
while taking advantage of display hardware acceleration when available
|
||||
|
|
@ -167,20 +167,6 @@ Font backends (required to have at least one)
|
|||
7.1 or later, including the free Microsoft Visual Studio
|
||||
Express editions, produce correct code.
|
||||
|
||||
Experimental surface backends
|
||||
-----------------------------
|
||||
beos backend
|
||||
------------
|
||||
No dependencies in itself other than an installed BeOS system, but cairo
|
||||
requires a font backend. See the freetype dependency list.
|
||||
|
||||
os2 backend
|
||||
-----------
|
||||
Cairo should run on any recent version of OS/2 or eComStation, but it
|
||||
requires a font backend. See the freetype dependency list. Ready to use
|
||||
packages and developer dependencies are available at Netlabs:
|
||||
ftp://ftp.netlabs.org/pub/cairo
|
||||
|
||||
|
||||
Compiling
|
||||
=========
|
||||
|
|
|
|||
|
|
@ -14,13 +14,7 @@ AM_CPPFLAGS = \
|
|||
$(NULL)
|
||||
AM_LDFLAGS = $(CAIRO_LDFLAGS)
|
||||
|
||||
if BUILD_CXX
|
||||
cxx_boilerplate_lib = libcairoboilerplate_cxx.la
|
||||
else
|
||||
cxx_boilerplate_lib =
|
||||
endif
|
||||
|
||||
EXTRA_LTLIBRARIES += libcairoboilerplate.la $(cxx_boilerplate_lib)
|
||||
EXTRA_LTLIBRARIES += libcairoboilerplate.la
|
||||
|
||||
|
||||
libcairoboilerplate_la_SOURCES = \
|
||||
|
|
@ -29,37 +23,23 @@ libcairoboilerplate_la_SOURCES = \
|
|||
$(enabled_cairo_boilerplate_sources) \
|
||||
cairo-boilerplate-constructors.c \
|
||||
$(NULL)
|
||||
libcairoboilerplate_cxx_la_SOURCES = \
|
||||
$(enabled_cairo_boilerplate_cxx_sources) \
|
||||
$(NULL)
|
||||
libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la \
|
||||
$(cxx_boilerplate_lib) \
|
||||
$(CAIRO_LIBS) \
|
||||
$(CAIROBOILERPLATE_LIBS) \
|
||||
$(NULL)
|
||||
libcairoboilerplate_cxx_la_LIBADD = $(top_builddir)/src/libcairo.la \
|
||||
$(CAIRO_LIBS) \
|
||||
$(CAIROBOILERPLATE_LIBS) \
|
||||
$(NULL)
|
||||
libcairoboilerplate_la_DEPENDENCIES = \
|
||||
$(cxx_boilerplate_lib) \
|
||||
$(NULL)
|
||||
|
||||
if CAIRO_HAS_DL
|
||||
libcairoboilerplate_la_LIBADD += -ldl
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_BEOS_SURFACE
|
||||
# BeOS system headers trigger this warning
|
||||
libcairoboilerplate_cxx_la_CXXFLAGS = -Wno-multichar
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_WIN32_SURFACE
|
||||
libcairoboilerplate_la_LIBADD += -lwinspool
|
||||
endif
|
||||
|
||||
cairo-boilerplate-constructors.c: Makefile $(enabled_cairo_boilerplate_sources) $(enabled_cairo_boilerplate_cxx_sources) make-cairo-boilerplate-constructors.sh
|
||||
(cd $(srcdir) && sh ./make-cairo-boilerplate-constructors.sh $(enabled_cairo_boilerplate_sources) $(enabled_cairo_boilerplate_cxx_sources)) > $@
|
||||
cairo-boilerplate-constructors.c: Makefile $(enabled_cairo_boilerplate_sources) make-cairo-boilerplate-constructors.sh
|
||||
(cd $(srcdir) && sh ./make-cairo-boilerplate-constructors.sh $(enabled_cairo_boilerplate_sources)) > $@
|
||||
|
||||
BUILT_SOURCES += cairo-boilerplate-constructors.c
|
||||
EXTRA_DIST += $(BUILT_SOURCES) make-cairo-boilerplate-constructors.sh
|
||||
|
|
|
|||
|
|
@ -19,23 +19,16 @@ cairo_boilerplate_private = \
|
|||
cairo-boilerplate-private.h \
|
||||
$(NULL)
|
||||
|
||||
cairo_boilerplate_beos_cxx_sources = cairo-boilerplate-beos.cpp
|
||||
cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c
|
||||
cairo_boilerplate_drm_sources = cairo-boilerplate-drm.c
|
||||
cairo_boilerplate_glx_sources = cairo-boilerplate-glx.c
|
||||
cairo_boilerplate_wgl_sources = cairo-boilerplate-wgl.c
|
||||
cairo_boilerplate_egl_sources = cairo-boilerplate-egl.c
|
||||
cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c
|
||||
cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c
|
||||
cairo_boilerplate_qt_cxx_sources = cairo-boilerplate-qt.cpp
|
||||
cairo_boilerplate_quartz_sources = cairo-boilerplate-quartz.c
|
||||
cairo_boilerplate_script_sources = cairo-boilerplate-script.c
|
||||
cairo_boilerplate_skia_sources = cairo-boilerplate-skia.c
|
||||
cairo_boilerplate_svg_sources = cairo-boilerplate-svg.c
|
||||
cairo_boilerplate_test_surfaces_sources = cairo-boilerplate-test-surfaces.c
|
||||
cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-win32-printing.c
|
||||
cairo_boilerplate_xcb_sources = cairo-boilerplate-xcb.c
|
||||
cairo_boilerplate_xlib_headers = cairo-boilerplate-xlib.h
|
||||
cairo_boilerplate_xlib_sources = cairo-boilerplate-xlib.c
|
||||
cairo_boilerplate_vg_sources = cairo-boilerplate-vg.c
|
||||
cairo_boilerplate_cogl_sources = cairo-boilerplate-cogl.c
|
||||
|
|
|
|||
|
|
@ -10,514 +10,344 @@ supported_cairo_boilerplate_headers = $(cairo_boilerplate_headers)
|
|||
unsupported_cairo_boilerplate_headers =
|
||||
all_cairo_boilerplate_headers = $(cairo_boilerplate_headers)
|
||||
all_cairo_boilerplate_private = $(cairo_boilerplate_private)
|
||||
all_cairo_boilerplate_cxx_sources = $(cairo_boilerplate_cxx_sources)
|
||||
all_cairo_boilerplate_sources = $(cairo_boilerplate_sources)
|
||||
|
||||
enabled_cairo_boilerplate_headers = $(cairo_boilerplate_headers)
|
||||
enabled_cairo_boilerplate_private = $(cairo_boilerplate_private)
|
||||
enabled_cairo_boilerplate_cxx_sources = $(cairo_boilerplate_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources = $(cairo_boilerplate_sources)
|
||||
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_xlib_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_sources)
|
||||
ifeq ($(CAIRO_HAS_XLIB_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xrender_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xrender_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xrender_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xrender_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xrender_sources)
|
||||
ifeq ($(CAIRO_HAS_XLIB_XRENDER_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xrender_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xrender_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xrender_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xrender_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_xcb_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_sources)
|
||||
ifeq ($(CAIRO_HAS_XCB_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xcb_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xcb_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xcb_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xcb_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xcb_sources)
|
||||
ifeq ($(CAIRO_HAS_XLIB_XCB_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xlib_xcb_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xcb_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xlib_xcb_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xcb_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_xcb_shm_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_shm_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_shm_sources)
|
||||
ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_shm_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_shm_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_shm_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_qt_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_qt_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_qt_sources)
|
||||
ifeq ($(CAIRO_HAS_QT_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_qt_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_qt_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_qt_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_sources)
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_quartz_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_font_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_font_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_font_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_font_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_font_sources)
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_FONT),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_font_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_quartz_font_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_font_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_font_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_image_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_image_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_image_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_image_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_image_sources)
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_IMAGE_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_image_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_quartz_image_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_quartz_image_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_quartz_image_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_win32_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_win32_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_win32_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_win32_sources)
|
||||
ifeq ($(CAIRO_HAS_WIN32_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_win32_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_font_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources)
|
||||
ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_win32_font_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_win32_font_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_os2_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_os2_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_os2_sources)
|
||||
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_os2_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_os2_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_os2_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_beos_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_beos_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_beos_sources)
|
||||
ifeq ($(CAIRO_HAS_BEOS_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_beos_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_beos_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_beos_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_drm_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources)
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_drm_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gallium_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources)
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gallium_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_png_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_png_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_png_sources)
|
||||
ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_png_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_png_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_png_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_gl_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gl_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources)
|
||||
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gl_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_gl_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gl_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gl_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glesv2_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_glesv2_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_glesv2_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv2_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_glesv2_sources)
|
||||
ifeq ($(CAIRO_HAS_GLESV2_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glesv2_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_glesv2_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv2_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glesv2_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_glesv3_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv3_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_glesv3_sources)
|
||||
ifeq ($(CAIRO_HAS_GLESV3_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_glesv3_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv3_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glesv3_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_cogl_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_cogl_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_cogl_sources)
|
||||
ifeq ($(CAIRO_HAS_COGL_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_cogl_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_cogl_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_cogl_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_directfb_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_directfb_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_directfb_sources)
|
||||
ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_directfb_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_directfb_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_directfb_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_directfb_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_vg_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_vg_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_vg_sources)
|
||||
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_vg_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_vg_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_vg_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_vg_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_egl_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_egl_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_egl_sources)
|
||||
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_egl_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_egl_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_egl_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_egl_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_glx_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glx_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_glx_sources)
|
||||
ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glx_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_glx_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glx_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glx_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_wgl_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_wgl_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_wgl_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_wgl_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_wgl_sources)
|
||||
ifeq ($(CAIRO_HAS_WGL_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_wgl_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_wgl_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_wgl_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_wgl_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_script_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_script_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_script_sources)
|
||||
ifeq ($(CAIRO_HAS_SCRIPT_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_script_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_script_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_script_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_script_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_ft_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_ft_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_ft_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ft_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_ft_sources)
|
||||
ifeq ($(CAIRO_HAS_FT_FONT),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_ft_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_ft_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ft_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ft_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_fc_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_fc_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_fc_sources)
|
||||
ifeq ($(CAIRO_HAS_FC_FONT),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_fc_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_fc_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_fc_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_ps_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ps_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_ps_sources)
|
||||
ifeq ($(CAIRO_HAS_PS_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_ps_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ps_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ps_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_pdf_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pdf_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_pdf_sources)
|
||||
ifeq ($(CAIRO_HAS_PDF_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_pdf_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_pdf_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pdf_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_pdf_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_svg_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_svg_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_svg_sources)
|
||||
ifeq ($(CAIRO_HAS_SVG_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_svg_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_svg_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_svg_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_svg_sources)
|
||||
endif
|
||||
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_test_surfaces_private) $(cairo_boilerplate_test_surfaces_headers)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_test_surfaces_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_test_surfaces_sources)
|
||||
ifeq ($(CAIRO_HAS_TEST_SURFACES),1)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_test_surfaces_private) $(cairo_boilerplate_test_surfaces_headers)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_test_surfaces_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_test_surfaces_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_image_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_image_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_image_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_image_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_image_sources)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_image_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_image_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_image_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_image_sources)
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_mime_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_mime_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_mime_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_mime_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_mime_sources)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_mime_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_mime_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_mime_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_mime_sources)
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_recording_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_recording_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_recording_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_recording_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_recording_sources)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_recording_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_recording_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_recording_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_recording_sources)
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_observer_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_observer_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_observer_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_observer_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_observer_sources)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_observer_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_observer_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_observer_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_observer_sources)
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_tee_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_tee_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_tee_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_tee_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_tee_sources)
|
||||
ifeq ($(CAIRO_HAS_TEE_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_tee_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_tee_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_tee_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_tee_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_xml_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_xml_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_xml_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xml_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_xml_sources)
|
||||
ifeq ($(CAIRO_HAS_XML_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xml_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_xml_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xml_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xml_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_user_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_user_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_user_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_user_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_user_sources)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_user_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_user_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_user_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_user_sources)
|
||||
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_pthread_private) $(cairo_boilerplate_pthread_headers)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pthread_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_pthread_sources)
|
||||
ifeq ($(CAIRO_HAS_PTHREAD),1)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_pthread_private) $(cairo_boilerplate_pthread_headers)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pthread_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_pthread_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_gobject_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_gobject_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_gobject_private)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gobject_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_gobject_sources)
|
||||
ifeq ($(CAIRO_HAS_GOBJECT_FUNCTIONS),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gobject_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_gobject_private)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gobject_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gobject_sources)
|
||||
endif
|
||||
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_trace_private) $(cairo_boilerplate_trace_headers)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_trace_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_trace_sources)
|
||||
ifeq ($(CAIRO_HAS_TRACE),1)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_trace_private) $(cairo_boilerplate_trace_headers)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_trace_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_trace_sources)
|
||||
endif
|
||||
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_interpreter_private) $(cairo_boilerplate_interpreter_headers)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_interpreter_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_interpreter_sources)
|
||||
ifeq ($(CAIRO_HAS_INTERPRETER),1)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_interpreter_private) $(cairo_boilerplate_interpreter_headers)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_interpreter_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_interpreter_sources)
|
||||
endif
|
||||
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_symbol_lookup_private) $(cairo_boilerplate_symbol_lookup_headers)
|
||||
all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_symbol_lookup_cxx_sources)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_symbol_lookup_sources)
|
||||
ifeq ($(CAIRO_HAS_SYMBOL_LOOKUP),1)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_symbol_lookup_private) $(cairo_boilerplate_symbol_lookup_headers)
|
||||
enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_symbol_lookup_cxx_sources)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_symbol_lookup_sources)
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,273 +0,0 @@
|
|||
/* vim:set ts=8 sw=4 noet cin: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Takashi Toyoshima <toyoshim@be-in.org>
|
||||
* Fredrik Holmqvist <thesuckiestemail@yahoo.se>
|
||||
* Christian Biesinger <cbiesinger@web.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "cairo-boilerplate.h"
|
||||
#include <cairo-beos.h>
|
||||
|
||||
// Part of this code was originally part of
|
||||
// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include <Bitmap.h>
|
||||
|
||||
class CairoTestWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
CairoTestWindow(BRect frame, const char* title);
|
||||
virtual ~CairoTestWindow();
|
||||
BView* View() const { return mView; }
|
||||
private:
|
||||
BView* mView;
|
||||
};
|
||||
|
||||
CairoTestWindow::CairoTestWindow(BRect frame, const char* title)
|
||||
: BWindow(frame, title, B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
||||
{
|
||||
mView = new BView(frame, "CairoWindowTestView", B_FOLLOW_ALL_SIDES, 0);
|
||||
AddChild(mView);
|
||||
Show();
|
||||
|
||||
// Make sure the window is actually on screen
|
||||
Lock();
|
||||
Sync();
|
||||
mView->SetViewColor(B_TRANSPARENT_COLOR);
|
||||
mView->Sync();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
CairoTestWindow::~CairoTestWindow()
|
||||
{
|
||||
RemoveChild(mView);
|
||||
delete mView;
|
||||
}
|
||||
|
||||
|
||||
class nsBeOSApp : public BApplication
|
||||
{
|
||||
public:
|
||||
nsBeOSApp(sem_id sem) : BApplication(GetAppSig()), init(sem)
|
||||
{}
|
||||
|
||||
void ReadyToRun()
|
||||
{
|
||||
release_sem(init);
|
||||
}
|
||||
|
||||
static int32 Main(void *args)
|
||||
{
|
||||
nsBeOSApp *app = new nsBeOSApp( (sem_id)args );
|
||||
if(app == NULL)
|
||||
return B_ERROR;
|
||||
return app->Run();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const char *GetAppSig()
|
||||
{
|
||||
return "application/x-vnd.cairo-test-app";
|
||||
}
|
||||
|
||||
sem_id init;
|
||||
}; //class nsBeOSApp
|
||||
|
||||
class AppRunner
|
||||
{
|
||||
public:
|
||||
AppRunner();
|
||||
~AppRunner();
|
||||
};
|
||||
|
||||
AppRunner::AppRunner()
|
||||
{
|
||||
if (be_app)
|
||||
return;
|
||||
|
||||
sem_id initsem = create_sem(0, "Cairo BApplication init");
|
||||
if (initsem < B_OK) {
|
||||
fprintf (stderr, "Error creating BeOS initialization semaphore\n");
|
||||
return;
|
||||
}
|
||||
|
||||
thread_id tid = spawn_thread(nsBeOSApp::Main, "Cairo/BeOS test", B_NORMAL_PRIORITY, (void *)initsem);
|
||||
if (tid < B_OK || B_OK != resume_thread(tid)) {
|
||||
fprintf (stderr, "Error spawning thread\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (B_OK != acquire_sem(initsem)) {
|
||||
fprintf (stderr, "Error acquiring semaphore\n");
|
||||
return;
|
||||
}
|
||||
|
||||
delete_sem(initsem);
|
||||
return;
|
||||
}
|
||||
|
||||
AppRunner::~AppRunner()
|
||||
{
|
||||
if (be_app) {
|
||||
if (be_app->Lock())
|
||||
be_app->Quit();
|
||||
delete be_app;
|
||||
be_app = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that the BApplication is initialized
|
||||
static AppRunner sAppRunner;
|
||||
|
||||
struct beos_boilerplate_closure {
|
||||
BView* view;
|
||||
BBitmap* bitmap;
|
||||
BWindow* window;
|
||||
};
|
||||
|
||||
// Test a real window
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_beos_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
float right = width ? width - 1 : 0;
|
||||
float bottom = height ? height - 1 : 0;
|
||||
BRect rect(0.0, 0.0, right, bottom);
|
||||
CairoTestWindow* wnd = new CairoTestWindow(rect, name);
|
||||
|
||||
beos_boilerplate_closure* bclosure = new beos_boilerplate_closure;
|
||||
bclosure->view = wnd->View();
|
||||
bclosure->bitmap = NULL;
|
||||
bclosure->window = wnd;
|
||||
|
||||
*closure = bclosure;
|
||||
|
||||
return cairo_beos_surface_create(wnd->View());
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_beos_cleanup (void *closure)
|
||||
{
|
||||
beos_boilerplate_closure* bclosure = reinterpret_cast<beos_boilerplate_closure*>(closure);
|
||||
|
||||
bclosure->window->Lock();
|
||||
bclosure->window->Quit();
|
||||
|
||||
delete bclosure;
|
||||
}
|
||||
|
||||
// Test a bitmap
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_beos_create_surface_for_bitmap (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
BRect rect(0.0, 0.0, width - 1, height - 1);
|
||||
color_space beosformat = (content == CAIRO_CONTENT_COLOR_ALPHA) ? B_RGBA32
|
||||
: B_RGB32;
|
||||
BBitmap* bmp = new BBitmap(rect, beosformat, true);
|
||||
BView* view = new BView(rect, "Cairo test view", B_FOLLOW_ALL_SIDES, 0);
|
||||
bmp->AddChild(view);
|
||||
|
||||
beos_boilerplate_closure* bclosure = new beos_boilerplate_closure;
|
||||
bclosure->view = view;
|
||||
bclosure->bitmap = bmp;
|
||||
bclosure->window = NULL;
|
||||
*closure = bclosure;
|
||||
|
||||
return cairo_beos_surface_create_for_bitmap(view, bmp);
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_beos_cleanup_bitmap (void *closure)
|
||||
{
|
||||
beos_boilerplate_closure* bclosure = reinterpret_cast<beos_boilerplate_closure*>(closure);
|
||||
|
||||
bclosure->bitmap->RemoveChild(bclosure->view);
|
||||
|
||||
|
||||
delete bclosure->view;
|
||||
delete bclosure->bitmap;
|
||||
|
||||
delete bclosure;
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
/* BeOS sometimes produces a slightly different image. Perhaps this
|
||||
* is related to the fact that it doesn't use premultiplied alpha...
|
||||
* Just ignore the small difference. */
|
||||
{
|
||||
"beos", "beos", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
|
||||
_cairo_boilerplate_beos_create_surface,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_beos_cleanup
|
||||
},
|
||||
{
|
||||
"beos-bitmap", "beos", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
|
||||
_cairo_boilerplate_beos_create_surface_for_bitmap,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_beos_cleanup_bitmap
|
||||
},
|
||||
{
|
||||
"beos-bitmap", "beos", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
_cairo_boilerplate_beos_create_surface_for_bitmap,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_beos_cleanup_bitmap
|
||||
},
|
||||
};
|
||||
CAIRO_BOILERPLATE (beos, targets)
|
||||
|
||||
|
|
@ -1,217 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
#include "cairo-malloc-private.h"
|
||||
|
||||
#include <cairo-cogl.h>
|
||||
#include <cogl/cogl2-experimental.h>
|
||||
|
||||
typedef struct _cogl_closure {
|
||||
cairo_device_t *device;
|
||||
cairo_surface_t *surface;
|
||||
} cogl_closure_t;
|
||||
|
||||
static const cairo_user_data_key_t cogl_closure_key;
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_cogl_cleanup (void *abstract_closure)
|
||||
{
|
||||
cogl_closure_t *closure = abstract_closure;
|
||||
|
||||
cairo_device_finish (closure->device);
|
||||
cairo_device_destroy (closure->device);
|
||||
|
||||
free (closure);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_cogl_create_offscreen_color_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **abstract_closure)
|
||||
{
|
||||
CoglContext *context;
|
||||
cairo_device_t *device;
|
||||
cogl_closure_t *closure;
|
||||
cairo_status_t status;
|
||||
|
||||
if (width < 1)
|
||||
width = 1;
|
||||
if (height < 1)
|
||||
height = 1;
|
||||
|
||||
context = cogl_context_new (NULL, NULL);
|
||||
|
||||
device = cairo_cogl_device_create (context);
|
||||
|
||||
/* The device will take a reference on the context */
|
||||
cogl_object_unref (context);
|
||||
|
||||
closure = _cairo_malloc (sizeof (cogl_closure_t));
|
||||
*abstract_closure = closure;
|
||||
closure->device = device;
|
||||
closure->surface = cairo_cogl_offscreen_surface_create (device,
|
||||
content,
|
||||
width,
|
||||
height);
|
||||
|
||||
status = cairo_surface_set_user_data (closure->surface,
|
||||
&cogl_closure_key, closure, NULL);
|
||||
if (status == CAIRO_STATUS_SUCCESS)
|
||||
return closure->surface;
|
||||
|
||||
_cairo_boilerplate_cogl_cleanup (closure);
|
||||
return cairo_boilerplate_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_cogl_create_onscreen_color_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **abstract_closure)
|
||||
{
|
||||
CoglContext *context;
|
||||
cairo_device_t *device;
|
||||
cogl_closure_t *closure;
|
||||
cairo_status_t status;
|
||||
|
||||
if (width < 1)
|
||||
width = 1;
|
||||
if (height < 1)
|
||||
height = 1;
|
||||
|
||||
if (content & CAIRO_CONTENT_ALPHA) {
|
||||
/* A hackish way to ensure that we get a framebuffer with
|
||||
* an alpha component */
|
||||
CoglSwapChain *swap_chain;
|
||||
CoglOnscreenTemplate *onscreen_template;
|
||||
CoglRenderer *renderer;
|
||||
CoglDisplay *display;
|
||||
|
||||
swap_chain = cogl_swap_chain_new ();
|
||||
cogl_swap_chain_set_has_alpha (swap_chain, TRUE);
|
||||
|
||||
onscreen_template = cogl_onscreen_template_new (swap_chain);
|
||||
renderer = cogl_renderer_new ();
|
||||
display = cogl_display_new (renderer, onscreen_template);
|
||||
|
||||
/* References will be taken on the swap chain, renderer, and
|
||||
* onscreen template by the constructors */
|
||||
cogl_object_unref (swap_chain);
|
||||
cogl_object_unref (renderer);
|
||||
cogl_object_unref (onscreen_template);
|
||||
|
||||
context = cogl_context_new (display, NULL);
|
||||
|
||||
/* The context will take a reference on the display */
|
||||
cogl_object_unref (display);
|
||||
} else {
|
||||
context = cogl_context_new (NULL, NULL);
|
||||
}
|
||||
|
||||
device = cairo_cogl_device_create (context);
|
||||
|
||||
/* The device will take a reference on the context */
|
||||
cogl_object_unref (context);
|
||||
|
||||
closure = _cairo_malloc (sizeof (cogl_closure_t));
|
||||
*abstract_closure = closure;
|
||||
closure->device = device;
|
||||
closure->surface = cairo_cogl_onscreen_surface_create (device,
|
||||
content,
|
||||
width,
|
||||
height);
|
||||
|
||||
status = cairo_surface_set_user_data (closure->surface,
|
||||
&cogl_closure_key, closure, NULL);
|
||||
if (status == CAIRO_STATUS_SUCCESS)
|
||||
return closure->surface;
|
||||
|
||||
_cairo_boilerplate_cogl_cleanup (closure);
|
||||
return cairo_boilerplate_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_boilerplate_cogl_finish (cairo_surface_t *surface)
|
||||
{
|
||||
return cairo_cogl_surface_end_frame (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_cogl_synchronize (void *abstract_closure)
|
||||
{
|
||||
cogl_closure_t *closure = abstract_closure;
|
||||
cairo_cogl_surface_synchronize (closure->surface);
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
{
|
||||
"cogl-offscreen-color", "cogl", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_COGL, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
"cairo_cogl_device_create",
|
||||
_cairo_boilerplate_cogl_create_offscreen_color_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL,
|
||||
_cairo_boilerplate_cogl_finish,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_cogl_cleanup,
|
||||
_cairo_boilerplate_cogl_synchronize,
|
||||
NULL,
|
||||
TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"cogl-onscreen-color", "cogl", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_COGL, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
"cairo_cogl_device_create",
|
||||
_cairo_boilerplate_cogl_create_onscreen_color_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL,
|
||||
_cairo_boilerplate_cogl_finish,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_cogl_cleanup,
|
||||
_cairo_boilerplate_cogl_synchronize,
|
||||
NULL,
|
||||
TRUE, FALSE, FALSE
|
||||
}
|
||||
};
|
||||
CAIRO_BOILERPLATE (cogl, targets)
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
/*
|
||||
Test were run with the following script
|
||||
target can be directfb_bitmap or directfb
|
||||
|
||||
export CAIRO_TEST_TARGET=directfb_bitmap
|
||||
export DFBARGS=quiet,no-banner,no-debug,log-file=dfblog,system=x11
|
||||
cd cairo/test
|
||||
make check
|
||||
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
|
||||
#include <cairo-directfb.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <direct/debug.h>
|
||||
|
||||
D_DEBUG_DOMAIN (CairoDFB_Boiler, "CairoDFB/Boiler", "Cairo DirectFB Boilerplate");
|
||||
|
||||
/* macro for a safe call to DirectFB functions */
|
||||
#define DFBCHECK(x...) do{ \
|
||||
err = x; \
|
||||
if (err != DFB_OK) { \
|
||||
fprintf (stderr, "%s <%d>:\n\t", __FILE__, __LINE__); \
|
||||
goto ERROR; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct _DFBInfo {
|
||||
IDirectFB *dfb;
|
||||
IDirectFBDisplayLayer *layer;
|
||||
IDirectFBWindow *window;
|
||||
IDirectFBSurface *surface;
|
||||
} DFBInfo;
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_directfb_cleanup (void *closure)
|
||||
{
|
||||
DFBInfo *info = (DFBInfo *) closure;
|
||||
|
||||
if (info->surface)
|
||||
info->surface->Release (info->surface);
|
||||
|
||||
if (info->window)
|
||||
info->window->Release (info->window);
|
||||
|
||||
if (info->layer)
|
||||
info->layer->Release (info->layer);
|
||||
|
||||
if (info->dfb)
|
||||
info->dfb->Release (info->dfb);
|
||||
|
||||
free (info);
|
||||
}
|
||||
|
||||
static DFBInfo *
|
||||
init (void)
|
||||
{
|
||||
DFBDisplayLayerConfig layer_config;
|
||||
DFBGraphicsDeviceDescription desc;
|
||||
int err;
|
||||
DFBInfo *info;
|
||||
|
||||
info = xcalloc (1, sizeof (DFBInfo));
|
||||
if (info == NULL)
|
||||
return NULL;
|
||||
|
||||
DFBCHECK (DirectFBInit (NULL, NULL));
|
||||
DFBCHECK (DirectFBCreate (&info->dfb));
|
||||
info->dfb->GetDeviceDescription (info->dfb, &desc);
|
||||
|
||||
DFBCHECK (info->dfb->GetDisplayLayer (info->dfb,
|
||||
DLID_PRIMARY, &info->layer));
|
||||
info->layer->SetCooperativeLevel (info->layer, DLSCL_ADMINISTRATIVE);
|
||||
|
||||
if ((desc.blitting_flags & (DSBLIT_BLEND_ALPHACHANNEL |
|
||||
DSBLIT_BLEND_COLORALPHA)) !=
|
||||
(DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_BLEND_COLORALPHA))
|
||||
{
|
||||
layer_config.flags = DLCONF_BUFFERMODE;
|
||||
layer_config.buffermode = DLBM_BACKSYSTEM;
|
||||
info->layer->SetConfiguration (info->layer, &layer_config);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
ERROR:
|
||||
if (info != NULL)
|
||||
_cairo_boilerplate_directfb_cleanup (info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_directfb_window_create_surface (DFBInfo *info,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
DFBWindowDescription desc;
|
||||
int err;
|
||||
|
||||
D_DEBUG_AT (CairoDFB_Boiler, "%s (%p, %s, %dx%d)\n", __FUNCTION__, info,
|
||||
content == CAIRO_CONTENT_ALPHA ? "ALPHA" :
|
||||
content == CAIRO_CONTENT_COLOR ? "RGB" :
|
||||
content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB" : "unknown content!",
|
||||
width, height);
|
||||
|
||||
desc.flags = DWDESC_POSX | DWDESC_POSY |
|
||||
DWDESC_WIDTH | DWDESC_HEIGHT;
|
||||
desc.caps = DSCAPS_NONE;
|
||||
desc.posx = 0;
|
||||
desc.posy = 0;
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
if (content == CAIRO_CONTENT_COLOR_ALPHA) {
|
||||
desc.flags |= DWDESC_CAPS | DWDESC_PIXELFORMAT;
|
||||
desc.caps |= DWCAPS_DOUBLEBUFFER | DWCAPS_ALPHACHANNEL;
|
||||
desc.pixelformat = DSPF_ARGB;
|
||||
}
|
||||
|
||||
DFBCHECK (info->layer->CreateWindow (info->layer, &desc, &info->window));
|
||||
info->window->SetOpacity (info->window, 0xFF);
|
||||
info->window->GetSurface (info->window, &info->surface);
|
||||
info->surface->SetColor (info->surface, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
info->surface->FillRectangle (info->surface,0, 0, desc.width, desc.height);
|
||||
info->surface->Flip (info->surface, NULL, 0);
|
||||
|
||||
return cairo_directfb_surface_create (info->dfb, info->surface);
|
||||
|
||||
ERROR:
|
||||
_cairo_boilerplate_directfb_cleanup (info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_directfb_bitmap_create_surface (DFBInfo *info,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
int err;
|
||||
DFBSurfaceDescription desc;
|
||||
|
||||
D_DEBUG_AT (CairoDFB_Boiler, "%s (%p, %s, %dx%d)\n", __FUNCTION__, info,
|
||||
content == CAIRO_CONTENT_ALPHA ? "ALPHA" :
|
||||
content == CAIRO_CONTENT_COLOR ? "RGB" :
|
||||
content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB" : "unknown content!",
|
||||
width, height);
|
||||
|
||||
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
|
||||
desc.caps = DSCAPS_NONE;
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
if (content == CAIRO_CONTENT_COLOR_ALPHA) {
|
||||
desc.flags |= DSDESC_PIXELFORMAT;
|
||||
desc.pixelformat = DSPF_ARGB;
|
||||
}
|
||||
DFBCHECK (info->dfb->CreateSurface (info->dfb, &desc, &info->surface));
|
||||
|
||||
return cairo_directfb_surface_create (info->dfb, info->surface);
|
||||
|
||||
ERROR:
|
||||
_cairo_boilerplate_directfb_cleanup (info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_directfb_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
|
||||
DFBInfo *info;
|
||||
|
||||
info = init ();
|
||||
if (info == NULL)
|
||||
return NULL;
|
||||
|
||||
*closure = info;
|
||||
|
||||
D_DEBUG_AT (CairoDFB_Boiler, "%s ('%s', %s, %dx%d, %s)\n",
|
||||
__FUNCTION__, name,
|
||||
content == CAIRO_CONTENT_ALPHA ? "ALPHA" :
|
||||
content == CAIRO_CONTENT_COLOR ? "RGB" :
|
||||
content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB" : "unknown content!",
|
||||
width, height,
|
||||
mode == CAIRO_BOILERPLATE_MODE_TEST ? "TEST" :
|
||||
mode == CAIRO_BOILERPLATE_MODE_PERF ? "PERF" : "unknown mode!");
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
|
||||
return _cairo_boilerplate_directfb_bitmap_create_surface (info, content, width, height);
|
||||
else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
|
||||
return _cairo_boilerplate_directfb_window_create_surface (info, content, width, height);
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
{
|
||||
"directfb", "directfb", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0,
|
||||
"cairo_directfb_surface_create",
|
||||
_cairo_boilerplate_directfb_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_directfb_cleanup,
|
||||
NULL, NULL, TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"directfb-bitmap", "directfb", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA, 0,
|
||||
"cairo_directfb_surface_create",
|
||||
_cairo_boilerplate_directfb_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_directfb_cleanup,
|
||||
NULL, NULL, FALSE, FALSE, FALSE
|
||||
},
|
||||
};
|
||||
CAIRO_BOILERPLATE (directfb, targets);
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
|
||||
#include <cairo-drm.h>
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_drm_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
cairo_device_t *device;
|
||||
cairo_format_t format;
|
||||
|
||||
device = cairo_drm_device_default ();
|
||||
if (device == NULL)
|
||||
return NULL; /* skip tests if no supported h/w found */
|
||||
|
||||
switch (content) {
|
||||
case CAIRO_CONTENT_ALPHA:
|
||||
format = CAIRO_FORMAT_A8;
|
||||
break;
|
||||
case CAIRO_CONTENT_COLOR:
|
||||
format = CAIRO_FORMAT_RGB24;
|
||||
break;
|
||||
case CAIRO_CONTENT_COLOR_ALPHA:
|
||||
default:
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
break;
|
||||
}
|
||||
|
||||
return *closure = cairo_drm_surface_create (device, format, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_drm_synchronize (void *closure)
|
||||
{
|
||||
cairo_surface_t *image;
|
||||
|
||||
image = cairo_drm_surface_map_to_image (closure);
|
||||
if (cairo_surface_status (image) == CAIRO_STATUS_SUCCESS)
|
||||
cairo_drm_surface_unmap (closure, image);
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
/* Acceleration architectures may make the results differ by a
|
||||
* bit, so we set the error tolerance to 1. */
|
||||
{
|
||||
"drm", "drm", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_DRM, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
"cairo_drm_surface_create",
|
||||
_cairo_boilerplate_drm_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
NULL,
|
||||
_cairo_boilerplate_drm_synchronize,
|
||||
NULL,
|
||||
TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"drm", "drm", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_DRM, CAIRO_CONTENT_COLOR, 1,
|
||||
"cairo_drm_surface_create",
|
||||
_cairo_boilerplate_drm_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
NULL,
|
||||
_cairo_boilerplate_drm_synchronize,
|
||||
NULL,
|
||||
FALSE, FALSE, FALSE
|
||||
},
|
||||
};
|
||||
CAIRO_BOILERPLATE (drm, targets)
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
|
||||
#include <cairo-qt.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
typedef struct _qt_closure {
|
||||
Display *dpy;
|
||||
QApplication *app;
|
||||
} qt_closure_t;
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_qt_cleanup (void *closure)
|
||||
{
|
||||
qt_closure_t *qtc = (qt_closure_t *) closure;
|
||||
|
||||
delete qtc->app;
|
||||
XCloseDisplay (qtc->dpy);
|
||||
free (qtc);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_qt_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
qt_closure_t *qtc;
|
||||
|
||||
qtc = (qt_closure_t *) xcalloc (1, sizeof (qt_closure_t));
|
||||
qtc->dpy = XOpenDisplay (NULL);
|
||||
if (qtc->dpy == NULL) {
|
||||
free (qtc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
|
||||
XSynchronize (qtc->dpy, True);
|
||||
|
||||
qtc->app = new QApplication (qtc->dpy);
|
||||
*closure = qtc;
|
||||
return cairo_qt_surface_create_with_qpixmap (content, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_qt_synchronize (void *closure)
|
||||
{
|
||||
qt_closure_t *qtc = (qt_closure_t *) closure;
|
||||
|
||||
qtc->app->flush (); /* not sure if this is sufficient */
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
{
|
||||
"qt", "qt", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0,
|
||||
"cairo_qt_surface_create",
|
||||
_cairo_boilerplate_qt_create_surface,
|
||||
NULL, NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_qt_cleanup
|
||||
},
|
||||
{
|
||||
"qt", "qt", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0,
|
||||
"cairo_qt_surface_create",
|
||||
_cairo_boilerplate_qt_create_surface,
|
||||
NULL, NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_qt_cleanup
|
||||
},
|
||||
};
|
||||
extern "C" {
|
||||
CAIRO_BOILERPLATE (qt, targets)
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
|
||||
#include <cairo-skia.h>
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_skia_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
cairo_format_t format;
|
||||
|
||||
*closure = NULL;
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR_ALPHA) {
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
} else if (content == CAIRO_CONTENT_COLOR) {
|
||||
format = CAIRO_FORMAT_RGB24;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cairo_skia_surface_create (format, width, height);
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
{
|
||||
"skia", "skia", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_SKIA, CAIRO_CONTENT_COLOR_ALPHA, 0,
|
||||
"cairo_skia_surface_create",
|
||||
_cairo_boilerplate_skia_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
NULL, NULL, NULL, TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"skia", "skia", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_SKIA, CAIRO_CONTENT_COLOR, 0,
|
||||
"cairo_skia_surface_create",
|
||||
_cairo_boilerplate_skia_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
NULL, NULL, NULL, FALSE, FALSE, FALSE
|
||||
},
|
||||
};
|
||||
CAIRO_BOILERPLATE (skia, targets)
|
||||
|
|
@ -1,364 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
#include "cairo-malloc-private.h"
|
||||
|
||||
#include <cairo-vg.h>
|
||||
|
||||
/* XXX Not sure how to handle library specific context initialization */
|
||||
//#define USE_SHIVA
|
||||
//#define USE_AMANITH
|
||||
|
||||
#if CAIRO_HAS_GLX_FUNCTIONS
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
typedef struct _vg_closure {
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window win;
|
||||
|
||||
GLXContext ctx;
|
||||
cairo_surface_t *surface;
|
||||
} vg_closure_glx_t;
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_vg_cleanup_glx (void *closure)
|
||||
{
|
||||
vg_closure_glx_t *vgc = closure;
|
||||
|
||||
#ifdef USE_AMANITH
|
||||
vgDestroyContextAM ();
|
||||
#endif
|
||||
#ifdef USE_SHIVA
|
||||
vgDestroyContextSH ();
|
||||
#endif
|
||||
|
||||
glXDestroyContext (vgc->dpy, vgc->ctx);
|
||||
XDestroyWindow (vgc->dpy, vgc->win);
|
||||
XCloseDisplay (vgc->dpy);
|
||||
free (vgc);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_vg_create_surface_glx (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
int rgba_attribs[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_ALPHA_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_NONE
|
||||
};
|
||||
int rgb_attribs[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_NONE
|
||||
};
|
||||
XVisualInfo *vi;
|
||||
Display *dpy;
|
||||
Colormap cmap;
|
||||
XSetWindowAttributes swa;
|
||||
cairo_surface_t *surface;
|
||||
cairo_vg_context_t *context;
|
||||
vg_closure_glx_t *vgc;
|
||||
|
||||
vgc = _cairo_malloc (sizeof (vg_closure_glx_t));
|
||||
*closure = vgc;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
dpy = XOpenDisplay (NULL);
|
||||
vgc->dpy = dpy;
|
||||
if (vgc->dpy == NULL) {
|
||||
fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
|
||||
free (vgc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR)
|
||||
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgb_attribs);
|
||||
else
|
||||
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
|
||||
|
||||
if (vi == NULL) {
|
||||
fprintf (stderr, "Failed to create RGB, double-buffered visual\n");
|
||||
XCloseDisplay (dpy);
|
||||
free (vgc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vgc->ctx = glXCreateContext (dpy, vi, NULL, True);
|
||||
cmap = XCreateColormap (dpy,
|
||||
RootWindow (dpy, vi->screen),
|
||||
vi->visual,
|
||||
AllocNone);
|
||||
swa.colormap = cmap;
|
||||
swa.border_pixel = 0;
|
||||
vgc->win = XCreateWindow (dpy, RootWindow (dpy, vi->screen),
|
||||
-1, -1, 1, 1, 0,
|
||||
vi->depth,
|
||||
InputOutput,
|
||||
vi->visual,
|
||||
CWBorderPixel | CWColormap, &swa);
|
||||
XFreeColormap (dpy, cmap);
|
||||
XFree (vi);
|
||||
|
||||
XMapWindow (dpy, vgc->win);
|
||||
|
||||
/* we need an active context to initialise VG */
|
||||
glXMakeContextCurrent (dpy, vgc->win, vgc->win, vgc->ctx);
|
||||
|
||||
#ifdef USE_AMANITH
|
||||
vgInitContextAM (width, height, VG_FALSE, VG_TRUE);
|
||||
#endif
|
||||
#ifdef USE_SHIVA
|
||||
vgCreateContextSH (width, height);
|
||||
#endif
|
||||
|
||||
context = cairo_vg_context_create_for_glx (dpy, vgc->ctx);
|
||||
vgc->surface = cairo_vg_surface_create (context, content, width, height);
|
||||
cairo_vg_context_destroy (context);
|
||||
|
||||
surface = vgc->surface;
|
||||
if (cairo_surface_status (surface))
|
||||
_cairo_boilerplate_vg_cleanup_glx (vgc);
|
||||
|
||||
return surface;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_EGL_FUNCTIONS
|
||||
typedef struct _vg_closure_egl {
|
||||
EGLDisplay *dpy;
|
||||
EGLContext *ctx;
|
||||
EGLSurface *dummy;
|
||||
} vg_closure_egl_t;
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_vg_cleanup_egl (void *closure)
|
||||
{
|
||||
vg_closure_egl_t *vgc = closure;
|
||||
|
||||
#ifdef USE_AMANITH
|
||||
vgDestroyContextAM ();
|
||||
#endif
|
||||
#ifdef USE_SHIVA
|
||||
vgDestroyContextSH ();
|
||||
#endif
|
||||
|
||||
eglDestroyContext (vgc->dpy, vgc->ctx);
|
||||
eglDestroySurface (vgc->dpy, vgc->dummy);
|
||||
eglTerminate (vgc->dpy);
|
||||
free (vgc);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_vg_create_surface_egl (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
int rgba_attribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
int rgb_attribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
int dummy_attribs[] = {
|
||||
EGL_WIDTH, 8, EGL_HEIGHT, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLDisplay *dpy;
|
||||
int major, minor;
|
||||
EGLConfig config;
|
||||
int num_configs;
|
||||
EGLContext *egl_context;
|
||||
EGLSurface *dummy;
|
||||
cairo_vg_context_t *context;
|
||||
cairo_surface_t *surface;
|
||||
vg_closure_egl_t *vgc;
|
||||
|
||||
dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
|
||||
|
||||
if (! eglInitialize (dpy, &major, &minor))
|
||||
return NULL;
|
||||
|
||||
eglBindAPI (EGL_OPENVG_API);
|
||||
|
||||
if (! eglChooseConfig (dpy,
|
||||
content == CAIRO_CONTENT_COLOR_ALPHA ?
|
||||
rgba_attribs : rgb_attribs,
|
||||
&config, 1, &num_configs) ||
|
||||
num_configs != 1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
egl_context = eglCreateContext (dpy, config, NULL, NULL);
|
||||
if (egl_context == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Create a dummy surface in order to enable a context to initialise VG */
|
||||
dummy = eglCreatePbufferSurface (dpy, config, dummy_attribs);
|
||||
if (dummy == NULL)
|
||||
return NULL;
|
||||
if (! eglMakeCurrent (dpy, dummy, dummy, egl_context))
|
||||
return NULL;
|
||||
|
||||
#ifdef USE_AMANITH
|
||||
vgInitContextAM (width, height, VG_FALSE, VG_TRUE);
|
||||
#endif
|
||||
#ifdef USE_SHIVA
|
||||
vgCreateContextSH (width, height);
|
||||
#endif
|
||||
|
||||
vgc = xmalloc (sizeof (vg_closure_egl_t));
|
||||
vgc->dpy = dpy;
|
||||
vgc->ctx = egl_context;
|
||||
vgc->dummy = dummy;
|
||||
*closure = vgc;
|
||||
|
||||
context = cairo_vg_context_create_for_egl (vgc->dpy, vgc->ctx);
|
||||
surface = cairo_vg_surface_create (context, content, width, height);
|
||||
cairo_vg_context_destroy (context);
|
||||
|
||||
if (cairo_surface_status (surface))
|
||||
_cairo_boilerplate_vg_cleanup_egl (vgc);
|
||||
|
||||
return surface;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_vg_synchronize (void *closure)
|
||||
{
|
||||
vgFinish ();
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
#if CAIRO_HAS_GLX_FUNCTIONS
|
||||
{
|
||||
"vg-glx", "vg", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
"cairo_vg_context_create_for_glx",
|
||||
_cairo_boilerplate_vg_create_surface_glx,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_vg_cleanup_glx,
|
||||
_cairo_boilerplate_vg_synchronize,
|
||||
NULL,
|
||||
TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"vg-glx", "vg", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR, 1,
|
||||
"cairo_vg_context_create_for_glx",
|
||||
_cairo_boilerplate_vg_create_surface_glx,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_vg_cleanup_glx,
|
||||
_cairo_boilerplate_vg_synchronize,
|
||||
NULL,
|
||||
FALSE, FALSE, FALSE
|
||||
},
|
||||
#endif
|
||||
#if CAIRO_HAS_EGL_FUNCTIONS
|
||||
{
|
||||
"vg-egl", "vg", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
"cairo_vg_context_create_for_egl",
|
||||
_cairo_boilerplate_vg_create_surface_egl,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_vg_cleanup_egl,
|
||||
_cairo_boilerplate_vg_synchronize,
|
||||
NULL,
|
||||
TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"vg-egl", "vg", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_VG, CAIRO_CONTENT_COLOR, 1,
|
||||
"cairo_vg_context_create_for_egl",
|
||||
_cairo_boilerplate_vg_create_surface_egl,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
_cairo_boilerplate_vg_cleanup_egl,
|
||||
_cairo_boilerplate_vg_synchronize,
|
||||
NULL,
|
||||
FALSE, FALSE, FALSE
|
||||
},
|
||||
#endif
|
||||
};
|
||||
CAIRO_BOILERPLATE (vg, targets)
|
||||
|
|
@ -6,17 +6,12 @@ cairo_boilerplate_sources = [
|
|||
|
||||
cairo_boilerplate_feature_sources = {
|
||||
'cairo-xlib': ['cairo-boilerplate-xlib.c'],
|
||||
'cairo-qt': ['cairo-boilerplate-qt.cpp'],
|
||||
'cairo-quartz': ['cairo-boilerplate-quartz.c'],
|
||||
'cairo-xcb': ['cairo-boilerplate-xcb.c'],
|
||||
'cairo-win32': ['cairo-boilerplate-win32.c', 'cairo-boilerplate-win32-printing.c'],
|
||||
'cairo-drm': ['cairo-boilerplate-drm.c'],
|
||||
'cairo-cogl': ['cairo-boilerplate-cogl.c'],
|
||||
'cairo-directfb': ['cairo-boilerplate-directfb.c'],
|
||||
'cairo-pdf': ['cairo-boilerplate-pdf.c'],
|
||||
'cairo-ps': ['cairo-boilerplate-ps.c'],
|
||||
'cairo-svg': ['cairo-boilerplate-svg.c'],
|
||||
'cairo-vg': ['cairo-boilerplate-vg.c'],
|
||||
'cairo-script': ['cairo-boilerplate-script.c'],
|
||||
# All tests crash with FPE
|
||||
# 'cairo-egl': ['cairo-boilerplate-egl.c'],
|
||||
|
|
|
|||
|
|
@ -5,23 +5,16 @@ CAIRO_HAS_XLIB_XRENDER_SURFACE=0
|
|||
CAIRO_HAS_XCB_SURFACE=0
|
||||
CAIRO_HAS_XLIB_XCB_FUNCTIONS=0
|
||||
CAIRO_HAS_XCB_SHM_FUNCTIONS=0
|
||||
CAIRO_HAS_QT_SURFACE=0
|
||||
CAIRO_HAS_QUARTZ_SURFACE=0
|
||||
CAIRO_HAS_QUARTZ_FONT=0
|
||||
CAIRO_HAS_QUARTZ_IMAGE_SURFACE=0
|
||||
CAIRO_HAS_WIN32_SURFACE=1
|
||||
CAIRO_HAS_WIN32_FONT=1
|
||||
CAIRO_HAS_OS2_SURFACE=0
|
||||
CAIRO_HAS_BEOS_SURFACE=0
|
||||
CAIRO_HAS_DRM_SURFACE=0
|
||||
CAIRO_HAS_GALLIUM_SURFACE=0
|
||||
CAIRO_HAS_PNG_FUNCTIONS=1
|
||||
CAIRO_HAS_GL_SURFACE=0
|
||||
CAIRO_HAS_GLESV2_SURFACE=0
|
||||
CAIRO_HAS_GLESV3_SURFACE=0
|
||||
CAIRO_HAS_COGL_SURFACE=0
|
||||
CAIRO_HAS_DIRECTFB_SURFACE=0
|
||||
CAIRO_HAS_VG_SURFACE=0
|
||||
CAIRO_HAS_EGL_FUNCTIONS=0
|
||||
CAIRO_HAS_GLX_FUNCTIONS=0
|
||||
CAIRO_HAS_WGL_FUNCTIONS=0
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ endif
|
|||
ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_XCB_SHM_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_QT_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_QT_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_QUARTZ_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
|
|
@ -38,18 +35,6 @@ endif
|
|||
ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
||||
@echo "#define CAIRO_HAS_WIN32_FONT 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_OS2_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_BEOS_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_BEOS_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_DRM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_GALLIUM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
|
|
@ -62,15 +47,9 @@ endif
|
|||
ifeq ($(CAIRO_HAS_GLESV3_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_GLESV3_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_COGL_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_COGL_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_VG_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_EGL_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -85,14 +85,12 @@ CAIRO_MAKEFILE_ACCUMULATE(*,
|
|||
[dnl
|
||||
all_$1_headers = $($1_headers)
|
||||
all_$1_private = $($1_private)
|
||||
all_$1_cxx_sources = $($1_cxx_sources)
|
||||
all_$1_sources = $($1_sources)
|
||||
])dnl
|
||||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,!,
|
||||
[dnl
|
||||
all_$1_headers += $($1_$2_headers)
|
||||
all_$1_private += $($1_$2_private)
|
||||
all_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
all_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -101,14 +99,12 @@ CAIRO_MAKEFILE_ACCUMULATE(*,
|
|||
[dnl
|
||||
enabled_$1_headers = $($1_headers)
|
||||
enabled_$1_private = $($1_private)
|
||||
enabled_$1_cxx_sources = $($1_cxx_sources)
|
||||
enabled_$1_sources = $($1_sources)
|
||||
])dnl
|
||||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,!,
|
||||
[dnl
|
||||
enabled_$1_headers += $($1_$2_headers)
|
||||
enabled_$1_private += $($1_$2_private)
|
||||
enabled_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
enabled_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -118,7 +114,6 @@ dnl Collect list of source files for all private features
|
|||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,,
|
||||
[dnl
|
||||
all_$1_private += $($1_$2_private) $($1_$2_headers)
|
||||
all_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
all_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -126,7 +121,6 @@ dnl Collect list of source files for enabled private features
|
|||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,,
|
||||
[dnl
|
||||
enabled_$1_private += $($1_$2_private) $($1_$2_headers)
|
||||
enabled_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
enabled_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -371,15 +365,12 @@ AC_DEFUN([CAIRO_REPORT],
|
|||
echo " Mime: yes (always builtin)"
|
||||
echo " Tee: $use_tee"
|
||||
echo " XML: $use_xml"
|
||||
#echo " Skia: $use_skia"
|
||||
echo " Xlib: $use_xlib"
|
||||
echo " Xlib Xrender: $use_xlib_xrender"
|
||||
echo " Qt: $use_qt"
|
||||
echo " Quartz: $use_quartz"
|
||||
echo " Quartz-image: $use_quartz_image"
|
||||
echo " XCB: $use_xcb"
|
||||
echo " Win32: $use_win32"
|
||||
echo " OS2: $use_os2"
|
||||
echo " CairoScript: $use_script"
|
||||
echo " PostScript: $use_ps"
|
||||
echo " PDF: $use_pdf"
|
||||
|
|
@ -387,11 +378,6 @@ AC_DEFUN([CAIRO_REPORT],
|
|||
echo " OpenGL: $use_gl"
|
||||
echo " OpenGL ES 2.0: $use_glesv2"
|
||||
echo " OpenGL ES 3.0: $use_glesv3"
|
||||
echo " BeOS: $use_beos"
|
||||
echo " DirectFB: $use_directfb"
|
||||
echo " OpenVG: $use_vg"
|
||||
echo " DRM: $use_drm"
|
||||
echo " Cogl: $use_cogl"
|
||||
echo ""
|
||||
echo "The following font backends:"
|
||||
echo " User: yes (always builtin)"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ AC_PATH_PROG(XARGS, xargs)
|
|||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CXX dnl required for BeOS (and cannot be a conditional dependency)
|
||||
AM_PROG_CC_C_O
|
||||
AC_C_INLINE
|
||||
|
||||
|
|
|
|||
101
configure.ac
101
configure.ac
|
|
@ -190,18 +190,6 @@ CAIRO_ENABLE_FUNCTIONS(xcb_shm, XCB/SHM, auto, [
|
|||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(qt, Qt, no, [
|
||||
dnl Keep in sync with meson.build!
|
||||
qt_REQUIRES="QtGui >= 4.4.0"
|
||||
PKG_CHECK_MODULES(qt, $qt_REQUIRES, ,
|
||||
[qt_REQUIRES=""
|
||||
use_qt="no (requires Qt4 development libraries)"
|
||||
])
|
||||
qt_NONPKGCONFIG_LIBS="-lstdc++"
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [
|
||||
dnl There is no pkgconfig for quartz; lets do a header check
|
||||
AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, , [use_quartz="no (requires ApplicationServices framework)"])
|
||||
|
|
@ -251,61 +239,6 @@ AM_CONDITIONAL(CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE, test "x$test_win32_printin
|
|||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(os2, OS/2, no, [
|
||||
case "$host" in
|
||||
*-*-os2*)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
use_os2="no (requires an OS/2 platform)"
|
||||
;;
|
||||
esac
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(beos, BeOS/Zeta, no, [
|
||||
case "$host" in
|
||||
*-*-beos)
|
||||
beos_LIBS=""
|
||||
dnl Add libbe and libzeta if available
|
||||
AC_CHECK_LIB(be,main,beos_LIBS="$beos_LIBS -lbe")
|
||||
AC_CHECK_LIB(zeta,main,beos_LIBS="$beos_LIBS -lzeta")
|
||||
;;
|
||||
*)
|
||||
use_beos="no (requires a BeOS platform)"
|
||||
;;
|
||||
esac
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(drm, DRM, no, [
|
||||
dnl Keep in sync with meson.build!
|
||||
drm_REQUIRES="libudev >= 136, libdrm >= 2.4"
|
||||
PKG_CHECK_MODULES(drm, $drm_REQUIRES, ,
|
||||
[use_drm="no (requires $drm_REQUIRES, udev is available from git://git.kernel.org/pub/scm/linux/hotplug/udev.git)"])
|
||||
])
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
|
||||
if test "x$use_drm" = "xyes"; then
|
||||
AC_ARG_WITH([gallium],
|
||||
[AS_HELP_STRING([--with-gallium=/path/to/mesa],
|
||||
[directory to find gallium enabled mesa])],
|
||||
[mesa_DIR="$withval"],
|
||||
[mesa_DIR="`pwd`/../mesa"])
|
||||
gallium_DIR="$mesa_DIR/src/gallium"
|
||||
gallium_NONPKGCONFIG_CFLAGS="-I$mesa_DIR/include -I$mesa_DIR/src/mesa -I$gallium_DIR/include -I$gallium_DIR/auxiliary"
|
||||
gallium_NONPKGCONFIG_LIBS="-lGL"
|
||||
AC_SUBST(mesa_DIR)
|
||||
AC_SUBST(gallium_DIR)
|
||||
else
|
||||
use_gallium="no (requires --enable-drm)"
|
||||
fi
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_FUNCTIONS(png, PNG, yes, [
|
||||
use_png=no
|
||||
AC_ARG_VAR([png_REQUIRES], [module name for libpng to search for using pkg-config])
|
||||
|
|
@ -398,31 +331,6 @@ CAIRO_ENABLE_SURFACE_BACKEND(glesv3, OpenGLESv3, no, [
|
|||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(cogl, Cogl, no, [
|
||||
cogl_REQUIRES="cogl-2.0-experimental >= 1.17.2"
|
||||
PKG_CHECK_MODULES(cogl, $cogl_REQUIRES,, [use_cogl="no"])
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(directfb, directfb, no, [
|
||||
directfb_REQUIRES=directfb
|
||||
PKG_CHECK_MODULES(directfb, $directfb_REQUIRES, ,
|
||||
[use_directfb="no (requires $directfb_REQUIRES http://www.directfb.org)"])
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(vg, OpenVG, no, [
|
||||
dnl There is no pkgconfig for OpenVG; lets do a header check
|
||||
AC_CHECK_HEADER(VG/openvg.h,, [use_vg="no (OpenVG headers not found)"])
|
||||
if test "x$use_vg" = "xyes"; then
|
||||
vg_NONPKGCONFIG_CFLAGS=
|
||||
vg_NONPKGCONFIG_LIBS="-lOpenVG"
|
||||
need_egl_functions=yes
|
||||
need_glx_functions=yes
|
||||
fi
|
||||
])
|
||||
|
||||
CAIRO_ENABLE_FUNCTIONS(egl, EGL, auto, [
|
||||
if test "x$need_egl_functions" = "xyes"; then
|
||||
|
|
@ -880,15 +788,6 @@ fi
|
|||
|
||||
dnl ===========================================================================
|
||||
|
||||
dnl Extra stuff we need to do when building C++ code
|
||||
need_cxx="no"
|
||||
AS_IF([test "x$use_qt" = "xyes"], [need_cxx="yes"])
|
||||
AS_IF([test "x$use_beos" = "xyes"], [need_cxx="yes"])
|
||||
|
||||
AM_CONDITIONAL(BUILD_CXX, test "x$need_cxx" = "xyes")
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
# We use GTK+ for some utility/debugging tools
|
||||
PKG_CHECK_MODULES(gtk, "gtk+-2.0",have_gtk=yes, have_gtk=no)
|
||||
AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ EXTRA_HFILES=$(top_builddir)/src/cairo-supported-features.h
|
|||
|
||||
# Headers to ignore
|
||||
IGNORE_HFILES= \
|
||||
drm \
|
||||
cairo-features.h \
|
||||
cairo-features-win32.h \
|
||||
$(all_cairo_private) \
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
<xi:include href="xml/cairo-ps.xml"/>
|
||||
<xi:include href="xml/cairo-recording.xml"/>
|
||||
<xi:include href="xml/cairo-win32.xml"/>
|
||||
<!--xi:include href="xml/cairo-beos.xml"/-->
|
||||
<xi:include href="xml/cairo-svg.xml"/>
|
||||
<xi:include href="xml/cairo-quartz.xml" />
|
||||
<!--xi:include href="xml/cairo-quartz-image.xml"/-->
|
||||
|
|
|
|||
|
|
@ -123,18 +123,6 @@ cairo_recording_surface_ink_extents
|
|||
cairo_recording_surface_get_extents
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>cairo-skia</FILE>
|
||||
cairo_skia_context_t
|
||||
cairo_skia_surface_t
|
||||
format_to_sk_config
|
||||
cairo_skia_surface_create
|
||||
cairo_skia_surface_create_for_data
|
||||
<SUBSECTION Private>
|
||||
cairo_skia_context
|
||||
cairo_skia_surface
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>cairo-win32</FILE>
|
||||
CAIRO_HAS_WIN32_SURFACE
|
||||
|
|
|
|||
|
|
@ -561,7 +561,6 @@ cairo_surface_t
|
|||
cairo_atsui_surface_t
|
||||
cairo_win32_surface_t
|
||||
cairo_xlib_surface_t
|
||||
cairo_beos_surface_t
|
||||
</programlisting>
|
||||
<para>
|
||||
Unlike patterns, the constructors and methods on these types are
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ gnome = import('gnome')
|
|||
|
||||
ignore_headers = [
|
||||
# Sub-directories
|
||||
'drm',
|
||||
'win32',
|
||||
|
||||
# Internal headers
|
||||
|
|
|
|||
89
meson.build
89
meson.build
|
|
@ -1,4 +1,4 @@
|
|||
project('cairo', 'c', 'cpp',
|
||||
project('cairo', 'c',
|
||||
meson_version: '>= 0.56.0',
|
||||
version: run_command(find_program('version.py'), check: true).stdout().strip(),
|
||||
default_options: ['warning_level=2'],
|
||||
|
|
@ -10,9 +10,7 @@ fontconfig_required_version = '>= 2.2.95'
|
|||
xrender_required_version = '>= 0.6'
|
||||
xcb_required_version = '>= 1.6'
|
||||
xcb_render_required_version = '>= 1.6'
|
||||
qtgui_required_version = '>= 4.4.0'
|
||||
libudev_required_version = '>= 136'
|
||||
libdrm_required_version = '>= 2.4'
|
||||
glib_required_version = '>= 2.14'
|
||||
|
||||
# library versioning
|
||||
|
|
@ -450,20 +448,6 @@ if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1
|
|||
endif
|
||||
endif
|
||||
|
||||
# Tests crash and burn
|
||||
qtgui_dep = dependency('QtGui', required: get_option('qt'),
|
||||
version: qtgui_required_version)
|
||||
if qtgui_dep.found() and false
|
||||
feature_conf.set('CAIRO_HAS_QT_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-qt',
|
||||
'description': 'Qt surface backend',
|
||||
'deps': [qtgui_dep],
|
||||
}]
|
||||
|
||||
deps += [qtgui_dep]
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
|
||||
quartz_deps = dependency('appleframeworks', modules : ['CoreFoundation', 'ApplicationServices'], required: get_option('quartz'))
|
||||
|
||||
|
|
@ -519,26 +503,6 @@ if host_machine.system() == 'windows'
|
|||
]
|
||||
endif
|
||||
|
||||
# FIXME: Doesn't build since at least 2011
|
||||
libudev_dep = dependency('libudev', required: get_option('drm'),
|
||||
version: libudev_required_version)
|
||||
libdrm_dep = dependency('libdrm', required: get_option('drm'),
|
||||
version: libdrm_required_version)
|
||||
if libudev_dep.found() and libdrm_dep.found() and false
|
||||
deps += [libudev_dep, libdrm_dep]
|
||||
|
||||
feature_conf.set('CAIRO_HAS_DRM_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-drm',
|
||||
'description': 'DRM surface backend',
|
||||
'deps': [libudev_dep, libdrm_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
# Not even trying to port gallium as it depends on drm
|
||||
|
||||
# Not porting BEOS or OS/2 backends either, meson doesn't support those
|
||||
|
||||
# GL / GLESV2 / GLESV3 are mutually exclusive
|
||||
gl_backend = get_option('gl-backend')
|
||||
need_egl_functions = false
|
||||
|
|
@ -612,50 +576,6 @@ if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and feature_conf.get('CAIRO_
|
|||
endif
|
||||
endif
|
||||
|
||||
cogl_dep = dependency('cogl-2.0-experimental',
|
||||
version: '>= 1.17.2',
|
||||
required: get_option('cogl'),
|
||||
)
|
||||
if cogl_dep.found()
|
||||
deps += [cogl_dep]
|
||||
|
||||
feature_conf.set('CAIRO_HAS_COGL_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-cogl',
|
||||
'description': 'Cogl surface backend',
|
||||
'deps': [cogl_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
# Untested
|
||||
directfb_dep = dependency('directfb', required: get_option('directfb'))
|
||||
if directfb_dep.found()
|
||||
deps += [directfb_dep]
|
||||
|
||||
feature_conf.set('CAIRO_HAS_DIRECTFB_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-directfb',
|
||||
'description': 'directfb surface backend',
|
||||
'deps': [directfb_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
# Untested
|
||||
openvg_dep = cc.find_library('OpenVG', has_headers: 'VG/openvg.h', required: get_option('openvg'))
|
||||
if openvg_dep.found()
|
||||
deps += [openvg_dep]
|
||||
|
||||
need_egl_functions = true
|
||||
need_glx_functions = true
|
||||
|
||||
feature_conf.set('CAIRO_HAS_VG_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-vg',
|
||||
'description': 'OpenVG surface backend',
|
||||
'deps': [openvg_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
if need_egl_functions
|
||||
# FIXME: automagic
|
||||
egl_extra_deps = []
|
||||
|
|
@ -1003,12 +923,10 @@ summary({
|
|||
'XML': feature_conf.get('CAIRO_HAS_XML_SURFACE', 0) == 1,
|
||||
'Xlib': feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1,
|
||||
'Xlib Xrender': feature_conf.get('CAIRO_HAS_XLIB_XRENDER_SURFACE', 0) == 1,
|
||||
'Qt': feature_conf.get('CAIRO_HAS_QT_SURFACE', 0) == 1,
|
||||
'Quartz': feature_conf.get('CAIRO_HAS_QUARTZ_SURFACE', 0) == 1,
|
||||
'Quartz-image': feature_conf.get('CAIRO_HAS_QUARTZ_IMAGE_SURFACE', 0) == 1,
|
||||
'XCB': feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1,
|
||||
'Win32': feature_conf.get('CAIRO_HAS_WIN32_SURFACE', 0) == 1,
|
||||
'OS2': false,
|
||||
'CairoScript': feature_conf.get('CAIRO_HAS_SCRIPT_SURFACE', 0) == 1,
|
||||
'PostScript': feature_conf.get('CAIRO_HAS_PS_SURFACE', 0) == 1,
|
||||
'PDF': feature_conf.get('CAIRO_HAS_PDF_SURFACE', 0) == 1,
|
||||
|
|
@ -1016,11 +934,6 @@ summary({
|
|||
'OpenGL': feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 1,
|
||||
'OpenGL ES 2.0': feature_conf.get('CAIRO_HAS_GLESV2_SURFACE', 0) == 1,
|
||||
'OpenGL ES 3.0': feature_conf.get('CAIRO_HAS_GLESV3_SURFACE', 0) == 1,
|
||||
'BeOS': false,
|
||||
'DirectFB': feature_conf.get('CAIRO_HAS_DIRECTFB_SURFACE', 0) == 1,
|
||||
'OpenVG': feature_conf.get('CAIRO_HAS_VG_SURFACE', 0) == 1,
|
||||
'DRM': feature_conf.get('CAIRO_HAS_DRM_SURFACE', 0) == 1,
|
||||
'Cogl': feature_conf.get('CAIRO_HAS_COGL_SURFACE', 0) == 1,
|
||||
}, section: 'Surface Backends', bool_yn: true)
|
||||
|
||||
summary({
|
||||
|
|
|
|||
|
|
@ -3,18 +3,13 @@ option('fontconfig', type : 'feature', value : 'auto')
|
|||
option('freetype', type : 'feature', value : 'auto')
|
||||
|
||||
# Cairo surface backends
|
||||
option('cogl', type : 'feature', value : 'disabled')
|
||||
option('directfb', type : 'feature', value : 'disabled')
|
||||
option('gl-backend', type : 'combo', value : 'disabled',
|
||||
# FIXME: https://github.com/mesonbuild/meson/issues/4566
|
||||
choices : ['auto', 'gl', 'glesv2', 'glesv3', 'disabled'])
|
||||
option('glesv2', type : 'feature', value : 'disabled')
|
||||
option('glesv3', type : 'feature', value : 'disabled')
|
||||
option('drm', type : 'feature', value : 'disabled')
|
||||
option('openvg', type : 'feature', value : 'disabled')
|
||||
option('png', type : 'feature', value : 'auto') # png and svg surfaces
|
||||
option('quartz', type : 'feature', value : 'auto')
|
||||
option('qt', type : 'feature', value : 'disabled')
|
||||
option('tee', type : 'feature', value : 'disabled')
|
||||
option('xcb', type : 'feature', value : 'auto')
|
||||
option('xlib', type : 'feature', value : 'auto')
|
||||
|
|
|
|||
|
|
@ -36,10 +36,7 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__OS2__)
|
||||
#define INCL_BASE
|
||||
#include <os2.h>
|
||||
#elif defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#elif defined(_POSIX_PRIORITY_SCHEDULING)
|
||||
|
|
@ -86,9 +83,7 @@ cairo_perf_yield (void)
|
|||
{
|
||||
/* try to deactivate this thread until the scheduler calls it again */
|
||||
|
||||
#if defined(__OS2__)
|
||||
DosSleep (0);
|
||||
#elif defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
SleepEx(0, TRUE);
|
||||
#elif defined(_POSIX_PRIORITY_SCHEDULING)
|
||||
sched_yield ();
|
||||
|
|
|
|||
|
|
@ -22,32 +22,14 @@ cairoinclude_HEADERS = $(enabled_cairo_headers)
|
|||
|
||||
lib_LTLIBRARIES = libcairo.la
|
||||
|
||||
if BUILD_CXX
|
||||
cairo_cxx_lib = libcairo_cxx.la
|
||||
else
|
||||
cairo_cxx_lib =
|
||||
endif
|
||||
|
||||
noinst_LTLIBRARIES = $(cairo_cxx_lib)
|
||||
libcairo_cxx_la_SOURCES = \
|
||||
$(enabled_cairo_headers) \
|
||||
$(enabled_cairo_private) \
|
||||
$(enabled_cairo_cxx_sources) \
|
||||
$(NULL)
|
||||
libcairo_cxx_la_LDFLAGS = $(AM_LDFLAGS) $(export_symbols)
|
||||
libcairo_cxx_la_LIBADD = $(CAIRO_LIBS)
|
||||
libcairo_cxx_la_DEPENDENCIES = $(cairo_def_dependency)
|
||||
|
||||
|
||||
libcairo_la_SOURCES = \
|
||||
$(enabled_cairo_headers) \
|
||||
$(enabled_cairo_private) \
|
||||
$(enabled_cairo_sources) \
|
||||
$(NULL)
|
||||
libcairo_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(CAIRO_LIBTOOL_VERSION_INFO) -no-undefined $(export_symbols)
|
||||
libcairo_la_LIBADD = $(CAIRO_LIBS) \
|
||||
$(cairo_cxx_lib)
|
||||
libcairo_la_DEPENDENCIES = $(cairo_def_dependency) $(cairo_cxx_lib)
|
||||
libcairo_la_LIBADD = $(CAIRO_LIBS)
|
||||
libcairo_la_DEPENDENCIES = $(cairo_def_dependency)
|
||||
|
||||
# Special headers
|
||||
nodist_cairoinclude_HEADERS = cairo-features.h
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
SPARSE = sparse
|
||||
sparse:
|
||||
@echo Checking enabled sources with sparse checker
|
||||
@status=true; for f in $(enabled_cairo_sources) $(enabled_cairo_cxx_sources); do \
|
||||
@status=true; for f in $(enabled_cairo_sources); do \
|
||||
echo $(SPARSE) $(PREPROCESS_ARGS) $(srcdir)/$$f; \
|
||||
$(SPARSE) $(PREPROCESS_ARGS) $(srcdir)/$$f || status=false; \
|
||||
done; $$status
|
||||
|
|
@ -10,7 +10,7 @@ sparse:
|
|||
SPLINT = splint -badflag
|
||||
splint:
|
||||
@echo Checking enabled sources with splint checker
|
||||
@status=true; for f in $(enabled_cairo_sources) $(enabled_cairo_cxx_sources); do \
|
||||
@status=true; for f in $(enabled_cairo_sources); do \
|
||||
echo $(SPLINT) $(PREPROCESS_ARGS) $(srcdir)/$$f; \
|
||||
$(SPLINT) $(PREPROCESS_ARGS) $(srcdir)/$$f || status=false; \
|
||||
done; $$status
|
||||
|
|
|
|||
|
|
@ -337,9 +337,6 @@ cairo_xcb_sources = \
|
|||
cairo-xcb-resources.c \
|
||||
$(NULL)
|
||||
|
||||
cairo_qt_headers = cairo-qt.h
|
||||
cairo_qt_cxx_sources = cairo-qt-surface.cpp
|
||||
|
||||
cairo_quartz_headers = cairo-quartz.h
|
||||
cairo_quartz_private = cairo-quartz-private.h
|
||||
cairo_quartz_sources = cairo-quartz-surface.c
|
||||
|
|
@ -364,15 +361,6 @@ cairo_win32_font_sources = \
|
|||
win32/cairo-win32-font.c \
|
||||
$(NULL)
|
||||
|
||||
cairo_os2_headers = cairo-os2.h
|
||||
cairo_os2_private = cairo-os2-private.h
|
||||
cairo_os2_sources = cairo-os2-surface.c
|
||||
|
||||
# automake is stupid enough to always use c++ linker if we enable the
|
||||
# following lines, even if beos surface is not enabled. Disable it for now.
|
||||
cairo_beos_headers = cairo-beos.h
|
||||
cairo_beos_cxx_sources = cairo-beos-surface.cpp
|
||||
|
||||
cairo_gl_headers = cairo-gl.h
|
||||
cairo_gl_private = cairo-gl-private.h \
|
||||
cairo-gl-dispatch-private.h \
|
||||
|
|
@ -405,41 +393,6 @@ cairo_egl_sources += cairo-egl-context.c
|
|||
cairo_glx_sources += cairo-glx-context.c
|
||||
cairo_wgl_sources += cairo-wgl-context.c
|
||||
|
||||
cairo_directfb_headers = cairo-directfb.h
|
||||
cairo_directfb_sources = cairo-directfb-surface.c
|
||||
|
||||
cairo_drm_headers = cairo-drm.h
|
||||
cairo_drm_private = drm/cairo-drm-private.h \
|
||||
drm/cairo-drm-intel-private.h \
|
||||
drm/cairo-drm-intel-brw-defines.h \
|
||||
drm/cairo-drm-intel-brw-structs.h \
|
||||
drm/cairo-drm-intel-brw-eu.h \
|
||||
drm/cairo-drm-intel-command-private.h \
|
||||
drm/cairo-drm-intel-ioctl-private.h \
|
||||
drm/cairo-drm-i915-private.h \
|
||||
drm/cairo-drm-i965-private.h \
|
||||
drm/cairo-drm-radeon-private.h
|
||||
cairo_drm_sources = drm/cairo-drm.c \
|
||||
drm/cairo-drm-bo.c \
|
||||
drm/cairo-drm-surface.c \
|
||||
drm/cairo-drm-intel.c \
|
||||
drm/cairo-drm-intel-debug.c \
|
||||
drm/cairo-drm-intel-surface.c \
|
||||
drm/cairo-drm-i915-surface.c \
|
||||
drm/cairo-drm-i915-glyphs.c \
|
||||
drm/cairo-drm-i915-shader.c \
|
||||
drm/cairo-drm-i915-spans.c \
|
||||
drm/cairo-drm-i965-surface.c \
|
||||
drm/cairo-drm-i965-glyphs.c \
|
||||
drm/cairo-drm-i965-shader.c \
|
||||
drm/cairo-drm-i965-spans.c \
|
||||
drm/cairo-drm-intel-brw-eu.c \
|
||||
drm/cairo-drm-intel-brw-eu-emit.c \
|
||||
drm/cairo-drm-intel-brw-eu-util.c \
|
||||
drm/cairo-drm-radeon.c \
|
||||
drm/cairo-drm-radeon-surface.c
|
||||
cairo_gallium_sources = drm/cairo-drm-gallium-surface.c
|
||||
|
||||
cairo_script_headers = cairo-script.h
|
||||
cairo_script_private = cairo-script-private.h
|
||||
cairo_script_sources = cairo-script-surface.c
|
||||
|
|
@ -450,12 +403,3 @@ cairo_tee_sources = cairo-tee-surface.c
|
|||
|
||||
cairo_xml_headers = cairo-xml.h
|
||||
cairo_xml_sources = cairo-xml-surface.c
|
||||
|
||||
cairo_vg_headers = cairo-vg.h
|
||||
cairo_vg_sources = cairo-vg-surface.c
|
||||
|
||||
cairo_cogl_headers = cairo-cogl.h
|
||||
cairo_cogl_private = cairo-cogl-private.h \
|
||||
cairo-cogl-gradient-private.h
|
||||
cairo_cogl_sources = cairo-cogl-surface.c \
|
||||
cairo-cogl-gradient.c
|
||||
|
|
|
|||
|
|
@ -10,12 +10,10 @@ supported_cairo_headers = $(cairo_headers)
|
|||
unsupported_cairo_headers =
|
||||
all_cairo_headers = $(cairo_headers)
|
||||
all_cairo_private = $(cairo_private)
|
||||
all_cairo_cxx_sources = $(cairo_cxx_sources)
|
||||
all_cairo_sources = $(cairo_sources)
|
||||
|
||||
enabled_cairo_headers = $(cairo_headers)
|
||||
enabled_cairo_private = $(cairo_private)
|
||||
enabled_cairo_cxx_sources = $(cairo_cxx_sources)
|
||||
enabled_cairo_sources = $(cairo_sources)
|
||||
|
||||
all_cairo_pkgconf = cairo.pc
|
||||
|
|
@ -24,12 +22,10 @@ enabled_cairo_pkgconf = cairo.pc
|
|||
supported_cairo_headers += $(cairo_xlib_headers)
|
||||
all_cairo_headers += $(cairo_xlib_headers)
|
||||
all_cairo_private += $(cairo_xlib_private)
|
||||
all_cairo_cxx_sources += $(cairo_xlib_cxx_sources)
|
||||
all_cairo_sources += $(cairo_xlib_sources)
|
||||
ifeq ($(CAIRO_HAS_XLIB_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_xlib_headers)
|
||||
enabled_cairo_private += $(cairo_xlib_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_xlib_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_xlib_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-xlib.pc
|
||||
|
|
@ -40,12 +36,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_xlib_xrender_headers)
|
||||
all_cairo_headers += $(cairo_xlib_xrender_headers)
|
||||
all_cairo_private += $(cairo_xlib_xrender_private)
|
||||
all_cairo_cxx_sources += $(cairo_xlib_xrender_cxx_sources)
|
||||
all_cairo_sources += $(cairo_xlib_xrender_sources)
|
||||
ifeq ($(CAIRO_HAS_XLIB_XRENDER_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_xlib_xrender_headers)
|
||||
enabled_cairo_private += $(cairo_xlib_xrender_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_xlib_xrender_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_xlib_xrender_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-xlib-xrender.pc
|
||||
|
|
@ -56,12 +50,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_xcb_headers)
|
||||
all_cairo_headers += $(cairo_xcb_headers)
|
||||
all_cairo_private += $(cairo_xcb_private)
|
||||
all_cairo_cxx_sources += $(cairo_xcb_cxx_sources)
|
||||
all_cairo_sources += $(cairo_xcb_sources)
|
||||
ifeq ($(CAIRO_HAS_XCB_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_xcb_headers)
|
||||
enabled_cairo_private += $(cairo_xcb_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_xcb_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_xcb_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-xcb.pc
|
||||
|
|
@ -72,12 +64,10 @@ endif
|
|||
unsupported_cairo_headers += $(cairo_xlib_xcb_headers)
|
||||
all_cairo_headers += $(cairo_xlib_xcb_headers)
|
||||
all_cairo_private += $(cairo_xlib_xcb_private)
|
||||
all_cairo_cxx_sources += $(cairo_xlib_xcb_cxx_sources)
|
||||
all_cairo_sources += $(cairo_xlib_xcb_sources)
|
||||
ifeq ($(CAIRO_HAS_XLIB_XCB_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_xlib_xcb_headers)
|
||||
enabled_cairo_private += $(cairo_xlib_xcb_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_xlib_xcb_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_xlib_xcb_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-xlib-xcb.pc
|
||||
|
|
@ -88,12 +78,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_xcb_shm_headers)
|
||||
all_cairo_headers += $(cairo_xcb_shm_headers)
|
||||
all_cairo_private += $(cairo_xcb_shm_private)
|
||||
all_cairo_cxx_sources += $(cairo_xcb_shm_cxx_sources)
|
||||
all_cairo_sources += $(cairo_xcb_shm_sources)
|
||||
ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_xcb_shm_headers)
|
||||
enabled_cairo_private += $(cairo_xcb_shm_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_xcb_shm_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_xcb_shm_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-xcb-shm.pc
|
||||
|
|
@ -101,31 +89,13 @@ ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
|
|||
enabled_cairo_pkgconf += cairo-xcb-shm.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_qt_headers)
|
||||
all_cairo_headers += $(cairo_qt_headers)
|
||||
all_cairo_private += $(cairo_qt_private)
|
||||
all_cairo_cxx_sources += $(cairo_qt_cxx_sources)
|
||||
all_cairo_sources += $(cairo_qt_sources)
|
||||
ifeq ($(CAIRO_HAS_QT_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_qt_headers)
|
||||
enabled_cairo_private += $(cairo_qt_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_qt_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_qt_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-qt.pc
|
||||
ifeq ($(CAIRO_HAS_QT_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-qt.pc
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_quartz_headers)
|
||||
all_cairo_headers += $(cairo_quartz_headers)
|
||||
all_cairo_private += $(cairo_quartz_private)
|
||||
all_cairo_cxx_sources += $(cairo_quartz_cxx_sources)
|
||||
all_cairo_sources += $(cairo_quartz_sources)
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_quartz_headers)
|
||||
enabled_cairo_private += $(cairo_quartz_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_quartz_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_quartz_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-quartz.pc
|
||||
|
|
@ -136,12 +106,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_quartz_font_headers)
|
||||
all_cairo_headers += $(cairo_quartz_font_headers)
|
||||
all_cairo_private += $(cairo_quartz_font_private)
|
||||
all_cairo_cxx_sources += $(cairo_quartz_font_cxx_sources)
|
||||
all_cairo_sources += $(cairo_quartz_font_sources)
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_FONT),1)
|
||||
enabled_cairo_headers += $(cairo_quartz_font_headers)
|
||||
enabled_cairo_private += $(cairo_quartz_font_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_quartz_font_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_quartz_font_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-quartz-font.pc
|
||||
|
|
@ -152,12 +120,10 @@ endif
|
|||
unsupported_cairo_headers += $(cairo_quartz_image_headers)
|
||||
all_cairo_headers += $(cairo_quartz_image_headers)
|
||||
all_cairo_private += $(cairo_quartz_image_private)
|
||||
all_cairo_cxx_sources += $(cairo_quartz_image_cxx_sources)
|
||||
all_cairo_sources += $(cairo_quartz_image_sources)
|
||||
ifeq ($(CAIRO_HAS_QUARTZ_IMAGE_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_quartz_image_headers)
|
||||
enabled_cairo_private += $(cairo_quartz_image_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_quartz_image_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_quartz_image_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-quartz-image.pc
|
||||
|
|
@ -168,12 +134,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_win32_headers)
|
||||
all_cairo_headers += $(cairo_win32_headers)
|
||||
all_cairo_private += $(cairo_win32_private)
|
||||
all_cairo_cxx_sources += $(cairo_win32_cxx_sources)
|
||||
all_cairo_sources += $(cairo_win32_sources)
|
||||
ifeq ($(CAIRO_HAS_WIN32_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_win32_headers)
|
||||
enabled_cairo_private += $(cairo_win32_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_win32_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_win32_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-win32.pc
|
||||
|
|
@ -184,12 +148,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_win32_font_headers)
|
||||
all_cairo_headers += $(cairo_win32_font_headers)
|
||||
all_cairo_private += $(cairo_win32_font_private)
|
||||
all_cairo_cxx_sources += $(cairo_win32_font_cxx_sources)
|
||||
all_cairo_sources += $(cairo_win32_font_sources)
|
||||
ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
||||
enabled_cairo_headers += $(cairo_win32_font_headers)
|
||||
enabled_cairo_private += $(cairo_win32_font_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_win32_font_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_win32_font_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-win32-font.pc
|
||||
|
|
@ -197,79 +159,13 @@ ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
|||
enabled_cairo_pkgconf += cairo-win32-font.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_os2_headers)
|
||||
all_cairo_headers += $(cairo_os2_headers)
|
||||
all_cairo_private += $(cairo_os2_private)
|
||||
all_cairo_cxx_sources += $(cairo_os2_cxx_sources)
|
||||
all_cairo_sources += $(cairo_os2_sources)
|
||||
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_os2_headers)
|
||||
enabled_cairo_private += $(cairo_os2_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_os2_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_os2_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-os2.pc
|
||||
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-os2.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_beos_headers)
|
||||
all_cairo_headers += $(cairo_beos_headers)
|
||||
all_cairo_private += $(cairo_beos_private)
|
||||
all_cairo_cxx_sources += $(cairo_beos_cxx_sources)
|
||||
all_cairo_sources += $(cairo_beos_sources)
|
||||
ifeq ($(CAIRO_HAS_BEOS_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_beos_headers)
|
||||
enabled_cairo_private += $(cairo_beos_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_beos_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_beos_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-beos.pc
|
||||
ifeq ($(CAIRO_HAS_BEOS_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-beos.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_drm_headers)
|
||||
all_cairo_headers += $(cairo_drm_headers)
|
||||
all_cairo_private += $(cairo_drm_private)
|
||||
all_cairo_cxx_sources += $(cairo_drm_cxx_sources)
|
||||
all_cairo_sources += $(cairo_drm_sources)
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_drm_headers)
|
||||
enabled_cairo_private += $(cairo_drm_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_drm_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_drm_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-drm.pc
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-drm.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_gallium_headers)
|
||||
all_cairo_headers += $(cairo_gallium_headers)
|
||||
all_cairo_private += $(cairo_gallium_private)
|
||||
all_cairo_cxx_sources += $(cairo_gallium_cxx_sources)
|
||||
all_cairo_sources += $(cairo_gallium_sources)
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_gallium_headers)
|
||||
enabled_cairo_private += $(cairo_gallium_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_gallium_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_gallium_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-gallium.pc
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-gallium.pc
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_png_headers)
|
||||
all_cairo_headers += $(cairo_png_headers)
|
||||
all_cairo_private += $(cairo_png_private)
|
||||
all_cairo_cxx_sources += $(cairo_png_cxx_sources)
|
||||
all_cairo_sources += $(cairo_png_sources)
|
||||
ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_png_headers)
|
||||
enabled_cairo_private += $(cairo_png_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_png_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_png_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-png.pc
|
||||
|
|
@ -280,12 +176,10 @@ endif
|
|||
unsupported_cairo_headers += $(cairo_gl_headers)
|
||||
all_cairo_headers += $(cairo_gl_headers)
|
||||
all_cairo_private += $(cairo_gl_private)
|
||||
all_cairo_cxx_sources += $(cairo_gl_cxx_sources)
|
||||
all_cairo_sources += $(cairo_gl_sources)
|
||||
ifeq ($(CAIRO_HAS_GL_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_gl_headers)
|
||||
enabled_cairo_private += $(cairo_gl_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_gl_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_gl_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-gl.pc
|
||||
|
|
@ -296,12 +190,10 @@ endif
|
|||
unsupported_cairo_headers += $(cairo_glesv2_headers)
|
||||
all_cairo_headers += $(cairo_glesv2_headers)
|
||||
all_cairo_private += $(cairo_glesv2_private)
|
||||
all_cairo_cxx_sources += $(cairo_glesv2_cxx_sources)
|
||||
all_cairo_sources += $(cairo_glesv2_sources)
|
||||
ifeq ($(CAIRO_HAS_GLESV2_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_glesv2_headers)
|
||||
enabled_cairo_private += $(cairo_glesv2_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_glesv2_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_glesv2_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-glesv2.pc
|
||||
|
|
@ -312,12 +204,10 @@ endif
|
|||
unsupported_cairo_headers += $(cairo_glesv3_headers)
|
||||
all_cairo_headers += $(cairo_glesv3_headers)
|
||||
all_cairo_private += $(cairo_glesv3_private)
|
||||
all_cairo_cxx_sources += $(cairo_glesv3_cxx_sources)
|
||||
all_cairo_sources += $(cairo_glesv3_sources)
|
||||
ifeq ($(CAIRO_HAS_GLESV3_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_glesv3_headers)
|
||||
enabled_cairo_private += $(cairo_glesv3_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_glesv3_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_glesv3_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-glesv3.pc
|
||||
|
|
@ -325,63 +215,13 @@ ifeq ($(CAIRO_HAS_GLESV3_SURFACE),1)
|
|||
enabled_cairo_pkgconf += cairo-glesv3.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_cogl_headers)
|
||||
all_cairo_headers += $(cairo_cogl_headers)
|
||||
all_cairo_private += $(cairo_cogl_private)
|
||||
all_cairo_cxx_sources += $(cairo_cogl_cxx_sources)
|
||||
all_cairo_sources += $(cairo_cogl_sources)
|
||||
ifeq ($(CAIRO_HAS_COGL_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_cogl_headers)
|
||||
enabled_cairo_private += $(cairo_cogl_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_cogl_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_cogl_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-cogl.pc
|
||||
ifeq ($(CAIRO_HAS_COGL_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-cogl.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_directfb_headers)
|
||||
all_cairo_headers += $(cairo_directfb_headers)
|
||||
all_cairo_private += $(cairo_directfb_private)
|
||||
all_cairo_cxx_sources += $(cairo_directfb_cxx_sources)
|
||||
all_cairo_sources += $(cairo_directfb_sources)
|
||||
ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_directfb_headers)
|
||||
enabled_cairo_private += $(cairo_directfb_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_directfb_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_directfb_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-directfb.pc
|
||||
ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-directfb.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_vg_headers)
|
||||
all_cairo_headers += $(cairo_vg_headers)
|
||||
all_cairo_private += $(cairo_vg_private)
|
||||
all_cairo_cxx_sources += $(cairo_vg_cxx_sources)
|
||||
all_cairo_sources += $(cairo_vg_sources)
|
||||
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_vg_headers)
|
||||
enabled_cairo_private += $(cairo_vg_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_vg_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_vg_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-vg.pc
|
||||
ifeq ($(CAIRO_HAS_VG_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-vg.pc
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_egl_headers)
|
||||
all_cairo_headers += $(cairo_egl_headers)
|
||||
all_cairo_private += $(cairo_egl_private)
|
||||
all_cairo_cxx_sources += $(cairo_egl_cxx_sources)
|
||||
all_cairo_sources += $(cairo_egl_sources)
|
||||
ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_egl_headers)
|
||||
enabled_cairo_private += $(cairo_egl_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_egl_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_egl_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-egl.pc
|
||||
|
|
@ -392,12 +232,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_glx_headers)
|
||||
all_cairo_headers += $(cairo_glx_headers)
|
||||
all_cairo_private += $(cairo_glx_private)
|
||||
all_cairo_cxx_sources += $(cairo_glx_cxx_sources)
|
||||
all_cairo_sources += $(cairo_glx_sources)
|
||||
ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_glx_headers)
|
||||
enabled_cairo_private += $(cairo_glx_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_glx_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_glx_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-glx.pc
|
||||
|
|
@ -408,12 +246,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_wgl_headers)
|
||||
all_cairo_headers += $(cairo_wgl_headers)
|
||||
all_cairo_private += $(cairo_wgl_private)
|
||||
all_cairo_cxx_sources += $(cairo_wgl_cxx_sources)
|
||||
all_cairo_sources += $(cairo_wgl_sources)
|
||||
ifeq ($(CAIRO_HAS_WGL_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_wgl_headers)
|
||||
enabled_cairo_private += $(cairo_wgl_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_wgl_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_wgl_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-wgl.pc
|
||||
|
|
@ -424,12 +260,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_script_headers)
|
||||
all_cairo_headers += $(cairo_script_headers)
|
||||
all_cairo_private += $(cairo_script_private)
|
||||
all_cairo_cxx_sources += $(cairo_script_cxx_sources)
|
||||
all_cairo_sources += $(cairo_script_sources)
|
||||
ifeq ($(CAIRO_HAS_SCRIPT_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_script_headers)
|
||||
enabled_cairo_private += $(cairo_script_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_script_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_script_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-script.pc
|
||||
|
|
@ -440,12 +274,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_ft_headers)
|
||||
all_cairo_headers += $(cairo_ft_headers)
|
||||
all_cairo_private += $(cairo_ft_private)
|
||||
all_cairo_cxx_sources += $(cairo_ft_cxx_sources)
|
||||
all_cairo_sources += $(cairo_ft_sources)
|
||||
ifeq ($(CAIRO_HAS_FT_FONT),1)
|
||||
enabled_cairo_headers += $(cairo_ft_headers)
|
||||
enabled_cairo_private += $(cairo_ft_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_ft_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_ft_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-ft.pc
|
||||
|
|
@ -456,12 +288,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_fc_headers)
|
||||
all_cairo_headers += $(cairo_fc_headers)
|
||||
all_cairo_private += $(cairo_fc_private)
|
||||
all_cairo_cxx_sources += $(cairo_fc_cxx_sources)
|
||||
all_cairo_sources += $(cairo_fc_sources)
|
||||
ifeq ($(CAIRO_HAS_FC_FONT),1)
|
||||
enabled_cairo_headers += $(cairo_fc_headers)
|
||||
enabled_cairo_private += $(cairo_fc_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_fc_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_fc_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-fc.pc
|
||||
|
|
@ -472,12 +302,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_ps_headers)
|
||||
all_cairo_headers += $(cairo_ps_headers)
|
||||
all_cairo_private += $(cairo_ps_private)
|
||||
all_cairo_cxx_sources += $(cairo_ps_cxx_sources)
|
||||
all_cairo_sources += $(cairo_ps_sources)
|
||||
ifeq ($(CAIRO_HAS_PS_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_ps_headers)
|
||||
enabled_cairo_private += $(cairo_ps_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_ps_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_ps_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-ps.pc
|
||||
|
|
@ -488,12 +316,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_pdf_headers)
|
||||
all_cairo_headers += $(cairo_pdf_headers)
|
||||
all_cairo_private += $(cairo_pdf_private)
|
||||
all_cairo_cxx_sources += $(cairo_pdf_cxx_sources)
|
||||
all_cairo_sources += $(cairo_pdf_sources)
|
||||
ifeq ($(CAIRO_HAS_PDF_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_pdf_headers)
|
||||
enabled_cairo_private += $(cairo_pdf_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_pdf_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_pdf_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-pdf.pc
|
||||
|
|
@ -504,12 +330,10 @@ endif
|
|||
supported_cairo_headers += $(cairo_svg_headers)
|
||||
all_cairo_headers += $(cairo_svg_headers)
|
||||
all_cairo_private += $(cairo_svg_private)
|
||||
all_cairo_cxx_sources += $(cairo_svg_cxx_sources)
|
||||
all_cairo_sources += $(cairo_svg_sources)
|
||||
ifeq ($(CAIRO_HAS_SVG_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_svg_headers)
|
||||
enabled_cairo_private += $(cairo_svg_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_svg_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_svg_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-svg.pc
|
||||
|
|
@ -518,63 +342,51 @@ enabled_cairo_pkgconf += cairo-svg.pc
|
|||
endif
|
||||
|
||||
all_cairo_private += $(cairo_test_surfaces_private) $(cairo_test_surfaces_headers)
|
||||
all_cairo_cxx_sources += $(cairo_test_surfaces_cxx_sources)
|
||||
all_cairo_sources += $(cairo_test_surfaces_sources)
|
||||
ifeq ($(CAIRO_HAS_TEST_SURFACES),1)
|
||||
enabled_cairo_private += $(cairo_test_surfaces_private) $(cairo_test_surfaces_headers)
|
||||
enabled_cairo_cxx_sources += $(cairo_test_surfaces_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_test_surfaces_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_image_headers)
|
||||
all_cairo_headers += $(cairo_image_headers)
|
||||
all_cairo_private += $(cairo_image_private)
|
||||
all_cairo_cxx_sources += $(cairo_image_cxx_sources)
|
||||
all_cairo_sources += $(cairo_image_sources)
|
||||
enabled_cairo_headers += $(cairo_image_headers)
|
||||
enabled_cairo_private += $(cairo_image_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_image_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_image_sources)
|
||||
|
||||
supported_cairo_headers += $(cairo_mime_headers)
|
||||
all_cairo_headers += $(cairo_mime_headers)
|
||||
all_cairo_private += $(cairo_mime_private)
|
||||
all_cairo_cxx_sources += $(cairo_mime_cxx_sources)
|
||||
all_cairo_sources += $(cairo_mime_sources)
|
||||
enabled_cairo_headers += $(cairo_mime_headers)
|
||||
enabled_cairo_private += $(cairo_mime_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_mime_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_mime_sources)
|
||||
|
||||
supported_cairo_headers += $(cairo_recording_headers)
|
||||
all_cairo_headers += $(cairo_recording_headers)
|
||||
all_cairo_private += $(cairo_recording_private)
|
||||
all_cairo_cxx_sources += $(cairo_recording_cxx_sources)
|
||||
all_cairo_sources += $(cairo_recording_sources)
|
||||
enabled_cairo_headers += $(cairo_recording_headers)
|
||||
enabled_cairo_private += $(cairo_recording_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_recording_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_recording_sources)
|
||||
|
||||
supported_cairo_headers += $(cairo_observer_headers)
|
||||
all_cairo_headers += $(cairo_observer_headers)
|
||||
all_cairo_private += $(cairo_observer_private)
|
||||
all_cairo_cxx_sources += $(cairo_observer_cxx_sources)
|
||||
all_cairo_sources += $(cairo_observer_sources)
|
||||
enabled_cairo_headers += $(cairo_observer_headers)
|
||||
enabled_cairo_private += $(cairo_observer_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_observer_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_observer_sources)
|
||||
|
||||
unsupported_cairo_headers += $(cairo_tee_headers)
|
||||
all_cairo_headers += $(cairo_tee_headers)
|
||||
all_cairo_private += $(cairo_tee_private)
|
||||
all_cairo_cxx_sources += $(cairo_tee_cxx_sources)
|
||||
all_cairo_sources += $(cairo_tee_sources)
|
||||
ifeq ($(CAIRO_HAS_TEE_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_tee_headers)
|
||||
enabled_cairo_private += $(cairo_tee_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_tee_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_tee_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-tee.pc
|
||||
|
|
@ -585,12 +397,10 @@ endif
|
|||
unsupported_cairo_headers += $(cairo_xml_headers)
|
||||
all_cairo_headers += $(cairo_xml_headers)
|
||||
all_cairo_private += $(cairo_xml_private)
|
||||
all_cairo_cxx_sources += $(cairo_xml_cxx_sources)
|
||||
all_cairo_sources += $(cairo_xml_sources)
|
||||
ifeq ($(CAIRO_HAS_XML_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_xml_headers)
|
||||
enabled_cairo_private += $(cairo_xml_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_xml_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_xml_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-xml.pc
|
||||
|
|
@ -601,31 +411,25 @@ endif
|
|||
supported_cairo_headers += $(cairo_user_headers)
|
||||
all_cairo_headers += $(cairo_user_headers)
|
||||
all_cairo_private += $(cairo_user_private)
|
||||
all_cairo_cxx_sources += $(cairo_user_cxx_sources)
|
||||
all_cairo_sources += $(cairo_user_sources)
|
||||
enabled_cairo_headers += $(cairo_user_headers)
|
||||
enabled_cairo_private += $(cairo_user_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_user_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_user_sources)
|
||||
|
||||
all_cairo_private += $(cairo_pthread_private) $(cairo_pthread_headers)
|
||||
all_cairo_cxx_sources += $(cairo_pthread_cxx_sources)
|
||||
all_cairo_sources += $(cairo_pthread_sources)
|
||||
ifeq ($(CAIRO_HAS_PTHREAD),1)
|
||||
enabled_cairo_private += $(cairo_pthread_private) $(cairo_pthread_headers)
|
||||
enabled_cairo_cxx_sources += $(cairo_pthread_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_pthread_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_gobject_headers)
|
||||
all_cairo_headers += $(cairo_gobject_headers)
|
||||
all_cairo_private += $(cairo_gobject_private)
|
||||
all_cairo_cxx_sources += $(cairo_gobject_cxx_sources)
|
||||
all_cairo_sources += $(cairo_gobject_sources)
|
||||
ifeq ($(CAIRO_HAS_GOBJECT_FUNCTIONS),1)
|
||||
enabled_cairo_headers += $(cairo_gobject_headers)
|
||||
enabled_cairo_private += $(cairo_gobject_private)
|
||||
enabled_cairo_cxx_sources += $(cairo_gobject_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_gobject_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-gobject.pc
|
||||
|
|
@ -634,28 +438,22 @@ enabled_cairo_pkgconf += cairo-gobject.pc
|
|||
endif
|
||||
|
||||
all_cairo_private += $(cairo_trace_private) $(cairo_trace_headers)
|
||||
all_cairo_cxx_sources += $(cairo_trace_cxx_sources)
|
||||
all_cairo_sources += $(cairo_trace_sources)
|
||||
ifeq ($(CAIRO_HAS_TRACE),1)
|
||||
enabled_cairo_private += $(cairo_trace_private) $(cairo_trace_headers)
|
||||
enabled_cairo_cxx_sources += $(cairo_trace_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_trace_sources)
|
||||
endif
|
||||
|
||||
all_cairo_private += $(cairo_interpreter_private) $(cairo_interpreter_headers)
|
||||
all_cairo_cxx_sources += $(cairo_interpreter_cxx_sources)
|
||||
all_cairo_sources += $(cairo_interpreter_sources)
|
||||
ifeq ($(CAIRO_HAS_INTERPRETER),1)
|
||||
enabled_cairo_private += $(cairo_interpreter_private) $(cairo_interpreter_headers)
|
||||
enabled_cairo_cxx_sources += $(cairo_interpreter_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_interpreter_sources)
|
||||
endif
|
||||
|
||||
all_cairo_private += $(cairo_symbol_lookup_private) $(cairo_symbol_lookup_headers)
|
||||
all_cairo_cxx_sources += $(cairo_symbol_lookup_cxx_sources)
|
||||
all_cairo_sources += $(cairo_symbol_lookup_sources)
|
||||
ifeq ($(CAIRO_HAS_SYMBOL_LOOKUP),1)
|
||||
enabled_cairo_private += $(cairo_symbol_lookup_private) $(cairo_symbol_lookup_headers)
|
||||
enabled_cairo_cxx_sources += $(cairo_symbol_lookup_cxx_sources)
|
||||
enabled_cairo_sources += $(cairo_symbol_lookup_sources)
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,984 +0,0 @@
|
|||
/* vim:set ts=8 sw=4 noet cin: */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2005 Christian Biesinger <cbiesinger@web.de>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Christian Biesinger
|
||||
* <cbiesinger@web.de>
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// This is a C++ file in order to use the C++ BeOS API
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-beos.h"
|
||||
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-inline.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Region.h>
|
||||
#if 0
|
||||
#include <DirectWindow.h>
|
||||
#endif
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
#include <Locker.h>
|
||||
|
||||
/**
|
||||
* SECTION:beos-surface
|
||||
* @Title: BeOS Surfaces
|
||||
* @Short_Description: BeOS surface support
|
||||
* @See_Also: #cairo_surface_t
|
||||
*
|
||||
* The BeOS surface is used to render cairo graphics to BeOS views
|
||||
* and bitmaps.
|
||||
**/
|
||||
|
||||
#define CAIRO_INT_STATUS_SUCCESS (cairo_int_status_t)(CAIRO_STATUS_SUCCESS)
|
||||
|
||||
struct cairo_beos_surface_t {
|
||||
cairo_surface_t base;
|
||||
|
||||
cairo_region_t *clip_region;
|
||||
|
||||
BView* view;
|
||||
|
||||
/*
|
||||
* A view is either attached to a bitmap, a window, or unattached.
|
||||
* If it is attached to a window, we can copy data out of it using BScreen.
|
||||
* If it is attached to a bitmap, we can read the bitmap data.
|
||||
* If it is not attached, it doesn't draw anything, we need not bother.
|
||||
*
|
||||
* Since there doesn't seem to be a way to get the bitmap from a view if it
|
||||
* is attached to one, we have to use a special surface creation function.
|
||||
*/
|
||||
|
||||
BBitmap* bitmap;
|
||||
|
||||
// If true, surface and view should be deleted when this surface is
|
||||
// destroyed
|
||||
bool owns_bitmap_view;
|
||||
};
|
||||
|
||||
class AutoLockView {
|
||||
public:
|
||||
AutoLockView(BView* view) : mView(view) {
|
||||
mOK = mView->LockLooper();
|
||||
}
|
||||
|
||||
~AutoLockView() {
|
||||
if (mOK)
|
||||
mView->UnlockLooper();
|
||||
}
|
||||
|
||||
operator bool() {
|
||||
return mOK;
|
||||
}
|
||||
|
||||
private:
|
||||
BView* mView;
|
||||
bool mOK;
|
||||
};
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_beos_surface_create_internal (BView* view,
|
||||
BBitmap* bmp,
|
||||
bool owns_bitmap_view = false);
|
||||
|
||||
static inline BRect
|
||||
_cairo_rectangle_to_brect (const cairo_rectangle_int_t* rect)
|
||||
{
|
||||
// A BRect is one pixel wider than you'd think
|
||||
return BRect (rect->x, rect->y,
|
||||
rect->x + rect->width - 1,
|
||||
rect->y + rect->height - 1);
|
||||
}
|
||||
|
||||
static inline cairo_rectangle_int_t
|
||||
_brect_to_cairo_rectangle (const BRect &rect)
|
||||
{
|
||||
cairo_rectangle_int_t retval;
|
||||
retval.x = floor (rect.left);
|
||||
retval.y = floor (rect.top);
|
||||
retval.width = ceil (rect.right) - retval.x + 1;
|
||||
retval.height = ceil (rect.bottom) - rectval.y + 1;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline rgb_color
|
||||
_cairo_color_to_be_color (const cairo_color_t *color)
|
||||
{
|
||||
// This factor ensures a uniform distribution of numbers
|
||||
const float factor = 256 - 1e-5;
|
||||
// Using doubles to have non-premultiplied colors
|
||||
rgb_color be_color = { uint8(color->red * factor),
|
||||
uint8(color->green * factor),
|
||||
uint8(color->blue * factor),
|
||||
uint8(color->alpha * factor) };
|
||||
|
||||
return be_color;
|
||||
}
|
||||
|
||||
enum ViewCopyStatus {
|
||||
OK,
|
||||
NOT_VISIBLE, // The view or the interest rect is not visible on screen
|
||||
ERROR // The view was visible, but the rect could not be copied. Probably OOM
|
||||
};
|
||||
|
||||
/**
|
||||
* _cairo_beos_view_to_bitmap:
|
||||
* @bitmap: [out] The resulting bitmap.
|
||||
* @rect: [out] The rectangle that was copied, in the view's coordinate system
|
||||
* @interestRect: If non-null, only this part of the view will be copied (view's coord system).
|
||||
*
|
||||
* Gets the contents of the view as a BBitmap*. Caller must delete the bitmap.
|
||||
**/
|
||||
static ViewCopyStatus
|
||||
_cairo_beos_view_to_bitmap (BView* view,
|
||||
BBitmap** bitmap,
|
||||
BRect* rect = NULL,
|
||||
const BRect* interestRect = NULL)
|
||||
{
|
||||
*bitmap = NULL;
|
||||
|
||||
BWindow* wnd = view->Window();
|
||||
// If we have no window, can't do anything
|
||||
if (!wnd)
|
||||
return NOT_VISIBLE;
|
||||
|
||||
view->Sync();
|
||||
wnd->Sync();
|
||||
|
||||
#if 0
|
||||
// Is it a direct window?
|
||||
BDirectWindow* directWnd = dynamic_cast<BDirectWindow*>(wnd);
|
||||
if (directWnd) {
|
||||
// WRITEME
|
||||
}
|
||||
#endif
|
||||
|
||||
// Is it visible? If so, we can copy the content off the screen
|
||||
if (wnd->IsHidden())
|
||||
return NOT_VISIBLE;
|
||||
|
||||
BRect rectToCopy(view->Bounds());
|
||||
if (interestRect)
|
||||
rectToCopy = rectToCopy & *interestRect;
|
||||
|
||||
if (!rectToCopy.IsValid())
|
||||
return NOT_VISIBLE;
|
||||
|
||||
BScreen screen(wnd);
|
||||
BRect screenRect(view->ConvertToScreen(rectToCopy));
|
||||
screenRect = screenRect & screen.Frame();
|
||||
|
||||
if (!screen.IsValid())
|
||||
return NOT_VISIBLE;
|
||||
|
||||
if (rect)
|
||||
*rect = view->ConvertFromScreen(screenRect);
|
||||
|
||||
if (screen.GetBitmap(bitmap, false, &screenRect) == B_OK)
|
||||
return OK;
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
unpremultiply_bgra (unsigned char* data,
|
||||
int width,
|
||||
int height,
|
||||
int stride,
|
||||
unsigned char* retdata)
|
||||
{
|
||||
unsigned char* end = data + stride * height;
|
||||
for (unsigned char* in = data, *out = retdata;
|
||||
in < end;
|
||||
in += stride, out += stride)
|
||||
{
|
||||
for (int i = 0; i < width; i ++) {
|
||||
uint8_t *b = &out[4*i];
|
||||
uint32_t pixel;
|
||||
uint8_t alpha;
|
||||
|
||||
memcpy (&pixel, &data[4*i], sizeof (uint32_t));
|
||||
alpha = pixel & 0xff;
|
||||
if (alpha == 0) {
|
||||
b[0] = b[1] = b[2] = b[3] = 0;
|
||||
} else {
|
||||
b[0] = (((pixel >> 24) & 0xff) * 255 + alpha / 2) / alpha;
|
||||
b[1] = (((pixel >> 16) & 0xff) * 255 + alpha / 2) / alpha;
|
||||
b[2] = (((pixel >> 8) & 0xff) * 255 + alpha / 2) / alpha;
|
||||
b[3] = alpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
multiply_alpha (int alpha, int color)
|
||||
{
|
||||
int temp = (alpha * color) + 0x80;
|
||||
return ((temp + (temp >> 8)) >> 8);
|
||||
}
|
||||
|
||||
static unsigned char*
|
||||
premultiply_bgra (unsigned char* data,
|
||||
int width,
|
||||
int height,
|
||||
int stride)
|
||||
{
|
||||
uint8_t * retdata = reinterpret_cast<unsigned char*>(_cairo_malloc_ab(height, stride));
|
||||
if (!retdata)
|
||||
return NULL;
|
||||
|
||||
uint8_t * end = data + stride * height;
|
||||
for (uint8_t * in = data, *out = retdata;
|
||||
in < end;
|
||||
in += stride, out += stride)
|
||||
{
|
||||
for (int i = 0; i < width; i ++) {
|
||||
uint8_t *base = &in[4*i];
|
||||
uint8_t alpha = base[3];
|
||||
uint32_t p;
|
||||
|
||||
if (alpha == 0) {
|
||||
p = 0;
|
||||
} else {
|
||||
uint8_t blue = base[0];
|
||||
uint8_t green = base[1];
|
||||
uint8_t red = base[2];
|
||||
|
||||
if (alpha != 0xff) {
|
||||
blue = multiply_alpha (alpha, blue);
|
||||
green = multiply_alpha (alpha, green);
|
||||
red = multiply_alpha (alpha, red);
|
||||
}
|
||||
p = (alpha << 0) | (red << 8) | (green << 16) | ((uint32_t)blue << 24);
|
||||
}
|
||||
memcpy (&out[4*i], &p, sizeof (uint32_t));
|
||||
}
|
||||
}
|
||||
return retdata;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_beos_surface_set_clip_region (cairo_beos_surface_t *surface,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
AutoLockView locker(surface->view);
|
||||
assert (locker);
|
||||
|
||||
if (region == surface->clip_region)
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
|
||||
cairo_region_destroy (surface->clip_region);
|
||||
surface->clip_region = cairo_region_reference (region);
|
||||
|
||||
if (region == NULL) {
|
||||
// No clipping
|
||||
surface->view->ConstrainClippingRegion(NULL);
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int count = cairo_region_num_rectangles (region);
|
||||
BRegion bregion;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
// Have to subtract one, because for pixman, the second coordinate
|
||||
// lies outside the rectangle.
|
||||
bregion.Include (_cairo_rectangle_to_brect (&rect));
|
||||
}
|
||||
surface->view->ConstrainClippingRegion(&bregion);
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _cairo_beos_bitmap_to_surface:
|
||||
*
|
||||
* Returns an addrefed image surface for a BBitmap. The bitmap need not outlive
|
||||
* the surface.
|
||||
**/
|
||||
static cairo_image_surface_t*
|
||||
_cairo_beos_bitmap_to_surface (BBitmap* bitmap)
|
||||
{
|
||||
color_space format = bitmap->ColorSpace();
|
||||
if (format != B_RGB32 && format != B_RGBA32) {
|
||||
BBitmap bmp(bitmap->Bounds(), B_RGB32, true);
|
||||
BView view(bitmap->Bounds(), "Cairo bitmap drawing view",
|
||||
B_FOLLOW_ALL_SIDES, 0);
|
||||
bmp.AddChild(&view);
|
||||
|
||||
view.LockLooper();
|
||||
|
||||
view.DrawBitmap(bitmap, BPoint(0.0, 0.0));
|
||||
view.Sync();
|
||||
|
||||
cairo_image_surface_t* imgsurf = _cairo_beos_bitmap_to_surface(&bmp);
|
||||
|
||||
view.UnlockLooper();
|
||||
bmp.RemoveChild(&view);
|
||||
return imgsurf;
|
||||
}
|
||||
|
||||
cairo_format_t cformat = format == B_RGB32 ?
|
||||
CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_ARGB32;
|
||||
|
||||
BRect bounds(bitmap->Bounds());
|
||||
unsigned char* bits = reinterpret_cast<unsigned char*>(bitmap->Bits());
|
||||
int width = bounds.IntegerWidth() + 1;
|
||||
int height = bounds.IntegerHeight() + 1;
|
||||
unsigned char* premultiplied;
|
||||
if (cformat == CAIRO_FORMAT_ARGB32) {
|
||||
premultiplied = premultiply_bgra (bits, width, height,
|
||||
bitmap->BytesPerRow());
|
||||
} else {
|
||||
premultiplied = reinterpret_cast<unsigned char*>(
|
||||
_cairo_malloc_ab(bitmap->BytesPerRow(), height));
|
||||
if (premultiplied)
|
||||
memcpy(premultiplied, bits, bitmap->BytesPerRow() * height);
|
||||
}
|
||||
if (!premultiplied)
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
cairo_image_surface_t* surf = reinterpret_cast<cairo_image_surface_t*>
|
||||
(cairo_image_surface_create_for_data(premultiplied,
|
||||
cformat,
|
||||
width,
|
||||
height,
|
||||
bitmap->BytesPerRow()));
|
||||
if (surf->base.status)
|
||||
free(premultiplied);
|
||||
else
|
||||
_cairo_image_surface_assume_ownership_of_data(surf);
|
||||
return surf;
|
||||
}
|
||||
|
||||
/**
|
||||
* _cairo_image_surface_to_bitmap:
|
||||
*
|
||||
* Converts an image surface to a BBitmap. The return value must be freed with
|
||||
* delete.
|
||||
**/
|
||||
static BBitmap*
|
||||
_cairo_image_surface_to_bitmap (cairo_image_surface_t* surface)
|
||||
{
|
||||
BRect size(0.0, 0.0, surface->width - 1, surface->height - 1);
|
||||
switch (surface->format) {
|
||||
case CAIRO_FORMAT_ARGB32: {
|
||||
BBitmap* data = new BBitmap(size, B_RGBA32);
|
||||
unpremultiply_bgra (surface->data,
|
||||
surface->width,
|
||||
surface->height,
|
||||
surface->stride,
|
||||
reinterpret_cast<unsigned char*>(data->Bits()));
|
||||
return data;
|
||||
}
|
||||
case CAIRO_FORMAT_RGB24: {
|
||||
BBitmap* data = new BBitmap(size, B_RGB32);
|
||||
memcpy(data->Bits(), surface->data, surface->height * surface->stride);
|
||||
return data;
|
||||
}
|
||||
default:
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _cairo_op_to_be_op:
|
||||
*
|
||||
* Converts a cairo drawing operator to a beos drawing_mode. Returns true if
|
||||
* the operator could be converted, false otherwise.
|
||||
**/
|
||||
static bool
|
||||
_cairo_op_to_be_op (cairo_operator_t cairo_op,
|
||||
drawing_mode* beos_op)
|
||||
{
|
||||
switch (cairo_op) {
|
||||
case CAIRO_OPERATOR_SOURCE:
|
||||
*beos_op = B_OP_COPY;
|
||||
return true;
|
||||
case CAIRO_OPERATOR_OVER:
|
||||
*beos_op = B_OP_ALPHA;
|
||||
return true;
|
||||
|
||||
case CAIRO_OPERATOR_ADD:
|
||||
// Does not actually work
|
||||
// XXX This is a fundamental compositing operator, it has to work!
|
||||
#if 1
|
||||
return false;
|
||||
#else
|
||||
*beos_op = B_OP_ADD;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
case CAIRO_OPERATOR_CLEAR:
|
||||
// Does not map to B_OP_ERASE - it replaces the dest with the low
|
||||
// color, instead of transparency; could be done by setting low
|
||||
// color appropriately.
|
||||
|
||||
case CAIRO_OPERATOR_IN:
|
||||
case CAIRO_OPERATOR_OUT:
|
||||
case CAIRO_OPERATOR_ATOP:
|
||||
|
||||
case CAIRO_OPERATOR_DEST:
|
||||
case CAIRO_OPERATOR_DEST_OVER:
|
||||
case CAIRO_OPERATOR_DEST_IN:
|
||||
case CAIRO_OPERATOR_DEST_OUT:
|
||||
case CAIRO_OPERATOR_DEST_ATOP:
|
||||
|
||||
case CAIRO_OPERATOR_XOR:
|
||||
case CAIRO_OPERATOR_SATURATE:
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_beos_surface_create_similar (void *abstract_surface,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
|
||||
if (width <= 0)
|
||||
width = 1;
|
||||
if (height <= 0)
|
||||
height = 1;
|
||||
|
||||
BRect rect(0.0, 0.0, width - 1, height - 1);
|
||||
BBitmap* bmp;
|
||||
switch (content) {
|
||||
case CAIRO_CONTENT_ALPHA:
|
||||
return NULL;
|
||||
case CAIRO_CONTENT_COLOR_ALPHA:
|
||||
bmp = new BBitmap(rect, B_RGBA32, true);
|
||||
break;
|
||||
case CAIRO_CONTENT_COLOR:
|
||||
// Match the color depth
|
||||
if (surface->bitmap) {
|
||||
color_space space = surface->bitmap->ColorSpace();
|
||||
// No alpha was requested -> make sure not to return
|
||||
// a surface with alpha
|
||||
if (space == B_RGBA32)
|
||||
space = B_RGB32;
|
||||
if (space == B_RGBA15)
|
||||
space = B_RGB15;
|
||||
bmp = new BBitmap(rect, space, true);
|
||||
} else {
|
||||
BScreen scr(surface->view->Window());
|
||||
color_space space = B_RGB32;
|
||||
if (scr.IsValid())
|
||||
space = scr.ColorSpace();
|
||||
bmp = new BBitmap(rect, space, true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED;
|
||||
return NULL;
|
||||
}
|
||||
BView* view = new BView(rect, "Cairo bitmap view", B_FOLLOW_ALL_SIDES, 0);
|
||||
bmp->AddChild(view);
|
||||
return _cairo_beos_surface_create_internal(view, bmp, true);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_beos_surface_finish (void *abstract_surface)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
if (surface->owns_bitmap_view) {
|
||||
if (surface->bitmap)
|
||||
surface->bitmap->RemoveChild(surface->view);
|
||||
|
||||
delete surface->view;
|
||||
delete surface->bitmap;
|
||||
|
||||
surface->view = NULL;
|
||||
surface->bitmap = NULL;
|
||||
}
|
||||
|
||||
cairo_region_destroy (surface->clip_region);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_beos_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
AutoLockView locker(surface->view);
|
||||
if (!locker)
|
||||
return CAIRO_STATUS_NO_MEMORY; /// XXX not exactly right, but what can we do?
|
||||
|
||||
|
||||
surface->view->Sync();
|
||||
|
||||
if (surface->bitmap) {
|
||||
*image_out = _cairo_beos_bitmap_to_surface (surface->bitmap);
|
||||
if (unlikely ((*image_out)->base.status))
|
||||
return (*image_out)->base.status;
|
||||
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
BBitmap* bmp;
|
||||
if (_cairo_beos_view_to_bitmap(surface->view, &bmp) != OK)
|
||||
return CAIRO_STATUS_NO_MEMORY; /// XXX incorrect if the error was NOT_VISIBLE
|
||||
|
||||
*image_out = _cairo_beos_bitmap_to_surface (bmp);
|
||||
if (unlikely ((*image_out)->base.status)) {
|
||||
delete bmp;
|
||||
return (*image_out)->base.status;
|
||||
}
|
||||
*image_extra = bmp;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_beos_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
if (image_extra != NULL) {
|
||||
BBitmap* bmp = static_cast<BBitmap*>(image_extra);
|
||||
delete bmp;
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_beos_surface_acquire_dest_image (void *abstract_surface,
|
||||
cairo_rectangle_int_t *interest_rect,
|
||||
cairo_image_surface_t **image_out,
|
||||
cairo_rectangle_int_t *image_rect,
|
||||
void **image_extra)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
|
||||
AutoLockView locker(surface->view);
|
||||
if (!locker) {
|
||||
*image_out = NULL;
|
||||
*image_extra = NULL;
|
||||
return (cairo_status_t) CAIRO_INT_STATUS_NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
if (surface->bitmap) {
|
||||
surface->view->Sync();
|
||||
*image_out = _cairo_beos_bitmap_to_surface(surface->bitmap);
|
||||
if (unlikely ((*image_out)->base.status))
|
||||
return (*image_out)->base.status;
|
||||
|
||||
image_rect->x = 0;
|
||||
image_rect->y = 0;
|
||||
image_rect->width = (*image_out)->width;
|
||||
image_rect->height = (*image_out)->height;
|
||||
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
BRect b_interest_rect (_cairo_rectangle_to_brect (interest_rect));
|
||||
|
||||
BRect rect;
|
||||
BBitmap* bitmap;
|
||||
ViewCopyStatus status = _cairo_beos_view_to_bitmap(surface->view, &bitmap,
|
||||
&rect, &b_interest_rect);
|
||||
if (status == NOT_VISIBLE) {
|
||||
*image_out = NULL;
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
if (status == ERROR)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
|
||||
*image_rect = _brect_to_cairo_rectangle(rect);
|
||||
*image_out = _cairo_beos_bitmap_to_surface(bitmap);
|
||||
delete bitmap;
|
||||
if (unlikely ((*image_out)->base.status))
|
||||
return (*image_out)->base.status;
|
||||
|
||||
*image_extra = NULL;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_cairo_beos_surface_release_dest_image (void *abstract_surface,
|
||||
cairo_rectangle_int_t *intersect_rect,
|
||||
cairo_image_surface_t *image,
|
||||
cairo_rectangle_int_t *image_rect,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
|
||||
AutoLockView locker(surface->view);
|
||||
if (!locker)
|
||||
return;
|
||||
|
||||
BBitmap* bitmap_to_draw = _cairo_image_surface_to_bitmap(image);
|
||||
surface->view->PushState();
|
||||
|
||||
surface->view->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
surface->view->DrawBitmap (bitmap_to_draw,
|
||||
_cairo_rectangle_to_brect (image_rect));
|
||||
|
||||
surface->view->PopState();
|
||||
|
||||
delete bitmap_to_draw;
|
||||
cairo_surface_destroy(&image->base);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_beos_surface_composite (cairo_operator_t op,
|
||||
cairo_pattern_t *src,
|
||||
cairo_pattern_t *mask,
|
||||
void *dst,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int mask_x,
|
||||
int mask_y,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
cairo_region_t *clip_region)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
dst);
|
||||
cairo_int_status_t status;
|
||||
AutoLockView locker(surface->view);
|
||||
if (!locker)
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
|
||||
drawing_mode mode;
|
||||
if (!_cairo_op_to_be_op(op, &mode))
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
// XXX Masks are not yet supported
|
||||
if (mask)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
// XXX should eventually support the others
|
||||
if (src->type != CAIRO_PATTERN_TYPE_SURFACE ||
|
||||
src->extend != CAIRO_EXTEND_NONE)
|
||||
{
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// Can we maybe support other matrices as well? (scale? if the filter is right)
|
||||
int itx, ity;
|
||||
if (!_cairo_matrix_is_integer_translation(&src->matrix, &itx, &ity))
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
status = _cairo_beos_surface_set_clip_region (surface, clip_region);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
BRect srcRect(src_x + itx,
|
||||
src_y + ity,
|
||||
src_x + itx + width - 1,
|
||||
src_y + ity + height - 1);
|
||||
BRect dstRect(dst_x, dst_y, dst_x + width - 1, dst_y + height - 1);
|
||||
|
||||
cairo_surface_t* src_surface = reinterpret_cast<cairo_surface_pattern_t*>(src)->
|
||||
surface;
|
||||
|
||||
// Get a bitmap
|
||||
BBitmap* bmp = NULL;
|
||||
bool free_bmp = false;
|
||||
if (_cairo_surface_is_image(src_surface)) {
|
||||
cairo_image_surface_t* img_surface =
|
||||
reinterpret_cast<cairo_image_surface_t*>(src_surface);
|
||||
|
||||
bmp = _cairo_image_surface_to_bitmap(img_surface);
|
||||
free_bmp = true;
|
||||
} else if (src_surface->backend == surface->base.backend) {
|
||||
cairo_beos_surface_t *beos_surface =
|
||||
reinterpret_cast<cairo_beos_surface_t*>(src_surface);
|
||||
if (beos_surface->bitmap) {
|
||||
AutoLockView locker(beos_surface->view);
|
||||
if (locker)
|
||||
beos_surface->view->Sync();
|
||||
bmp = beos_surface->bitmap;
|
||||
} else {
|
||||
_cairo_beos_view_to_bitmap(surface->view, &bmp);
|
||||
free_bmp = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bmp)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
// So, BeOS seems to screw up painting an opaque bitmap onto a
|
||||
// translucent one (it makes them partly transparent). Just return
|
||||
// unsupported.
|
||||
if (bmp->ColorSpace() == B_RGB32 && surface->bitmap &&
|
||||
surface->bitmap->ColorSpace() == B_RGBA32 &&
|
||||
(mode == B_OP_COPY || mode == B_OP_ALPHA))
|
||||
{
|
||||
if (free_bmp)
|
||||
delete bmp;
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// Draw it on screen.
|
||||
surface->view->PushState();
|
||||
|
||||
// If our image rect is only a subrect of the desired size, and we
|
||||
// aren't using B_OP_ALPHA, then we need to fill the rect first.
|
||||
if (mode == B_OP_COPY && !bmp->Bounds().Contains(srcRect)) {
|
||||
rgb_color black = { 0, 0, 0, 0 };
|
||||
|
||||
surface->view->SetDrawingMode(mode);
|
||||
surface->view->SetHighColor(black);
|
||||
surface->view->FillRect(dstRect);
|
||||
}
|
||||
|
||||
if (mode == B_OP_ALPHA && bmp->ColorSpace() == B_RGB32) {
|
||||
mode = B_OP_COPY;
|
||||
}
|
||||
surface->view->SetDrawingMode(mode);
|
||||
|
||||
if (surface->bitmap && surface->bitmap->ColorSpace() == B_RGBA32)
|
||||
surface->view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
|
||||
else
|
||||
surface->view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||
|
||||
surface->view->DrawBitmap(bmp, srcRect, dstRect);
|
||||
|
||||
surface->view->PopState();
|
||||
|
||||
if (free_bmp)
|
||||
delete bmp;
|
||||
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_beos_surface_fill_rectangles (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_color_t *color,
|
||||
cairo_rectangle_int_t *rects,
|
||||
int num_rects,
|
||||
cairo_region_t *clip_region)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
cairo_int_status_t status;
|
||||
|
||||
if (num_rects <= 0)
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
|
||||
AutoLockView locker(surface->view);
|
||||
if (!locker)
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
|
||||
drawing_mode mode;
|
||||
if (!_cairo_op_to_be_op(op, &mode))
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
status = _cairo_beos_surface_set_clip_region (surface, clip_region);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
rgb_color be_color = _cairo_color_to_be_color(color);
|
||||
|
||||
if (mode == B_OP_ALPHA && be_color.alpha == 0xFF)
|
||||
mode = B_OP_COPY;
|
||||
|
||||
// For CAIRO_OPERATOR_SOURCE, cairo expects us to use the premultiplied
|
||||
// color info. This is only relevant when drawing into an rgb24 buffer
|
||||
// (as for others, we can convert when asked for the image)
|
||||
if (mode == B_OP_COPY && be_color.alpha != 0xFF &&
|
||||
(!surface->bitmap || surface->bitmap->ColorSpace() != B_RGBA32))
|
||||
{
|
||||
be_color.red = color->red_short >> 8;
|
||||
be_color.green = color->green_short >> 8;
|
||||
be_color.blue = color->blue_short >> 8;
|
||||
}
|
||||
|
||||
surface->view->PushState();
|
||||
|
||||
surface->view->SetDrawingMode(mode);
|
||||
surface->view->SetHighColor(be_color);
|
||||
if (surface->bitmap && surface->bitmap->ColorSpace() == B_RGBA32)
|
||||
surface->view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
|
||||
else
|
||||
surface->view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
|
||||
|
||||
for (int i = 0; i < num_rects; ++i)
|
||||
surface->view->FillRect (_cairo_rectangle_to_brect (&rects[i]));
|
||||
|
||||
surface->view->PopState();
|
||||
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_beos_surface_get_extents (void *abstract_surface,
|
||||
cairo_rectangle_int_t *rectangle)
|
||||
{
|
||||
cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
|
||||
abstract_surface);
|
||||
AutoLockView locker(surface->view);
|
||||
if (!locker)
|
||||
return FALSE;
|
||||
|
||||
*rectangle = _brect_to_cairo_rectangle (surface->view->Bounds());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const struct _cairo_surface_backend cairo_beos_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_BEOS,
|
||||
_cairo_beos_surface_create_similar,
|
||||
_cairo_beos_surface_finish,
|
||||
_cairo_beos_surface_acquire_source_image,
|
||||
_cairo_beos_surface_release_source_image,
|
||||
_cairo_beos_surface_acquire_dest_image,
|
||||
_cairo_beos_surface_release_dest_image,
|
||||
NULL, /* clone_similar */
|
||||
_cairo_beos_surface_composite, /* composite */
|
||||
_cairo_beos_surface_fill_rectangles,
|
||||
NULL, /* composite_trapezoids */
|
||||
NULL, /* create_span_renderer */
|
||||
NULL, /* check_span_renderer */
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_beos_surface_get_extents,
|
||||
NULL, /* old_show_glyphs */
|
||||
NULL, /* get_font_options */
|
||||
NULL, /* flush */
|
||||
NULL, /* mark_dirty_rectangle */
|
||||
NULL, /* scaled_font_fini */
|
||||
NULL, /* scaled_glyph_fini */
|
||||
|
||||
NULL, /* paint */
|
||||
NULL, /* mask */
|
||||
NULL, /* stroke */
|
||||
NULL, /* fill */
|
||||
NULL /* show_glyphs */
|
||||
};
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_beos_surface_create_internal (BView* view,
|
||||
BBitmap* bmp,
|
||||
bool owns_bitmap_view)
|
||||
{
|
||||
// Must use malloc, because cairo code will use free() on the surface
|
||||
cairo_beos_surface_t *surface = static_cast<cairo_beos_surface_t*>(
|
||||
malloc(sizeof(cairo_beos_surface_t)));
|
||||
if (surface == NULL) {
|
||||
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
return const_cast<cairo_surface_t*>(&_cairo_surface_nil);
|
||||
}
|
||||
|
||||
cairo_content_t content = CAIRO_CONTENT_COLOR;
|
||||
if (bmp && (bmp->ColorSpace() == B_RGBA32 || bmp->ColorSpace() == B_RGBA15))
|
||||
content = CAIRO_CONTENT_COLOR_ALPHA;
|
||||
_cairo_surface_init (&surface->base,
|
||||
&cairo_beos_surface_backend,
|
||||
NULL, /* device */
|
||||
content);
|
||||
|
||||
surface->view = view;
|
||||
surface->bitmap = bmp;
|
||||
surface->owns_bitmap_view = owns_bitmap_view;
|
||||
|
||||
surface->clip_region = NULL;
|
||||
|
||||
return &surface->base;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_beos_surface_create:
|
||||
* @view: The view to draw on
|
||||
*
|
||||
* Creates a Cairo surface that draws onto a BeOS BView.
|
||||
* The caller must ensure that the view does not get deleted before the surface.
|
||||
* If the view is attached to a bitmap rather than an on-screen window, use
|
||||
* cairo_beos_surface_create_for_bitmap() instead of this function.
|
||||
*
|
||||
* Since: TBD
|
||||
**/
|
||||
cairo_surface_t *
|
||||
cairo_beos_surface_create (BView* view)
|
||||
{
|
||||
return cairo_beos_surface_create_for_bitmap(view, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_beos_surface_create_for_bitmap:
|
||||
* @view: The view to draw on
|
||||
* @bmp: The bitmap to which the view is attached
|
||||
*
|
||||
* Creates a Cairo surface that draws onto a BeOS BView which is attached to a
|
||||
* BBitmap.
|
||||
* The caller must ensure that the view and the bitmap do not get deleted
|
||||
* before the surface.
|
||||
*
|
||||
* For views that draw to a bitmap (as opposed to a screen), use this function
|
||||
* rather than cairo_beos_surface_create(). Not using this function WILL lead to
|
||||
* incorrect behaviour.
|
||||
*
|
||||
* For now, only views that draw to the entire area of bmp are supported.
|
||||
* The view must already be attached to the bitmap.
|
||||
*
|
||||
* Since: TBD
|
||||
**/
|
||||
cairo_surface_t *
|
||||
cairo_beos_surface_create_for_bitmap (BView* view,
|
||||
BBitmap* bmp)
|
||||
{
|
||||
return _cairo_beos_surface_create_internal(view, bmp);
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2005 Christian Biesinger <cbiesinger@web.de>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Christian Biesinger
|
||||
* <cbiesinger@web.de>
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_BEOS_H
|
||||
#define CAIRO_BEOS_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_BEOS_SURFACE
|
||||
|
||||
#include <View.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_beos_surface_create (BView* view);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_beos_surface_create_for_bitmap (BView* view,
|
||||
BBitmap* bmp);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_BEOS_SURFACE */
|
||||
# error Cairo was not compiled with support for the beos backend
|
||||
#endif /* CAIRO_HAS_BEOS_SURFACE */
|
||||
|
||||
#endif /* CAIRO_BEOS_H */
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2011 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.og/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_COGL_GRADIENT_PRIVATE_H
|
||||
#define CAIRO_COGL_GRADIENT_PRIVATE_H
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-pattern-private.h"
|
||||
|
||||
#include <cogl/cogl2-experimental.h>
|
||||
|
||||
#define CAIRO_COGL_LINEAR_GRADIENT_CACHE_SIZE (1024 * 1024)
|
||||
|
||||
typedef enum _cairo_cogl_gradient_compatibility {
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_PAD = 1<<0,
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_REPEAT = 1<<1,
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_REFLECT = 1<<2,
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_NONE = 1<<3
|
||||
} cairo_cogl_gradient_compatibility_t;
|
||||
#define CAIRO_COGL_GRADIENT_CAN_EXTEND_ALL (CAIRO_COGL_GRADIENT_CAN_EXTEND_PAD |\
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_REPEAT|\
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_REFLECT|\
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_NONE)
|
||||
|
||||
typedef struct _cairo_cogl_linear_texture_entry {
|
||||
cairo_cogl_gradient_compatibility_t compatibility;
|
||||
CoglTexture *texture;
|
||||
float translate_x;
|
||||
float scale_x;
|
||||
} cairo_cogl_linear_texture_entry_t;
|
||||
|
||||
typedef struct _cairo_cogl_linear_gradient {
|
||||
cairo_cache_entry_t cache_entry;
|
||||
cairo_reference_count_t ref_count;
|
||||
GList *textures;
|
||||
int n_stops;
|
||||
const cairo_gradient_stop_t *stops;
|
||||
cairo_gradient_stop_t stops_embedded[1];
|
||||
} cairo_cogl_linear_gradient_t;
|
||||
|
||||
cairo_int_status_t
|
||||
_cairo_cogl_get_linear_gradient (cairo_cogl_device_t *context,
|
||||
cairo_extend_t extend_mode,
|
||||
int n_stops,
|
||||
const cairo_gradient_stop_t *stops,
|
||||
const cairo_bool_t need_mirrored_gradient,
|
||||
cairo_cogl_linear_gradient_t **gradient_out);
|
||||
|
||||
cairo_cogl_linear_texture_entry_t *
|
||||
_cairo_cogl_linear_gradient_texture_for_extend (cairo_cogl_linear_gradient_t *gradient,
|
||||
cairo_extend_t extend_mode);
|
||||
|
||||
cairo_cogl_linear_gradient_t *
|
||||
_cairo_cogl_linear_gradient_reference (cairo_cogl_linear_gradient_t *gradient);
|
||||
|
||||
void
|
||||
_cairo_cogl_linear_gradient_destroy (cairo_cogl_linear_gradient_t *gradient);
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_cogl_linear_gradient_equal (const void *key_a, const void *key_b);
|
||||
|
||||
#endif /* CAIRO_COGL_GRADIENT_PRIVATE_H */
|
||||
|
|
@ -1,678 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2011 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.og/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
//#include "cairoint.h"
|
||||
|
||||
#include "cairo-cogl-private.h"
|
||||
#include "cairo-cogl-gradient-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
#include <cogl/cogl2-experimental.h>
|
||||
#include <glib.h>
|
||||
|
||||
//#define DUMP_GRADIENTS_TO_PNG
|
||||
|
||||
static uintptr_t
|
||||
_cairo_cogl_linear_gradient_hash (unsigned int n_stops,
|
||||
const cairo_gradient_stop_t *stops)
|
||||
{
|
||||
return _cairo_hash_bytes (n_stops, stops,
|
||||
sizeof (cairo_gradient_stop_t) * n_stops);
|
||||
}
|
||||
|
||||
static cairo_cogl_linear_gradient_t *
|
||||
_cairo_cogl_linear_gradient_lookup (cairo_cogl_device_t *ctx,
|
||||
uintptr_t hash,
|
||||
unsigned int n_stops,
|
||||
const cairo_gradient_stop_t *stops)
|
||||
{
|
||||
cairo_cogl_linear_gradient_t lookup;
|
||||
|
||||
lookup.cache_entry.hash = hash,
|
||||
lookup.n_stops = n_stops;
|
||||
lookup.stops = stops;
|
||||
|
||||
return _cairo_cache_lookup (&ctx->linear_cache, &lookup.cache_entry);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_cogl_linear_gradient_equal (const void *key_a, const void *key_b)
|
||||
{
|
||||
const cairo_cogl_linear_gradient_t *a = key_a;
|
||||
const cairo_cogl_linear_gradient_t *b = key_b;
|
||||
|
||||
if (a->n_stops != b->n_stops)
|
||||
return FALSE;
|
||||
|
||||
return memcmp (a->stops, b->stops, a->n_stops * sizeof (cairo_gradient_stop_t)) == 0;
|
||||
}
|
||||
|
||||
cairo_cogl_linear_gradient_t *
|
||||
_cairo_cogl_linear_gradient_reference (cairo_cogl_linear_gradient_t *gradient)
|
||||
{
|
||||
assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&gradient->ref_count));
|
||||
|
||||
_cairo_reference_count_inc (&gradient->ref_count);
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_cogl_linear_gradient_destroy (cairo_cogl_linear_gradient_t *gradient)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&gradient->ref_count));
|
||||
|
||||
if (! _cairo_reference_count_dec_and_test (&gradient->ref_count))
|
||||
return;
|
||||
|
||||
for (l = gradient->textures; l; l = l->next) {
|
||||
cairo_cogl_linear_texture_entry_t *entry = l->data;
|
||||
cogl_object_unref (entry->texture);
|
||||
free (entry);
|
||||
}
|
||||
g_list_free (gradient->textures);
|
||||
|
||||
free (gradient);
|
||||
}
|
||||
|
||||
static int
|
||||
_cairo_cogl_util_next_p2 (int a)
|
||||
{
|
||||
int rval = 1;
|
||||
|
||||
while (rval < a)
|
||||
rval <<= 1;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static float
|
||||
get_max_color_component_range (const cairo_color_stop_t *color0,
|
||||
const cairo_color_stop_t *color1)
|
||||
{
|
||||
float range;
|
||||
float max = 0;
|
||||
|
||||
range = fabs (color0->red - color1->red);
|
||||
max = MAX (range, max);
|
||||
range = fabs (color0->green - color1->green);
|
||||
max = MAX (range, max);
|
||||
range = fabs (color0->blue - color1->blue);
|
||||
max = MAX (range, max);
|
||||
range = fabs (color0->alpha - color1->alpha);
|
||||
max = MAX (range, max);
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
static int
|
||||
_cairo_cogl_linear_gradient_width_for_stops (cairo_extend_t extend,
|
||||
unsigned int n_stops,
|
||||
const cairo_gradient_stop_t *stops)
|
||||
{
|
||||
unsigned int n;
|
||||
float max_texels_per_unit_offset = 0;
|
||||
float total_offset_range;
|
||||
|
||||
/* Find the stop pair demanding the most precision because we are
|
||||
* interpolating the largest color-component range.
|
||||
*
|
||||
* From that we can define the relative sizes of all the other
|
||||
* stop pairs within our texture and thus the overall size.
|
||||
*
|
||||
* To determine the maximum number of texels for a given gap we
|
||||
* look at the range of colors we are expected to interpolate (so
|
||||
* long as the stop offsets are not degenerate) and we simply
|
||||
* assume we want one texel for each unique color value possible
|
||||
* for a one byte-per-component representation.
|
||||
* XXX: maybe this is overkill and just allowing 128 levels
|
||||
* instead of 256 would be enough and then we'd rely on the
|
||||
* bilinear filtering to give the full range.
|
||||
*
|
||||
* XXX: potentially we could try and map offsets to pixels to come
|
||||
* up with a more precise mapping, but we are aiming to cache
|
||||
* the gradients so we can't make assumptions about how it will be
|
||||
* scaled in the future.
|
||||
*/
|
||||
for (n = 1; n < n_stops; n++) {
|
||||
float color_range;
|
||||
float offset_range;
|
||||
float texels;
|
||||
float texels_per_unit_offset;
|
||||
|
||||
/* note: degenerate stops don't need to be represented in the
|
||||
* texture but we want to be sure that solid gaps get at least
|
||||
* one texel and all other gaps get at least 2 texels.
|
||||
*/
|
||||
|
||||
if (stops[n].offset == stops[n-1].offset)
|
||||
continue;
|
||||
|
||||
color_range = get_max_color_component_range (&stops[n].color, &stops[n-1].color);
|
||||
if (color_range == 0)
|
||||
texels = 1;
|
||||
else
|
||||
texels = MAX (2, 256.0f * color_range);
|
||||
|
||||
/* So how many texels would we need to map over the full [0,1]
|
||||
* gradient range so this gap would have enough texels? ... */
|
||||
offset_range = stops[n].offset - stops[n - 1].offset;
|
||||
texels_per_unit_offset = texels / offset_range;
|
||||
|
||||
if (texels_per_unit_offset > max_texels_per_unit_offset)
|
||||
max_texels_per_unit_offset = texels_per_unit_offset;
|
||||
}
|
||||
|
||||
total_offset_range = fabs (stops[n_stops - 1].offset - stops[0].offset);
|
||||
return max_texels_per_unit_offset * total_offset_range;
|
||||
}
|
||||
|
||||
/* Aim to create gradient textures without an alpha component so we can avoid
|
||||
* needing to use blending... */
|
||||
static CoglTextureComponents
|
||||
_cairo_cogl_linear_gradient_components_for_stops (cairo_extend_t extend,
|
||||
unsigned int n_stops,
|
||||
const cairo_gradient_stop_t *stops)
|
||||
{
|
||||
unsigned int n;
|
||||
|
||||
/* We have to add extra transparent texels to the end of the gradient to
|
||||
* handle CAIRO_EXTEND_NONE... */
|
||||
if (extend == CAIRO_EXTEND_NONE)
|
||||
return COGL_TEXTURE_COMPONENTS_RGBA;
|
||||
|
||||
for (n = 1; n < n_stops; n++) {
|
||||
if (stops[n].color.alpha != 1.0)
|
||||
return COGL_TEXTURE_COMPONENTS_RGBA;
|
||||
}
|
||||
|
||||
return COGL_TEXTURE_COMPONENTS_RGBA;
|
||||
}
|
||||
|
||||
static cairo_cogl_gradient_compatibility_t
|
||||
_cairo_cogl_compatibility_from_extend_mode (cairo_extend_t extend_mode)
|
||||
{
|
||||
switch (extend_mode)
|
||||
{
|
||||
case CAIRO_EXTEND_NONE:
|
||||
return CAIRO_COGL_GRADIENT_CAN_EXTEND_NONE;
|
||||
case CAIRO_EXTEND_PAD:
|
||||
return CAIRO_COGL_GRADIENT_CAN_EXTEND_PAD;
|
||||
case CAIRO_EXTEND_REPEAT:
|
||||
return CAIRO_COGL_GRADIENT_CAN_EXTEND_REPEAT;
|
||||
case CAIRO_EXTEND_REFLECT:
|
||||
return CAIRO_COGL_GRADIENT_CAN_EXTEND_REFLECT;
|
||||
}
|
||||
|
||||
assert (0); /* not reached */
|
||||
return CAIRO_EXTEND_NONE;
|
||||
}
|
||||
|
||||
cairo_cogl_linear_texture_entry_t *
|
||||
_cairo_cogl_linear_gradient_texture_for_extend (cairo_cogl_linear_gradient_t *gradient,
|
||||
cairo_extend_t extend_mode)
|
||||
{
|
||||
GList *l;
|
||||
cairo_cogl_gradient_compatibility_t compatibility =
|
||||
_cairo_cogl_compatibility_from_extend_mode (extend_mode);
|
||||
for (l = gradient->textures; l; l = l->next) {
|
||||
cairo_cogl_linear_texture_entry_t *entry = l->data;
|
||||
if (entry->compatibility & compatibility)
|
||||
return entry;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
color_stop_lerp (const cairo_color_stop_t *c0,
|
||||
const cairo_color_stop_t *c1,
|
||||
float factor,
|
||||
cairo_color_stop_t *dest)
|
||||
{
|
||||
/* NB: we always ignore the short members in this file so we don't need to
|
||||
* worry about initializing them here. */
|
||||
dest->red = c0->red * (1.0f-factor) + c1->red * factor;
|
||||
dest->green = c0->green * (1.0f-factor) + c1->green * factor;
|
||||
dest->blue = c0->blue * (1.0f-factor) + c1->blue * factor;
|
||||
dest->alpha = c0->alpha * (1.0f-factor) + c1->alpha * factor;
|
||||
}
|
||||
|
||||
static size_t
|
||||
_cairo_cogl_linear_gradient_size (cairo_cogl_linear_gradient_t *gradient)
|
||||
{
|
||||
GList *l;
|
||||
size_t size = 0;
|
||||
for (l = gradient->textures; l; l = l->next) {
|
||||
cairo_cogl_linear_texture_entry_t *entry = l->data;
|
||||
size += cogl_texture_get_width (entry->texture) * 4;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
static void
|
||||
emit_stop (CoglVertexP2C4 **position,
|
||||
float left,
|
||||
float right,
|
||||
const cairo_color_stop_t *left_color,
|
||||
const cairo_color_stop_t *right_color)
|
||||
{
|
||||
CoglVertexP2C4 *p = *position;
|
||||
|
||||
guint8 lr = left_color->red * 255;
|
||||
guint8 lg = left_color->green * 255;
|
||||
guint8 lb = left_color->blue * 255;
|
||||
guint8 la = left_color->alpha * 255;
|
||||
|
||||
guint8 rr = right_color->red * 255;
|
||||
guint8 rg = right_color->green * 255;
|
||||
guint8 rb = right_color->blue * 255;
|
||||
guint8 ra = right_color->alpha * 255;
|
||||
|
||||
p[0].x = left;
|
||||
p[0].y = 0;
|
||||
p[0].r = lr; p[0].g = lg; p[0].b = lb; p[0].a = la;
|
||||
p[1].x = left;
|
||||
p[1].y = 1;
|
||||
p[1].r = lr; p[1].g = lg; p[1].b = lb; p[1].a = la;
|
||||
p[2].x = right;
|
||||
p[2].y = 1;
|
||||
p[2].r = rr; p[2].g = rg; p[2].b = rb; p[2].a = ra;
|
||||
|
||||
p[3].x = left;
|
||||
p[3].y = 0;
|
||||
p[3].r = lr; p[3].g = lg; p[3].b = lb; p[3].a = la;
|
||||
p[4].x = right;
|
||||
p[4].y = 1;
|
||||
p[4].r = rr; p[4].g = rg; p[4].b = rb; p[4].a = ra;
|
||||
p[5].x = right;
|
||||
p[5].y = 0;
|
||||
p[5].r = rr; p[5].g = rg; p[5].b = rb; p[5].a = ra;
|
||||
|
||||
*position = &p[6];
|
||||
}
|
||||
|
||||
#ifdef DUMP_GRADIENTS_TO_PNG
|
||||
static void
|
||||
dump_gradient_to_png (CoglTexture *texture)
|
||||
{
|
||||
cairo_image_surface_t *image = (cairo_image_surface_t *)
|
||||
cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
cogl_texture_get_width (texture),
|
||||
cogl_texture_get_height (texture));
|
||||
CoglPixelFormat format;
|
||||
static int gradient_id = 0;
|
||||
char *gradient_name;
|
||||
|
||||
if (image->base.status)
|
||||
return;
|
||||
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
|
||||
#else
|
||||
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
|
||||
#endif
|
||||
cogl_texture_get_data (texture,
|
||||
format,
|
||||
0,
|
||||
image->data);
|
||||
gradient_name = g_strdup_printf ("./gradient%d.png", gradient_id++);
|
||||
g_print ("writing gradient: %s\n", gradient_name);
|
||||
cairo_surface_write_to_png ((cairo_surface_t *)image, gradient_name);
|
||||
g_free (gradient_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
cairo_int_status_t
|
||||
_cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
|
||||
cairo_extend_t extend_mode,
|
||||
int n_stops,
|
||||
const cairo_gradient_stop_t *stops,
|
||||
const cairo_bool_t need_mirrored_gradient,
|
||||
cairo_cogl_linear_gradient_t **gradient_out)
|
||||
{
|
||||
uintptr_t hash;
|
||||
cairo_cogl_linear_gradient_t *gradient;
|
||||
cairo_cogl_linear_texture_entry_t *entry;
|
||||
cairo_gradient_stop_t *internal_stops;
|
||||
int stop_offset;
|
||||
int n_internal_stops;
|
||||
int n;
|
||||
cairo_cogl_gradient_compatibility_t compatibilities;
|
||||
int width;
|
||||
int tex_width;
|
||||
int left_padding = 0;
|
||||
cairo_color_stop_t left_padding_color;
|
||||
int right_padding = 0;
|
||||
cairo_color_stop_t right_padding_color;
|
||||
CoglTextureComponents components;
|
||||
CoglTexture2D *tex;
|
||||
int un_padded_width;
|
||||
CoglFramebuffer *offscreen = NULL;
|
||||
cairo_int_status_t status;
|
||||
int n_quads;
|
||||
int n_vertices;
|
||||
float prev;
|
||||
float right;
|
||||
CoglVertexP2C4 *vertices;
|
||||
CoglVertexP2C4 *p;
|
||||
CoglPrimitive *prim;
|
||||
CoglPipeline *pipeline;
|
||||
|
||||
hash = _cairo_cogl_linear_gradient_hash (n_stops, stops);
|
||||
|
||||
gradient = _cairo_cogl_linear_gradient_lookup (device, hash, n_stops, stops);
|
||||
if (gradient) {
|
||||
cairo_cogl_linear_texture_entry_t *entry =
|
||||
_cairo_cogl_linear_gradient_texture_for_extend (gradient, extend_mode);
|
||||
if (entry) {
|
||||
*gradient_out = _cairo_cogl_linear_gradient_reference (gradient);
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gradient) {
|
||||
gradient = _cairo_malloc (sizeof (cairo_cogl_linear_gradient_t) +
|
||||
sizeof (cairo_gradient_stop_t) * (n_stops - 1));
|
||||
if (!gradient)
|
||||
return CAIRO_INT_STATUS_NO_MEMORY;
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&gradient->ref_count, 1);
|
||||
/* NB: we update the cache_entry size at the end before
|
||||
* [re]adding it to the cache. */
|
||||
gradient->cache_entry.hash = hash;
|
||||
gradient->textures = NULL;
|
||||
gradient->n_stops = n_stops;
|
||||
gradient->stops = gradient->stops_embedded;
|
||||
memcpy (gradient->stops_embedded, stops, sizeof (cairo_gradient_stop_t) * n_stops);
|
||||
} else {
|
||||
_cairo_cogl_linear_gradient_reference (gradient);
|
||||
}
|
||||
|
||||
entry = _cairo_malloc (sizeof (cairo_cogl_linear_texture_entry_t));
|
||||
if (unlikely (!entry)) {
|
||||
status = CAIRO_INT_STATUS_NO_MEMORY;
|
||||
goto BAIL;
|
||||
}
|
||||
|
||||
compatibilities = _cairo_cogl_compatibility_from_extend_mode (extend_mode);
|
||||
|
||||
n_internal_stops = n_stops;
|
||||
stop_offset = 0;
|
||||
|
||||
/* We really need stops covering the full [0,1] range for repeat/reflect
|
||||
* if we want to use sampler REPEAT/MIRROR wrap modes so we may need
|
||||
* to add some extra stops... */
|
||||
if (extend_mode == CAIRO_EXTEND_REPEAT || extend_mode == CAIRO_EXTEND_REFLECT)
|
||||
{
|
||||
/* If we don't need any extra stops then actually the texture
|
||||
* will be shareable for repeat and reflect... */
|
||||
compatibilities = (CAIRO_COGL_GRADIENT_CAN_EXTEND_REPEAT |
|
||||
CAIRO_COGL_GRADIENT_CAN_EXTEND_REFLECT);
|
||||
|
||||
if (stops[0].offset != 0) {
|
||||
n_internal_stops++;
|
||||
stop_offset++;
|
||||
}
|
||||
|
||||
if (stops[n_stops - 1].offset != 1)
|
||||
n_internal_stops++;
|
||||
}
|
||||
|
||||
internal_stops = alloca (n_internal_stops * sizeof (cairo_gradient_stop_t));
|
||||
memcpy (&internal_stops[stop_offset], stops, sizeof (cairo_gradient_stop_t) * n_stops);
|
||||
|
||||
/* cairo_color_stop_t values are all unpremultiplied but we need to
|
||||
* interpolate premultiplied colors so we premultiply all the double
|
||||
* components now. (skipping any extra stops added for repeat/reflect)
|
||||
*
|
||||
* Another thing to note is that by premultiplying the colors
|
||||
* early we'll also reduce the range of colors to interpolate
|
||||
* which can result in smaller gradient textures.
|
||||
*/
|
||||
for (n = stop_offset; n < n_stops; n++) {
|
||||
cairo_color_stop_t *color = &internal_stops[n].color;
|
||||
color->red *= color->alpha;
|
||||
color->green *= color->alpha;
|
||||
color->blue *= color->alpha;
|
||||
}
|
||||
|
||||
if (n_internal_stops != n_stops)
|
||||
{
|
||||
if (extend_mode == CAIRO_EXTEND_REPEAT) {
|
||||
compatibilities &= ~CAIRO_COGL_GRADIENT_CAN_EXTEND_REFLECT;
|
||||
if (stops[0].offset != 0) {
|
||||
/* what's the wrap-around distance between the user's end-stops? */
|
||||
double dx = (1.0 - stops[n_stops - 1].offset) + stops[0].offset;
|
||||
internal_stops[0].offset = 0;
|
||||
color_stop_lerp (&stops[0].color,
|
||||
&stops[n_stops - 1].color,
|
||||
stops[0].offset / dx,
|
||||
&internal_stops[0].color);
|
||||
}
|
||||
if (stops[n_stops - 1].offset != 1) {
|
||||
internal_stops[n_internal_stops - 1].offset = 1;
|
||||
internal_stops[n_internal_stops - 1].color = internal_stops[0].color;
|
||||
}
|
||||
} else if (extend_mode == CAIRO_EXTEND_REFLECT) {
|
||||
compatibilities &= ~CAIRO_COGL_GRADIENT_CAN_EXTEND_REPEAT;
|
||||
if (stops[0].offset != 0) {
|
||||
internal_stops[0].offset = 0;
|
||||
internal_stops[0].color = stops[n_stops - 1].color;
|
||||
}
|
||||
if (stops[n_stops - 1].offset != 1) {
|
||||
internal_stops[n_internal_stops - 1].offset = 1;
|
||||
internal_stops[n_internal_stops - 1].color = stops[0].color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stops = internal_stops;
|
||||
n_stops = n_internal_stops;
|
||||
|
||||
width = _cairo_cogl_linear_gradient_width_for_stops (extend_mode, n_stops, stops);
|
||||
|
||||
if (extend_mode == CAIRO_EXTEND_PAD) {
|
||||
|
||||
/* Here we need to guarantee that the edge texels of our
|
||||
* texture correspond to the desired padding color so we
|
||||
* can use CLAMP_TO_EDGE.
|
||||
*
|
||||
* For short stop-gaps and especially for degenerate stops
|
||||
* it's possible that without special consideration the
|
||||
* user's end stop colors would not be present in our final
|
||||
* texture.
|
||||
*
|
||||
* To handle this we forcibly add two extra padding texels
|
||||
* at the edges which extend beyond the [0,1] range of the
|
||||
* gradient itself and we will later report a translate and
|
||||
* scale transform to compensate for this.
|
||||
*/
|
||||
|
||||
/* XXX: If we consider generating a mipmap for our 1d texture
|
||||
* at some point then we also need to consider how much
|
||||
* padding to add to be sure lower mipmap levels still have
|
||||
* the desired edge color (as opposed to a linear blend with
|
||||
* other colors of the gradient).
|
||||
*/
|
||||
|
||||
left_padding = 1;
|
||||
left_padding_color = stops[0].color;
|
||||
right_padding = 1;
|
||||
right_padding_color = stops[n_stops - 1].color;
|
||||
} else if (extend_mode == CAIRO_EXTEND_NONE) {
|
||||
/* We handle EXTEND_NONE by adding two extra, transparent, texels at
|
||||
* the ends of the texture and use CLAMP_TO_EDGE.
|
||||
*
|
||||
* We add a scale and translate transform so to account for our texels
|
||||
* extending beyond the [0,1] range. */
|
||||
|
||||
left_padding = 1;
|
||||
left_padding_color.red = 0;
|
||||
left_padding_color.green = 0;
|
||||
left_padding_color.blue = 0;
|
||||
left_padding_color.alpha = 0;
|
||||
right_padding = 1;
|
||||
right_padding_color = left_padding_color;
|
||||
}
|
||||
|
||||
/* If we still have stops that don't cover the full [0,1] range
|
||||
* then we need to define a texture-coordinate scale + translate
|
||||
* transform to account for that... */
|
||||
if (stops[n_stops - 1].offset - stops[0].offset < 1) {
|
||||
float range = stops[n_stops - 1].offset - stops[0].offset;
|
||||
entry->scale_x = 1.0 / range;
|
||||
entry->translate_x = -(stops[0].offset * entry->scale_x);
|
||||
}
|
||||
|
||||
width += left_padding + right_padding;
|
||||
|
||||
width = _cairo_cogl_util_next_p2 (width);
|
||||
width = MIN (4096, width); /* lets not go too stupidly big! */
|
||||
|
||||
if (!device->has_npots)
|
||||
width = pow (2, ceil (log2 (width)));
|
||||
|
||||
if (need_mirrored_gradient)
|
||||
tex_width = width * 2;
|
||||
else
|
||||
tex_width = width;
|
||||
|
||||
components = _cairo_cogl_linear_gradient_components_for_stops (extend_mode, n_stops, stops);
|
||||
|
||||
do {
|
||||
tex = cogl_texture_2d_new_with_size (device->cogl_context,
|
||||
tex_width, 1);
|
||||
} while (tex == NULL && width >> 1 && tex_width >> 1);
|
||||
|
||||
if (unlikely (!tex)) {
|
||||
status = CAIRO_INT_STATUS_NO_MEMORY;
|
||||
goto BAIL;
|
||||
}
|
||||
|
||||
cogl_texture_set_components (tex, components);
|
||||
|
||||
entry->texture = tex;
|
||||
entry->compatibility = compatibilities;
|
||||
|
||||
un_padded_width = width - left_padding - right_padding;
|
||||
|
||||
/* XXX: only when we know the final texture width can we calculate the
|
||||
* scale and translate factors needed to account for padding... */
|
||||
if (un_padded_width != width)
|
||||
entry->scale_x *= (float)un_padded_width / (float)width;
|
||||
if (left_padding)
|
||||
entry->translate_x += (entry->scale_x / (float)un_padded_width) * (float)left_padding;
|
||||
|
||||
offscreen = cogl_offscreen_new_with_texture (tex);
|
||||
cogl_framebuffer_orthographic (offscreen, 0, 0,
|
||||
tex_width, 1,
|
||||
-1, 100);
|
||||
cogl_framebuffer_clear4f (offscreen,
|
||||
COGL_BUFFER_BIT_COLOR,
|
||||
0, 0, 0, 0);
|
||||
|
||||
n_quads = n_stops - 1 + !!left_padding + !!right_padding;
|
||||
n_vertices = 6 * n_quads;
|
||||
vertices = _cairo_malloc_ab (n_vertices, sizeof (CoglVertexP2C4));
|
||||
if (unlikely (!vertices)) {
|
||||
status = CAIRO_INT_STATUS_NO_MEMORY;
|
||||
goto BAIL;
|
||||
}
|
||||
|
||||
p = vertices;
|
||||
if (left_padding)
|
||||
emit_stop (&p, 0, left_padding, &left_padding_color, &left_padding_color);
|
||||
prev = (float)left_padding;
|
||||
for (n = 1; n < n_stops; n++) {
|
||||
right = (float)left_padding + (float)un_padded_width * stops[n].offset;
|
||||
emit_stop (&p, prev, right, &stops[n-1].color, &stops[n].color);
|
||||
prev = right;
|
||||
}
|
||||
if (right_padding)
|
||||
emit_stop (&p, prev, width, &right_padding_color, &right_padding_color);
|
||||
|
||||
prim = cogl_primitive_new_p2c4 (device->cogl_context,
|
||||
COGL_VERTICES_MODE_TRIANGLES,
|
||||
n_vertices,
|
||||
vertices);
|
||||
free (vertices);
|
||||
pipeline = cogl_pipeline_new (device->cogl_context);
|
||||
cogl_primitive_draw (prim, offscreen, pipeline);
|
||||
|
||||
if (need_mirrored_gradient) {
|
||||
/* In order to use a reflected gradient on hardware that
|
||||
* doesn't have a mirrored repeating texture wrap mode, we
|
||||
* render two reflected images to a double-length linear
|
||||
* texture and reflect that */
|
||||
CoglMatrix transform;
|
||||
|
||||
cogl_matrix_init_identity (&transform);
|
||||
cogl_matrix_translate (&transform, tex_width, 0.0f, 0.0f);
|
||||
cogl_matrix_scale (&transform, -1.0f, 1.0f, 1.0f);
|
||||
|
||||
cogl_framebuffer_transform (offscreen, &transform);
|
||||
cogl_primitive_draw (prim, offscreen, pipeline);
|
||||
}
|
||||
|
||||
cogl_object_unref (prim);
|
||||
cogl_object_unref (pipeline);
|
||||
|
||||
cogl_object_unref (offscreen);
|
||||
offscreen = NULL;
|
||||
|
||||
gradient->textures = g_list_prepend (gradient->textures, entry);
|
||||
gradient->cache_entry.size = _cairo_cogl_linear_gradient_size (gradient);
|
||||
|
||||
#ifdef DUMP_GRADIENTS_TO_PNG
|
||||
dump_gradient_to_png (tex);
|
||||
#endif
|
||||
|
||||
#warning "FIXME:"
|
||||
/* XXX: it seems the documentation of _cairo_cache_insert isn't true - it
|
||||
* doesn't handle re-adding the same entry gracefully - the cache will
|
||||
* just keep on growing and then it will start randomly evicting things
|
||||
* pointlessly */
|
||||
/* we ignore errors here and just return an uncached gradient */
|
||||
if (likely (! _cairo_cache_insert (&device->linear_cache, &gradient->cache_entry)))
|
||||
_cairo_cogl_linear_gradient_reference (gradient);
|
||||
|
||||
*gradient_out = gradient;
|
||||
return CAIRO_INT_STATUS_SUCCESS;
|
||||
|
||||
BAIL:
|
||||
free (entry);
|
||||
if (gradient)
|
||||
_cairo_cogl_linear_gradient_destroy (gradient);
|
||||
if (offscreen)
|
||||
cogl_object_unref (offscreen);
|
||||
return status;
|
||||
}
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2011 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.og/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_COGL_PRIVATE_H
|
||||
#define CAIRO_COGL_PRIVATE_H
|
||||
|
||||
#include "cairo-device-private.h"
|
||||
#include "cairo-cache-private.h"
|
||||
#include "cairo-backend-private.h"
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-surface-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
|
||||
#include <cogl/cogl2-experimental.h>
|
||||
|
||||
typedef enum _cairo_cogl_template_type {
|
||||
/* solid source */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_SOLID,
|
||||
/* solid source with solid mask */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_SOLID_MASK_SOLID,
|
||||
/* solid source with texture mask */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_TEXTURE_MASK_SOLID,
|
||||
/* texture source */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_TEXTURE,
|
||||
/* texture source with solid mask */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_SOLID_MASK_TEXTURE,
|
||||
/* texture source with texture mask */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_TEXTURE_MASK_TEXTURE,
|
||||
/* texture source with source alpha ignored */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_TEXTURE_IGNORE_ALPHA,
|
||||
/* texture source with solid mask with source alpha ignored */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_SOLID_MASK_TEXTURE_IGNORE_ALPHA,
|
||||
/* texture source with texture mask with source alpha ignored */
|
||||
CAIRO_COGL_TEMPLATE_TYPE_TEXTURE_MASK_TEXTURE_IGNORE_ALPHA,
|
||||
CAIRO_COGL_TEMPLATE_TYPE_COUNT
|
||||
} cairo_cogl_template_type;
|
||||
|
||||
typedef struct _cairo_cogl_device {
|
||||
cairo_device_t base;
|
||||
|
||||
CoglContext *cogl_context;
|
||||
|
||||
cairo_bool_t has_npots;
|
||||
cairo_bool_t has_mirrored_repeat;
|
||||
|
||||
CoglAttributeBuffer *buffer_stack;
|
||||
size_t buffer_stack_size;
|
||||
size_t buffer_stack_offset;
|
||||
guint8 *buffer_stack_pointer;
|
||||
|
||||
/* This is a limited set of templates because we don't support the
|
||||
* full range of operators that cairo has. The CAIRO_OPERATOR_ADD
|
||||
* is the operator enum with the highest value that we support so
|
||||
* we cap the size of the array by that.
|
||||
*
|
||||
* For each operator, we have a template for when we have a solid
|
||||
* source and a non-solid source. For each of those, we also have
|
||||
* additional templates for when we have a solid mask or a
|
||||
* non-solid mask, for a total of six templates per operator.
|
||||
*
|
||||
* The templates are set to null at device creation time and only
|
||||
* actually created on their first use.
|
||||
*/
|
||||
CoglPipeline *template_pipelines[CAIRO_OPERATOR_ADD + 1][CAIRO_COGL_TEMPLATE_TYPE_COUNT];
|
||||
|
||||
/* Caches 1d linear gradient textures */
|
||||
cairo_cache_t linear_cache;
|
||||
|
||||
cairo_cache_t path_fill_prim_cache;
|
||||
cairo_cache_t path_stroke_prim_cache;
|
||||
|
||||
cairo_freelist_t path_fill_meta_freelist;
|
||||
cairo_freelist_t path_stroke_meta_freelist;
|
||||
} cairo_cogl_device_t;
|
||||
|
||||
typedef struct _cairo_cogl_clip_primitives {
|
||||
cairo_t *clip;
|
||||
CoglPrimitive **primitives;
|
||||
} cairo_cogl_clip_primitives_t;
|
||||
|
||||
typedef struct _cairo_cogl_surface {
|
||||
cairo_surface_t base;
|
||||
|
||||
/* We currently have 3 basic kinds of Cogl surfaces:
|
||||
* 1) A light surface simply wrapping a CoglTexture
|
||||
* 2) A CoglOffscreen framebuffer that implicitly also wraps a CoglTexture
|
||||
* 3) A CoglOnscreen framebuffer which could potentially be mapped to
|
||||
* a CoglTexture (e.g. via tfp on X11) but we don't currently do
|
||||
* that.
|
||||
*/
|
||||
|
||||
CoglTexture *texture;
|
||||
CoglFramebuffer *framebuffer;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
/* Is this a snapshot used for mirrored repeating on hardware which
|
||||
* doesn't have it, consisting of four reflected images? */
|
||||
cairo_bool_t is_mirrored_snapshot;
|
||||
|
||||
GQueue *journal;
|
||||
|
||||
cairo_clip_t *last_clip;
|
||||
|
||||
/* A small fifo of recently used cairo_clip_ts paired with CoglPrimitives
|
||||
* that can be used to mask the stencil buffer. */
|
||||
GList *clips_fifo;
|
||||
|
||||
int n_clip_updates_per_frame;
|
||||
|
||||
/* Since the surface backend drawing operator functions don't get
|
||||
* passed the current cairo_t context we don't have a good way
|
||||
* to get our user-coordinates path into our surface_fill function.
|
||||
*
|
||||
* For now we use our _cairo_cogl_context_fill() wrapper to set this
|
||||
* side band data on the surface...
|
||||
*/
|
||||
cairo_path_fixed_t *user_path;
|
||||
cairo_matrix_t ctm;
|
||||
cairo_matrix_t ctm_inverse;
|
||||
cairo_bool_t path_is_rectangle;
|
||||
double path_rectangle_x;
|
||||
double path_rectangle_y;
|
||||
double path_rectangle_width;
|
||||
double path_rectangle_height;
|
||||
} cairo_cogl_surface_t;
|
||||
|
||||
cairo_status_t
|
||||
_cairo_cogl_path_fixed_rectangle (cairo_path_fixed_t *path,
|
||||
cairo_fixed_t x,
|
||||
cairo_fixed_t y,
|
||||
cairo_fixed_t width,
|
||||
cairo_fixed_t height);
|
||||
|
||||
#endif /* CAIRO_COGL_PRIVATE_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,86 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2011 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_COGL_H
|
||||
#define CAIRO_COGL_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_COGL_SURFACE
|
||||
|
||||
#include <cogl/cogl2-experimental.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_cogl_device_create (CoglContext *context);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_cogl_onscreen_surface_create (cairo_device_t *device,
|
||||
cairo_content_t content,
|
||||
int width, int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_cogl_offscreen_surface_create (cairo_device_t *device,
|
||||
cairo_content_t content,
|
||||
int width, int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_cogl_surface_create_for_fb (cairo_device_t *device,
|
||||
CoglFramebuffer *framebuffer,
|
||||
cairo_content_t content);
|
||||
|
||||
cairo_public CoglFramebuffer *
|
||||
cairo_cogl_surface_get_framebuffer (cairo_surface_t *surface);
|
||||
|
||||
/* If NPOT textures are not supported, the contents of interests may
|
||||
* only be in the lowest-coordinate corner of the texture obtained from
|
||||
* this function */
|
||||
cairo_public CoglTexture *
|
||||
cairo_cogl_surface_get_texture (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_cogl_surface_end_frame (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_cogl_surface_synchronize (cairo_surface_t *surface);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_COGL_SURFACE*/
|
||||
# error Cairo was not compiled with support for the Cogl backend
|
||||
#endif /* CAIRO_HAS_COGL_SURFACE*/
|
||||
|
||||
#endif /* CAIRO_COGL_H */
|
||||
|
|
@ -88,10 +88,6 @@ cairo_debug_reset_static_data (void)
|
|||
|
||||
_cairo_image_compositor_reset_static_data ();
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
_cairo_drm_device_reset_static_data ();
|
||||
#endif
|
||||
|
||||
_cairo_default_context_reset_static_data ();
|
||||
|
||||
CAIRO_MUTEX_FINALIZE ();
|
||||
|
|
|
|||
|
|
@ -1,545 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2012 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-directfb.h"
|
||||
|
||||
#include "cairo-clip-private.h"
|
||||
#include "cairo-compositor-private.h"
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-inline.h"
|
||||
#include "cairo-pattern-private.h"
|
||||
#include "cairo-surface-backend-private.h"
|
||||
#include "cairo-surface-fallback-private.h"
|
||||
|
||||
#include <pixman.h>
|
||||
|
||||
#include <directfb.h>
|
||||
#include <direct/types.h>
|
||||
#include <direct/debug.h>
|
||||
#include <direct/memcpy.h>
|
||||
#include <direct/util.h>
|
||||
|
||||
slim_hidden_proto(cairo_directfb_surface_create);
|
||||
|
||||
typedef struct _cairo_dfb_surface {
|
||||
cairo_image_surface_t image;
|
||||
|
||||
IDirectFB *dfb;
|
||||
IDirectFBSurface *dfb_surface;
|
||||
|
||||
unsigned blit_premultiplied : 1;
|
||||
} cairo_dfb_surface_t;
|
||||
|
||||
static cairo_content_t
|
||||
_directfb_format_to_content (DFBSurfacePixelFormat format)
|
||||
{
|
||||
cairo_content_t content = 0;
|
||||
|
||||
if (DFB_PIXELFORMAT_HAS_ALPHA (format))
|
||||
content |= CAIRO_CONTENT_ALPHA;
|
||||
if (DFB_COLOR_BITS_PER_PIXEL (format))
|
||||
content |= CAIRO_CONTENT_COLOR_ALPHA;
|
||||
|
||||
assert(content);
|
||||
return content;
|
||||
}
|
||||
|
||||
static inline pixman_format_code_t
|
||||
_directfb_to_pixman_format (DFBSurfacePixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case DSPF_UNKNOWN: return 0;
|
||||
case DSPF_ARGB1555: return PIXMAN_a1r5g5b5;
|
||||
case DSPF_RGB16: return PIXMAN_r5g6b5;
|
||||
case DSPF_RGB24: return PIXMAN_r8g8b8;
|
||||
case DSPF_RGB32: return PIXMAN_x8r8g8b8;
|
||||
case DSPF_ARGB: return PIXMAN_a8r8g8b8;
|
||||
case DSPF_A8: return PIXMAN_a8;
|
||||
case DSPF_YUY2: return PIXMAN_yuy2;
|
||||
case DSPF_RGB332: return PIXMAN_r3g3b2;
|
||||
case DSPF_UYVY: return 0;
|
||||
case DSPF_I420: return 0;
|
||||
case DSPF_YV12: return PIXMAN_yv12;
|
||||
case DSPF_LUT8: return 0;
|
||||
case DSPF_ALUT44: return 0;
|
||||
case DSPF_AiRGB: return 0;
|
||||
case DSPF_A1: return 0; /* bit reversed, oops */
|
||||
case DSPF_NV12: return 0;
|
||||
case DSPF_NV16: return 0;
|
||||
case DSPF_ARGB2554: return 0;
|
||||
case DSPF_ARGB4444: return PIXMAN_a4r4g4b4;
|
||||
case DSPF_NV21: return 0;
|
||||
case DSPF_AYUV: return 0;
|
||||
case DSPF_A4: return PIXMAN_a4;
|
||||
case DSPF_ARGB1666: return 0;
|
||||
case DSPF_ARGB6666: return 0;
|
||||
case DSPF_RGB18: return 0;
|
||||
case DSPF_LUT2: return 0;
|
||||
case DSPF_RGB444: return PIXMAN_x4r4g4b4;
|
||||
case DSPF_RGB555: return PIXMAN_x1r5g5b5;
|
||||
#if DFB_NUM_PIXELFORMATS >= 29
|
||||
case DSPF_BGR555: return PIXMAN_x1b5g5r5;
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_dfb_surface_create_similar (void *abstract_src,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_dfb_surface_t *other = abstract_src;
|
||||
DFBSurfacePixelFormat format;
|
||||
IDirectFBSurface *buffer;
|
||||
DFBSurfaceDescription dsc;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return _cairo_image_surface_create_with_content (content, width, height);
|
||||
|
||||
switch (content) {
|
||||
default:
|
||||
ASSERT_NOT_REACHED;
|
||||
case CAIRO_CONTENT_COLOR_ALPHA:
|
||||
format = DSPF_ARGB;
|
||||
break;
|
||||
case CAIRO_CONTENT_COLOR:
|
||||
format = DSPF_RGB32;
|
||||
break;
|
||||
case CAIRO_CONTENT_ALPHA:
|
||||
format = DSPF_A8;
|
||||
break;
|
||||
}
|
||||
|
||||
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
|
||||
dsc.caps = DSCAPS_PREMULTIPLIED;
|
||||
dsc.width = width;
|
||||
dsc.height = height;
|
||||
dsc.pixelformat = format;
|
||||
|
||||
if (other->dfb->CreateSurface (other->dfb, &dsc, &buffer))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_DEVICE_ERROR));
|
||||
|
||||
surface = cairo_directfb_surface_create (other->dfb, buffer);
|
||||
buffer->Release (buffer);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_dfb_surface_finish (void *abstract_surface)
|
||||
{
|
||||
cairo_dfb_surface_t *surface = abstract_surface;
|
||||
|
||||
surface->dfb_surface->Release (surface->dfb_surface);
|
||||
return _cairo_image_surface_finish (abstract_surface);
|
||||
}
|
||||
|
||||
static cairo_image_surface_t *
|
||||
_cairo_dfb_surface_map_to_image (void *abstract_surface,
|
||||
const cairo_rectangle_int_t *extents)
|
||||
{
|
||||
cairo_dfb_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->image.pixman_image == NULL) {
|
||||
IDirectFBSurface *buffer = surface->dfb_surface;
|
||||
pixman_image_t *image;
|
||||
void *data;
|
||||
int pitch;
|
||||
|
||||
if (buffer->Lock (buffer, DSLF_READ | DSLF_WRITE, &data, &pitch))
|
||||
return _cairo_image_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
image = pixman_image_create_bits (surface->image.pixman_format,
|
||||
surface->image.width,
|
||||
surface->image.height,
|
||||
data, pitch);
|
||||
if (image == NULL) {
|
||||
buffer->Unlock (buffer);
|
||||
return _cairo_image_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
_cairo_image_surface_init (&surface->image, image, surface->image.pixman_format);
|
||||
}
|
||||
|
||||
return _cairo_image_surface_map_to_image (&surface->image.base, extents);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_dfb_surface_unmap_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image)
|
||||
{
|
||||
cairo_dfb_surface_t *surface = abstract_surface;
|
||||
return _cairo_image_surface_unmap_image (&surface->image.base, image);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_dfb_surface_flush (void *abstract_surface,
|
||||
unsigned flags)
|
||||
{
|
||||
cairo_dfb_surface_t *surface = abstract_surface;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->image.pixman_image) {
|
||||
surface->dfb_surface->Unlock (surface->dfb_surface);
|
||||
|
||||
pixman_image_unref (surface->image.pixman_image);
|
||||
surface->image.pixman_image = NULL;
|
||||
surface->image.data = NULL;
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static inline DFBSurfacePixelFormat
|
||||
_directfb_from_pixman_format (pixman_format_code_t format)
|
||||
{
|
||||
switch ((int) format) {
|
||||
case PIXMAN_a1r5g5b5: return DSPF_ARGB1555;
|
||||
case PIXMAN_r5g6b5: return DSPF_RGB16;
|
||||
case PIXMAN_r8g8b8: return DSPF_RGB24;
|
||||
case PIXMAN_x8r8g8b8: return DSPF_RGB32;
|
||||
case PIXMAN_a8r8g8b8: return DSPF_ARGB;
|
||||
case PIXMAN_a8: return DSPF_A8;
|
||||
case PIXMAN_yuy2: return DSPF_YUY2;
|
||||
case PIXMAN_r3g3b2: return DSPF_RGB332;
|
||||
case PIXMAN_yv12: return DSPF_YV12;
|
||||
case PIXMAN_a1: return DSPF_A1; /* bit reversed, oops */
|
||||
case PIXMAN_a4r4g4b4: return DSPF_ARGB4444;
|
||||
case PIXMAN_a4: return DSPF_A4;
|
||||
case PIXMAN_x4r4g4b4: return DSPF_RGB444;
|
||||
case PIXMAN_x1r5g5b5: return DSPF_RGB555;
|
||||
#if DFB_NUM_PIXELFORMATS >= 29
|
||||
case PIXMAN_x1b5g5r5: return DSPF_BGR555;
|
||||
#endif
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_directfb_get_operator (cairo_operator_t operator,
|
||||
DFBSurfaceBlendFunction *ret_srcblend,
|
||||
DFBSurfaceBlendFunction *ret_dstblend)
|
||||
{
|
||||
DFBSurfaceBlendFunction srcblend = DSBF_ONE;
|
||||
DFBSurfaceBlendFunction dstblend = DSBF_ZERO;
|
||||
|
||||
switch (operator) {
|
||||
case CAIRO_OPERATOR_CLEAR:
|
||||
srcblend = DSBF_ZERO;
|
||||
dstblend = DSBF_ZERO;
|
||||
break;
|
||||
case CAIRO_OPERATOR_SOURCE:
|
||||
srcblend = DSBF_ONE;
|
||||
dstblend = DSBF_ZERO;
|
||||
break;
|
||||
case CAIRO_OPERATOR_OVER:
|
||||
srcblend = DSBF_ONE;
|
||||
dstblend = DSBF_INVSRCALPHA;
|
||||
break;
|
||||
case CAIRO_OPERATOR_IN:
|
||||
srcblend = DSBF_DESTALPHA;
|
||||
dstblend = DSBF_ZERO;
|
||||
break;
|
||||
case CAIRO_OPERATOR_OUT:
|
||||
srcblend = DSBF_INVDESTALPHA;
|
||||
dstblend = DSBF_ZERO;
|
||||
break;
|
||||
case CAIRO_OPERATOR_ATOP:
|
||||
srcblend = DSBF_DESTALPHA;
|
||||
dstblend = DSBF_INVSRCALPHA;
|
||||
break;
|
||||
case CAIRO_OPERATOR_DEST:
|
||||
srcblend = DSBF_ZERO;
|
||||
dstblend = DSBF_ONE;
|
||||
break;
|
||||
case CAIRO_OPERATOR_DEST_OVER:
|
||||
srcblend = DSBF_INVDESTALPHA;
|
||||
dstblend = DSBF_ONE;
|
||||
break;
|
||||
case CAIRO_OPERATOR_DEST_IN:
|
||||
srcblend = DSBF_ZERO;
|
||||
dstblend = DSBF_SRCALPHA;
|
||||
break;
|
||||
case CAIRO_OPERATOR_DEST_OUT:
|
||||
srcblend = DSBF_ZERO;
|
||||
dstblend = DSBF_INVSRCALPHA;
|
||||
break;
|
||||
case CAIRO_OPERATOR_DEST_ATOP:
|
||||
srcblend = DSBF_INVDESTALPHA;
|
||||
dstblend = DSBF_SRCALPHA;
|
||||
break;
|
||||
case CAIRO_OPERATOR_XOR:
|
||||
srcblend = DSBF_INVDESTALPHA;
|
||||
dstblend = DSBF_INVSRCALPHA;
|
||||
break;
|
||||
case CAIRO_OPERATOR_ADD:
|
||||
srcblend = DSBF_ONE;
|
||||
dstblend = DSBF_ONE;
|
||||
break;
|
||||
case CAIRO_OPERATOR_SATURATE:
|
||||
/* XXX This does not work. */
|
||||
#if 0
|
||||
srcblend = DSBF_SRCALPHASAT;
|
||||
dstblend = DSBF_ONE;
|
||||
break;
|
||||
#endif
|
||||
case CAIRO_OPERATOR_MULTIPLY:
|
||||
case CAIRO_OPERATOR_SCREEN:
|
||||
case CAIRO_OPERATOR_OVERLAY:
|
||||
case CAIRO_OPERATOR_DARKEN:
|
||||
case CAIRO_OPERATOR_LIGHTEN:
|
||||
case CAIRO_OPERATOR_COLOR_DODGE:
|
||||
case CAIRO_OPERATOR_COLOR_BURN:
|
||||
case CAIRO_OPERATOR_HARD_LIGHT:
|
||||
case CAIRO_OPERATOR_SOFT_LIGHT:
|
||||
case CAIRO_OPERATOR_DIFFERENCE:
|
||||
case CAIRO_OPERATOR_EXCLUSION:
|
||||
case CAIRO_OPERATOR_HSL_HUE:
|
||||
case CAIRO_OPERATOR_HSL_SATURATION:
|
||||
case CAIRO_OPERATOR_HSL_COLOR:
|
||||
case CAIRO_OPERATOR_HSL_LUMINOSITY:
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*ret_srcblend = srcblend;
|
||||
*ret_dstblend = dstblend;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#define RUN_CLIPPED(surface, clip_region, clip, func) {\
|
||||
if ((clip_region) != NULL) {\
|
||||
int n_clips = cairo_region_num_rectangles (clip_region), n; \
|
||||
for (n = 0; n < n_clips; n++) {\
|
||||
if (clip) {\
|
||||
DFBRegion reg, *cli = (clip); \
|
||||
cairo_rectangle_int_t rect; \
|
||||
cairo_region_get_rectangle (clip_region, n, &rect); \
|
||||
reg.x1 = rect.x; \
|
||||
reg.y1 = rect.y; \
|
||||
reg.x2 = rect.x + rect.width - 1; \
|
||||
reg.y2 = rect.y + rect.height - 1; \
|
||||
if (reg.x2 < cli->x1 || reg.y2 < cli->y1 ||\
|
||||
reg.x1 > cli->x2 || reg.y1 > cli->y2)\
|
||||
continue;\
|
||||
if (reg.x1 < cli->x1)\
|
||||
reg.x1 = cli->x1;\
|
||||
if (reg.y1 < cli->y1)\
|
||||
reg.y1 = cli->y1;\
|
||||
if (reg.x2 > cli->x2)\
|
||||
reg.x2 = cli->x2;\
|
||||
if (reg.y2 > cli->y2)\
|
||||
reg.y2 = cli->y2;\
|
||||
(surface)->dfbsurface->SetClip ((surface)->dfbsurface, ®);\
|
||||
} else {\
|
||||
DFBRegion reg; \
|
||||
cairo_rectangle_int_t rect; \
|
||||
cairo_region_get_rectangle (clip_region, n, &rect); \
|
||||
reg.x1 = rect.x; \
|
||||
reg.y1 = rect.y; \
|
||||
reg.x2 = rect.x + rect.width - 1; \
|
||||
reg.y2 = rect.y + rect.height - 1; \
|
||||
(surface)->dfbsurface->SetClip ((surface)->dfbsurface, ®); \
|
||||
}\
|
||||
func;\
|
||||
}\
|
||||
} else {\
|
||||
(surface)->dfbsurface->SetClip ((surface)->dfbsurface, clip);\
|
||||
func;\
|
||||
}\
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_dfb_surface_fill_rectangles (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_color_t *color,
|
||||
cairo_rectangle_int_t *rects,
|
||||
int n_rects)
|
||||
{
|
||||
cairo_dfb_surface_t *dst = abstract_surface;
|
||||
DFBSurfaceDrawingFlags flags;
|
||||
DFBSurfaceBlendFunction sblend;
|
||||
DFBSurfaceBlendFunction dblend;
|
||||
DFBRectangle r[n_rects];
|
||||
int i;
|
||||
|
||||
D_DEBUG_AT (CairoDFB_Render,
|
||||
"%s( dst=%p, op=%d, color=%p, rects=%p, n_rects=%d ).\n",
|
||||
__FUNCTION__, dst, op, color, rects, n_rects);
|
||||
|
||||
if (! dst->supported_destination)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
if (! _directfb_get_operator (op, &sblend, &dblend))
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
if (CAIRO_COLOR_IS_OPAQUE (color)) {
|
||||
if (sblend == DSBF_SRCALPHA)
|
||||
sblend = DSBF_ONE;
|
||||
else if (sblend == DSBF_INVSRCALPHA)
|
||||
sblend = DSBF_ZERO;
|
||||
|
||||
if (dblend == DSBF_SRCALPHA)
|
||||
dblend = DSBF_ONE;
|
||||
else if (dblend == DSBF_INVSRCALPHA)
|
||||
dblend = DSBF_ZERO;
|
||||
}
|
||||
if ((dst->base.content & CAIRO_CONTENT_ALPHA) == 0) {
|
||||
if (sblend == DSBF_DESTALPHA)
|
||||
sblend = DSBF_ONE;
|
||||
else if (sblend == DSBF_INVDESTALPHA)
|
||||
sblend = DSBF_ZERO;
|
||||
|
||||
if (dblend == DSBF_DESTALPHA)
|
||||
dblend = DSBF_ONE;
|
||||
else if (dblend == DSBF_INVDESTALPHA)
|
||||
dblend = DSBF_ZERO;
|
||||
}
|
||||
|
||||
flags = (sblend == DSBF_ONE && dblend == DSBF_ZERO) ? DSDRAW_NOFX : DSDRAW_BLEND;
|
||||
dst->dfbsurface->SetDrawingFlags (dst->dfbsurface, flags);
|
||||
if (flags & DSDRAW_BLEND) {
|
||||
dst->dfbsurface->SetSrcBlendFunction (dst->dfbsurface, sblend);
|
||||
dst->dfbsurface->SetDstBlendFunction (dst->dfbsurface, dblend);
|
||||
}
|
||||
|
||||
dst->dfbsurface->SetColor (dst->dfbsurface,
|
||||
color->red_short >> 8,
|
||||
color->green_short >> 8,
|
||||
color->blue_short >> 8,
|
||||
color->alpha_short >> 8);
|
||||
|
||||
for (i = 0; i < n_rects; i++) {
|
||||
r[i].x = rects[i].x;
|
||||
r[i].y = rects[i].y;
|
||||
r[i].w = rects[i].width;
|
||||
r[i].h = rects[i].height;
|
||||
}
|
||||
|
||||
RUN_CLIPPED (dst, NULL, NULL,
|
||||
dst->dfbsurface->FillRectangles (dst->dfbsurface, r, n_rects));
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static cairo_surface_backend_t
|
||||
_cairo_dfb_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DIRECTFB, /*type*/
|
||||
_cairo_dfb_surface_finish, /*finish*/
|
||||
_cairo_default_context_create,
|
||||
|
||||
_cairo_dfb_surface_create_similar,/*create_similar*/
|
||||
NULL, /* create similar image */
|
||||
_cairo_dfb_surface_map_to_image,
|
||||
_cairo_dfb_surface_unmap_image,
|
||||
|
||||
_cairo_surface_default_source,
|
||||
_cairo_surface_default_acquire_source_image,
|
||||
_cairo_surface_default_release_source_image,
|
||||
NULL,
|
||||
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
|
||||
_cairo_image_surface_get_extents,
|
||||
_cairo_image_surface_get_font_options,
|
||||
|
||||
_cairo_dfb_surface_flush,
|
||||
NULL, /* mark_dirty_rectangle */
|
||||
|
||||
_cairo_surface_fallback_paint,
|
||||
_cairo_surface_fallback_mask,
|
||||
_cairo_surface_fallback_stroke,
|
||||
_cairo_surface_fallback_fill,
|
||||
NULL, /* fill-stroke */
|
||||
_cairo_surface_fallback_glyphs,
|
||||
};
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
|
||||
{
|
||||
cairo_dfb_surface_t *surface;
|
||||
DFBSurfacePixelFormat format;
|
||||
DFBSurfaceCapabilities caps;
|
||||
pixman_format_code_t pixman_format;
|
||||
int width, height;
|
||||
|
||||
D_ASSERT (dfb != NULL);
|
||||
D_ASSERT (dfbsurface != NULL);
|
||||
|
||||
dfbsurface->GetPixelFormat (dfbsurface, &format);
|
||||
dfbsurface->GetSize (dfbsurface, &width, &height);
|
||||
|
||||
pixman_format = _directfb_to_pixman_format (format);
|
||||
if (! pixman_format_supported_destination (pixman_format))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
|
||||
surface = calloc (1, sizeof (cairo_dfb_surface_t));
|
||||
if (surface == NULL)
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
/* XXX dfb -> device */
|
||||
_cairo_surface_init (&surface->image.base,
|
||||
&_cairo_dfb_surface_backend,
|
||||
NULL, /* device */
|
||||
_directfb_format_to_content (format),
|
||||
FALSE); /* is_vector */
|
||||
|
||||
surface->image.pixman_format = pixman_format;
|
||||
surface->image.format = _cairo_format_from_pixman_format (pixman_format);
|
||||
|
||||
surface->image.width = width;
|
||||
surface->image.height = height;
|
||||
surface->image.depth = PIXMAN_FORMAT_DEPTH(pixman_format);
|
||||
|
||||
surface->dfb = dfb;
|
||||
surface->dfb_surface = dfbsurface;
|
||||
dfbsurface->AddRef (dfbsurface);
|
||||
|
||||
dfbsurface->GetCapabilities (dfbsurface, &caps);
|
||||
if (caps & DSCAPS_PREMULTIPLIED)
|
||||
surface->blit_premultiplied = TRUE;
|
||||
|
||||
return &surface->image.base;
|
||||
}
|
||||
slim_hidden_def(cairo_directfb_surface_create);
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2003 University of Southern California
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is University of Southern
|
||||
* California.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Carl D. Worth <cworth@isi.edu>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Environment variables affecting the backend:
|
||||
*
|
||||
* %CAIRO_DIRECTFB_NO_ACCEL (boolean)
|
||||
* if found, disables acceleration at all
|
||||
*
|
||||
* %CAIRO_DIRECTFB_ARGB_FONT (boolean)
|
||||
* if found, enables using ARGB fonts instead of A8
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DIRECTFB_H
|
||||
#define CAIRO_DIRECTFB_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_DIRECTFB_SURFACE
|
||||
|
||||
#include <directfb.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *surface);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /*CAIRO_HAS_DIRECTFB_SURFACE*/
|
||||
# error Cairo was not compiled with support for the directfb backend
|
||||
#endif /*CAIRO_HAS_DIRECTFB_SURFACE*/
|
||||
|
||||
#endif /*CAIRO_DIRECTFB_H*/
|
||||
120
src/cairo-drm.h
120
src/cairo-drm.h
|
|
@ -1,120 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_H
|
||||
#define CAIRO_DRM_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
struct udev_device;
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_drm_device_get (struct udev_device *device);
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_drm_device_get_for_fd (int fd);
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_drm_device_default (void);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_device_get_fd (cairo_device_t *device);
|
||||
|
||||
cairo_public void
|
||||
cairo_drm_device_throttle (cairo_device_t *device);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_create (cairo_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_create_for_name (cairo_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_create_from_cacheable_image (cairo_device_t *device,
|
||||
cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_drm_surface_enable_scan_out (cairo_surface_t *surface);
|
||||
|
||||
cairo_public unsigned int
|
||||
cairo_drm_surface_get_handle (cairo_surface_t *surface);
|
||||
|
||||
cairo_public unsigned int
|
||||
cairo_drm_surface_get_name (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_format_t
|
||||
cairo_drm_surface_get_format (cairo_surface_t *surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_surface_get_width (cairo_surface_t *surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_surface_get_height (cairo_surface_t *surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_surface_get_stride (cairo_surface_t *surface);
|
||||
|
||||
/* XXX map/unmap, general surface layer? */
|
||||
|
||||
/* Rough outline, culled from a conversation on IRC:
|
||||
* map() returns an image-surface representation of the drm-surface,
|
||||
* which you unmap() when you are finished, i.e. map() pulls the buffer back
|
||||
* from the GPU, maps it into the CPU domain and gives you direct access to
|
||||
* the pixels. With the unmap(), the buffer is ready to be used again by the
|
||||
* GPU and *until* the unmap(), all operations will be done in software.
|
||||
*
|
||||
* (Technically calling cairo_surface_flush() on the underlying drm-surface
|
||||
* will also disassociate the mapping.)
|
||||
*/
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_map_to_image (cairo_surface_t *surface);
|
||||
|
||||
cairo_public void
|
||||
cairo_drm_surface_unmap (cairo_surface_t *drm_surface,
|
||||
cairo_surface_t *image_surface);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_DRM_SURFACE */
|
||||
# error Cairo was not compiled with support for the DRM backend
|
||||
#endif /* CAIRO_HAS_DRM_SURFACE */
|
||||
|
||||
#endif /* CAIRO_DRM_H */
|
||||
|
|
@ -195,32 +195,6 @@
|
|||
# define CAIRO_MUTEX_IMPL_FINI(mutex) DeleteCriticalSection (&(mutex))
|
||||
# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER { NULL, 0, 0, NULL, NULL, 0 }
|
||||
|
||||
#elif defined __OS2__ /******************************************************/
|
||||
|
||||
# define INCL_BASE
|
||||
# define INCL_PM
|
||||
# include <os2.h>
|
||||
|
||||
typedef HMTX cairo_mutex_impl_t;
|
||||
|
||||
# define CAIRO_MUTEX_IMPL_OS2 1
|
||||
# define CAIRO_MUTEX_IMPL_LOCK(mutex) DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT)
|
||||
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) DosReleaseMutexSem(mutex)
|
||||
# define CAIRO_MUTEX_IMPL_INIT(mutex) DosCreateMutexSem (NULL, &(mutex), 0L, FALSE)
|
||||
# define CAIRO_MUTEX_IMPL_FINI(mutex) DosCloseMutexSem (mutex)
|
||||
# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER 0
|
||||
|
||||
#elif CAIRO_HAS_BEOS_SURFACE /***********************************************/
|
||||
|
||||
typedef BLocker* cairo_mutex_impl_t;
|
||||
|
||||
# define CAIRO_MUTEX_IMPL_BEOS 1
|
||||
# define CAIRO_MUTEX_IMPL_LOCK(mutex) (mutex)->Lock()
|
||||
# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) (mutex)->Unlock()
|
||||
# define CAIRO_MUTEX_IMPL_INIT(mutex) (mutex) = new BLocker()
|
||||
# define CAIRO_MUTEX_IMPL_FINI(mutex) delete (mutex)
|
||||
# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER NULL
|
||||
|
||||
#elif CAIRO_HAS_PTHREAD /* and finally if there are no native mutexes ********/
|
||||
|
||||
# include <pthread.h>
|
||||
|
|
|
|||
|
|
@ -72,8 +72,5 @@ CAIRO_MUTEX_DECLARE (_cairo_gl_context_mutex)
|
|||
CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex)
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
CAIRO_MUTEX_DECLARE (_cairo_drm_device_mutex)
|
||||
#endif
|
||||
/* Undefine, to err on unintended inclusion */
|
||||
#undef CAIRO_MUTEX_DECLARE
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
/* vim: set sw=4 sts=4 et cin: */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright (c) 2005-2006 netlabs.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Doodle <doodle@scenergy.dfmk.hu>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Weilbacher <mozilla@Weilbacher.org>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_OS2_PRIVATE_H
|
||||
#define CAIRO_OS2_PRIVATE_H
|
||||
|
||||
#include "cairo-os2.h"
|
||||
#include "cairoint.h"
|
||||
|
||||
typedef struct _cairo_os2_surface
|
||||
{
|
||||
cairo_surface_t base;
|
||||
|
||||
/* Mutex semaphore to protect private fields from concurrent access */
|
||||
HMTX hmtx_use_private_fields;
|
||||
/* Private fields: */
|
||||
HPS hps_client_window;
|
||||
HWND hwnd_client_window;
|
||||
BITMAPINFO2 bitmap_info;
|
||||
unsigned char *pixels;
|
||||
cairo_image_surface_t *image_surface;
|
||||
int pixel_array_lend_count;
|
||||
HEV hev_pixel_array_came_back;
|
||||
|
||||
RECTL rcl_dirty_area;
|
||||
cairo_bool_t dirty_area_present;
|
||||
|
||||
/* General flags: */
|
||||
cairo_bool_t blit_as_changes;
|
||||
cairo_bool_t use_24bpp;
|
||||
} cairo_os2_surface_t;
|
||||
|
||||
#endif /* CAIRO_OS2_PRIVATE_H */
|
||||
File diff suppressed because it is too large
Load diff
110
src/cairo-os2.h
110
src/cairo-os2.h
|
|
@ -1,110 +0,0 @@
|
|||
/* vim: set sw=4 sts=4 et cin: */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright (c) 2005-2006 netlabs.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Doodle <doodle@scenergy.dfmk.hu>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Weilbacher <mozilla@Weilbacher.org>
|
||||
* Rich Walsh <dragtext@e-vertise.com>
|
||||
*/
|
||||
|
||||
#ifndef _CAIRO_OS2_H_
|
||||
#define _CAIRO_OS2_H_
|
||||
|
||||
#define INCL_DOS
|
||||
#define INCL_DOSSEMAPHORES
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_WIN
|
||||
#define INCL_GPI
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
/* The OS/2 Specific Cairo API */
|
||||
|
||||
cairo_public void
|
||||
cairo_os2_init (void);
|
||||
|
||||
cairo_public void
|
||||
cairo_os2_fini (void);
|
||||
|
||||
#if CAIRO_HAS_OS2_SURFACE
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_os2_surface_create (HPS hps_client_window,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_os2_surface_create_for_window (HWND hwnd_client_window,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_public void
|
||||
cairo_os2_surface_set_hwnd (cairo_surface_t *surface,
|
||||
HWND hwnd_client_window);
|
||||
|
||||
cairo_public int
|
||||
cairo_os2_surface_set_size (cairo_surface_t *surface,
|
||||
int new_width,
|
||||
int new_height,
|
||||
int timeout);
|
||||
|
||||
cairo_public void
|
||||
cairo_os2_surface_refresh_window (cairo_surface_t *surface,
|
||||
HPS hps_begin_paint,
|
||||
PRECTL prcl_begin_paint_rect);
|
||||
|
||||
cairo_public void
|
||||
cairo_os2_surface_set_manual_window_refresh (cairo_surface_t *surface,
|
||||
cairo_bool_t manual_refresh);
|
||||
|
||||
cairo_public cairo_bool_t
|
||||
cairo_os2_surface_get_manual_window_refresh (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_os2_surface_get_hps (cairo_surface_t *surface,
|
||||
HPS *hps);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_os2_surface_set_hps (cairo_surface_t *surface,
|
||||
HPS hps);
|
||||
|
||||
#else /* CAIRO_HAS_OS2_SURFACE */
|
||||
# error Cairo was not compiled with support for the OS/2 backend
|
||||
#endif /* CAIRO_HAS_OS2_SURFACE */
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#endif /* _CAIRO_OS2_H_ */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,85 +0,0 @@
|
|||
/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2008 Mozilla Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@mozilla.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_QT_H
|
||||
#define CAIRO_QT_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_QT_SURFACE
|
||||
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_qt_surface_create (QPainter *painter);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_qt_surface_create_with_qimage (cairo_format_t format,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_qt_surface_create_with_qpixmap (cairo_content_t content,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_public QPainter *
|
||||
cairo_qt_surface_get_qpainter (cairo_surface_t *surface);
|
||||
|
||||
/* XXX needs hooking to generic surface layer, my vote is for
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_surface_map_image (cairo_surface_t *surface);
|
||||
cairo_public void
|
||||
cairo_surface_unmap_image (cairo_surface_t *surface, cairo_surface_t *image);
|
||||
*/
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_qt_surface_get_image (cairo_surface_t *surface);
|
||||
|
||||
cairo_public QImage *
|
||||
cairo_qt_surface_get_qimage (cairo_surface_t *surface);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_QT_SURFACE */
|
||||
|
||||
# error Cairo was not compiled with support for the Qt backend
|
||||
|
||||
#endif /* CAIRO_HAS_QT_SURFACE */
|
||||
|
||||
#endif /* CAIRO_QT_H */
|
||||
|
|
@ -61,34 +61,6 @@ _cairo_time_get (void)
|
|||
return mach_absolute_time ();
|
||||
}
|
||||
|
||||
#elif defined(__OS2__)
|
||||
#define INCL_BASE
|
||||
#include <os2.h>
|
||||
|
||||
static cairo_always_inline double
|
||||
_cairo_time_1s (void)
|
||||
{
|
||||
ULONG freq;
|
||||
|
||||
DosTmrQueryFreq (&freq);
|
||||
|
||||
return freq;
|
||||
}
|
||||
|
||||
cairo_time_t
|
||||
_cairo_time_get (void)
|
||||
{
|
||||
QWORD t;
|
||||
cairo_int64_t r;
|
||||
|
||||
DosTmrQueryTime (&t);
|
||||
|
||||
r = _cairo_int64_lsl (_cairo_int32_to_int64 (t.ulHi), 32);
|
||||
r = _cairo_int64_add (r, _cairo_int32_to_int64 (t.ulLo));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#elif _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
103
src/cairo-vg.h
103
src/cairo-vg.h
|
|
@ -1,103 +0,0 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2007 * Mozilla Corporation
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@mozilla.com>
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_VG_H
|
||||
#define CAIRO_VG_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_VG_SURFACE
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
typedef struct _cairo_vg_context cairo_vg_context_t;
|
||||
|
||||
#if CAIRO_HAS_GLX_FUNCTIONS
|
||||
typedef struct __GLXcontextRec *GLXContext;
|
||||
typedef struct _XDisplay Display;
|
||||
|
||||
cairo_public cairo_vg_context_t *
|
||||
cairo_vg_context_create_for_glx (Display *dpy,
|
||||
GLXContext ctx);
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_EGL_FUNCTIONS
|
||||
#include <EGL/egl.h>
|
||||
|
||||
cairo_public cairo_vg_context_t *
|
||||
cairo_vg_context_create_for_egl (EGLDisplay egl_display,
|
||||
EGLContext egl_context);
|
||||
#endif
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_vg_context_status (cairo_vg_context_t *context);
|
||||
|
||||
cairo_public void
|
||||
cairo_vg_context_destroy (cairo_vg_context_t *context);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_vg_surface_create (cairo_vg_context_t *context,
|
||||
cairo_content_t content, int width, int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_vg_surface_create_for_image (cairo_vg_context_t *context,
|
||||
VGImage image,
|
||||
VGImageFormat format,
|
||||
int width, int height);
|
||||
|
||||
cairo_public VGImage
|
||||
cairo_vg_surface_get_image (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_public VGImageFormat
|
||||
cairo_vg_surface_get_format (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_vg_surface_get_height (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_vg_surface_get_width (cairo_surface_t *abstract_surface);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_VG_SURFACE*/
|
||||
# error Cairo was not compiled with support for the OpenVG backend
|
||||
#endif /* CAIRO_HAS_VG_SURFACE*/
|
||||
|
||||
#endif /* CAIRO_VG_H */
|
||||
|
|
@ -461,11 +461,6 @@ _cairo_ft_font_reset_static_data (void);
|
|||
cairo_private void
|
||||
_cairo_win32_font_reset_static_data (void);
|
||||
|
||||
#if CAIRO_HAS_COGL_SURFACE
|
||||
void
|
||||
_cairo_cogl_context_reset_static_data (void);
|
||||
#endif
|
||||
|
||||
/* the font backend interface */
|
||||
|
||||
struct _cairo_unscaled_font_backend {
|
||||
|
|
@ -1895,13 +1890,6 @@ _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
|
|||
double tx, double ty,
|
||||
double sx, double sy);
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_device_reset_static_data (void);
|
||||
|
||||
#endif
|
||||
|
||||
cairo_private void
|
||||
_cairo_clip_reset_static_data (void);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ echo Checking public headers for missing cairo_public decorators
|
|||
cd "$srcdir"
|
||||
FILES=$all_cairo_headers
|
||||
if test "x$FILES" = x; then
|
||||
FILES=`find . -name 'cairo*.h' ! -name '*-private.h' ! -name 'cairoint.h' ! -name '*-inline.h' ! -name cairo-drm-intel-brw-eu.h`
|
||||
FILES=`find . -name 'cairo*.h' ! -name '*-private.h' ! -name 'cairoint.h' ! -name '*-inline.h'`
|
||||
fi
|
||||
|
||||
grep -B 1 '^cairo_.*[ ]\+(' /dev/null $FILES |
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <libdrm/drm.h>
|
||||
|
||||
#define ERR_DEBUG(x) x
|
||||
|
||||
cairo_status_t
|
||||
_cairo_drm_bo_open_for_name (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo,
|
||||
uint32_t name)
|
||||
{
|
||||
struct drm_gem_open open;
|
||||
int ret;
|
||||
|
||||
open.name = name;
|
||||
open.handle = 0;
|
||||
open.size = 0;
|
||||
do {
|
||||
ret = ioctl (dev->fd, DRM_IOCTL_GEM_OPEN, &open);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (ret == -1) {
|
||||
ERR_DEBUG((fprintf (stderr, "Failed to open bo for name %d: %s\n",
|
||||
name, strerror (errno))));
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
bo->name = name;
|
||||
bo->size = open.size;
|
||||
bo->handle = open.handle;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_drm_bo_flink (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
int ret;
|
||||
|
||||
memset (&flink, 0, sizeof (flink));
|
||||
flink.handle = bo->handle;
|
||||
ret = ioctl (dev->fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
if (ret == -1) {
|
||||
ERR_DEBUG((fprintf (stderr, "Failed to flink bo: %s\n",
|
||||
strerror (errno))));
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
bo->name = flink.name;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_drm_bo_close (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo)
|
||||
{
|
||||
struct drm_gem_close close;
|
||||
int ret;
|
||||
|
||||
close.handle = bo->handle;
|
||||
do {
|
||||
ret = ioctl (dev->fd, DRM_IOCTL_GEM_CLOSE, &close);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
}
|
||||
|
|
@ -1,826 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
* Copyright © 2009 Eric Anholt
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <state_tracker/drm_api.h>
|
||||
#include <pipe/p_format.h>
|
||||
#include <pipe/p_screen.h>
|
||||
#include <pipe/p_context.h>
|
||||
#include <pipe/p_state.h>
|
||||
|
||||
#include <util/u_inlines.h>
|
||||
|
||||
typedef struct _gallium_surface gallium_surface_t;
|
||||
typedef struct _gallium_device gallium_device_t;
|
||||
|
||||
struct _gallium_device {
|
||||
cairo_drm_device_t drm;
|
||||
|
||||
void *dlhandle;
|
||||
struct drm_api *api;
|
||||
|
||||
struct pipe_screen *screen;
|
||||
struct pipe_context *pipe;
|
||||
|
||||
int max_size;
|
||||
};
|
||||
|
||||
struct _gallium_surface {
|
||||
cairo_drm_surface_t drm;
|
||||
|
||||
enum pipe_format pipe_format;
|
||||
|
||||
struct pipe_resource *texture;
|
||||
struct pipe_transfer *map_transfer;
|
||||
|
||||
cairo_surface_t *fallback;
|
||||
};
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_internal (gallium_device_t *device,
|
||||
enum pipe_format format,
|
||||
int width, int height);
|
||||
|
||||
static inline gallium_device_t *
|
||||
gallium_device (gallium_surface_t *surface)
|
||||
{
|
||||
return (gallium_device_t *) surface->drm.base.device;
|
||||
}
|
||||
|
||||
static cairo_format_t
|
||||
_cairo_format_from_pipe_format (enum pipe_format format)
|
||||
{
|
||||
switch ((int) format) {
|
||||
case PIPE_FORMAT_A8_UNORM:
|
||||
return CAIRO_FORMAT_A8;
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
default:
|
||||
return CAIRO_FORMAT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static enum pipe_format
|
||||
pipe_format_from_format (cairo_format_t format)
|
||||
{
|
||||
switch ((int) format) {
|
||||
case CAIRO_FORMAT_A8:
|
||||
return PIPE_FORMAT_A8_UNORM;
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
return PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
default:
|
||||
return (enum pipe_format) -1;
|
||||
}
|
||||
}
|
||||
|
||||
static enum pipe_format
|
||||
pipe_format_from_content (cairo_content_t content)
|
||||
{
|
||||
if (content == CAIRO_CONTENT_ALPHA)
|
||||
return PIPE_FORMAT_A8_UNORM;
|
||||
else
|
||||
return PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
format_is_supported_destination (gallium_device_t *device,
|
||||
enum pipe_format format)
|
||||
{
|
||||
if (format == (enum pipe_format) -1)
|
||||
return FALSE;
|
||||
|
||||
return device->screen->is_format_supported (device->screen,
|
||||
format,
|
||||
0,
|
||||
PIPE_BIND_RENDER_TARGET,
|
||||
0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static cairo_bool_t
|
||||
format_is_supported_source (gallium_device_t *device,
|
||||
enum pipe_format format)
|
||||
{
|
||||
return device->screen->is_format_supported (device->screen,
|
||||
format,
|
||||
0,
|
||||
PIPE_BIND_SAMPLER_VIEW,
|
||||
0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_similar (void *abstract_src,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gallium_surface_t *other = abstract_src;
|
||||
gallium_device_t *device = gallium_device (other);
|
||||
enum pipe_format pipe_format;
|
||||
cairo_surface_t *surface = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
|
||||
if (MAX (width, height) > device->max_size)
|
||||
goto RELEASE;
|
||||
|
||||
if (content == other->drm.base.content)
|
||||
pipe_format = other->pipe_format;
|
||||
else
|
||||
pipe_format = pipe_format_from_content (content);
|
||||
|
||||
if (! format_is_supported_destination (device, pipe_format))
|
||||
goto RELEASE;
|
||||
|
||||
surface = gallium_surface_create_internal (device,
|
||||
pipe_format,
|
||||
width, height);
|
||||
|
||||
RELEASE:
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
gallium_surface_finish (void *abstract_surface)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_status_t status;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
pipe_resource_reference (&surface->texture, NULL);
|
||||
cairo_device_release (&device->drm.base);
|
||||
}
|
||||
|
||||
return _cairo_drm_surface_finish (&surface->drm);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_map_to_image (gallium_surface_t *surface)
|
||||
{
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_status_t status;
|
||||
void *ptr = NULL;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
|
||||
surface->map_transfer =
|
||||
pipe_get_transfer (device->pipe,
|
||||
surface->texture, 0, 0, 0,
|
||||
PIPE_TRANSFER_MAP_DIRECTLY |
|
||||
PIPE_TRANSFER_READ_WRITE,
|
||||
0, 0,
|
||||
surface->drm.width,
|
||||
surface->drm.height);
|
||||
if (likely (surface->map_transfer != NULL))
|
||||
ptr = device->pipe->transfer_map (device->pipe, surface->map_transfer);
|
||||
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
if (unlikely (ptr == NULL)) {
|
||||
if (surface->map_transfer != NULL) {
|
||||
device->pipe->transfer_destroy (device->pipe,
|
||||
surface->map_transfer);
|
||||
surface->map_transfer = NULL;
|
||||
}
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
|
||||
return cairo_image_surface_create_for_data (ptr,
|
||||
surface->drm.format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->map_transfer->stride);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
gallium_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_format_t format;
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
struct pipe_transfer *transfer;
|
||||
void *ptr;
|
||||
|
||||
if (surface->fallback != NULL) {
|
||||
*image_out = (cairo_image_surface_t *)
|
||||
cairo_surface_reference (surface->fallback);
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (unlikely (surface->drm.width == 0 || surface->drm.height == 0)) {
|
||||
image = cairo_image_surface_create (surface->drm.format, 0, 0);
|
||||
if (unlikely (image->status))
|
||||
return image->status;
|
||||
|
||||
*image_out = (cairo_image_surface_t *) image;
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
format = _cairo_format_from_pipe_format (surface->pipe_format);
|
||||
if (format == CAIRO_FORMAT_INVALID)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
transfer = pipe_get_transfer (device->pipe,
|
||||
surface->texture, 0, 0, 0,
|
||||
PIPE_TRANSFER_READ,
|
||||
0, 0,
|
||||
surface->drm.width,
|
||||
surface->drm.height);
|
||||
ptr = device->pipe->transfer_map (device->pipe, transfer);
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr, format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->drm.stride);
|
||||
if (unlikely (image->status))
|
||||
return image->status;
|
||||
|
||||
*image_out = (cairo_image_surface_t *) image;
|
||||
*image_extra = transfer;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
gallium_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
if (image_extra != NULL) {
|
||||
gallium_device_t *device = gallium_device (abstract_surface);
|
||||
|
||||
device->pipe->transfer_unmap (device->pipe, image_extra);
|
||||
device->pipe->transfer_destroy (device->pipe, image_extra);
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
gallium_surface_flush (void *abstract_surface,
|
||||
unsigned flags)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_status_t status;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
device->pipe->flush (device->pipe,
|
||||
PIPE_FLUSH_RENDER_CACHE,
|
||||
NULL);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* kill any outstanding maps */
|
||||
cairo_surface_finish (surface->fallback);
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
device->pipe->transfer_unmap (device->pipe,
|
||||
surface->map_transfer);
|
||||
device->pipe->transfer_destroy (device->pipe,
|
||||
surface->map_transfer);
|
||||
surface->map_transfer = NULL;
|
||||
cairo_device_release (&device->drm.base);
|
||||
}
|
||||
|
||||
status = cairo_surface_status (surface->fallback);
|
||||
cairo_surface_destroy (surface->fallback);
|
||||
surface->fallback = NULL;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_paint (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_paint (surface->fallback, op, source, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_mask (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const cairo_pattern_t *mask,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_mask (surface->fallback,
|
||||
op, source, mask,
|
||||
clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_stroke (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_stroke (surface->fallback,
|
||||
op, source,
|
||||
path, style,
|
||||
ctm, ctm_inverse,
|
||||
tolerance, antialias,
|
||||
clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_fill (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_fill (surface->fallback,
|
||||
op, source,
|
||||
path, fill_rule,
|
||||
tolerance, antialias,
|
||||
clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
*num_remaining = 0;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_show_text_glyphs (surface->fallback,
|
||||
op, source,
|
||||
NULL, 0,
|
||||
glyphs, num_glyphs,
|
||||
NULL, 0, 0,
|
||||
scaled_font,
|
||||
clip);
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t gallium_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DRM,
|
||||
_cairo_default_context_create,
|
||||
|
||||
gallium_surface_create_similar,
|
||||
gallium_surface_finish,
|
||||
|
||||
NULL,
|
||||
gallium_surface_acquire_source_image,
|
||||
gallium_surface_release_source_image,
|
||||
|
||||
NULL, //gallium_surface_acquire_dest_image,
|
||||
NULL, //gallium_surface_release_dest_image,
|
||||
NULL, //gallium_surface_clone_similar,
|
||||
NULL, //gallium_surface_composite,
|
||||
NULL, //gallium_surface_fill_rectangles,
|
||||
NULL, //gallium_surface_composite_trapezoids,
|
||||
NULL, //gallium_surface_create_span_renderer,
|
||||
NULL, //gallium_surface_check_span_renderer,
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_drm_surface_get_extents,
|
||||
NULL, /* old_show_glyphs */
|
||||
_cairo_drm_surface_get_font_options,
|
||||
gallium_surface_flush,
|
||||
NULL, /* mark_dirty_rectangle */
|
||||
NULL, //gallium_surface_scaled_font_fini,
|
||||
NULL, //gallium_surface_scaled_glyph_fini,
|
||||
|
||||
gallium_surface_paint,
|
||||
gallium_surface_mask,
|
||||
gallium_surface_stroke,
|
||||
gallium_surface_fill,
|
||||
gallium_surface_glyphs,
|
||||
|
||||
NULL, /* snapshot */
|
||||
|
||||
NULL, /* is_similar */
|
||||
|
||||
NULL, /* reset */
|
||||
};
|
||||
|
||||
static int
|
||||
gallium_format_stride_for_width (enum pipe_format format, int width)
|
||||
{
|
||||
int stride;
|
||||
|
||||
stride = 1024; /* XXX fugly */
|
||||
while (stride < width)
|
||||
stride *= 2;
|
||||
|
||||
if (format == PIPE_FORMAT_A8R8G8B8_UNORM)
|
||||
stride *= 4;
|
||||
|
||||
return stride;
|
||||
}
|
||||
|
||||
static cairo_drm_bo_t *
|
||||
_gallium_fake_bo_create (uint32_t size, uint32_t name)
|
||||
{
|
||||
cairo_drm_bo_t *bo;
|
||||
|
||||
/* XXX integrate with winsys handle */
|
||||
|
||||
bo = _cairo_malloc (sizeof (cairo_drm_bo_t));
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&bo->ref_count, 1);
|
||||
bo->name = name;
|
||||
bo->handle = 0;
|
||||
bo->size = size;
|
||||
|
||||
return bo;
|
||||
}
|
||||
|
||||
static void
|
||||
_gallium_fake_bo_release (void *dev, void *bo)
|
||||
{
|
||||
free (bo);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_internal (gallium_device_t *device,
|
||||
enum pipe_format pipe_format,
|
||||
int width, int height)
|
||||
{
|
||||
gallium_surface_t *surface;
|
||||
struct pipe_resource template;
|
||||
cairo_status_t status;
|
||||
cairo_format_t format;
|
||||
int stride, size;
|
||||
|
||||
surface = _cairo_malloc (sizeof (gallium_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
format = _cairo_format_from_pipe_format (pipe_format);
|
||||
_cairo_surface_init (&surface->drm.base,
|
||||
&gallium_surface_backend,
|
||||
&device->drm.base,
|
||||
_cairo_content_from_format (format));
|
||||
_cairo_drm_surface_init (&surface->drm, format, width, height);
|
||||
|
||||
stride = gallium_format_stride_for_width (pipe_format, width);
|
||||
size = stride * height;
|
||||
|
||||
surface->drm.stride = stride;
|
||||
surface->drm.bo = _gallium_fake_bo_create (size, 0);
|
||||
|
||||
memset(&template, 0, sizeof(template));
|
||||
template.target = PIPE_TEXTURE_2D;
|
||||
template.format = pipe_format;
|
||||
template.width0 = width;
|
||||
template.height0 = height;
|
||||
template.depth0 = 1;
|
||||
template.last_level = 0;
|
||||
template.bind = PIPE_BIND_RENDER_TARGET;
|
||||
surface->texture = device->screen->resource_create (device->screen,
|
||||
&template);
|
||||
|
||||
if (unlikely (surface->texture == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
|
||||
surface->pipe_format = pipe_format;
|
||||
surface->texture = NULL;
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create (cairo_drm_device_t *base_dev,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
gallium_device_t *device = (gallium_device_t *) base_dev;
|
||||
cairo_surface_t *surface;
|
||||
enum pipe_format pipe_format;
|
||||
cairo_status_t status;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
|
||||
if (MAX (width, height) > device->max_size) {
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
goto RELEASE;
|
||||
}
|
||||
|
||||
pipe_format = pipe_format_from_format (format);
|
||||
if (! format_is_supported_destination (device, pipe_format)) {
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
goto RELEASE;
|
||||
}
|
||||
|
||||
surface = gallium_surface_create_internal (device,
|
||||
pipe_format,
|
||||
width, height);
|
||||
|
||||
RELEASE:
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_for_name (cairo_drm_device_t *base_dev,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
gallium_device_t *device;
|
||||
gallium_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
cairo_content_t content;
|
||||
|
||||
surface = _cairo_malloc (sizeof (gallium_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_A8:
|
||||
surface->pipe_format = PIPE_FORMAT_A8_UNORM;
|
||||
break;
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
surface->pipe_format = PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
break;
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
|
||||
if (MAX (width, height) > device->max_size) {
|
||||
cairo_device_release (&device->drm.base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
}
|
||||
|
||||
if (! format_is_supported_destination (device, surface->pipe_format)) {
|
||||
cairo_device_release (&device->drm.base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
}
|
||||
|
||||
content = _cairo_content_from_format (format);
|
||||
_cairo_surface_init (&surface->drm.base,
|
||||
&gallium_surface_backend,
|
||||
content);
|
||||
_cairo_drm_surface_init (&surface->drm, base_dev);
|
||||
|
||||
surface->drm.bo = _gallium_fake_bo_create (height * stride, name);
|
||||
|
||||
surface->drm.width = width;
|
||||
surface->drm.height = height;
|
||||
surface->drm.stride = stride;
|
||||
|
||||
#if 0
|
||||
/* XXX screen->create_from_handle */
|
||||
surface->buffer = device->api->buffer_from_handle (device->api,
|
||||
device->screen,
|
||||
"cairo-gallium alien",
|
||||
name);
|
||||
if (unlikely (surface->buffer == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
cairo_device_release (&device->drm.base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
#endif
|
||||
|
||||
surface->texture = NULL;
|
||||
|
||||
surface->fallback = NULL;
|
||||
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_flink (void *abstract_surface)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device;
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (! device->api->global_handle_from_buffer (device->api,
|
||||
device->screen,
|
||||
surface->buffer,
|
||||
&surface->drm.bo->name))
|
||||
{
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gallium_device_destroy (void *abstract_device)
|
||||
{
|
||||
gallium_device_t *device = abstract_device;
|
||||
|
||||
device->pipe->destroy (device->pipe);
|
||||
device->screen->destroy (device->screen);
|
||||
device->api->destroy (device->api);
|
||||
|
||||
dlclose (device->dlhandle);
|
||||
free (device);
|
||||
}
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
|
||||
{
|
||||
gallium_device_t *device;
|
||||
cairo_status_t status;
|
||||
void *handle;
|
||||
const char *libdir;
|
||||
char buf[4096];
|
||||
struct drm_api *(*ctor) (void);
|
||||
|
||||
/* XXX need search path + probe */
|
||||
libdir = getenv ("CAIRO_GALLIUM_LIBDIR");
|
||||
if (libdir == NULL)
|
||||
libdir = "/usr/lib/dri";
|
||||
buf[snprintf (buf, sizeof (buf)-1, "%s/i915_dri.so", libdir)] = '\0';
|
||||
|
||||
handle = dlopen (buf, RTLD_LAZY);
|
||||
if (handle == NULL)
|
||||
return NULL;
|
||||
|
||||
ctor = dlsym (handle, "drm_api_create");
|
||||
if (ctor == NULL) {
|
||||
dlclose (handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = _cairo_malloc (sizeof (gallium_device_t));
|
||||
if (device == NULL) {
|
||||
dlclose (handle);
|
||||
return _cairo_drm_device_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
|
||||
device->dlhandle = handle;
|
||||
|
||||
device->drm.surface.create = gallium_surface_create;
|
||||
device->drm.surface.create_for_name = NULL;
|
||||
//device->drm.surface.create_for_name = gallium_surface_create_for_name;
|
||||
device->drm.surface.enable_scan_out = NULL;
|
||||
//device->drm.surface.flink = gallium_surface_flink;
|
||||
device->drm.surface.flink = NULL;
|
||||
|
||||
device->drm.device.flush = NULL;
|
||||
device->drm.device.throttle = NULL;
|
||||
device->drm.device.destroy = gallium_device_destroy;
|
||||
|
||||
device->drm.bo.release = _gallium_fake_bo_release;
|
||||
|
||||
device->api = ctor ();
|
||||
if (device->api == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
device->screen = device->api->create_screen (device->api, fd, NULL);
|
||||
if (device->screen == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP_API;
|
||||
}
|
||||
|
||||
device->max_size = 1 << device->screen->get_param (device->screen,
|
||||
PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
|
||||
|
||||
device->pipe = device->screen->context_create (device->screen, device);
|
||||
if (device->pipe == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP_SCREEN;
|
||||
}
|
||||
|
||||
return _cairo_drm_device_init (&device->drm,
|
||||
fd, dev,
|
||||
0, 0,
|
||||
device->max_size);
|
||||
|
||||
CLEANUP_SCREEN:
|
||||
device->screen->destroy (device->screen);
|
||||
CLEANUP_API:
|
||||
device->api->destroy (device->api);
|
||||
CLEANUP:
|
||||
free (device);
|
||||
dlclose (handle);
|
||||
return _cairo_drm_device_create_in_error (status);
|
||||
}
|
||||
|
|
@ -1,566 +0,0 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-drm-i915-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-rtree-private.h"
|
||||
#include "cairo-clip-inline.h"
|
||||
|
||||
static void
|
||||
i915_emit_glyph_rectangle_zero (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
*/
|
||||
|
||||
v = i915_add_rectangle (device);
|
||||
*v++ = x2; *v++ = y2;
|
||||
*v++ = x1; *v++ = y2;
|
||||
*v++ = x1; *v++ = y1;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_emit_glyph_rectangle_constant (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* 2 glyph texture coordinates
|
||||
*/
|
||||
|
||||
v = i915_add_rectangle (device);
|
||||
|
||||
/* bottom right */
|
||||
*v++ = x2; *v++ = y2;
|
||||
*v++ = glyph->texcoord[0];
|
||||
|
||||
/* bottom left */
|
||||
*v++ = x1; *v++ = y2;
|
||||
*v++ = glyph->texcoord[1];
|
||||
|
||||
/* top left */
|
||||
*v++ = x1; *v++ = y1;
|
||||
*v++ = glyph->texcoord[2];
|
||||
}
|
||||
|
||||
static void
|
||||
i915_emit_glyph_rectangle_general (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
double s, t;
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* [0-2] source texture coordinates
|
||||
* 2 glyph texture coordinates
|
||||
*/
|
||||
|
||||
v = i915_add_rectangle (device);
|
||||
|
||||
/* bottom right */
|
||||
*v++ = x2; *v++ = y2;
|
||||
s = x2, t = y2;
|
||||
switch (shader->source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*v++ = i915_shader_linear_texcoord (&shader->source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = s; *v++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*v++ = glyph->texcoord[0];
|
||||
|
||||
/* bottom left */
|
||||
*v++ = x1; *v++ = y2;
|
||||
s = x1, t = y2;
|
||||
switch (shader->source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*v++ = i915_shader_linear_texcoord (&shader->source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = s; *v++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*v++ = glyph->texcoord[1];
|
||||
|
||||
/* top left */
|
||||
*v++ = x1; *v++ = y1;
|
||||
s = x1, t = y2;
|
||||
switch (shader->source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*v++ = i915_shader_linear_texcoord (&shader->source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = s; *v++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*v++ = glyph->texcoord[2];
|
||||
}
|
||||
|
||||
typedef void
|
||||
(*i915_emit_glyph_rectangle_func_t) (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph);
|
||||
|
||||
static cairo_status_t
|
||||
i915_surface_mask_internal (i915_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
i915_surface_t *mask,
|
||||
cairo_clip_t *clip,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
i915_device_t *device;
|
||||
i915_shader_t shader;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
i915_shader_init (&shader, dst, op, 1.);
|
||||
|
||||
status = i915_shader_acquire_pattern (&shader, &shader.source,
|
||||
source, &extents->bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
shader.mask.type.vertex = VS_TEXTURE_16;
|
||||
shader.mask.type.pattern = PATTERN_TEXTURE;
|
||||
shader.mask.type.fragment = FS_TEXTURE;
|
||||
shader.mask.base.content = mask->intel.drm.base.content;
|
||||
shader.mask.base.texfmt = TEXCOORDFMT_2D_16;
|
||||
shader.mask.base.n_samplers = 1;
|
||||
shader.mask.base.sampler[0] =
|
||||
(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
|
||||
i915_texture_filter (CAIRO_FILTER_NEAREST);
|
||||
shader.mask.base.sampler[1] =
|
||||
SS3_NORMALIZED_COORDS |
|
||||
i915_texture_extend (CAIRO_EXTEND_NONE);
|
||||
|
||||
cairo_matrix_init_translate (&shader.mask.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
cairo_matrix_scale (&shader.mask.base.matrix,
|
||||
1. / mask->intel.drm.width,
|
||||
1. / mask->intel.drm.height);
|
||||
|
||||
shader.mask.base.bo = intel_bo_reference (to_intel_bo (mask->intel.drm.bo));
|
||||
shader.mask.base.offset[0] = 0;
|
||||
shader.mask.base.map[0] = mask->map0;
|
||||
shader.mask.base.map[1] = mask->map1;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i915_shader_set_clip (&shader, clip);
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SHADER;
|
||||
|
||||
device = i915_device (dst);
|
||||
|
||||
status = i915_shader_commit (&shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
if (clip_region != NULL) {
|
||||
unsigned int n, num_rectangles;
|
||||
|
||||
num_rectangles = cairo_region_num_rectangles (clip_region);
|
||||
for (n = 0; n < num_rectangles; n++) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (clip_region, n, &rect);
|
||||
|
||||
shader.add_rectangle (&shader,
|
||||
rect.x, rect.y,
|
||||
rect.x + rect.width, rect.y + rect.height);
|
||||
}
|
||||
} else {
|
||||
shader.add_rectangle (&shader,
|
||||
extents->bounded.x, extents->bounded.y,
|
||||
extents->bounded.x + extents->bounded.width,
|
||||
extents->bounded.y + extents->bounded.height);
|
||||
}
|
||||
|
||||
if (! extents->is_bounded)
|
||||
status = i915_fixup_unbounded (dst, extents, clip);
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (&device->intel.base.base);
|
||||
CLEANUP_SHADER:
|
||||
i915_shader_fini (&shader);
|
||||
return status;
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
i915_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
i915_surface_t *surface = abstract_surface;
|
||||
i915_surface_t *mask = NULL;
|
||||
i915_device_t *device;
|
||||
i915_shader_t shader;
|
||||
cairo_composite_rectangles_t extents;
|
||||
cairo_clip_t local_clip;
|
||||
cairo_bool_t have_clip = FALSE;
|
||||
cairo_bool_t overlap;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
intel_bo_t *last_bo = NULL;
|
||||
i915_emit_glyph_rectangle_func_t emit_func;
|
||||
cairo_scaled_glyph_t *glyph_cache[64];
|
||||
cairo_status_t status;
|
||||
int mask_x = 0, mask_y = 0;
|
||||
int i = 0;
|
||||
|
||||
*num_remaining = 0;
|
||||
status = _cairo_composite_rectangles_init_for_glyphs (&extents,
|
||||
surface->intel.drm.width,
|
||||
surface->intel.drm.height,
|
||||
op, source,
|
||||
scaled_font,
|
||||
glyphs, num_glyphs,
|
||||
clip,
|
||||
&overlap);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (_cairo_clip_contains_rectangle (clip, &extents.mask))
|
||||
clip = NULL;
|
||||
|
||||
if (clip != NULL && extents.is_bounded) {
|
||||
clip = _cairo_clip_init_copy (&local_clip, clip);
|
||||
status = _cairo_clip_rectangle (clip, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
have_clip = TRUE;
|
||||
}
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
if (unlikely (_cairo_status_is_error (status) ||
|
||||
status == CAIRO_INT_STATUS_NOTHING_TO_DO))
|
||||
{
|
||||
if (have_clip)
|
||||
_cairo_clip_fini (&local_clip);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (i915_surface_needs_tiling (surface)) {
|
||||
ASSERT_NOT_REACHED;
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (overlap || ! extents.is_bounded) {
|
||||
cairo_format_t format;
|
||||
|
||||
format = CAIRO_FORMAT_A8;
|
||||
if (scaled_font->options.antialias == CAIRO_ANTIALIAS_SUBPIXEL)
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
|
||||
mask = (i915_surface_t *)
|
||||
i915_surface_create_internal (&i915_device (surface)->intel.base,
|
||||
format,
|
||||
extents.bounded.width,
|
||||
extents.bounded.height,
|
||||
I915_TILING_DEFAULT,
|
||||
TRUE);
|
||||
if (unlikely (mask->intel.drm.base.status))
|
||||
return mask->intel.drm.base.status;
|
||||
|
||||
status = i915_surface_clear (mask);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
i915_shader_init (&shader, mask, CAIRO_OPERATOR_ADD, 1.);
|
||||
|
||||
status = i915_shader_acquire_pattern (&shader, &shader.source,
|
||||
&_cairo_pattern_white.base,
|
||||
&extents.bounded);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
mask_x = -extents.bounded.x;
|
||||
mask_y = -extents.bounded.y;
|
||||
} else {
|
||||
i915_shader_init (&shader, surface, op, 1.);
|
||||
|
||||
status = i915_shader_acquire_pattern (&shader, &shader.source,
|
||||
source, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i915_shader_set_clip (&shader, clip);
|
||||
}
|
||||
}
|
||||
|
||||
shader.mask.type.fragment = FS_TEXTURE;
|
||||
shader.mask.base.content = CAIRO_CONTENT_ALPHA; /* XXX */
|
||||
shader.mask.base.texfmt = TEXCOORDFMT_2D_16;
|
||||
shader.mask.base.n_samplers = 1;
|
||||
shader.mask.base.sampler[0] =
|
||||
(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
|
||||
i915_texture_filter (CAIRO_FILTER_NEAREST);
|
||||
shader.mask.base.sampler[1] =
|
||||
SS3_NORMALIZED_COORDS |
|
||||
i915_texture_extend (CAIRO_EXTEND_NONE);
|
||||
|
||||
switch (shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
emit_func = i915_emit_glyph_rectangle_zero;
|
||||
break;
|
||||
case VS_CONSTANT:
|
||||
emit_func = i915_emit_glyph_rectangle_constant;
|
||||
break;
|
||||
default:
|
||||
case VS_LINEAR:
|
||||
case VS_TEXTURE:
|
||||
case VS_TEXTURE_16:
|
||||
emit_func = i915_emit_glyph_rectangle_general;
|
||||
break;
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (surface->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SHADER;
|
||||
|
||||
device = i915_device (surface);
|
||||
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
if (scaled_font->surface_private == NULL) {
|
||||
scaled_font->surface_private = device;
|
||||
scaled_font->surface_backend = surface->intel.drm.base.backend;
|
||||
cairo_list_add (&scaled_font->link, &device->intel.fonts);
|
||||
}
|
||||
|
||||
memset (glyph_cache, 0, sizeof (glyph_cache));
|
||||
|
||||
for (i = 0; i < num_glyphs; i++) {
|
||||
cairo_scaled_glyph_t *scaled_glyph;
|
||||
int x, y, x1, x2, y1, y2;
|
||||
int cache_index = glyphs[i].index % ARRAY_LENGTH (glyph_cache);
|
||||
intel_glyph_t *glyph;
|
||||
|
||||
scaled_glyph = glyph_cache[cache_index];
|
||||
if (scaled_glyph == NULL ||
|
||||
_cairo_scaled_glyph_index (scaled_glyph) != glyphs[i].index)
|
||||
{
|
||||
status = _cairo_scaled_glyph_lookup (scaled_font,
|
||||
glyphs[i].index,
|
||||
CAIRO_SCALED_GLYPH_INFO_METRICS,
|
||||
NULL, /* foreground color */
|
||||
&scaled_glyph);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
glyph_cache[cache_index] = scaled_glyph;
|
||||
}
|
||||
|
||||
if (unlikely (scaled_glyph->metrics.width == 0 ||
|
||||
scaled_glyph->metrics.height == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX glyph images are snapped to pixel locations */
|
||||
x = _cairo_lround (glyphs[i].x);
|
||||
y = _cairo_lround (glyphs[i].y);
|
||||
|
||||
x1 = x + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.x);
|
||||
y1 = y + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.y);
|
||||
x2 = x + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.x);
|
||||
y2 = y + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.y);
|
||||
|
||||
if (x2 < extents.bounded.x ||
|
||||
y2 < extents.bounded.y ||
|
||||
x1 > extents.bounded.x + extents.bounded.width ||
|
||||
y1 > extents.bounded.y + extents.bounded.height)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scaled_glyph->surface_private == NULL) {
|
||||
status = intel_get_glyph (&device->intel, scaled_font, scaled_glyph);
|
||||
if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) {
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
continue;
|
||||
}
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
glyph = intel_glyph_pin (scaled_glyph->surface_private);
|
||||
if (glyph->cache->buffer.bo != last_bo) {
|
||||
intel_buffer_cache_t *cache = glyph->cache;
|
||||
|
||||
shader.mask.base.bo = cache->buffer.bo;
|
||||
shader.mask.base.offset[0] = cache->buffer.offset;
|
||||
shader.mask.base.map[0] = cache->buffer.map0;
|
||||
shader.mask.base.map[1] = cache->buffer.map1;
|
||||
shader.mask.base.content = CAIRO_CONTENT_ALPHA; /* XXX */
|
||||
|
||||
status = i915_shader_commit (&shader, device);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
last_bo = cache->buffer.bo;
|
||||
}
|
||||
|
||||
x2 = x1 + glyph->width;
|
||||
y2 = y1 + glyph->height;
|
||||
|
||||
if (mask_x)
|
||||
x1 += mask_x, x2 += mask_x;
|
||||
if (mask_y)
|
||||
y1 += mask_y, y2 += mask_y;
|
||||
|
||||
/* XXX clip glyph */
|
||||
emit_func (device, &shader, x1, y1, x2, y2, glyph);
|
||||
}
|
||||
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
FINISH:
|
||||
_cairo_scaled_font_thaw_cache (scaled_font);
|
||||
cairo_device_release (surface->intel.drm.base.device);
|
||||
CLEANUP_SHADER:
|
||||
i915_shader_fini (&shader);
|
||||
|
||||
if (unlikely (status == CAIRO_INT_STATUS_UNSUPPORTED)) {
|
||||
cairo_path_fixed_t path;
|
||||
|
||||
_cairo_path_fixed_init (&path);
|
||||
status = _cairo_scaled_font_glyph_path (scaled_font,
|
||||
glyphs + i, num_glyphs - i,
|
||||
&path);
|
||||
if (mask_x | mask_y) {
|
||||
_cairo_path_fixed_translate (&path,
|
||||
_cairo_fixed_from_int (mask_x),
|
||||
_cairo_fixed_from_int (mask_y));
|
||||
}
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = surface->intel.drm.base.backend->fill (shader.target,
|
||||
shader.op,
|
||||
mask != NULL ? &_cairo_pattern_white.base : source,
|
||||
&path,
|
||||
CAIRO_FILL_RULE_WINDING,
|
||||
0,
|
||||
scaled_font->options.antialias,
|
||||
clip);
|
||||
}
|
||||
_cairo_path_fixed_fini (&path);
|
||||
}
|
||||
|
||||
if (mask != NULL) {
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = i915_surface_mask_internal (surface, op, source, mask,
|
||||
clip, &extents);
|
||||
}
|
||||
cairo_surface_finish (&mask->intel.drm.base);
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
}
|
||||
|
||||
if (have_clip)
|
||||
_cairo_clip_fini (&local_clip);
|
||||
|
||||
return status;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,799 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-boxes-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-drm-i915-private.h"
|
||||
|
||||
/* Operates in either immediate or retained mode.
|
||||
* When given a clip region we record the sequence of vbo and then
|
||||
* replay them for each clip rectangle, otherwise we simply emit
|
||||
* the vbo straight into the command stream.
|
||||
*/
|
||||
|
||||
typedef struct _i915_spans i915_spans_t;
|
||||
|
||||
typedef float *
|
||||
(*i915_get_rectangle_func_t) (i915_spans_t *spans);
|
||||
|
||||
typedef void
|
||||
(*i915_span_func_t) (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha);
|
||||
|
||||
struct _i915_spans {
|
||||
cairo_span_renderer_t renderer;
|
||||
|
||||
i915_device_t *device;
|
||||
|
||||
int xmin, xmax;
|
||||
cairo_bool_t is_bounded;
|
||||
const cairo_rectangle_int_t *extents;
|
||||
|
||||
i915_get_rectangle_func_t get_rectangle;
|
||||
i915_span_func_t span;
|
||||
i915_shader_t shader;
|
||||
|
||||
cairo_region_t *clip_region;
|
||||
cairo_bool_t need_clip_surface;
|
||||
|
||||
struct vbo {
|
||||
struct vbo *next;
|
||||
intel_bo_t *bo;
|
||||
unsigned int count;
|
||||
} head, *tail;
|
||||
|
||||
unsigned int vbo_offset;
|
||||
float *vbo_base;
|
||||
};
|
||||
|
||||
static float *
|
||||
i915_emit_rectangle (i915_spans_t *spans)
|
||||
{
|
||||
return i915_add_rectangle (spans->device);
|
||||
}
|
||||
|
||||
static float *
|
||||
i915_accumulate_rectangle (i915_spans_t *spans)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = spans->device->rectangle_size;
|
||||
if (unlikely (spans->vbo_offset + size > I915_VBO_SIZE)) {
|
||||
struct vbo *vbo;
|
||||
|
||||
vbo = _cairo_malloc (sizeof (struct vbo));
|
||||
if (unlikely (vbo == NULL)) {
|
||||
/* throw error! */
|
||||
}
|
||||
|
||||
spans->tail->next = vbo;
|
||||
spans->tail = vbo;
|
||||
|
||||
vbo->next = NULL;
|
||||
vbo->bo = intel_bo_create (&spans->device->intel,
|
||||
I915_VBO_SIZE, I915_VBO_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
vbo->count = 0;
|
||||
|
||||
spans->vbo_offset = 0;
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, vbo->bo);
|
||||
}
|
||||
|
||||
vertices = spans->vbo_base + spans->vbo_offset;
|
||||
spans->vbo_offset += size;
|
||||
spans->tail->count += 3;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_zero (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_constant (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_linear (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
double s, t;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
s = x0, t = y0;
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
s = x1, t = y0;
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
s = x1, t = y1;
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_texture (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
double s, t;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
s = x1, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_texture16 (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1, int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
double s, t;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
s = x1, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_generic (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1, int alpha)
|
||||
{
|
||||
double s, t;
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* [0-2] source texture coordinates
|
||||
* 1 alpha value.
|
||||
* [0,2] clip mask coordinates
|
||||
*/
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
/* bottom right */
|
||||
*vertices++ = x1; *vertices++ = y1;
|
||||
s = x1, t = y1;
|
||||
switch (spans->shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*vertices++ = a;
|
||||
if (spans->need_clip_surface) {
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.clip.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
if (spans->shader.need_combine) {
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.dst.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
|
||||
/* bottom left */
|
||||
*vertices++ = x0; *vertices++ = y1;
|
||||
s = x0, t = y1;
|
||||
switch (spans->shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*vertices++ = a;
|
||||
if (spans->need_clip_surface) {
|
||||
s = x0, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.clip.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
if (spans->shader.need_combine) {
|
||||
s = x0, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.dst.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
|
||||
/* top left */
|
||||
*vertices++ = x0; *vertices++ = y0;
|
||||
s = x0, t = y0;
|
||||
switch (spans->shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*vertices++ = a;
|
||||
if (spans->need_clip_surface) {
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.clip.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
if (spans->shader.need_combine) {
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.dst.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_zero_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
int x0, x1;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
while (num_spans && half[0].coverage < 128)
|
||||
half++, num_spans--;
|
||||
if (num_spans == 0)
|
||||
break;
|
||||
|
||||
x0 = x1 = half[0].x;
|
||||
while (num_spans--) {
|
||||
half++;
|
||||
|
||||
x1 = half[0].x;
|
||||
if (half[0].coverage < 128)
|
||||
break;
|
||||
}
|
||||
|
||||
i915_span_zero (spans,
|
||||
x0, x1,
|
||||
y, y + height,
|
||||
0);
|
||||
} while (num_spans);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_zero_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
int x0, x1;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
while (num_spans && half[0].coverage == 0)
|
||||
half++, num_spans--;
|
||||
if (num_spans == 0)
|
||||
break;
|
||||
|
||||
x0 = x1 = half[0].x;
|
||||
while (num_spans--) {
|
||||
half++;
|
||||
|
||||
x1 = half[0].x;
|
||||
if (half[0].coverage == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
i915_span_zero (spans,
|
||||
x0, x1,
|
||||
y, y + height,
|
||||
0);
|
||||
} while (num_spans);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_bounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage >= 128) {
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
255);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_bounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage) {
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_unbounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
spans->span (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
spans->span (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
spans->span (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_unbounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
spans->span (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
spans->span (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
int alpha = 0;
|
||||
if (half[0].coverage >= 128)
|
||||
alpha = 255;
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
alpha);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
spans->span (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_spans_init (i915_spans_t *spans,
|
||||
i915_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip,
|
||||
double opacity,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
spans->device = (i915_device_t *) dst->intel.drm.base.device;
|
||||
|
||||
spans->is_bounded = extents->is_bounded;
|
||||
if (extents->is_bounded) {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i915_bounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i915_bounded_spans;
|
||||
|
||||
spans->extents = &extents->bounded;
|
||||
} else {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i915_unbounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i915_unbounded_spans;
|
||||
|
||||
spans->extents = &extents->unbounded;
|
||||
}
|
||||
spans->xmin = spans->extents->x;
|
||||
spans->xmax = spans->extents->x + spans->extents->width;
|
||||
|
||||
spans->clip_region = NULL;
|
||||
spans->need_clip_surface = FALSE;
|
||||
if (clip != NULL) {
|
||||
cairo_region_t *clip_region = NULL;
|
||||
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
spans->clip_region = clip_region;
|
||||
spans->need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
spans->head.next = NULL;
|
||||
spans->head.bo = NULL;
|
||||
spans->head.count = 0;
|
||||
spans->tail = &spans->head;
|
||||
|
||||
if (spans->clip_region == NULL) {
|
||||
spans->get_rectangle = i915_emit_rectangle;
|
||||
} else {
|
||||
assert (! extents->is_bounded);
|
||||
spans->get_rectangle = i915_accumulate_rectangle;
|
||||
spans->head.bo = intel_bo_create (&spans->device->intel,
|
||||
I915_VBO_SIZE, I915_VBO_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
if (unlikely (spans->head.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, spans->head.bo);
|
||||
}
|
||||
spans->vbo_offset = 0;
|
||||
|
||||
i915_shader_init (&spans->shader, dst, op, opacity);
|
||||
if (spans->need_clip_surface)
|
||||
i915_shader_set_clip (&spans->shader, clip);
|
||||
|
||||
status = i915_shader_acquire_pattern (&spans->shader, &spans->shader.source,
|
||||
pattern, &extents->bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_spans_fini (i915_spans_t *spans)
|
||||
{
|
||||
i915_shader_fini (&spans->shader);
|
||||
|
||||
if (spans->head.bo != NULL) {
|
||||
struct vbo *vbo, *next;
|
||||
|
||||
intel_bo_destroy (&spans->device->intel, spans->head.bo);
|
||||
for (vbo = spans->head.next; vbo != NULL; vbo = next) {
|
||||
next = vbo->next;
|
||||
intel_bo_destroy (&spans->device->intel, vbo->bo);
|
||||
free (vbo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
i915_clip_and_composite_spans (i915_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
i915_spans_func_t draw_func,
|
||||
void *draw_closure,
|
||||
const cairo_composite_rectangles_t*extents,
|
||||
cairo_clip_t *clip,
|
||||
double opacity)
|
||||
{
|
||||
i915_spans_t spans;
|
||||
i915_device_t *device;
|
||||
cairo_status_t status;
|
||||
struct vbo *vbo;
|
||||
|
||||
if (i915_surface_needs_tiling (dst)) {
|
||||
ASSERT_NOT_REACHED;
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (op == CAIRO_OPERATOR_CLEAR) {
|
||||
pattern = &_cairo_pattern_white.base;
|
||||
op = CAIRO_OPERATOR_DEST_OUT;
|
||||
}
|
||||
|
||||
status = i915_spans_init (&spans, dst, op, pattern, antialias, clip, opacity, extents);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
spans.shader.mask.base.texfmt = TEXCOORDFMT_1D;
|
||||
spans.shader.mask.base.content = CAIRO_CONTENT_ALPHA;
|
||||
spans.shader.mask.type.fragment = FS_SPANS;
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SPANS;
|
||||
|
||||
if (dst->deferred_clear) {
|
||||
status = i915_surface_clear (dst);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SPANS;
|
||||
}
|
||||
|
||||
device = i915_device (dst);
|
||||
status = i915_shader_commit (&spans.shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
if (! spans.shader.need_combine && ! spans.need_clip_surface) {
|
||||
switch (spans.shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
spans.span = i915_span_zero;
|
||||
if (extents->is_bounded) {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans.renderer.render_rows = i915_zero_spans_mono;
|
||||
else
|
||||
spans.renderer.render_rows = i915_zero_spans;
|
||||
}
|
||||
break;
|
||||
case VS_CONSTANT:
|
||||
spans.span = i915_span_constant;
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
spans.span = i915_span_linear;
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
spans.span = i915_span_texture;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
spans.span = i915_span_texture16;
|
||||
break;
|
||||
default:
|
||||
spans.span = i915_span_generic;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
spans.span = i915_span_generic;
|
||||
}
|
||||
|
||||
status = draw_func (draw_closure, &spans.renderer, spans.extents);
|
||||
if (spans.clip_region != NULL && status == CAIRO_STATUS_SUCCESS) {
|
||||
i915_vbo_finish (device);
|
||||
|
||||
OUT_DWORD (_3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT);
|
||||
for (vbo = &spans.head; vbo != NULL; vbo = vbo->next) {
|
||||
int i, num_rectangles;
|
||||
|
||||
/* XXX require_space & batch_flush */
|
||||
|
||||
OUT_DWORD (_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S (0) | I1_LOAD_S (1) | 1);
|
||||
i915_batch_emit_reloc (device, vbo->bo, 0,
|
||||
I915_GEM_DOMAIN_VERTEX, 0,
|
||||
FALSE);
|
||||
OUT_DWORD ((device->floats_per_vertex << S1_VERTEX_WIDTH_SHIFT) |
|
||||
(device->floats_per_vertex << S1_VERTEX_PITCH_SHIFT) |
|
||||
vbo->count);
|
||||
|
||||
num_rectangles = cairo_region_num_rectangles (spans.clip_region);
|
||||
for (i = 0; i < num_rectangles; i++) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (spans.clip_region, i, &rect);
|
||||
|
||||
OUT_DWORD (_3DSTATE_SCISSOR_RECT_0_CMD);
|
||||
OUT_DWORD (SCISSOR_RECT_0_XMIN (rect.x) |
|
||||
SCISSOR_RECT_0_YMIN (rect.y));
|
||||
OUT_DWORD (SCISSOR_RECT_0_XMAX (rect.x + rect.width) |
|
||||
SCISSOR_RECT_0_YMAX (rect.y + rect.height));
|
||||
|
||||
OUT_DWORD (PRIM3D_RECTLIST | PRIM3D_INDIRECT_SEQUENTIAL | vbo->count);
|
||||
OUT_DWORD (0);
|
||||
}
|
||||
}
|
||||
OUT_DWORD (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
|
||||
}
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (dst->intel.drm.base.device);
|
||||
CLEANUP_SPANS:
|
||||
i915_spans_fini (&spans);
|
||||
|
||||
return status;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,506 +0,0 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-drm-i965-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-rtree-private.h"
|
||||
|
||||
typedef struct _i965_glyphs i965_glyphs_t;
|
||||
|
||||
typedef float *
|
||||
(*i965_get_rectangle_func_t) (i965_glyphs_t *glyphs);
|
||||
|
||||
struct _i965_glyphs {
|
||||
i965_get_rectangle_func_t get_rectangle;
|
||||
i965_shader_t shader;
|
||||
|
||||
struct i965_vbo head, *tail;
|
||||
|
||||
unsigned int vbo_offset;
|
||||
float *vbo_base;
|
||||
};
|
||||
|
||||
static float *
|
||||
i965_glyphs_emit_rectangle (i965_glyphs_t *glyphs)
|
||||
{
|
||||
return i965_add_rectangle (glyphs->shader.device);
|
||||
}
|
||||
|
||||
static float *
|
||||
i965_glyphs_accumulate_rectangle (i965_glyphs_t *glyphs)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = glyphs->shader.device->rectangle_size;
|
||||
if (unlikely (glyphs->vbo_offset + size > I965_VERTEX_SIZE)) {
|
||||
struct i965_vbo *vbo;
|
||||
|
||||
vbo = _cairo_malloc (sizeof (struct i965_vbo));
|
||||
if (unlikely (vbo == NULL)) {
|
||||
/* throw error! */
|
||||
}
|
||||
|
||||
glyphs->tail->next = vbo;
|
||||
glyphs->tail = vbo;
|
||||
|
||||
vbo->next = NULL;
|
||||
vbo->bo = intel_bo_create (&glyphs->shader.device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
vbo->count = 0;
|
||||
|
||||
glyphs->vbo_offset = 0;
|
||||
glyphs->vbo_base = intel_bo_map (&glyphs->shader.device->intel, vbo->bo);
|
||||
}
|
||||
|
||||
vertices = glyphs->vbo_base + glyphs->vbo_offset;
|
||||
glyphs->vbo_offset += size;
|
||||
glyphs->tail->count += 3;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static void
|
||||
i965_add_glyph_rectangle (i965_glyphs_t *glyphs,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* 1 glyph texture coordinate
|
||||
*/
|
||||
|
||||
v = glyphs->get_rectangle (glyphs);
|
||||
|
||||
/* bottom right */
|
||||
*v++ = x2; *v++ = y2;
|
||||
*v++ = glyph->texcoord[0];
|
||||
|
||||
/* bottom left */
|
||||
*v++ = x1; *v++ = y2;
|
||||
*v++ = glyph->texcoord[1];
|
||||
|
||||
/* top left */
|
||||
*v++ = x1; *v++ = y1;
|
||||
*v++ = glyph->texcoord[2];
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_surface_mask_internal (i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
i965_surface_t *mask,
|
||||
cairo_clip_t *clip,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
i965_device_t *device;
|
||||
i965_shader_t shader;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
i965_shader_init (&shader, dst, op);
|
||||
|
||||
status = i965_shader_acquire_pattern (&shader, &shader.source,
|
||||
source, &extents->bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
shader.mask.type.vertex = VS_NONE;
|
||||
shader.mask.type.fragment = FS_SURFACE;
|
||||
shader.mask.base.content = mask->intel.drm.base.content;
|
||||
shader.mask.base.filter = i965_filter (CAIRO_FILTER_NEAREST);
|
||||
shader.mask.base.extend = i965_extend (CAIRO_EXTEND_NONE);
|
||||
|
||||
cairo_matrix_init_translate (&shader.mask.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
cairo_matrix_scale (&shader.mask.base.matrix,
|
||||
1. / mask->intel.drm.width,
|
||||
1. / mask->intel.drm.height);
|
||||
|
||||
shader.mask.base.bo = to_intel_bo (mask->intel.drm.bo);
|
||||
shader.mask.base.format = mask->intel.drm.format;
|
||||
shader.mask.base.width = mask->intel.drm.width;
|
||||
shader.mask.base.height = mask->intel.drm.height;
|
||||
shader.mask.base.stride = mask->intel.drm.stride;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i965_shader_set_clip (&shader, clip);
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SHADER;
|
||||
|
||||
device = i965_device (dst);
|
||||
|
||||
status = i965_shader_commit (&shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
if (clip_region != NULL) {
|
||||
unsigned int n, num_rectangles;
|
||||
|
||||
num_rectangles = cairo_region_num_rectangles (clip_region);
|
||||
for (n = 0; n < num_rectangles; n++) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (clip_region, n, &rect);
|
||||
|
||||
i965_shader_add_rectangle (&shader,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
} else {
|
||||
i965_shader_add_rectangle (&shader,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
extents->bounded.width,
|
||||
extents->bounded.height);
|
||||
}
|
||||
|
||||
if (! extents->is_bounded)
|
||||
status = i965_fixup_unbounded (dst, extents, clip);
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (&device->intel.base.base);
|
||||
CLEANUP_SHADER:
|
||||
i965_shader_fini (&shader);
|
||||
return status;
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
i965_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *g,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
i965_surface_t *surface = abstract_surface;
|
||||
i965_surface_t *mask = NULL;
|
||||
i965_device_t *device;
|
||||
i965_glyphs_t glyphs;
|
||||
cairo_composite_rectangles_t extents;
|
||||
cairo_clip_t local_clip;
|
||||
cairo_bool_t have_clip = FALSE;
|
||||
cairo_bool_t overlap;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
intel_bo_t *last_bo = NULL;
|
||||
cairo_scaled_glyph_t *glyph_cache[64];
|
||||
cairo_status_t status;
|
||||
int mask_x = 0, mask_y = 0;
|
||||
int i = 0;
|
||||
|
||||
*num_remaining = 0;
|
||||
status = _cairo_composite_rectangles_init_for_glyphs (&extents,
|
||||
surface->intel.drm.width,
|
||||
surface->intel.drm.height,
|
||||
op, source,
|
||||
scaled_font,
|
||||
g, num_glyphs,
|
||||
clip,
|
||||
&overlap);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (clip != NULL && _cairo_clip_contains_rectangle (clip, &extents.mask))
|
||||
clip = NULL;
|
||||
|
||||
if (clip != NULL && extents.is_bounded) {
|
||||
clip = _cairo_clip_init_copy (&local_clip, clip);
|
||||
status = _cairo_clip_rectangle (clip, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
have_clip = TRUE;
|
||||
}
|
||||
|
||||
if (overlap || ! extents.is_bounded) {
|
||||
cairo_format_t format;
|
||||
|
||||
format = CAIRO_FORMAT_A8;
|
||||
if (scaled_font->options.antialias == CAIRO_ANTIALIAS_SUBPIXEL)
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
|
||||
mask = (i965_surface_t *)
|
||||
i965_surface_create_internal (&i965_device (surface)->intel.base,
|
||||
format,
|
||||
extents.bounded.width,
|
||||
extents.bounded.height,
|
||||
I965_TILING_DEFAULT,
|
||||
TRUE);
|
||||
if (unlikely (mask->intel.drm.base.status))
|
||||
return mask->intel.drm.base.status;
|
||||
|
||||
status = _cairo_surface_paint (&mask->intel.drm.base,
|
||||
CAIRO_OPERATOR_CLEAR,
|
||||
&_cairo_pattern_clear.base,
|
||||
NULL);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
i965_shader_init (&glyphs.shader, mask, CAIRO_OPERATOR_ADD);
|
||||
|
||||
status = i965_shader_acquire_pattern (&glyphs.shader, &glyphs.shader.source,
|
||||
&_cairo_pattern_white.base,
|
||||
&extents.bounded);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
mask_x = -extents.bounded.x;
|
||||
mask_y = -extents.bounded.y;
|
||||
} else {
|
||||
i965_shader_init (&glyphs.shader, surface, op);
|
||||
|
||||
status = i965_shader_acquire_pattern (&glyphs.shader, &glyphs.shader.source,
|
||||
source, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i965_shader_set_clip (&glyphs.shader, clip);
|
||||
}
|
||||
}
|
||||
|
||||
glyphs.head.next = NULL;
|
||||
glyphs.head.bo = NULL;
|
||||
glyphs.head.count = 0;
|
||||
glyphs.tail = &glyphs.head;
|
||||
|
||||
device = i965_device (surface);
|
||||
if (mask != NULL || clip_region == NULL) {
|
||||
glyphs.get_rectangle = i965_glyphs_emit_rectangle;
|
||||
} else {
|
||||
glyphs.get_rectangle = i965_glyphs_accumulate_rectangle;
|
||||
glyphs.head.bo = intel_bo_create (&device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
if (unlikely (glyphs.head.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
glyphs.vbo_base = intel_bo_map (&device->intel, glyphs.head.bo);
|
||||
}
|
||||
glyphs.vbo_offset = 0;
|
||||
|
||||
status = cairo_device_acquire (&device->intel.base.base);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_GLYPHS;
|
||||
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
//private = _cairo_scaled_font_get_device (scaled_font, device);
|
||||
if (scaled_font->surface_private == NULL) {
|
||||
scaled_font->surface_private = device;
|
||||
scaled_font->surface_backend = surface->intel.drm.base.backend;
|
||||
cairo_list_add (&scaled_font->link, &device->intel.fonts);
|
||||
}
|
||||
|
||||
memset (glyph_cache, 0, sizeof (glyph_cache));
|
||||
|
||||
for (i = 0; i < num_glyphs; i++) {
|
||||
cairo_scaled_glyph_t *scaled_glyph;
|
||||
int x, y, x1, x2, y1, y2;
|
||||
int cache_index = g[i].index % ARRAY_LENGTH (glyph_cache);
|
||||
intel_glyph_t *glyph;
|
||||
|
||||
scaled_glyph = glyph_cache[cache_index];
|
||||
if (scaled_glyph == NULL ||
|
||||
_cairo_scaled_glyph_index (scaled_glyph) != g[i].index)
|
||||
{
|
||||
status = _cairo_scaled_glyph_lookup (scaled_font,
|
||||
g[i].index,
|
||||
CAIRO_SCALED_GLYPH_INFO_METRICS,
|
||||
NULL, /* foreground color */
|
||||
&scaled_glyph);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
glyph_cache[cache_index] = scaled_glyph;
|
||||
}
|
||||
|
||||
if (unlikely (scaled_glyph->metrics.width == 0 ||
|
||||
scaled_glyph->metrics.height == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX glyph images are snapped to pixel locations */
|
||||
x = _cairo_lround (g[i].x);
|
||||
y = _cairo_lround (g[i].y);
|
||||
|
||||
x1 = x + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.x);
|
||||
y1 = y + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.y);
|
||||
x2 = x + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.x);
|
||||
y2 = y + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.y);
|
||||
|
||||
if (x2 < extents.bounded.x ||
|
||||
y2 < extents.bounded.y ||
|
||||
x1 > extents.bounded.x + extents.bounded.width ||
|
||||
y1 > extents.bounded.y + extents.bounded.height)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scaled_glyph->surface_private == NULL) {
|
||||
status = intel_get_glyph (&device->intel, scaled_font, scaled_glyph);
|
||||
if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) {
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
continue;
|
||||
}
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
}
|
||||
glyph = intel_glyph_pin (scaled_glyph->surface_private);
|
||||
|
||||
if (glyph->cache->buffer.bo != last_bo) {
|
||||
intel_buffer_cache_t *cache = glyph->cache;
|
||||
|
||||
glyphs.shader.mask.type.vertex = VS_GLYPHS;
|
||||
glyphs.shader.mask.type.fragment = FS_GLYPHS;
|
||||
glyphs.shader.mask.type.pattern = PATTERN_BASE;
|
||||
|
||||
glyphs.shader.mask.base.bo = cache->buffer.bo;
|
||||
glyphs.shader.mask.base.format = cache->buffer.format;
|
||||
glyphs.shader.mask.base.width = cache->buffer.width;
|
||||
glyphs.shader.mask.base.height = cache->buffer.height;
|
||||
glyphs.shader.mask.base.stride = cache->buffer.stride;
|
||||
glyphs.shader.mask.base.filter = i965_filter (CAIRO_FILTER_NEAREST);
|
||||
glyphs.shader.mask.base.extend = i965_extend (CAIRO_EXTEND_NONE);
|
||||
glyphs.shader.mask.base.content = CAIRO_CONTENT_ALPHA; /* XXX */
|
||||
|
||||
glyphs.shader.committed = FALSE;
|
||||
status = i965_shader_commit (&glyphs.shader, device);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
last_bo = cache->buffer.bo;
|
||||
}
|
||||
|
||||
x2 = x1 + glyph->width;
|
||||
y2 = y1 + glyph->height;
|
||||
|
||||
if (mask_x)
|
||||
x1 += mask_x, x2 += mask_x;
|
||||
if (mask_y)
|
||||
y1 += mask_y, y2 += mask_y;
|
||||
|
||||
i965_add_glyph_rectangle (&glyphs, x1, y1, x2, y2, glyph);
|
||||
}
|
||||
|
||||
if (mask != NULL && clip_region != NULL)
|
||||
i965_clipped_vertices (device, &glyphs.head, clip_region);
|
||||
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
FINISH:
|
||||
_cairo_scaled_font_thaw_cache (scaled_font);
|
||||
cairo_device_release (surface->intel.drm.base.device);
|
||||
CLEANUP_GLYPHS:
|
||||
i965_shader_fini (&glyphs.shader);
|
||||
|
||||
if (glyphs.head.bo != NULL) {
|
||||
struct i965_vbo *vbo, *next;
|
||||
|
||||
intel_bo_destroy (&device->intel, glyphs.head.bo);
|
||||
for (vbo = glyphs.head.next; vbo != NULL; vbo = next) {
|
||||
next = vbo->next;
|
||||
intel_bo_destroy (&device->intel, vbo->bo);
|
||||
free (vbo);
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely (status == CAIRO_INT_STATUS_UNSUPPORTED)) {
|
||||
cairo_path_fixed_t path;
|
||||
|
||||
_cairo_path_fixed_init (&path);
|
||||
status = _cairo_scaled_font_glyph_path (scaled_font,
|
||||
g + i, num_glyphs - i,
|
||||
&path);
|
||||
if (mask_x | mask_y) {
|
||||
_cairo_path_fixed_translate (&path,
|
||||
_cairo_fixed_from_int (mask_x),
|
||||
_cairo_fixed_from_int (mask_y));
|
||||
}
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = surface->intel.drm.base.backend->fill (glyphs.shader.target,
|
||||
glyphs.shader.op,
|
||||
mask != NULL ? &_cairo_pattern_white.base : source,
|
||||
&path,
|
||||
CAIRO_FILL_RULE_WINDING,
|
||||
0,
|
||||
scaled_font->options.antialias,
|
||||
clip);
|
||||
}
|
||||
_cairo_path_fixed_fini (&path);
|
||||
}
|
||||
|
||||
if (mask != NULL) {
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = i965_surface_mask_internal (surface, op, source, mask,
|
||||
clip, &extents);
|
||||
}
|
||||
cairo_surface_finish (&mask->intel.drm.base);
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
}
|
||||
|
||||
if (have_clip)
|
||||
_cairo_clip_fini (&local_clip);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
@ -1,737 +0,0 @@
|
|||
#ifndef CAIRO_DRM_I965_PRIVATE_H
|
||||
#define CAIRO_DRM_I965_PRIVATE_H
|
||||
|
||||
#include "cairo-drm-intel-private.h"
|
||||
|
||||
#include "cairo-hash-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
|
||||
#include "cairo-drm-intel-brw-defines.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define BRW_MI_GLOBAL_SNAPSHOT_RESET (1 << 3)
|
||||
|
||||
/*
|
||||
* New regs for broadwater -- we need to split this file up sensibly somehow.
|
||||
*/
|
||||
#define BRW_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
|
||||
((Pipeline) << 27) | \
|
||||
((Opcode) << 24) | \
|
||||
((Subopcode) << 16))
|
||||
|
||||
#define BRW_URB_FENCE BRW_3D(0, 0, 0)
|
||||
#define BRW_CS_URB_STATE BRW_3D(0, 0, 1)
|
||||
#define BRW_CONSTANT_BUFFER BRW_3D(0, 0, 2)
|
||||
#define BRW_STATE_PREFETCH BRW_3D(0, 0, 3)
|
||||
|
||||
#define BRW_STATE_BASE_ADDRESS BRW_3D(0, 1, 1)
|
||||
#define BRW_STATE_SIP BRW_3D(0, 1, 2)
|
||||
#define BRW_PIPELINE_SELECT BRW_3D(0, 1, 4)
|
||||
|
||||
#define NEW_PIPELINE_SELECT BRW_3D(1, 1, 4)
|
||||
|
||||
#define BRW_MEDIA_STATE_POINTERS BRW_3D(2, 0, 0)
|
||||
#define BRW_MEDIA_OBJECT BRW_3D(2, 1, 0)
|
||||
|
||||
#define BRW_3DSTATE_PIPELINED_POINTERS BRW_3D(3, 0, 0)
|
||||
#define BRW_3DSTATE_BINDING_TABLE_POINTERS BRW_3D(3, 0, 1)
|
||||
#define BRW_3DSTATE_VERTEX_BUFFERS BRW_3D(3, 0, 8)
|
||||
#define BRW_3DSTATE_VERTEX_ELEMENTS BRW_3D(3, 0, 9)
|
||||
#define BRW_3DSTATE_INDEX_BUFFER BRW_3D(3, 0, 0xa)
|
||||
#define BRW_3DSTATE_VF_STATISTICS BRW_3D(3, 0, 0xb)
|
||||
|
||||
#define BRW_3DSTATE_DRAWING_RECTANGLE BRW_3D(3, 1, 0)
|
||||
#define BRW_3DSTATE_CONSTANT_COLOR BRW_3D(3, 1, 1)
|
||||
#define BRW_3DSTATE_SAMPLER_PALETTE_LOAD BRW_3D(3, 1, 2)
|
||||
#define BRW_3DSTATE_CHROMA_KEY BRW_3D(3, 1, 4)
|
||||
#define BRW_3DSTATE_DEPTH_BUFFER BRW_3D(3, 1, 5)
|
||||
#define BRW_3DSTATE_POLY_STIPPLE_OFFSET BRW_3D(3, 1, 6)
|
||||
#define BRW_3DSTATE_POLY_STIPPLE_PATTERN BRW_3D(3, 1, 7)
|
||||
#define BRW_3DSTATE_LINE_STIPPLE BRW_3D(3, 1, 8)
|
||||
#define BRW_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP BRW_3D(3, 1, 9)
|
||||
/* These two are BLC and CTG only, not BW or CL */
|
||||
#define BRW_3DSTATE_AA_LINE_PARAMS BRW_3D(3, 1, 0xa)
|
||||
#define BRW_3DSTATE_GS_SVB_INDEX BRW_3D(3, 1, 0xb)
|
||||
|
||||
#define BRW_PIPE_CONTROL BRW_3D(3, 2, 0)
|
||||
|
||||
#define BRW_3DPRIMITIVE BRW_3D(3, 3, 0)
|
||||
|
||||
#define PIPELINE_SELECT_3D 0
|
||||
#define PIPELINE_SELECT_MEDIA 1
|
||||
|
||||
#define UF0_CS_REALLOC (1 << 13)
|
||||
#define UF0_VFE_REALLOC (1 << 12)
|
||||
#define UF0_SF_REALLOC (1 << 11)
|
||||
#define UF0_CLIP_REALLOC (1 << 10)
|
||||
#define UF0_GS_REALLOC (1 << 9)
|
||||
#define UF0_VS_REALLOC (1 << 8)
|
||||
#define UF1_CLIP_FENCE_SHIFT 20
|
||||
#define UF1_GS_FENCE_SHIFT 10
|
||||
#define UF1_VS_FENCE_SHIFT 0
|
||||
#define UF2_CS_FENCE_SHIFT 20
|
||||
#define UF2_VFE_FENCE_SHIFT 10
|
||||
#define UF2_SF_FENCE_SHIFT 0
|
||||
|
||||
/* for BRW_STATE_BASE_ADDRESS */
|
||||
#define BASE_ADDRESS_MODIFY (1 << 0)
|
||||
|
||||
/* for BRW_3DSTATE_PIPELINED_POINTERS */
|
||||
#define BRW_GS_DISABLE 0
|
||||
#define BRW_GS_ENABLE 1
|
||||
#define BRW_CLIP_DISABLE 0
|
||||
#define BRW_CLIP_ENABLE 1
|
||||
|
||||
/* for BRW_PIPE_CONTROL */
|
||||
#define BRW_PIPE_CONTROL_NOWRITE (0 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_QWORD (1 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_DEPTH (2 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_TIME (3 << 14)
|
||||
#define BRW_PIPE_CONTROL_DEPTH_STALL (1 << 13)
|
||||
#define BRW_PIPE_CONTROL_WC_FLUSH (1 << 12)
|
||||
#define BRW_PIPE_CONTROL_IS_FLUSH (1 << 11)
|
||||
#define BRW_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
|
||||
#define BRW_PIPE_CONTROL_GLOBAL_GTT (1 << 2)
|
||||
#define BRW_PIPE_CONTROL_LOCAL_PGTT (0 << 2)
|
||||
|
||||
/* VERTEX_BUFFER_STATE Structure */
|
||||
#define VB0_BUFFER_INDEX_SHIFT 27
|
||||
#define VB0_VERTEXDATA (0 << 26)
|
||||
#define VB0_INSTANCEDATA (1 << 26)
|
||||
#define VB0_BUFFER_PITCH_SHIFT 0
|
||||
|
||||
/* VERTEX_ELEMENT_STATE Structure */
|
||||
#define VE0_VERTEX_BUFFER_INDEX_SHIFT 27
|
||||
#define VE0_VALID (1 << 26)
|
||||
#define VE0_FORMAT_SHIFT 16
|
||||
#define VE0_OFFSET_SHIFT 0
|
||||
#define VE1_VFCOMPONENT_0_SHIFT 28
|
||||
#define VE1_VFCOMPONENT_1_SHIFT 24
|
||||
#define VE1_VFCOMPONENT_2_SHIFT 20
|
||||
#define VE1_VFCOMPONENT_3_SHIFT 16
|
||||
#define VE1_DESTINATION_ELEMENT_OFFSET_SHIFT 0
|
||||
|
||||
/* 3DPRIMITIVE bits */
|
||||
#define BRW_3DPRIMITIVE_VERTEX_SEQUENTIAL (0 << 15)
|
||||
#define BRW_3DPRIMITIVE_VERTEX_RANDOM (1 << 15)
|
||||
/* Primitive types are in brw_defines.h */
|
||||
#define BRW_3DPRIMITIVE_TOPOLOGY_SHIFT 10
|
||||
|
||||
#define BRW_SVG_CTL 0x7400
|
||||
|
||||
#define BRW_SVG_CTL_GS_BA (0 << 8)
|
||||
#define BRW_SVG_CTL_SS_BA (1 << 8)
|
||||
#define BRW_SVG_CTL_IO_BA (2 << 8)
|
||||
#define BRW_SVG_CTL_GS_AUB (3 << 8)
|
||||
#define BRW_SVG_CTL_IO_AUB (4 << 8)
|
||||
#define BRW_SVG_CTL_SIP (5 << 8)
|
||||
|
||||
#define BRW_SVG_RDATA 0x7404
|
||||
#define BRW_SVG_WORK_CTL 0x7408
|
||||
|
||||
#define BRW_VF_CTL 0x7500
|
||||
|
||||
#define BRW_VF_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_VF_CTL_SNAPSHOT_MUX_SELECT_THREADID (0 << 8)
|
||||
#define BRW_VF_CTL_SNAPSHOT_MUX_SELECT_VF_DEBUG (1 << 8)
|
||||
#define BRW_VF_CTL_SNAPSHOT_TYPE_VERTEX_SEQUENCE (0 << 4)
|
||||
#define BRW_VF_CTL_SNAPSHOT_TYPE_VERTEX_INDEX (1 << 4)
|
||||
#define BRW_VF_CTL_SKIP_INITIAL_PRIMITIVES (1 << 3)
|
||||
#define BRW_VF_CTL_MAX_PRIMITIVES_LIMIT_ENABLE (1 << 2)
|
||||
#define BRW_VF_CTL_VERTEX_RANGE_LIMIT_ENABLE (1 << 1)
|
||||
#define BRW_VF_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_VF_STRG_VAL 0x7504
|
||||
#define BRW_VF_STR_VL_OVR 0x7508
|
||||
#define BRW_VF_VC_OVR 0x750c
|
||||
#define BRW_VF_STR_PSKIP 0x7510
|
||||
#define BRW_VF_MAX_PRIM 0x7514
|
||||
#define BRW_VF_RDATA 0x7518
|
||||
|
||||
#define BRW_VS_CTL 0x7600
|
||||
#define BRW_VS_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VERTEX_0 (0 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VERTEX_1 (1 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VALID_COUNT (2 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VS_KERNEL_POINTER (3 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_ALL_THREADS (1 << 2)
|
||||
#define BRW_VS_CTL_THREAD_SNAPSHOT_ENABLE (1 << 1)
|
||||
#define BRW_VS_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_VS_STRG_VAL 0x7604
|
||||
#define BRW_VS_RDATA 0x7608
|
||||
|
||||
#define BRW_SF_CTL 0x7b00
|
||||
#define BRW_SF_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_0_FF_ID (0 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_0_REL_COUNT (1 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_1_FF_ID (2 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_1_REL_COUNT (3 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_2_FF_ID (4 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_2_REL_COUNT (5 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_COUNT (6 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_SF_KERNEL_POINTER (7 << 8)
|
||||
#define BRW_SF_CTL_MIN_MAX_PRIMITIVE_RANGE_ENABLE (1 << 4)
|
||||
#define BRW_SF_CTL_DEBUG_CLIP_RECTANGLE_ENABLE (1 << 3)
|
||||
#define BRW_SF_CTL_SNAPSHOT_ALL_THREADS (1 << 2)
|
||||
#define BRW_SF_CTL_THREAD_SNAPSHOT_ENABLE (1 << 1)
|
||||
#define BRW_SF_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_SF_STRG_VAL 0x7b04
|
||||
#define BRW_SF_RDATA 0x7b18
|
||||
|
||||
#define BRW_WIZ_CTL 0x7c00
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_WIZ_CTL_SUBSPAN_INSTANCE_SHIFT 16
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_MUX_WIZ_KERNEL_POINTER (0 << 8)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_MUX_SUBSPAN_INSTANCE (1 << 8)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_MUX_PRIMITIVE_SEQUENCE (2 << 8)
|
||||
#define BRW_WIZ_CTL_SINGLE_SUBSPAN_DISPATCH (1 << 6)
|
||||
#define BRW_WIZ_CTL_IGNORE_COLOR_SCOREBOARD_STALLS (1 << 5)
|
||||
#define BRW_WIZ_CTL_ENABLE_SUBSPAN_INSTANCE_COMPARE (1 << 4)
|
||||
#define BRW_WIZ_CTL_USE_UPSTREAM_SNAPSHOT_FLAG (1 << 3)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_ALL_THREADS (1 << 2)
|
||||
#define BRW_WIZ_CTL_THREAD_SNAPSHOT_ENABLE (1 << 1)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_WIZ_STRG_VAL 0x7c04
|
||||
#define BRW_WIZ_RDATA 0x7c18
|
||||
|
||||
#define BRW_TS_CTL 0x7e00
|
||||
#define BRW_TS_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_TS_CTL_SNAPSHOT_MESSAGE_ERROR (0 << 8)
|
||||
#define BRW_TS_CTL_SNAPSHOT_INTERFACE_DESCRIPTOR (3 << 8)
|
||||
#define BRW_TS_CTL_SNAPSHOT_ALL_CHILD_THREADS (1 << 2)
|
||||
#define BRW_TS_CTL_SNAPSHOT_ALL_ROOT_THREADS (1 << 1)
|
||||
#define BRW_TS_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_TS_STRG_VAL 0x7e04
|
||||
#define BRW_TS_RDATA 0x7e08
|
||||
|
||||
#define BRW_TD_CTL 0x8000
|
||||
#define BRW_TD_CTL_MUX_SHIFT 8
|
||||
#define BRW_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH (1 << 7)
|
||||
#define BRW_TD_CTL_FORCE_EXTERNAL_HALT (1 << 6)
|
||||
#define BRW_TD_CTL_EXCEPTION_MASK_OVERRIDE (1 << 5)
|
||||
#define BRW_TD_CTL_FORCE_THREAD_BREAKPOINT_ENABLE (1 << 4)
|
||||
#define BRW_TD_CTL_BREAKPOINT_ENABLE (1 << 2)
|
||||
#define BRW_TD_CTL2 0x8004
|
||||
#define BRW_TD_CTL2_ILLEGAL_OPCODE_EXCEPTION_OVERRIDE (1 << 28)
|
||||
#define BRW_TD_CTL2_MASKSTACK_EXCEPTION_OVERRIDE (1 << 26)
|
||||
#define BRW_TD_CTL2_SOFTWARE_EXCEPTION_OVERRIDE (1 << 25)
|
||||
#define BRW_TD_CTL2_ACTIVE_THREAD_LIMIT_SHIFT 16
|
||||
#define BRW_TD_CTL2_ACTIVE_THREAD_LIMIT_ENABLE (1 << 8)
|
||||
#define BRW_TD_CTL2_THREAD_SPAWNER_EXECUTION_MASK_ENABLE (1 << 7)
|
||||
#define BRW_TD_CTL2_WIZ_EXECUTION_MASK_ENABLE (1 << 6)
|
||||
#define BRW_TD_CTL2_SF_EXECUTION_MASK_ENABLE (1 << 5)
|
||||
#define BRW_TD_CTL2_CLIPPER_EXECUTION_MASK_ENABLE (1 << 4)
|
||||
#define BRW_TD_CTL2_GS_EXECUTION_MASK_ENABLE (1 << 3)
|
||||
#define BRW_TD_CTL2_VS_EXECUTION_MASK_ENABLE (1 << 0)
|
||||
#define BRW_TD_VF_VS_EMSK 0x8008
|
||||
#define BRW_TD_GS_EMSK 0x800c
|
||||
#define BRW_TD_CLIP_EMSK 0x8010
|
||||
#define BRW_TD_SF_EMSK 0x8014
|
||||
#define BRW_TD_WIZ_EMSK 0x8018
|
||||
#define BRW_TD_0_6_EHTRG_VAL 0x801c
|
||||
#define BRW_TD_0_7_EHTRG_VAL 0x8020
|
||||
#define BRW_TD_0_6_EHTRG_MSK 0x8024
|
||||
#define BRW_TD_0_7_EHTRG_MSK 0x8028
|
||||
#define BRW_TD_RDATA 0x802c
|
||||
#define BRW_TD_TS_EMSK 0x8030
|
||||
|
||||
#define BRW_EU_CTL 0x8800
|
||||
#define BRW_EU_CTL_SELECT_SHIFT 16
|
||||
#define BRW_EU_CTL_DATA_MUX_SHIFT 8
|
||||
#define BRW_EU_ATT_0 0x8810
|
||||
#define BRW_EU_ATT_1 0x8814
|
||||
#define BRW_EU_ATT_DATA_0 0x8820
|
||||
#define BRW_EU_ATT_DATA_1 0x8824
|
||||
#define BRW_EU_ATT_CLR_0 0x8830
|
||||
#define BRW_EU_ATT_CLR_1 0x8834
|
||||
#define BRW_EU_RDATA 0x8840
|
||||
|
||||
typedef struct i965_device i965_device_t;
|
||||
typedef struct i965_surface i965_surface_t;
|
||||
typedef struct i965_shader i965_shader_t;
|
||||
typedef struct i965_stream i965_stream_t;
|
||||
|
||||
struct i965_sf_state {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_sf_state_equal (const void *, const void *);
|
||||
|
||||
struct i965_cc_state {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_cc_state_equal (const void *, const void *);
|
||||
|
||||
struct i965_wm_kernel {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct i965_wm_state {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t kernel;
|
||||
uint32_t sampler;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_wm_state_equal (const void *, const void *);
|
||||
|
||||
struct i965_wm_binding {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t table[4];
|
||||
int size;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_wm_binding_equal (const void *, const void *);
|
||||
|
||||
struct i965_sampler {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct i965_vbo {
|
||||
struct i965_vbo *next;
|
||||
intel_bo_t *bo;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
struct i965_surface {
|
||||
intel_surface_t intel;
|
||||
|
||||
uint32_t stream;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct i965_pending_relocation {
|
||||
uint32_t offset;
|
||||
uint32_t read_domains;
|
||||
uint32_t write_domain;
|
||||
uint32_t delta;
|
||||
};
|
||||
|
||||
struct i965_stream {
|
||||
uint32_t used;
|
||||
uint32_t committed;
|
||||
uint32_t size;
|
||||
uint8_t *data;
|
||||
uint32_t serial;
|
||||
|
||||
int num_pending_relocations;
|
||||
int max_pending_relocations;
|
||||
struct i965_pending_relocation *pending_relocations;
|
||||
|
||||
int num_relocations;
|
||||
int max_relocations;
|
||||
struct drm_i915_gem_relocation_entry *relocations;
|
||||
};
|
||||
|
||||
#define I965_BATCH_SIZE (16 * 4096)
|
||||
#define I965_GENERAL_SIZE (16 * 4096)
|
||||
#define I965_SURFACE_SIZE (32 * 4096)
|
||||
#define I965_VERTEX_SIZE (128 * 4096)
|
||||
|
||||
#define I965_TILING_DEFAULT I915_TILING_Y
|
||||
|
||||
|
||||
struct i965_device {
|
||||
intel_device_t intel;
|
||||
|
||||
cairo_bool_t is_g4x;
|
||||
|
||||
i965_shader_t *shader; /* note: only valid during geometry emission */
|
||||
|
||||
/* track state changes */
|
||||
struct i965_sf_state sf_state;
|
||||
struct i965_cc_state cc_state;
|
||||
struct i965_wm_state wm_state;
|
||||
struct i965_wm_binding wm_binding;
|
||||
|
||||
i965_surface_t *target;
|
||||
uint32_t target_offset;
|
||||
|
||||
intel_bo_t *source;
|
||||
uint32_t source_offset;
|
||||
|
||||
intel_bo_t *mask;
|
||||
uint32_t mask_offset;
|
||||
|
||||
intel_bo_t *clip;
|
||||
uint32_t clip_offset;
|
||||
|
||||
uint32_t draw_rectangle;
|
||||
|
||||
uint32_t vs_offset;
|
||||
uint32_t border_color_offset;
|
||||
cairo_hash_table_t *sf_states;
|
||||
cairo_hash_table_t *cc_states;
|
||||
cairo_hash_table_t *wm_kernels;
|
||||
cairo_hash_table_t *wm_states;
|
||||
cairo_hash_table_t *wm_bindings;
|
||||
cairo_hash_table_t *samplers;
|
||||
intel_bo_t *general_state;
|
||||
|
||||
cairo_freelist_t sf_freelist;
|
||||
cairo_freelist_t cc_freelist;
|
||||
cairo_freelist_t wm_kernel_freelist;
|
||||
cairo_freelist_t wm_state_freelist;
|
||||
cairo_freelist_t wm_binding_freelist;
|
||||
cairo_freelist_t sampler_freelist;
|
||||
|
||||
uint32_t vertex_type;
|
||||
uint32_t vertex_size;
|
||||
uint32_t rectangle_size;
|
||||
uint32_t last_vertex_size;
|
||||
|
||||
float *constants; /* 4 x matrix + 2 x source */
|
||||
unsigned constants_size;
|
||||
cairo_bool_t have_urb_fences;
|
||||
|
||||
i965_stream_t batch;
|
||||
uint8_t batch_base[I965_BATCH_SIZE];
|
||||
struct drm_i915_gem_relocation_entry batch_relocations[2048];
|
||||
|
||||
i965_stream_t surface;
|
||||
uint8_t surface_base[I965_SURFACE_SIZE];
|
||||
struct i965_pending_relocation surface_pending_relocations[1];
|
||||
struct drm_i915_gem_relocation_entry surface_relocations[1024];
|
||||
|
||||
i965_stream_t general;
|
||||
uint8_t general_base[I965_GENERAL_SIZE];
|
||||
struct i965_pending_relocation general_pending_relocations[1];
|
||||
|
||||
i965_stream_t vertex;
|
||||
uint8_t vertex_base[I965_VERTEX_SIZE];
|
||||
struct i965_pending_relocation vertex_pending_relocations[512];
|
||||
|
||||
struct {
|
||||
size_t gtt_size;
|
||||
|
||||
intel_bo_t *bo[1024];
|
||||
int count;
|
||||
|
||||
struct drm_i915_gem_exec_object2 exec[1024];
|
||||
} exec;
|
||||
cairo_list_t flush;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
VS_NONE = 0,
|
||||
VS_GLYPHS,
|
||||
VS_SPANS,
|
||||
} i965_vertex_shader_t;
|
||||
|
||||
typedef enum {
|
||||
FS_NONE = 0,
|
||||
FS_CONSTANT,
|
||||
FS_LINEAR,
|
||||
FS_RADIAL,
|
||||
FS_SURFACE,
|
||||
FS_GLYPHS,
|
||||
FS_SPANS,
|
||||
} i965_fragment_shader_t;
|
||||
|
||||
typedef enum {
|
||||
PATTERN_BASE,
|
||||
PATTERN_SOLID,
|
||||
PATTERN_LINEAR,
|
||||
PATTERN_RADIAL,
|
||||
PATTERN_SURFACE,
|
||||
} i965_shader_channel_t;
|
||||
#define PATTERN_NONE (i965_shader_channel_t)-1
|
||||
|
||||
struct i965_shader {
|
||||
i965_device_t *device;
|
||||
i965_surface_t *target;
|
||||
|
||||
cairo_operator_t op;
|
||||
|
||||
cairo_bool_t committed;
|
||||
cairo_bool_t need_combine;
|
||||
|
||||
float constants[4*8 + 2*8]; /* 4 x matrix + 2 x source */
|
||||
unsigned constants_size;
|
||||
|
||||
union i965_shader_channel {
|
||||
struct {
|
||||
i965_vertex_shader_t vertex;
|
||||
i965_fragment_shader_t fragment;
|
||||
i965_shader_channel_t pattern;
|
||||
} type;
|
||||
struct i965_shader_base {
|
||||
i965_vertex_shader_t vertex;
|
||||
i965_fragment_shader_t fragment;
|
||||
i965_shader_channel_t pattern;
|
||||
|
||||
uint32_t mode;
|
||||
|
||||
float constants[8];
|
||||
unsigned constants_size;
|
||||
|
||||
intel_bo_t *bo;
|
||||
cairo_format_t format;
|
||||
cairo_content_t content;
|
||||
int width, height, stride;
|
||||
int filter, extend;
|
||||
cairo_matrix_t matrix;
|
||||
cairo_bool_t has_component_alpha;
|
||||
} base;
|
||||
struct i965_shader_solid {
|
||||
struct i965_shader_base base;
|
||||
} solid;
|
||||
struct i965_shader_linear {
|
||||
struct i965_shader_base base;
|
||||
} linear;
|
||||
struct i965_shader_radial {
|
||||
struct i965_shader_base base;
|
||||
} radial;
|
||||
struct i965_shader_surface {
|
||||
struct i965_shader_base base;
|
||||
cairo_surface_t *surface;
|
||||
} surface;
|
||||
} source, mask, clip, dst;
|
||||
|
||||
jmp_buf unwind;
|
||||
};
|
||||
|
||||
enum i965_shader_linear_mode {
|
||||
/* XXX REFLECT */
|
||||
LINEAR_TEXTURE,
|
||||
LINEAR_NONE,
|
||||
LINEAR_REPEAT,
|
||||
LINEAR_PAD,
|
||||
};
|
||||
|
||||
enum i965_shader_radial_mode {
|
||||
RADIAL_ONE,
|
||||
RADIAL_TWO
|
||||
};
|
||||
|
||||
typedef cairo_status_t
|
||||
(*i965_spans_func_t) (void *closure,
|
||||
cairo_span_renderer_t *renderer,
|
||||
const cairo_rectangle_int_t *extents);
|
||||
|
||||
static inline i965_device_t *
|
||||
i965_device (i965_surface_t *surface)
|
||||
{
|
||||
return (i965_device_t *) surface->intel.drm.base.device;
|
||||
}
|
||||
|
||||
cairo_private void
|
||||
i965_emit_relocation (i965_device_t *device,
|
||||
i965_stream_t *stream,
|
||||
intel_bo_t *target,
|
||||
uint32_t target_offset,
|
||||
uint32_t read_domains,
|
||||
uint32_t write_domain,
|
||||
uint32_t offset);
|
||||
|
||||
static cairo_always_inline uint32_t
|
||||
i965_stream_emit (i965_stream_t *stream, const void *data, size_t size)
|
||||
{
|
||||
uint32_t offset;
|
||||
|
||||
offset = stream->used;
|
||||
assert (offset + size <= stream->size);
|
||||
memcpy (stream->data + offset, data, size);
|
||||
stream->used += size;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static cairo_always_inline void
|
||||
i965_stream_align (i965_stream_t *stream, uint32_t size)
|
||||
{
|
||||
stream->used = (stream->used + size - 1) & -size;
|
||||
}
|
||||
|
||||
static cairo_always_inline void *
|
||||
i965_stream_alloc (i965_stream_t *stream, uint32_t align, uint32_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (align)
|
||||
i965_stream_align (stream, align);
|
||||
|
||||
assert (stream->used + size <= stream->size);
|
||||
ptr = stream->data + stream->used;
|
||||
stream->used += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static cairo_always_inline uint32_t
|
||||
i965_stream_offsetof (i965_stream_t *stream, const void *ptr)
|
||||
{
|
||||
return (char *) ptr - (char *) stream->data;
|
||||
}
|
||||
|
||||
cairo_private void
|
||||
i965_stream_commit (i965_device_t *device,
|
||||
i965_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
i965_general_state_reset (i965_device_t *device);
|
||||
|
||||
static inline void
|
||||
i965_batch_emit_dword (i965_device_t *device, uint32_t dword)
|
||||
{
|
||||
*(uint32_t *) (device->batch.data + device->batch.used) = dword;
|
||||
device->batch.used += 4;
|
||||
}
|
||||
|
||||
#define OUT_BATCH(dword) i965_batch_emit_dword(device, dword)
|
||||
|
||||
cairo_private void
|
||||
i965_clipped_vertices (i965_device_t *device,
|
||||
struct i965_vbo *vbo,
|
||||
cairo_region_t *clip_region);
|
||||
|
||||
cairo_private void
|
||||
i965_flush_vertices (i965_device_t *device);
|
||||
|
||||
cairo_private void
|
||||
i965_finish_vertices (i965_device_t *device);
|
||||
|
||||
static inline float *
|
||||
i965_add_rectangle (i965_device_t *device)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = device->rectangle_size;
|
||||
if (unlikely (device->vertex.used + size > device->vertex.size))
|
||||
i965_finish_vertices (device);
|
||||
|
||||
vertices = (float *) (device->vertex.data + device->vertex.used);
|
||||
device->vertex.used += size;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static inline void
|
||||
i965_shader_add_rectangle (const i965_shader_t *shader,
|
||||
int x, int y,
|
||||
int w, int h)
|
||||
{
|
||||
float *v;
|
||||
|
||||
v= i965_add_rectangle (shader->device);
|
||||
|
||||
/* bottom-right */
|
||||
*v++ = x + w;
|
||||
*v++ = y + h;
|
||||
|
||||
/* bottom-left */
|
||||
*v++ = x;
|
||||
*v++ = y + h;
|
||||
|
||||
/* top-left */
|
||||
*v++ = x;
|
||||
*v++ = y;
|
||||
}
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
i965_surface_create_internal (cairo_drm_device_t *base_dev,
|
||||
cairo_format_t format,
|
||||
int width, int height,
|
||||
uint32_t tiling,
|
||||
cairo_bool_t gpu_target);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_clip_and_composite_spans (i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
i965_spans_func_t draw_func,
|
||||
void *draw_closure,
|
||||
const cairo_composite_rectangles_t*extents,
|
||||
cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_int_status_t
|
||||
i965_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining);
|
||||
|
||||
cairo_private void
|
||||
i965_shader_init (i965_shader_t *shader,
|
||||
i965_surface_t *dst,
|
||||
cairo_operator_t op);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_shader_acquire_pattern (i965_shader_t *shader,
|
||||
union i965_shader_channel *src,
|
||||
const cairo_pattern_t *pattern,
|
||||
const cairo_rectangle_int_t *extents);
|
||||
|
||||
cairo_private void
|
||||
i965_shader_set_clip (i965_shader_t *shader,
|
||||
cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_shader_commit (i965_shader_t *shader,
|
||||
i965_device_t *device);
|
||||
|
||||
cairo_private void
|
||||
i965_shader_fini (i965_shader_t *shader);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_device_flush (i965_device_t *device);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_fixup_unbounded (i965_surface_t *dst,
|
||||
const cairo_composite_rectangles_t *extents,
|
||||
cairo_clip_t *clip);
|
||||
|
||||
static inline int
|
||||
i965_filter (cairo_filter_t filter)
|
||||
{
|
||||
switch (filter) {
|
||||
default:
|
||||
case CAIRO_FILTER_FAST:
|
||||
case CAIRO_FILTER_NEAREST:
|
||||
return BRW_MAPFILTER_NEAREST;
|
||||
|
||||
case CAIRO_FILTER_GOOD:
|
||||
case CAIRO_FILTER_BEST:
|
||||
case CAIRO_FILTER_BILINEAR:
|
||||
case CAIRO_FILTER_GAUSSIAN:
|
||||
return BRW_MAPFILTER_LINEAR;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
i965_extend (cairo_extend_t extend)
|
||||
{
|
||||
switch (extend) {
|
||||
default:
|
||||
case CAIRO_EXTEND_NONE:
|
||||
return BRW_TEXCOORDMODE_CLAMP_BORDER;
|
||||
case CAIRO_EXTEND_REPEAT:
|
||||
return BRW_TEXCOORDMODE_WRAP;
|
||||
case CAIRO_EXTEND_PAD:
|
||||
return BRW_TEXCOORDMODE_CLAMP;
|
||||
case CAIRO_EXTEND_REFLECT:
|
||||
return BRW_TEXCOORDMODE_MIRROR;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CAIRO_DRM_I965_PRIVATE_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,407 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-boxes-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-drm-i965-private.h"
|
||||
|
||||
/* Operates in either immediate or retained mode.
|
||||
* When given a clip region we record the sequence of vbo and then
|
||||
* replay them for each clip rectangle, otherwise we simply emit
|
||||
* the vbo straight into the command stream.
|
||||
*/
|
||||
|
||||
typedef struct _i965_spans i965_spans_t;
|
||||
|
||||
typedef float *
|
||||
(*i965_get_rectangle_func_t) (i965_spans_t *spans);
|
||||
|
||||
struct _i965_spans {
|
||||
cairo_span_renderer_t renderer;
|
||||
|
||||
i965_device_t *device;
|
||||
|
||||
int xmin, xmax;
|
||||
cairo_bool_t is_bounded;
|
||||
const cairo_rectangle_int_t *extents;
|
||||
|
||||
i965_get_rectangle_func_t get_rectangle;
|
||||
i965_shader_t shader;
|
||||
|
||||
cairo_region_t *clip_region;
|
||||
|
||||
struct i965_vbo head, *tail;
|
||||
|
||||
unsigned int vbo_offset;
|
||||
float *vbo_base;
|
||||
};
|
||||
|
||||
static float *
|
||||
i965_spans_emit_rectangle (i965_spans_t *spans)
|
||||
{
|
||||
return i965_add_rectangle (spans->device);
|
||||
}
|
||||
|
||||
static float *
|
||||
i965_spans_accumulate_rectangle (i965_spans_t *spans)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = spans->device->rectangle_size;
|
||||
if (unlikely (spans->vbo_offset + size > I965_VERTEX_SIZE)) {
|
||||
struct i965_vbo *vbo;
|
||||
|
||||
vbo = _cairo_malloc (sizeof (struct i965_vbo));
|
||||
if (unlikely (vbo == NULL)) {
|
||||
/* throw error! */
|
||||
}
|
||||
|
||||
spans->tail->next = vbo;
|
||||
spans->tail = vbo;
|
||||
|
||||
vbo->next = NULL;
|
||||
vbo->bo = intel_bo_create (&spans->device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
vbo->count = 0;
|
||||
|
||||
spans->vbo_offset = 0;
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, vbo->bo);
|
||||
}
|
||||
|
||||
vertices = spans->vbo_base + spans->vbo_offset;
|
||||
spans->vbo_offset += size;
|
||||
spans->tail->count += 3;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static void
|
||||
i965_span_rectangle (i965_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_bounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage >= 128) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
255);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_bounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_unbounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_unbounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
int alpha = 0;
|
||||
if (half[0].coverage >= 128)
|
||||
alpha = 255;
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
alpha);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_spans_init (i965_spans_t *spans,
|
||||
i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
spans->device = i965_device (dst);
|
||||
i965_shader_init (&spans->shader, dst, op);
|
||||
|
||||
spans->is_bounded = extents->is_bounded;
|
||||
if (extents->is_bounded) {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i965_bounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i965_bounded_spans;
|
||||
|
||||
spans->extents = &extents->bounded;
|
||||
} else {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i965_unbounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i965_unbounded_spans;
|
||||
|
||||
spans->extents = &extents->unbounded;
|
||||
}
|
||||
spans->xmin = spans->extents->x;
|
||||
spans->xmax = spans->extents->x + spans->extents->width;
|
||||
|
||||
spans->clip_region = NULL;
|
||||
if (clip != NULL) {
|
||||
cairo_region_t *clip_region = NULL;
|
||||
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
spans->clip_region = clip_region;
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i965_shader_set_clip (&spans->shader, clip);
|
||||
}
|
||||
|
||||
spans->head.next = NULL;
|
||||
spans->head.bo = NULL;
|
||||
spans->head.count = 0;
|
||||
spans->tail = &spans->head;
|
||||
|
||||
if (spans->clip_region == NULL) {
|
||||
spans->get_rectangle = i965_spans_emit_rectangle;
|
||||
} else {
|
||||
spans->get_rectangle = i965_spans_accumulate_rectangle;
|
||||
spans->head.bo = intel_bo_create (&spans->device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
if (unlikely (spans->head.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, spans->head.bo);
|
||||
}
|
||||
spans->vbo_offset = 0;
|
||||
|
||||
return i965_shader_acquire_pattern (&spans->shader,
|
||||
&spans->shader.source,
|
||||
pattern, &extents->bounded);
|
||||
}
|
||||
|
||||
static void
|
||||
i965_spans_fini (i965_spans_t *spans)
|
||||
{
|
||||
i965_shader_fini (&spans->shader);
|
||||
|
||||
if (spans->head.bo != NULL) {
|
||||
struct i965_vbo *vbo, *next;
|
||||
|
||||
intel_bo_destroy (&spans->device->intel, spans->head.bo);
|
||||
for (vbo = spans->head.next; vbo != NULL; vbo = next) {
|
||||
next = vbo->next;
|
||||
intel_bo_destroy (&spans->device->intel, vbo->bo);
|
||||
free (vbo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
i965_clip_and_composite_spans (i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
i965_spans_func_t draw_func,
|
||||
void *draw_closure,
|
||||
const cairo_composite_rectangles_t*extents,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
i965_spans_t spans;
|
||||
i965_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (op == CAIRO_OPERATOR_CLEAR) {
|
||||
pattern = &_cairo_pattern_white.base;
|
||||
op = CAIRO_OPERATOR_DEST_OUT;
|
||||
}
|
||||
|
||||
status = i965_spans_init (&spans, dst, op, pattern, antialias, clip, extents);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
spans.shader.mask.base.content = CAIRO_CONTENT_ALPHA;
|
||||
spans.shader.mask.type.fragment = FS_SPANS;
|
||||
spans.shader.mask.type.vertex = VS_SPANS;
|
||||
spans.shader.mask.type.pattern = PATTERN_BASE;
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SPANS;
|
||||
|
||||
device = i965_device (dst);
|
||||
status = i965_shader_commit (&spans.shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
status = draw_func (draw_closure, &spans.renderer, spans.extents);
|
||||
if (spans.clip_region != NULL && status == CAIRO_STATUS_SUCCESS)
|
||||
i965_clipped_vertices (device, &spans.head, spans.clip_region);
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (dst->intel.drm.base.device);
|
||||
CLEANUP_SPANS:
|
||||
i965_spans_fini (&spans);
|
||||
|
||||
return status;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,824 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2005 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_BRW_DEFINES_H
|
||||
#define CAIRO_DRM_INTEL_BRW_DEFINES_H
|
||||
|
||||
/* 3D state: */
|
||||
#define _3DOP_3DSTATE_PIPELINED 0x0
|
||||
#define _3DOP_3DSTATE_NONPIPELINED 0x1
|
||||
#define _3DOP_3DCONTROL 0x2
|
||||
#define _3DOP_3DPRIMITIVE 0x3
|
||||
|
||||
#define _3DSTATE_PIPELINED_POINTERS 0x00
|
||||
#define _3DSTATE_BINDING_TABLE_POINTERS 0x01
|
||||
#define _3DSTATE_VERTEX_BUFFERS 0x08
|
||||
#define _3DSTATE_VERTEX_ELEMENTS 0x09
|
||||
#define _3DSTATE_INDEX_BUFFER 0x0A
|
||||
#define _3DSTATE_VF_STATISTICS 0x0B
|
||||
#define _3DSTATE_DRAWING_RECTANGLE 0x00
|
||||
#define _3DSTATE_CONSTANT_COLOR 0x01
|
||||
#define _3DSTATE_SAMPLER_PALETTE_LOAD 0x02
|
||||
#define _3DSTATE_CHROMA_KEY 0x04
|
||||
#define _3DSTATE_DEPTH_BUFFER 0x05
|
||||
#define _3DSTATE_POLY_STIPPLE_OFFSET 0x06
|
||||
#define _3DSTATE_POLY_STIPPLE_PATTERN 0x07
|
||||
#define _3DSTATE_LINE_STIPPLE 0x08
|
||||
#define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP 0x09
|
||||
#define _3DCONTROL 0x00
|
||||
#define _3DPRIMITIVE 0x00
|
||||
|
||||
#define PIPE_CONTROL_NOWRITE 0x00
|
||||
#define PIPE_CONTROL_WRITEIMMEDIATE 0x01
|
||||
#define PIPE_CONTROL_WRITEDEPTH 0x02
|
||||
#define PIPE_CONTROL_WRITETIMESTAMP 0x03
|
||||
|
||||
#define PIPE_CONTROL_GTTWRITE_PROCESS_LOCAL 0x00
|
||||
#define PIPE_CONTROL_GTTWRITE_GLOBAL 0x01
|
||||
|
||||
#define BRW_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
|
||||
((Pipeline) << 27) | \
|
||||
((Opcode) << 24) | \
|
||||
((Subopcode) << 16))
|
||||
|
||||
#define BRW_PIPE_CONTROL BRW_3D(3, 2, 0)
|
||||
#define BRW_PIPE_CONTROL_NOWRITE (0 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_QWORD (1 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_DEPTH (2 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_TIME (3 << 14)
|
||||
#define BRW_PIPE_CONTROL_DEPTH_STALL (1 << 13)
|
||||
#define BRW_PIPE_CONTROL_WC_FLUSH (1 << 12)
|
||||
#define BRW_PIPE_CONTROL_IS_FLUSH (1 << 11)
|
||||
#define BRW_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
|
||||
#define BRW_PIPE_CONTROL_GLOBAL_GTT (1 << 2)
|
||||
#define BRW_PIPE_CONTROL_LOCAL_PGTT (0 << 2)
|
||||
|
||||
#define _3DPRIM_POINTLIST 0x01
|
||||
#define _3DPRIM_LINELIST 0x02
|
||||
#define _3DPRIM_LINESTRIP 0x03
|
||||
#define _3DPRIM_TRILIST 0x04
|
||||
#define _3DPRIM_TRISTRIP 0x05
|
||||
#define _3DPRIM_TRIFAN 0x06
|
||||
#define _3DPRIM_QUADLIST 0x07
|
||||
#define _3DPRIM_QUADSTRIP 0x08
|
||||
#define _3DPRIM_LINELIST_ADJ 0x09
|
||||
#define _3DPRIM_LINESTRIP_ADJ 0x0A
|
||||
#define _3DPRIM_TRILIST_ADJ 0x0B
|
||||
#define _3DPRIM_TRISTRIP_ADJ 0x0C
|
||||
#define _3DPRIM_TRISTRIP_REVERSE 0x0D
|
||||
#define _3DPRIM_POLYGON 0x0E
|
||||
#define _3DPRIM_RECTLIST 0x0F
|
||||
#define _3DPRIM_LINELOOP 0x10
|
||||
#define _3DPRIM_POINTLIST_BF 0x11
|
||||
#define _3DPRIM_LINESTRIP_CONT 0x12
|
||||
#define _3DPRIM_LINESTRIP_BF 0x13
|
||||
#define _3DPRIM_LINESTRIP_CONT_BF 0x14
|
||||
#define _3DPRIM_TRIFAN_NOSTIPPLE 0x15
|
||||
|
||||
#define _3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL 0
|
||||
#define _3DPRIM_VERTEXBUFFER_ACCESS_RANDOM 1
|
||||
|
||||
#define BRW_ANISORATIO_2 0
|
||||
#define BRW_ANISORATIO_4 1
|
||||
#define BRW_ANISORATIO_6 2
|
||||
#define BRW_ANISORATIO_8 3
|
||||
#define BRW_ANISORATIO_10 4
|
||||
#define BRW_ANISORATIO_12 5
|
||||
#define BRW_ANISORATIO_14 6
|
||||
#define BRW_ANISORATIO_16 7
|
||||
|
||||
#define BRW_BLENDFACTOR_ONE 0x1
|
||||
#define BRW_BLENDFACTOR_SRC_COLOR 0x2
|
||||
#define BRW_BLENDFACTOR_SRC_ALPHA 0x3
|
||||
#define BRW_BLENDFACTOR_DST_ALPHA 0x4
|
||||
#define BRW_BLENDFACTOR_DST_COLOR 0x5
|
||||
#define BRW_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6
|
||||
#define BRW_BLENDFACTOR_CONST_COLOR 0x7
|
||||
#define BRW_BLENDFACTOR_CONST_ALPHA 0x8
|
||||
#define BRW_BLENDFACTOR_SRC1_COLOR 0x9
|
||||
#define BRW_BLENDFACTOR_SRC1_ALPHA 0x0A
|
||||
#define BRW_BLENDFACTOR_ZERO 0x11
|
||||
#define BRW_BLENDFACTOR_INV_SRC_COLOR 0x12
|
||||
#define BRW_BLENDFACTOR_INV_SRC_ALPHA 0x13
|
||||
#define BRW_BLENDFACTOR_INV_DST_ALPHA 0x14
|
||||
#define BRW_BLENDFACTOR_INV_DST_COLOR 0x15
|
||||
#define BRW_BLENDFACTOR_INV_CONST_COLOR 0x17
|
||||
#define BRW_BLENDFACTOR_INV_CONST_ALPHA 0x18
|
||||
#define BRW_BLENDFACTOR_INV_SRC1_COLOR 0x19
|
||||
#define BRW_BLENDFACTOR_INV_SRC1_ALPHA 0x1A
|
||||
|
||||
#define BRW_BLENDFUNCTION_ADD 0
|
||||
#define BRW_BLENDFUNCTION_SUBTRACT 1
|
||||
#define BRW_BLENDFUNCTION_REVERSE_SUBTRACT 2
|
||||
#define BRW_BLENDFUNCTION_MIN 3
|
||||
#define BRW_BLENDFUNCTION_MAX 4
|
||||
|
||||
#define BRW_ALPHATEST_FORMAT_UNORM8 0
|
||||
#define BRW_ALPHATEST_FORMAT_FLOAT32 1
|
||||
|
||||
#define BRW_CHROMAKEY_KILL_ON_ANY_MATCH 0
|
||||
#define BRW_CHROMAKEY_REPLACE_BLACK 1
|
||||
|
||||
#define BRW_CLIP_API_OGL 0
|
||||
#define BRW_CLIP_API_DX 1
|
||||
|
||||
#define BRW_CLIPMODE_NORMAL 0
|
||||
#define BRW_CLIPMODE_CLIP_ALL 1
|
||||
#define BRW_CLIPMODE_CLIP_NON_REJECTED 2
|
||||
#define BRW_CLIPMODE_REJECT_ALL 3
|
||||
#define BRW_CLIPMODE_ACCEPT_ALL 4
|
||||
|
||||
#define BRW_CLIP_NDCSPACE 0
|
||||
#define BRW_CLIP_SCREENSPACE 1
|
||||
|
||||
#define BRW_COMPAREFUNCTION_ALWAYS 0
|
||||
#define BRW_COMPAREFUNCTION_NEVER 1
|
||||
#define BRW_COMPAREFUNCTION_LESS 2
|
||||
#define BRW_COMPAREFUNCTION_EQUAL 3
|
||||
#define BRW_COMPAREFUNCTION_LEQUAL 4
|
||||
#define BRW_COMPAREFUNCTION_GREATER 5
|
||||
#define BRW_COMPAREFUNCTION_NOTEQUAL 6
|
||||
#define BRW_COMPAREFUNCTION_GEQUAL 7
|
||||
|
||||
#define BRW_COVERAGE_PIXELS_HALF 0
|
||||
#define BRW_COVERAGE_PIXELS_1 1
|
||||
#define BRW_COVERAGE_PIXELS_2 2
|
||||
#define BRW_COVERAGE_PIXELS_4 3
|
||||
|
||||
#define BRW_CULLMODE_BOTH 0
|
||||
#define BRW_CULLMODE_NONE 1
|
||||
#define BRW_CULLMODE_FRONT 2
|
||||
#define BRW_CULLMODE_BACK 3
|
||||
|
||||
#define BRW_DEFAULTCOLOR_R8G8B8A8_UNORM 0
|
||||
#define BRW_DEFAULTCOLOR_R32G32B32A32_FLOAT 1
|
||||
|
||||
#define BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT 0
|
||||
#define BRW_DEPTHFORMAT_D32_FLOAT 1
|
||||
#define BRW_DEPTHFORMAT_D24_UNORM_S8_UINT 2
|
||||
#define BRW_DEPTHFORMAT_D16_UNORM 5
|
||||
|
||||
#define BRW_FLOATING_POINT_IEEE_754 0
|
||||
#define BRW_FLOATING_POINT_NON_IEEE_754 1
|
||||
|
||||
#define BRW_FRONTWINDING_CW 0
|
||||
#define BRW_FRONTWINDING_CCW 1
|
||||
|
||||
#define BRW_INDEX_BYTE 0
|
||||
#define BRW_INDEX_WORD 1
|
||||
#define BRW_INDEX_DWORD 2
|
||||
|
||||
#define BRW_LOGICOPFUNCTION_CLEAR 0
|
||||
#define BRW_LOGICOPFUNCTION_NOR 1
|
||||
#define BRW_LOGICOPFUNCTION_AND_INVERTED 2
|
||||
#define BRW_LOGICOPFUNCTION_COPY_INVERTED 3
|
||||
#define BRW_LOGICOPFUNCTION_AND_REVERSE 4
|
||||
#define BRW_LOGICOPFUNCTION_INVERT 5
|
||||
#define BRW_LOGICOPFUNCTION_XOR 6
|
||||
#define BRW_LOGICOPFUNCTION_NAND 7
|
||||
#define BRW_LOGICOPFUNCTION_AND 8
|
||||
#define BRW_LOGICOPFUNCTION_EQUIV 9
|
||||
#define BRW_LOGICOPFUNCTION_NOOP 10
|
||||
#define BRW_LOGICOPFUNCTION_OR_INVERTED 11
|
||||
#define BRW_LOGICOPFUNCTION_COPY 12
|
||||
#define BRW_LOGICOPFUNCTION_OR_REVERSE 13
|
||||
#define BRW_LOGICOPFUNCTION_OR 14
|
||||
#define BRW_LOGICOPFUNCTION_SET 15
|
||||
|
||||
#define BRW_MAPFILTER_NEAREST 0x0
|
||||
#define BRW_MAPFILTER_LINEAR 0x1
|
||||
#define BRW_MAPFILTER_ANISOTROPIC 0x2
|
||||
|
||||
#define BRW_MIPFILTER_NONE 0
|
||||
#define BRW_MIPFILTER_NEAREST 1
|
||||
#define BRW_MIPFILTER_LINEAR 3
|
||||
|
||||
#define BRW_POLYGON_FRONT_FACING 0
|
||||
#define BRW_POLYGON_BACK_FACING 1
|
||||
|
||||
#define BRW_PREFILTER_ALWAYS 0x0
|
||||
#define BRW_PREFILTER_NEVER 0x1
|
||||
#define BRW_PREFILTER_LESS 0x2
|
||||
#define BRW_PREFILTER_EQUAL 0x3
|
||||
#define BRW_PREFILTER_LEQUAL 0x4
|
||||
#define BRW_PREFILTER_GREATER 0x5
|
||||
#define BRW_PREFILTER_NOTEQUAL 0x6
|
||||
#define BRW_PREFILTER_GEQUAL 0x7
|
||||
|
||||
#define BRW_PROVOKING_VERTEX_0 0
|
||||
#define BRW_PROVOKING_VERTEX_1 1
|
||||
#define BRW_PROVOKING_VERTEX_2 2
|
||||
|
||||
#define BRW_RASTRULE_UPPER_LEFT 0
|
||||
#define BRW_RASTRULE_UPPER_RIGHT 1
|
||||
|
||||
#define BRW_RENDERTARGET_CLAMPRANGE_UNORM 0
|
||||
#define BRW_RENDERTARGET_CLAMPRANGE_SNORM 1
|
||||
#define BRW_RENDERTARGET_CLAMPRANGE_FORMAT 2
|
||||
|
||||
#define BRW_STENCILOP_KEEP 0
|
||||
#define BRW_STENCILOP_ZERO 1
|
||||
#define BRW_STENCILOP_REPLACE 2
|
||||
#define BRW_STENCILOP_INCRSAT 3
|
||||
#define BRW_STENCILOP_DECRSAT 4
|
||||
#define BRW_STENCILOP_INCR 5
|
||||
#define BRW_STENCILOP_DECR 6
|
||||
#define BRW_STENCILOP_INVERT 7
|
||||
|
||||
#define BRW_SURFACE_MIPMAPLAYOUT_BELOW 0
|
||||
#define BRW_SURFACE_MIPMAPLAYOUT_RIGHT 1
|
||||
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_FLOAT 0x000
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_SINT 0x001
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_UINT 0x002
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_UNORM 0x003
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_SNORM 0x004
|
||||
#define BRW_SURFACEFORMAT_R64G64_FLOAT 0x005
|
||||
#define BRW_SURFACEFORMAT_R32G32B32X32_FLOAT 0x006
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_SSCALED 0x007
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_USCALED 0x008
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_FLOAT 0x040
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_SINT 0x041
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_UINT 0x042
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_UNORM 0x043
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_SNORM 0x044
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_SSCALED 0x045
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_USCALED 0x046
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_UNORM 0x080
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_SNORM 0x081
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_SINT 0x082
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_UINT 0x083
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_FLOAT 0x084
|
||||
#define BRW_SURFACEFORMAT_R32G32_FLOAT 0x085
|
||||
#define BRW_SURFACEFORMAT_R32G32_SINT 0x086
|
||||
#define BRW_SURFACEFORMAT_R32G32_UINT 0x087
|
||||
#define BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS 0x088
|
||||
#define BRW_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT 0x089
|
||||
#define BRW_SURFACEFORMAT_L32A32_FLOAT 0x08A
|
||||
#define BRW_SURFACEFORMAT_R32G32_UNORM 0x08B
|
||||
#define BRW_SURFACEFORMAT_R32G32_SNORM 0x08C
|
||||
#define BRW_SURFACEFORMAT_R64_FLOAT 0x08D
|
||||
#define BRW_SURFACEFORMAT_R16G16B16X16_UNORM 0x08E
|
||||
#define BRW_SURFACEFORMAT_R16G16B16X16_FLOAT 0x08F
|
||||
#define BRW_SURFACEFORMAT_A32X32_FLOAT 0x090
|
||||
#define BRW_SURFACEFORMAT_L32X32_FLOAT 0x091
|
||||
#define BRW_SURFACEFORMAT_I32X32_FLOAT 0x092
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_SSCALED 0x093
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_USCALED 0x094
|
||||
#define BRW_SURFACEFORMAT_R32G32_SSCALED 0x095
|
||||
#define BRW_SURFACEFORMAT_R32G32_USCALED 0x096
|
||||
#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM 0x0C0
|
||||
#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB 0x0C1
|
||||
#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM 0x0C2
|
||||
#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB 0x0C3
|
||||
#define BRW_SURFACEFORMAT_R10G10B10A2_UINT 0x0C4
|
||||
#define BRW_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM 0x0C5
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM 0x0C7
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB 0x0C8
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_SNORM 0x0C9
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_SINT 0x0CA
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_UINT 0x0CB
|
||||
#define BRW_SURFACEFORMAT_R16G16_UNORM 0x0CC
|
||||
#define BRW_SURFACEFORMAT_R16G16_SNORM 0x0CD
|
||||
#define BRW_SURFACEFORMAT_R16G16_SINT 0x0CE
|
||||
#define BRW_SURFACEFORMAT_R16G16_UINT 0x0CF
|
||||
#define BRW_SURFACEFORMAT_R16G16_FLOAT 0x0D0
|
||||
#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM 0x0D1
|
||||
#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB 0x0D2
|
||||
#define BRW_SURFACEFORMAT_R11G11B10_FLOAT 0x0D3
|
||||
#define BRW_SURFACEFORMAT_R32_SINT 0x0D6
|
||||
#define BRW_SURFACEFORMAT_R32_UINT 0x0D7
|
||||
#define BRW_SURFACEFORMAT_R32_FLOAT 0x0D8
|
||||
#define BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS 0x0D9
|
||||
#define BRW_SURFACEFORMAT_X24_TYPELESS_G8_UINT 0x0DA
|
||||
#define BRW_SURFACEFORMAT_L16A16_UNORM 0x0DF
|
||||
#define BRW_SURFACEFORMAT_I24X8_UNORM 0x0E0
|
||||
#define BRW_SURFACEFORMAT_L24X8_UNORM 0x0E1
|
||||
#define BRW_SURFACEFORMAT_A24X8_UNORM 0x0E2
|
||||
#define BRW_SURFACEFORMAT_I32_FLOAT 0x0E3
|
||||
#define BRW_SURFACEFORMAT_L32_FLOAT 0x0E4
|
||||
#define BRW_SURFACEFORMAT_A32_FLOAT 0x0E5
|
||||
#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM 0x0E9
|
||||
#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB 0x0EA
|
||||
#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM 0x0EB
|
||||
#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB 0x0EC
|
||||
#define BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP 0x0ED
|
||||
#define BRW_SURFACEFORMAT_B10G10R10X2_UNORM 0x0EE
|
||||
#define BRW_SURFACEFORMAT_L16A16_FLOAT 0x0F0
|
||||
#define BRW_SURFACEFORMAT_R32_UNORM 0x0F1
|
||||
#define BRW_SURFACEFORMAT_R32_SNORM 0x0F2
|
||||
#define BRW_SURFACEFORMAT_R10G10B10X2_USCALED 0x0F3
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_SSCALED 0x0F4
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_USCALED 0x0F5
|
||||
#define BRW_SURFACEFORMAT_R16G16_SSCALED 0x0F6
|
||||
#define BRW_SURFACEFORMAT_R16G16_USCALED 0x0F7
|
||||
#define BRW_SURFACEFORMAT_R32_SSCALED 0x0F8
|
||||
#define BRW_SURFACEFORMAT_R32_USCALED 0x0F9
|
||||
#define BRW_SURFACEFORMAT_B5G6R5_UNORM 0x100
|
||||
#define BRW_SURFACEFORMAT_B5G6R5_UNORM_SRGB 0x101
|
||||
#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM 0x102
|
||||
#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB 0x103
|
||||
#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM 0x104
|
||||
#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB 0x105
|
||||
#define BRW_SURFACEFORMAT_R8G8_UNORM 0x106
|
||||
#define BRW_SURFACEFORMAT_R8G8_SNORM 0x107
|
||||
#define BRW_SURFACEFORMAT_R8G8_SINT 0x108
|
||||
#define BRW_SURFACEFORMAT_R8G8_UINT 0x109
|
||||
#define BRW_SURFACEFORMAT_R16_UNORM 0x10A
|
||||
#define BRW_SURFACEFORMAT_R16_SNORM 0x10B
|
||||
#define BRW_SURFACEFORMAT_R16_SINT 0x10C
|
||||
#define BRW_SURFACEFORMAT_R16_UINT 0x10D
|
||||
#define BRW_SURFACEFORMAT_R16_FLOAT 0x10E
|
||||
#define BRW_SURFACEFORMAT_I16_UNORM 0x111
|
||||
#define BRW_SURFACEFORMAT_L16_UNORM 0x112
|
||||
#define BRW_SURFACEFORMAT_A16_UNORM 0x113
|
||||
#define BRW_SURFACEFORMAT_L8A8_UNORM 0x114
|
||||
#define BRW_SURFACEFORMAT_I16_FLOAT 0x115
|
||||
#define BRW_SURFACEFORMAT_L16_FLOAT 0x116
|
||||
#define BRW_SURFACEFORMAT_A16_FLOAT 0x117
|
||||
#define BRW_SURFACEFORMAT_R5G5_SNORM_B6_UNORM 0x119
|
||||
#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM 0x11A
|
||||
#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB 0x11B
|
||||
#define BRW_SURFACEFORMAT_R8G8_SSCALED 0x11C
|
||||
#define BRW_SURFACEFORMAT_R8G8_USCALED 0x11D
|
||||
#define BRW_SURFACEFORMAT_R16_SSCALED 0x11E
|
||||
#define BRW_SURFACEFORMAT_R16_USCALED 0x11F
|
||||
#define BRW_SURFACEFORMAT_R8_UNORM 0x140
|
||||
#define BRW_SURFACEFORMAT_R8_SNORM 0x141
|
||||
#define BRW_SURFACEFORMAT_R8_SINT 0x142
|
||||
#define BRW_SURFACEFORMAT_R8_UINT 0x143
|
||||
#define BRW_SURFACEFORMAT_A8_UNORM 0x144
|
||||
#define BRW_SURFACEFORMAT_I8_UNORM 0x145
|
||||
#define BRW_SURFACEFORMAT_L8_UNORM 0x146
|
||||
#define BRW_SURFACEFORMAT_P4A4_UNORM 0x147
|
||||
#define BRW_SURFACEFORMAT_A4P4_UNORM 0x148
|
||||
#define BRW_SURFACEFORMAT_R8_SSCALED 0x149
|
||||
#define BRW_SURFACEFORMAT_R8_USCALED 0x14A
|
||||
#define BRW_SURFACEFORMAT_R1_UINT 0x181
|
||||
#define BRW_SURFACEFORMAT_YCRCB_NORMAL 0x182
|
||||
#define BRW_SURFACEFORMAT_YCRCB_SWAPUVY 0x183
|
||||
#define BRW_SURFACEFORMAT_BC1_UNORM 0x186
|
||||
#define BRW_SURFACEFORMAT_BC2_UNORM 0x187
|
||||
#define BRW_SURFACEFORMAT_BC3_UNORM 0x188
|
||||
#define BRW_SURFACEFORMAT_BC4_UNORM 0x189
|
||||
#define BRW_SURFACEFORMAT_BC5_UNORM 0x18A
|
||||
#define BRW_SURFACEFORMAT_BC1_UNORM_SRGB 0x18B
|
||||
#define BRW_SURFACEFORMAT_BC2_UNORM_SRGB 0x18C
|
||||
#define BRW_SURFACEFORMAT_BC3_UNORM_SRGB 0x18D
|
||||
#define BRW_SURFACEFORMAT_MONO8 0x18E
|
||||
#define BRW_SURFACEFORMAT_YCRCB_SWAPUV 0x18F
|
||||
#define BRW_SURFACEFORMAT_YCRCB_SWAPY 0x190
|
||||
#define BRW_SURFACEFORMAT_DXT1_RGB 0x191
|
||||
#define BRW_SURFACEFORMAT_FXT1 0x192
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_UNORM 0x193
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_SNORM 0x194
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_SSCALED 0x195
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_USCALED 0x196
|
||||
#define BRW_SURFACEFORMAT_R64G64B64A64_FLOAT 0x197
|
||||
#define BRW_SURFACEFORMAT_R64G64B64_FLOAT 0x198
|
||||
#define BRW_SURFACEFORMAT_BC4_SNORM 0x199
|
||||
#define BRW_SURFACEFORMAT_BC5_SNORM 0x19A
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_UNORM 0x19C
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_SNORM 0x19D
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_SSCALED 0x19E
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_USCALED 0x19F
|
||||
|
||||
#define BRW_SURFACERETURNFORMAT_FLOAT32 0
|
||||
#define BRW_SURFACERETURNFORMAT_S1 1
|
||||
|
||||
#define BRW_SURFACE_1D 0
|
||||
#define BRW_SURFACE_2D 1
|
||||
#define BRW_SURFACE_3D 2
|
||||
#define BRW_SURFACE_CUBE 3
|
||||
#define BRW_SURFACE_BUFFER 4
|
||||
#define BRW_SURFACE_NULL 7
|
||||
|
||||
#define BRW_BORDER_COLOR_MODE_DEFAULT 0
|
||||
#define BRW_BORDER_COLOR_MODE_LEGACY 1
|
||||
|
||||
#define BRW_TEXCOORDMODE_WRAP 0
|
||||
#define BRW_TEXCOORDMODE_MIRROR 1
|
||||
#define BRW_TEXCOORDMODE_CLAMP 2
|
||||
#define BRW_TEXCOORDMODE_CUBE 3
|
||||
#define BRW_TEXCOORDMODE_CLAMP_BORDER 4
|
||||
#define BRW_TEXCOORDMODE_MIRROR_ONCE 5
|
||||
|
||||
#define BRW_THREAD_PRIORITY_NORMAL 0
|
||||
#define BRW_THREAD_PRIORITY_HIGH 1
|
||||
|
||||
#define BRW_TILEWALK_XMAJOR 0
|
||||
#define BRW_TILEWALK_YMAJOR 1
|
||||
|
||||
#define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS 0
|
||||
#define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS 1
|
||||
|
||||
#define BRW_VERTEXBUFFER_ACCESS_VERTEXDATA 0
|
||||
#define BRW_VERTEXBUFFER_ACCESS_INSTANCEDATA 1
|
||||
|
||||
#define BRW_VFCOMPONENT_NOSTORE 0
|
||||
#define BRW_VFCOMPONENT_STORE_SRC 1
|
||||
#define BRW_VFCOMPONENT_STORE_0 2
|
||||
#define BRW_VFCOMPONENT_STORE_1_FLT 3
|
||||
#define BRW_VFCOMPONENT_STORE_1_INT 4
|
||||
#define BRW_VFCOMPONENT_STORE_VID 5
|
||||
#define BRW_VFCOMPONENT_STORE_IID 6
|
||||
#define BRW_VFCOMPONENT_STORE_PID 7
|
||||
|
||||
|
||||
|
||||
/* Execution Unit (EU) defines */
|
||||
|
||||
#define BRW_ALIGN_1 0
|
||||
#define BRW_ALIGN_16 1
|
||||
|
||||
#define BRW_ADDRESS_DIRECT 0
|
||||
#define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER 1
|
||||
|
||||
#define BRW_CHANNEL_X 0
|
||||
#define BRW_CHANNEL_Y 1
|
||||
#define BRW_CHANNEL_Z 2
|
||||
#define BRW_CHANNEL_W 3
|
||||
|
||||
#define BRW_COMPRESSION_NONE 0
|
||||
#define BRW_COMPRESSION_2NDHALF 1
|
||||
#define BRW_COMPRESSION_COMPRESSED 2
|
||||
|
||||
#define BRW_CONDITIONAL_NONE 0
|
||||
#define BRW_CONDITIONAL_Z 1
|
||||
#define BRW_CONDITIONAL_NZ 2
|
||||
#define BRW_CONDITIONAL_EQ 1 /* Z */
|
||||
#define BRW_CONDITIONAL_NEQ 2 /* NZ */
|
||||
#define BRW_CONDITIONAL_G 3
|
||||
#define BRW_CONDITIONAL_GE 4
|
||||
#define BRW_CONDITIONAL_L 5
|
||||
#define BRW_CONDITIONAL_LE 6
|
||||
#define BRW_CONDITIONAL_C 7
|
||||
#define BRW_CONDITIONAL_O 8
|
||||
|
||||
#define BRW_DEBUG_NONE 0
|
||||
#define BRW_DEBUG_BREAKPOINT 1
|
||||
|
||||
#define BRW_DEPENDENCY_NORMAL 0
|
||||
#define BRW_DEPENDENCY_NOTCLEARED 1
|
||||
#define BRW_DEPENDENCY_NOTCHECKED 2
|
||||
#define BRW_DEPENDENCY_DISABLE 3
|
||||
|
||||
#define BRW_EXECUTE_1 0
|
||||
#define BRW_EXECUTE_2 1
|
||||
#define BRW_EXECUTE_4 2
|
||||
#define BRW_EXECUTE_8 3
|
||||
#define BRW_EXECUTE_16 4
|
||||
#define BRW_EXECUTE_32 5
|
||||
|
||||
#define BRW_HORIZONTAL_STRIDE_0 0
|
||||
#define BRW_HORIZONTAL_STRIDE_1 1
|
||||
#define BRW_HORIZONTAL_STRIDE_2 2
|
||||
#define BRW_HORIZONTAL_STRIDE_4 3
|
||||
|
||||
#define BRW_INSTRUCTION_NORMAL 0
|
||||
#define BRW_INSTRUCTION_SATURATE 1
|
||||
|
||||
#define BRW_MASK_ENABLE 0
|
||||
#define BRW_MASK_DISABLE 1
|
||||
|
||||
#define BRW_OPCODE_MOV 1
|
||||
#define BRW_OPCODE_SEL 2
|
||||
#define BRW_OPCODE_NOT 4
|
||||
#define BRW_OPCODE_AND 5
|
||||
#define BRW_OPCODE_OR 6
|
||||
#define BRW_OPCODE_XOR 7
|
||||
#define BRW_OPCODE_SHR 8
|
||||
#define BRW_OPCODE_SHL 9
|
||||
#define BRW_OPCODE_RSR 10
|
||||
#define BRW_OPCODE_RSL 11
|
||||
#define BRW_OPCODE_ASR 12
|
||||
#define BRW_OPCODE_CMP 16
|
||||
#define BRW_OPCODE_JMPI 32
|
||||
#define BRW_OPCODE_IF 34
|
||||
#define BRW_OPCODE_IFF 35
|
||||
#define BRW_OPCODE_ELSE 36
|
||||
#define BRW_OPCODE_ENDIF 37
|
||||
#define BRW_OPCODE_DO 38
|
||||
#define BRW_OPCODE_WHILE 39
|
||||
#define BRW_OPCODE_BREAK 40
|
||||
#define BRW_OPCODE_CONTINUE 41
|
||||
#define BRW_OPCODE_HALT 42
|
||||
#define BRW_OPCODE_MSAVE 44
|
||||
#define BRW_OPCODE_MRESTORE 45
|
||||
#define BRW_OPCODE_PUSH 46
|
||||
#define BRW_OPCODE_POP 47
|
||||
#define BRW_OPCODE_WAIT 48
|
||||
#define BRW_OPCODE_SEND 49
|
||||
#define BRW_OPCODE_ADD 64
|
||||
#define BRW_OPCODE_MUL 65
|
||||
#define BRW_OPCODE_AVG 66
|
||||
#define BRW_OPCODE_FRC 67
|
||||
#define BRW_OPCODE_RNDU 68
|
||||
#define BRW_OPCODE_RNDD 69
|
||||
#define BRW_OPCODE_RNDE 70
|
||||
#define BRW_OPCODE_RNDZ 71
|
||||
#define BRW_OPCODE_MAC 72
|
||||
#define BRW_OPCODE_MACH 73
|
||||
#define BRW_OPCODE_LZD 74
|
||||
#define BRW_OPCODE_SAD2 80
|
||||
#define BRW_OPCODE_SADA2 81
|
||||
#define BRW_OPCODE_DP4 84
|
||||
#define BRW_OPCODE_DPH 85
|
||||
#define BRW_OPCODE_DP3 86
|
||||
#define BRW_OPCODE_DP2 87
|
||||
#define BRW_OPCODE_DPA2 88
|
||||
#define BRW_OPCODE_LINE 89
|
||||
#define BRW_OPCODE_NOP 126
|
||||
|
||||
#define BRW_PREDICATE_NONE 0
|
||||
#define BRW_PREDICATE_NORMAL 1
|
||||
#define BRW_PREDICATE_ALIGN1_ANYV 2
|
||||
#define BRW_PREDICATE_ALIGN1_ALLV 3
|
||||
#define BRW_PREDICATE_ALIGN1_ANY2H 4
|
||||
#define BRW_PREDICATE_ALIGN1_ALL2H 5
|
||||
#define BRW_PREDICATE_ALIGN1_ANY4H 6
|
||||
#define BRW_PREDICATE_ALIGN1_ALL4H 7
|
||||
#define BRW_PREDICATE_ALIGN1_ANY8H 8
|
||||
#define BRW_PREDICATE_ALIGN1_ALL8H 9
|
||||
#define BRW_PREDICATE_ALIGN1_ANY16H 10
|
||||
#define BRW_PREDICATE_ALIGN1_ALL16H 11
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_X 2
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_Y 3
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_Z 4
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_W 5
|
||||
#define BRW_PREDICATE_ALIGN16_ANY4H 6
|
||||
#define BRW_PREDICATE_ALIGN16_ALL4H 7
|
||||
|
||||
#define BRW_ARCHITECTURE_REGISTER_FILE 0
|
||||
#define BRW_GENERAL_REGISTER_FILE 1
|
||||
#define BRW_MESSAGE_REGISTER_FILE 2
|
||||
#define BRW_IMMEDIATE_VALUE 3
|
||||
|
||||
#define BRW_REGISTER_TYPE_UD 0
|
||||
#define BRW_REGISTER_TYPE_D 1
|
||||
#define BRW_REGISTER_TYPE_UW 2
|
||||
#define BRW_REGISTER_TYPE_W 3
|
||||
#define BRW_REGISTER_TYPE_UB 4
|
||||
#define BRW_REGISTER_TYPE_B 5
|
||||
#define BRW_REGISTER_TYPE_VF 5 /* packed float vector, immediates only? */
|
||||
#define BRW_REGISTER_TYPE_HF 6
|
||||
#define BRW_REGISTER_TYPE_V 6 /* packed int vector, immediates only, uword dest only */
|
||||
#define BRW_REGISTER_TYPE_F 7
|
||||
|
||||
#define BRW_ARF_NULL 0x00
|
||||
#define BRW_ARF_ADDRESS 0x10
|
||||
#define BRW_ARF_ACCUMULATOR 0x20
|
||||
#define BRW_ARF_FLAG 0x30
|
||||
#define BRW_ARF_MASK 0x40
|
||||
#define BRW_ARF_MASK_STACK 0x50
|
||||
#define BRW_ARF_MASK_STACK_DEPTH 0x60
|
||||
#define BRW_ARF_STATE 0x70
|
||||
#define BRW_ARF_CONTROL 0x80
|
||||
#define BRW_ARF_NOTIFICATION_COUNT 0x90
|
||||
#define BRW_ARF_IP 0xA0
|
||||
|
||||
#define BRW_AMASK 0
|
||||
#define BRW_IMASK 1
|
||||
#define BRW_LMASK 2
|
||||
#define BRW_CMASK 3
|
||||
|
||||
|
||||
|
||||
#define BRW_THREAD_NORMAL 0
|
||||
#define BRW_THREAD_ATOMIC 1
|
||||
#define BRW_THREAD_SWITCH 2
|
||||
|
||||
#define BRW_VERTICAL_STRIDE_0 0
|
||||
#define BRW_VERTICAL_STRIDE_1 1
|
||||
#define BRW_VERTICAL_STRIDE_2 2
|
||||
#define BRW_VERTICAL_STRIDE_4 3
|
||||
#define BRW_VERTICAL_STRIDE_8 4
|
||||
#define BRW_VERTICAL_STRIDE_16 5
|
||||
#define BRW_VERTICAL_STRIDE_32 6
|
||||
#define BRW_VERTICAL_STRIDE_64 7
|
||||
#define BRW_VERTICAL_STRIDE_128 8
|
||||
#define BRW_VERTICAL_STRIDE_256 9
|
||||
#define BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL 0xF
|
||||
|
||||
#define BRW_WIDTH_1 0
|
||||
#define BRW_WIDTH_2 1
|
||||
#define BRW_WIDTH_4 2
|
||||
#define BRW_WIDTH_8 3
|
||||
#define BRW_WIDTH_16 4
|
||||
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_1K 0
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_2K 1
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_4K 2
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_8K 3
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_16K 4
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_32K 5
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_64K 6
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_128K 7
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_256K 8
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_512K 9
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_1M 10
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_2M 11
|
||||
|
||||
#define BRW_POLYGON_FACING_FRONT 0
|
||||
#define BRW_POLYGON_FACING_BACK 1
|
||||
|
||||
#define BRW_MESSAGE_TARGET_NULL 0
|
||||
#define BRW_MESSAGE_TARGET_MATH 1
|
||||
#define BRW_MESSAGE_TARGET_SAMPLER 2
|
||||
#define BRW_MESSAGE_TARGET_GATEWAY 3
|
||||
#define BRW_MESSAGE_TARGET_DATAPORT_READ 4
|
||||
#define BRW_MESSAGE_TARGET_DATAPORT_WRITE 5
|
||||
#define BRW_MESSAGE_TARGET_URB 6
|
||||
#define BRW_MESSAGE_TARGET_THREAD_SPAWNER 7
|
||||
|
||||
#define BRW_SAMPLER_RETURN_FORMAT_FLOAT32 0
|
||||
#define BRW_SAMPLER_RETURN_FORMAT_UINT32 2
|
||||
#define BRW_SAMPLER_RETURN_FORMAT_SINT32 3
|
||||
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX 1
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD 1
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD 1
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_RESINFO 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_LD 3
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_LD 3
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_LD 3
|
||||
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW 0
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH 1
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS 2
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS 3
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS 4
|
||||
|
||||
#define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD 0
|
||||
#define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS 2
|
||||
|
||||
#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS 2
|
||||
#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS 3
|
||||
|
||||
#define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ 0
|
||||
#define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 1
|
||||
#define BRW_DATAPORT_READ_MESSAGE_DWORD_BLOCK_READ 2
|
||||
#define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 3
|
||||
|
||||
#define BRW_DATAPORT_READ_TARGET_DATA_CACHE 0
|
||||
#define BRW_DATAPORT_READ_TARGET_RENDER_CACHE 1
|
||||
#define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE 2
|
||||
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE 0
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED 1
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01 2
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23 3
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01 4
|
||||
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 0
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 1
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_BLOCK_WRITE 2
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 3
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 4
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE 5
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE 7
|
||||
|
||||
#define BRW_MATH_FUNCTION_INV 1
|
||||
#define BRW_MATH_FUNCTION_LOG 2
|
||||
#define BRW_MATH_FUNCTION_EXP 3
|
||||
#define BRW_MATH_FUNCTION_SQRT 4
|
||||
#define BRW_MATH_FUNCTION_RSQ 5
|
||||
#define BRW_MATH_FUNCTION_SIN 6 /* was 7 */
|
||||
#define BRW_MATH_FUNCTION_COS 7 /* was 8 */
|
||||
#define BRW_MATH_FUNCTION_SINCOS 8 /* was 6 */
|
||||
#define BRW_MATH_FUNCTION_TAN 9
|
||||
#define BRW_MATH_FUNCTION_POW 10
|
||||
#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER 11
|
||||
#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT 12
|
||||
#define BRW_MATH_FUNCTION_INT_DIV_REMAINDER 13
|
||||
|
||||
#define BRW_MATH_INTEGER_UNSIGNED 0
|
||||
#define BRW_MATH_INTEGER_SIGNED 1
|
||||
|
||||
#define BRW_MATH_PRECISION_FULL 0
|
||||
#define BRW_MATH_PRECISION_PARTIAL 1
|
||||
|
||||
#define BRW_MATH_SATURATE_NONE 0
|
||||
#define BRW_MATH_SATURATE_SATURATE 1
|
||||
|
||||
#define BRW_MATH_DATA_VECTOR 0
|
||||
#define BRW_MATH_DATA_SCALAR 1
|
||||
|
||||
#define BRW_URB_OPCODE_WRITE 0
|
||||
|
||||
#define BRW_URB_SWIZZLE_NONE 0
|
||||
#define BRW_URB_SWIZZLE_INTERLEAVE 1
|
||||
#define BRW_URB_SWIZZLE_TRANSPOSE 2
|
||||
|
||||
#define BRW_SCRATCH_SPACE_SIZE_1K 0
|
||||
#define BRW_SCRATCH_SPACE_SIZE_2K 1
|
||||
#define BRW_SCRATCH_SPACE_SIZE_4K 2
|
||||
#define BRW_SCRATCH_SPACE_SIZE_8K 3
|
||||
#define BRW_SCRATCH_SPACE_SIZE_16K 4
|
||||
#define BRW_SCRATCH_SPACE_SIZE_32K 5
|
||||
#define BRW_SCRATCH_SPACE_SIZE_64K 6
|
||||
#define BRW_SCRATCH_SPACE_SIZE_128K 7
|
||||
#define BRW_SCRATCH_SPACE_SIZE_256K 8
|
||||
#define BRW_SCRATCH_SPACE_SIZE_512K 9
|
||||
#define BRW_SCRATCH_SPACE_SIZE_1M 10
|
||||
#define BRW_SCRATCH_SPACE_SIZE_2M 11
|
||||
|
||||
|
||||
|
||||
|
||||
#define CMD_URB_FENCE 0x6000
|
||||
#define CMD_CONST_BUFFER_STATE 0x6001
|
||||
#define CMD_CONST_BUFFER 0x6002
|
||||
|
||||
#define CMD_STATE_BASE_ADDRESS 0x6101
|
||||
#define CMD_STATE_INSN_POINTER 0x6102
|
||||
#define CMD_PIPELINE_SELECT 0x6104
|
||||
|
||||
#define CMD_PIPELINED_STATE_POINTERS 0x7800
|
||||
#define CMD_BINDING_TABLE_PTRS 0x7801
|
||||
#define CMD_VERTEX_BUFFER 0x7808
|
||||
#define CMD_VERTEX_ELEMENT 0x7809
|
||||
#define CMD_INDEX_BUFFER 0x780a
|
||||
#define CMD_VF_STATISTICS 0x780b
|
||||
|
||||
#define CMD_DRAW_RECT 0x7900
|
||||
#define CMD_BLEND_CONSTANT_COLOR 0x7901
|
||||
#define CMD_CHROMA_KEY 0x7904
|
||||
#define CMD_DEPTH_BUFFER 0x7905
|
||||
#define CMD_POLY_STIPPLE_OFFSET 0x7906
|
||||
#define CMD_POLY_STIPPLE_PATTERN 0x7907
|
||||
#define CMD_LINE_STIPPLE_PATTERN 0x7908
|
||||
#define CMD_GLOBAL_DEPTH_OFFSET_CLAMP 0x7908
|
||||
|
||||
#define CMD_PIPE_CONTROL 0x7a00
|
||||
|
||||
#define CMD_3D_PRIM 0x7b00
|
||||
|
||||
#define CMD_MI_FLUSH 0x0200
|
||||
|
||||
|
||||
/* Various values from the R0 vertex header:
|
||||
*/
|
||||
#define R02_PRIM_END 0x1
|
||||
#define R02_PRIM_START 0x2
|
||||
|
||||
/* media pipeline */
|
||||
|
||||
#define BRW_VFE_MODE_GENERIC 0x0
|
||||
#define BRW_VFE_MODE_VLD_MPEG2 0x1
|
||||
#define BRW_VFE_MODE_IS 0x2
|
||||
#define BRW_VFE_MODE_AVC_MC 0x4
|
||||
#define BRW_VFE_MODE_AVC_IT 0x7
|
||||
#define BRW_VFE_MODE_VC1_IT 0xB
|
||||
|
||||
#define BRW_VFE_DEBUG_COUNTER_FREE 0
|
||||
#define BRW_VFE_DEBUG_COUNTER_FROZEN 1
|
||||
#define BRW_VFE_DEBUG_COUNTER_ONCE 2
|
||||
#define BRW_VFE_DEBUG_COUNTER_ALWAYS 3
|
||||
|
||||
/* VLD_STATE */
|
||||
#define BRW_MPEG_TOP_FIELD 1
|
||||
#define BRW_MPEG_BOTTOM_FIELD 2
|
||||
#define BRW_MPEG_FRAME 3
|
||||
#define BRW_MPEG_QSCALE_LINEAR 0
|
||||
#define BRW_MPEG_QSCALE_NONLINEAR 1
|
||||
#define BRW_MPEG_ZIGZAG_SCAN 0
|
||||
#define BRW_MPEG_ALTER_VERTICAL_SCAN 1
|
||||
#define BRW_MPEG_I_PICTURE 1
|
||||
#define BRW_MPEG_P_PICTURE 2
|
||||
#define BRW_MPEG_B_PICTURE 3
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
Copyright (C) Intel Corp. 2006. All Rights Reserved.
|
||||
Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
|
||||
develop this 3D driver.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the
|
||||
next paragraph) shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-drm-intel-brw-eu.h"
|
||||
|
||||
|
||||
void brw_math_invert( struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_reg src)
|
||||
{
|
||||
brw_math( p,
|
||||
dst,
|
||||
BRW_MATH_FUNCTION_INV,
|
||||
BRW_MATH_SATURATE_NONE,
|
||||
0,
|
||||
src,
|
||||
BRW_MATH_PRECISION_FULL,
|
||||
BRW_MATH_DATA_VECTOR );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void brw_copy4(struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_reg src,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
dst = vec4(dst);
|
||||
src = vec4(src);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
|
||||
brw_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brw_copy8(struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_reg src,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
dst = vec8(dst);
|
||||
src = vec8(src);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brw_copy_indirect_to_indirect(struct brw_compile *p,
|
||||
struct brw_indirect dst_ptr,
|
||||
struct brw_indirect src_ptr,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, deref_4f(dst_ptr, delta), deref_4f(src_ptr, delta));
|
||||
brw_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brw_copy_from_indirect(struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_indirect ptr,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
dst = vec4(dst);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, byte_offset(dst, delta), deref_4f(ptr, delta));
|
||||
brw_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,250 +0,0 @@
|
|||
/*
|
||||
Copyright (C) Intel Corp. 2006. All Rights Reserved.
|
||||
Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
|
||||
develop this 3D driver.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the
|
||||
next paragraph) shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-drm-intel-brw-eu.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* How does predicate control work when execution_size != 8? Do I
|
||||
* need to test/set for 0xffff when execution_size is 16?
|
||||
*/
|
||||
void brw_set_predicate_control_flag_value( struct brw_compile *p, uint32_t value )
|
||||
{
|
||||
p->current->header.predicate_control = BRW_PREDICATE_NONE;
|
||||
|
||||
if (value != 0xff) {
|
||||
if (value != p->flag_value) {
|
||||
brw_push_insn_state(p);
|
||||
brw_MOV(p, brw_flag_reg(), brw_imm_uw(value));
|
||||
p->flag_value = value;
|
||||
brw_pop_insn_state(p);
|
||||
}
|
||||
|
||||
p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
void brw_set_predicate_control( struct brw_compile *p, uint32_t pc )
|
||||
{
|
||||
p->current->header.predicate_control = pc;
|
||||
}
|
||||
|
||||
void brw_set_conditionalmod( struct brw_compile *p, uint32_t conditional )
|
||||
{
|
||||
p->current->header.destreg__conditonalmod = conditional;
|
||||
}
|
||||
|
||||
void brw_set_access_mode( struct brw_compile *p, uint32_t access_mode )
|
||||
{
|
||||
p->current->header.access_mode = access_mode;
|
||||
}
|
||||
|
||||
void brw_set_compression_control( struct brw_compile *p, int compression_control )
|
||||
{
|
||||
p->current->header.compression_control = compression_control;
|
||||
}
|
||||
|
||||
void brw_set_mask_control( struct brw_compile *p, uint32_t value )
|
||||
{
|
||||
p->current->header.mask_control = value;
|
||||
}
|
||||
|
||||
void brw_set_saturate( struct brw_compile *p, uint32_t value )
|
||||
{
|
||||
p->current->header.saturate = value;
|
||||
}
|
||||
|
||||
void brw_push_insn_state( struct brw_compile *p )
|
||||
{
|
||||
assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
|
||||
memcpy(p->current+1, p->current, sizeof(struct brw_instruction));
|
||||
p->current++;
|
||||
}
|
||||
|
||||
void brw_pop_insn_state( struct brw_compile *p )
|
||||
{
|
||||
assert(p->current != p->stack);
|
||||
p->current--;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
void
|
||||
brw_compile_init (struct brw_compile *p,
|
||||
cairo_bool_t is_g4x)
|
||||
{
|
||||
p->nr_insn = 0;
|
||||
p->current = p->stack;
|
||||
memset (p->current, 0, sizeof (p->current[0]));
|
||||
|
||||
p->is_g4x = is_g4x;
|
||||
|
||||
/* Some defaults? */
|
||||
brw_set_mask_control (p, BRW_MASK_ENABLE); /* what does this do? */
|
||||
brw_set_saturate (p, 0);
|
||||
brw_set_compression_control (p, BRW_COMPRESSION_NONE);
|
||||
brw_set_predicate_control_flag_value (p, 0xff);
|
||||
}
|
||||
|
||||
const uint32_t *
|
||||
brw_get_program (struct brw_compile *p,
|
||||
uint32_t *sz)
|
||||
{
|
||||
*sz = p->nr_insn * sizeof (struct brw_instruction);
|
||||
return (const uint32_t *)p->store;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Subroutine calls require special attention.
|
||||
* Mesa instructions may be expanded into multiple hardware instructions
|
||||
* so the prog_instruction::BranchTarget field can't be used as an index
|
||||
* into the hardware instructions.
|
||||
*
|
||||
* The BranchTarget field isn't needed, however. Mesa's GLSL compiler
|
||||
* emits CAL and BGNSUB instructions with labels that can be used to map
|
||||
* subroutine calls to actual subroutine code blocks.
|
||||
*
|
||||
* The structures and function here implement patching of CAL instructions
|
||||
* so they jump to the right subroutine code...
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* For each OPCODE_BGNSUB we create one of these.
|
||||
*/
|
||||
struct brw_glsl_label
|
||||
{
|
||||
const char *name; /*< the label string */
|
||||
uint32_t position; /*< the position of the brw instruction for this label */
|
||||
struct brw_glsl_label *next; /*< next in linked list */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* For each OPCODE_CAL we create one of these.
|
||||
*/
|
||||
struct brw_glsl_call
|
||||
{
|
||||
uint32_t call_inst_pos; /*< location of the CAL instruction */
|
||||
const char *sub_name; /*< name of subroutine to call */
|
||||
struct brw_glsl_call *next; /*< next in linked list */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Called for each OPCODE_BGNSUB.
|
||||
*/
|
||||
void
|
||||
brw_save_label(struct brw_compile *c, const char *name, uint32_t position)
|
||||
{
|
||||
struct brw_glsl_label *label = calloc(1, sizeof *label);
|
||||
label->name = name;
|
||||
label->position = position;
|
||||
label->next = c->first_label;
|
||||
c->first_label = label;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called for each OPCODE_CAL.
|
||||
*/
|
||||
void
|
||||
brw_save_call(struct brw_compile *c, const char *name, uint32_t call_pos)
|
||||
{
|
||||
struct brw_glsl_call *call = calloc(1, sizeof *call);
|
||||
call->call_inst_pos = call_pos;
|
||||
call->sub_name = name;
|
||||
call->next = c->first_call;
|
||||
c->first_call = call;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lookup a label, return label's position/offset.
|
||||
*/
|
||||
static uint32_t
|
||||
brw_lookup_label(struct brw_compile *c, const char *name)
|
||||
{
|
||||
const struct brw_glsl_label *label;
|
||||
for (label = c->first_label; label; label = label->next) {
|
||||
if (strcmp(name, label->name) == 0) {
|
||||
return label->position;
|
||||
}
|
||||
}
|
||||
abort(); /* should never happen */
|
||||
return ~0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When we're done generating code, this function is called to resolve
|
||||
* subroutine calls.
|
||||
*/
|
||||
void
|
||||
brw_resolve_cals(struct brw_compile *c)
|
||||
{
|
||||
const struct brw_glsl_call *call;
|
||||
|
||||
for (call = c->first_call; call; call = call->next) {
|
||||
const uint32_t sub_loc = brw_lookup_label(c, call->sub_name);
|
||||
struct brw_instruction *brw_call_inst = &c->store[call->call_inst_pos];
|
||||
struct brw_instruction *brw_sub_inst = &c->store[sub_loc];
|
||||
int32_t offset = brw_sub_inst - brw_call_inst;
|
||||
|
||||
/* patch brw_inst1 to point to brw_inst2 */
|
||||
brw_set_src1(brw_call_inst, brw_imm_d(offset * 16));
|
||||
}
|
||||
|
||||
/* free linked list of calls */
|
||||
{
|
||||
struct brw_glsl_call *call, *next;
|
||||
for (call = c->first_call; call; call = next) {
|
||||
next = call->next;
|
||||
free(call);
|
||||
}
|
||||
c->first_call = NULL;
|
||||
}
|
||||
|
||||
/* free linked list of labels */
|
||||
{
|
||||
struct brw_glsl_label *label, *next;
|
||||
for (label = c->first_label; label; label = next) {
|
||||
next = label->next;
|
||||
free(label);
|
||||
}
|
||||
c->first_label = NULL;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,909 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_COMMAND_PRIVATE_H
|
||||
#define CAIRO_DRM_INTEL_COMMAND_PRIVATE_H
|
||||
|
||||
#include "cairo-types-private.h"
|
||||
|
||||
#define CMD_MI (0x0 << 29)
|
||||
#define CMD_misc (0x1 << 29)
|
||||
#define CMD_2D (0x2 << 29)
|
||||
#define CMD_3D (0x3 << 29)
|
||||
/* 4-7 reserved */
|
||||
|
||||
#define MI_NOOP (CMD_MI | 0)
|
||||
/* Batch */
|
||||
#define MI_BATCH_BUFFER (CMD_MI | (0x30 << 23) | 1)
|
||||
#define MI_BATCH_BUFFER_START (CMD_MI | (0x31 << 23))
|
||||
#define MI_BATCH_BUFFER_END (CMD_MI | (0x0a << 23))
|
||||
#define MI_BATCH_NON_SECURE (1)
|
||||
#define MI_BATCH_NON_SECURE_I965 (1 << 8)
|
||||
/* Flush */
|
||||
#define MI_FLUSH (CMD_MI | (0x04 << 23))
|
||||
#define MI_WRITE_DIRTY_STATE (1<<4)
|
||||
#define MI_END_SCENE (1<<3)
|
||||
#define MI_GLOBAL_SNAPSHOT_COUNT_RESET (1<<3)
|
||||
#define MI_INHIBIT_RENDER_CACHE_FLUSH (1<<2)
|
||||
#define MI_STATE_INSTRUCTION_CACHE_FLUSH (1<<1)
|
||||
#define MI_INVALIDATE_MAP_CACHE (1<<0)
|
||||
|
||||
#define PRIM3D (CMD_3D | (0x1f<<24))
|
||||
#define PRIM3D_TRILIST (PRIM3D | (0x0<<18))
|
||||
#define PRIM3D_TRISTRIP (PRIM3D | (0x1<<18))
|
||||
#define PRIM3D_TRISTRIP_RVRSE (PRIM3D | (0x2<<18))
|
||||
#define PRIM3D_TRIFAN (PRIM3D | (0x3<<18))
|
||||
#define PRIM3D_POLY (PRIM3D | (0x4<<18))
|
||||
#define PRIM3D_LINELIST (PRIM3D | (0x5<<18))
|
||||
#define PRIM3D_LINESTRIP (PRIM3D | (0x6<<18))
|
||||
#define PRIM3D_RECTLIST (PRIM3D | (0x7<<18))
|
||||
#define PRIM3D_POINTLIST (PRIM3D | (0x8<<18))
|
||||
#define PRIM3D_DIB (PRIM3D | (0x9<<18))
|
||||
#define PRIM3D_CLEAR_RECT (PRIM3D | (0xa<<18))
|
||||
#define PRIM3D_ZONE_INIT (PRIM3D | (0xd<<18))
|
||||
#define PRIM3D_MASK (0x1f<<18)
|
||||
#define PRIM3D_INDIRECT_SEQUENTIAL ((1<<23) | (0<<17))
|
||||
#define PRIM3D_INDIRECT_ELTS ((1<<23) | (1<<17))
|
||||
|
||||
/* p137 */
|
||||
#define _3DSTATE_AA_CMD (CMD_3D | (0x06<<24))
|
||||
#define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16)
|
||||
#define AA_LINE_ECAAR_WIDTH_0_5 0
|
||||
#define AA_LINE_ECAAR_WIDTH_1_0 (1<<14)
|
||||
#define AA_LINE_ECAAR_WIDTH_2_0 (2<<14)
|
||||
#define AA_LINE_ECAAR_WIDTH_4_0 (3<<14)
|
||||
#define AA_LINE_REGION_WIDTH_ENABLE (1<<8)
|
||||
#define AA_LINE_REGION_WIDTH_0_5 0
|
||||
#define AA_LINE_REGION_WIDTH_1_0 (1<<6)
|
||||
#define AA_LINE_REGION_WIDTH_2_0 (2<<6)
|
||||
#define AA_LINE_REGION_WIDTH_4_0 (3<<6)
|
||||
|
||||
/* 3DSTATE_BACKFACE_STENCIL_OPS, p138*/
|
||||
#define _3DSTATE_BACKFACE_STENCIL_OPS (CMD_3D | (0x8<<24))
|
||||
#define BFO_ENABLE_STENCIL_REF (1<<23)
|
||||
#define BFO_STENCIL_REF_SHIFT 15
|
||||
#define BFO_STENCIL_REF_MASK (0xff<<15)
|
||||
#define BFO_ENABLE_STENCIL_FUNCS (1<<14)
|
||||
#define BFO_STENCIL_TEST_SHIFT 11
|
||||
#define BFO_STENCIL_TEST_MASK (0x7<<11)
|
||||
#define BFO_STENCIL_FAIL_SHIFT 8
|
||||
#define BFO_STENCIL_FAIL_MASK (0x7<<8)
|
||||
#define BFO_STENCIL_PASS_Z_FAIL_SHIFT 5
|
||||
#define BFO_STENCIL_PASS_Z_FAIL_MASK (0x7<<5)
|
||||
#define BFO_STENCIL_PASS_Z_PASS_SHIFT 2
|
||||
#define BFO_STENCIL_PASS_Z_PASS_MASK (0x7<<2)
|
||||
#define BFO_ENABLE_STENCIL_TWO_SIDE (1<<1)
|
||||
#define BFO_STENCIL_TWO_SIDE (1<<0)
|
||||
|
||||
/* 3DSTATE_BACKFACE_STENCIL_MASKS, p140 */
|
||||
#define _3DSTATE_BACKFACE_STENCIL_MASKS (CMD_3D | (0x9<<24))
|
||||
#define BFM_ENABLE_STENCIL_TEST_MASK (1<<17)
|
||||
#define BFM_ENABLE_STENCIL_WRITE_MASK (1<<16)
|
||||
#define BFM_STENCIL_TEST_MASK_SHIFT 8
|
||||
#define BFM_STENCIL_TEST_MASK_MASK (0xff<<8)
|
||||
#define BFM_STENCIL_WRITE_MASK_SHIFT 0
|
||||
#define BFM_STENCIL_WRITE_MASK_MASK (0xff<<0)
|
||||
|
||||
/* 3DSTATE_BIN_CONTROL p141 */
|
||||
|
||||
/* p143 */
|
||||
#define _3DSTATE_BUF_INFO_CMD (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
|
||||
/* Dword 1 */
|
||||
#define BUF_3D_ID_COLOR_BACK (0x3<<24)
|
||||
#define BUF_3D_ID_DEPTH (0x7<<24)
|
||||
#define BUF_3D_USE_FENCE (1<<23)
|
||||
#define BUF_3D_TILED_SURFACE (1<<22)
|
||||
#define BUF_3D_TILE_WALK_X 0
|
||||
#define BUF_3D_TILE_WALK_Y (1<<21)
|
||||
#define BUF_3D_PITCH(x) (x)
|
||||
/* Dword 2 */
|
||||
#define BUF_3D_ADDR(x) ((x) & ~0x3)
|
||||
|
||||
/* 3DSTATE_CHROMA_KEY */
|
||||
|
||||
/* 3DSTATE_CLEAR_PARAMETERS, p150 */
|
||||
#define _3DSTATE_CLEAR_PARAMETERS (CMD_3D | (0x1d<<24) | (0x9c<<16) | 5)
|
||||
/* Dword 1 */
|
||||
#define CLEARPARAM_CLEAR_RECT (1 << 16)
|
||||
#define CLEARPARAM_ZONE_INIT (0 << 16)
|
||||
#define CLEARPARAM_WRITE_COLOR (1 << 2)
|
||||
#define CLEARPARAM_WRITE_DEPTH (1 << 1)
|
||||
#define CLEARPARAM_WRITE_STENCIL (1 << 0)
|
||||
|
||||
/* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */
|
||||
#define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
|
||||
|
||||
/* 3DSTATE_COORD_SET_BINDINGS, p154 */
|
||||
#define _3DSTATE_COORD_SET_BINDINGS (CMD_3D | (0x16<<24))
|
||||
#define CSB_TCB(iunit, eunit) ((eunit)<<(iunit*3))
|
||||
|
||||
/* p156 */
|
||||
#define _3DSTATE_DFLT_DIFFUSE_CMD (CMD_3D | (0x1d<<24) | (0x99<<16))
|
||||
|
||||
/* p157 */
|
||||
#define _3DSTATE_DFLT_SPEC_CMD (CMD_3D | (0x1d<<24) | (0x9a<<16))
|
||||
|
||||
/* p158 */
|
||||
#define _3DSTATE_DFLT_Z_CMD (CMD_3D | (0x1d<<24) | (0x98<<16))
|
||||
|
||||
/* 3DSTATE_DEPTH_OFFSET_SCALE, p159 */
|
||||
#define _3DSTATE_DEPTH_OFFSET_SCALE (CMD_3D | (0x1d<<24) | (0x97<<16))
|
||||
/* scale in dword 1 */
|
||||
|
||||
/* The depth subrectangle is not supported, but must be disabled. */
|
||||
/* 3DSTATE_DEPTH_SUBRECT_DISABLE, p160 */
|
||||
#define _3DSTATE_DEPTH_SUBRECT_DISABLE (CMD_3D | (0x1c<<24) | (0x11<<19) | (1 << 1) | (0 << 0))
|
||||
|
||||
/* p161 */
|
||||
#define _3DSTATE_DST_BUF_VARS_CMD (CMD_3D | (0x1d<<24) | (0x85<<16))
|
||||
/* Dword 1 */
|
||||
#define TEX_DEFAULT_COLOR_OGL (0<<30)
|
||||
#define TEX_DEFAULT_COLOR_D3D (1<<30)
|
||||
#define ZR_EARLY_DEPTH (1<<29)
|
||||
#define LOD_PRECLAMP_OGL (1<<28)
|
||||
#define LOD_PRECLAMP_D3D (0<<28)
|
||||
#define DITHER_FULL_ALWAYS (0<<26)
|
||||
#define DITHER_FULL_ON_FB_BLEND (1<<26)
|
||||
#define DITHER_CLAMPED_ALWAYS (2<<26)
|
||||
#define LINEAR_GAMMA_BLEND_32BPP (1<<25)
|
||||
#define DEBUG_DISABLE_ENH_DITHER (1<<24)
|
||||
#define DSTORG_HORT_BIAS(x) ((x)<<20)
|
||||
#define DSTORG_VERT_BIAS(x) ((x)<<16)
|
||||
#define COLOR_4_2_2_CHNL_WRT_ALL 0
|
||||
#define COLOR_4_2_2_CHNL_WRT_Y (1<<12)
|
||||
#define COLOR_4_2_2_CHNL_WRT_CR (2<<12)
|
||||
#define COLOR_4_2_2_CHNL_WRT_CB (3<<12)
|
||||
#define COLOR_4_2_2_CHNL_WRT_CRCB (4<<12)
|
||||
#define COLR_BUF_8BIT 0
|
||||
#define COLR_BUF_RGB555 (1<<8)
|
||||
#define COLR_BUF_RGB565 (2<<8)
|
||||
#define COLR_BUF_ARGB8888 (3<<8)
|
||||
#define COLR_BUF_ARGB4444 (8<<8)
|
||||
#define COLR_BUF_ARGB1555 (9<<8)
|
||||
#define COLR_BUF_ARGB2AAA (0xa<<8)
|
||||
#define DEPTH_FRMT_16_FIXED 0
|
||||
#define DEPTH_FRMT_16_FLOAT (1<<2)
|
||||
#define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2)
|
||||
#define VERT_LINE_STRIDE_1 (1<<1)
|
||||
#define VERT_LINE_STRIDE_0 (0<<1)
|
||||
#define VERT_LINE_STRIDE_OFS_1 1
|
||||
#define VERT_LINE_STRIDE_OFS_0 0
|
||||
|
||||
/* p166 */
|
||||
#define _3DSTATE_DRAW_RECT_CMD (CMD_3D|(0x1d<<24)|(0x80<<16)|3)
|
||||
/* Dword 1 */
|
||||
#define DRAW_RECT_DIS_DEPTH_OFS (1<<30)
|
||||
#define DRAW_DITHER_OFS_X(x) ((x)<<26)
|
||||
#define DRAW_DITHER_OFS_Y(x) ((x)<<24)
|
||||
/* Dword 2 */
|
||||
#define DRAW_YMIN(x) ((x)<<16)
|
||||
#define DRAW_XMIN(x) (x)
|
||||
/* Dword 3 */
|
||||
#define DRAW_YMAX(x) ((x-1)<<16)
|
||||
#define DRAW_XMAX(x) (x-1)
|
||||
/* Dword 4 */
|
||||
#define DRAW_YORG(x) ((x)<<16)
|
||||
#define DRAW_XORG(x) (x)
|
||||
|
||||
/* 3DSTATE_FILTER_COEFFICIENTS_4X4, p170 */
|
||||
|
||||
/* 3DSTATE_FILTER_COEFFICIENTS_6X5, p172 */
|
||||
|
||||
/* _3DSTATE_FOG_COLOR, p173 */
|
||||
#define _3DSTATE_FOG_COLOR_CMD (CMD_3D|(0x15<<24))
|
||||
#define FOG_COLOR_RED(x) ((x)<<16)
|
||||
#define FOG_COLOR_GREEN(x) ((x)<<8)
|
||||
#define FOG_COLOR_BLUE(x) (x)
|
||||
|
||||
/* _3DSTATE_FOG_MODE, p174 */
|
||||
#define _3DSTATE_FOG_MODE_CMD (CMD_3D|(0x1d<<24)|(0x89<<16)|2)
|
||||
/* Dword 1 */
|
||||
#define FMC1_FOGFUNC_MODIFY_ENABLE (1<<31)
|
||||
#define FMC1_FOGFUNC_VERTEX (0<<28)
|
||||
#define FMC1_FOGFUNC_PIXEL_EXP (1<<28)
|
||||
#define FMC1_FOGFUNC_PIXEL_EXP2 (2<<28)
|
||||
#define FMC1_FOGFUNC_PIXEL_LINEAR (3<<28)
|
||||
#define FMC1_FOGFUNC_MASK (3<<28)
|
||||
#define FMC1_FOGINDEX_MODIFY_ENABLE (1<<27)
|
||||
#define FMC1_FOGINDEX_Z (0<<25)
|
||||
#define FMC1_FOGINDEX_W (1<<25)
|
||||
#define FMC1_C1_C2_MODIFY_ENABLE (1<<24)
|
||||
#define FMC1_DENSITY_MODIFY_ENABLE (1<<23)
|
||||
#define FMC1_C1_ONE (1<<13)
|
||||
#define FMC1_C1_MASK (0xffff<<4)
|
||||
/* Dword 2 */
|
||||
#define FMC2_C2_ONE (1<<16)
|
||||
/* Dword 3 */
|
||||
#define FMC3_D_ONE (1<<16)
|
||||
|
||||
/* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p177 */
|
||||
#define _3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD (CMD_3D|(0x0b<<24))
|
||||
#define IAB_MODIFY_ENABLE (1<<23)
|
||||
#define IAB_ENABLE (1<<22)
|
||||
#define IAB_MODIFY_FUNC (1<<21)
|
||||
#define IAB_FUNC_SHIFT 16
|
||||
#define IAB_MODIFY_SRC_FACTOR (1<<11)
|
||||
#define IAB_SRC_FACTOR_SHIFT 6
|
||||
#define IAB_SRC_FACTOR_MASK (BLENDFACT_MASK<<6)
|
||||
#define IAB_MODIFY_DST_FACTOR (1<<5)
|
||||
#define IAB_DST_FACTOR_SHIFT 0
|
||||
#define IAB_DST_FACTOR_MASK (BLENDFACT_MASK<<0)
|
||||
|
||||
#define BLENDFACT_ZERO 0x01
|
||||
#define BLENDFACT_ONE 0x02
|
||||
#define BLENDFACT_SRC_COLR 0x03
|
||||
#define BLENDFACT_INV_SRC_COLR 0x04
|
||||
#define BLENDFACT_SRC_ALPHA 0x05
|
||||
#define BLENDFACT_INV_SRC_ALPHA 0x06
|
||||
#define BLENDFACT_DST_ALPHA 0x07
|
||||
#define BLENDFACT_INV_DST_ALPHA 0x08
|
||||
#define BLENDFACT_DST_COLR 0x09
|
||||
#define BLENDFACT_INV_DST_COLR 0x0a
|
||||
#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
|
||||
#define BLENDFACT_CONST_COLOR 0x0c
|
||||
#define BLENDFACT_INV_CONST_COLOR 0x0d
|
||||
#define BLENDFACT_CONST_ALPHA 0x0e
|
||||
#define BLENDFACT_INV_CONST_ALPHA 0x0f
|
||||
#define BLENDFACT_MASK 0x0f
|
||||
|
||||
#define BLENDFUNC_ADD 0x0
|
||||
#define BLENDFUNC_SUBTRACT 0x1
|
||||
#define BLENDFUNC_REVERSE_SUBTRACT 0x2
|
||||
#define BLENDFUNC_MIN 0x3
|
||||
#define BLENDFUNC_MAX 0x4
|
||||
#define BLENDFUNC_MASK 0x7
|
||||
|
||||
/* 3DSTATE_LOAD_INDIRECT, p180 */
|
||||
|
||||
#define _3DSTATE_LOAD_INDIRECT (CMD_3D|(0x1d<<24)|(0x7<<16))
|
||||
#define LI0_STATE_STATIC_INDIRECT (0x01<<8)
|
||||
#define LI0_STATE_DYNAMIC_INDIRECT (0x02<<8)
|
||||
#define LI0_STATE_SAMPLER (0x04<<8)
|
||||
#define LI0_STATE_MAP (0x08<<8)
|
||||
#define LI0_STATE_PROGRAM (0x10<<8)
|
||||
#define LI0_STATE_CONSTANTS (0x20<<8)
|
||||
|
||||
#define SIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define SIS0_FORCE_LOAD (1<<1)
|
||||
#define SIS0_BUFFER_VALID (1<<0)
|
||||
#define SIS1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define DIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define DIS0_BUFFER_RESET (1<<1)
|
||||
#define DIS0_BUFFER_VALID (1<<0)
|
||||
|
||||
#define SSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define SSB0_FORCE_LOAD (1<<1)
|
||||
#define SSB0_BUFFER_VALID (1<<0)
|
||||
#define SSB1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define MSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define MSB0_FORCE_LOAD (1<<1)
|
||||
#define MSB0_BUFFER_VALID (1<<0)
|
||||
#define MSB1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define PSP0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define PSP0_FORCE_LOAD (1<<1)
|
||||
#define PSP0_BUFFER_VALID (1<<0)
|
||||
#define PSP1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define PSC0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define PSC0_FORCE_LOAD (1<<1)
|
||||
#define PSC0_BUFFER_VALID (1<<0)
|
||||
#define PSC1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
/* _3DSTATE_RASTERIZATION_RULES */
|
||||
#define _3DSTATE_RASTER_RULES_CMD (CMD_3D|(0x07<<24))
|
||||
#define ENABLE_POINT_RASTER_RULE (1<<15)
|
||||
#define OGL_POINT_RASTER_RULE (1<<13)
|
||||
#define ENABLE_TEXKILL_3D_4D (1<<10)
|
||||
#define TEXKILL_3D (0<<9)
|
||||
#define TEXKILL_4D (1<<9)
|
||||
#define ENABLE_LINE_STRIP_PROVOKE_VRTX (1<<8)
|
||||
#define ENABLE_TRI_FAN_PROVOKE_VRTX (1<<5)
|
||||
#define LINE_STRIP_PROVOKE_VRTX(x) ((x)<<6)
|
||||
#define TRI_FAN_PROVOKE_VRTX(x) ((x)<<3)
|
||||
|
||||
/* _3DSTATE_SCISSOR_ENABLE, p256 */
|
||||
#define _3DSTATE_SCISSOR_ENABLE_CMD (CMD_3D|(0x1c<<24)|(0x10<<19))
|
||||
#define ENABLE_SCISSOR_RECT ((1<<1) | 1)
|
||||
#define DISABLE_SCISSOR_RECT (1<<1)
|
||||
|
||||
/* _3DSTATE_SCISSOR_RECTANGLE_0, p257 */
|
||||
#define _3DSTATE_SCISSOR_RECT_0_CMD (CMD_3D|(0x1d<<24)|(0x81<<16)|1)
|
||||
/* Dword 1 */
|
||||
#define SCISSOR_RECT_0_YMIN(x) ((x)<<16)
|
||||
#define SCISSOR_RECT_0_XMIN(x) (x)
|
||||
/* Dword 2 */
|
||||
#define SCISSOR_RECT_0_YMAX(x) ((x)<<16)
|
||||
#define SCISSOR_RECT_0_XMAX(x) (x)
|
||||
|
||||
/* p189 */
|
||||
#define _3DSTATE_LOAD_STATE_IMMEDIATE_1 (CMD_3D | (0x1d<<24) | (0x04<<16))
|
||||
#define I1_LOAD_S(n) (1<<(4+n))
|
||||
|
||||
#define S0_VB_OFFSET_MASK 0xffffffc
|
||||
#define S0_AUTO_CACHE_INV_DISABLE (1<<0)
|
||||
|
||||
#define S1_VERTEX_WIDTH_SHIFT 24
|
||||
#define S1_VERTEX_WIDTH_MASK (0x3f<<24)
|
||||
#define S1_VERTEX_PITCH_SHIFT 16
|
||||
#define S1_VERTEX_PITCH_MASK (0x3f<<16)
|
||||
|
||||
#define TEXCOORDFMT_2D 0x0
|
||||
#define TEXCOORDFMT_3D 0x1
|
||||
#define TEXCOORDFMT_4D 0x2
|
||||
#define TEXCOORDFMT_1D 0x3
|
||||
#define TEXCOORDFMT_2D_16 0x4
|
||||
#define TEXCOORDFMT_4D_16 0x5
|
||||
#define TEXCOORDFMT_NOT_PRESENT 0xf
|
||||
#define S2_TEXCOORD_FMT0_MASK 0xf
|
||||
#define S2_TEXCOORD_FMT1_SHIFT 4
|
||||
#define S2_TEXCOORD_FMT(unit, type) ((type)<<(unit*4))
|
||||
#define S2_TEXCOORD_NONE (~0U)
|
||||
|
||||
#define TEXCOORD_WRAP_SHORTEST_TCX 8
|
||||
#define TEXCOORD_WRAP_SHORTEST_TCY 4
|
||||
#define TEXCOORD_WRAP_SHORTEST_TCZ 2
|
||||
#define TEXCOORD_PERSPECTIVE_DISABLE 1
|
||||
|
||||
#define S3_WRAP_SHORTEST_TCX(unit) (TEXCOORD_WRAP_SHORTEST_TCX << ((unit) * 4))
|
||||
#define S3_WRAP_SHORTEST_TCY(unit) (TEXCOORD_WRAP_SHORTEST_TCY << ((unit) * 4))
|
||||
#define S3_WRAP_SHORTEST_TCZ(unit) (TEXCOORD_WRAP_SHORTEST_TCZ << ((unit) * 4))
|
||||
#define S3_PERSPECTIVE_DISABLE(unit) (TEXCOORD_PERSPECTIVE_DISABLE << ((unit) * 4))
|
||||
|
||||
/* S3 not interesting */
|
||||
|
||||
#define S4_POINT_WIDTH_SHIFT 23
|
||||
#define S4_POINT_WIDTH_MASK (0x1ff<<23)
|
||||
#define S4_LINE_WIDTH_SHIFT 19
|
||||
#define S4_LINE_WIDTH_ONE (0x2<<19)
|
||||
#define S4_LINE_WIDTH_MASK (0xf<<19)
|
||||
#define S4_FLATSHADE_ALPHA (1<<18)
|
||||
#define S4_FLATSHADE_FOG (1<<17)
|
||||
#define S4_FLATSHADE_SPECULAR (1<<16)
|
||||
#define S4_FLATSHADE_COLOR (1<<15)
|
||||
#define S4_CULLMODE_BOTH (0<<13)
|
||||
#define S4_CULLMODE_NONE (1<<13)
|
||||
#define S4_CULLMODE_CW (2<<13)
|
||||
#define S4_CULLMODE_CCW (3<<13)
|
||||
#define S4_CULLMODE_MASK (3<<13)
|
||||
#define S4_VFMT_POINT_WIDTH (1<<12)
|
||||
#define S4_VFMT_SPEC_FOG (1<<11)
|
||||
#define S4_VFMT_COLOR (1<<10)
|
||||
#define S4_VFMT_DEPTH_OFFSET (1<<9)
|
||||
#define S4_VFMT_XYZ (1<<6)
|
||||
#define S4_VFMT_XYZW (2<<6)
|
||||
#define S4_VFMT_XY (3<<6)
|
||||
#define S4_VFMT_XYW (4<<6)
|
||||
#define S4_VFMT_XYZW_MASK (7<<6)
|
||||
#define S4_FORCE_DEFAULT_DIFFUSE (1<<5)
|
||||
#define S4_FORCE_DEFAULT_SPECULAR (1<<4)
|
||||
#define S4_LOCAL_DEPTH_OFFSET_ENABLE (1<<3)
|
||||
#define S4_VFMT_FOG_PARAM (1<<2)
|
||||
#define S4_SPRITE_POINT_ENABLE (1<<1)
|
||||
#define S4_LINE_ANTIALIAS_ENABLE (1<<0)
|
||||
|
||||
#define S4_VFMT_MASK (S4_VFMT_POINT_WIDTH | \
|
||||
S4_VFMT_SPEC_FOG | \
|
||||
S4_VFMT_COLOR | \
|
||||
S4_VFMT_DEPTH_OFFSET | \
|
||||
S4_VFMT_XYZW_MASK | \
|
||||
S4_VFMT_FOG_PARAM)
|
||||
|
||||
#define S5_WRITEDISABLE_ALPHA (1<<31)
|
||||
#define S5_WRITEDISABLE_RED (1<<30)
|
||||
#define S5_WRITEDISABLE_GREEN (1<<29)
|
||||
#define S5_WRITEDISABLE_BLUE (1<<28)
|
||||
#define S5_WRITEDISABLE_MASK (0xf<<28)
|
||||
#define S5_FORCE_DEFAULT_POINT_SIZE (1<<27)
|
||||
#define S5_LAST_PIXEL_ENABLE (1<<26)
|
||||
#define S5_GLOBAL_DEPTH_OFFSET_ENABLE (1<<25)
|
||||
#define S5_FOG_ENABLE (1<<24)
|
||||
#define S5_STENCIL_REF_SHIFT 16
|
||||
#define S5_STENCIL_REF_MASK (0xff<<16)
|
||||
#define S5_STENCIL_TEST_FUNC_SHIFT 13
|
||||
#define S5_STENCIL_TEST_FUNC_MASK (0x7<<13)
|
||||
#define S5_STENCIL_FAIL_SHIFT 10
|
||||
#define S5_STENCIL_FAIL_MASK (0x7<<10)
|
||||
#define S5_STENCIL_PASS_Z_FAIL_SHIFT 7
|
||||
#define S5_STENCIL_PASS_Z_FAIL_MASK (0x7<<7)
|
||||
#define S5_STENCIL_PASS_Z_PASS_SHIFT 4
|
||||
#define S5_STENCIL_PASS_Z_PASS_MASK (0x7<<4)
|
||||
#define S5_STENCIL_WRITE_ENABLE (1<<3)
|
||||
#define S5_STENCIL_TEST_ENABLE (1<<2)
|
||||
#define S5_COLOR_DITHER_ENABLE (1<<1)
|
||||
#define S5_LOGICOP_ENABLE (1<<0)
|
||||
|
||||
#define COMPAREFUNC_ALWAYS 0
|
||||
#define COMPAREFUNC_NEVER 0x1
|
||||
#define COMPAREFUNC_LESS 0x2
|
||||
#define COMPAREFUNC_EQUAL 0x3
|
||||
#define COMPAREFUNC_LEQUAL 0x4
|
||||
#define COMPAREFUNC_GREATER 0x5
|
||||
#define COMPAREFUNC_NOTEQUAL 0x6
|
||||
#define COMPAREFUNC_GEQUAL 0x7
|
||||
|
||||
#define STENCILOP_KEEP 0
|
||||
#define STENCILOP_ZERO 0x1
|
||||
#define STENCILOP_REPLACE 0x2
|
||||
#define STENCILOP_INCRSAT 0x3
|
||||
#define STENCILOP_DECRSAT 0x4
|
||||
#define STENCILOP_INCR 0x5
|
||||
#define STENCILOP_DECR 0x6
|
||||
#define STENCILOP_INVERT 0x7
|
||||
|
||||
#define S6_ALPHA_TEST_ENABLE (1<<31)
|
||||
#define S6_ALPHA_TEST_FUNC_SHIFT 28
|
||||
#define S6_ALPHA_TEST_FUNC_MASK (0x7<<28)
|
||||
#define S6_ALPHA_REF_SHIFT 20
|
||||
#define S6_ALPHA_REF_MASK (0xff<<20)
|
||||
#define S6_DEPTH_TEST_ENABLE (1<<19)
|
||||
#define S6_DEPTH_TEST_FUNC_SHIFT 16
|
||||
#define S6_DEPTH_TEST_FUNC_MASK (0x7<<16)
|
||||
#define S6_CBUF_BLEND_ENABLE (1<<15)
|
||||
#define S6_CBUF_BLEND_FUNC_SHIFT 12
|
||||
#define S6_CBUF_BLEND_FUNC_MASK (0x7<<12)
|
||||
#define S6_CBUF_SRC_BLEND_FACT_SHIFT 8
|
||||
#define S6_CBUF_SRC_BLEND_FACT_MASK (0xf<<8)
|
||||
#define S6_CBUF_DST_BLEND_FACT_SHIFT 4
|
||||
#define S6_CBUF_DST_BLEND_FACT_MASK (0xf<<4)
|
||||
#define S6_DEPTH_WRITE_ENABLE (1<<3)
|
||||
#define S6_COLOR_WRITE_ENABLE (1<<2)
|
||||
#define S6_TRISTRIP_PV_SHIFT 0
|
||||
#define S6_TRISTRIP_PV_MASK (0x3<<0)
|
||||
|
||||
#define S7_DEPTH_OFFSET_CONST_MASK ~0
|
||||
|
||||
/* 3DSTATE_MAP_DEINTERLACER_PARAMETERS */
|
||||
/* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */
|
||||
|
||||
/* _3DSTATE_MODES_4, p218 */
|
||||
#define _3DSTATE_MODES_4_CMD (CMD_3D|(0x0d<<24))
|
||||
#define ENABLE_LOGIC_OP_FUNC (1<<23)
|
||||
#define LOGIC_OP_FUNC(x) ((x)<<18)
|
||||
#define LOGICOP_MASK (0xf<<18)
|
||||
#define LOGICOP_COPY 0xc
|
||||
#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
|
||||
#define ENABLE_STENCIL_TEST_MASK (1<<17)
|
||||
#define STENCIL_TEST_MASK(x) ((x)<<8)
|
||||
#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
|
||||
#define ENABLE_STENCIL_WRITE_MASK (1<<16)
|
||||
#define STENCIL_WRITE_MASK(x) ((x)&0xff)
|
||||
|
||||
/* _3DSTATE_MODES_5, p220 */
|
||||
#define _3DSTATE_MODES_5_CMD (CMD_3D|(0x0c<<24))
|
||||
#define PIPELINE_FLUSH_RENDER_CACHE (1<<18)
|
||||
#define PIPELINE_FLUSH_TEXTURE_CACHE (1<<16)
|
||||
|
||||
/* p221 */
|
||||
#define _3DSTATE_PIXEL_SHADER_CONSTANTS (CMD_3D|(0x1d<<24)|(0x6<<16))
|
||||
#define PS1_REG(n) (1<<(n))
|
||||
#define PS2_CONST_X(n) (n)
|
||||
#define PS3_CONST_Y(n) (n)
|
||||
#define PS4_CONST_Z(n) (n)
|
||||
#define PS5_CONST_W(n) (n)
|
||||
|
||||
/* p222 */
|
||||
|
||||
#define I915_MAX_TEX_INDIRECT 4
|
||||
#define I915_MAX_TEX_INSN 32
|
||||
#define I915_MAX_ALU_INSN 64
|
||||
#define I915_MAX_DECL_INSN 27
|
||||
#define I915_MAX_TEMPORARY 16
|
||||
|
||||
/* Each instruction is 3 dwords long, though most don't require all
|
||||
* this space. Maximum of 123 instructions. Smaller maxes per insn
|
||||
* type.
|
||||
*/
|
||||
#define _3DSTATE_PIXEL_SHADER_PROGRAM (CMD_3D|(0x1d<<24)|(0x5<<16))
|
||||
|
||||
#define REG_TYPE_R 0 /* temporary regs, no need to
|
||||
* dcl, must be written before
|
||||
* read -- Preserved between
|
||||
* phases.
|
||||
*/
|
||||
#define REG_TYPE_T 1 /* Interpolated values, must be
|
||||
* dcl'ed before use.
|
||||
*
|
||||
* 0..7: texture coord,
|
||||
* 8: diffuse spec,
|
||||
* 9: specular color,
|
||||
* 10: fog parameter in w.
|
||||
*/
|
||||
#define REG_TYPE_CONST 2 /* Restriction: only one const
|
||||
* can be referenced per
|
||||
* instruction, though it may be
|
||||
* selected for multiple inputs.
|
||||
* Constants not initialized
|
||||
* default to zero.
|
||||
*/
|
||||
#define REG_TYPE_S 3 /* sampler */
|
||||
#define REG_TYPE_OC 4 /* output color (rgba) */
|
||||
#define REG_TYPE_OD 5 /* output depth (w), xyz are
|
||||
* temporaries. If not written,
|
||||
* interpolated depth is used?
|
||||
*/
|
||||
#define REG_TYPE_U 6 /* unpreserved temporaries */
|
||||
#define REG_TYPE_MASK 0x7
|
||||
#define REG_NR_MASK 0xf
|
||||
|
||||
/* REG_TYPE_T:
|
||||
*/
|
||||
#define T_TEX0 0
|
||||
#define T_TEX1 1
|
||||
#define T_TEX2 2
|
||||
#define T_TEX3 3
|
||||
#define T_TEX4 4
|
||||
#define T_TEX5 5
|
||||
#define T_TEX6 6
|
||||
#define T_TEX7 7
|
||||
#define T_DIFFUSE 8
|
||||
#define T_SPECULAR 9
|
||||
#define T_FOG_W 10 /* interpolated fog is in W coord */
|
||||
|
||||
/* Arithmetic instructions */
|
||||
|
||||
/* .replicate_swizzle == selection and replication of a particular
|
||||
* scalar channel, ie., .xxxx, .yyyy, .zzzz or .wwww
|
||||
*/
|
||||
#define A0_NOP (0x0<<24) /* no operation */
|
||||
#define A0_ADD (0x1<<24) /* dst = src0 + src1 */
|
||||
#define A0_MOV (0x2<<24) /* dst = src0 */
|
||||
#define A0_MUL (0x3<<24) /* dst = src0 * src1 */
|
||||
#define A0_MAD (0x4<<24) /* dst = src0 * src1 + src2 */
|
||||
#define A0_DP2ADD (0x5<<24) /* dst.xyzw = src0.xy dot src1.xy + src2.replicate_swizzle */
|
||||
#define A0_DP3 (0x6<<24) /* dst.xyzw = src0.xyz dot src1.xyz */
|
||||
#define A0_DP4 (0x7<<24) /* dst.xyzw = src0.xyzw dot src1.xyzw */
|
||||
#define A0_FRC (0x8<<24) /* dst = src0 - floor(src0) */
|
||||
#define A0_RCP (0x9<<24) /* dst.xyzw = 1/(src0.replicate_swizzle) */
|
||||
#define A0_RSQ (0xa<<24) /* dst.xyzw = 1/(sqrt(abs(src0.replicate_swizzle))) */
|
||||
#define A0_EXP (0xb<<24) /* dst.xyzw = exp2(src0.replicate_swizzle) */
|
||||
#define A0_LOG (0xc<<24) /* dst.xyzw = log2(abs(src0.replicate_swizzle)) */
|
||||
#define A0_CMP (0xd<<24) /* dst = (src0 >= 0.0) ? src1 : src2 */
|
||||
#define A0_MIN (0xe<<24) /* dst = (src0 < src1) ? src0 : src1 */
|
||||
#define A0_MAX (0xf<<24) /* dst = (src0 >= src1) ? src0 : src1 */
|
||||
#define A0_FLR (0x10<<24) /* dst = floor(src0) */
|
||||
#define A0_MOD (0x11<<24) /* dst = src0 fmod 1.0 */
|
||||
#define A0_TRC (0x12<<24) /* dst = int(src0) */
|
||||
#define A0_SGE (0x13<<24) /* dst = src0 >= src1 ? 1.0 : 0.0 */
|
||||
#define A0_SLT (0x14<<24) /* dst = src0 < src1 ? 1.0 : 0.0 */
|
||||
#define A0_DEST_SATURATE (1<<22)
|
||||
#define A0_DEST_TYPE_SHIFT 19
|
||||
/* Allow: R, OC, OD, U */
|
||||
#define A0_DEST_NR_SHIFT 14
|
||||
/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
|
||||
#define A0_DEST_CHANNEL_X (1<<10)
|
||||
#define A0_DEST_CHANNEL_Y (2<<10)
|
||||
#define A0_DEST_CHANNEL_Z (4<<10)
|
||||
#define A0_DEST_CHANNEL_W (8<<10)
|
||||
#define A0_DEST_CHANNEL_ALL (0xf<<10)
|
||||
#define A0_DEST_CHANNEL_SHIFT 10
|
||||
#define A0_SRC0_TYPE_SHIFT 7
|
||||
#define A0_SRC0_NR_SHIFT 2
|
||||
|
||||
#define A0_DEST_CHANNEL_XY (A0_DEST_CHANNEL_X|A0_DEST_CHANNEL_Y)
|
||||
#define A0_DEST_CHANNEL_XYZ (A0_DEST_CHANNEL_XY|A0_DEST_CHANNEL_Z)
|
||||
|
||||
#define SRC_X 0
|
||||
#define SRC_Y 1
|
||||
#define SRC_Z 2
|
||||
#define SRC_W 3
|
||||
#define SRC_ZERO 4
|
||||
#define SRC_ONE 5
|
||||
|
||||
#define A1_SRC0_CHANNEL_X_NEGATE (1<<31)
|
||||
#define A1_SRC0_CHANNEL_X_SHIFT 28
|
||||
#define A1_SRC0_CHANNEL_Y_NEGATE (1<<27)
|
||||
#define A1_SRC0_CHANNEL_Y_SHIFT 24
|
||||
#define A1_SRC0_CHANNEL_Z_NEGATE (1<<23)
|
||||
#define A1_SRC0_CHANNEL_Z_SHIFT 20
|
||||
#define A1_SRC0_CHANNEL_W_NEGATE (1<<19)
|
||||
#define A1_SRC0_CHANNEL_W_SHIFT 16
|
||||
#define A1_SRC1_TYPE_SHIFT 13
|
||||
#define A1_SRC1_NR_SHIFT 8
|
||||
#define A1_SRC1_CHANNEL_X_NEGATE (1<<7)
|
||||
#define A1_SRC1_CHANNEL_X_SHIFT 4
|
||||
#define A1_SRC1_CHANNEL_Y_NEGATE (1<<3)
|
||||
#define A1_SRC1_CHANNEL_Y_SHIFT 0
|
||||
|
||||
#define A2_SRC1_CHANNEL_Z_NEGATE (1<<31)
|
||||
#define A2_SRC1_CHANNEL_Z_SHIFT 28
|
||||
#define A2_SRC1_CHANNEL_W_NEGATE (1<<27)
|
||||
#define A2_SRC1_CHANNEL_W_SHIFT 24
|
||||
#define A2_SRC2_TYPE_SHIFT 21
|
||||
#define A2_SRC2_NR_SHIFT 16
|
||||
#define A2_SRC2_CHANNEL_X_NEGATE (1<<15)
|
||||
#define A2_SRC2_CHANNEL_X_SHIFT 12
|
||||
#define A2_SRC2_CHANNEL_Y_NEGATE (1<<11)
|
||||
#define A2_SRC2_CHANNEL_Y_SHIFT 8
|
||||
#define A2_SRC2_CHANNEL_Z_NEGATE (1<<7)
|
||||
#define A2_SRC2_CHANNEL_Z_SHIFT 4
|
||||
#define A2_SRC2_CHANNEL_W_NEGATE (1<<3)
|
||||
#define A2_SRC2_CHANNEL_W_SHIFT 0
|
||||
|
||||
/* Texture instructions */
|
||||
#define T0_TEXLD (0x15<<24) /* Sample texture using predeclared
|
||||
* sampler and address, and output
|
||||
* filtered texel data to destination
|
||||
* register */
|
||||
#define T0_TEXLDP (0x16<<24) /* Same as texld but performs a
|
||||
* perspective divide of the texture
|
||||
* coordinate .xyz values by .w before
|
||||
* sampling. */
|
||||
#define T0_TEXLDB (0x17<<24) /* Same as texld but biases the
|
||||
* computed LOD by w. Only S4.6 two's
|
||||
* comp is used. This implies that a
|
||||
* float to fixed conversion is
|
||||
* done. */
|
||||
#define T0_TEXKILL (0x18<<24) /* Does not perform a sampling
|
||||
* operation. Simply kills the pixel
|
||||
* if any channel of the address
|
||||
* register is < 0.0. */
|
||||
#define T0_DEST_TYPE_SHIFT 19
|
||||
/* Allow: R, OC, OD, U */
|
||||
/* Note: U (unpreserved) regs do not retain their values between
|
||||
* phases (cannot be used for feedback)
|
||||
*
|
||||
* Note: oC and OD registers can only be used as the destination of a
|
||||
* texture instruction once per phase (this is an implementation
|
||||
* restriction).
|
||||
*/
|
||||
#define T0_DEST_NR_SHIFT 14
|
||||
/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
|
||||
#define T0_SAMPLER_NR_SHIFT 0 /* This field ignored for TEXKILL */
|
||||
#define T0_SAMPLER_NR_MASK (0xf<<0)
|
||||
|
||||
#define T1_ADDRESS_REG_TYPE_SHIFT 24 /* Reg to use as texture coord */
|
||||
/* Allow R, T, OC, OD -- R, OC, OD are 'dependent' reads, new program phase */
|
||||
#define T1_ADDRESS_REG_NR_SHIFT 17
|
||||
#define T2_MBZ 0
|
||||
|
||||
/* Declaration instructions */
|
||||
#define D0_DCL (0x19<<24) /* Declare a t (interpolated attrib)
|
||||
* register or an s (sampler)
|
||||
* register. */
|
||||
#define D0_SAMPLE_TYPE_SHIFT 22
|
||||
#define D0_SAMPLE_TYPE_2D (0x0<<22)
|
||||
#define D0_SAMPLE_TYPE_CUBE (0x1<<22)
|
||||
#define D0_SAMPLE_TYPE_VOLUME (0x2<<22)
|
||||
#define D0_SAMPLE_TYPE_MASK (0x3<<22)
|
||||
|
||||
#define D0_TYPE_SHIFT 19
|
||||
/* Allow: T, S */
|
||||
#define D0_NR_SHIFT 14
|
||||
/* Allow T: 0..10, S: 0..15 */
|
||||
#define D0_CHANNEL_X (1<<10)
|
||||
#define D0_CHANNEL_Y (2<<10)
|
||||
#define D0_CHANNEL_Z (4<<10)
|
||||
#define D0_CHANNEL_W (8<<10)
|
||||
#define D0_CHANNEL_ALL (0xf<<10)
|
||||
#define D0_CHANNEL_NONE (0<<10)
|
||||
|
||||
#define D0_CHANNEL_XY (D0_CHANNEL_X|D0_CHANNEL_Y)
|
||||
#define D0_CHANNEL_XYZ (D0_CHANNEL_XY|D0_CHANNEL_Z)
|
||||
|
||||
/* I915 Errata: Do not allow (xz), (xw), (xzw) combinations for diffuse
|
||||
* or specular declarations.
|
||||
*
|
||||
* For T dcls, only allow: (x), (xy), (xyz), (w), (xyzw)
|
||||
*
|
||||
* Must be zero for S (sampler) dcls
|
||||
*/
|
||||
#define D1_MBZ 0
|
||||
#define D2_MBZ 0
|
||||
|
||||
/* p207.
|
||||
* The DWORD count is 3 times the number of bits set in MS1_MAPMASK_MASK
|
||||
*/
|
||||
#define _3DSTATE_MAP_STATE (CMD_3D|(0x1d<<24)|(0x0<<16))
|
||||
|
||||
#define MS1_MAPMASK_SHIFT 0
|
||||
#define MS1_MAPMASK_MASK (0x8fff<<0)
|
||||
|
||||
#define MS2_UNTRUSTED_SURFACE (1<<31)
|
||||
#define MS2_ADDRESS_MASK 0xfffffffc
|
||||
#define MS2_VERTICAL_LINE_STRIDE (1<<1)
|
||||
#define MS2_VERTICAL_OFFSET (1<<1)
|
||||
|
||||
#define MS3_HEIGHT_SHIFT 21
|
||||
#define MS3_WIDTH_SHIFT 10
|
||||
#define MS3_PALETTE_SELECT (1<<9)
|
||||
#define MS3_MAPSURF_FORMAT_SHIFT 7
|
||||
#define MS3_MAPSURF_FORMAT_MASK (0x7<<7)
|
||||
#define MAPSURF_8BIT (1<<7)
|
||||
#define MAPSURF_16BIT (2<<7)
|
||||
#define MAPSURF_32BIT (3<<7)
|
||||
#define MAPSURF_422 (5<<7)
|
||||
#define MAPSURF_COMPRESSED (6<<7)
|
||||
#define MAPSURF_4BIT_INDEXED (7<<7)
|
||||
#define MS3_MT_FORMAT_MASK (0x7 << 3)
|
||||
#define MS3_MT_FORMAT_SHIFT 3
|
||||
#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
|
||||
#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
|
||||
#define MT_8BIT_L8 (1<<3)
|
||||
#define MT_8BIT_A8 (4<<3)
|
||||
#define MT_8BIT_MONO8 (5<<3)
|
||||
#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
|
||||
#define MT_16BIT_ARGB1555 (1<<3)
|
||||
#define MT_16BIT_ARGB4444 (2<<3)
|
||||
#define MT_16BIT_AY88 (3<<3)
|
||||
#define MT_16BIT_88DVDU (5<<3)
|
||||
#define MT_16BIT_BUMP_655LDVDU (6<<3)
|
||||
#define MT_16BIT_I16 (7<<3)
|
||||
#define MT_16BIT_L16 (8<<3)
|
||||
#define MT_16BIT_A16 (9<<3)
|
||||
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
|
||||
#define MT_32BIT_ABGR8888 (1<<3)
|
||||
#define MT_32BIT_XRGB8888 (2<<3)
|
||||
#define MT_32BIT_XBGR8888 (3<<3)
|
||||
#define MT_32BIT_QWVU8888 (4<<3)
|
||||
#define MT_32BIT_AXVU8888 (5<<3)
|
||||
#define MT_32BIT_LXVU8888 (6<<3)
|
||||
#define MT_32BIT_XLVU8888 (7<<3)
|
||||
#define MT_32BIT_ARGB2101010 (8<<3)
|
||||
#define MT_32BIT_ABGR2101010 (9<<3)
|
||||
#define MT_32BIT_AWVU2101010 (0xA<<3)
|
||||
#define MT_32BIT_GR1616 (0xB<<3)
|
||||
#define MT_32BIT_VU1616 (0xC<<3)
|
||||
#define MT_32BIT_xI824 (0xD<<3)
|
||||
#define MT_32BIT_xA824 (0xE<<3)
|
||||
#define MT_32BIT_xL824 (0xF<<3)
|
||||
#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
|
||||
#define MT_422_YCRCB_NORMAL (1<<3)
|
||||
#define MT_422_YCRCB_SWAPUV (2<<3)
|
||||
#define MT_422_YCRCB_SWAPUVY (3<<3)
|
||||
#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
|
||||
#define MT_COMPRESS_DXT2_3 (1<<3)
|
||||
#define MT_COMPRESS_DXT4_5 (2<<3)
|
||||
#define MT_COMPRESS_FXT1 (3<<3)
|
||||
#define MT_COMPRESS_DXT1_RGB (4<<3)
|
||||
#define MS3_USE_FENCE_REGS (1<<2)
|
||||
#define MS3_TILED_SURFACE (1<<1)
|
||||
#define MS3_TILE_WALK (1<<0)
|
||||
|
||||
/* The pitch is the pitch measured in DWORDS, minus 1 */
|
||||
#define MS4_PITCH_SHIFT 21
|
||||
#define MS4_CUBE_FACE_ENA_NEGX (1<<20)
|
||||
#define MS4_CUBE_FACE_ENA_POSX (1<<19)
|
||||
#define MS4_CUBE_FACE_ENA_NEGY (1<<18)
|
||||
#define MS4_CUBE_FACE_ENA_POSY (1<<17)
|
||||
#define MS4_CUBE_FACE_ENA_NEGZ (1<<16)
|
||||
#define MS4_CUBE_FACE_ENA_POSZ (1<<15)
|
||||
#define MS4_CUBE_FACE_ENA_MASK (0x3f<<15)
|
||||
#define MS4_MAX_LOD_SHIFT 9
|
||||
#define MS4_MAX_LOD_MASK (0x3f<<9)
|
||||
#define MS4_MIP_LAYOUT_LEGACY (0<<8)
|
||||
#define MS4_MIP_LAYOUT_BELOW_LPT (0<<8)
|
||||
#define MS4_MIP_LAYOUT_RIGHT_LPT (1<<8)
|
||||
#define MS4_VOLUME_DEPTH_SHIFT 0
|
||||
#define MS4_VOLUME_DEPTH_MASK (0xff<<0)
|
||||
|
||||
/* p244.
|
||||
* The DWORD count is 3 times the number of bits set in SS1_MAPMASK_MASK.
|
||||
*/
|
||||
#define _3DSTATE_SAMPLER_STATE (CMD_3D|(0x1d<<24)|(0x1<<16))
|
||||
|
||||
#define SS1_MAPMASK_SHIFT 0
|
||||
#define SS1_MAPMASK_MASK (0x8fff<<0)
|
||||
|
||||
#define SS2_REVERSE_GAMMA_ENABLE (1<<31)
|
||||
#define SS2_PACKED_TO_PLANAR_ENABLE (1<<30)
|
||||
#define SS2_COLORSPACE_CONVERSION (1<<29)
|
||||
#define SS2_CHROMAKEY_SHIFT 27
|
||||
#define SS2_BASE_MIP_LEVEL_SHIFT 22
|
||||
#define SS2_BASE_MIP_LEVEL_MASK (0x1f<<22)
|
||||
#define SS2_MIP_FILTER_SHIFT 20
|
||||
#define SS2_MIP_FILTER_MASK (0x3<<20)
|
||||
#define MIPFILTER_NONE 0
|
||||
#define MIPFILTER_NEAREST 1
|
||||
#define MIPFILTER_LINEAR 3
|
||||
#define SS2_MAG_FILTER_SHIFT 17
|
||||
#define SS2_MAG_FILTER_MASK (0x7<<17)
|
||||
#define FILTER_NEAREST 0
|
||||
#define FILTER_LINEAR 1
|
||||
#define FILTER_ANISOTROPIC 2
|
||||
#define FILTER_4X4_1 3
|
||||
#define FILTER_4X4_2 4
|
||||
#define FILTER_4X4_FLAT 5
|
||||
#define FILTER_6X5_MONO 6 /* XXX - check */
|
||||
#define SS2_MIN_FILTER_SHIFT 14
|
||||
#define SS2_MIN_FILTER_MASK (0x7<<14)
|
||||
#define SS2_LOD_BIAS_SHIFT 5
|
||||
#define SS2_LOD_BIAS_ONE (0x10<<5)
|
||||
#define SS2_LOD_BIAS_MASK (0x1ff<<5)
|
||||
/* Shadow requires:
|
||||
* MT_X8{I,L,A}24 or MT_{I,L,A}16 texture format
|
||||
* FILTER_4X4_x MIN and MAG filters
|
||||
*/
|
||||
#define SS2_SHADOW_ENABLE (1<<4)
|
||||
#define SS2_MAX_ANISO_MASK (1<<3)
|
||||
#define SS2_MAX_ANISO_2 (0<<3)
|
||||
#define SS2_MAX_ANISO_4 (1<<3)
|
||||
#define SS2_SHADOW_FUNC_SHIFT 0
|
||||
#define SS2_SHADOW_FUNC_MASK (0x7<<0)
|
||||
/* SS2_SHADOW_FUNC values: see COMPAREFUNC_* */
|
||||
|
||||
#define SS3_MIN_LOD_SHIFT 24
|
||||
#define SS3_MIN_LOD_ONE (0x10<<24)
|
||||
#define SS3_MIN_LOD_MASK (0xff<<24)
|
||||
#define SS3_KILL_PIXEL_ENABLE (1<<17)
|
||||
#define SS3_TCX_ADDR_MODE_SHIFT 12
|
||||
#define SS3_TCX_ADDR_MODE_MASK (0x7<<12)
|
||||
#define TEXCOORDMODE_WRAP 0
|
||||
#define TEXCOORDMODE_MIRROR 1
|
||||
#define TEXCOORDMODE_CLAMP_EDGE 2
|
||||
#define TEXCOORDMODE_CUBE 3
|
||||
#define TEXCOORDMODE_CLAMP_BORDER 4
|
||||
#define TEXCOORDMODE_MIRROR_ONCE 5
|
||||
#define SS3_TCY_ADDR_MODE_SHIFT 9
|
||||
#define SS3_TCY_ADDR_MODE_MASK (0x7<<9)
|
||||
#define SS3_TCZ_ADDR_MODE_SHIFT 6
|
||||
#define SS3_TCZ_ADDR_MODE_MASK (0x7<<6)
|
||||
#define SS3_NORMALIZED_COORDS (1<<5)
|
||||
#define SS3_TEXTUREMAP_INDEX_SHIFT 1
|
||||
#define SS3_TEXTUREMAP_INDEX_MASK (0xf<<1)
|
||||
#define SS3_DEINTERLACER_ENABLE (1<<0)
|
||||
|
||||
#define SS4_BORDER_COLOR_MASK (~0)
|
||||
|
||||
/* 3DSTATE_SPAN_STIPPLE, p258
|
||||
*/
|
||||
#define _3DSTATE_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
|
||||
#define ST1_ENABLE (1<<16)
|
||||
#define ST1_MASK (0xffff)
|
||||
|
||||
#define FLUSH_MAP_CACHE (1<<0)
|
||||
#define FLUSH_RENDER_CACHE (1<<1)
|
||||
|
||||
/* BLT commands */
|
||||
#define COLOR_BLT_CMD (CMD_2D | (0x40 << 22) | 3)
|
||||
#define XY_COLOR_BLT_CMD (CMD_2D | (0x50 << 22) | 4)
|
||||
#define XY_SETUP_CLIP_BLT_CMD (CMD_2D | (0x03 << 22) | 1)
|
||||
#define XY_SRC_COPY_BLT_CMD (CMD_2D | (0x53 << 22) | 6)
|
||||
#define SRC_COPY_BLT_CMD (CMD_2D | (0x43 << 22) | 4)
|
||||
|
||||
#define XY_MONO_PAT_BLT_CMD (CMD_2D | (0x52<<22)|0x7)
|
||||
#define XY_MONO_PAT_VERT_SEED ((1<<10) | (1<<9)|(1<<8))
|
||||
#define XY_MONO_PAT_HORT_SEED ((1<<14) | (1<<13)|(1<<12))
|
||||
#define XY_MONO_SRC_BLT_CMD (CMD_2D | (0x54<<22)|(0x6))
|
||||
|
||||
#define XY_SETUP_BLT_CMD (CMD_2D | (0x01 << 22) | 6)
|
||||
#define XY_TEXT_IMMEDIATE_BLIT_CMD (CMD_2D | (0x31 << 22))
|
||||
#define XY_TEXT_BYTE_PACKED (1 << 16)
|
||||
|
||||
/* BR00 */
|
||||
#define XY_BLT_WRITE_ALPHA (1 << 21)
|
||||
#define XY_BLT_WRITE_RGB (1 << 20)
|
||||
#define XY_SRC_TILED (1 << 15)
|
||||
#define XY_DST_TILED (1 << 11)
|
||||
|
||||
/* BR13 */
|
||||
#define BR13_565 (0x1 << 24)
|
||||
#define BR13_8888 (0x3 << 24)
|
||||
|
||||
#endif /* CAIRO_DRM_INTEL_COMMAND_PRIVATE_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,45 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_IOCTL_PRIVATE_H
|
||||
#define CAIRO_DRM_INTEL_IOCTL_PRIVATE_H
|
||||
|
||||
#include "cairo-drm-intel-command-private.h"
|
||||
|
||||
#include <drm/i915_drm.h>
|
||||
|
||||
struct drm_i915_gem_real_size {
|
||||
uint32_t handle;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
#define DRM_I915_GEM_REAL_SIZE 0x2a
|
||||
#define DRM_IOCTL_I915_GEM_REAL_SIZE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_REAL_SIZE, struct drm_i915_gem_real_size)
|
||||
|
||||
#endif /* CAIRO_DRM_INTEL_IOCTL_PRIVATE_H */
|
||||
|
|
@ -1,515 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_PRIVATE_H
|
||||
#define CAIRO_DRM_INTEL_PRIVATE_H
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-cache-private.h"
|
||||
#include "cairo-compiler-private.h"
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
#include "cairo-list-private.h"
|
||||
#include "cairo-mutex-private.h"
|
||||
#include "cairo-rtree-private.h"
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-pattern-private.h"
|
||||
|
||||
#include "cairo-drm-intel-ioctl-private.h"
|
||||
|
||||
#define INTEL_TILING_DEFAULT I915_TILING_Y
|
||||
|
||||
#define INTEL_BO_CACHE_BUCKETS 12 /* cache surfaces up to 16 MiB */
|
||||
|
||||
#define INTEL_GLYPH_CACHE_WIDTH 1024
|
||||
#define INTEL_GLYPH_CACHE_HEIGHT 1024
|
||||
#define INTEL_GLYPH_CACHE_MIN_SIZE 1
|
||||
#define INTEL_GLYPH_CACHE_MAX_SIZE 128
|
||||
|
||||
typedef struct _intel_bo {
|
||||
cairo_drm_bo_t base;
|
||||
|
||||
cairo_list_t link;
|
||||
cairo_list_t cache_list;
|
||||
|
||||
uint32_t offset;
|
||||
uint32_t batch_read_domains;
|
||||
uint32_t batch_write_domain;
|
||||
|
||||
uint32_t opaque0;
|
||||
uint32_t opaque1;
|
||||
|
||||
uint32_t full_size;
|
||||
uint16_t stride;
|
||||
uint16_t _stride;
|
||||
uint32_t tiling :4;
|
||||
uint32_t _tiling :4;
|
||||
uint32_t purgeable :1;
|
||||
uint32_t busy :1;
|
||||
uint32_t cpu :1;
|
||||
|
||||
struct drm_i915_gem_exec_object2 *exec;
|
||||
void *virtual;
|
||||
} intel_bo_t;
|
||||
|
||||
#define INTEL_BATCH_SIZE (64*1024)
|
||||
#define INTEL_VERTEX_BUFFER_SIZE (512*1024)
|
||||
#define INTEL_MAX_RELOCS 2048
|
||||
|
||||
static inline void
|
||||
intel_bo_mark_purgeable (intel_bo_t *bo)
|
||||
{
|
||||
if (bo->base.name == 0)
|
||||
bo->purgeable = 1;
|
||||
}
|
||||
|
||||
typedef struct _intel_vertex_buffer intel_vertex_buffer_t;
|
||||
|
||||
typedef void (*intel_vertex_buffer_new_func_t) (intel_vertex_buffer_t *vertex_buffer);
|
||||
typedef void (*intel_vertex_buffer_start_rectangles_func_t) (intel_vertex_buffer_t *vertex_buffer,
|
||||
uint32_t floats_per_vertex);
|
||||
typedef void (*intel_vertex_buffer_flush_func_t) (intel_vertex_buffer_t *vertex_buffer);
|
||||
typedef void (*intel_vertex_buffer_finish_func_t) (intel_vertex_buffer_t *vertex_buffer);
|
||||
|
||||
struct _intel_vertex_buffer {
|
||||
uint32_t vbo_batch; /* reloc position in batch, 0 -> not yet allocated */
|
||||
uint32_t vbo_offset;
|
||||
uint32_t vbo_used;
|
||||
|
||||
uint32_t vertex_index;
|
||||
uint32_t vertex_count;
|
||||
|
||||
uint32_t floats_per_vertex;
|
||||
uint32_t rectangle_size;
|
||||
|
||||
intel_bo_t *last_vbo;
|
||||
uint32_t last_vbo_offset;
|
||||
uint32_t last_vbo_space;
|
||||
|
||||
intel_vertex_buffer_new_func_t new;
|
||||
intel_vertex_buffer_start_rectangles_func_t start_rectangles;
|
||||
intel_vertex_buffer_flush_func_t flush;
|
||||
intel_vertex_buffer_finish_func_t finish;
|
||||
|
||||
uint32_t base[INTEL_VERTEX_BUFFER_SIZE / sizeof (uint32_t)];
|
||||
};
|
||||
|
||||
typedef struct _intel_batch intel_batch_t;
|
||||
|
||||
typedef void (*intel_batch_commit_func_t) (intel_batch_t *batch);
|
||||
typedef void (*intel_batch_reset_func_t) (intel_batch_t *batch);
|
||||
|
||||
struct _intel_batch {
|
||||
size_t gtt_size;
|
||||
size_t gtt_avail_size;
|
||||
|
||||
intel_batch_commit_func_t commit;
|
||||
intel_batch_reset_func_t reset;
|
||||
|
||||
uint16_t exec_count;
|
||||
uint16_t reloc_count;
|
||||
uint16_t used;
|
||||
uint16_t header;
|
||||
|
||||
intel_bo_t *target_bo[INTEL_MAX_RELOCS];
|
||||
struct drm_i915_gem_exec_object2 exec[INTEL_MAX_RELOCS];
|
||||
struct drm_i915_gem_relocation_entry reloc[INTEL_MAX_RELOCS];
|
||||
|
||||
uint32_t base[INTEL_BATCH_SIZE / sizeof (uint32_t)];
|
||||
|
||||
intel_vertex_buffer_t vertex_buffer;
|
||||
};
|
||||
|
||||
typedef struct _intel_buffer {
|
||||
intel_bo_t *bo;
|
||||
uint32_t offset;
|
||||
cairo_format_t format;
|
||||
uint32_t map0, map1;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride;
|
||||
} intel_buffer_t;
|
||||
|
||||
typedef struct _intel_buffer_cache {
|
||||
int ref_count;
|
||||
intel_buffer_t buffer;
|
||||
cairo_rtree_t rtree;
|
||||
cairo_list_t link;
|
||||
} intel_buffer_cache_t;
|
||||
|
||||
typedef struct _intel_glyph {
|
||||
cairo_rtree_node_t node;
|
||||
intel_buffer_cache_t *cache;
|
||||
void **owner;
|
||||
float texcoord[3];
|
||||
int width, height;
|
||||
} intel_glyph_t;
|
||||
|
||||
typedef struct _intel_gradient_cache {
|
||||
cairo_pattern_union_t pattern;
|
||||
intel_buffer_t buffer;
|
||||
} intel_gradient_cache_t;
|
||||
#define GRADIENT_CACHE_SIZE 16
|
||||
|
||||
typedef struct _intel_surface {
|
||||
cairo_drm_surface_t drm;
|
||||
|
||||
cairo_cache_entry_t snapshot_cache_entry;
|
||||
} intel_surface_t;
|
||||
|
||||
typedef void (*intel_reset_context_func_t) (void *device);
|
||||
|
||||
typedef struct _intel_device {
|
||||
cairo_drm_device_t base;
|
||||
|
||||
size_t gtt_max_size;
|
||||
size_t gtt_avail_size;
|
||||
|
||||
cairo_freepool_t bo_pool;
|
||||
cairo_list_t bo_in_flight;
|
||||
|
||||
cairo_mutex_t mutex;
|
||||
intel_batch_t batch;
|
||||
|
||||
intel_buffer_cache_t glyph_cache[2];
|
||||
cairo_list_t fonts;
|
||||
|
||||
struct {
|
||||
intel_gradient_cache_t cache[GRADIENT_CACHE_SIZE];
|
||||
unsigned int size;
|
||||
} gradient_cache;
|
||||
|
||||
cairo_cache_t snapshot_cache;
|
||||
size_t snapshot_cache_max_size;
|
||||
|
||||
intel_reset_context_func_t reset_context;
|
||||
|
||||
cairo_status_t (*flush) (struct _intel_device *);
|
||||
} intel_device_t;
|
||||
|
||||
static inline intel_device_t *
|
||||
to_intel_device (cairo_device_t *base)
|
||||
{
|
||||
return (intel_device_t *) base;
|
||||
}
|
||||
|
||||
static inline intel_bo_t *
|
||||
to_intel_bo (cairo_drm_bo_t *base)
|
||||
{
|
||||
return (intel_bo_t *) base;
|
||||
}
|
||||
|
||||
static inline intel_bo_t *
|
||||
intel_bo_reference (intel_bo_t *bo)
|
||||
{
|
||||
return to_intel_bo (cairo_drm_bo_reference (&bo->base));
|
||||
}
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_bo_madvise (intel_device_t *device, intel_bo_t *bo, int madv);
|
||||
|
||||
static cairo_always_inline void
|
||||
intel_bo_destroy (intel_device_t *device, intel_bo_t *bo)
|
||||
{
|
||||
cairo_drm_bo_destroy (&device->base.base, &bo->base);
|
||||
}
|
||||
|
||||
static inline void
|
||||
intel_bo_in_flight_add (intel_device_t *device,
|
||||
intel_bo_t *bo)
|
||||
{
|
||||
if (bo->base.name == 0 && bo->exec != NULL && cairo_list_is_empty (&bo->cache_list))
|
||||
cairo_list_add (&bo->cache_list, &device->bo_in_flight);
|
||||
}
|
||||
|
||||
cairo_private int
|
||||
intel_get (int fd, int param);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_info (int fd, uint64_t *gtt_size);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_device_init (intel_device_t *device, int fd);
|
||||
|
||||
cairo_private void
|
||||
intel_device_fini (intel_device_t *dev);
|
||||
|
||||
cairo_private intel_bo_t *
|
||||
intel_bo_create (intel_device_t *dev,
|
||||
uint32_t max_size,
|
||||
uint32_t real_size,
|
||||
cairo_bool_t gpu_target,
|
||||
uint32_t tiling,
|
||||
uint32_t stride);
|
||||
|
||||
cairo_private intel_bo_t *
|
||||
intel_bo_create_for_name (intel_device_t *dev, uint32_t name);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_set_tiling (const intel_device_t *dev,
|
||||
intel_bo_t *bo);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_bo_is_inactive (const intel_device_t *device,
|
||||
intel_bo_t *bo);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_bo_wait (const intel_device_t *device, const intel_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_write (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
const void *data);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_read (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
void *data);
|
||||
|
||||
cairo_private void *
|
||||
intel_bo_map (const intel_device_t *dev, intel_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_unmap (intel_bo_t *bo);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_bo_init (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
uint32_t size,
|
||||
uint32_t initial_domain);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_bo_init_for_name (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
uint32_t size,
|
||||
uint32_t name);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_bo_put_image (intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
cairo_image_surface_t *src,
|
||||
int src_x, int src_y,
|
||||
int width, int height,
|
||||
int dst_x, int dst_y);
|
||||
|
||||
cairo_private void
|
||||
intel_surface_init (intel_surface_t *surface,
|
||||
const cairo_surface_backend_t *backend,
|
||||
cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_buffer_cache_init (intel_buffer_cache_t *cache,
|
||||
intel_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_gradient_render (intel_device_t *device,
|
||||
const cairo_gradient_pattern_t *pattern,
|
||||
intel_buffer_t *buffer);
|
||||
|
||||
cairo_private cairo_int_status_t
|
||||
intel_get_glyph (intel_device_t *device,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_scaled_glyph_t *scaled_glyph);
|
||||
|
||||
cairo_private void
|
||||
intel_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_private void
|
||||
intel_scaled_font_fini (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_private void
|
||||
intel_glyph_cache_unpin (intel_device_t *device);
|
||||
|
||||
static inline intel_glyph_t *
|
||||
intel_glyph_pin (intel_glyph_t *glyph)
|
||||
{
|
||||
cairo_rtree_node_t *node = &glyph->node;
|
||||
if (unlikely (node->pinned == 0))
|
||||
return _cairo_rtree_pin (&glyph->cache->rtree, node);
|
||||
return glyph;
|
||||
}
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_snapshot_cache_insert (intel_device_t *device,
|
||||
intel_surface_t *surface);
|
||||
|
||||
cairo_private void
|
||||
intel_surface_detach_snapshot (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_private void
|
||||
intel_snapshot_cache_thaw (intel_device_t *device);
|
||||
|
||||
cairo_private void
|
||||
intel_throttle (intel_device_t *device);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra);
|
||||
|
||||
cairo_private void
|
||||
intel_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra);
|
||||
cairo_private cairo_surface_t *
|
||||
intel_surface_map_to_image (void *abstract_surface);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_surface_flush (void *abstract_surface,
|
||||
unsigned flags);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_surface_finish (void *abstract_surface);
|
||||
|
||||
cairo_private void
|
||||
intel_dump_batchbuffer (const void *batch,
|
||||
uint32_t length,
|
||||
int devid);
|
||||
|
||||
static inline uint32_t cairo_const
|
||||
MS3_tiling (uint32_t tiling)
|
||||
{
|
||||
switch (tiling) {
|
||||
default:
|
||||
case I915_TILING_NONE: return 0;
|
||||
case I915_TILING_X: return MS3_TILED_SURFACE;
|
||||
case I915_TILING_Y: return MS3_TILED_SURFACE | MS3_TILE_WALK;
|
||||
}
|
||||
}
|
||||
|
||||
static inline float cairo_const
|
||||
texcoord_2d_16 (double x, double y)
|
||||
{
|
||||
union {
|
||||
uint32_t ui;
|
||||
float f;
|
||||
} u;
|
||||
u.ui = (_cairo_half_from_float (y) << 16) | _cairo_half_from_float (x);
|
||||
return u.f;
|
||||
}
|
||||
|
||||
#define PCI_CHIP_I810 0x7121
|
||||
#define PCI_CHIP_I810_DC100 0x7123
|
||||
#define PCI_CHIP_I810_E 0x7125
|
||||
#define PCI_CHIP_I815 0x1132
|
||||
|
||||
#define PCI_CHIP_I830_M 0x3577
|
||||
#define PCI_CHIP_845_G 0x2562
|
||||
#define PCI_CHIP_I855_GM 0x3582
|
||||
#define PCI_CHIP_I865_G 0x2572
|
||||
|
||||
#define PCI_CHIP_I915_G 0x2582
|
||||
#define PCI_CHIP_E7221_G 0x258A
|
||||
#define PCI_CHIP_I915_GM 0x2592
|
||||
#define PCI_CHIP_I945_G 0x2772
|
||||
#define PCI_CHIP_I945_GM 0x27A2
|
||||
#define PCI_CHIP_I945_GME 0x27AE
|
||||
|
||||
#define PCI_CHIP_Q35_G 0x29B2
|
||||
#define PCI_CHIP_G33_G 0x29C2
|
||||
#define PCI_CHIP_Q33_G 0x29D2
|
||||
|
||||
#define PCI_CHIP_IGD_GM 0xA011
|
||||
#define PCI_CHIP_IGD_G 0xA001
|
||||
|
||||
#define IS_IGDGM(devid) (devid == PCI_CHIP_IGD_GM)
|
||||
#define IS_IGDG(devid) (devid == PCI_CHIP_IGD_G)
|
||||
#define IS_IGD(devid) (IS_IGDG(devid) || IS_IGDGM(devid))
|
||||
|
||||
#define PCI_CHIP_I965_G 0x29A2
|
||||
#define PCI_CHIP_I965_Q 0x2992
|
||||
#define PCI_CHIP_I965_G_1 0x2982
|
||||
#define PCI_CHIP_I946_GZ 0x2972
|
||||
#define PCI_CHIP_I965_GM 0x2A02
|
||||
#define PCI_CHIP_I965_GME 0x2A12
|
||||
|
||||
#define PCI_CHIP_GM45_GM 0x2A42
|
||||
|
||||
#define PCI_CHIP_IGD_E_G 0x2E02
|
||||
#define PCI_CHIP_Q45_G 0x2E12
|
||||
#define PCI_CHIP_G45_G 0x2E22
|
||||
#define PCI_CHIP_G41_G 0x2E32
|
||||
|
||||
#define PCI_CHIP_ILD_G 0x0042
|
||||
#define PCI_CHIP_ILM_G 0x0046
|
||||
|
||||
#define IS_MOBILE(devid) (devid == PCI_CHIP_I855_GM || \
|
||||
devid == PCI_CHIP_I915_GM || \
|
||||
devid == PCI_CHIP_I945_GM || \
|
||||
devid == PCI_CHIP_I945_GME || \
|
||||
devid == PCI_CHIP_I965_GM || \
|
||||
devid == PCI_CHIP_I965_GME || \
|
||||
devid == PCI_CHIP_GM45_GM || IS_IGD(devid))
|
||||
|
||||
#define IS_G45(devid) (devid == PCI_CHIP_IGD_E_G || \
|
||||
devid == PCI_CHIP_Q45_G || \
|
||||
devid == PCI_CHIP_G45_G || \
|
||||
devid == PCI_CHIP_G41_G)
|
||||
#define IS_GM45(devid) (devid == PCI_CHIP_GM45_GM)
|
||||
#define IS_G4X(devid) (IS_G45(devid) || IS_GM45(devid))
|
||||
|
||||
#define IS_ILD(devid) (devid == PCI_CHIP_ILD_G)
|
||||
#define IS_ILM(devid) (devid == PCI_CHIP_ILM_G)
|
||||
#define IS_IRONLAKE(devid) (IS_ILD(devid) || IS_ILM(devid))
|
||||
|
||||
#define IS_915(devid) (devid == PCI_CHIP_I915_G || \
|
||||
devid == PCI_CHIP_E7221_G || \
|
||||
devid == PCI_CHIP_I915_GM)
|
||||
|
||||
#define IS_945(devid) (devid == PCI_CHIP_I945_G || \
|
||||
devid == PCI_CHIP_I945_GM || \
|
||||
devid == PCI_CHIP_I945_GME || \
|
||||
devid == PCI_CHIP_G33_G || \
|
||||
devid == PCI_CHIP_Q33_G || \
|
||||
devid == PCI_CHIP_Q35_G || IS_IGD(devid))
|
||||
|
||||
#define IS_965(devid) (devid == PCI_CHIP_I965_G || \
|
||||
devid == PCI_CHIP_I965_Q || \
|
||||
devid == PCI_CHIP_I965_G_1 || \
|
||||
devid == PCI_CHIP_I965_GM || \
|
||||
devid == PCI_CHIP_I965_GME || \
|
||||
devid == PCI_CHIP_I946_GZ || \
|
||||
IS_G4X(devid) || \
|
||||
IS_IRONLAKE(devid))
|
||||
|
||||
#define IS_9XX(devid) (IS_915(devid) || \
|
||||
IS_945(devid) || \
|
||||
IS_965(devid))
|
||||
|
||||
|
||||
#endif /* CAIRO_DRM_INTEL_PRIVATE_H */
|
||||
|
|
@ -1,454 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-drm-intel-private.h"
|
||||
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
/* Basic generic/stub surface for intel chipsets */
|
||||
|
||||
#define MAX_SIZE 2048
|
||||
|
||||
static cairo_surface_t *
|
||||
intel_surface_create_similar (void *abstract_surface,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return cairo_image_surface_create (_cairo_format_from_content (content),
|
||||
width, height);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
intel_surface_finish (void *abstract_surface)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
|
||||
intel_bo_in_flight_add (to_intel_device (surface->drm.base.device),
|
||||
to_intel_bo (surface->drm.bo));
|
||||
return _cairo_drm_surface_finish (&surface->drm);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_finish_and_destroy (cairo_surface_t *surface)
|
||||
{
|
||||
cairo_surface_finish (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
intel_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *ptr;
|
||||
|
||||
if (surface->drm.fallback != NULL) {
|
||||
image = surface->drm.fallback;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
image = _cairo_surface_has_snapshot (&surface->drm.base,
|
||||
&_cairo_image_surface_backend);
|
||||
if (image != NULL)
|
||||
goto DONE;
|
||||
|
||||
if (surface->drm.base.backend->flush != NULL) {
|
||||
status = surface->drm.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
}
|
||||
|
||||
ptr = intel_bo_map (to_intel_device (surface->drm.base.device),
|
||||
to_intel_bo (surface->drm.bo));
|
||||
if (unlikely (ptr == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr,
|
||||
surface->drm.format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->drm.stride);
|
||||
if (unlikely (image->status))
|
||||
return image->status;
|
||||
|
||||
_cairo_surface_attach_snapshot (&surface->drm.base, image, surface_finish_and_destroy);
|
||||
|
||||
DONE:
|
||||
*image_out = (cairo_image_surface_t *) cairo_surface_reference (image);
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
intel_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
intel_surface_map_to_image (void *abstract_surface)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->drm.fallback == NULL) {
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *ptr;
|
||||
|
||||
if (surface->drm.base.backend->flush != NULL) {
|
||||
status = surface->drm.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
ptr = intel_bo_map (to_intel_device (surface->drm.base.device),
|
||||
to_intel_bo (surface->drm.bo));
|
||||
if (unlikely (ptr == NULL))
|
||||
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr,
|
||||
surface->drm.format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->drm.stride);
|
||||
if (unlikely (image->status))
|
||||
return image;
|
||||
|
||||
surface->drm.fallback = image;
|
||||
}
|
||||
|
||||
return surface->drm.fallback;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
intel_surface_flush (void *abstract_surface, unsigned flags)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
cairo_status_t status;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->drm.fallback == NULL)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* kill any outstanding maps */
|
||||
cairo_surface_finish (surface->drm.fallback);
|
||||
|
||||
status = cairo_surface_status (surface->drm.fallback);
|
||||
cairo_surface_destroy (surface->drm.fallback);
|
||||
surface->drm.fallback = NULL;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_paint (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_paint (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_mask (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const cairo_pattern_t *mask,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_mask (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, mask, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_stroke (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *stroke_style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_stroke (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, path, stroke_style, ctm, ctm_inverse,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_fill (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_fill (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, path, fill_rule,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
*num_remaining = 0;
|
||||
return _cairo_surface_show_text_glyphs (intel_surface_map_to_image (abstract_surface),
|
||||
op, source,
|
||||
NULL, 0,
|
||||
glyphs, num_glyphs,
|
||||
NULL, 0, 0,
|
||||
scaled_font, clip);
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t intel_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DRM,
|
||||
_cairo_default_context_create,
|
||||
|
||||
intel_surface_create_similar,
|
||||
intel_surface_finish,
|
||||
|
||||
NULL,
|
||||
intel_surface_acquire_source_image,
|
||||
intel_surface_release_source_image,
|
||||
|
||||
NULL, NULL, NULL,
|
||||
NULL, /* composite */
|
||||
NULL, /* fill */
|
||||
NULL, /* trapezoids */
|
||||
NULL, /* span */
|
||||
NULL, /* check-span */
|
||||
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_drm_surface_get_extents,
|
||||
NULL, /* old-glyphs */
|
||||
_cairo_drm_surface_get_font_options,
|
||||
|
||||
intel_surface_flush,
|
||||
NULL, /* mark dirty */
|
||||
NULL, NULL, /* font/glyph fini */
|
||||
|
||||
intel_surface_paint,
|
||||
intel_surface_mask,
|
||||
intel_surface_stroke,
|
||||
intel_surface_fill,
|
||||
intel_surface_glyphs,
|
||||
};
|
||||
|
||||
void
|
||||
intel_surface_init (intel_surface_t *surface,
|
||||
const cairo_surface_backend_t *backend,
|
||||
cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
_cairo_surface_init (&surface->drm.base,
|
||||
backend,
|
||||
&device->base,
|
||||
_cairo_content_from_format (format),
|
||||
FALSE);
|
||||
|
||||
_cairo_drm_surface_init (&surface->drm, format, width, height);
|
||||
|
||||
surface->snapshot_cache_entry.hash = 0;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
intel_surface_create (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
intel_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = _cairo_malloc (sizeof (intel_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
intel_surface_init (surface, &intel_surface_backend, device,
|
||||
format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
/* Vol I, p134: size restrictions for textures */
|
||||
width = (width + 3) & -4;
|
||||
height = (height + 1) & -2;
|
||||
surface->drm.stride =
|
||||
cairo_format_stride_for_width (surface->drm.format, width);
|
||||
surface->drm.bo = &intel_bo_create (to_intel_device (&device->base),
|
||||
surface->drm.stride * height,
|
||||
surface->drm.stride * height,
|
||||
TRUE, I915_TILING_NONE, surface->drm.stride)->base;
|
||||
if (surface->drm.bo == NULL) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
intel_surface_create_for_name (cairo_drm_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
intel_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_A8:
|
||||
break;
|
||||
}
|
||||
|
||||
if (stride < cairo_format_stride_for_width (format, width))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
|
||||
surface = _cairo_malloc (sizeof (intel_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
intel_surface_init (surface, &intel_surface_backend,
|
||||
device, format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
surface->drm.stride = stride;
|
||||
|
||||
surface->drm.bo = &intel_bo_create_for_name (to_intel_device (&device->base),
|
||||
name)->base;
|
||||
if (unlikely (surface->drm.bo == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error
|
||||
(CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
intel_surface_enable_scan_out (void *abstract_surface)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
|
||||
if (unlikely (surface->drm.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_INVALID_SIZE);
|
||||
|
||||
to_intel_bo (surface->drm.bo)->tiling = I915_TILING_X;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_device_throttle (cairo_drm_device_t *device)
|
||||
{
|
||||
intel_throttle (to_intel_device (&device->base));
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
intel_device_destroy (void *data)
|
||||
{
|
||||
intel_device_t *device = data;
|
||||
|
||||
intel_device_fini (device);
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_intel_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
|
||||
{
|
||||
intel_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (! intel_info (fd, NULL))
|
||||
return NULL;
|
||||
|
||||
device = _cairo_malloc (sizeof (intel_device_t));
|
||||
if (unlikely (device == NULL))
|
||||
return (cairo_drm_device_t *) _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
status = intel_device_init (device, fd);
|
||||
if (unlikely (status)) {
|
||||
free (device);
|
||||
return (cairo_drm_device_t *) _cairo_device_create_in_error (status);
|
||||
}
|
||||
|
||||
device->base.surface.create = intel_surface_create;
|
||||
device->base.surface.create_for_name = intel_surface_create_for_name;
|
||||
device->base.surface.create_from_cacheable_image = NULL;
|
||||
device->base.surface.flink = _cairo_drm_surface_flink;
|
||||
device->base.surface.enable_scan_out = intel_surface_enable_scan_out;
|
||||
|
||||
device->base.surface.map_to_image = intel_surface_map_to_image;
|
||||
|
||||
device->base.device.flush = NULL;
|
||||
device->base.device.throttle = intel_device_throttle;
|
||||
device->base.device.destroy = intel_device_destroy;
|
||||
|
||||
return _cairo_drm_device_init (&device->base,
|
||||
fd, dev,
|
||||
vendor_id, chip_id,
|
||||
MAX_SIZE);
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,238 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*
|
||||
* Contributors(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_PRIVATE_H
|
||||
#define CAIRO_DRM_PRIVATE_H
|
||||
|
||||
#include "cairo-drm.h"
|
||||
|
||||
#include "cairo-device-private.h"
|
||||
#include "cairo-reference-count-private.h"
|
||||
#include "cairo-surface-private.h"
|
||||
|
||||
#include <sys/types.h> /* dev_t */
|
||||
|
||||
typedef struct _cairo_drm_device cairo_drm_device_t;
|
||||
|
||||
typedef cairo_drm_device_t *
|
||||
(*cairo_drm_device_create_func_t) (int fd,
|
||||
dev_t dev,
|
||||
int vendor_id,
|
||||
int chip_id);
|
||||
|
||||
typedef cairo_int_status_t
|
||||
(*cairo_drm_device_flush_func_t) (cairo_drm_device_t *device);
|
||||
|
||||
typedef cairo_int_status_t
|
||||
(*cairo_drm_device_throttle_func_t) (cairo_drm_device_t *device);
|
||||
|
||||
typedef void
|
||||
(*cairo_drm_device_destroy_func_t) (void *data);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_create_func_t) (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_create_for_name_func_t) (cairo_drm_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_create_from_cacheable_image_func_t)
|
||||
(cairo_drm_device_t *device, cairo_surface_t *image);
|
||||
|
||||
typedef cairo_int_status_t
|
||||
(*cairo_drm_surface_flink_func_t) (void *surface);
|
||||
|
||||
typedef cairo_status_t
|
||||
(*cairo_drm_surface_enable_scan_out_func_t) (void *surface);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_map_to_image_func_t) (void *surface);
|
||||
|
||||
typedef struct _cairo_drm_bo_backend {
|
||||
void (*release) (void *device, void *bo);
|
||||
} cairo_drm_bo_backend_t;
|
||||
|
||||
typedef struct _cairo_drm_device_backend {
|
||||
cairo_drm_device_flush_func_t flush;
|
||||
cairo_drm_device_throttle_func_t throttle;
|
||||
cairo_drm_device_destroy_func_t destroy;
|
||||
} cairo_drm_device_backend_t;
|
||||
|
||||
typedef struct _cairo_drm_surface_backend {
|
||||
cairo_drm_surface_create_func_t create;
|
||||
cairo_drm_surface_create_for_name_func_t create_for_name;
|
||||
cairo_drm_surface_create_from_cacheable_image_func_t create_from_cacheable_image;
|
||||
cairo_drm_surface_flink_func_t flink;
|
||||
cairo_drm_surface_enable_scan_out_func_t enable_scan_out;
|
||||
cairo_drm_surface_map_to_image_func_t map_to_image;
|
||||
} cairo_drm_surface_backend_t;
|
||||
|
||||
typedef struct _cairo_drm_bo {
|
||||
cairo_reference_count_t ref_count;
|
||||
uint32_t name;
|
||||
uint32_t handle;
|
||||
uint32_t size;
|
||||
} cairo_drm_bo_t;
|
||||
|
||||
struct _cairo_drm_device {
|
||||
cairo_device_t base;
|
||||
|
||||
int vendor_id;
|
||||
int chip_id;
|
||||
dev_t id;
|
||||
int fd;
|
||||
|
||||
int max_surface_size;
|
||||
|
||||
cairo_drm_bo_backend_t bo;
|
||||
cairo_drm_surface_backend_t surface;
|
||||
cairo_drm_device_backend_t device;
|
||||
|
||||
cairo_drm_device_t *next, *prev;
|
||||
};
|
||||
|
||||
typedef struct _cairo_drm_surface {
|
||||
cairo_surface_t base;
|
||||
|
||||
cairo_drm_bo_t *bo;
|
||||
|
||||
cairo_format_t format;
|
||||
int width, height, stride;
|
||||
|
||||
cairo_surface_t *fallback;
|
||||
uint32_t map_count;
|
||||
} cairo_drm_surface_t;
|
||||
|
||||
static inline cairo_drm_bo_t *
|
||||
cairo_drm_bo_reference (cairo_drm_bo_t *bo)
|
||||
{
|
||||
_cairo_reference_count_inc (&bo->ref_count);
|
||||
return bo;
|
||||
}
|
||||
|
||||
static cairo_always_inline void
|
||||
cairo_drm_bo_destroy (cairo_device_t *abstract_device,
|
||||
cairo_drm_bo_t *bo)
|
||||
{
|
||||
if (_cairo_reference_count_dec_and_test (&bo->ref_count)) {
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
device->bo.release (device, bo);
|
||||
}
|
||||
}
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_drm_bo_open_for_name (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo,
|
||||
uint32_t name);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_drm_bo_flink (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_bo_close (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_surface_init (cairo_drm_surface_t *surface,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_drm_surface_finish (cairo_drm_surface_t *surface);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_surface_get_font_options (void *abstract_surface,
|
||||
cairo_font_options_t *options);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_drm_surface_get_extents (void *abstract_surface,
|
||||
cairo_rectangle_int_t *rectangle);
|
||||
|
||||
cairo_private cairo_int_status_t
|
||||
_cairo_drm_surface_flink (void *abstract_surface);
|
||||
|
||||
static inline cairo_drm_device_t *
|
||||
_cairo_drm_device_create_in_error (cairo_status_t status)
|
||||
{
|
||||
return (cairo_drm_device_t *) _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_device_init (cairo_drm_device_t *device,
|
||||
int fd,
|
||||
dev_t devid,
|
||||
int vendor_id,
|
||||
int chip_id,
|
||||
int max_surface_size);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_device_fini (cairo_drm_device_t *device);
|
||||
|
||||
/* h/w specific backends */
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_intel_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_i915_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_i965_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_radeon_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
#if CAIRO_HAS_GALLIUM_SURFACE
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
#endif
|
||||
|
||||
slim_hidden_proto (cairo_drm_device_default);
|
||||
slim_hidden_proto (cairo_drm_device_get);
|
||||
slim_hidden_proto (cairo_drm_device_get_for_fd);
|
||||
|
||||
slim_hidden_proto (cairo_drm_surface_create_for_name);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_drm_size_is_valid (cairo_device_t *abstract_device,
|
||||
int width, int height);
|
||||
|
||||
#endif /* CAIRO_DRM_PRIVATE_H */
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_RADEON_PRIVATE_H
|
||||
#define CAIRO_DRM_RADEON_PRIVATE_H
|
||||
|
||||
#include "cairo-compiler-private.h"
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
|
||||
typedef struct _radeon_bo {
|
||||
cairo_drm_bo_t base;
|
||||
|
||||
void *virtual;
|
||||
|
||||
cairo_bool_t in_batch;
|
||||
uint32_t read_domains;
|
||||
uint32_t write_domain;
|
||||
} radeon_bo_t;
|
||||
|
||||
typedef struct _radeon_device {
|
||||
cairo_drm_device_t base;
|
||||
cairo_freepool_t bo_pool;
|
||||
|
||||
uint64_t vram_limit;
|
||||
uint64_t gart_limit;
|
||||
} radeon_device_t;
|
||||
|
||||
cairo_private cairo_status_t
|
||||
radeon_device_init (radeon_device_t *device, int fd);
|
||||
|
||||
cairo_private void
|
||||
radeon_device_fini (radeon_device_t *device);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
radeon_info (int fd,
|
||||
uint64_t *gart_size,
|
||||
uint64_t *vram_size);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_write (const radeon_device_t *dev,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
const void *data);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_read (const radeon_device_t *dev,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
void *data);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_wait (const radeon_device_t *dev, radeon_bo_t *bo);
|
||||
|
||||
cairo_private void *
|
||||
radeon_bo_map (const radeon_device_t *dev, radeon_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_unmap (radeon_bo_t *bo);
|
||||
|
||||
cairo_private cairo_drm_bo_t *
|
||||
radeon_bo_create (radeon_device_t *dev,
|
||||
uint32_t size,
|
||||
uint32_t initial_domain);
|
||||
|
||||
cairo_private cairo_drm_bo_t *
|
||||
radeon_bo_create_for_name (radeon_device_t *dev, uint32_t name);
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
radeon_bo_get_image (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
const cairo_drm_surface_t *surface);
|
||||
|
||||
#endif /* CAIRO_DRM_RADEON_PRIVATE_H */
|
||||
|
|
@ -1,454 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-drm-radeon-private.h"
|
||||
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h> /* workaround for broken <drm/radeon_drm.h> */
|
||||
#include <drm/radeon_drm.h>
|
||||
|
||||
/* Basic stub surface for radeon chipsets */
|
||||
|
||||
#define MAX_SIZE 2048
|
||||
|
||||
typedef struct _radeon_surface {
|
||||
cairo_drm_surface_t base;
|
||||
} radeon_surface_t;
|
||||
|
||||
static inline radeon_device_t *
|
||||
to_radeon_device (cairo_device_t *device)
|
||||
{
|
||||
return (radeon_device_t *) device;
|
||||
}
|
||||
|
||||
static inline radeon_bo_t *
|
||||
to_radeon_bo (cairo_drm_bo_t *bo)
|
||||
{
|
||||
return (radeon_bo_t *) bo;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create_similar (void *abstract_surface,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return cairo_image_surface_create (_cairo_format_from_content (content),
|
||||
width, height);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
radeon_surface_finish (void *abstract_surface)
|
||||
{
|
||||
radeon_surface_t *surface = abstract_surface;
|
||||
|
||||
return _cairo_drm_surface_finish (&surface->base);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
radeon_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
radeon_surface_t *surface = abstract_surface;
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
|
||||
/* XXX batch flush */
|
||||
|
||||
if (surface->base.fallback != NULL) {
|
||||
image = surface->base.fallback;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
image = _cairo_surface_has_snapshot (&surface->base.base,
|
||||
&_cairo_image_surface_backend);
|
||||
if (image != NULL)
|
||||
goto DONE;
|
||||
|
||||
if (surface->base.base.backend->flush != NULL) {
|
||||
status = surface->base.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
}
|
||||
|
||||
image = radeon_bo_get_image (to_radeon_device (surface->base.base.device),
|
||||
to_radeon_bo (surface->base.bo),
|
||||
&surface->base);
|
||||
status = image->status;
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
_cairo_surface_attach_snapshot (&surface->base.base, image, cairo_surface_destroy);
|
||||
|
||||
DONE:
|
||||
*image_out = (cairo_image_surface_t *) cairo_surface_reference (image);
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
radeon_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_map_to_image (radeon_surface_t *surface)
|
||||
{
|
||||
if (surface->base.fallback == NULL) {
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *ptr;
|
||||
|
||||
if (surface->base.base.backend->flush != NULL) {
|
||||
status = surface->base.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
ptr = radeon_bo_map (to_radeon_device (surface->base.base.device),
|
||||
to_radeon_bo (surface->base.bo));
|
||||
if (unlikely (ptr == NULL))
|
||||
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr,
|
||||
surface->base.format,
|
||||
surface->base.width,
|
||||
surface->base.height,
|
||||
surface->base.stride);
|
||||
if (unlikely (image->status)) {
|
||||
radeon_bo_unmap (to_radeon_bo (surface->base.bo));
|
||||
return image;
|
||||
}
|
||||
|
||||
surface->base.fallback = image;
|
||||
}
|
||||
|
||||
return surface->base.fallback;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
radeon_surface_flush (void *abstract_surface,
|
||||
unsigned flags)
|
||||
{
|
||||
radeon_surface_t *surface = abstract_surface;
|
||||
cairo_status_t status;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->base.fallback == NULL)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* kill any outstanding maps */
|
||||
cairo_surface_finish (surface->base.fallback);
|
||||
|
||||
status = cairo_surface_status (surface->base.fallback);
|
||||
cairo_surface_destroy (surface->base.fallback);
|
||||
surface->base.fallback = NULL;
|
||||
|
||||
radeon_bo_unmap (to_radeon_bo (surface->base.bo));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_paint (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_paint (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_mask (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const cairo_pattern_t *mask,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_mask (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, mask, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_stroke (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *stroke_style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_stroke (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, path, stroke_style, ctm, ctm_inverse,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_fill (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_fill (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, path, fill_rule,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
*num_remaining = 0;
|
||||
return _cairo_surface_show_text_glyphs (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source,
|
||||
NULL, 0,
|
||||
glyphs, num_glyphs,
|
||||
NULL, 0, 0,
|
||||
scaled_font, clip);
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t radeon_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DRM,
|
||||
_cairo_default_context_create,
|
||||
|
||||
radeon_surface_create_similar,
|
||||
radeon_surface_finish,
|
||||
|
||||
NULL,
|
||||
radeon_surface_acquire_source_image,
|
||||
radeon_surface_release_source_image,
|
||||
|
||||
NULL, NULL, NULL,
|
||||
NULL, /* composite */
|
||||
NULL, /* fill */
|
||||
NULL, /* trapezoids */
|
||||
NULL, /* span */
|
||||
NULL, /* check-span */
|
||||
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_drm_surface_get_extents,
|
||||
NULL, /* old-glyphs */
|
||||
_cairo_drm_surface_get_font_options,
|
||||
|
||||
radeon_surface_flush,
|
||||
NULL, /* mark dirty */
|
||||
NULL, NULL, /* font/glyph fini */
|
||||
|
||||
radeon_surface_paint,
|
||||
radeon_surface_mask,
|
||||
radeon_surface_stroke,
|
||||
radeon_surface_fill,
|
||||
radeon_surface_glyphs,
|
||||
};
|
||||
|
||||
static void
|
||||
radeon_surface_init (radeon_surface_t *surface,
|
||||
cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
_cairo_surface_init (&surface->base.base,
|
||||
&radeon_surface_backend,
|
||||
&device->base,
|
||||
_cairo_content_from_format (format),
|
||||
FALSE);
|
||||
_cairo_drm_surface_init (&surface->base, format, width, height);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create_internal (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
radeon_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = _cairo_malloc (sizeof (radeon_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
radeon_surface_init (surface, device, format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
surface->base.stride =
|
||||
cairo_format_stride_for_width (surface->base.format, width);
|
||||
|
||||
surface->base.bo = radeon_bo_create (to_radeon_device (&device->base),
|
||||
surface->base.stride * height,
|
||||
RADEON_GEM_DOMAIN_GTT);
|
||||
|
||||
if (unlikely (surface->base.bo == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->base.base;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_A8:
|
||||
break;
|
||||
}
|
||||
|
||||
return radeon_surface_create_internal (device, format, width, height);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create_for_name (cairo_drm_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
radeon_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_A8:
|
||||
break;
|
||||
}
|
||||
|
||||
if (stride < cairo_format_stride_for_width (format, width))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
|
||||
surface = _cairo_malloc (sizeof (radeon_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
radeon_surface_init (surface, device, format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
surface->base.stride = stride;
|
||||
|
||||
surface->base.bo = radeon_bo_create_for_name (to_radeon_device (&device->base),
|
||||
name);
|
||||
|
||||
if (unlikely (surface->base.bo == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->base.base;
|
||||
}
|
||||
|
||||
static void
|
||||
radeon_device_destroy (void *data)
|
||||
{
|
||||
radeon_device_t *device = data;
|
||||
|
||||
radeon_device_fini (device);
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_radeon_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
|
||||
{
|
||||
radeon_device_t *device;
|
||||
uint64_t gart_size, vram_size;
|
||||
cairo_status_t status;
|
||||
|
||||
if (! radeon_info (fd, &gart_size, &vram_size))
|
||||
return NULL;
|
||||
|
||||
device = _cairo_malloc (sizeof (radeon_device_t));
|
||||
if (device == NULL)
|
||||
return _cairo_drm_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
status = radeon_device_init (device, fd);
|
||||
if (unlikely (status)) {
|
||||
free (device);
|
||||
return _cairo_drm_device_create_in_error (status);
|
||||
}
|
||||
|
||||
device->base.surface.create = radeon_surface_create;
|
||||
device->base.surface.create_for_name = radeon_surface_create_for_name;
|
||||
device->base.surface.create_from_cacheable_image = NULL;
|
||||
device->base.surface.flink = _cairo_drm_surface_flink;
|
||||
device->base.surface.enable_scan_out = NULL;
|
||||
|
||||
device->base.device.flush = NULL;
|
||||
device->base.device.throttle = NULL;
|
||||
device->base.device.destroy = radeon_device_destroy;
|
||||
|
||||
device->vram_limit = vram_size;
|
||||
device->gart_limit = gart_size;
|
||||
|
||||
return _cairo_drm_device_init (&device->base, fd, dev, vendor_id, chip_id, MAX_SIZE);
|
||||
}
|
||||
|
|
@ -1,331 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-drm-radeon-private.h"
|
||||
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
#include <drm/radeon_drm.h>
|
||||
|
||||
cairo_bool_t
|
||||
radeon_info (int fd,
|
||||
uint64_t *gart_size,
|
||||
uint64_t *vram_size)
|
||||
{
|
||||
struct drm_radeon_gem_info info;
|
||||
int ret;
|
||||
|
||||
ret = ioctl (fd, DRM_IOCTL_RADEON_GEM_INFO, &info);
|
||||
if (ret == -1)
|
||||
return FALSE;
|
||||
|
||||
if (gart_size != NULL)
|
||||
*gart_size = info.gart_size;
|
||||
|
||||
if (vram_size != NULL)
|
||||
*vram_size = info.vram_size;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_write (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
const void *data)
|
||||
{
|
||||
struct drm_radeon_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
memset (&pwrite, 0, sizeof (pwrite));
|
||||
pwrite.handle = bo->base.handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uint64_t) (uintptr_t) data;
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_PWRITE, &pwrite);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
/* XXX temporary workaround */
|
||||
if (ret == -1 && errno == ENOSYS) {
|
||||
uint8_t *ptr;
|
||||
|
||||
ptr = radeon_bo_map (device, bo);
|
||||
if (ptr != NULL) {
|
||||
memcpy (ptr + offset, data, size);
|
||||
radeon_bo_unmap (bo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_read (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
void *data)
|
||||
{
|
||||
struct drm_radeon_gem_pread pread;
|
||||
int ret;
|
||||
|
||||
memset (&pread, 0, sizeof (pread));
|
||||
pread.handle = bo->base.handle;
|
||||
pread.offset = offset;
|
||||
pread.size = size;
|
||||
pread.data_ptr = (uint64_t) (uintptr_t) data;
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_PREAD, &pread);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
/* XXX temporary workaround */
|
||||
if (ret == -1 && errno == ENOSYS) {
|
||||
uint8_t *ptr;
|
||||
|
||||
ptr = radeon_bo_map (device, bo);
|
||||
if (ptr != NULL) {
|
||||
memcpy (data, ptr + offset, size);
|
||||
radeon_bo_unmap (bo);
|
||||
}
|
||||
}
|
||||
|
||||
VG (VALGRIND_MAKE_MEM_DEFINED (data, size));
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_wait (const radeon_device_t *device, radeon_bo_t *bo)
|
||||
{
|
||||
struct drm_radeon_gem_wait_idle wait;
|
||||
int ret;
|
||||
|
||||
wait.handle = bo->base.handle;
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_WAIT_IDLE, &wait);
|
||||
} while (ret == -1 && (errno == EINTR || errno == EBUSY));
|
||||
}
|
||||
|
||||
void *
|
||||
radeon_bo_map (const radeon_device_t *device, radeon_bo_t *bo)
|
||||
{
|
||||
struct drm_radeon_gem_mmap mmap_arg;
|
||||
void *ptr;
|
||||
int ret;
|
||||
|
||||
assert (bo->virtual == NULL);
|
||||
|
||||
memset (&mmap_arg, 0, sizeof (mmap_arg));
|
||||
mmap_arg.handle = bo->base.handle;
|
||||
mmap_arg.offset = 0;
|
||||
mmap_arg.size = bo->base.size;
|
||||
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_MMAP, &mmap_arg);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (unlikely (ret != 0)) {
|
||||
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VG (VALGRIND_MAKE_MEM_DEFINED (&mmap_arg, sizeof (mmap_arg)));
|
||||
|
||||
/* and mmap it */
|
||||
ptr = mmap (0, bo->base.size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, device->base.fd,
|
||||
mmap_arg.addr_ptr);
|
||||
if (unlikely (ptr == MAP_FAILED)) {
|
||||
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo->virtual = ptr;
|
||||
|
||||
/* XXX set_domain? */
|
||||
return bo->virtual;
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_unmap (radeon_bo_t *bo)
|
||||
{
|
||||
assert (bo->virtual != NULL);
|
||||
|
||||
munmap (bo->virtual, bo->base.size);
|
||||
bo->virtual = NULL;
|
||||
}
|
||||
|
||||
cairo_drm_bo_t *
|
||||
radeon_bo_create (radeon_device_t *device,
|
||||
uint32_t size,
|
||||
uint32_t initial_domain)
|
||||
{
|
||||
struct drm_radeon_gem_create create;
|
||||
radeon_bo_t *bo;
|
||||
int ret;
|
||||
|
||||
bo = _cairo_freepool_alloc (&device->bo_pool);
|
||||
if (unlikely (bo == NULL))
|
||||
return NULL;
|
||||
|
||||
create.size = size;
|
||||
create.alignment = 0;
|
||||
create.initial_domain = initial_domain;
|
||||
create.flags = 0;
|
||||
create.handle = 0;
|
||||
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_CREATE, &create);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (ret == -1) {
|
||||
_cairo_freepool_free (&device->bo_pool, bo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo->base.handle = create.handle;
|
||||
bo->base.size = size;
|
||||
|
||||
bo->virtual = NULL;
|
||||
|
||||
bo->in_batch = FALSE;
|
||||
bo->read_domains = 0;
|
||||
bo->write_domain = 0;
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&bo->base.ref_count, 1);
|
||||
return &bo->base;
|
||||
}
|
||||
|
||||
cairo_drm_bo_t *
|
||||
radeon_bo_create_for_name (radeon_device_t *device,
|
||||
uint32_t name)
|
||||
{
|
||||
radeon_bo_t *bo;
|
||||
cairo_status_t status;
|
||||
|
||||
bo = _cairo_freepool_alloc (&device->bo_pool);
|
||||
if (unlikely (bo == NULL))
|
||||
return NULL;
|
||||
|
||||
status = _cairo_drm_bo_open_for_name (&device->base, &bo->base, name);
|
||||
if (unlikely (status)) {
|
||||
_cairo_freepool_free (&device->bo_pool, bo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo->virtual = NULL;
|
||||
|
||||
bo->in_batch = FALSE;
|
||||
bo->read_domains = 0;
|
||||
bo->write_domain = 0;
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&bo->base.ref_count, 1);
|
||||
return &bo->base;
|
||||
}
|
||||
|
||||
static void
|
||||
radeon_bo_release (void *_dev, void *_bo)
|
||||
{
|
||||
radeon_device_t *device = _dev;
|
||||
radeon_bo_t *bo = _bo;
|
||||
|
||||
_cairo_drm_bo_close (&device->base, &bo->base);
|
||||
_cairo_freepool_free (&device->bo_pool, bo);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
radeon_bo_get_image (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
const cairo_drm_surface_t *surface)
|
||||
{
|
||||
cairo_image_surface_t *image;
|
||||
uint8_t *dst;
|
||||
int size, row;
|
||||
|
||||
image = (cairo_image_surface_t *)
|
||||
cairo_image_surface_create (surface->format,
|
||||
surface->width,
|
||||
surface->height);
|
||||
if (unlikely (image->base.status))
|
||||
return &image->base;
|
||||
|
||||
if (image->stride == surface->stride) {
|
||||
size = surface->stride * surface->height;
|
||||
radeon_bo_read (device, bo, 0, size, image->data);
|
||||
} else {
|
||||
int offset;
|
||||
|
||||
size = surface->width;
|
||||
if (surface->format != CAIRO_FORMAT_A8)
|
||||
size *= 4;
|
||||
|
||||
offset = 0;
|
||||
row = surface->height;
|
||||
dst = image->data;
|
||||
while (row--) {
|
||||
radeon_bo_read (device, bo, offset, size, dst);
|
||||
offset += surface->stride;
|
||||
dst += image->stride;
|
||||
}
|
||||
}
|
||||
|
||||
return &image->base;
|
||||
}
|
||||
|
||||
static void
|
||||
_radeon_device_init_bo_cache (radeon_device_t *device)
|
||||
{
|
||||
_cairo_freepool_init (&device->bo_pool, sizeof (radeon_bo_t));
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
radeon_device_init (radeon_device_t *device, int fd)
|
||||
{
|
||||
_radeon_device_init_bo_cache (device);
|
||||
|
||||
device->base.bo.release = radeon_bo_release;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
_radeon_bo_cache_fini (radeon_device_t *device)
|
||||
{
|
||||
_cairo_freepool_fini (&device->bo_pool);
|
||||
}
|
||||
|
||||
void
|
||||
radeon_device_fini (radeon_device_t *device)
|
||||
{
|
||||
_radeon_bo_cache_fini (device);
|
||||
_cairo_drm_device_fini (&device->base);
|
||||
}
|
||||
|
|
@ -1,369 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-inline.h"
|
||||
|
||||
void
|
||||
_cairo_drm_surface_init (cairo_drm_surface_t *surface,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
surface->bo = NULL;
|
||||
surface->format = format;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->stride = 0;
|
||||
|
||||
surface->fallback = NULL;
|
||||
surface->map_count = 0;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_drm_surface_finish (cairo_drm_surface_t *surface)
|
||||
{
|
||||
assert (surface->fallback == NULL);
|
||||
|
||||
if (surface->bo != NULL)
|
||||
cairo_drm_bo_destroy (surface->base.device, surface->bo);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_drm_surface_get_font_options (void *abstract_surface,
|
||||
cairo_font_options_t *options)
|
||||
{
|
||||
_cairo_font_options_init_default (options);
|
||||
|
||||
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_drm_surface_get_extents (void *abstract_surface,
|
||||
cairo_rectangle_int_t *rectangle)
|
||||
{
|
||||
cairo_drm_surface_t *surface = abstract_surface;
|
||||
|
||||
rectangle->x = 0;
|
||||
rectangle->y = 0;
|
||||
rectangle->width = surface->width;
|
||||
rectangle->height = surface->height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_create (cairo_device_t *abstract_device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (device != NULL && device->base.status)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (device->base.status);
|
||||
}
|
||||
else if (device == NULL ||
|
||||
device->surface.create == NULL ||
|
||||
width == 0 || width > device->max_surface_size ||
|
||||
height == 0 || height > device->max_surface_size)
|
||||
{
|
||||
surface = cairo_image_surface_create (format, width, height);
|
||||
}
|
||||
else if (device->base.finished)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface = device->surface.create (device, format, width, height);
|
||||
if (surface->status == CAIRO_STATUS_INVALID_SIZE)
|
||||
surface = cairo_image_surface_create (format, width, height);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_create_for_name (cairo_device_t *abstract_device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (! CAIRO_FORMAT_VALID (format))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
|
||||
if (device != NULL && device->base.status)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (device->base.status);
|
||||
}
|
||||
else if (device == NULL || device->surface.create_for_name == NULL)
|
||||
{
|
||||
/* XXX invalid device! */
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
}
|
||||
else if (width == 0 || width > device->max_surface_size ||
|
||||
height == 0 || height > device->max_surface_size)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
}
|
||||
else if (device->base.finished)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface = device->surface.create_for_name (device,
|
||||
name, format,
|
||||
width, height, stride);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_surface_create_for_name);
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_create_from_cacheable_image (cairo_device_t *abstract_device,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
|
||||
if (surface->status) {
|
||||
surface = _cairo_surface_create_in_error (surface->status);
|
||||
} else if (device != NULL && device->base.status) {
|
||||
surface = _cairo_surface_create_in_error (device->base.status);
|
||||
} else if (device == NULL || device->surface.create_from_cacheable_image == NULL) {
|
||||
/* XXX invalid device! */
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
} else if (device->base.finished) {
|
||||
surface = _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
} else {
|
||||
surface = device->surface.create_from_cacheable_image (device, surface);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static cairo_drm_surface_t *
|
||||
_cairo_surface_as_drm (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
if (unlikely (abstract_surface->status))
|
||||
return NULL;
|
||||
|
||||
if (abstract_surface->type != CAIRO_SURFACE_TYPE_DRM)
|
||||
return NULL;
|
||||
|
||||
return (cairo_drm_surface_t *) abstract_surface;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
cairo_drm_surface_enable_scan_out (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
cairo_drm_device_t *device;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
if (unlikely (surface->base.finished))
|
||||
return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
|
||||
device = (cairo_drm_device_t *) surface->base.device;
|
||||
if (device->surface.enable_scan_out == NULL)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (unlikely (device->base.finished))
|
||||
return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
|
||||
return device->surface.enable_scan_out (abstract_surface);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cairo_drm_surface_get_handle (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return surface->bo->handle;
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
_cairo_drm_surface_flink (void *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface = abstract_surface;
|
||||
|
||||
return _cairo_drm_bo_flink ((cairo_drm_device_t *) surface->base.device,
|
||||
surface->bo);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cairo_drm_surface_get_name (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
cairo_drm_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (surface->bo->name)
|
||||
return surface->bo->name;
|
||||
|
||||
device = (cairo_drm_device_t *) surface->base.device;
|
||||
if (device->surface.flink == NULL)
|
||||
return 0;
|
||||
|
||||
status = device->surface.flink (abstract_surface);
|
||||
if (status) {
|
||||
if (_cairo_status_is_error (status))
|
||||
status = _cairo_surface_set_error (abstract_surface, status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return surface->bo->name;
|
||||
}
|
||||
|
||||
cairo_format_t
|
||||
cairo_drm_surface_get_format (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_format (abstract_surface);
|
||||
|
||||
return surface->format;
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_surface_get_width (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_width (abstract_surface);
|
||||
|
||||
return surface->width;
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_surface_get_height (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_height (abstract_surface);
|
||||
|
||||
return surface->height;
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_surface_get_stride (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_stride (abstract_surface);
|
||||
|
||||
return surface->stride;
|
||||
}
|
||||
|
||||
/* XXX drm or general surface layer? naming? */
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_map_to_image (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
cairo_drm_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (unlikely (abstract_surface->status))
|
||||
return _cairo_surface_create_in_error (abstract_surface->status);
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
if (_cairo_surface_is_image (abstract_surface))
|
||||
return cairo_surface_reference (abstract_surface);
|
||||
|
||||
status = _cairo_surface_set_error (abstract_surface,
|
||||
CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
surface->map_count++;
|
||||
device = (cairo_drm_device_t *) surface->base.device;
|
||||
return cairo_surface_reference (device->surface.map_to_image (surface));
|
||||
}
|
||||
|
||||
void
|
||||
cairo_drm_surface_unmap (cairo_surface_t *abstract_surface,
|
||||
cairo_surface_t *image)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
if (_cairo_surface_is_image (abstract_surface))
|
||||
cairo_surface_destroy (image);
|
||||
else
|
||||
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX assert image belongs to drm */
|
||||
//assert (image == drm->fallback);
|
||||
cairo_surface_destroy (image);
|
||||
|
||||
assert (surface->map_count > 0);
|
||||
if (--surface->map_count == 0)
|
||||
cairo_surface_flush (&surface->base);
|
||||
}
|
||||
|
|
@ -1,390 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
|
||||
#include "cairo-device-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
|
||||
#include <libudev.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h> /* open(), close() */
|
||||
|
||||
static cairo_drm_device_t *_cairo_drm_known_devices;
|
||||
static cairo_drm_device_t *_cairo_drm_default_device;
|
||||
|
||||
static const char *
|
||||
get_udev_property(struct udev_device *device, const char *name)
|
||||
{
|
||||
struct udev_list_entry *entry;
|
||||
|
||||
udev_list_entry_foreach (entry,
|
||||
udev_device_get_properties_list_entry (device))
|
||||
{
|
||||
if (strcmp (udev_list_entry_get_name (entry), name) == 0)
|
||||
return udev_list_entry_get_value (entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_device_flush (void *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = abstract_device;
|
||||
|
||||
device->device.flush (device);
|
||||
}
|
||||
|
||||
static void
|
||||
_device_finish (void *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = abstract_device;
|
||||
|
||||
CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
|
||||
if (device->prev != NULL)
|
||||
device->prev->next = device->next;
|
||||
else
|
||||
_cairo_drm_known_devices = device->next;
|
||||
if (device->next != NULL)
|
||||
device->next->prev = device->prev;
|
||||
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
|
||||
|
||||
if (_cairo_atomic_ptr_cmpxchg (&_cairo_drm_default_device,
|
||||
device, NULL))
|
||||
{
|
||||
cairo_device_destroy (&device->base);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_device_destroy (void *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = abstract_device;
|
||||
|
||||
device->device.destroy (device);
|
||||
}
|
||||
|
||||
static const cairo_device_backend_t _cairo_drm_device_backend = {
|
||||
CAIRO_DEVICE_TYPE_DRM,
|
||||
|
||||
NULL, NULL, /* lock, unlock */
|
||||
|
||||
_device_flush,
|
||||
_device_finish,
|
||||
_device_destroy,
|
||||
};
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_device_init (cairo_drm_device_t *dev,
|
||||
int fd,
|
||||
dev_t devid,
|
||||
int vendor_id,
|
||||
int chip_id,
|
||||
int max_surface_size)
|
||||
{
|
||||
assert (CAIRO_MUTEX_IS_LOCKED (_cairo_drm_device_mutex));
|
||||
|
||||
_cairo_device_init (&dev->base, &_cairo_drm_device_backend);
|
||||
|
||||
dev->id = devid;
|
||||
dev->vendor_id = vendor_id;
|
||||
dev->chip_id = chip_id;
|
||||
dev->fd = fd;
|
||||
|
||||
dev->max_surface_size = max_surface_size;
|
||||
|
||||
dev->prev = NULL;
|
||||
dev->next = _cairo_drm_known_devices;
|
||||
if (_cairo_drm_known_devices != NULL)
|
||||
_cairo_drm_known_devices->prev = dev;
|
||||
_cairo_drm_known_devices = dev;
|
||||
|
||||
if (_cairo_drm_default_device == NULL)
|
||||
_cairo_drm_default_device = (cairo_drm_device_t *) cairo_device_reference (&dev->base);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
cairo_device_t *
|
||||
cairo_drm_device_get (struct udev_device *device)
|
||||
{
|
||||
static const struct dri_driver_entry {
|
||||
uint32_t vendor_id;
|
||||
uint32_t chip_id;
|
||||
cairo_drm_device_create_func_t create_func;
|
||||
} driver_map[] = {
|
||||
{ 0x8086, 0x29a2, _cairo_drm_i965_device_create }, /* I965_G */
|
||||
{ 0x8086, 0x2982, _cairo_drm_i965_device_create }, /* G35_G */
|
||||
{ 0x8086, 0x2992, _cairo_drm_i965_device_create }, /* I965_Q */
|
||||
{ 0x8086, 0x2972, _cairo_drm_i965_device_create }, /* I946_GZ */
|
||||
{ 0x8086, 0x2a02, _cairo_drm_i965_device_create }, /* I965_GM */
|
||||
{ 0x8086, 0x2a12, _cairo_drm_i965_device_create }, /* I965_GME */
|
||||
{ 0x8086, 0x2e02, _cairo_drm_i965_device_create }, /* IGD_E_G */
|
||||
{ 0x8086, 0x2e22, _cairo_drm_i965_device_create }, /* G45_G */
|
||||
{ 0x8086, 0x2e12, _cairo_drm_i965_device_create }, /* Q45_G */
|
||||
{ 0x8086, 0x2e32, _cairo_drm_i965_device_create }, /* G41_G */
|
||||
{ 0x8086, 0x2a42, _cairo_drm_i965_device_create }, /* GM45_GM */
|
||||
|
||||
{ 0x8086, 0x2582, _cairo_drm_i915_device_create }, /* I915_G */
|
||||
{ 0x8086, 0x2592, _cairo_drm_i915_device_create }, /* I915_GM */
|
||||
{ 0x8086, 0x258a, _cairo_drm_i915_device_create }, /* E7221_G */
|
||||
{ 0x8086, 0x2772, _cairo_drm_i915_device_create }, /* I945_G */
|
||||
{ 0x8086, 0x27a2, _cairo_drm_i915_device_create }, /* I945_GM */
|
||||
{ 0x8086, 0x27ae, _cairo_drm_i915_device_create }, /* I945_GME */
|
||||
{ 0x8086, 0x29c2, _cairo_drm_i915_device_create }, /* G33_G */
|
||||
{ 0x8086, 0x29b2, _cairo_drm_i915_device_create }, /* Q35_G */
|
||||
{ 0x8086, 0x29d2, _cairo_drm_i915_device_create }, /* Q33_G */
|
||||
{ 0x8086, 0xa011, _cairo_drm_i915_device_create }, /* IGD_GM */
|
||||
{ 0x8086, 0xa001, _cairo_drm_i915_device_create }, /* IGD_G */
|
||||
|
||||
/* XXX i830 */
|
||||
|
||||
{ 0x8086, ~0, _cairo_drm_intel_device_create },
|
||||
|
||||
{ 0x1002, ~0, _cairo_drm_radeon_device_create },
|
||||
#if CAIRO_HAS_GALLIUM_SURFACE
|
||||
{ ~0, ~0, _cairo_drm_gallium_device_create },
|
||||
#endif
|
||||
};
|
||||
|
||||
cairo_drm_device_t *dev;
|
||||
dev_t devid;
|
||||
struct udev_device *parent;
|
||||
const char *pci_id;
|
||||
uint32_t vendor_id, chip_id;
|
||||
const char *path;
|
||||
int i, fd;
|
||||
|
||||
devid = udev_device_get_devnum (device);
|
||||
|
||||
CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
|
||||
for (dev = _cairo_drm_known_devices; dev != NULL; dev = dev->next) {
|
||||
if (dev->id == devid) {
|
||||
dev = (cairo_drm_device_t *) cairo_device_reference (&dev->base);
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
parent = udev_device_get_parent (device);
|
||||
pci_id = get_udev_property (parent, "PCI_ID");
|
||||
if (pci_id == NULL || sscanf (pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
|
||||
dev = NULL;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
#if CAIRO_HAS_GALLIUM_SURFACE
|
||||
if (getenv ("CAIRO_GALLIUM_FORCE"))
|
||||
{
|
||||
i = ARRAY_LENGTH (driver_map) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < ARRAY_LENGTH (driver_map); i++) {
|
||||
if (driver_map[i].vendor_id == ~0U)
|
||||
break;
|
||||
|
||||
if (driver_map[i].vendor_id == vendor_id &&
|
||||
(driver_map[i].chip_id == ~0U || driver_map[i].chip_id == chip_id))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == ARRAY_LENGTH (driver_map)) {
|
||||
dev = (cairo_drm_device_t *)
|
||||
_cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
path = udev_device_get_devnode (device);
|
||||
if (path == NULL)
|
||||
path = "/dev/dri/card0"; /* XXX buggy udev? */
|
||||
|
||||
fd = open (path, O_RDWR);
|
||||
if (fd == -1) {
|
||||
/* XXX more likely to be a permissions issue... */
|
||||
_cairo_error_throw (CAIRO_STATUS_FILE_NOT_FOUND);
|
||||
dev = NULL;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
dev = driver_map[i].create_func (fd, devid, vendor_id, chip_id);
|
||||
if (dev == NULL)
|
||||
close (fd);
|
||||
|
||||
DONE:
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
|
||||
|
||||
if (dev == NULL)
|
||||
return _cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
else
|
||||
return &dev->base;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_device_get);
|
||||
|
||||
cairo_device_t *
|
||||
cairo_drm_device_get_for_fd (int fd)
|
||||
{
|
||||
struct stat st;
|
||||
struct udev *udev;
|
||||
struct udev_device *device;
|
||||
cairo_device_t *dev = NULL;
|
||||
|
||||
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode)) {
|
||||
//_cairo_error_throw (CAIRO_STATUS_INVALID_DEVICE);
|
||||
return _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
udev = udev_new ();
|
||||
|
||||
device = udev_device_new_from_devnum (udev, 'c', st.st_rdev);
|
||||
if (device != NULL) {
|
||||
dev = cairo_drm_device_get (device);
|
||||
udev_device_unref (device);
|
||||
}
|
||||
|
||||
udev_unref (udev);
|
||||
|
||||
return dev;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_device_get_for_fd);
|
||||
|
||||
cairo_device_t *
|
||||
cairo_drm_device_default (void)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_enumerate *e;
|
||||
struct udev_list_entry *entry;
|
||||
cairo_device_t *dev;
|
||||
|
||||
/* optimistic atomic pointer read */
|
||||
dev = &_cairo_drm_default_device->base;
|
||||
if (dev != NULL)
|
||||
return dev;
|
||||
|
||||
udev = udev_new();
|
||||
if (udev == NULL)
|
||||
return _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
e = udev_enumerate_new (udev);
|
||||
udev_enumerate_add_match_subsystem (e, "drm");
|
||||
udev_enumerate_scan_devices (e);
|
||||
udev_list_entry_foreach (entry, udev_enumerate_get_list_entry (e)) {
|
||||
struct udev_device *device;
|
||||
|
||||
device =
|
||||
udev_device_new_from_syspath (udev,
|
||||
udev_list_entry_get_name (entry));
|
||||
|
||||
dev = cairo_drm_device_get (device);
|
||||
|
||||
udev_device_unref (device);
|
||||
|
||||
if (dev != NULL) {
|
||||
if (((cairo_drm_device_t *) dev)->fd == -1) {
|
||||
/* try again, we may find a usable card */
|
||||
cairo_device_destroy (dev);
|
||||
dev = NULL;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
}
|
||||
udev_enumerate_unref (e);
|
||||
udev_unref (udev);
|
||||
|
||||
cairo_device_destroy (dev); /* owned by _cairo_drm_default_device */
|
||||
return dev;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_device_default);
|
||||
|
||||
void
|
||||
_cairo_drm_device_reset_static_data (void)
|
||||
{
|
||||
if (_cairo_drm_default_device != NULL) {
|
||||
cairo_device_t *device = &_cairo_drm_default_device->base;
|
||||
_cairo_drm_default_device = NULL;
|
||||
cairo_device_destroy (device);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_device_get_fd (cairo_device_t *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
|
||||
if (device->base.status)
|
||||
return -1;
|
||||
|
||||
return device->fd;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_drm_device_fini (cairo_drm_device_t *device)
|
||||
{
|
||||
if (device->fd != -1)
|
||||
close (device->fd);
|
||||
}
|
||||
|
||||
void
|
||||
cairo_drm_device_throttle (cairo_device_t *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (unlikely (device->base.status))
|
||||
return;
|
||||
|
||||
if (device->device.throttle == NULL)
|
||||
return;
|
||||
|
||||
status = device->device.throttle (device);
|
||||
if (unlikely (status))
|
||||
_cairo_status_set_error (&device->base.status, status);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_drm_size_is_valid (cairo_device_t *abstract_device,
|
||||
int width, int height)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
|
||||
if (unlikely (device->base.status))
|
||||
return FALSE;
|
||||
|
||||
return width <= device->max_surface_size &&
|
||||
height <= device->max_surface_size;
|
||||
}
|
||||
|
|
@ -156,9 +156,6 @@ cairo_feature_sources = {
|
|||
'cairo-xcb-surface-render.c',
|
||||
'cairo-xcb-resources.c',
|
||||
],
|
||||
'cairo-qt': [
|
||||
'cairo-qt-surface.cpp',
|
||||
],
|
||||
'cairo-quartz': [
|
||||
'cairo-quartz-surface.c',
|
||||
],
|
||||
|
|
@ -180,27 +177,6 @@ cairo_feature_sources = {
|
|||
'cairo-win32-font': [
|
||||
'win32/cairo-win32-font.c',
|
||||
],
|
||||
'cairo-drm': [
|
||||
'drm/cairo-drm.c',
|
||||
'drm/cairo-drm-bo.c',
|
||||
'drm/cairo-drm-surface.c',
|
||||
'drm/cairo-drm-intel.c',
|
||||
'drm/cairo-drm-intel-debug.c',
|
||||
'drm/cairo-drm-intel-surface.c',
|
||||
'drm/cairo-drm-i915-surface.c',
|
||||
'drm/cairo-drm-i915-glyphs.c',
|
||||
'drm/cairo-drm-i915-shader.c',
|
||||
'drm/cairo-drm-i915-spans.c',
|
||||
'drm/cairo-drm-i965-surface.c',
|
||||
'drm/cairo-drm-i965-glyphs.c',
|
||||
'drm/cairo-drm-i965-shader.c',
|
||||
'drm/cairo-drm-i965-spans.c',
|
||||
'drm/cairo-drm-intel-brw-eu.c',
|
||||
'drm/cairo-drm-intel-brw-eu-emit.c',
|
||||
'drm/cairo-drm-intel-brw-eu-util.c',
|
||||
'drm/cairo-drm-radeon.c',
|
||||
'drm/cairo-drm-radeon-surface.c',
|
||||
],
|
||||
'cairo-gl': [
|
||||
'cairo-gl-composite.c',
|
||||
'cairo-gl-device.c',
|
||||
|
|
@ -216,16 +192,6 @@ cairo_feature_sources = {
|
|||
'cairo-gl-surface.c',
|
||||
'cairo-gl-traps-compositor.c',
|
||||
],
|
||||
'cairo-cogl': [
|
||||
'cairo-cogl-surface.c',
|
||||
'cairo-cogl-gradient.c',
|
||||
],
|
||||
'cairo-directfb': [
|
||||
'cairo-directfb-surface.c',
|
||||
],
|
||||
'cairo-vg': [
|
||||
'cairo-vg-surface.c',
|
||||
],
|
||||
'cairo-script': [
|
||||
'cairo-script-surface.c',
|
||||
],
|
||||
|
|
@ -264,18 +230,14 @@ cairo_feature_headers = {
|
|||
'cairo-xlib': ['cairo-xlib.h'],
|
||||
'cairo-xlib-xrender': ['cairo-xlib-xrender.h'],
|
||||
'cairo-xcb': ['cairo-xcb.h'],
|
||||
'cairo-qt': ['cairo-qt.h'],
|
||||
'cairo-quartz': ['cairo-quartz.h'],
|
||||
'cairo-quartz-image': ['cairo-quartz-image.h'],
|
||||
'cairo-win32': ['cairo-win32.h'],
|
||||
'cairo-gl': ['cairo-gl.h'],
|
||||
'cairo-directfb': ['cairo-directfb.h'],
|
||||
'cairo-drm': ['cairo-drm.h'],
|
||||
'cairo-script': ['cairo-script.h'],
|
||||
'cairo-tee': ['cairo-tee.h'],
|
||||
'cairo-xml': ['cairo-xml.h'],
|
||||
'cairo-vg': ['cairo-vg.h'],
|
||||
'cairo-cogl': ['cairo-cogl.h'],
|
||||
}
|
||||
|
||||
cairo_no_warn_c_args = cc.get_supported_arguments([
|
||||
|
|
|
|||
|
|
@ -66,9 +66,6 @@
|
|||
#if CAIRO_HAS_GL_SURFACE
|
||||
#include <cairo-gl.h>
|
||||
#endif
|
||||
#if CAIRO_HAS_OS2_SURFACE
|
||||
#include <cairo-os2.h>
|
||||
#endif
|
||||
#if CAIRO_HAS_PDF_SURFACE
|
||||
#include <cairo-pdf.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@
|
|||
#if CAIRO_HAS_GL_SURFACE
|
||||
#include <cairo-gl.h>
|
||||
#endif
|
||||
#if CAIRO_HAS_OS2_SURFACE
|
||||
#include <cairo-os2.h>
|
||||
#endif
|
||||
#if CAIRO_HAS_PDF_SURFACE
|
||||
#include <cairo-pdf.h>
|
||||
#endif
|
||||
|
|
@ -61,12 +58,6 @@ preamble (cairo_test_context_t *ctx)
|
|||
cairo_gl_surface_swapbuffers (surface);
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_OS2_SURFACE
|
||||
cairo_os2_surface_set_hwnd (surface, 0);
|
||||
cairo_os2_surface_set_size (surface, 0, 0, 0);
|
||||
cairo_os2_surface_set_manual_window_refresh (surface, FALSE);
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_PDF_SURFACE
|
||||
cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4);
|
||||
cairo_pdf_surface_set_size (surface, 0, 0);
|
||||
|
|
|
|||
|
|
@ -5320,85 +5320,6 @@ cairo_recording_surface_create (cairo_content_t content,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if CAIRO_HAS_VG_SURFACE
|
||||
#include <cairo-vg.h>
|
||||
cairo_surface_t *
|
||||
cairo_vg_surface_create (cairo_vg_context_t *context,
|
||||
cairo_content_t content,
|
||||
int width, int height)
|
||||
{
|
||||
cairo_surface_t *ret;
|
||||
|
||||
_enter_trace ();
|
||||
|
||||
ret = DLCALL (cairo_vg_surface_create, context, content, width, height);
|
||||
|
||||
_emit_line_info ();
|
||||
if (_write_lock ()) {
|
||||
Object *obj = _create_surface (ret);
|
||||
|
||||
_trace_printf ("dict\n"
|
||||
" /type /vg set\n"
|
||||
" /content //%s set\n"
|
||||
" /width %d set\n"
|
||||
" /height %d set\n"
|
||||
" surface dup /s%ld exch def\n",
|
||||
_content_to_string (content),
|
||||
width, height,
|
||||
obj->token);
|
||||
obj->width = width;
|
||||
obj->height = height;
|
||||
obj->defined = TRUE;
|
||||
_push_object (obj);
|
||||
dump_stack(__func__);
|
||||
_write_unlock ();
|
||||
}
|
||||
|
||||
_exit_trace ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_vg_surface_create_for_image (cairo_vg_context_t *context,
|
||||
VGImage image,
|
||||
VGImageFormat format,
|
||||
int width, int height)
|
||||
{
|
||||
cairo_surface_t *ret;
|
||||
|
||||
_enter_trace ();
|
||||
|
||||
ret = DLCALL (cairo_vg_surface_create_for_image,
|
||||
context, image, format, width, height);
|
||||
|
||||
_emit_line_info ();
|
||||
if (_write_lock ()) {
|
||||
Object *obj = _create_surface (ret);
|
||||
cairo_content_t content;
|
||||
|
||||
content = DLCALL (cairo_surface_get_content, ret);
|
||||
_trace_printf ("dict\n"
|
||||
" /type /vg set\n"
|
||||
" /content //%s set\n"
|
||||
" /width %d set\n"
|
||||
" /height %d set\n"
|
||||
" surface dup /s%ld exch def\n",
|
||||
_content_to_string (content),
|
||||
width, height,
|
||||
obj->token);
|
||||
obj->width = width;
|
||||
obj->height = height;
|
||||
obj->defined = TRUE;
|
||||
_push_object (obj);
|
||||
dump_stack(__func__);
|
||||
_write_unlock ();
|
||||
}
|
||||
|
||||
_exit_trace ();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_GLESV2_SURFACE
|
||||
#include <cairo-gl.h>
|
||||
cairo_surface_t *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue