2014-01-08  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Introduce ComputeKernel class (part 2)
        Issue #389

        Reviewed by Igor.

        Removed the left over bits of 7f1014eab1:
        CCKernel should not be used from ComputeContext.cpp/h

        * platform/ComputeContext.h:
        * platform/opencl/ComputeContextCL.cpp:
2014-01-12  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Introduce a isUserEvent helper getter.

        Reviewed by TrustMe.

        * Modules/webcl/WebCLEvent.cpp:
        (WebCore::WebCLEvent::WebCLEvent):
        (WebCore::WebCLEvent::isUserEvent):
        * Modules/webcl/WebCLEvent.h:
        * Modules/webcl/WebCLUserEvent.cpp:
        (WebCore::WebCLUserEvent::create):
        (WebCore::WebCLUserEvent::WebCLUserEvent):
2014-01-08  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        WebCLEvent::setCallback implementation not working.
        Issue #102

        Reviewed by Igor.

        Fix custom bindings as following:

        * Modules/webcl/WebCLCommandQueue.cpp:
        (WebCore::WebCLCommandQueue::enqueueWriteBufferBase):
        (WebCore::WebCLCommandQueue::enqueueWriteBufferRectBase):
        (WebCore::WebCLCommandQueue::enqueueReadBufferBase):
        (WebCore::WebCLCommandQueue::enqueueReadImageBase):
        (WebCore::WebCLCommandQueue::enqueueReadBufferRectBase):
        (WebCore::WebCLCommandQueue::enqueueNDRangeKernel):
        (WebCore::WebCLCommandQueue::enqueueWriteImageBase):
        (WebCore::WebCLCommandQueue::enqueueCopyImage):
        (WebCore::WebCLCommandQueue::enqueueCopyImageToBuffer):
        (WebCore::WebCLCommandQueue::enqueueCopyBufferToImage):
        (WebCore::WebCLCommandQueue::enqueueCopyBuffer):
        (WebCore::WebCLCommandQueue::enqueueCopyBufferRect):
        (WebCore::WebCLCommandQueue::enqueueAcquireGLObjects):
        (WebCore::WebCLCommandQueue::enqueueReleaseGLObjects):

        - Added a call to process the callback register queue, in
          case a callback was set before the cl_event object was
          initialized by the associated 'queue' method.

          It bails out in case there is nothing to register.

        * Modules/webcl/WebCLEvent.cpp:
        (WebCore::WebCLEvent::getInfo):
        (WebCore::WebCLEvent::getProfilingInfo):
        (WebCore::WebCLEvent::callbackProxy):

        - OpenCL might call the registered callback on non-mainthread.
          When it happens, we can not simply call the associated JS-callback:
          JS has to be called from the main thread.
          To work it around, we dispatch a call to the mainthread, so that
          JS can be called safely.

        (WebCore::WebCLEvent::callbackProxyOnMainThread):

        - Actually responsible for calling the JS callback in case.
        1) It converts the "userData" to an WebCLEvent instance;
        2) walks through the registered callbacks for this event and
           call them all.
        3) After that, it removed the event from the HashMap (queue).

        (WebCore::WebCLEvent::setCallback):

        1) Events are added to the queue once.
        2) Each event in the queue might have many callbacks associated to it.
        2) While being added, if the event holds a valid OpenCL cl_event instance,
           then it can be registered in OpenCL right way.
        3) Otherwise, it is processed when the associated WebCLCommandQueue method
           initializes it by 'processCallbackRegisterQueueForEvent'.
        4) Once an event has a callback registered in OpenCL, the following
           callback registrations are shortcut: they are added to the queue, but
           not registered in OpenCL.

        (WebCore::WebCLEvent::processCallbackRegisterQueueForEvent):

        - Processes a given event

        * Modules/webcl/WebCLEvent.h:
        (WebCore::WebCLEvent::callbackRegisterQueue):
        * Modules/webcl/WebCLGetInfo.h:
        * bindings/js/JSWebCLEventCustom.cpp:
        (WebCore::createCallback):

        - Fixed the createCallback function so that it actually
        creates a callback, instead of just hard-returning 0.

        (WebCore::JSWebCLEvent::setCallback):

        - Changed the number of expected parameters
        from 3 to 2.
        - Removed a lot of unused and unneeded code.

        * platform/ComputeContext.h:

        - Declared setUserEventStatus

        * platform/ComputeTypes.h:

        - Declared our new function signature.

        * platform/opencl/ComputeContextCL.cpp:
        (WebCore::ComputeContext::setEventCallback):

        - Bridge throgh the actual OpenCL call.
2014-01-12  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Make WebCL::waitForEvents less hang-prone
        Issue #401

        Reviewed by Igor.

        Restrict the events accepted by the WebCL::waitForEvents method in two ways:
        1) only WebCLEvents that hold valid CCEvent can be waited on.
        An exception is thrown otherwise.
        2) for now, fail to accept WebCLUserEvents. Reasons:
        2.1) Logical: if application is waiting on an event
        (blocked), it won't be able to set this event status to
        'complete', so the browser will hang undefinitively.
        2.2) We might consider reverting both restrictions above
        when we support the asynchronous variant of this method.

        * Modules/webcl/WebCL.cpp:
        (WebCore::WebCL::waitForEvents):
2014-01-12  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        WebCLUserEvent::setStatus can only be called once.
        Issue #402

        Reviewed by Igor.

        As per the spec.

        * Modules/webcl/WebCLUserEvent.cpp:
        (WebCore::WebCLUserEvent::WebCLUserEvent):
        (WebCore::WebCLUserEvent::setStatus):
        * Modules/webcl/WebCLUserEvent.h:
2014-01-12  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Fix WebCLUserEvent::setStatus acceptable values list.
        Issue #403

        Reviewed by Igor.

        Both negative values or 'complete' should be acceptable
        as valid input.

        * Modules/webcl/WebCLUserEvent.cpp:
        (WebCore::WebCLUserEvent::setStatus):
2014-01-12  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Fix WebCLEvent/WebCLUserEvent::getInfo
        Issue #406

        Reviewed by Igor.

        Patch makes WebCLEvent::getInfo virtual, and adds an
        overload to WebCLUserEvent.
        WebCLUserEvent::getInfo supports queries for both
        COMMAND_QUEUE and CONTEXT, and defers to the base class
        other values.

        WebCLUserEvent now safily only verifies if platformObject
        if valid, instead of checking 'm_commandQueue', etc.

        * Modules/webcl/WebCLEvent.cpp:
        (WebCore::WebCLEvent::getInfo):
        * Modules/webcl/WebCLEvent.h:
        (WebCore::WebCLEvent::callbackRegisterQueue):
        * Modules/webcl/WebCLUserEvent.cpp:
        (WebCore::WebCLUserEvent::getInfo):
2014-01-09  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Throw an exception if getProfilingInfo is called from an WebCLUserEvent.
        Issue #405

        Reviewed by Igor.

        As per the spec

        * Modules/webcl/WebCLEvent.cpp:
        (WebCore::WebCLEvent::getProfilingInfo):
2014-01-12  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Validate eventWaitList content before actually passing it down to OpenCL.
        Issue #399

        Reviewed by Igor.

        events in an eventWaitList (almost all CommandQueue APIs
        optionally take it) have to hold valid platform objects
        (i.e. CCEvents). They can be either originated from
        an explicit create user event call, or implicitly populated
        by one of the previous CommandQueue calls.

        * Modules/webcl/WebCLCommandQueue.cpp:
        (WebCore::ccEventListFromWebCLEventList):
        (WebCore::WebCLCommandQueue::enqueueWriteBufferBase):
        (WebCore::WebCLCommandQueue::enqueueWriteBufferRectBase):
        (WebCore::WebCLCommandQueue::enqueueReadBufferBase):
        (WebCore::WebCLCommandQueue::enqueueReadImageBase):
        (WebCore::WebCLCommandQueue::enqueueReadBufferRectBase):
        (WebCore::WebCLCommandQueue::enqueueNDRangeKernel):
        (WebCore::WebCLCommandQueue::enqueueWriteImageBase):
        (WebCore::WebCLCommandQueue::enqueueCopyImage):
        (WebCore::WebCLCommandQueue::enqueueCopyImageToBuffer):
        (WebCore::WebCLCommandQueue::enqueueCopyBufferToImage):
        (WebCore::WebCLCommandQueue::enqueueCopyBuffer):
        (WebCore::WebCLCommandQueue::enqueueCopyBufferRect):
        (WebCore::WebCLCommandQueue::enqueueAcquireGLObjects):
        (WebCore::WebCLCommandQueue::enqueueReleaseGLObjects):
2014-01-13  Antonio Gomes  <a1.gomes@sisa.samsung.com>

        Check events' context
        Issue #404

        Reviewed by Igor.

        WebCLEvents must share the same context of
        its associated command queue.

        * Modules/webcl/WebCLCommandQueue.cpp:
        (WebCore::WebCLCommandQueue::ccEventListFromWebCLEventList):
        * Modules/webcl/WebCLCommandQueue.h:
        * Modules/webcl/WebCLEvent.cpp:
        (WebCore::WebCLEvent::context):
        * Modules/webcl/WebCLEvent.h:
        * Modules/webcl/WebCLProgram.cpp:
        (WebCore::WebCLProgram::build):
        * Modules/webcl/WebCLUserEvent.cpp:
        (WebCore::WebCLUserEvent::context):
        * Modules/webcl/WebCLUserEvent.h: