gceSTATUS
ppoPREPROCESSOR_MacroExpand_0_SelfContain(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *Head,
    ppoTOKEN            *End,
    gctBOOL             *AnyExpanationHappened,
    gctBOOL             *MatchCase,
    ppoTOKEN            *ID)
{
    gceSTATUS status = gcvSTATUS_INVALID_DATA;

    ppoTOKEN id = gcvNULL;

    gctBOOL inhs = gcvFALSE;

    gcmONERROR(
        (*IS)->GetToken(PP, IS, &id, !ppvICareWhiteSpace)
        );

    gcmASSERT(id && id->type == ppvTokenType_ID);

    *ID = id;

    gcmTRACE(gcvLEVEL_VERBOSE, "ME : Begin to process %s.", id->poolString);

    gcmONERROR(
        ppoHIDE_SET_LIST_ContainSelf(PP, id, &inhs)
        );

    if (inhs == gcvTRUE)
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : self-contain.",id->poolString);

        *Head = id;
        *End  = id;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvTRUE;

        return gcvSTATUS_OK;
    }
    else
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : not self-contain.",id->poolString);

        *Head = gcvNULL;
        *End  = gcvNULL;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvFALSE;

        return gcvSTATUS_OK;
    }
OnError:
    if (id != gcvNULL)
    {
        gcmVERIFY_OK(ppoTOKEN_Destroy(PP, id));
        id = gcvNULL;
    }
    return status;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_3_NoMoreTokenInIS(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *Head,
    ppoTOKEN            *End,
    gctBOOL             *AnyExpanationHappened,
    gctBOOL             *MatchCase,
    ppoTOKEN            ID
    )
{
    ppoTOKEN id = ID;

    if ((*IS) == gcvNULL)
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s, no real arg list.", id->poolString);

        *Head = id;
        *End  = id;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvTRUE;
    }
    else
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s, has real arg list.", id->poolString);

        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvFALSE;
    }

    return gcvSTATUS_OK;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_4_NoRealArg(
                                        ppoPREPROCESSOR     PP,
                                        ppoINPUT_STREAM     *IS,
                                        ppoTOKEN            *Head,
                                        ppoTOKEN            *End,
                                        gctBOOL             *AnyExpanationHappened,
                                        gctBOOL             *MatchCase,
                                        ppoTOKEN            ID
                                        )
{
    gceSTATUS status;

    ppoTOKEN id = ID;

    ppoTOKEN ahead = gcvNULL;

    gcmONERROR(
        (*IS)->GetToken(PP, IS, &ahead, !ppvICareWhiteSpace)
        );

    if (ahead->poolString != PP->keyword->lpara)
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s, no real arg.", id->poolString);

        *Head = id;
        *End  = id;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvTRUE;

        gcmONERROR(
            ppoINPUT_STREAM_UnGetToken(PP, (ppoINPUT_STREAM *)IS, ahead));

        gcmONERROR(ppoTOKEN_Destroy(PP, ahead));

        return gcvSTATUS_OK;
    }
    else
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s, real arg.", id->poolString);

        *MatchCase = gcvFALSE;
        *AnyExpanationHappened = gcvFALSE;

        gcmONERROR(
            ppoINPUT_STREAM_UnGetToken(PP, IS, ahead)
            );

        return gcvSTATUS_OK;
    }
OnError:
    if (ahead != gcvNULL)
    {
        gcmVERIFY_OK(ppoTOKEN_Destroy(PP, ahead));
        ahead = gcvNULL;
    }
	return status;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_6_ExpandHeadTail(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *HeadTail,
    ppoTOKEN            *ExpandHeadTail,
    ppoTOKEN            ID,
    ppoMACRO_SYMBOL     MS
    )
{
    gctINT real_argc = 0;
    ppoMACRO_SYMBOL ms = MS;

    while (real_argc < ms->argc)
    {
        gcmASSERT(
            ((HeadTail[real_argc*2] == gcvNULL) && (HeadTail[real_argc*2 + 1] == gcvNULL))
            ||
            ((HeadTail[real_argc*2] != gcvNULL) && (HeadTail[real_argc*2 + 1] != gcvNULL))
            );

        if(HeadTail[real_argc*2] != gcvNULL)
        {
            HeadTail[real_argc*2+1]->inputStream.base.node.prev = gcvNULL;

            gcmTRACE(gcvLEVEL_VERBOSE,  "ME : expand the %dth real-arg ", real_argc);

            ppoPREPROCESSOR_ArgsMacroExpand(
                PP,
                &(HeadTail[real_argc*2]),
                &(ExpandHeadTail[real_argc*2]),
                &(ExpandHeadTail[real_argc*2+1])
                );

            gcmASSERT(HeadTail[real_argc*2] == gcvNULL);

            gcmTRACE(gcvLEVEL_VERBOSE, "ME : the %dth real-arg expanded.", real_argc);
        }
        else
        {
            gcmTRACE(gcvLEVEL_VERBOSE, "ME : no real-arg at %d",real_argc);

            gcmASSERT(
                ExpandHeadTail[real_argc*2] == gcvNULL
                &&
                ExpandHeadTail[real_argc*2+1] == gcvNULL
                );
        }

        ++real_argc;
    }

    gcmTRACE(gcvLEVEL_VERBOSE, "ME : check the HeadTail buffer");

    return gcvSTATUS_OK;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_1_NotMacroSymbol(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *Head,
    ppoTOKEN            *End,
    gctBOOL             *AnyExpanationHappened,
    gctBOOL             *MatchCase,
    ppoTOKEN            ID,
    ppoMACRO_SYMBOL     *MS
    )
{

    gceSTATUS status = gcvSTATUS_INVALID_DATA;

    ppoTOKEN id = ID;

    ppoMACRO_SYMBOL ms = gcvNULL;

    gcmONERROR(
        ppoMACRO_MANAGER_GetMacroSymbol(PP, PP->macroManager, id->poolString, &ms)
        );

    *MS = ms;

    if (ms == gcvNULL)
    {
        gcmTRACE(gcvLEVEL_VERBOSE,"ME : %s is not defined.",id->poolString);

        *Head = id;
        *End  = id;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvTRUE;

        return gcvSTATUS_OK;
    }
    else
    {
        gcmTRACE(gcvLEVEL_VERBOSE,"ME : %s is defined.",id->poolString);

        *Head = gcvNULL;
        *End  = gcvNULL;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvFALSE;

        return gcvSTATUS_OK;
    }
OnError:
	return status;
}
GL_APICALL void GL_APIENTRY
glGenRenderbuffers(
    GLsizei n,
    GLuint *renderbuffers
    )
{
#if gcdNULL_DRIVER < 3
    GLContext context;
    GLRenderbuffer renderbuffer;
    GLsizei i;

    gcmHEADER_ARG("n=%d", n);

    context = _glshGetCurrentContext();
    if (context == gcvNULL)
    {
        gcmFOOTER_NO();
        return;
    }

    if (n < 0)
    {
        gl2mERROR(GL_INVALID_VALUE);
        gcmFOOTER_NO();
        return;
    }

    /* Loop while there are renderbuffers to generate. */
    for (i = 0; i < n; ++i)
    {
        /* Create a new renderbuffer. */
        renderbuffer = _NewRenderbuffer(context, 0);
        if (renderbuffer == gcvNULL)
        {
            gcmFOOTER_NO();
            return;
        }

        /* Return Renderbuffer name. */
        gcmTRACE(gcvLEVEL_VERBOSE,
                 "glGenRenderbuffers: ==> %u",
                 renderbuffer->object.name);
        renderbuffers[i] = renderbuffer->object.name;
    }

    gcmDUMP_API("${ES20 glGenRenderbuffers 0x%08X (0x%08X)", n, renderbuffers);
    gcmDUMP_API_ARRAY(renderbuffers, n);
    gcmDUMP_API("$}");
    gcmFOOTER_NO();
#else
    while (n-- > 0)
    {
        *renderbuffers++ = 1;
    }
#endif
}
GL_APICALL void GL_APIENTRY
glBindRenderbuffer(
    GLenum target,
    GLuint renderbuffer
    )
{
#if gcdNULL_DRIVER < 3
    GLRenderbuffer object;

	glmENTER2(glmARGENUM, target, glmARGUINT, renderbuffer)
	{
    gcmDUMP_API("${ES20 glBindRenderbuffer 0x%08X 0x%08X}",
                target, renderbuffer);

    glmPROFILE(context, GLES2_BINDRENDERBUFFER, 0);

    if (target != GL_RENDERBUFFER)
    {
        gcmTRACE(gcvLEVEL_WARNING,
                 "glBindRenderbuffer: Invalid target 0x%04X",
                 target);
        gl2mERROR(GL_INVALID_OPERATION);
        break;
    }

    if (renderbuffer == 0)
    {
        /* Remove current binding. */
        object = gcvNULL;
    }
    else
    {
        /* Find the object. */
        object = (GLRenderbuffer) _glshFindObject(
            &context->renderbufferObjects,
            renderbuffer);

        if (object == gcvNULL)
        {
            /* Create a new renderbuffer. */
            object = _NewRenderbuffer(context, renderbuffer);
            if (object == gcvNULL)
            {
                break;
            }
        }
    }

    context->renderbuffer = object;

    /* Disable batch optmization. */
    context->batchDirty = GL_TRUE;

	}
Exemplo n.º 8
0
static void _PrintLinkChain(
	void
	)
{
	gctUINT i, j;

	gcmTRACE(0, "\nLink chain:\n\n");

	i = _lnkInfo.tail;

	for (j = 0; j < _lnkInfo.count; j += 1)
	{
		gcmTRACE(0,
			"  LINK 0x%08X --> 0x%08X\n",
			_lnkRecord[i].fromAddress,
			_lnkRecord[i].toAddress
			);

		i = (i + 1) % gcdRECORD_COUNT;
	}
}
Exemplo n.º 9
0
static void _PrintBuffer(
	gctUINT32_PTR Logical,
	gctUINT Address,
	gctUINT Size
	)
{
	gctUINT i;
	gctUINT value;

	for (i = 0; i < Size; i += 4)
	{
		value = * Logical;
		Logical += 1;

		if ((i % 16) == 0)
		{
			gcmTRACE(0, "0x%08X: ", Address + i);
		}

		if (i + 4 < Size)
		{
			if (((i + 4) % 16) == 0)
			{
				gcmTRACE(0, "0x%08X,\n", value);
			}
			else
			{
				gcmTRACE(0, "0x%08X, ", value);
			}
		}
		else
		{
			gcmTRACE(0, "0x%08X\n", value);
		}
	}
}
Exemplo n.º 10
0
static void _PrintCmdBuffer(
	gckCOMMAND Command,
	gctUINT Address
	)
{
	gctUINT i, j, first, last;
	gcsCMDBUF_RECORD_PTR buffer;
	gctUINT address;

	gcmTRACE(0,
		"\n%s(%d):\n"
		"  number of buffers stored %d;\n"
		"  buffer list:\n\n",
		__FUNCTION__, __LINE__, _cmdInfo.count
		);

	i = _cmdInfo.tail;

	for (j = 0; j < _cmdInfo.count; j += 1)
	{
		first = _cmdRecord[i].address;
		last  = first + _cmdRecord[i].size;

		gcmTRACE(0,
			"  0x%08X-0x%08X%s%s\n",
			first,
			last,
			_cmdRecord[i].context ? " context" : "",
			_cmdRecord[i].queue   ? " queue"   : ""
			);

		i = (i + 1) % gcdRECORD_COUNT;
	}

	buffer = _FindCmdBuffer(Address);

	if (buffer == gcvNULL)
	{
		gcmTRACE(0,
			"\n*** buffer not found for the specified location ***\n"
			);
	}
	else
	{
		first = buffer->address;
		last  = first + buffer->size;

		gcmTRACE(0,
			"\n%s(%d): buffer found 0x%08X-0x%08X%s%s:\n\n",
			__FUNCTION__, __LINE__,
			first,
			last,
			buffer->context ? " context" : "",
			buffer->context ? " queue"   : ""
			);

		_PrintBuffer(buffer->logical, buffer->address, buffer->size);
	}

	gckHARDWARE_ConvertLogical(
		Command->kernel->hardware, Command->logical, &address
		);

	first = address;
	last  = first + Command->pageSize;

	gcmTRACE(0,
		"\nCommand queue N%d: 0x%08X-0x%08X:\n\n",
		_cmdQueueCount,
		first,
		last
		);

	_PrintBuffer(Command->logical, address, Command->pageSize);
}
gceSTATUS
_StretchBlitPE1x(
    IN gcsCOPYBIT_CONTEXT * Context,
    IN struct copybit_image_t const  * Dest,
    IN struct copybit_image_t const  * Source,
    IN struct copybit_rect_t const   * DestRect,
    IN struct copybit_rect_t const   * SourceRect,
    IN struct copybit_region_t const * Clip)
{
    gceSTATUS status = gcvSTATUS_OK;

    gceSURF_FORMAT siFormat;
    gceSURF_FORMAT diFormat;

    gctUINT32      diPhysical = ~0;
    gctUINT32      diAlignedWidth;
    gctUINT32      diAlignedHeight;
    gctINT         diStride;

    gcsRECT srcRect;
    gcsRECT dstRect;
    copybit_rect_t rect;

    gctUINT32      srcPhysical = ~0;
    gctINT         srcStride;
    gctUINT32      srcAlignedWidth;
    gctUINT32      srcAlignedHeight;
    gceSURF_FORMAT srcFormat;

    gctUINT32      dstPhysical = ~0;
    gctINT         dstStride;
    gctUINT32      dstAlignedWidth;
    gctUINT32      dstAlignedHeight;
    gceSURF_FORMAT dstFormat;

    gctBOOL stretch   = gcvFALSE;
    gctBOOL yuvFormat = gcvFALSE;
    gctBOOL perpixelAlpha;

    gc_private_handle_t* dsthnd = (gc_private_handle_t *) Dest->handle;
    gc_private_handle_t* srchnd = (gc_private_handle_t *) Source->handle;

    LOGV("Blit from Source hnd=%p, to Dest hnd=%p", srchnd, dsthnd);

    if (gc_private_handle_t::validate(dsthnd) < 0)
    {
        gcmTRACE(gcvLEVEL_ERROR,
                 "Invalid hnd in funciton %s",
                 __func__);

        return gcvSTATUS_INVALID_ARGUMENT;
    }

    siFormat = (gceSURF_FORMAT) srchnd->format;
    diFormat = (gceSURF_FORMAT) dsthnd->format;

    if ((siFormat == gcvSURF_UNKNOWN)
    ||  (diFormat == gcvSURF_UNKNOWN)
    )
    {
        gcmTRACE(gcvLEVEL_ERROR,
                 "Image format not support in copybit!");

        return gcvSTATUS_INVALID_ARGUMENT;
    }

    /* Convert to supported Source format. */
    siFormat = (siFormat == gcvSURF_A8B8G8R8) ? gcvSURF_A8R8G8B8 : siFormat;
    siFormat = (siFormat == gcvSURF_X8B8G8R8) ? gcvSURF_X8R8G8B8 : siFormat;

    /* Convert to supported Dest format. */
    diFormat = (diFormat == gcvSURF_A8B8G8R8) ? gcvSURF_A8R8G8B8 : diFormat;
    diFormat = (diFormat == gcvSURF_X8B8G8R8) ? gcvSURF_X8R8G8B8 : diFormat;

    do
    {
        srcPhysical = srchnd->phys;
        gcoSURF_GetAlignedSize((gcoSURF) srchnd->surface,
                               &srcAlignedWidth,
                               &srcAlignedHeight,
                               &srcStride);

        diPhysical = dsthnd->phys;
        gcoSURF_GetAlignedSize((gcoSURF) dsthnd->surface,
                               &diAlignedWidth,
                               &diAlignedHeight,
                               &diStride);

        if  ((((gcoSURF)srchnd->surface)->info.type == gcvSURF_BITMAP) &&
            !(srchnd->flags & gc_private_handle_t::PRIV_FLAGS_FRAMEBUFFER))
        {
            /* Clean the CPU cache. Source would've been rendered by the CPU. */
            gcmERR_BREAK(
                gcoSURF_CPUCacheOperation(
                            (gcoSURF) srchnd->surface,
                            gcvCACHE_CLEAN
                            )
            );
        }

        perpixelAlpha = _HasAlpha(siFormat) &&
                 (dsthnd->flags & gc_private_handle_t::PRIV_FLAGS_FRAMEBUFFER) &&
                 !(srchnd->flags & gc_private_handle_t::PRIV_FLAGS_FRAMEBUFFER);

        if (Context->perpixelAlpha != perpixelAlpha)
        {
            Context->perpixelAlpha = perpixelAlpha;

            if (Context->planeAlpha == 0xff)
            {
                Context->dirty.s.alphaKey = 1;
            }
        }

        /* Need temp surface if source has alpha channel, but dest not. */
        Context->needAlphaDest = Context->perpixelAlpha &&
                !_HasAlpha(diFormat);

        if (Context->needAlphaDest)
        {
            gcsRECT tempRect;

            tempRect.left   = gcmMAX(0, DestRect->l);
            tempRect.top    = gcmMAX(0, DestRect->t);
            tempRect.right  = gcmMIN((int32_t) Dest->w, DestRect->r);
            tempRect.bottom = gcmMIN((int32_t) Dest->h, DestRect->b);

            gcmERR_BREAK(
                _FitSurface(Context,
                            &Context->alphaDest,
                            Dest->w,
                            Dest->h));

            if (Context->alphaDest.surface == gcvNULL)
            {
                gcmTRACE(gcvLEVEL_ERROR,
                         "fail to construct tmp surface for per_pixel_alpha");

                break;
            }

            /* Copy dest surface to temp surface. */
            gcmERR_BREAK(
                _MonoBlit(Context,
                          diPhysical,
                          diStride,
                          diFormat,
                          Context->alphaDest.physical,
                          Context->alphaDest.stride,
                          Context->alphaDest.format,
                          &tempRect));
        }

        gcmERR_BREAK(
            _UploadStates(Context));

        if (Context->needAlphaDest)
        {
            dstPhysical      = Context->alphaDest.physical;
            dstStride        = Context->alphaDest.stride;
            dstAlignedWidth  = Context->alphaDest.alignedWidth;
            dstAlignedHeight = Context->alphaDest.alignedHeight;
            dstFormat        = Context->alphaDest.format;
        }
        else
        {
            dstPhysical      = diPhysical;
            dstStride        = diStride;
            dstAlignedWidth  = diAlignedWidth;
            dstAlignedHeight = diAlignedHeight;
            dstFormat        = diFormat;
        }

        srcFormat = siFormat;

        if (Context->transform == COPYBIT_TRANSFORM_ROT_270)
        {
            srcRect.left   = SourceRect->t;
            srcRect.top    = Source->w - SourceRect->r;
            srcRect.right  = SourceRect->b;
            srcRect.bottom = Source->w - SourceRect->l;
        }
        else
        {
            srcRect.left   = SourceRect->l;
            srcRect.top    = SourceRect->t;
            srcRect.right  = SourceRect->r;
            srcRect.bottom = SourceRect->b;
        }

        if (Context->transform ==  COPYBIT_TRANSFORM_ROT_90)
        {
            dstRect.left   = DestRect->t;
            dstRect.top    = Dest->w - DestRect->r;
            dstRect.right  = DestRect->b;
            dstRect.bottom = Dest->w - DestRect->l;
        }
        else
        {
            dstRect.left   = DestRect->l;
            dstRect.top    = DestRect->t;
            dstRect.right  = DestRect->r;
            dstRect.bottom = DestRect->b;
        }

        /* Check yuv format. */
        yuvFormat = (srcFormat == gcvSURF_YUY2 || srcFormat == gcvSURF_UYVY);

        stretch =
            (srcRect.right - srcRect.left) != (dstRect.right - dstRect.left) ||
            (srcRect.bottom - srcRect.top) != (dstRect.bottom - dstRect.top);

        /* Upload stretch factor. */
        if (stretch)
        {
            int hFactor;
            int vFactor;

            if ((dstRect.right-dstRect.left) > 1 && (dstRect.bottom-dstRect.top) > 1)
            {
                hFactor = ((srcRect.right - srcRect.left - 1) << 16) /
                        (dstRect.right - dstRect.left - 1);

                vFactor = ((srcRect.bottom - srcRect.top - 1) << 16) /
                        (dstRect.bottom - dstRect.top - 1);
            }
            else
            {
                hFactor = 0;
                vFactor = 0;
            }

            gcmERR_BREAK(
                gco2D_SetStretchFactors(Context->engine,
                                        hFactor,
                                        vFactor));
        }

        /* Prepare source and target for normal blit. */
        gcmERR_BREAK(
            gco2D_SetColorSource(Context->engine,
                                 srcPhysical,
                                 srcStride,
                                 srcFormat,
                                 Context->srcRotation,
                                 srcAlignedWidth,
                                 gcvFALSE,
                                 gcvSURF_OPAQUE,
                                 0));

        gcmERR_BREAK(
            gco2D_SetSource(Context->engine,
                            &srcRect));

        gcmERR_BREAK(
            gco2D_SetTarget(Context->engine,
                            dstPhysical,
                            dstStride,
                            Context->dstRotation,
                            dstAlignedWidth));

        gcsRECT srcRectBackup = srcRect;
        gcsRECT dstRectBackup = dstRect;

        /* Go though all clip rectangles. */
        while (Clip->next(Clip, &rect))
        {
            gcsRECT clipRect;

            srcRect = srcRectBackup;
            dstRect = dstRectBackup;

            if (Context->transform ==  COPYBIT_TRANSFORM_ROT_90)
            {
                clipRect.left   = rect.t;
                clipRect.top    = Dest->w - rect.r;
                clipRect.right  = rect.b;
                clipRect.bottom = Dest->w - rect.l;
            }
            else if (Context->transform == COPYBIT_TRANSFORM_ROT_180)
            {
                float hfactor = (float) (SourceRect->r - SourceRect->l)
                                 / (DestRect->r - DestRect->l);

                float vfactor = (float) (SourceRect->b - SourceRect->t)
                                 / (DestRect->b - DestRect->t);

                /* Intersect. */
                clipRect.left   = gcmMAX(dstRect.left, rect.l);
                clipRect.top    = gcmMAX(dstRect.top, rect.t);
                clipRect.right  = gcmMIN(dstRect.right, rect.r);
                clipRect.bottom = gcmMIN(dstRect.bottom, rect.b);

                /* Adjust src rectangle. */
                srcRect.left   += (int) ((dstRect.right - clipRect.right) * hfactor);
                srcRect.top    += (int) ((dstRect.bottom - clipRect.bottom) * vfactor);
                srcRect.right  -= (int) ((clipRect.left - dstRect.left) * hfactor);
                srcRect.bottom -= (int) ((clipRect.top - dstRect.top) * vfactor);

                /* Set dstRect to clip rectangle. */
                dstRect = clipRect;

                if ((srcRect.left   != srcRectBackup.left)
                ||  (srcRect.right  != srcRectBackup.right)
                ||  (srcRect.top    != srcRectBackup.top)
                ||  (srcRect.bottom != srcRectBackup.bottom)
                )
                {
                    gcmERR_BREAK(
                        gco2D_SetSource(Context->engine,
                                        &srcRect));
                }
            }
            else
            {
                clipRect.left   = rect.l;
                clipRect.top    = rect.t;
                clipRect.right  = rect.r;
                clipRect.bottom = rect.b;
            }

            /* Clamp clip rectangle. */
            if (clipRect.right > dstRect.right)
                clipRect.right = dstRect.right;

            if (clipRect.bottom > dstRect.bottom)
                clipRect.bottom = dstRect.bottom;

            if (clipRect.left < dstRect.left)
                clipRect.left = dstRect.left;

            if (clipRect.top < dstRect.top)
                clipRect.top = dstRect.top;

            gcmERR_BREAK(
                gco2D_SetClipping(Context->engine,
                                  &clipRect));

            if (yuvFormat)
            {
                /* TODO: FilterBlit does not support rotation before PE20. */
                /* Video filter blit */
                /* 1. SetClipping() has no effect for FilterBlit()
                 *    so we use dstSubRect to realize clipping effect
                 * 2. Only FilterBlit support yuv format covertion.
                 */
                gcsRECT dstSubRect;
                int dstWidth   = dstRect.right   - dstRect.left;
                int dstHeight  = dstRect.bottom  - dstRect.top;
                int clipWidth  = clipRect.right  - clipRect.left;
                int clipHeight = clipRect.bottom - clipRect.top;

                dstSubRect.left   = clipRect.left - dstRect.left;
                dstSubRect.top    = clipRect.top - dstRect.top;
                dstSubRect.right  = dstWidth < clipWidth ?
                        dstSubRect.left + dstWidth :
                        dstSubRect.left + clipWidth;
                dstSubRect.bottom = dstHeight < clipHeight ?
                        dstSubRect.top  + dstHeight :
                        dstSubRect.top  + clipHeight;

                gcmERR_BREAK(
                    gco2D_SetKernelSize(Context->engine,
                                        gcdFILTER_BLOCK_SIZE,
                                        gcdFILTER_BLOCK_SIZE));

                gcmERR_BREAK(
                    gco2D_SetFilterType(Context->engine,
                                        gcvFILTER_SYNC));

                gcmERR_BREAK(
                    gco2D_FilterBlit(Context->engine,
                                     srcPhysical,
                                     srcStride,
                                     0, 0, 0, 0,
                                     srcFormat,
                                     Context->srcRotation,
                                     srcAlignedWidth,
                                     &srcRect,
                                     dstPhysical,
                                     dstStride,
                                     dstFormat,
                                     Context->dstRotation,
                                     dstAlignedWidth,
                                     &dstRect,
                                     &dstSubRect));
            }
            else if (Context->blur)
            {
                /* TODO: FilterBlit does not support rotation before PE20. */
                gcsRECT dstSubRect;
                dstSubRect.left  = 0;
                dstSubRect.top   = 0;
                dstSubRect.right = dstRect.right - dstRect.left;
                dstSubRect.bottom = dstRect.bottom - dstRect.top;

                /* Blur blit. */
                gcmERR_BREAK(
                    gco2D_SetKernelSize(Context->engine,
                                        gcdFILTER_BLOCK_SIZE,
                                        gcdFILTER_BLOCK_SIZE));

                gcmERR_BREAK(
                    gco2D_SetFilterType(Context->engine,
                                        gcvFILTER_BLUR));

                gcmERR_BREAK(
                    gco2D_FilterBlit(Context->engine,
                                     srcPhysical,
                                     srcStride,
                                     0, 0, 0, 0,
                                     srcFormat,
                                     gcvSURF_0_DEGREE,
                                     srcAlignedWidth,
                                     &srcRect,
                                     dstPhysical,
                                     dstStride,
                                     dstFormat,
                                     gcvSURF_0_DEGREE,
                                     dstAlignedWidth,
                                     &dstRect,
                                     &dstSubRect));

                gcmERR_BREAK(
                    gco2D_FilterBlit(Context->engine,
                                     dstPhysical,
                                     dstStride,
                                     0, 0, 0, 0,
                                     dstFormat,
                                     gcvSURF_0_DEGREE,
                                     dstAlignedWidth,
                                     &dstRect,
                                     dstPhysical,
                                     dstStride,
                                     dstFormat,
                                     gcvSURF_0_DEGREE,
                                     dstAlignedWidth,
                                     &dstRect,
                                     &dstSubRect));

                /* TODO: surfaceflinger set blur issue. */
                Context->blur = COPYBIT_DISABLE;
            }
            else if (stretch == gcvFALSE)
            {
                /* BitBlit. */
                gcmERR_BREAK(
                    gco2D_Blit(Context->engine,
                               1,
                               &dstRect,
                               0xCC,
                               0xCC,
                               dstFormat));
            }
            else
            {
                /* Normal stretch blit. */
                gcmERR_BREAK(
                    gco2D_StretchBlit(Context->engine,
                                      1,
                                      &dstRect,
                                      0xCC,
                                      0xCC,
                                      dstFormat));
            }
        }

        if (gcmIS_ERROR(status))
        {
            break;
        }

        if (Context->needAlphaDest)
        {
            gcsRECT tempRect;

            tempRect.left   = gcmMAX(0, DestRect->l);
            tempRect.top    = gcmMAX(0, DestRect->t);
            tempRect.right  = gcmMIN((int32_t) Dest->w, DestRect->r);
            tempRect.bottom = gcmMIN((int32_t) Dest->h, DestRect->b);

            /* Blit back to actual dest. */
            gcmERR_BREAK(
                _MonoBlit(Context,
                          Context->alphaDest.physical,
                          Context->alphaDest.stride,
                          Context->alphaDest.format,
                          diPhysical,
                          diStride,
                          diFormat,
                          &tempRect));
        }

        /* Flush and commit. */
        gcmERR_BREAK(
            gco2D_Flush(Context->engine));

        gcmERR_BREAK(
            gcoHAL_Commit(gcvNULL, gcvFALSE));
    }
    while (gcvFALSE);

    return status;
}
Exemplo n.º 12
0
static gceSTATUS _DereferenceObjectCache(
	vgsCONTEXT_PTR Context,
	vgsOBJECT_CACHE_PTR * ObjectCache
	)
{
	/* Define the result and assume success. */
	gceSTATUS status = gcvSTATUS_OK;

	do
	{
		vgsOBJECT_PTR object;
		vgsOBJECT_LIST_PTR objectList;

		/* Get a shortcut to the object cache. */
		vgsOBJECT_CACHE_PTR objectCache = *ObjectCache;

		/* Existing object cache? */
		if (objectCache == gcvNULL)
		{
			break;
		}

		/* Valid reference count? */
		if (objectCache->referenceCount < 1)
		{
			gcmFATAL("Invalid reference count found.\n");
			status = gcvSTATUS_INVALID_OBJECT;
			break;
		}

		/* Decrement the counter. */
		objectCache->referenceCount--;

		/* Time to destroy? */
		if (objectCache->referenceCount == 0)
		{
			gctUINT i;

			/* Delete objects that are still in the cache. */
			for (i = 0; i < vgvOBJECTTYPE_COUNT; i++)
			{
				gctUINT32 index;

				/* Get the current object list. */
				objectList = &objectCache->cache[i];

				for (index = 0; index < vgvNAMED_OBJECTS_HASH; index++)
				{
					/* Are there objects in the list? */
					if (objectList->head[index] != gcvNULL)
					{
						gcmTRACE(
							gcvLEVEL_ERROR,
							"%s (%d): object cache %d still has objects in it.\n",
							__FUNCTION__, __LINE__, i
							);

						/* Delete the objects. */
						while (objectList->head[index])
                                        	{
							/* Copy the head object. */
							object = objectList->head[index];

							/* Dereference it. */
							gcmERR_BREAK(vgfDereferenceObject(
								Context,
								&object
								));
						}
					}
				 }

				/* Error? */
				if (gcmIS_ERROR(status))
				{
					break;
				}
			}

			/* Error? */
			if (gcmIS_ERROR(status))
			{
				break;
			}

			/* Allocate the context structure. */
			gcmERR_BREAK(gcoOS_Free(
				Context->os,
				(gctPOINTER *) objectCache
				));

			/* Reset the object. */
			*ObjectCache = gcvNULL;
		}
	}
	while (gcvFALSE);

	/* Return status. */
	return status;
}
Exemplo n.º 13
0
EGLAPI EGLBoolean EGLAPIENTRY
eglChooseConfig(
    EGLDisplay Dpy,
    const EGLint *attrib_list,
    EGLConfig *configs,
    EGLint config_size,
    EGLint *num_config
    )
{
    VEGLThreadData thread;
    VEGLDisplay dpy;
    struct eglConfig criteria = { 0 };
    EGLint config;

    gcmHEADER_ARG("Dpy=0x%x attrib_list=0x%x configs=0x%x config_size=%d",
                  Dpy, attrib_list, configs, config_size);

    /* Get thread data. */
    thread = veglGetThreadData();
    if (thread == gcvNULL)
    {
        gcmTRACE(
            gcvLEVEL_ERROR,
            "%s(%d): veglGetThreadData failed.",
            __FUNCTION__, __LINE__
            );

        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Create a shortcut to the display. */
    dpy = VEGL_DISPLAY(Dpy);

    /* Test for valid EGLDisplay structure. */
    if ((dpy == gcvNULL)
    ||  (dpy->signature != EGL_DISPLAY_SIGNATURE)
    )
    {
        /* Bad display. */
        thread->error = EGL_BAD_DISPLAY;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    if (num_config == gcvNULL)
    {
        /* Bad parameter. */
        thread->error = EGL_BAD_PARAMETER;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Parse attributes. */
    if (!veglParseAttributes(dpy, attrib_list, &criteria))
    {
        /* Bail out on invalid or non-matching attributes. */
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Reference the EGLDisplay. */
    if (!veglReferenceDisplay(thread, dpy))
    {
        /* Not initialized. */
        thread->error = EGL_NOT_INITIALIZED;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Reset number of configurations. */
    *num_config = 0;

    /* Walk through all configurations. */
    for (config = 0; config < dpy->configCount; config++)
    {
        /* Get pointer to configuration. */
        VEGLConfig configuration = &dpy->config[config];

        gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                      "%s: examining config index=%d",
                      __FUNCTION__, config);

		if (criteria.configId != EGL_DONT_CARE)
        {
            if (!((criteria.configId == configuration->configId) ||
                ((criteria.configId == 0) && configuration->defaultConfig)))
            {
                /* Criterium doesn't match. */
                gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                    "  rejected on config ID.");
                continue;
            }
            else
            {
                *num_config += 1;

                if (configs != gcvNULL)
                {
                    /* Copy configuration into specified buffer. */
                    *configs = configuration;
                }

                break;
            }
        }

        /* Check configuration against criteria. */
        if (criteria.bufferSize > configuration->bufferSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on buffer size.");
            continue;
        }

        if (criteria.alphaSize > configuration->alphaSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on alpha size.");
            continue;
        }

        if (criteria.blueSize > configuration->blueSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on blue size.");
            continue;
        }

        if (criteria.greenSize > configuration->greenSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on green size.");
            continue;
        }

        if (criteria.redSize > configuration->redSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on red size.");
            continue;
        }

        if (criteria.depthSize > configuration->depthSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on depth size.");
            continue;
        }

        if (criteria.stencilSize > configuration->stencilSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on stencil size.");
            continue;
        }

        if ((criteria.configCaveat != (EGLenum) EGL_DONT_CARE)
        &&  (criteria.configCaveat != configuration->configCaveat)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on config caveat.");
            continue;
        }

        if ((criteria.configId != EGL_DONT_CARE) &&
            !((criteria.configId == configuration->configId) ||
              ((criteria.configId == 0) && configuration->defaultConfig)))
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on config ID.");
            continue;
        }

        if ((criteria.nativeRenderable != (EGLBoolean) EGL_DONT_CARE)
        &&  criteria.nativeRenderable
        &&  (criteria.nativeRenderable != configuration->nativeRenderable)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on native renderable.");
            continue;
        }

        if ((criteria.nativeVisualType != EGL_DONT_CARE) &&
            (criteria.nativeVisualType != configuration->nativeVisualType))
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on native visual type.");
            continue;
        }

        if (criteria.samples > configuration->samples)
        {
            if ((criteria.samples == 1) && (configuration->samples == 0))
            {
                /* Criterium still matches. */
            }
            else
            {
                /* Criterium doesn't match. */
                gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                              "  rejected on samples.");
                continue;
            }
        }

        if (criteria.sampleBuffers > configuration->sampleBuffers)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on sample buffers.");
            continue;
        }

        if ((criteria.surfaceType != (EGLenum) EGL_DONT_CARE)
        &&  !(criteria.surfaceType & configuration->surfaceType)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on surface type.");
            continue;
        }

        if ((criteria.bindToTetxureRGB != (EGLBoolean) EGL_DONT_CARE)
        &&  (criteria.bindToTetxureRGB != configuration->bindToTetxureRGB)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on bind to tetxure RGB.");
            continue;
        }

        if ((criteria.bindToTetxureRGBA != (EGLBoolean) EGL_DONT_CARE)
        &&  (criteria.bindToTetxureRGBA != configuration->bindToTetxureRGBA)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on bind to tetxure RGBA.");
            continue;
        }

        if (criteria.luminanceSize > configuration->luminanceSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on luminance size.");
            continue;
        }

        if (criteria.alphaMaskSize > configuration->alphaMaskSize)
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on alpha mask size.");
            continue;
        }

        if ((criteria.colorBufferType != (EGLenum) EGL_DONT_CARE)
        &&  (criteria.colorBufferType != configuration->colorBufferType)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on color buffer type.");
            continue;
        }

        if ((criteria.renderableType != (EGLenum) EGL_DONT_CARE)
        &&  ((criteria.renderableType & configuration->renderableType)
             != criteria.renderableType)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on renderable type.");
            continue;
        }

        if ((criteria.conformant != (EGLenum) EGL_DONT_CARE)
        &&  (criteria.conformant != 0)
        &&  !(criteria.conformant & configuration->conformant)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on conformant.");
            continue;
        }

        if ((criteria.matchNativePixmap != EGL_DONT_CARE)
        &&  (criteria.matchNativePixmap != EGL_NONE)
        )
        {
            EGLBoolean bMatch = EGL_TRUE;
            gctUINT width, height;
            gceSURF_FORMAT format = gcvSURF_UNKNOWN;
            gctUINT bitsPerPixel;

            if (!(configuration->surfaceType & EGL_PIXMAP_BIT)
            ||  !veglGetPixmapInfo(dpy->hdc,
                                   (NativePixmapType)
                                   gcmINT2PTR(criteria.matchNativePixmap),
                                   &width, &height,
                                   &bitsPerPixel,
                                   &format)
            )
            {
                /* surface type of config is not EGL_PIXMAP_BIT or bad pixmap. */
                gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                              "  rejected on match native pixmap.");
                continue;
            }

            switch (format)
            {
            case gcvSURF_R5G6B5:
                if ((configuration->redSize   != 5)
                ||  (configuration->greenSize != 6)
                ||  (configuration->blueSize  != 5)
                )
                {
                    bMatch = EGL_FALSE;
                }
                break;

            case gcvSURF_X8R8G8B8:
                if ((configuration->redSize   != 8)
                ||  (configuration->greenSize != 8)
                ||  (configuration->blueSize  != 8)
                ||  (configuration->alphaSize != 0)
                )
                {
                    bMatch = EGL_FALSE;
                }
                break;

            default:
                break;
            }

            if (!bMatch)
            {
                /* Criterium doesn't match. */
                gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                              "  rejected on match native pixmap.");
                continue;
            }
        }

        if ((criteria.matchFormat != (EGLenum) EGL_DONT_CARE)
        &&  (criteria.matchFormat != (EGLenum) EGL_NONE)
        )
        {
            EGLBoolean bMatch = EGL_TRUE;

            switch(criteria.matchFormat)
            {
            case EGL_FORMAT_RGB_565_EXACT_KHR:
                if (configuration->matchFormat != EGL_FORMAT_RGB_565_EXACT_KHR)
                {
                    bMatch = EGL_FALSE;
                }
                break;

            case EGL_FORMAT_RGB_565_KHR:
                if ((configuration->matchFormat != EGL_FORMAT_RGB_565_EXACT_KHR)
                &&  (configuration->matchFormat != EGL_FORMAT_RGB_565_KHR)
                )
                {
                    bMatch = EGL_FALSE;
                }
                break;

            case EGL_FORMAT_RGBA_8888_EXACT_KHR:
                if (configuration->matchFormat != EGL_FORMAT_RGBA_8888_EXACT_KHR)
                {
                    bMatch = EGL_FALSE;
                }
                break;

            case EGL_FORMAT_RGBA_8888_KHR:
                if ((configuration->matchFormat != EGL_FORMAT_RGBA_8888_EXACT_KHR)
                &&  (configuration->matchFormat != EGL_FORMAT_RGBA_8888_KHR)
                )
                {
                    bMatch = EGL_FALSE;
                }
                break;

            default:
                break;
            }

            if (!bMatch)
            {
                /* Criterium doesn't match. */
                gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                              "  rejected on conformant.");
                continue;
            }
        }

        if ((criteria.recordableConfig != (EGLBoolean) EGL_DONT_CARE)
        &&  (criteria.recordableConfig != configuration->recordableConfig)
        )
        {
            /* Criterium doesn't match. */
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "  rejected on recordable config.");
            continue;
        }

        gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, "  accepted.");

        if (configs != gcvNULL)
        {
            /* Copy configuration into specified buffer. */
            configs[*num_config] = configuration;
        }

        *num_config += 1;

        if (*num_config == config_size)
        {
            /* Bail out if the specified buffer is full. */
            break;
        }
    }

    if ((*num_config > 1) && (configs != gcvNULL))
    {
        /* Sort the matching configurations. */
        veglSort((VEGLConfig *) configs, *num_config, &criteria);
    }

    /* Dereference the EGLDisplay. */
    veglDereferenceDisplay(thread, dpy, EGL_FALSE);

    /* Success. */
    thread->error = EGL_SUCCESS;
    gcmDUMP_API("${EGL eglChooseConfig 0x%08X (0x%08X) (0x%08X) 0x%08X "
                "(0x%08X)",
                Dpy, attrib_list, configs, config_size, num_config);
    gcmDUMP_API_ARRAY_TOKEN(attrib_list, EGL_NONE);
    gcmDUMP_API_ARRAY(configs, *num_config);
    gcmDUMP_API_ARRAY(num_config, 1);
    gcmDUMP_API("$}");
    gcmFOOTER_ARG("*num_config=%d", *num_config);
    return EGL_TRUE;
}
Exemplo n.º 14
0
EGLAPI EGLBoolean EGLAPIENTRY
eglGetConfigs(
    EGLDisplay Dpy,
    EGLConfig *configs,
    EGLint config_size,
    EGLint *num_config
    )
{
    VEGLThreadData thread;
    VEGLDisplay dpy;

    gcmHEADER_ARG("Dpy=0x%x configs=0x%x config_size=%d",
                  Dpy, configs, config_size);

    /* Get thread data. */
    thread = veglGetThreadData();
    if (thread == gcvNULL)
    {
        gcmTRACE(
            gcvLEVEL_ERROR,
            "%s(%d): veglGetThreadData failed.",
            __FUNCTION__, __LINE__
            );

        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Create a shortcut to the display. */
    dpy = VEGL_DISPLAY(Dpy);

    /* Test for valid EGLDisplay structure. */
    if ( (dpy == gcvNULL) ||
         (dpy->signature != EGL_DISPLAY_SIGNATURE) )
    {
        /* Bad display. */
        thread->error = EGL_BAD_DISPLAY;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Test for initialized or not. */
    if (dpy->referenceDpy == gcvNULL &&
        dpy->contextStack == EGL_NO_CONTEXT)
    {
        thread->error = EGL_NOT_INITIALIZED;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    if (num_config == gcvNULL)
    {
        /* Bad parameter. */
        thread->error = EGL_BAD_PARAMETER;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Reference the EGLDisplay. */
    if (!veglReferenceDisplay(thread, dpy))
    {
        /* Not initialized. */
        thread->error = EGL_NOT_INITIALIZED;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    if (configs == gcvNULL)
    {
        /* Return number of configurations. */
        *num_config = dpy->configCount;
    }
    else
    {
        EGLint index;

        /* Copy pointers to configurations into supplied buffer. */
        for (index = 0; index < dpy->configCount; index++)
        {
            /* Bail out if the supplied buffer is too small. */
            if (index >= config_size)
            {
                break;
            }

            configs[index] = &dpy->config[index];
        }

        *num_config = index;

        /* Zero any remaining configurations in the supplied buffer. */
        while (index < config_size)
        {
            configs[index++] = gcvNULL;
        }
    }

    /* Dereference the EGLDisplay. */
    veglDereferenceDisplay(thread, dpy, EGL_FALSE);

    /* Success. */
    thread->error = EGL_SUCCESS;
    gcmDUMP_API("${EGL eglGetConfigs 0x%08X (0x%08X) 0x%08X (0x%08X)",
                Dpy, configs, config_size, num_config);
    gcmDUMP_API_ARRAY(configs, *num_config);
    gcmDUMP_API_ARRAY(num_config, 1);
    gcmDUMP_API("$}");
    gcmFOOTER_ARG("*num_config=%d", *num_config);
    return EGL_TRUE;
}
Exemplo n.º 15
0
static EGLBoolean
veglParseAttributes(
    VEGLDisplay Display,
    const EGLint * AttributeList,
    VEGLConfig Configuration
    )
{
    VEGLThreadData thread;
    EGLenum attribute;
    EGLint value = 0;

    /* Get thread data. */
    thread = veglGetThreadData();
    if (thread == gcvNULL)
    {
        gcmTRACE(
            gcvLEVEL_ERROR,
            "%s(%d): veglGetThreadData failed.",
            __FUNCTION__, __LINE__
            );

        return EGL_FALSE;
    }

    /* Assume success. */
    thread->error = EGL_SUCCESS;

    /* Fill in default attributes. */
    Configuration->bufferSize        = 0;
    Configuration->alphaSize         = 0;
    Configuration->blueSize          = 0;
    Configuration->greenSize         = 0;
    Configuration->redSize           = 0;
    Configuration->depthSize         = 0;
    Configuration->stencilSize       = 0;
    Configuration->configCaveat      = (EGLenum) EGL_DONT_CARE;
    Configuration->configId          = EGL_DONT_CARE;
    Configuration->nativeRenderable  = (EGLBoolean) EGL_DONT_CARE;
    Configuration->nativeVisualType  = EGL_DONT_CARE;
    Configuration->samples           = 0;
    Configuration->sampleBuffers     = 0;
    Configuration->surfaceType       = EGL_WINDOW_BIT;
    Configuration->bindToTetxureRGB  = (EGLBoolean) EGL_DONT_CARE;
    Configuration->bindToTetxureRGBA = (EGLBoolean) EGL_DONT_CARE;
    Configuration->luminanceSize     = 0;
    Configuration->alphaMaskSize     = 0;
    Configuration->colorBufferType   = EGL_RGB_BUFFER;
    Configuration->renderableType    = EGL_OPENGL_ES_BIT;
    Configuration->conformant        = 0;
    Configuration->matchFormat       = (EGLenum) EGL_DONT_CARE;
    Configuration->matchNativePixmap = EGL_NONE;
    Configuration->recordableConfig  = (EGLBoolean) EGL_DONT_CARE;

    /* Parse the attribute list. */
    do
    {
        if (AttributeList != gcvNULL)
        {
            attribute      = AttributeList[0];
            value          = AttributeList[1];
            AttributeList += 2;
        }
        else
        {
            attribute = EGL_NONE;
        }

        switch (attribute)
        {
        case EGL_BUFFER_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                         "%s: EGL_BUFFER_SIZE=%d",
                         __FUNCTION__, value);
            Configuration->bufferSize = value;
            break;

        case EGL_ALPHA_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                         "%s: EGL_ALPHA_SIZE=%d",
                         __FUNCTION__, value);
            Configuration->alphaSize = value;
            break;

        case EGL_BLUE_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_BLUE_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->blueSize = value;
            break;

        case EGL_GREEN_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_GREEN_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->greenSize = value;
            break;

        case EGL_RED_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_RED_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->redSize = value;
            break;

        case EGL_DEPTH_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_DEPTH_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->depthSize = value;
            break;

        case EGL_STENCIL_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_STENCIL_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->stencilSize = value;
            break;

        case EGL_CONFIG_CAVEAT:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_CONFIG_CAVEAT=%d",
                          __FUNCTION__, value);
            Configuration->configCaveat = value;
            break;

        case EGL_CONFIG_ID:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_CONFIG_ID=%d",
                          __FUNCTION__, value);
            Configuration->configId = value;
            break;

        case EGL_LEVEL:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_LEVEL=%d",
                          __FUNCTION__, value);
            if ((value != EGL_DONT_CARE) && (value != 0))
            {
                return EGL_FALSE;
            }
            break;

        case EGL_MAX_PBUFFER_WIDTH:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MAX_PBUFFER_WIDTH=%d",
                          __FUNCTION__, value);
            if ((value != EGL_DONT_CARE) && (value > thread->maxWidth))
            {
                return EGL_FALSE;
            }
            break;

        case EGL_MAX_PBUFFER_HEIGHT:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MAX_PBUFFER_HEIGHT=%d",
                          __FUNCTION__, value);
            if ((value != EGL_DONT_CARE) && (value > thread->maxHeight))
            {
                return EGL_FALSE;
            }
            break;

        case EGL_MAX_PBUFFER_PIXELS:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MAX_PBUFFER_PIXELS=%d",
                          __FUNCTION__, value);
            if ( (value != EGL_DONT_CARE) &&
                 (value > thread->maxWidth * thread->maxHeight) )
            {
                return EGL_FALSE;
            }
            break;

        case EGL_NATIVE_RENDERABLE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_NATIVE_RENDERABLE=%d",
                          __FUNCTION__, value);
            Configuration->nativeRenderable = value;
            break;

        case EGL_NATIVE_VISUAL_ID:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_NATIVE_VISUAL_ID=%d",
                          __FUNCTION__, value);
            if
            (
                (value != EGL_DONT_CARE)
                &&
                (gcmINT2PTR(value) != (void*) Display->hdc)
            )
            {
                return EGL_FALSE;
            }
            break;

        case EGL_NATIVE_VISUAL_TYPE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_NATIVE_VISUAL_TYPE=%d",
                          __FUNCTION__, value);
            Configuration->nativeVisualType = value;
            break;

        case EGL_SAMPLES:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_SAMPLES=%d",
                          __FUNCTION__, value);
            Configuration->samples = value;
            break;

        case EGL_SAMPLE_BUFFERS:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_SAMPLE_BUFFERS=%d",
                          __FUNCTION__, value);
            Configuration->sampleBuffers = value;
            break;

        case EGL_SURFACE_TYPE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_SURFACE_TYPE=%d",
                          __FUNCTION__, value);
            Configuration->surfaceType = value;
            break;

        case EGL_TRANSPARENT_TYPE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_TRANSPARENT_TYPE=%d",
                          __FUNCTION__, value);
            if ((value != EGL_NONE) && (value != EGL_DONT_CARE))
            {
                return EGL_FALSE;
            }
            break;

        case EGL_TRANSPARENT_BLUE_VALUE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_TRANSPARENT_BLUE_VALUE=%d",
                          __FUNCTION__, value);
            if (value != EGL_DONT_CARE)
            {
                return EGL_FALSE;
            }
            break;

        case EGL_TRANSPARENT_GREEN_VALUE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_TRANSPARENT_GREEN_VALUE=%d",
                          __FUNCTION__, value);
            if (value != EGL_DONT_CARE)
            {
                return EGL_FALSE;
            }
            break;

        case EGL_TRANSPARENT_RED_VALUE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_TRANSPARENT_RED_VALUE=%d",
                          __FUNCTION__, value);
            if (value != EGL_DONT_CARE)
            {
                return EGL_FALSE;
            }
            break;

        case EGL_BIND_TO_TEXTURE_RGB:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_BIND_TO_TEXTURE_RGB=%d",
                          __FUNCTION__, value);
            Configuration->bindToTetxureRGB = value;
            break;

        case EGL_BIND_TO_TEXTURE_RGBA:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_BIND_TO_TEXTURE_RGBA=%d",
                          __FUNCTION__, value);
            Configuration->bindToTetxureRGBA = value;
            break;

        case EGL_MIN_SWAP_INTERVAL:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MIN_SWAP_INTERVAL=%d",
                          __FUNCTION__, value);
            if ((value != EGL_DONT_CARE) && (value > 1))
            {
                return EGL_FALSE;
            }
            break;

        case EGL_MAX_SWAP_INTERVAL:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MAX_SWAP_INTERVAL=%d",
                          __FUNCTION__, value);
            if ((value != EGL_DONT_CARE) && (value > 1))
            {
                return EGL_FALSE;
            }
            break;

        case EGL_LUMINANCE_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_LUMINANCE_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->luminanceSize = value;
            break;

        case EGL_ALPHA_MASK_SIZE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_ALPHA_MASK_SIZE=%d",
                          __FUNCTION__, value);
            Configuration->alphaMaskSize = value;
            break;

        case EGL_COLOR_BUFFER_TYPE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_COLOR_BUFFER_TYPE=%d",
                          __FUNCTION__, value);
            Configuration->colorBufferType = value;
            break;

        case EGL_RENDERABLE_TYPE:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_RENDERABLE_TYPE=%d",
                          __FUNCTION__, value);
            Configuration->renderableType = value;
            break;

        case EGL_CONFORMANT:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_RENDERABLE_TYPE=%d",
                          __FUNCTION__, value);
            Configuration->conformant = value;
            break;

        case EGL_MATCH_FORMAT_KHR:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MATCH_FORMAT_KHR=%d",
                          __FUNCTION__, value);
            Configuration->matchFormat = value;
            break;

        case EGL_MATCH_NATIVE_PIXMAP:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_MATCH_NATIVE_PIXMAP=%d",
                          __FUNCTION__, value);
            Configuration->matchNativePixmap = value;
            break;

        case EGL_RECORDABLE_ANDROID:
            gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG,
                          "%s: EGL_RECORDABLE_ANDROID=%d",
                          __FUNCTION__, value);
            Configuration->recordableConfig = value;
            break;

        case EGL_NONE:
            break;

        default:
            /* Bad attribute. */
            thread->error = EGL_BAD_ATTRIBUTE;
            return EGL_FALSE;
        }
    }
    while (attribute != EGL_NONE);

    /* Success. */
    return EGL_TRUE;
}
Exemplo n.º 16
0
EGLAPI EGLBoolean EGLAPIENTRY
eglGetConfigAttrib(
    EGLDisplay Dpy,
    EGLConfig Config,
    EGLint attribute,
    EGLint *value
    )
{
    VEGLThreadData thread;
    VEGLDisplay dpy;
    VEGLConfig config;

    gcmHEADER_ARG("Dpy=0x%x Config=0x%x attribute=%d", Dpy, Config, attribute);

    /* Get thread data. */
    thread = veglGetThreadData();
    if (thread == gcvNULL)
    {
        gcmTRACE(
            gcvLEVEL_ERROR,
            "%s(%d): veglGetThreadData failed.",
            __FUNCTION__, __LINE__
            );

        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Create shortcuts to objects. */
    dpy    = VEGL_DISPLAY(Dpy);
    config = VEGL_CONFIG(Config);

    /* Test for valid EGLDisplay structure. */
    if ((dpy == gcvNULL)
    ||  (dpy->signature != EGL_DISPLAY_SIGNATURE)
    )
    {
        /* Bad display. */
        thread->error = EGL_BAD_DISPLAY;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    if (value == gcvNULL)
    {
        /* Bad parameter. */
        thread->error = EGL_BAD_PARAMETER;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Test for valid config. */
    if ((config < dpy->config)
    ||  (config >= dpy->config + dpy->configCount)
    )
    {
        thread->error = EGL_BAD_CONFIG;
        gcmFOOTER_ARG("0x%x", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Reference the EGLDisplay. */
    if (!veglReferenceDisplay(thread, dpy))
    {
        /* Not initialized. */
        thread->error = EGL_NOT_INITIALIZED;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    switch (attribute)
    {
    case EGL_BUFFER_SIZE:
        *value = config->bufferSize;
        break;

    case EGL_ALPHA_SIZE:
        *value = config->alphaSize;
        break;

    case EGL_BLUE_SIZE:
        *value = config->blueSize;
        break;

    case EGL_GREEN_SIZE:
        *value = config->greenSize;
        break;

    case EGL_RED_SIZE:
        *value = config->redSize;
        break;

    case EGL_DEPTH_SIZE:
        *value = config->depthSize;
        break;

    case EGL_STENCIL_SIZE:
        *value = config->stencilSize;
        break;

    case EGL_CONFIG_CAVEAT:
        *value = config->configCaveat;
        break;

    case EGL_CONFIG_ID:
        *value = config->configId;
        break;

    case EGL_LEVEL:
        *value = 0;
        break;

    case EGL_MAX_PBUFFER_WIDTH:
        *value = thread->maxWidth;
        break;

    case EGL_MAX_PBUFFER_HEIGHT:
        *value = thread->maxHeight;
        break;

    case EGL_MAX_PBUFFER_PIXELS:
        *value = thread->maxWidth * thread->maxHeight;
        break;

    case EGL_NATIVE_RENDERABLE:
        *value = config->nativeRenderable;
        break;

    case EGL_NATIVE_VISUAL_ID:
        *value = veglGetNativeVisualId(dpy, config);
        break;

    case EGL_NATIVE_VISUAL_TYPE:
        *value = config->nativeVisualType;
        break;

    case EGL_PRESERVED_RESOURCES:
        *value = EGL_TRUE;
        break;

    case EGL_SAMPLES:
        *value = config->samples;
        break;

    case EGL_SAMPLE_BUFFERS:
        if ((config->samples == 16) && (thread->api == EGL_OPENVG_API))
        {
            *value = 0;
        }
        else
        {
            *value = config->sampleBuffers;
        }
        break;

    case EGL_SURFACE_TYPE:
        *value = config->surfaceType;
        break;

    case EGL_TRANSPARENT_TYPE:
        *value = EGL_NONE;
        break;

    case EGL_TRANSPARENT_BLUE_VALUE:
    case EGL_TRANSPARENT_GREEN_VALUE:
    case EGL_TRANSPARENT_RED_VALUE:
        *value = EGL_DONT_CARE;
        break;

    case EGL_BIND_TO_TEXTURE_RGB:
        *value = config->bindToTetxureRGB;
        break;

    case EGL_BIND_TO_TEXTURE_RGBA:
        *value = config->bindToTetxureRGBA;
        break;

    case EGL_MIN_SWAP_INTERVAL:
    case EGL_MAX_SWAP_INTERVAL:
        *value = 1;
        break;

    case EGL_LUMINANCE_SIZE:
        *value = config->luminanceSize;
        break;

    case EGL_ALPHA_MASK_SIZE:
        *value = config->alphaMaskSize;
        break;

    case EGL_COLOR_BUFFER_TYPE:
        *value = config->colorBufferType;
        break;

    case EGL_RENDERABLE_TYPE:
        *value = config->renderableType;
        break;

    case EGL_CONFORMANT:
        *value = config->conformant;
        break;

    case EGL_MATCH_NATIVE_PIXMAP:
        *value = config->matchNativePixmap;
		break;

    case EGL_RECORDABLE_ANDROID:
        *value = config->recordableConfig;
		break;

    default:
        /* Dereference the EGLDisplay. */
        veglDereferenceDisplay(thread, dpy, EGL_FALSE);

        /* Bad attribute. */
        thread->error = EGL_BAD_ATTRIBUTE;
        gcmFOOTER_ARG("return=%d", EGL_FALSE);
        return EGL_FALSE;
    }

    /* Dereference the EGLDisplay. */
    veglDereferenceDisplay(thread, dpy, EGL_FALSE);

    /* Success. */
    thread->error = EGL_SUCCESS;
    gcmDUMP_API("${EGL eglGetConfigAttrib 0x%08X 0x%08X 0x%08X := 0x%08X}",
                Dpy, Config, attribute, *value);
    gcmFOOTER_ARG("*value=%d", *value);
    return EGL_TRUE;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_7_ParseReplacementList(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *Head,
    ppoTOKEN            *End,
    gctBOOL             *AnyExpanationHappened,
    ppoTOKEN            *ExpandedHeadTail,
    ppoTOKEN            ID,
    ppoMACRO_SYMBOL     MS
    )
{

    ppoTOKEN id = ID;

    ppoMACRO_SYMBOL ms = MS;

    ppoTOKEN replacement_list = gcvNULL;

    ppoTOKEN *expandedheadtail = ExpandedHeadTail;

    gceSTATUS status = gcvSTATUS_INVALID_DATA;

    gctBOOL pasting = gcvFALSE;

    gcmTRACE(gcvLEVEL_VERBOSE, "ME : begin to expand replacement-list.");

    ppoTOKEN_ColonTokenList(
        PP,
        ms->replacementList,
        __FILE__,
        __LINE__,
        "ppoPREPROCESSOR_MacroExpand : Colon the replacement list.",
        &replacement_list
        );

    while(replacement_list)
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : add to rp-list %s's hs.", replacement_list->poolString);

        ppoHIDE_SET_AddHS(PP, replacement_list, id->poolString);

        if (replacement_list->type == ppvTokenType_ID)
        {
            gctINT whereisarg = -1;

            ppoTOKEN search_formal_arg = ms->argv;

            status = ppoPREPROCESSOR_MacroExpand_7_ParseReplacementList_GetPositionOfNode(
                PP,
                replacement_list,
                &whereisarg,
                &search_formal_arg);

            if(status != gcvSTATUS_OK) return status;

            gcmTRACE(gcvLEVEL_VERBOSE,
                "ME : find the position(%d) in argv to rp-list %s's hs.",
                whereisarg,
                replacement_list->poolString);

            gcmASSERT(whereisarg < ms->argc);

            if(search_formal_arg)
            {
                ppoTOKEN tmphead = gcvNULL;
                ppoTOKEN tmpend  = gcvNULL;

                if(expandedheadtail[whereisarg*2 + 1])
                {
                    (expandedheadtail[whereisarg*2 + 1])->inputStream.base.node.prev = gcvNULL;
                }

                gcmTRACE(gcvLEVEL_VERBOSE, "ME : rp-list node : %s, is a formal arg.", replacement_list->poolString);

                ppoTOKEN_ColonTokenList(
                    PP,
                    expandedheadtail[whereisarg*2],
                    __FILE__,
                    __LINE__,
                    "ppoPREPROCESSOR_MacroExpand : Creat a list of the tokenlist expanded out by the actual arguments.",
                    &tmphead
                    );

                tmpend = tmphead;

                gcmTRACE(gcvLEVEL_VERBOSE, "ME : add hs to output nodes.");

                while(tmpend)
                {
                    ppoHIDE_SET_LIST_Append(
                        PP,
                        tmpend,
                        id);

                    ppoHIDE_SET_AddHS(PP, tmpend, id->poolString);

                    if(tmpend->inputStream.base.node.prev == gcvNULL)
                    {
                        break;
                    }

                    tmpend = (ppoTOKEN)tmpend->inputStream.base.node.prev;
                }


                gcmTRACE(gcvLEVEL_VERBOSE,
                    "ME : replacementList : add the expanded node to output.",
                    replacement_list->poolString);

                if(pasting)
                {
                    status = ppoPREPROCESSOR_MacroExpand_7_ParseReplacementList_MergePastingTokenName(
                        PP,
                        (*End),
                        tmphead,
                        &(*End)->poolString
                        );

                    pasting = gcvFALSE;
                }
                else
                {
                    status = ppoPREPROCESSOR_MacroExpand_7_ParseReplacementList_AddToOut(
                        PP,
                        tmphead,
                        tmpend,
                        Head,
                        End
                        );
                }

                if(status != gcvSTATUS_OK) return status;


                do
                {
                    ppoTOKEN tmp = replacement_list;

                    replacement_list = (ppoTOKEN)replacement_list->inputStream.base.node.prev;

                    gcmONERROR(ppoTOKEN_Destroy(PP, tmp));
                }
                while(gcvFALSE);

                continue;

            }/*not found in argv*/
            else
            {
                gcmTRACE(
                    gcvLEVEL_VERBOSE,
                    "ME : replacementList node: %s,inputStream not a formal arg.",
                    replacement_list->poolString);
            }
        }/*if(replacementList->type == ppvTokenType_ID)*/
        else
        {
            if(pasting)
            {
                status = ppoPREPROCESSOR_MacroExpand_7_ParseReplacementList_MergePastingTokenName(
                    PP,
                    (*End),
                    replacement_list,
                    &(*End)->poolString
                    );

                pasting = gcvFALSE;
                replacement_list = (ppoTOKEN)replacement_list->inputStream.base.node.prev;
                continue;
            }
            else if(replacement_list->poolString == PP->keyword->sharp &&
                (ppoTOKEN)replacement_list->inputStream.base.node.prev != gcvNULL)
            {
                ppoTOKEN tmprplst = replacement_list;
                tmprplst = (ppoTOKEN)tmprplst->inputStream.base.node.prev;

                /* ## */
                if(tmprplst->poolString == PP->keyword->sharp &&
                    tmprplst->inputStream.base.node.prev != gcvNULL)
                {
                    replacement_list = (ppoTOKEN)tmprplst->inputStream.base.node.prev;
                    pasting = gcvTRUE;
                    continue;
                }
            }
        }

        gcmTRACE(gcvLEVEL_VERBOSE,
            "ME : node in replacementList(%s0,not an ID or not a formal arg.",
            replacement_list->poolString);
        do
        {
            ppoTOKEN tmprplst = replacement_list;

            if( (*Head) == gcvNULL )
            {
                *Head = replacement_list;
                *End  = replacement_list;
            }
            else
            {
                (*End)->inputStream.base.node.prev = (void *)replacement_list;

                replacement_list->inputStream.base.node.next    = (void *)(*End);

                (*End) = replacement_list;
            }

            replacement_list = (ppoTOKEN)tmprplst->inputStream.base.node.prev;
        }
        while(gcvFALSE);

    }/*while(replacementList)*/

    if(*End)
    {
        (*End)->inputStream.base.node.prev = gcvNULL;
    }

    *AnyExpanationHappened = gcvTRUE;

    return gcvSTATUS_OK;

OnError:
	return status;
}
Exemplo n.º 18
0
/*******************************************************************************
**
**	gckCOMMAND_Stall
**
**	The calling thread will be suspended until the command queue has been
**  completed.
**
**	INPUT:
**
**		gckCOMMAND Command
**			Pointer to an gckCOMMAND object.
**
**	OUTPUT:
**
**		Nothing.
*/
gceSTATUS
gckCOMMAND_Stall(
    IN gckCOMMAND Command
    )
{
    gckOS os;
    gckHARDWARE hardware;
    gckEVENT event;
    gceSTATUS status;
	gctSIGNAL signal = gcvNULL;

	gcmkHEADER_ARG("Command=0x%x", Command);

    /* Verify the arguments. */
    gcmkVERIFY_OBJECT(Command, gcvOBJ_COMMAND);

#if gcdNULL_DRIVER == 2
	/* Do nothing with infinite hardware. */
	gcmkFOOTER_NO();
	return gcvSTATUS_OK;
#endif

    /* Extract the gckOS object pointer. */
    os = Command->os;
    gcmkVERIFY_OBJECT(os, gcvOBJ_OS);

    /* Extract the gckHARDWARE object pointer. */
    hardware = Command->kernel->hardware;
    gcmkVERIFY_OBJECT(hardware, gcvOBJ_HARDWARE);

    /* Extract the gckEVENT object pointer. */
    event = Command->kernel->event;
    gcmkVERIFY_OBJECT(event, gcvOBJ_EVENT);

    /* Allocate the signal. */
	gcmkONERROR(
		gckOS_CreateSignal(os, gcvTRUE, &signal));

    /* Append the EVENT command to trigger the signal. */
    gcmkONERROR(gckEVENT_Signal(event,
                                signal,
                                gcvKERNEL_PIXEL,
								gcvFALSE));

    /* Submit the event queue. */
	gcmkONERROR(gckEVENT_Submit(event, gcvTRUE, gcvFALSE));

#if gcdDUMP_COMMAND
    gcmkPRINT("@[kernel.stall]");
#endif

    if (status == gcvSTATUS_CHIP_NOT_READY)
    {
        /* Error. */
        goto OnError;
    }

	do
	{
		/* Wait for the signal. */
		status = gckOS_WaitSignal(os, signal, gcvINFINITE);

		if (status == gcvSTATUS_TIMEOUT)
		{
#if gcdDEBUG
			gctUINT32 idle;

			/* IDLE */
			gckOS_ReadRegister(Command->os, 0x0004, &idle);
                
			gcmkTRACE(gcvLEVEL_ERROR,
					  "%s(%d): idle=%08x",
					  __FUNCTION__, __LINE__, idle);
        	    	gckOS_Log(_GFX_LOG_WARNING_, "%s : %d : idle register = 0x%08x \n", 
                            __FUNCTION__, __LINE__, idle);                
#endif 

#if MRVL_PRINT_CMD_BUFFER
            {
    			gctUINT i;
                gctUINT32 idle;
    			gctUINT32 intAck;
    			gctUINT32 prevAddr = 0;
    			gctUINT32 currAddr;
    			gctBOOL changeDetected;

    			changeDetected = gcvFALSE;

                /* IDLE */
			    gckOS_ReadRegister(Command->os, 0x0004, &idle);
                
				/* INT ACK */
				gckOS_ReadRegister(Command->os, 0x0010, &intAck);

				/* DMA POS */
				for (i = 0; i < 300; i += 1)
				{
					gckOS_ReadRegister(Command->os, 0x0664, &currAddr);

					if ((i > 0) && (prevAddr != currAddr))
					{
						changeDetected = gcvTRUE;
					}

					prevAddr = currAddr;
				}

				gcmTRACE(0,
					"\n%s(%d):\n"
					"  idle = 0x%08X\n"
					"  int  = 0x%08X\n"
					"  dma  = 0x%08X (change=%d)\n",
					__FUNCTION__, __LINE__,
					idle,
					intAck,
					currAddr,
					changeDetected
					);
                
				_PrintCmdBuffer(Command, currAddr);
				_PrintLinkChain();
            }
#endif


#if MRVL_LOW_POWER_MODE_DEBUG
            	{
                	int i = 0;
                
                	printk(">>>>>>>>>>>>galDevice->kernel->kernelMSG\n");
                	printk("galDevice->kernel->msgLen=%d\n",Command->kernel->msgLen);
                
                	for(i=0;i<Command->kernel->msgLen;i+=1024)
                	{
                    		Command->kernel->kernelMSG[i+1023] = '\0';
            	    		printk("%s\n",(char*)Command->kernel->kernelMSG + i);
                	}
            	}
#endif
#ifdef __QNXNTO__
            gctUINT32 reg_cmdbuf_fetch;
            gctUINT32 reg_intr;

            gcmkVERIFY_OK(
                    gckOS_ReadRegister(Command->kernel->hardware->os, 0x0664, &reg_cmdbuf_fetch));

            if (idle == 0x7FFFFFFE)
            {
                /*
                 * GPU is idle so there should not be pending interrupts.
                 * Just double check.
                 *
                 * Note that reading interrupt register clears it.
                 * That's why we don't read it in all cases.
                 */
                gcmkVERIFY_OK(
                        gckOS_ReadRegister(Command->kernel->hardware->os, 0x10, &reg_intr));

                slogf(
                    _SLOG_SETCODE(1, 0),
                    _SLOG_CRITICAL,
                    "GALcore: Stall timeout (idle = 0x%X, command buffer fetch = 0x%X, interrupt = 0x%X)",
                    idle, reg_cmdbuf_fetch, reg_intr);
            }
            else
            {
                slogf(
                    _SLOG_SETCODE(1, 0),
                    _SLOG_CRITICAL,
                    "GALcore: Stall timeout (idle = 0x%X, command buffer fetch = 0x%X)",
                    idle, reg_cmdbuf_fetch);
            }
#endif
			gcmkVERIFY_OK(
				gckOS_MemoryBarrier(os, gcvNULL));
		}

	}
	while (gcmIS_ERROR(status));

	/* Delete the signal. */
	gcmkVERIFY_OK(gckOS_DestroySignal(os, signal));

    /* Success. */
    gcmkFOOTER_NO();
    return gcvSTATUS_OK;

OnError:
    /* Free the signal. */
    if (signal != gcvNULL)
    {
    	gcmkVERIFY_OK(gckOS_DestroySignal(os, signal));
    }

    /* Return the status. */
    gcmkFOOTER();
    return status;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_5_BufferRealArgs(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *HeadTail,
    ppoTOKEN            ID,
    ppoMACRO_SYMBOL     MS
    )
{
    gceSTATUS status;

    ppoTOKEN id = ID;

    ppoMACRO_SYMBOL ms = MS;

    ppoTOKEN ahead = gcvNULL;

    gctINT real_argc;

    gcmONERROR(
        (*IS)->GetToken(PP, IS, &ahead, !ppvICareWhiteSpace)
        );

    gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s, buffer real-arg(s).", id->poolString);

    real_argc = 0;

    while (ahead->poolString != PP->keyword->rpara)
    {
        gcmONERROR(ppoTOKEN_Destroy(PP, ahead));
        ahead = gcvNULL;

        if (real_argc < ms->argc)
        {
            gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s, buffer the %dth arg.", id->poolString, real_argc);

            ppoPREPROCESSOR_BufferActualArgs(
                PP,
                IS,
                &(HeadTail[real_argc*2]),
                &(HeadTail[real_argc*2+1])
                );

            gcmASSERT(
                ((HeadTail[real_argc*2] == gcvNULL) && (HeadTail[real_argc*2 + 1] == gcvNULL))
                ||
                ((HeadTail[real_argc*2] != gcvNULL) && (HeadTail[real_argc*2 + 1] != gcvNULL))
                );

            ++ real_argc;
        }
        else
        {
            ppoTOKEN no_use_head = gcvNULL;
            ppoTOKEN no_use_end  = gcvNULL;

            ppoPREPROCESSOR_BufferActualArgs(
                PP,
                IS,
                &no_use_head,
                &no_use_end
                );

            ++ real_argc;
        }

        if (*IS)
        {
            (*IS)->GetToken(PP, IS, &ahead, !ppvICareWhiteSpace);
        }
        else
        {
            ppoPREPROCESSOR_Report(
                PP,
                slvREPORT_ERROR,
                "unexpected end of file when expand the macro %s.",
                id->poolString);

            return gcvSTATUS_INVALID_DATA;
        }

        if (ahead->poolString != PP->keyword->rpara &&
            ahead->poolString != PP->keyword->comma)
        {

            if(ahead->poolString == PP->keyword->eof)
            {

                ppoPREPROCESSOR_Report(
                    PP,
                    slvREPORT_ERROR,
                    " unexpected end of file when expand the macro %s.",
                    id->poolString);
            }
            else
            {
                ppoPREPROCESSOR_Report(
                    PP,
                    slvREPORT_ERROR,
                    " unexpected token when expand the macro %s.",
                    id->poolString);
            }

            gcmONERROR(
                ppoTOKEN_Destroy(PP, id)
                );

            gcmONERROR(
                ppoTOKEN_Destroy(PP, ahead)
                );

            return gcvSTATUS_INVALID_DATA;
        }
    }/*while (ahead->poolString != PP->keyword->rpara)*/

    gcmONERROR(
        ppoTOKEN_Destroy(PP, ahead)
        );
    ahead = gcvNULL;

    if(real_argc < ms->argc)
    {
        ppoPREPROCESSOR_Report(
            PP,
            slvREPORT_WARN,
            "not enough actual parameters for macro '%s'.",
            id->poolString);
    }

    if(real_argc > ms->argc)
    {

        ppoPREPROCESSOR_Report(
            PP,
            slvREPORT_ERROR,
            "too many actual parameters for macro '%s'.",
            id->poolString);
    }

    gcmTRACE(gcvLEVEL_VERBOSE, "ME : %s,finish real-arg(s)-buffering.", id->poolString);

    return gcvSTATUS_OK;
OnError:
    if (ahead != gcvNULL)
    {
        gcmVERIFY_OK(ppoTOKEN_Destroy(PP, ahead));
        ahead = gcvNULL;
    }
	return status;
}
gceSTATUS
ppoPREPROCESSOR_MacroExpand_2_NoFormalArgs(
    ppoPREPROCESSOR     PP,
    ppoINPUT_STREAM     *IS,
    ppoTOKEN            *Head,
    ppoTOKEN            *End,
    gctBOOL             *AnyExpanationHappened,
    gctBOOL             *MatchCase,
    ppoTOKEN            ID,
    ppoMACRO_SYMBOL     MS)
{
    gceSTATUS status = gcvSTATUS_INVALID_DATA;

    ppoTOKEN id = ID;

    ppoMACRO_SYMBOL ms = MS;

    ppoTOKEN replacement_list = gcvNULL;

    gcmHEADER_ARG("PP=0x%x IS=0x%x Head=0x%x End=0x%x AnyExpanationHappened=0x%x MatchCase=0x%x ID=0x%x MS=0x%x",
                  PP, IS, Head, End, AnyExpanationHappened, MatchCase, ID, MS);

    gcmASSERT(ms != gcvNULL);

    if (ms->argc == 0)
    {
        gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s has no arg(s).",id->poolString);

        if (ms->replacementList == gcvNULL)
        {
            gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, has no replacement-list.",id->poolString);

            *Head = gcvNULL;
            *End  = gcvNULL;
            *AnyExpanationHappened = gcvTRUE;
            *MatchCase = gcvTRUE;

            status = ppoTOKEN_Destroy(PP,id);

            if (gcmIS_SUCCESS(status))
            {
                gcmFOOTER_ARG("*Head=0x%x *End=0x%x *AnyExpanationHappened=%d *MatchCase=%d",
                              *Head, *End, *AnyExpanationHappened, *MatchCase);
                return gcvSTATUS_OK;
            }
            else
            {
                gcmFOOTER();
                return status;
            }
        }

        gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, has replacement-list.",id->poolString);

        gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, colon replacement-list.",id->poolString);

        gcmONERROR(ppoTOKEN_ColonTokenList(
            PP,
            ms->replacementList,
            __FILE__,
            __LINE__,
            "ME : colon replacementList",
            &replacement_list)
            );

        *Head = replacement_list;

        gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, add hs.",id->poolString);

        while(replacement_list)
        {
            gcmASSERT(replacement_list->hideSet == gcvNULL);

            ppoHIDE_SET_LIST_Append(
                PP,
                replacement_list,
                id);

            ppoHIDE_SET_AddHS(PP, replacement_list, id->poolString);

            if((void*)replacement_list->inputStream.base.node.prev == gcvNULL)
            {
                *End = replacement_list;
            }

            replacement_list = (ppoTOKEN)replacement_list->inputStream.base.node.prev;
        }

        *AnyExpanationHappened = gcvTRUE;

        *MatchCase = gcvTRUE;

        status = ppoTOKEN_Destroy(PP,id);

        if (gcmIS_SUCCESS(status))
        {
            gcmFOOTER_ARG("*Head=0x%x *End=0x%x *AnyExpanationHappened=%d *MatchCase=%d",
                          *Head, *End, *AnyExpanationHappened, *MatchCase);
            return gcvSTATUS_OK;
        }
        else
        {
            gcmFOOTER();
            return status;
        }

    }
    else/*if (ms->argc == 0)*/
    {
        *Head   = gcvNULL;
        *End    = gcvNULL;
        *AnyExpanationHappened = gcvFALSE;
        *MatchCase = gcvFALSE;

        gcmFOOTER_ARG("*Head=0x%x *End=0x%x *AnyExpanationHappened=%d *MatchCase=%d",
                      *Head, *End, *AnyExpanationHappened, *MatchCase);
        return gcvSTATUS_OK;
    }

OnError:
    gcmFOOTER();
	return status;
}