changeset 11245:d13a6227b543

Merge
author kcr
date Mon, 15 Apr 2019 11:15:07 -0700
parents 66b5bcf8564d aace3d512963
children b1b8c9c65c2a
files
diffstat 13 files changed, 497 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Apr 02 09:58:07 2019 -0700
+++ b/.hgtags	Mon Apr 15 11:15:07 2019 -0700
@@ -529,3 +529,5 @@
 4d10485201c7dd803ada7c257d0452b8e13c7c82 13+1
 bf9eac8eebef0f469e62e08f394084bfa08ebffb 13+2
 fe567d56155a1b2e339b92a53511ac9353709e59 13+3
+ca6835f332858982f118f8ecee0c264328ea3b47 13+4
+ee34b53aac6bed55084170dd916d414a72126faf 13+5
--- a/build.gradle	Tue Apr 02 09:58:07 2019 -0700
+++ b/build.gradle	Mon Apr 15 11:15:07 2019 -0700
@@ -1295,6 +1295,18 @@
 logger.quiet("jdk build number: ${jdkBuildNumber}")
 logger.quiet("minimum jdk version: ${jfxBuildJdkVersionMin}")
 logger.quiet("minimum jdk build number: ${jfxBuildJdkBuildnumMin}")
+
+if (IS_LINUX) {
+    logger.quiet("GCC version: ${jfxBuildLinuxGccVersion}")
+} else if (IS_WINDOWS) {
+    logger.quiet("MSVC version: ${jfxBuildWindowsMsvcVersion}")
+} else if (IS_MAC) {
+    logger.quiet("XCODE version: ${jfxBuildMacosxXcodeVersion}")
+}
+logger.quiet("cmake version: ${jfxBuildCmakeVersion}")
+logger.quiet("ninja version: ${jfxBuildNinjaVersion}")
+logger.quiet("ant version: ${jfxBuildAntVersion}")
+
 logger.quiet("HAS_JAVAFX_MODULES: $HAS_JAVAFX_MODULES")
 logger.quiet("STUB_RUNTIME: $STUB_RUNTIME")
 logger.quiet("CONF: $CONF")
@@ -1604,6 +1616,98 @@
 }
 
 /**
+ * Verifies that all of the *.java files in a source tree have the
+ * correct package name. If not, fail the build.
+ *
+ * @param sourceRoot the root of the source tree to check
+ * @param hasModuleName true if the sources under sourceRoot are being
+ * compiled as modules, with the immediate child directories being the
+ * root(s) of the named modules being compiled. In this case the package
+ * root is one directory below the sourceRoot.
+ */
+void validatePackages(File sourceRoot, boolean hasModuleName) {
+    if (!sourceRoot.isDirectory()) {
+        return;
+    }
+    def err = false;
+    String sourceString = sourceRoot.toString().replace("\\", "/")
+    def startPos = sourceString.length() + 1
+    logger.info("validating packages for ${sourceRoot}")
+    def inputFiles = fileTree(dir: sourceRoot, include: "**/*.java")
+    inputFiles.each { file ->
+        def packageRoot = file.toString().replace("\\", "/").substring(startPos)
+        if (hasModuleName) {
+            packageRoot = packageRoot.substring(packageRoot.indexOf("/") + 1)
+        }
+        def endPos = packageRoot.lastIndexOf("/")
+        def pkgEx = endPos > -1 ?  packageRoot.substring(0, endPos).replace("/", ".") : ""
+        def pkg = ""
+        file.withReader { reader ->
+            def line
+            while ((line = reader.readLine()) != null) {
+                def words = line.trim().split("[ ;]+")
+                if (words.length > 1 && words[0] == "package") {
+                    pkg = words[1]
+                    break;
+                }
+            }
+        }
+        if (pkg != pkgEx) {
+            err = true
+            println "*** ERROR: File location <${file}> does not match package name <${pkg}>"
+        }
+    }
+    if (err) {
+        fail("Package validation failed")
+    }
+}
+
+/**
+ * Add a task to the given project to validate that the package names
+ * of all java files in the given source sets have the correct package
+ * name. If not, fail the build.
+ */
+void addValidateSourceSets(Project project,
+                           Collection<SourceSet> sourceSets,
+                           Collection<SourceSet> modSourceSets) {
+    def validateSourceSetsTask = project.task("validateSourceSets") {
+        doLast {
+            // Accumulate the root directories from all sourceSets.
+            // We use a Set to elide duplicates (the shims sourceset
+            // will include the dirs from the main sourceset)
+            Set<File> sourceRoots = []
+            sourceSets.each { srcSet ->
+                srcSet.java.srcDirs.each { rootDir ->
+                    sourceRoots += rootDir
+                }
+            }
+            sourceRoots.each { rootDir ->
+                validatePackages(rootDir, false)
+            }
+
+            Set<File> modSourceRoots = []
+            modSourceSets.each { srcSet ->
+                srcSet.java.srcDirs.each { rootDir ->
+                    modSourceRoots += rootDir
+                }
+            }
+            modSourceRoots.each { rootDir ->
+                validatePackages(rootDir, true)
+            }
+        }
+    }
+
+    // Run this for all projects when compiling the test sources
+    // (i.e., when running "gradle test")
+    project.compileTestJava.dependsOn(validateSourceSetsTask)
+}
+
+void addValidateSourceSets(Project project, Collection<SourceSet> sourceSets) {
+    addValidateSourceSets(project, sourceSets, []);
+}
+
+
+/**
  * Parses a JDK version string. The string must be in one of the following
  * two formats:
  *
@@ -1734,7 +1838,7 @@
         repositories {
             mavenCentral()
             ivy {
-                url "http://download.eclipse.org/eclipse/updates/4.6/R-4.6.3-201703010400/plugins/"
+                url "https://download.eclipse.org/eclipse/updates/4.6/R-4.6.3-201703010400/plugins/"
                 layout "pattern", {
                     artifact "[artifact].[ext]"
                 }
@@ -1852,12 +1956,24 @@
 
     sourceSets {
         main
-        shims
-        test
+        shims {
+            java {
+                compileClasspath += sourceSets.main.output
+                runtimeClasspath += sourceSets.main.output
+            }
+        }
+        test {
+            java {
+                compileClasspath += sourceSets.shims.output
+                runtimeClasspath += sourceSets.shims.output
+            }
+        }
     }
 
     dependencies {
         testCompile group: "junit", name: "junit", version: "4.8.2"
+        testCompile sourceSets.main.output
+        testCompile sourceSets.shims.output
     }
 
     commonModuleSetup(project, [ 'base' ])
@@ -1895,6 +2011,7 @@
     compileJava.dependsOn processVersionInfo
     addMavenPublication(project, [])
 
+    addValidateSourceSets(project, sourceSets)
 }
 
 // The graphics module is needed for any graphical JavaFX application. It requires
@@ -1914,9 +2031,19 @@
     sourceSets {
         jslc   // JSLC gramar subset
         main
-        shims
+        shims {
+            java {
+                compileClasspath += sourceSets.main.output
+                runtimeClasspath += sourceSets.main.output
+            }
+        }
         shaders // generated shaders (prism & decora)
-        test
+        test {
+            java {
+                compileClasspath += sourceSets.shims.output
+                runtimeClasspath += sourceSets.shims.output
+            }
+        }
         stub
     }
 
@@ -1924,6 +2051,7 @@
         stubCompile group: "junit", name: "junit", version: "4.8.2"
 
         antlr group: "org.antlr", name: "antlr4", version: "4.7.2", classifier: "complete"
+        compile project(':base')
     }
 
     project.ext.moduleSourcePath = defaultModuleSourcePath_GraphicsOne
@@ -1970,6 +2098,12 @@
         // so we will do this by hand
 
         File wd = file(project.projectDir.path + "/src/jslc/antlr")
+        File outDir = file("$buildDir/gensrc/antlr")
+        def inJSL = "com/sun/scenario/effect/compiler/JSL.g4"
+        if (IS_WINDOWS) {
+            // antlr needs backslashes on Windows
+            inJSL = inJSL.replace("/", "\\")
+        }
 
         executable = JAVA
         classpath = project.configurations.antlr
@@ -1978,13 +2112,13 @@
 
         args = [
             "-o",
-            "$buildDir/gensrc/antlr",
+            outDir.toString(),
             "-package",
             "com.sun.scenario.effect.compiler",
-            "com/sun/scenario/effect/compiler/JSL.g4" ]
+            inJSL ]
 
         inputs.dir wd
-        outputs.dir file("$buildDir/gensrc/antlr")
+        outputs.dir outDir
     }
     sourceSets.jslc.java.srcDirs += "$buildDir/gensrc/antlr"
 
@@ -2322,6 +2456,7 @@
 
     addMavenPublication(project, [ 'base' ])
 
+    addValidateSourceSets(project, sourceSets)
 }
 
 project(":controls") {
@@ -2332,8 +2467,18 @@
 
     sourceSets {
         main
-        shims
-        test
+        shims {
+            java {
+                compileClasspath += sourceSets.main.output
+                runtimeClasspath += sourceSets.main.output
+            }
+        }
+        test {
+            java {
+                compileClasspath += sourceSets.shims.output
+                runtimeClasspath += sourceSets.shims.output
+            }
+        }
     }
 
     project.ext.moduleSourcePath = defaultModuleSourcePath
@@ -2344,6 +2489,8 @@
     dependencies {
         testCompile project(":graphics").sourceSets.test.output
         testCompile project(":base").sourceSets.test.output
+        compile project(':base')
+        compile project(':graphics')
     }
 
     test {
@@ -2383,6 +2530,7 @@
 
     addMavenPublication(project, [ 'graphics' ])
 
+    addValidateSourceSets(project, sourceSets)
 }
 
 project(":swing") {
@@ -2408,6 +2556,8 @@
     commonModuleSetup(project, [ 'base', 'graphics', 'swing' ])
 
     dependencies {
+        compile project(":base")
+        compile project(":graphics")
     }
 
     test {
@@ -2417,6 +2567,8 @@
     if (COMPILE_SWING) {
         addMavenPublication(project, [ 'graphics' ])
     }
+
+    addValidateSourceSets(project, sourceSets)
 }
 
 project(":swt") {
@@ -2476,6 +2628,8 @@
             logger.info("SWT tests are disabled on MAC, because Gradle test runner does not handle -XstartOnFirstThread properly (https://issues.gradle.org/browse/GRADLE-3290).")
         }
     }
+
+    addValidateSourceSets(project, sourceSets)
 }
 
 project(":fxml") {
@@ -2486,8 +2640,18 @@
 
     sourceSets {
         main
-        shims
-        test
+        shims {
+            java {
+                compileClasspath += sourceSets.main.output
+                runtimeClasspath += sourceSets.main.output
+            }
+        }
+        test {
+            java {
+                compileClasspath += sourceSets.shims.output
+                runtimeClasspath += sourceSets.shims.output
+            }
+        }
     }
 
     project.ext.moduleSourcePath = defaultModuleSourcePath
@@ -2499,6 +2663,8 @@
     dependencies {
         testCompile project(":graphics").sourceSets.test.output
         testCompile project(":base").sourceSets.test.output
+        compile project(":base")
+        compile project(":graphics")
     }
 
     test {
@@ -2512,6 +2678,7 @@
 
     addMavenPublication(project, [ 'controls' ])
 
+    addValidateSourceSets(project, sourceSets)
 }
 
 project(":media") {
@@ -2545,6 +2712,8 @@
             media name: "libav-12.1", ext: "tar.gz"
             media name: "ffmpeg-3.3.3", ext: "tar.gz"
         }
+        compile project(":base")
+        compile project(":graphics")
     }
 
     compileJava.dependsOn updateCacheIfNeeded
@@ -3101,6 +3270,7 @@
 
     addMavenPublication(project, [ 'graphics' ])
 
+    addValidateSourceSets(project, sourceSets)
 }
 
 project(":web") {
@@ -3114,8 +3284,18 @@
 
     sourceSets {
         main
-        shims
-        test
+        shims {
+            java {
+                compileClasspath += sourceSets.main.output
+                runtimeClasspath += sourceSets.main.output
+            }
+        }
+        test {
+            java {
+                compileClasspath += sourceSets.shims.output
+                runtimeClasspath += sourceSets.shims.output
+            }
+        }
     }
 
     project.ext.moduleSourcePath = defaultModuleSourcePath
@@ -3124,6 +3304,10 @@
     commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'media', 'web' ])
 
     dependencies {
+        compile project(":base")
+        compile project(":graphics")
+        compile project(":controls")
+        compile project(":media")
     }
 
     compileJava.dependsOn updateCacheIfNeeded
@@ -3276,7 +3460,7 @@
         }
 
         def copyNativeTask = task("copyNative${t.capital}", type: Copy,
-                dependsOn: [compileNativeTask, , copyDumpTreeNativeTask]) {
+                dependsOn: [compileNativeTask, copyDumpTreeNativeTask]) {
             enabled =  (IS_COMPILE_WEBKIT)
             def library = rootProject.ext[t.upper].library
             from "$webkitOutputDir/$webkitConfig/$dllDir/${library('jfxwebkit')}"
@@ -3329,6 +3513,7 @@
 
     addMavenPublication(project, [ 'controls', 'media' ])
 
+    addValidateSourceSets(project, sourceSets)
 }
 
 // This project is for system tests that need to run with a full SDK.
@@ -3352,6 +3537,19 @@
         testapp6
     }
 
+    def nonModSrcSets = [
+        sourceSets.test,
+        sourceSets.testapp1
+    ]
+
+    def modSrcSets = [
+        sourceSets.testapp2,
+        sourceSets.testapp3,
+        sourceSets.testapp4,
+        sourceSets.testapp5,
+        sourceSets.testapp6
+    ]
+
     project.ext.buildModule = false
     project.ext.moduleRuntime = false
     project.ext.moduleName = "systemTests"
@@ -3537,6 +3735,8 @@
 
         forkEvery = 1
     }
+
+    addValidateSourceSets(project, nonModSrcSets, modSrcSets)
 }
 
 allprojects {
--- a/build.properties	Tue Apr 02 09:58:07 2019 -0700
+++ b/build.properties	Mon Apr 15 11:15:07 2019 -0700
@@ -72,6 +72,9 @@
 #
 ##############################################################################
 
+# JDK
+jfx.build.jdk.version=12
+jfx.build.jdk.buildnum=33
 jfx.build.jdk.version.min=11
 jfx.build.jdk.buildnum.min=28
 
@@ -83,3 +86,13 @@
 # that is supported. It must be <= jfx.gradle.version.
 jfx.gradle.version=5.3
 jfx.gradle.version.min=4.8
+
+# Toolchains
+jfx.build.linux.gcc.version=gcc7.3.0-OEL6.4+1.1
+jfx.build.windows.msvc.version=VS2017-15.5.5+1.1
+jfx.build.macosx.xcode.version=Xcode9.4-MacOSX10.13+1.0
+
+# Build tools
+jfx.build.cmake.version=3.13.3
+jfx.build.ninja.version=1.8.2
+jfx.build.ant.version=1.10.5
--- a/modules/javafx.controls/src/main/java/javafx/scene/control/Dialog.java	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.controls/src/main/java/javafx/scene/control/Dialog.java	Mon Apr 15 11:15:07 2019 -0700
@@ -249,7 +249,7 @@
      *
      **************************************************************************/
 
-     FXDialog dialog;
+    final FXDialog dialog;
 
     private boolean isClosing;
 
--- a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/AccordionSkin.java	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/AccordionSkin.java	Mon Apr 15 11:15:07 2019 -0700
@@ -105,6 +105,9 @@
             if (!control.getPanes().isEmpty()) {
                 firstTitledPane = control.getPanes().get(0);
                 firstTitledPane.getStyleClass().add("first-titled-pane");
+            } else {
+                // Sever previously stored reference to the first pane, so that it may be collected.
+                firstTitledPane = null;
             }
             // TODO there may be a more efficient way to keep these in sync
             getChildren().setAll(control.getPanes());
--- a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c	Mon Apr 15 11:15:07 2019 -0700
@@ -1995,8 +1995,9 @@
 
 
   clear_scan_context (&context);
+
+  changed |= context.changed;
 #endif // GSTREAMER_LITE
-  changed |= context.changed;
 
   /* Remove cached plugins so stale info is cleared. */
   changed |= gst_registry_remove_cache_plugins (default_registry);
--- a/modules/javafx.media/src/main/native/gstreamer/plugins/avcdecoder/avcdecoder.c	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/plugins/avcdecoder/avcdecoder.c	Mon Apr 15 11:15:07 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -324,13 +324,20 @@
         size_t bytes_per_row = CVPixelBufferGetBytesPerRow(imageBuffer);
         if(!decode->is_stride_set)
         {
-            GstCaps *caps = gst_pad_get_current_caps(srcpad);
-            if (caps != NULL)
+            GstCaps *pad_caps = gst_pad_get_current_caps(srcpad);
+            if (pad_caps != NULL)
             {
-                GstStructure* caps_struct = gst_caps_get_structure(caps, 0);
-                gst_structure_set(caps_struct, "line_stride", G_TYPE_INT, (int)bytes_per_row, NULL);
-                decode->is_stride_set = TRUE;
-                gst_caps_unref(caps);
+                GstCaps *caps = gst_caps_copy(pad_caps);
+                if (caps != NULL)
+                {
+                    gst_caps_set_simple(caps, "line_stride", G_TYPE_INT, (int)bytes_per_row, NULL);
+                    GstEvent *caps_event = gst_event_new_caps(caps);
+                    if (caps_event != NULL)
+                        gst_pad_push_event(decode->srcpad, caps_event);
+                    decode->is_stride_set = TRUE;
+                    gst_caps_unref(caps);
+                }
+                gst_caps_unref(pad_caps);
             }
         }
         if (kCVReturnSuccess == CVPixelBufferLockBaseAddress (imageBuffer, 0))
--- a/modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/Sink.cpp	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/Sink.cpp	Mon Apr 15 11:15:07 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
     m_pIAlloc = NULL;
     m_pAlloc = NULL;
     m_bUseExternalAllocator = false;
+    m_bEnableDynamicFormatChanges = false;
 }
 
 CInputPin::~CInputPin()
@@ -152,6 +153,70 @@
     return S_OK;
 }
 
+HRESULT CInputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt)
+{
+    HRESULT hr = CBasePin::ReceiveConnection(pConnector, pmt);
+    if (m_bEnableDynamicFormatChanges && hr == VFW_E_ALREADY_CONNECTED)
+    {
+        CAutoLock cObjectLock(m_pLock);
+
+        CMediaType *pcmt = (CMediaType*)pmt;
+        hr = CheckMediaType(pcmt);
+        if (hr == S_OK)
+        {
+            if (m_Connected != pConnector)
+            {
+                if (m_Connected != NULL)
+                {
+                    m_Connected->Release();
+                }
+                m_Connected = pConnector;
+                m_Connected->AddRef();
+            }
+
+            hr = SetMediaType(pcmt);
+            if (SUCCEEDED(hr))
+            {
+                if (IsEqualGUID(FORMAT_VideoInfo2, pcmt->formattype))
+                {
+                    VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2*)pcmt->pbFormat;
+                    DWORD dwSize = vih2->bmiHeader.biSizeImage;
+                    if (dwSize > 0)
+                    {
+                        IMemAllocator *pAllocator = NULL;
+                        hr = GetAllocator(&pAllocator);
+                        if (SUCCEEDED(hr))
+                        {
+                            ALLOCATOR_PROPERTIES request;
+                            ZeroMemory(&request, sizeof(ALLOCATOR_PROPERTIES));
+                            hr = pAllocator->GetProperties(&request);
+                            if (SUCCEEDED(hr))
+                            {
+                                request.cbBuffer = dwSize;
+                                hr = pAllocator->Decommit();
+                                if (SUCCEEDED(hr))
+                                {
+                                    ALLOCATOR_PROPERTIES actual;
+                                    ZeroMemory(&actual, sizeof(ALLOCATOR_PROPERTIES));
+                                    hr = pAllocator->SetProperties(&request, &actual);
+                                    if (SUCCEEDED(hr))
+                                    {
+                                        hr = pAllocator->Commit();
+                                    }
+                                }
+                            }
+
+                            pAllocator->Release();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    return hr;
+}
+
 CSink::CSink(HRESULT *phr) : CBaseRenderer(CLSID_Sink, "CSink", NULL, phr)
 {
     ZeroMemory(&m_UserData, sizeof(sUserData));
@@ -163,6 +228,7 @@
 
     m_bForceStereoOutput = false;
     m_bUseExternalAllocator = false;
+    m_bEnableDynamicFormatChanges = false;
 
     m_bEOSInProgress = false;
     m_bWorkerThreadExits = false;
@@ -276,10 +342,14 @@
 
                 if (SinkEventCallback != NULL)
                 {
-                    __int64 width = hdrout->rcSource.right;
-                    __int64 height = hdrout->rcSource.bottom;
-                    __int64 resolution = (width << 32) | height;
-                    SinkEventCallback(SINK_VIDEO_RESOLUTION, (void*)&resolution, sizeof(__int64), &m_UserData);
+                    sVideoResolutionEvent resolution;
+                    resolution.width = hdrout->rcSource.right;
+                    resolution.height = hdrout->rcSource.bottom;
+                    if (m_bEnableDynamicFormatChanges)
+                        resolution.offset = resolution.width;
+                    else
+                        resolution.offset = 1920;
+                    SinkEventCallback(SINK_VIDEO_RESOLUTION, (void*)&resolution, sizeof(sVideoResolutionEvent), &m_UserData);
                 }
             }
 
@@ -477,6 +547,7 @@
         }
 
         ((CInputPin*)m_pInputPin)->m_bUseExternalAllocator = m_bUseExternalAllocator;
+        ((CInputPin*)m_pInputPin)->m_bEnableDynamicFormatChanges = m_bEnableDynamicFormatChanges;
     }
 
     return m_pInputPin;
@@ -531,6 +602,9 @@
     m_bUseExternalAllocator = (pOutputFormat->bUseExternalAllocator != 0);
     if (m_pInputPin)
         ((CInputPin*)m_pInputPin)->m_bUseExternalAllocator = m_bUseExternalAllocator;
+    m_bEnableDynamicFormatChanges = (pOutputFormat->bEnableDynamicFormatChanges != 0);
+    if (m_pInputPin)
+        ((CInputPin*)m_pInputPin)->m_bEnableDynamicFormatChanges = m_bEnableDynamicFormatChanges;
 
     return S_OK;
 }
--- a/modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/Sink.h	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/Sink.h	Mon Apr 15 11:15:07 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,14 @@
     ULONG length;
     BOOL bForceStereoOutput;
     BOOL bUseExternalAllocator;
+    BOOL bEnableDynamicFormatChanges;
+};
+
+struct sVideoResolutionEvent
+{
+    int width;
+    int height;
+    int offset;
 };
 
 enum SINK_EVENTS
@@ -79,9 +87,11 @@
     HRESULT SetReleaseSampleCallback(void (*function)(GstBuffer *pBuffer, sUserData *pUserData));
     HRESULT SetGetGstBufferCallback(void (*function)(GstBuffer **ppBuffer, long lSize, sUserData *pUserData));
     HRESULT CreateAllocator();
+    STDMETHODIMP ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt);
 
 public:
     bool m_bUseExternalAllocator;
+    bool m_bEnableDynamicFormatChanges;
 
 private:
     CAllocator *m_pAlloc;
@@ -130,6 +140,7 @@
 
     bool m_bForceStereoOutput;
     bool m_bUseExternalAllocator;
+    bool m_bEnableDynamicFormatChanges;
 
     bool m_bEOSInProgress;
     bool m_bWorkerThreadExits;
--- a/modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/dshowwrapper.cpp	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/dshowwrapper.cpp	Mon Apr 15 11:15:07 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -754,43 +754,43 @@
             if (decoder->eOutputFormat[pUserData->output_index] == MEDIA_FORMAT_VIDEO_H264)
             {
                 if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                    g_print("AMDEBUG MP2T H264 %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
+                    g_print("JFXMEDIA MP2T H264 %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
                 else if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && !GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                    g_print("AMDEBUG MP2T H264 %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
+                    g_print("DEBUG MP2T H264 %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
                 else
-                    g_print("AMDEBUG MP2T H264 -1\n");
+                    g_print("JFXMEDIA MP2T H264 -1\n");
             }
             if (decoder->eOutputFormat[pUserData->output_index] == MEDIA_FORMAT_AUDIO_AAC)
             {
                 if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                    g_print("AMDEBUG MP2T AAC  %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
+                    g_print("JFXMEDIA MP2T AAC  %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
                 else if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && !GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                    g_print("AMDEBUG MP2T AAC  %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
+                    g_print("JFXMEDIA MP2T AAC  %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
                 else
-                    g_print("AMDEBUG MP2T AAC  -1\n");
+                    g_print("JFXMEDIA MP2T AAC  -1\n");
             }
         }
 #endif
 #if H264_PTS_DEBUG
-        if (decoder->eInputFormat == MEDIA_FORMAT_VIDEO_H264)
+        if (decoder->eInputFormat == MEDIA_FORMAT_VIDEO_H264 || decoder->eInputFormat == MEDIA_FORMAT_VIDEO_AVC1)
         {
             if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                g_print("AMDEBUG H264 %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
+                g_print("JFXMEDIA H264 %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
             else if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && !GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                g_print("AMDEBUG H264 %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
+                g_print("JFXMEDIA H264 %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
             else
-                g_print("AMDEBUG H264 -1\n");
+                g_print("JFXMEDIA H264 -1\n");
         }
 #endif
 #if AAC_PTS_DEBUG
         if (decoder->eInputFormat == MEDIA_FORMAT_AUDIO_AAC)
         {
             if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                g_print("AMDEBUG AAC  %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
+                g_print("JFXMEDIA AAC  %I64u %I64u\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]), GST_BUFFER_DURATION(decoder->out_buffer[pUserData->output_index]));
             else if (GST_BUFFER_TIMESTAMP_IS_VALID(decoder->out_buffer[pUserData->output_index]) && !GST_BUFFER_DURATION_IS_VALID(decoder->out_buffer[pUserData->output_index]))
-                g_print("AMDEBUG AAC  %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
+                g_print("JFXMEDIA AAC  %I64u -1\n", GST_BUFFER_TIMESTAMP(decoder->out_buffer[pUserData->output_index]));
             else
-                g_print("AMDEBUG AAC  -1\n");
+                g_print("JFXMEDIA AAC  -1\n");
         }
 #endif
 
@@ -875,13 +875,13 @@
         decoder->is_eos[pUserData->output_index] = TRUE;
 #if EOS_DEBUG
         if (decoder->eInputFormat == MEDIA_FORMAT_STREAM_MP2T && (decoder->eOutputFormat[pUserData->output_index] == MEDIA_FORMAT_VIDEO_AVC1 || decoder->eOutputFormat[pUserData->output_index] == MEDIA_FORMAT_VIDEO_H264))
-            g_print("AMDEBUG EOS MP2T H264\n");
+            g_print("JFXMEDIA EOS MP2T H264\n");
         else if (decoder->eInputFormat == MEDIA_FORMAT_STREAM_MP2T && decoder->eOutputFormat[pUserData->output_index] == MEDIA_FORMAT_AUDIO_AAC)
-            g_print("AMDEBUG EOS MP2T AAC\n");
+            g_print("JFXMEDIA EOS MP2T AAC\n");
         else if (decoder->eInputFormat == MEDIA_FORMAT_VIDEO_AVC1 || decoder->eInputFormat == MEDIA_FORMAT_VIDEO_H264)
-            g_print("AMDEBUG EOS H264\n");
+            g_print("JFXMEDIA EOS H264\n");
         else if (decoder->eInputFormat == MEDIA_FORMAT_AUDIO_AAC)
-            g_print("AMDEBUG EOS AAC\n");
+            g_print("JFXMEDIA EOS AAC\n");
 #endif
         gst_pad_push_event (decoder->srcpad[pUserData->output_index], gst_event_new_eos());
         break;
@@ -947,11 +947,12 @@
         }
         break;
     case SINK_VIDEO_RESOLUTION:
-        if (pData != NULL && size == sizeof(__int64))
+        if (pData != NULL && size == sizeof(sVideoResolutionEvent))
         {
-            __int64 resolution = *((__int64*)pData);
-            int width = (resolution >> 32) & 0x00000000FFFFFFFF;
-            int height = resolution & 0x00000000FFFFFFFF;
+            sVideoResolutionEvent resolution = *((sVideoResolutionEvent*)pData);
+            int width = resolution.width;
+            int height = resolution.height;
+            int offset = resolution.offset;
 
             GstCaps *padCaps = gst_pad_get_current_caps(decoder->srcpad[pUserData->output_index]);
             if (padCaps == NULL)
@@ -966,11 +967,11 @@
                     "width", G_TYPE_INT, width,
                     "height", G_TYPE_INT, height,
                     "offset-y", G_TYPE_INT, 0,
-                    "offset-v", G_TYPE_INT, (1920*height+((1920*height)/4)),
-                    "offset-u", G_TYPE_INT, 1920*height,
-                    "stride-y", G_TYPE_INT, 1920,
-                    "stride-v", G_TYPE_INT, 1920/2,
-                    "stride-u", G_TYPE_INT, 1920/2,
+                    "offset-v", G_TYPE_INT, (offset*height+((offset*height)/4)),
+                    "offset-u", G_TYPE_INT, offset*height,
+                    "stride-y", G_TYPE_INT, offset,
+                    "stride-v", G_TYPE_INT, offset/2,
+                    "stride-u", G_TYPE_INT, offset/2,
                     NULL);
             }
             else if (decoder->eOutputFormat[DEFAULT_OUTPUT_DS_STREAM_INDEX] == MEDIA_FORMAT_VIDEO_YV12)
@@ -1944,6 +1945,10 @@
     sInputFormat inputFormat;
     ZeroMemory(&inputFormat, sizeof(sInputFormat));
 
+    // Init output
+    sOutputFormat outputFormat;
+    ZeroMemory(&outputFormat, sizeof(sOutputFormat));
+
     gint width = 0;
     gint height = 0;
     const GValue *v = NULL;
@@ -2022,6 +2027,15 @@
         pbFormat->dwFlags = lengthSizeMinusOne + 1;
         memcpy(pbFormat->dwSequenceHeader, header, header_size);
         pbFormat->cbSequenceHeader = header_size;
+
+        // Enable dynamic format change for MP4 via ReceiveConnection().
+        // HLS works fine using QueryAccept without buffer size changes and
+        // breaks if dynamic format is enabled, so for now we will use it only
+        // for MP4. It seems we only need it for portrait video or anything
+        // bigger then 1920x1080, so we will enable it only for such resolution.
+        // See JDK-8133841.
+        if ((width < height) || (width > 1920 && height > 1080))
+            outputFormat.bEnableDynamicFormatChanges = 1;
     }
     else
     {
@@ -2060,10 +2074,6 @@
     if (!dshowwrapper_create_ds_source(decoder, &inputFormat))
         goto exit;
 
-    // Init output
-    sOutputFormat outputFormat;
-    ZeroMemory(&outputFormat, sizeof(sOutputFormat));
-
     gint framerate_num = 0;
     gint framerate_den = 0;
 
--- a/modules/javafx.web/src/main/java/com/sun/javafx/webkit/prism/WCFontImpl.java	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.web/src/main/java/com/sun/javafx/webkit/prism/WCFontImpl.java	Mon Apr 15 11:15:07 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,19 +32,19 @@
 import com.sun.javafx.font.PGFont;
 import com.sun.javafx.geom.BaseBounds;
 import com.sun.javafx.geom.transform.BaseTransform;
+import com.sun.javafx.logging.PlatformLogger.Level;
 import com.sun.javafx.logging.PlatformLogger;
-import com.sun.javafx.logging.PlatformLogger.Level;
 import com.sun.javafx.scene.text.GlyphList;
 import com.sun.javafx.scene.text.TextLayout;
 import com.sun.javafx.text.TextRun;
-import static com.sun.javafx.webkit.prism.TextUtilities.getLayoutWidth;
-import static com.sun.javafx.webkit.prism.TextUtilities.getLayoutBounds;
+import com.sun.javafx.webkit.prism.WCTextRunImpl;
 import com.sun.prism.GraphicsPipeline;
 import com.sun.webkit.graphics.WCFont;
 import com.sun.webkit.graphics.WCTextRun;
-import com.sun.webkit.graphics.WCTextRunImpl;
 import java.util.Arrays;
 import java.util.HashMap;
+import static com.sun.javafx.webkit.prism.TextUtilities.getLayoutBounds;
+import static com.sun.javafx.webkit.prism.TextUtilities.getLayoutWidth;
 
 final class WCFontImpl extends WCFont {
     private final static PlatformLogger log =
--- a/modules/javafx.web/src/main/java/com/sun/javafx/webkit/prism/WCTextRunImpl.java	Tue Apr 02 09:58:07 2019 -0700
+++ b/modules/javafx.web/src/main/java/com/sun/javafx/webkit/prism/WCTextRunImpl.java	Mon Apr 15 11:15:07 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,11 @@
  * questions.
  */
 
-package com.sun.webkit.graphics;
+package com.sun.javafx.webkit.prism;
 
 import com.sun.javafx.scene.text.GlyphList;
 import com.sun.javafx.text.TextRun;
+import com.sun.webkit.graphics.WCTextRun;
 
 public final class WCTextRunImpl implements WCTextRun {
     private final TextRun run;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/system/src/test/java/test/javafx/scene/control/AccordionTitlePaneLeakTest.java	Mon Apr 15 11:15:07 2019 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.javafx.scene.control;
+
+import javafx.application.Application;
+import javafx.application.Platform;
+import javafx.scene.Scene;
+import javafx.scene.control.Accordion;
+import javafx.scene.control.TitledPane;
+import javafx.scene.layout.StackPane;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+
+import test.util.Util;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import junit.framework.Assert;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AccordionTitlePaneLeakTest extends Application {
+
+    static private CountDownLatch startupLatch;
+    static private Accordion accordion;
+    static private StackPane root;
+    static private Stage stage;
+
+    @Override
+    public void start(Stage primaryStage) throws Exception {
+        stage = primaryStage;
+        accordion = new Accordion();
+        root = new StackPane(accordion);
+        stage.setScene(new Scene(root));
+        stage.addEventHandler(WindowEvent.WINDOW_SHOWN, e -> {
+            Platform.runLater(() -> startupLatch.countDown());
+        });
+        stage.show();
+    }
+
+    @BeforeClass
+    public static void initFX() {
+        startupLatch = new CountDownLatch(1);
+        new Thread(() -> Application.launch(AccordionTitlePaneLeakTest.class, (String[]) null)).start();
+
+        try {
+            if (!startupLatch.await(15, TimeUnit.SECONDS)) {
+                Assert.fail("Timeout waiting for FX runtime to start");
+            }
+        } catch (InterruptedException ex) {
+            Assert.fail("Unexpected exception: " + ex);
+        }
+    }
+
+    @Test
+    public void testForTitledPaneLeak() throws Exception {
+        TitledPane pane = new TitledPane();
+        accordion.getPanes().add(pane);
+        WeakReference<TitledPane> weakRefToPane = new WeakReference<>(pane);
+        pane = null;
+        accordion.getPanes().clear();
+        for (int i = 0; i < 10; i++) {
+            System.gc();
+            System.runFinalization();
+            if (weakRefToPane.get() == null) {
+                break;
+            }
+            Util.sleep(500);
+        }
+        // Ensure accordion's skin no longer hold a ref to titled pane.
+        Assert.assertNull("Couldn't collect TitledPane", weakRefToPane.get());
+    }
+
+    @AfterClass
+    public static void teardownOnce() {
+        Platform.runLater(() -> {
+            stage.hide();
+            Platform.exit();
+        });
+    }
+}