Only terminate egl display once
Only terminate egl display once

Unblocks angle roller into skia that was triggering an assert in
EGLImageTest. In that test, there were two egl contexts created that
shared the same egl display. The child context was destroyed first,
and ANGLEGLContext's destroyGLContext() implementation always called
eglTerminate on the display. According to the egl spec you're not
supposed to do anything with the terminated display other than call
makeCurrent() to release any active context.

In this case, the child context's termination would cause the display
to be deferred until the parent context was destroyed. This triggered
a bug in ANGLE's D3D backend, leading to the assert. However, with
that fixed, we then trigger critical error messages about calling
eglDestroySurface, etc. in the parent context's destroyGLContext()
function since the display was terminated out from beneath it.

This change adds a rudimentary ownership tracking mechanism to the
ANGLEGLContext so that when a child context is cleaned up it won't
call eglTerminate on its display. This happens to avoid the bug in
ANGLE's D3D backend as well as silencing the critical warnings if it
were fixed.

Bug: skia:12413
Change-Id: I31f64189315a1921adbee204d11138272d4b40af
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446182
Commit-Queue: Robert Phillips <95e8ac5504948c7bf91b22c16a8dbb7ae7c66bfd@google.com>
Auto-Submit: Michael Ludwig <cb1f3dd24de0f0b611b26bc28bec758a551d9b7d@google.com>
Reviewed-by: Robert Phillips <95e8ac5504948c7bf91b22c16a8dbb7ae7c66bfd@google.com>

aosp-mirror/platform_external_skia,aosp-mirror/platform_external_skia,aosp-mirror/platform_external_skia,google/skia,google/skia,google/skia,google/skia,google/skia,google/skia,aosp-mirror/platform_external_skia,aosp-mirror/platform_external_skia,aosp-mirror/platform_external_skia,google/skia,google/skia,aosp-mirror/platform_external_skia,google/skia,google/skia,aosp-mirror/platform_external_skia,aosp-mirror/platform_external_skia,aosp-mirror/platform_external_skia