Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8336624: Improve Decora Shader loading for modern APIs #1530

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -429,7 +429,8 @@ private static ByteBuffer getBuffer(InputStream is) {
}

@Override
public Shader createShader(InputStream pixelShaderCode,
public Shader createShader(String pixelShaderName,
InputStream pixelShaderCode,
Map<String, Integer> samplers,
Map<String, Integer> params,
int maxTexCoordIndex,
@@ -458,8 +459,8 @@ public Shader createStockShader(final String name) {
);
Class klass = Class.forName("com.sun.prism.shader." + name + "_Loader");
Method m = klass.getMethod("loadShader",
new Class[] { ShaderFactory.class, InputStream.class });
return (Shader)m.invoke(null, new Object[] { this, stream });
new Class[] { ShaderFactory.class, String.class, InputStream.class });
return (Shader)m.invoke(null, new Object[] { this, name, stream });
} catch (Throwable e) {
e.printStackTrace();
throw new InternalError("Error loading stock shader " + name);
Original file line number Diff line number Diff line change
@@ -217,7 +217,8 @@ public int getMaximumTextureSize() {
}

@Override
public Shader createShader(InputStream pixelShaderCode,
public Shader createShader(String pixelShaderName,
InputStream pixelShaderCode,
Map<String, Integer> samplers,
Map<String, Integer> params,
int maxTexCoordIndex,
@@ -320,8 +321,8 @@ public Shader createStockShader(String name) {
}
Method m =
klass.getMethod("loadShader", new Class[]{ShaderFactory.class,
InputStream.class});
return (Shader) m.invoke(null, new Object[]{this, stream});
String.class, InputStream.class});
return (Shader) m.invoke(null, new Object[]{this, name, stream});
} catch (Throwable e) {
e.printStackTrace();
throw new InternalError("Error loading stock shader " + name);
Original file line number Diff line number Diff line change
@@ -108,7 +108,8 @@ public Presentable createPresentable(PresentableState pState) {
}

@Override
public Shader createShader(InputStream pixelShaderCode,
public Shader createShader(String pixelShaderName,
InputStream pixelShaderCode,
Map<String, Integer> samplers,
Map<String, Integer> params,
int maxTexCoordIndex,
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@

public interface ShaderFactory extends ResourceFactory {

public Shader createShader(InputStream pixelShaderCode,
public Shader createShader(String pixelShaderName,
InputStream pixelShaderCode,
Map<String, Integer> samplers,
Map<String, Integer> params,
int maxTexCoordIndex,
Original file line number Diff line number Diff line change
@@ -267,7 +267,7 @@ public Shader createShader(String name,
InputStream pscode = shaderSource.loadSource(name);
int maxTexCoordIndex = samplers.keySet().size()-1;
ShaderFactory factory = (ShaderFactory)rf;
return factory.createShader(pscode, samplers, params,
return factory.createShader(name, pscode, samplers, params,
maxTexCoordIndex,
isPixcoordUsed, false);
}
Original file line number Diff line number Diff line change
@@ -43,13 +43,14 @@ public class $shaderName$_Loader {
}

public static Shader loadShader(ShaderFactory factory,
String pixelShaderName,
InputStream pixelShaderCode)
{
HashMap<String, Integer> samplers = new HashMap<String, Integer>();
$samplerInit$
HashMap<String, Integer> params = new HashMap<String, Integer>();
$paramInit$
return factory.createShader(pixelShaderCode, samplers, params,
return factory.createShader(pixelShaderName, pixelShaderCode, samplers, params,
$maxTexCoordIndex$,
$isPixcoordUsed$, true);
}