/*
 * Westford Wayland Compositor.
 * Copyright (C) 2016  Erik De Rijcke
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.westford.compositor.core;

import org.freedesktop.wayland.server.WlBufferResource;
import org.freedesktop.wayland.server.WlSurfaceResource;
import org.westford.compositor.drm.egl.DrmEglOutput;
import org.westford.compositor.protocol.WlOutput;
import org.westford.compositor.x11.egl.X11EglOutput;

import javax.annotation.Nonnull;

public interface Renderer {
    void visit(@Nonnull RenderOutput renderOutput,
               @Nonnull WlOutput wlOutput);

    void visit(@Nonnull EglOutput eglConnector,
               @Nonnull WlOutput wlOutput);

    void visit(@Nonnull DrmEglOutput drmEglOutput,
               @Nonnull WlOutput wlOutput);

    void visit(@Nonnull X11EglOutput x11EglOutput,
               @Nonnull WlOutput wlOutput);

    //TODO pixman sw rendering platform
    //void visit(PixmanOutput pixmanOutput);
    //void visit(DrmPixmanOutput drmPixmanOutput);
    //void visit(X11PixmanOutput x11PixmanOutput);

    /**
     * @param wlSurfaceResource
     *
     * @deprecated method will be removed
     */
    //FIXME remove this method and instead register a destroy listener in the renderer implementation
    @Deprecated
    void onDestroy(@Nonnull WlSurfaceResource wlSurfaceResource);

    @Nonnull
    Buffer queryBuffer(@Nonnull WlBufferResource wlBufferResource);
}

@@ -1111,24 +1111,32 @@
 derer %7B%0A    
+default 
 void visit(@
@@ -1177,32 +1177,40 @@
 %0A               
+        
 @Nonnull WlOutpu
@@ -1212,38 +1212,227 @@
 Output wlOutput)
-;%0A%0A   
+ %7B%0A        throw new UnsupportedOperationException(String.format(%22RenderOutput %25s not supported.%22,%0A                                                              renderOutput));%0A    %7D%0A%0A    default
  void visit(@Non
@@ -1453,19 +1453,22 @@
  egl
-Connector,%0A
+Output,%0A      
     
@@ -1470,32 +1470,34 @@
                 
+  
 @Nonnull WlOutpu
@@ -1499,38 +1499,221 @@
 Output wlOutput)
-;%0A%0A   
+ %7B%0A        throw new UnsupportedOperationException(String.format(%22EglOutput %25s not supported.%22,%0A                                                              eglOutput));%0A    %7D%0A%0A    default
  void visit(@Non
@@ -1751,32 +1751,40 @@
 %0A               
+        
 @Nonnull WlOutpu
@@ -1794,22 +1794,211 @@
 lOutput)
-;%0A%0A   
+ %7B%0A        throw new UnsupportedOperationException(String.format(%22DrmEglOutput %25s not supported.%22,%0A                                                              drmEglOutput));%0A    %7D%0A%0A    default
  void vi
@@ -2044,32 +2044,40 @@
 %0A               
+        
 @Nonnull WlOutpu
@@ -2083,25 +2083,206 @@
 ut wlOutput)
-;
+ %7B%0A        throw new UnsupportedOperationException(String.format(%22X11EglOutput %25s not supported.%22,%0A                                                              x11EglOutput));%0A    %7D
 %0A%0A    //TODO

add default implementations for rendering on different outputs