changeset 5626:1194b215f671

RT-33549: Clip applied on 3D object causes VM crash Summary: Resolve d3d crash when apply 2D operation on 3D object Reviewed-by: kcr, ckyang
author Yao Wang <yao.w.wang@oracle.com>
date Mon, 04 Nov 2013 13:59:44 -0800
parents 939e768ae868
children b937270b6da0
files modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGNode.java modules/graphics/src/main/native-prism-d3d/D3DMeshView.cc
diffstat 2 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGNode.java	Mon Nov 04 09:51:02 2013 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGNode.java	Mon Nov 04 13:59:44 2013 -0800
@@ -2017,19 +2017,20 @@
         // approximation, but somewhat more accurate (at least it doesn't include
         // groups which don't paint anything themselves).
         boolean p = false;
-        if (g instanceof ReadbackGraphics && needsBlending()) {
+        // NOTE: Opt out 2D operations on 3D Shapes, which are not yet handled by Prism
+        if (!isShape3D() && g instanceof ReadbackGraphics && needsBlending()) {
             renderNodeBlendMode(g);
             p = true;
-        } else if (getOpacity() < 1f) {
+        } else if (!isShape3D() && getOpacity() < 1f) {
             renderOpacity(g);
             p = true;
-        } else if (getCacheFilter() != null) {
+        } else if (!isShape3D() && getCacheFilter() != null) {
             renderCached(g);
             p = true;
-        } else if (getClipNode() != null) {
+        } else if (!isShape3D() && getClipNode() != null) {
             renderClip(g);
             p = true;
-        } else if (getEffectFilter() != null && effectsSupported) {
+        } else if (!isShape3D() && getEffectFilter() != null && effectsSupported) {
             renderEffect(g);
             p = true;
         } else {
--- a/modules/graphics/src/main/native-prism-d3d/D3DMeshView.cc	Mon Nov 04 09:51:02 2013 -0800
+++ b/modules/graphics/src/main/native-prism-d3d/D3DMeshView.cc	Mon Nov 04 13:59:44 2013 -0800
@@ -121,24 +121,26 @@
 }
 
 void D3DMeshView::render() {
-    D3DMATRIX mat;
-    HRESULT status = true;
+    RETURN_IF_NULL(context);
+    RETURN_IF_NULL(material);
+    RETURN_IF_NULL(mesh);
+
     IDirect3DDevice9 *device = context->Get3DDevice();
+    RETURN_IF_NULL(device);
 
-    if (material == NULL) {
+    HRESULT status = SUCCEEDED(device->SetFVF(mesh->getVertexFVF()));
+    if (!status) {
+        cout << "D3DMeshView.render() - SetFVF failed !!!" << endl;
         return;
     }
 
-    status = SUCCEEDED(device->SetFVF(mesh->getVertexFVF()));
-    if (!status) {
-        cout << "D3DMeshView.render() - SetFVF failed !!!" << endl;
-    }
-
     D3DPhongShader *pShader = context->getPhongShader();
+    RETURN_IF_NULL(pShader);
 
     status = SUCCEEDED(device->SetVertexShader(pShader->getVertexShader()));
     if (!status) {
         cout << "D3DMeshView.render() - SetVertexShader failed !!!" << endl;
+        return;
     }
 
     // TODO: 3D - Use Java layer sorting instead of the local sort.
@@ -151,11 +153,13 @@
     status = SUCCEEDED(device->SetVertexShaderConstantF(VSR_AMBIENTCOLOR, ambientLightColor, 1));
     if (!status) {
         cout << "D3DMeshView.render() - SetVertexShaderConstantF (VSR_AMBIENTCOLOR) failed !!!" << endl;
+        return;
     }
 
     status = SUCCEEDED(device->SetPixelShaderConstantF(PSR_CONSTANTCOLOR, material->getSolidColor(), 1));
     if (!status) {
         cout << "D3DMeshView.render() - SetPixelShaderConstantF (PSR_CONSTANTCOLOR) failed !!!" << endl;
+        return;
     }
 
     float lightsColor[12];
@@ -169,6 +173,7 @@
     status = SUCCEEDED(device->SetPixelShaderConstantF(PSR_LIGHTCOLOR, lightsColor, 3));
     if (!status) {
         cout << "D3DMeshView.render() - SetPixelShaderConstantF (PSR_LIGHTCOLOR) failed !!!" << endl;
+        return;
     }
 
     int bm = pShader->getBumpMode(material->isBumpMap());
@@ -179,6 +184,7 @@
     status = pShader->setPixelShader(numLights, sm, bm, im);
     if (!status) {
         cout << "D3DMeshView.render() - setPixelShader failed !!!" << endl;
+        return;
     }
 
     SUCCEEDED(device->SetTexture(SR_DIFFUSEMAP, material->getMap(DIFFUSE)));
@@ -186,6 +192,7 @@
     SUCCEEDED(device->SetTexture(SR_BUMPHEIGHTMAP, material->getMap(BUMP)));
     SUCCEEDED(device->SetTexture(SR_SELFILLUMMAP, material->getMap(SELFILLUMINATION)));
 
+    D3DMATRIX mat;
     matrixTransposed(mat, *(context->GetWorldTx()));
 //    std::cerr << "Transposed world transform:\n";
 //    fprintf(stderr, "  %5f %5f %5f %5f\n", mat._11, mat._12, mat._13, mat._14);