2 * Copyright © 2001 Keith Packard
3 * Copyright © 2008 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * Eric Anholt <eric@anholt.net>
26 * Zhigang Gong <zhigang.gong@linux.intel.com>
32 #include "glamor_priv.h"
34 * Sets the offsets to add to coordinates to make them address the same bits in
35 * the backing drawable. These coordinates are nonzero only for redirected
39 glamor_get_drawable_deltas(DrawablePtr drawable
, PixmapPtr pixmap
,
42 #if defined(COMPOSITE) || defined(ROOTLESS)
43 if (drawable
->type
== DRAWABLE_WINDOW
) {
44 *x
= -pixmap
->screen_x
;
45 *y
= -pixmap
->screen_y
;
55 glamor_pixmap_init(ScreenPtr screen
)
61 glamor_pixmap_fini(ScreenPtr screen
)
66 glamor_set_destination_pixmap_fbo(glamor_screen_private
*glamor_priv
,
67 glamor_pixmap_fbo
*fbo
, int x0
, int y0
,
68 int width
, int height
)
70 glamor_make_current(glamor_priv
);
72 glBindFramebuffer(GL_FRAMEBUFFER
, fbo
->fb
);
73 glViewport(x0
, y0
, width
, height
);
77 glamor_set_destination_pixmap_priv_nc(glamor_screen_private
*glamor_priv
,
79 glamor_pixmap_private
*pixmap_priv
)
83 PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap
, pixmap_priv
, w
, h
);
84 glamor_set_destination_pixmap_fbo(glamor_priv
, pixmap_priv
->fbo
, 0, 0, w
, h
);
88 glamor_set_destination_pixmap_priv(glamor_screen_private
*glamor_priv
,
90 glamor_pixmap_private
*pixmap_priv
)
92 if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv
))
95 glamor_set_destination_pixmap_priv_nc(glamor_priv
, pixmap
, pixmap_priv
);
100 glamor_set_destination_pixmap(PixmapPtr pixmap
)
103 glamor_pixmap_private
*pixmap_priv
= glamor_get_pixmap_private(pixmap
);
104 ScreenPtr screen
= pixmap
->drawable
.pScreen
;
105 glamor_screen_private
*glamor_priv
= glamor_get_screen_private(screen
);
107 err
= glamor_set_destination_pixmap_priv(glamor_priv
, pixmap
, pixmap_priv
);
112 glamor_set_planemask(int depth
, unsigned long planemask
)
114 if (glamor_pm_is_solid(depth
, planemask
)) {
118 glamor_fallback("unsupported planemask %lx\n", planemask
);
123 glamor_set_alu(DrawablePtr drawable
, unsigned char alu
)
125 ScreenPtr screen
= drawable
->pScreen
;
126 glamor_screen_private
*glamor_priv
= glamor_get_screen_private(screen
);
128 if (glamor_priv
->is_gles
) {
136 glDisable(GL_COLOR_LOGIC_OP
);
144 /* These leave the alpha channel at 1.0 */
147 if (glamor_drawable_effective_depth(drawable
) == 24 &&
148 glamor_get_drawable_pixmap(drawable
)->drawable
.depth
== 32) {
149 glamor_fallback("ALU %x not supported with mixed depth\n", alu
);
154 glEnable(GL_COLOR_LOGIC_OP
);
163 glLogicOp(GL_AND_REVERSE
);
166 glLogicOp(GL_AND_INVERTED
);
184 glLogicOp(GL_INVERT
);
187 glLogicOp(GL_OR_REVERSE
);
190 glLogicOp(GL_COPY_INVERTED
);
193 glLogicOp(GL_OR_INVERTED
);
202 glamor_fallback("unsupported alu %x\n", alu
);