[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    Re: Question regarding XGetImage in libx11
From:       Chuanlong Du <longendu () yahoo ! com>
Date:       2021-08-01 0:40:47
Message-ID: 1726910063.1082259.1627778447859 () mail ! yahoo ! com
[Download RAW message or body]

Thank you very much for the explanation, Alan!

    On Saturday, July 31, 2021, 9:36:07 AM PDT, Alan Coopersmith <alan.coopersmith@oracle.com> wrote:  
 
 On 7/30/21 10:49 PM, Chuanlong Du wrote:
> I was reading the source code of the file GetImage.c 
> <https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c>  and got 
> confused about the function XGetImage. Specifically, I'm confused about where 
> the defined variable registerxGetImageReq*req; is used. The function never uses 
> it again after setting values for req at line 83 
> <https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L83>. 

The GetReq() call at line 73 sets up req to be in the Xlib buffer of requests to
send to the X server.   The _XReply call at line 85 causes everything in that
buffer, including req, to be sent to the X server for processing, so it
implicitly processes the contents of req.

> At line 85 
> <https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L85>, 
> does the function _XReply copy the whole display/screen's data to rep or just 
> the specified rectangle defined by req? If _XReply copies the whole 
> display/screen's data, where does the function XGetImage crop the image to keep 
> the specified rectangle only?

The function _XReply simply sends the message to the X server, who does all the
processing and returns the reply.   The X server is responsible for copying just
the specified area, not the whole screen, so Xlib does not need to do any
cropping on its own.

-- 
       -Alan Coopersmith-                     alan.coopersmith@oracle.com
       Oracle Solaris Engineering - https://blogs.oracle.com/alanc
  
[Attachment #3 (text/html)]

<html><head></head><body><div class="ydpdb26dceayahoo-style-wrap" style="font-family: \
                Helvetica Neue, Helvetica, Arial, sans-serif; font-size: \
                13px;"><div></div>
        <div dir="ltr" data-setdir="false">Thank you very much for the explanation, \
Alan!<br></div><div><br></div>  
        </div><div id="yahoo_quoted_8069990656" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, \
sans-serif;font-size:13px;color:#26282a;">  
                <div>
                    On Saturday, July 31, 2021, 9:36:07 AM PDT, Alan Coopersmith \
&lt;alan.coopersmith@oracle.com&gt; wrote:  </div>
                <div><br></div>
                <div><br></div>
                <div><div dir="ltr">On 7/30/21 10:49 PM, Chuanlong Du wrote:<br \
clear="none">&gt; I was reading the source code of the file GetImage.c <br \
clear="none">&gt; &lt;<a shape="rect" \
href="https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c" \
target="_blank">https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c</a>&gt;&nbsp;and \
got <br clear="none">&gt; confused about the function XGetImage. Specifically, I'm \
confused about where <br clear="none">&gt; the defined variable \
registerxGetImageReq*req; is used. The function never uses <br clear="none">&gt; it \
again after setting values for req at line 83 <br clear="none">&gt; &lt;<a \
shape="rect" href="https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L83" \
target="_blank">https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L83</a>&gt;. \
<br clear="none"><br clear="none">The GetReq() call at line 73 sets up req to be in \
the Xlib buffer of requests to<br clear="none">send to the X server.&nbsp; The \
_XReply call at line 85 causes everything in that<br clear="none">buffer, including \
req, to be sent to the X server for processing, so it<br clear="none">implicitly \
processes the contents of req.<br clear="none"><br clear="none">&gt; At line 85 <br \
clear="none">&gt; &lt;<a shape="rect" \
href="https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L85" \
target="_blank">https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L85</a>&gt;, \
<div class="yqt2729942560" id="yqtfd84185"><br clear="none">&gt; does the function \
_XReply copy the whole display/screen's data to rep or just <br clear="none">&gt; the \
specified rectangle defined by req? If _XReply copies the whole <br clear="none">&gt; \
display/screen's data, where does the function XGetImage crop the image to keep <br \
clear="none">&gt; the specified rectangle only?</div><br clear="none"><br \
clear="none">The function _XReply simply sends the message to the X server, who does \
all the<br clear="none">processing and returns the reply.&nbsp; The X server is \
responsible for copying just<br clear="none">the specified area, not the whole \
screen, so Xlib does not need to do any<br clear="none">cropping on its own.<br \
clear="none"><br clear="none">-- <br clear="none">&nbsp;&nbsp;&nbsp; -Alan \
Coopersmith-&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <a shape="rect" \
ymailto="mailto:alan.coopersmith@oracle.com" \
href="mailto:alan.coopersmith@oracle.com">alan.coopersmith@oracle.com</a><br \
clear="none">&nbsp;&nbsp;&nbsp;  Oracle Solaris Engineering - <a shape="rect" \
href="https://blogs.oracle.com/alanc" \
target="_blank">https://blogs.oracle.com/alanc</a><div class="yqt2729942560" \
id="yqtfd61631"><br clear="none"></div></div></div>  </div>
        </div></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic