Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: x11/real_x_connection.cc

Issue 6793005: Add the xrender backend to the window manager. (Closed) Base URL: ssh://gitrw.chromium.org:9222/window_manager.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: x11/real_x_connection.cc
diff --git a/x11/real_x_connection.cc b/x11/real_x_connection.cc
index 1155e242d586765ba732649e43b577e2825a9393..70fe17c174dd98f56b8c351fc2c016358839f556 100644
--- a/x11/real_x_connection.cc
+++ b/x11/real_x_connection.cc
@@ -15,6 +15,7 @@ extern "C" {
#include <X11/extensions/sync.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/Xrender.h>
#include <X11/Xatom.h>
#include <X11/Xlib-xcb.h>
#include <X11/Xutil.h>
@@ -1344,6 +1345,114 @@ bool RealXConnection::QueryPointerPosition(Point* absolute_pos_out) {
return true;
}
+bool RealXConnection::RenderQueryExtension() {
+ int render_event, render_error;
+ if (!XRenderQueryExtension (display_, &render_event, &render_error))
Daniel Erat 2011/04/02 14:54:36 why not do "return XRenderQueryExtension(...)"?
marcheu 2011/04/04 19:55:58 Done.
+ return false;
+ return true;
+}
+
+XPicture RealXConnection::RenderCreatePicture(XDrawable drawable, int depth) {
+ XRenderPictFormat *format;
+ XRenderPictureAttributes pa;
+
+ format = XRenderFindStandardFormat(display_,
Daniel Erat 2011/04/02 14:54:36 nit: move 'display_' to the beginning of the next
marcheu 2011/04/04 19:55:58 Done.
+ depth == 24 ? PictStandardRGB24 : PictStandardARGB32);
+ pa.repeat = True;
+ XPicture r = XRenderCreatePicture(display_, drawable, format, CPRepeat, &pa);
+ return r;
+}
+
+XPixmap RealXConnection::CreatePixmapFromData(char* data, const Size& size) {
Daniel Erat 2011/04/02 14:54:36 see other comment about using ImageContainer inste
marcheu 2011/04/04 19:55:58 Done.
+ int data_size = size.width * size.height * 4;
+ char* pixmap_data = (char*)malloc(data_size);
Daniel Erat 2011/04/02 14:54:36 use static_cast
marcheu 2011/04/02 23:31:38 Note to self: add a comment that XDestroyImage wil
marcheu 2011/04/04 19:55:58 Done.
+
+ /* premultiply the RGB channels */
+ memcpy(pixmap_data, data, data_size);
+ for(int i = 0; i<size.width * size.height; i++) {
Daniel Erat 2011/04/02 14:54:36 add space between for and ( and around <
marcheu 2011/04/04 19:55:58 Done.
+ pixmap_data[i*4+0] = pixmap_data[i*4+0] * pixmap_data[i*4+3] / 255;
+ pixmap_data[i*4+1] = pixmap_data[i*4+1] * pixmap_data[i*4+3] / 255;
+ pixmap_data[i*4+2] = pixmap_data[i*4+2] * pixmap_data[i*4+3] / 255;
+ }
+
+ XPixmap pixmap = XCreatePixmap(display_, root_, size.width, size.height, 32);
+
+ XImage* image = XCreateImage (display_,
+ DefaultVisual(display_, DefaultScreen(display_)),
Daniel Erat 2011/04/02 14:54:36 fix indenting
marcheu 2011/04/04 19:55:58 Done.
+ 32,
Daniel Erat 2011/04/02 14:54:36 nit: mind labeling the ambiguous arguments with tr
marcheu 2011/04/04 19:55:58 Done.
+ ZPixmap,
+ 0,
+ pixmap_data,
+ size.width, size.height,
+ 32, 0);
+
+ GC gc = XCreateGC (display_, pixmap, 0, NULL);
Daniel Erat 2011/04/02 14:54:36 remove space
marcheu 2011/04/04 19:55:58 Done.
+ if (!gc) {
+ XDestroyImage (image);
Daniel Erat 2011/04/02 14:54:36 remove space
marcheu 2011/04/04 19:55:58 Done.
+ XFreePixmap (display_, pixmap);
Daniel Erat 2011/04/02 14:54:36 remove space
marcheu 2011/04/04 19:55:58 Done.
+ return None;
+ }
+
+ XPutImage (display_, pixmap, gc, image, 0, 0, 0, 0, size.width, size.height);
Daniel Erat 2011/04/02 14:54:36 ditto
marcheu 2011/04/04 19:55:58 Done.
+ XDestroyImage(image);
+
+ XFreeGC (display_, gc);
+
+ return pixmap;
+}
+
+void RealXConnection::RenderComposite(bool blend, XPicture src, XPicture mask,
+ XPicture dst, Point srcpos, Point maskpos, Matrix4 transform, Size size)
Daniel Erat 2011/04/02 14:54:36 fix indenting
marcheu 2011/04/04 19:55:58 Done.
+{
Daniel Erat 2011/04/02 14:54:36 move to end of previous line
marcheu 2011/04/04 19:55:58 Done.
+ XTransform xform = {{
+ { XDoubleToFixed( size.width/(float)transform[0][0] ),
Daniel Erat 2011/04/02 14:54:36 fix indenting/spacing/casts
marcheu 2011/04/04 19:55:58 Tried to do something about it, not sure exactly h
+ XDoubleToFixed( transform[1][0] ),
+ XDoubleToFixed( transform[2][0] ) },
+ { XDoubleToFixed( transform[0][1] ),
+ XDoubleToFixed( size.height/(float)transform[1][1] ),
+ XDoubleToFixed( transform[2][1] ) },
+ { XDoubleToFixed( 0.0 ),
+ XDoubleToFixed( 0.0 ),
+ XDoubleToFixed( 1.0 ) }
+ }};
+ Point dstpos(transform[3][0], transform[3][1]);
+
+ // Don't use transform/filtering all the time,
+ // there are performance implications in doing so.
+ if ( (size.width != transform[0][0]) || (size.height != transform[1][1] ) ) {
Daniel Erat 2011/04/02 14:54:36 remove extra spaces here and below
marcheu 2011/04/04 19:55:58 Done.
+ XRenderSetPictureTransform( display_, src, &xform );
+ XRenderSetPictureFilter( display_, src, FilterBilinear, 0, 0 );
+ }
+
+ int op = blend ? PictOpOver : PictOpSrc;
+ XRenderComposite(display_, op, src, mask, dst,
+ (int)srcpos.x, (int)srcpos.y, (int)maskpos.x, (int)maskpos.y,
Daniel Erat 2011/04/02 14:54:36 c++ casts, and group related params together on li
marcheu 2011/04/04 19:55:58 Done.
+ (int)dstpos.x, (int)dstpos.y,
+ (int)transform[0][0], (int)transform[1][1]);
+}
+
+void RealXConnection::RenderFreePicture(XPicture pict)
+{
Daniel Erat 2011/04/02 14:54:36 ...
marcheu 2011/04/04 19:55:58 Done.
+ XRenderFreePicture(display_, pict);
+}
+
+void RealXConnection::RenderFillRectangle(XPicture dst,
+ float red,
+ float green,
+ float blue,
+ Point pos,
+ Size size)
+{
Daniel Erat 2011/04/02 14:54:36 ...
marcheu 2011/04/04 19:55:58 Done.
+ XRenderColor c;
+
+ c.red = red * 0xffff;
+ c.green = green * 0xffff;
+ c.blue = blue * 0xffff;
+ c.alpha = 0xffff;
+ XRenderFillRectangle(display_, PictOpSrc, dst, &c,
+ pos.x, pos.y, size.width, size.height);
+}
+
void RealXConnection::Free(void* item) {
XFree(item);
}

Powered by Google App Engine
This is Rietveld 408576698