VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/util/compositor.cpp@ 62479

Last change on this file since 62479 was 54860, checked in by vboxsync, 10 years ago

Host 3D: fix memory leak in crServer.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.8 KB
Line 
1/* $Id: compositor.cpp 54860 2015-03-20 09:56:49Z vboxsync $ */
2/** @file
3 * Compositor implementation.
4 */
5
6/*
7 * Copyright (C) 2013-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#include "../include/cr_compositor.h"
22
23
24/*******************************************************************************
25* Defined Constants And Macros *
26*******************************************************************************/
27#define VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED UINT32_MAX
28#ifdef IN_VMSVGA3D
29# define WARN AssertMsgFailed
30#endif
31
32
33
34static int crVrScrCompositorRectsAssignBuffer(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRects)
35{
36 Assert(cRects);
37
38 if (pCompositor->cRectsBuffer >= cRects)
39 {
40 pCompositor->cRects = cRects;
41 return VINF_SUCCESS;
42 }
43
44 if (pCompositor->cRectsBuffer)
45 {
46 Assert(pCompositor->paSrcRects);
47 RTMemFree(pCompositor->paSrcRects);
48 pCompositor->paSrcRects = NULL;
49 Assert(pCompositor->paDstRects);
50 RTMemFree(pCompositor->paDstRects);
51 pCompositor->paDstRects = NULL;
52 Assert(pCompositor->paDstUnstretchedRects);
53 RTMemFree(pCompositor->paDstUnstretchedRects);
54 pCompositor->paDstUnstretchedRects = NULL;
55 }
56 else
57 {
58 Assert(!pCompositor->paSrcRects);
59 Assert(!pCompositor->paDstRects);
60 Assert(!pCompositor->paDstUnstretchedRects);
61 }
62
63 pCompositor->paSrcRects = (PRTRECT)RTMemAlloc(sizeof(*pCompositor->paSrcRects) * cRects);
64 if (pCompositor->paSrcRects)
65 {
66 pCompositor->paDstRects = (PRTRECT)RTMemAlloc(sizeof(*pCompositor->paDstRects) * cRects);
67 if (pCompositor->paDstRects)
68 {
69 pCompositor->paDstUnstretchedRects = (PRTRECT)RTMemAlloc(sizeof(*pCompositor->paDstUnstretchedRects) * cRects);
70 if (pCompositor->paDstUnstretchedRects)
71 {
72 pCompositor->cRects = cRects;
73 pCompositor->cRectsBuffer = cRects;
74 return VINF_SUCCESS;
75 }
76
77 RTMemFree(pCompositor->paDstRects);
78 pCompositor->paDstRects = NULL;
79 }
80 else
81 {
82 WARN(("RTMemAlloc failed!"));
83 }
84 RTMemFree(pCompositor->paSrcRects);
85 pCompositor->paSrcRects = NULL;
86 }
87 else
88 {
89 WARN(("RTMemAlloc failed!"));
90 }
91
92 pCompositor->cRects = VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED;
93 pCompositor->cRectsBuffer = 0;
94
95 return VERR_NO_MEMORY;
96}
97
98static void crVrScrCompositorRectsInvalidate(PVBOXVR_SCR_COMPOSITOR pCompositor)
99{
100 pCompositor->cRects = VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED;
101}
102
103static DECLCALLBACK(bool) crVrScrCompositorRectsCounterCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry,
104 void *pvVisitor)
105{
106 uint32_t* pCounter = (uint32_t*)pvVisitor;
107 Assert(VBoxVrListRectsCount(&pEntry->Vr));
108 *pCounter += VBoxVrListRectsCount(&pEntry->Vr);
109 return true;
110}
111
112typedef struct VBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER
113{
114 PRTRECT paSrcRects;
115 PRTRECT paDstRects;
116 PRTRECT paDstUnstretchedRects;
117 uint32_t cRects;
118} VBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER, *PVBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER;
119
120static DECLCALLBACK(bool) crVrScrCompositorRectsAssignerCb(PVBOXVR_COMPOSITOR pCCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry,
121 void *pvVisitor)
122{
123 PVBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER pData = (PVBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER)pvVisitor;
124 PVBOXVR_SCR_COMPOSITOR pCompositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCCompositor);
125 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCEntry);
126 pEntry->paSrcRects = pData->paSrcRects;
127 pEntry->paDstRects = pData->paDstRects;
128 pEntry->paDstUnstretchedRects = pData->paDstUnstretchedRects;
129 uint32_t cRects = VBoxVrListRectsCount(&pCEntry->Vr);
130 Assert(cRects);
131 Assert(cRects <= pData->cRects);
132 int rc = VBoxVrListRectsGet(&pCEntry->Vr, cRects, pEntry->paDstUnstretchedRects);
133 AssertRC(rc);
134
135 if (!pEntry->Rect.xLeft && !pEntry->Rect.yTop)
136 {
137 memcpy(pEntry->paSrcRects, pEntry->paDstUnstretchedRects, cRects * sizeof(*pEntry->paSrcRects));
138 }
139 else
140 {
141 for (uint32_t i = 0; i < cRects; ++i)
142 {
143 pEntry->paSrcRects[i].xLeft = (int32_t)((pEntry->paDstUnstretchedRects[i].xLeft - pEntry->Rect.xLeft));
144 pEntry->paSrcRects[i].yTop = (int32_t)((pEntry->paDstUnstretchedRects[i].yTop - pEntry->Rect.yTop));
145 pEntry->paSrcRects[i].xRight = (int32_t)((pEntry->paDstUnstretchedRects[i].xRight - pEntry->Rect.xLeft));
146 pEntry->paSrcRects[i].yBottom = (int32_t)((pEntry->paDstUnstretchedRects[i].yBottom - pEntry->Rect.yTop));
147 }
148 }
149
150#ifndef IN_RING0
151 if (pCompositor->StretchX != 1. || pCompositor->StretchY != 1.)
152 {
153 for (uint32_t i = 0; i < cRects; ++i)
154 {
155 if (pCompositor->StretchX != 1.)
156 {
157 pEntry->paDstRects[i].xLeft = (int32_t)(pEntry->paDstUnstretchedRects[i].xLeft * pCompositor->StretchX);
158 pEntry->paDstRects[i].xRight = (int32_t)(pEntry->paDstUnstretchedRects[i].xRight * pCompositor->StretchX);
159 }
160 if (pCompositor->StretchY != 1.)
161 {
162 pEntry->paDstRects[i].yTop = (int32_t)(pEntry->paDstUnstretchedRects[i].yTop * pCompositor->StretchY);
163 pEntry->paDstRects[i].yBottom = (int32_t)(pEntry->paDstUnstretchedRects[i].yBottom * pCompositor->StretchY);
164 }
165 }
166 }
167 else
168#endif
169 {
170 memcpy(pEntry->paDstRects, pEntry->paDstUnstretchedRects, cRects * sizeof(*pEntry->paDstUnstretchedRects));
171 }
172
173#if 0//ndef IN_RING0
174 bool canZeroX = (pCompositor->StretchX < 1.);
175 bool canZeroY = (pCompositor->StretchY < 1.);
176 if (canZeroX && canZeroY)
177 {
178 /* filter out zero rectangles*/
179 uint32_t iOrig, iNew;
180 for (iOrig = 0, iNew = 0; iOrig < cRects; ++iOrig)
181 {
182 PRTRECT pOrigRect = &pEntry->paDstRects[iOrig];
183 if (pOrigRect->xLeft != pOrigRect->xRight
184 && pOrigRect->yTop != pOrigRect->yBottom)
185 continue;
186
187 if (iNew != iOrig)
188 {
189 PRTRECT pNewRect = &pEntry->paSrcRects[iNew];
190 *pNewRect = *pOrigRect;
191 }
192
193 ++iNew;
194 }
195
196 Assert(iNew <= iOrig);
197
198 uint32_t cDiff = iOrig - iNew;
199
200 if (cDiff)
201 {
202 pCompositor->cRects -= cDiff;
203 cRects -= cDiff;
204 }
205 }
206#endif
207
208 pEntry->cRects = cRects;
209 pData->paDstRects += cRects;
210 pData->paSrcRects += cRects;
211 pData->paDstUnstretchedRects += cRects;
212 pData->cRects -= cRects;
213 return true;
214}
215
216static int crVrScrCompositorRectsCheckInit(PCVBOXVR_SCR_COMPOSITOR pcCompositor)
217{
218 PVBOXVR_SCR_COMPOSITOR pCompositor = const_cast<PVBOXVR_SCR_COMPOSITOR>(pcCompositor);
219
220 if (pCompositor->cRects != VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED)
221 return VINF_SUCCESS;
222
223 uint32_t cRects = 0;
224 VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorRectsCounterCb, &cRects);
225
226 if (!cRects)
227 {
228 pCompositor->cRects = 0;
229 return VINF_SUCCESS;
230 }
231
232 int rc = crVrScrCompositorRectsAssignBuffer(pCompositor, cRects);
233 if (RT_FAILURE(rc))
234 return rc;
235
236 VBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER AssignerData;
237 AssignerData.paSrcRects = pCompositor->paSrcRects;
238 AssignerData.paDstRects = pCompositor->paDstRects;
239 AssignerData.paDstUnstretchedRects = pCompositor->paDstUnstretchedRects;
240 AssignerData.cRects = pCompositor->cRects;
241 VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorRectsAssignerCb, &AssignerData);
242 Assert(!AssignerData.cRects);
243 return VINF_SUCCESS;
244}
245
246
247static int crVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
248 uint32_t cRegions, PCRTRECT paRegions,
249 VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, uint32_t *pfChangedFlags)
250{
251 uint32_t fChangedFlags = 0;
252 PVBOXVR_COMPOSITOR_ENTRY pReplacedEntry;
253 int rc = VBoxVrCompositorEntryRegionsAdd(&pCompositor->Compositor, pEntry ? &pEntry->Ce : NULL, cRegions,
254 paRegions, &pReplacedEntry, &fChangedFlags);
255 if (RT_FAILURE(rc))
256 {
257 WARN(("VBoxVrCompositorEntryRegionsAdd failed, rc %d", rc));
258 return rc;
259 }
260
261 VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacedScrEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacedEntry);
262
263 if (fChangedFlags & VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED)
264 crVrScrCompositorRectsInvalidate(pCompositor);
265 else if (fChangedFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED)
266 Assert(pReplacedScrEntry);
267
268 if (fChangedFlags & VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED)
269 CrVrScrCompositorEntrySetAllChanged(pCompositor, true);
270 else if ((fChangedFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED) && pEntry)
271 CrVrScrCompositorEntrySetChanged(pEntry, true);
272
273 if (pfChangedFlags)
274 *pfChangedFlags = fChangedFlags;
275
276 if (ppReplacedScrEntry)
277 *ppReplacedScrEntry = pReplacedScrEntry;
278
279 return VINF_SUCCESS;
280}
281
282static int crVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
283 uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged)
284{
285 bool fChanged;
286 int rc = VBoxVrCompositorEntryRegionsSet(&pCompositor->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged);
287 if (RT_FAILURE(rc))
288 {
289 WARN(("VBoxVrCompositorEntryRegionsSet failed, rc %d", rc));
290 return rc;
291 }
292
293 if (fChanged)
294 {
295 CrVrScrCompositorEntrySetAllChanged(pCompositor, true);
296 if (!CrVrScrCompositorEntryIsInList(pEntry))
297 {
298 pEntry->cRects = 0;
299 pEntry->paSrcRects = NULL;
300 pEntry->paDstRects = NULL;
301 pEntry->paDstUnstretchedRects = NULL;
302 }
303 crVrScrCompositorRectsInvalidate(pCompositor);
304 }
305
306
307 if (pfChanged)
308 *pfChanged = fChanged;
309 return VINF_SUCCESS;
310}
311
312static int crVrScrCompositorEntryPositionSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
313 PCRTPOINT pPos, bool *pfChanged)
314{
315 if (pfChanged)
316 *pfChanged = false;
317 if (pEntry && (pEntry->Rect.xLeft != pPos->x || pEntry->Rect.yTop != pPos->y))
318 {
319 if (VBoxVrCompositorEntryIsInList(&pEntry->Ce))
320 {
321 int rc = VBoxVrCompositorEntryRegionsTranslate(&pCompositor->Compositor, &pEntry->Ce, pPos->x - pEntry->Rect.xLeft,
322 pPos->y - pEntry->Rect.yTop, pfChanged);
323 if (RT_FAILURE(rc))
324 {
325 WARN(("VBoxVrCompositorEntryRegionsTranslate failed rc %d", rc));
326 return rc;
327 }
328
329 crVrScrCompositorRectsInvalidate(pCompositor);
330 }
331
332 VBoxRectMove(&pEntry->Rect, pPos->x, pPos->y);
333 CrVrScrCompositorEntrySetChanged(pEntry, true);
334
335 if (pfChanged)
336 *pfChanged = true;
337 }
338 return VINF_SUCCESS;
339}
340
341static int crVrScrCompositorEntryEnsureRegionsBounds(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
342 bool *pfChanged)
343{
344 RTRECT Rect;
345 Rect.xLeft = RT_MAX(pCompositor->Rect.xLeft, pEntry->Rect.xLeft);
346 Rect.yTop = RT_MAX(pCompositor->Rect.yTop, pEntry->Rect.yTop);
347 Rect.xRight = RT_MIN(pCompositor->Rect.xRight, pEntry->Rect.xRight);
348 Rect.yBottom = RT_MIN(pCompositor->Rect.yBottom, pEntry->Rect.yBottom);
349 bool fChanged = false;
350
351 if (pfChanged)
352 *pfChanged = false;
353
354 int rc = CrVrScrCompositorEntryRegionsIntersect(pCompositor, pEntry, 1, &Rect, &fChanged);
355 if (RT_FAILURE(rc))
356 WARN(("CrVrScrCompositorEntryRegionsIntersect failed, rc %d", rc));
357
358 if (pfChanged)
359 *pfChanged = fChanged;
360 return rc;
361}
362
363VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
364 PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions,
365 bool fPosRelated, VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry,
366 uint32_t *pfChangeFlags)
367{
368 int rc;
369 uint32_t fChangeFlags = 0;
370 bool fPosChanged = false;
371 RTRECT *paTranslatedRects = NULL;
372 if (pPos)
373 {
374 rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, pPos, &fPosChanged);
375 if (RT_FAILURE(rc))
376 {
377 WARN(("RegionsAdd: crVrScrCompositorEntryPositionSet failed rc %d", rc));
378 return rc;
379 }
380 }
381
382 if (fPosRelated)
383 {
384 if (!pEntry)
385 {
386 WARN(("Entry is expected to be specified for pos-related regions"));
387 return VERR_INVALID_PARAMETER;
388 }
389
390 if (cRegions && (pEntry->Rect.xLeft || pEntry->Rect.yTop))
391 {
392 paTranslatedRects = (RTRECT*)RTMemAlloc(sizeof(RTRECT) * cRegions);
393 if (!paTranslatedRects)
394 {
395 WARN(("RTMemAlloc failed"));
396 return VERR_NO_MEMORY;
397 }
398 memcpy (paTranslatedRects, paRegions, sizeof(RTRECT) * cRegions);
399 for (uint32_t i = 0; i < cRegions; ++i)
400 {
401 VBoxRectTranslate(&paTranslatedRects[i], pEntry->Rect.xLeft, pEntry->Rect.yTop);
402 paRegions = paTranslatedRects;
403 }
404 }
405 }
406
407 rc = crVrScrCompositorEntryRegionsAdd(pCompositor, pEntry, cRegions, paRegions, ppReplacedScrEntry, &fChangeFlags);
408 if (RT_FAILURE(rc))
409 {
410 WARN(("crVrScrCompositorEntryRegionsAdd failed, rc %d", rc));
411 goto done;
412 }
413
414 if ((fPosChanged || (fChangeFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED)) && pEntry)
415 {
416 bool fAdjusted = false;
417 rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, &fAdjusted);
418 if (RT_FAILURE(rc))
419 {
420 WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc));
421 goto done;
422 }
423
424 if (fAdjusted)
425 {
426 if (CrVrScrCompositorEntryIsUsed(pEntry))
427 {
428 fChangeFlags &= ~VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED;
429 fChangeFlags |= VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED;
430 }
431 else
432 {
433 fChangeFlags = 0;
434 }
435 }
436 }
437
438 if (fChangeFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED)
439 fPosChanged = false;
440 else if (ppReplacedScrEntry)
441 *ppReplacedScrEntry = NULL;
442
443 if (pfChangeFlags)
444 {
445 if (fPosChanged)
446 {
447 /* means entry was in list and was moved, so regions changed */
448 *pfChangeFlags = VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED
449 | VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED;
450 }
451 else
452 *pfChangeFlags = fChangeFlags;
453 }
454
455done:
456
457 if (paTranslatedRects)
458 RTMemFree(paTranslatedRects);
459
460 return rc;
461}
462
463VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
464 PCRTRECT pRect)
465{
466 if (!memcmp(&pEntry->Rect, pRect, sizeof(*pRect)))
467 {
468 return VINF_SUCCESS;
469 }
470 RTPOINT Point = {pRect->xLeft, pRect->yTop};
471 bool fChanged = false;
472 int rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, &Point, &fChanged);
473 if (RT_FAILURE(rc))
474 {
475 WARN(("crVrScrCompositorEntryPositionSet failed %d", rc));
476 return rc;
477 }
478
479 pEntry->Rect = *pRect;
480
481 if (!CrVrScrCompositorEntryIsUsed(pEntry))
482 return VINF_SUCCESS;
483
484 rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL);
485 if (RT_FAILURE(rc))
486 {
487 WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc));
488 return rc;
489 }
490
491 return VINF_SUCCESS;
492}
493
494VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
495 CR_TEXDATA *pTex)
496{
497 if (pEntry->pTex == pTex)
498 return VINF_SUCCESS;
499
500 if (pEntry->pTex)
501 CrTdRelease(pEntry->pTex);
502 if (pTex)
503 CrTdAddRef(pTex);
504 pEntry->pTex = pTex;
505 return VINF_SUCCESS;
506}
507
508VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
509 PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions,
510 bool fPosRelated, bool *pfChanged)
511{
512 /* @todo: the fChanged sate calculation is really rough now, this is enough for now though */
513 bool fChanged = false, fPosChanged = false;
514 bool fWasInList = CrVrScrCompositorEntryIsInList(pEntry);
515 RTRECT *paTranslatedRects = NULL;
516 int rc = CrVrScrCompositorEntryRemove(pCompositor, pEntry);
517 if (RT_FAILURE(rc))
518 {
519 WARN(("RegionsSet: CrVrScrCompositorEntryRemove failed rc %d", rc));
520 return rc;
521 }
522
523 if (pPos)
524 {
525 rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, pPos, &fPosChanged);
526 if (RT_FAILURE(rc))
527 {
528 WARN(("RegionsSet: crVrScrCompositorEntryPositionSet failed rc %d", rc));
529 return rc;
530 }
531 }
532
533 if (fPosRelated)
534 {
535 if (!pEntry)
536 {
537 WARN(("Entry is expected to be specified for pos-related regions"));
538 return VERR_INVALID_PARAMETER;
539 }
540
541 if (cRegions && (pEntry->Rect.xLeft || pEntry->Rect.yTop))
542 {
543 paTranslatedRects = (RTRECT*)RTMemAlloc(sizeof(RTRECT) * cRegions);
544 if (!paTranslatedRects)
545 {
546 WARN(("RTMemAlloc failed"));
547 return VERR_NO_MEMORY;
548 }
549 memcpy (paTranslatedRects, paRegions, sizeof(RTRECT) * cRegions);
550 for (uint32_t i = 0; i < cRegions; ++i)
551 {
552 VBoxRectTranslate(&paTranslatedRects[i], pEntry->Rect.xLeft, pEntry->Rect.yTop);
553 paRegions = paTranslatedRects;
554 }
555 }
556 }
557
558 rc = crVrScrCompositorEntryRegionsSet(pCompositor, pEntry, cRegions, paRegions, &fChanged);
559 if (RT_SUCCESS(rc))
560 {
561 if (fChanged && CrVrScrCompositorEntryIsUsed(pEntry))
562 {
563 rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL);
564 if (RT_SUCCESS(rc))
565 {
566 if (pfChanged)
567 *pfChanged = fPosChanged || fChanged || fWasInList;
568 }
569 else
570 WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc));
571 }
572
573 }
574 else
575 WARN(("crVrScrCompositorEntryRegionsSet failed, rc %d", rc));
576
577 if (paTranslatedRects)
578 RTMemFree(paTranslatedRects);
579
580 return rc;
581}
582
583VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
584 PCVBOXVR_LIST pList2, bool *pfChanged)
585{
586 bool fChanged = false;
587 int rc = VBoxVrCompositorEntryListIntersect(&pCompositor->Compositor, &pEntry->Ce, pList2, &fChanged);
588 if (RT_FAILURE(rc))
589 {
590 WARN(("RegionsIntersect: VBoxVrCompositorEntryRegionsIntersect failed rc %d", rc));
591 return rc;
592 }
593
594 if (fChanged)
595 {
596 CrVrScrCompositorEntrySetChanged(pEntry, true);
597 crVrScrCompositorRectsInvalidate(pCompositor);
598 }
599
600 if (pfChanged)
601 *pfChanged = fChanged;
602
603 return VINF_SUCCESS;
604}
605
606VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
607 uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged)
608{
609 bool fChanged = false;
610 int rc = VBoxVrCompositorEntryRegionsIntersect(&pCompositor->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged);
611 if (RT_FAILURE(rc))
612 {
613 WARN(("RegionsIntersect: VBoxVrCompositorEntryRegionsIntersect failed rc %d", rc));
614 return rc;
615 }
616
617 if (fChanged)
618 crVrScrCompositorRectsInvalidate(pCompositor);
619
620 if (pfChanged)
621 *pfChanged = fChanged;
622
623 return VINF_SUCCESS;
624}
625
626VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2, bool *pfChanged)
627{
628 VBOXVR_SCR_COMPOSITOR_ITERATOR Iter;
629 CrVrScrCompositorIterInit(pCompositor, &Iter);
630 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
631 int rc = VINF_SUCCESS;
632 bool fChanged = false;
633
634 while ((pEntry = CrVrScrCompositorIterNext(&Iter)) != NULL)
635 {
636 bool fTmpChanged = false;
637 int tmpRc = CrVrScrCompositorEntryListIntersect(pCompositor, pEntry, pList2, &fTmpChanged);
638 if (RT_SUCCESS(tmpRc))
639 {
640 fChanged |= fTmpChanged;
641 }
642 else
643 {
644 WARN(("CrVrScrCompositorEntryRegionsIntersect failed, rc %d", tmpRc));
645 rc = tmpRc;
646 }
647 }
648
649 if (pfChanged)
650 *pfChanged = fChanged;
651
652 return rc;
653}
654
655VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions,
656 PCRTRECT paRegions, bool *pfChanged)
657{
658 VBOXVR_SCR_COMPOSITOR_ITERATOR Iter;
659 CrVrScrCompositorIterInit(pCompositor, &Iter);
660 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
661 int rc = VINF_SUCCESS;
662 bool fChanged = false;
663
664 while ((pEntry = CrVrScrCompositorIterNext(&Iter)) != NULL)
665 {
666 bool fTmpChanged = false;
667 int tmpRc = CrVrScrCompositorEntryRegionsIntersect(pCompositor, pEntry, cRegions, paRegions, &fTmpChanged);
668 if (RT_SUCCESS(tmpRc))
669 {
670 fChanged |= fTmpChanged;
671 }
672 else
673 {
674 WARN(("CrVrScrCompositorEntryRegionsIntersect failed, rc %d", tmpRc));
675 rc = tmpRc;
676 }
677 }
678
679 if (pfChanged)
680 *pfChanged = fChanged;
681
682 return rc;
683}
684
685VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
686 PCRTPOINT pPos)
687{
688 int rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, pPos, NULL);
689 if (RT_FAILURE(rc))
690 {
691 WARN(("RegionsSet: crVrScrCompositorEntryPositionSet failed rc %d", rc));
692 return rc;
693 }
694
695 rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL);
696 if (RT_FAILURE(rc))
697 {
698 WARN(("RegionsSet: crVrScrCompositorEntryEnsureRegionsBounds failed rc %d", rc));
699 return rc;
700 }
701
702 return VINF_SUCCESS;
703}
704
705/* regions are valid until the next CrVrScrCompositor call */
706VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor,
707 PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t *pcRegions,
708 PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions,
709 PCRTRECT *ppaDstUnstretchedRects)
710{
711 if (CrVrScrCompositorEntryIsUsed(pEntry))
712 {
713 int rc = crVrScrCompositorRectsCheckInit(pCompositor);
714 if (RT_FAILURE(rc))
715 {
716 WARN(("crVrScrCompositorRectsCheckInit failed, rc %d", rc));
717 return rc;
718 }
719 }
720
721 Assert(pCompositor->cRects != VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED);
722
723 *pcRegions = pEntry->cRects;
724 if (ppaSrcRegions)
725 *ppaSrcRegions = pEntry->paSrcRects;
726 if (ppaDstRegions)
727 *ppaDstRegions = pEntry->paDstRects;
728 if (ppaDstUnstretchedRects)
729 *ppaDstUnstretchedRects = pEntry->paDstUnstretchedRects;
730
731 return VINF_SUCCESS;
732}
733
734VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(PCVBOXVR_SCR_COMPOSITOR pCompositor,
735 PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
736{
737 return CRBLT_FOP_COMBINE(pCompositor->fFlags, pEntry->fFlags);
738}
739
740VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags)
741{
742 if (pEntry->fFlags == fFlags)
743 return;
744
745 pEntry->fFlags = fFlags;
746 CrVrScrCompositorEntrySetChanged(pEntry, true);
747}
748
749static void crVrScrCompositorEntryDataCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
750{
751 pEntry->cRects = 0;
752 pEntry->paSrcRects = NULL;
753 pEntry->paDstRects = NULL;
754 pEntry->paDstUnstretchedRects = NULL;
755}
756
757static void crVrScrCompositorEntryDataCopy(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, PVBOXVR_SCR_COMPOSITOR_ENTRY pToEntry)
758{
759 pToEntry->cRects = pEntry->cRects;
760 pToEntry->paSrcRects = pEntry->paSrcRects;
761 pToEntry->paDstRects = pEntry->paDstRects;
762 pToEntry->paDstUnstretchedRects = pEntry->paDstUnstretchedRects;
763 crVrScrCompositorEntryDataCleanup(pEntry);
764}
765
766VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
767{
768 if (!VBoxVrCompositorEntryRemove(&pCompositor->Compositor, &pEntry->Ce))
769 return VINF_SUCCESS;
770
771 CrVrScrCompositorEntrySetChanged(pEntry, true);
772 crVrScrCompositorEntryDataCleanup(pEntry);
773
774 crVrScrCompositorRectsInvalidate(pCompositor);
775 return VINF_SUCCESS;
776}
777
778VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
779 PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry)
780{
781 Assert(!CrVrScrCompositorEntryIsUsed(pNewEntry));
782
783 if (!VBoxVrCompositorEntryReplace(&pCompositor->Compositor, &pEntry->Ce, &pNewEntry->Ce))
784 return false;
785
786 CrVrScrCompositorEntrySetChanged(pEntry, true);
787 crVrScrCompositorEntryDataCopy(pEntry, pNewEntry);
788 CrVrScrCompositorEntrySetChanged(pNewEntry, true);
789
790 return true;
791}
792
793static DECLCALLBACK(void) crVrScrCompositorEntryReleasedCB(PCVBOXVR_COMPOSITOR pCompositor,
794 PVBOXVR_COMPOSITOR_ENTRY pEntry,
795 PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry)
796{
797 PVBOXVR_SCR_COMPOSITOR_ENTRY pCEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pEntry);
798
799 CrVrScrCompositorEntrySetChanged(pCEntry, true);
800
801 Assert(!CrVrScrCompositorEntryIsInList(pCEntry));
802
803 if (pReplacingEntry)
804 {
805 PVBOXVR_SCR_COMPOSITOR_ENTRY pCReplacingEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacingEntry);
806 Assert(CrVrScrCompositorEntryIsInList(pCReplacingEntry));
807 pCReplacingEntry->cRects = pCEntry->cRects;
808 pCReplacingEntry->paSrcRects = pCEntry->paSrcRects;
809 pCReplacingEntry->paDstRects = pCEntry->paDstRects;
810 pCReplacingEntry->paDstUnstretchedRects = pCEntry->paDstUnstretchedRects;
811 }
812
813 if (pCEntry->pfnEntryReleased)
814 {
815 PVBOXVR_SCR_COMPOSITOR_ENTRY pCReplacingEntry = pReplacingEntry
816 ? VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacingEntry) : NULL;
817 PVBOXVR_SCR_COMPOSITOR pCConpositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCompositor);
818 pCEntry->pfnEntryReleased(pCConpositor, pCEntry, pCReplacingEntry);
819 }
820}
821
822VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect, bool *pfChanged)
823{
824 if (!memcmp(&pCompositor->Rect, pRect, sizeof(pCompositor->Rect)))
825 {
826 if (pfChanged)
827 *pfChanged = false;
828 return VINF_SUCCESS;
829 }
830
831 pCompositor->Rect = *pRect;
832
833 VBOXVR_SCR_COMPOSITOR_ITERATOR Iter;
834 CrVrScrCompositorIterInit(pCompositor, &Iter);
835 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
836 while ((pEntry = CrVrScrCompositorIterNext(&Iter)) != NULL)
837 {
838 int rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL);
839 if (RT_FAILURE(rc))
840 {
841 WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc));
842 return rc;
843 }
844 }
845
846 return VINF_SUCCESS;
847}
848
849VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect)
850{
851 memset(pCompositor, 0, sizeof(*pCompositor));
852 VBoxVrCompositorInit(&pCompositor->Compositor, crVrScrCompositorEntryReleasedCB);
853 pCompositor->fFlags = CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS;
854 if (pRect)
855 pCompositor->Rect = *pRect;
856#ifndef IN_RING0
857 pCompositor->StretchX = 1.0;
858 pCompositor->StretchY = 1.0;
859#endif
860}
861
862VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged)
863{
864 /* set changed flag first, while entries are in the list and we have them */
865 CrVrScrCompositorEntrySetAllChanged(pCompositor, true);
866 VBoxVrCompositorRegionsClear(&pCompositor->Compositor, pfChanged);
867 crVrScrCompositorRectsInvalidate(pCompositor);
868}
869
870VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor)
871{
872 CrVrScrCompositorRegionsClear(pCompositor, NULL);
873 if (pCompositor->paDstRects)
874 {
875 RTMemFree(pCompositor->paDstRects);
876 pCompositor->paDstRects = NULL;
877 }
878 if (pCompositor->paSrcRects)
879 {
880 RTMemFree(pCompositor->paSrcRects);
881 pCompositor->paSrcRects = NULL;
882 }
883 if (pCompositor->paDstUnstretchedRects)
884 {
885 RTMemFree(pCompositor->paDstUnstretchedRects);
886 pCompositor->paDstUnstretchedRects = NULL;
887 }
888
889 pCompositor->cRects = 0;
890 pCompositor->cRectsBuffer = 0;
891}
892
893VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged)
894{
895 VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
896 PVBOXVR_SCR_COMPOSITOR_ENTRY pCurEntry;
897 CrVrScrCompositorIterInit(pCompositor, &CIter);
898
899 while ((pCurEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
900 {
901 CrVrScrCompositorEntrySetChanged(pCurEntry, fChanged);
902 }
903}
904
905#ifndef IN_RING0
906VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY)
907{
908 if (pCompositor->StretchX == StretchX && pCompositor->StretchY == StretchY)
909 return;
910
911 pCompositor->StretchX = StretchX;
912 pCompositor->StretchY = StretchY;
913 crVrScrCompositorRectsInvalidate(pCompositor);
914 CrVrScrCompositorEntrySetAllChanged(pCompositor, true);
915}
916#endif
917
918/* regions are valid until the next CrVrScrCompositor call */
919VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t *pcRegions,
920 PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions,
921 PCRTRECT *ppaDstUnstretchedRects)
922{
923 int rc = crVrScrCompositorRectsCheckInit(pCompositor);
924 if (RT_FAILURE(rc))
925 {
926 WARN(("crVrScrCompositorRectsCheckInit failed, rc %d", rc));
927 return rc;
928 }
929
930 Assert(pCompositor->cRects != VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED);
931
932 *pcRegions = pCompositor->cRects;
933 if (ppaSrcRegions)
934 *ppaSrcRegions = pCompositor->paSrcRects;
935 if (ppaDstRegions)
936 *ppaDstRegions = pCompositor->paDstRects;
937 if (ppaDstUnstretchedRects)
938 *ppaDstUnstretchedRects = pCompositor->paDstUnstretchedRects;
939
940 return VINF_SUCCESS;
941}
942
943typedef struct VBOXVR_SCR_COMPOSITOR_VISITOR_CB
944{
945 PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor;
946 void *pvVisitor;
947} VBOXVR_SCR_COMPOSITOR_VISITOR_CB, *PVBOXVR_SCR_COMPOSITOR_VISITOR_CB;
948
949static DECLCALLBACK(bool) crVrScrCompositorVisitCb(PVBOXVR_COMPOSITOR pCCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry,
950 void *pvVisitor)
951{
952 PVBOXVR_SCR_COMPOSITOR_VISITOR_CB pData = (PVBOXVR_SCR_COMPOSITOR_VISITOR_CB)pvVisitor;
953 PVBOXVR_SCR_COMPOSITOR pCompositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCCompositor);
954 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCEntry);
955 return pData->pfnVisitor(pCompositor, pEntry, pData->pvVisitor);
956}
957
958VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor,
959 void *pvVisitor)
960{
961 VBOXVR_SCR_COMPOSITOR_VISITOR_CB Data;
962 Data.pfnVisitor = pfnVisitor;
963 Data.pvVisitor = pvVisitor;
964 VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorVisitCb, &Data);
965}
966
967VBOXVREGDECL(int) CrVrScrCompositorClone(PCVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor,
968 PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor)
969{
970 /* for simplicity just copy from one to another */
971 CrVrScrCompositorInit(pDstCompositor, CrVrScrCompositorRectGet(pCompositor));
972 VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter;
973 PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
974 CrVrScrCompositorConstIterInit(pCompositor, &CIter);
975 int rc = VINF_SUCCESS;
976 uint32_t cRects;
977 PCRTRECT paRects;
978
979 while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL)
980 {
981 /* get source rects, that will be non-stretched and entry pos - pased */
982 rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRects, NULL, NULL, &paRects);
983 if (RT_FAILURE(rc))
984 {
985 WARN(("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc));
986 return rc;
987 }
988
989 PVBOXVR_SCR_COMPOSITOR_ENTRY pDstEntry = pfnEntryFor(pEntry, pvEntryFor);
990 if (!pDstEntry)
991 {
992 WARN(("pfnEntryFor failed"));
993 return VERR_INVALID_STATE;
994 }
995
996 rc = CrVrScrCompositorEntryRegionsSet(pDstCompositor, pDstEntry, NULL, cRects, paRects, false, NULL);
997 if (RT_FAILURE(rc))
998 {
999 WARN(("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc));
1000 return rc;
1001 }
1002 }
1003
1004 return rc;
1005}
1006
1007VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, bool *pfChanged)
1008{
1009 VBOXVR_SCR_COMPOSITOR_ITERATOR CIter;
1010 PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry;
1011 CrVrScrCompositorIterInit(pCompositor, &CIter);
1012 int rc = VINF_SUCCESS;
1013 bool fChanged = false;
1014
1015 while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL)
1016 {
1017 bool fCurChanged = false;
1018
1019 rc = CrVrScrCompositorEntryListIntersect(pCompositor, pEntry, pVr, &fCurChanged);
1020 if (RT_FAILURE(rc))
1021 {
1022 WARN(("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc));
1023 break;
1024 }
1025
1026 fChanged |= fCurChanged;
1027 }
1028
1029 if (pfChanged)
1030 *pfChanged = fChanged;
1031
1032 return rc;
1033}
1034
1035VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(PCVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr,
1036 PVBOXVR_SCR_COMPOSITOR pDstCompositor,
1037 PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor,
1038 bool *pfChanged)
1039{
1040 int rc = CrVrScrCompositorClone(pCompositor, pDstCompositor, pfnEntryFor, pvEntryFor);
1041 if (RT_FAILURE(rc))
1042 {
1043 WARN(("CrVrScrCompositorClone failed, rc %d", rc));
1044 return rc;
1045 }
1046
1047 rc = CrVrScrCompositorIntersectList(pDstCompositor, pVr, pfChanged);
1048 if (RT_FAILURE(rc))
1049 {
1050 WARN(("CrVrScrCompositorIntersectList failed, rc %d", rc));
1051 CrVrScrCompositorClear(pDstCompositor);
1052 return rc;
1053 }
1054
1055 return VINF_SUCCESS;
1056}
1057
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette