xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

glamor_pixmap.c (5071B)


      1 /*
      2  * Copyright © 2001 Keith Packard
      3  * Copyright © 2008 Intel Corporation
      4  *
      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:
     11  *
     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
     14  * Software.
     15  *
     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
     22  * IN THE SOFTWARE.
     23  *
     24  * Authors:
     25  *    Eric Anholt <eric@anholt.net>
     26  *    Zhigang Gong <zhigang.gong@linux.intel.com>
     27  *
     28  */
     29 
     30 #include <stdlib.h>
     31 
     32 #include "glamor_priv.h"
     33 /**
     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
     36  * windows.
     37  */
     38 void
     39 glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
     40                            int *x, int *y)
     41 {
     42 #ifdef COMPOSITE
     43     if (drawable->type == DRAWABLE_WINDOW) {
     44         *x = -pixmap->screen_x;
     45         *y = -pixmap->screen_y;
     46         return;
     47     }
     48 #endif
     49 
     50     *x = 0;
     51     *y = 0;
     52 }
     53 
     54 void
     55 glamor_pixmap_init(ScreenPtr screen)
     56 {
     57 
     58 }
     59 
     60 void
     61 glamor_pixmap_fini(ScreenPtr screen)
     62 {
     63 }
     64 
     65 void
     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)
     69 {
     70     glamor_make_current(glamor_priv);
     71 
     72     glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
     73     glViewport(x0, y0, width, height);
     74 }
     75 
     76 void
     77 glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv,
     78                                       PixmapPtr pixmap,
     79                                       glamor_pixmap_private *pixmap_priv)
     80 {
     81     int w, h;
     82 
     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);
     85 }
     86 
     87 int
     88 glamor_set_destination_pixmap_priv(glamor_screen_private *glamor_priv,
     89                                    PixmapPtr pixmap,
     90                                    glamor_pixmap_private *pixmap_priv)
     91 {
     92     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
     93         return -1;
     94 
     95     glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv);
     96     return 0;
     97 }
     98 
     99 int
    100 glamor_set_destination_pixmap(PixmapPtr pixmap)
    101 {
    102     int err;
    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);
    106 
    107     err = glamor_set_destination_pixmap_priv(glamor_priv, pixmap, pixmap_priv);
    108     return err;
    109 }
    110 
    111 Bool
    112 glamor_set_planemask(int depth, unsigned long planemask)
    113 {
    114     if (glamor_pm_is_solid(depth, planemask)) {
    115         return GL_TRUE;
    116     }
    117 
    118     glamor_fallback("unsupported planemask %lx\n", planemask);
    119     return GL_FALSE;
    120 }
    121 
    122 Bool
    123 glamor_set_alu(ScreenPtr screen, unsigned char alu)
    124 {
    125     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
    126 
    127     if (glamor_priv->is_gles) {
    128         if (alu != GXcopy)
    129             return FALSE;
    130         else
    131             return TRUE;
    132     }
    133 
    134     if (alu == GXcopy) {
    135         glDisable(GL_COLOR_LOGIC_OP);
    136         return TRUE;
    137     }
    138     glEnable(GL_COLOR_LOGIC_OP);
    139     switch (alu) {
    140     case GXclear:
    141         glLogicOp(GL_CLEAR);
    142         break;
    143     case GXand:
    144         glLogicOp(GL_AND);
    145         break;
    146     case GXandReverse:
    147         glLogicOp(GL_AND_REVERSE);
    148         break;
    149     case GXandInverted:
    150         glLogicOp(GL_AND_INVERTED);
    151         break;
    152     case GXnoop:
    153         glLogicOp(GL_NOOP);
    154         break;
    155     case GXxor:
    156         glLogicOp(GL_XOR);
    157         break;
    158     case GXor:
    159         glLogicOp(GL_OR);
    160         break;
    161     case GXnor:
    162         glLogicOp(GL_NOR);
    163         break;
    164     case GXequiv:
    165         glLogicOp(GL_EQUIV);
    166         break;
    167     case GXinvert:
    168         glLogicOp(GL_INVERT);
    169         break;
    170     case GXorReverse:
    171         glLogicOp(GL_OR_REVERSE);
    172         break;
    173     case GXcopyInverted:
    174         glLogicOp(GL_COPY_INVERTED);
    175         break;
    176     case GXorInverted:
    177         glLogicOp(GL_OR_INVERTED);
    178         break;
    179     case GXnand:
    180         glLogicOp(GL_NAND);
    181         break;
    182     case GXset:
    183         glLogicOp(GL_SET);
    184         break;
    185     default:
    186         glamor_fallback("unsupported alu %x\n", alu);
    187         return FALSE;
    188     }
    189 
    190     return TRUE;
    191 }