EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { thread->setError(EglBadSurface()); return EGL_FALSE; } error = display->destroySurface(reinterpret_cast<Surface *>(surface)); if (error.isError()) { thread->setError(error); return EGL_FALSE; } thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } display->destroySurface((Surface*)surface); SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = " "0x%0.8p)", dpy, surface, target); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (display->testDeviceLost()) { thread->setError(EglContextLost()); return EGL_FALSE; } UNIMPLEMENTED(); // FIXME thread->setError(NoError()); return 0; }
EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = 0x%0.8p)", dpy, surface, target); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } UNIMPLEMENTED(); // FIXME SetGlobalError(Error(EGL_SUCCESS)); return 0; }
// EGL 1.1 EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle()) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } if (eglSurface->getBoundTexture()) { SetGlobalError(Error(EGL_BAD_ACCESS)); return EGL_FALSE; } if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } gl::Context *context = GetGlobalContext(); if (context) { gl::Texture *textureObject = context->getTargetTexture(GL_TEXTURE_2D); ASSERT(textureObject != NULL); if (textureObject->isImmutable()) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } eglSurface->bindTexImage(textureObject, buffer); } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
// EGL_NV_post_sub_buffer EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint x = %d, EGLint y = %d, EGLint width = %d, EGLint height = %d)", dpy, surface, x, y, width, height); if (x < 0 || y < 0 || width < 0 || height < 0) { SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } #if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (defined(ANGLE_ENABLE_WINDOWS_STORE) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Qt WP: Allow this entry point as a workaround if (!display->getExtensions().postSubBuffer) { // Spec is not clear about how this should be handled. SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } #endif error = eglSurface->postSubBuffer(x, y, width, height); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { thread->setError(EglBadParameter()); return EGL_FALSE; } if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT) { thread->setError(EglBadSurface()); return EGL_FALSE; } if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) { thread->setError(EglBadMatch()); return EGL_FALSE; } gl::Texture *texture = eglSurface->getBoundTexture(); if (texture) { error = eglSurface->releaseTexImage(thread->getContext(), buffer); if (error.isError()) { thread->setError(error); return EGL_FALSE; } } thread->setError(NoError()); return EGL_TRUE; }
// EGL_NV_post_sub_buffer EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint x = %d, EGLint y = %d, EGLint width = %d, EGLint height = %d)", dpy, surface, x, y, width, height); if (x < 0 || y < 0 || width < 0 || height < 0) { SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } if (!display->getExtensions().postSubBuffer) { // Spec is not clear about how this should be handled. SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; } error = eglSurface->postSubBuffer(x, y, width, height); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
// EGL_ANGLE_query_surface_pointer EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)", dpy, surface, attribute, value); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (!display->getExtensions().querySurfacePointer) { SetGlobalError(Error(EGL_SUCCESS)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } // validate the attribute parameter switch (attribute) { case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE: if (!display->getExtensions().surfaceD3DTexture2DShareHandle) { SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } break; default: SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } error = eglSurface->querySurfacePointerANGLE(attribute, value); SetGlobalError(error); return (error.isError() ? EGL_FALSE : EGL_TRUE); }
EGLBoolean EGLAPIENTRY ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { SetGlobalError(Error(EGL_BAD_PARAMETER)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } gl::Texture *texture = eglSurface->getBoundTexture(); if (texture) { error = eglSurface->releaseTexImage(buffer); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = (Surface *)surface; Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (display->testDeviceLost()) { thread->setError(EglContextLost()); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { thread->setError(EglBadSurface()); return EGL_FALSE; } if (!thread->getContext() || thread->getCurrentDrawSurface() != eglSurface) { thread->setError(EglBadSurface()); return EGL_FALSE; } error = eglSurface->swap(thread->getContext()); if (error.isError()) { thread->setError(error); return EGL_FALSE; } thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint value = %d)", dpy, surface, attribute, value); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = static_cast<Surface*>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } UNIMPLEMENTED(); // FIXME SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY SwapBuffers(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = (Surface*)surface; Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } error = eglSurface->swap(); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
mitk::Surface::Pointer mitk::ACVD::Remesh(mitk::Surface::ConstPointer surface, unsigned int t, int numVertices, double gradation, int subsampling, double edgeSplitting, int optimizationLevel, bool forceManifold, bool boundaryFixing) { ValidateSurface(surface, t); MITK_INFO << "Start remeshing..."; vtkSmartPointer<vtkPolyData> surfacePolyData = vtkSmartPointer<vtkPolyData>::New(); surfacePolyData->DeepCopy(const_cast<Surface*>(surface.GetPointer())->GetVtkPolyData(t)); vtkSmartPointer<vtkSurface> mesh = vtkSmartPointer<vtkSurface>::New(); mesh->CreateFromPolyData(surfacePolyData); mesh->GetCellData()->Initialize(); mesh->GetPointData()->Initialize(); mesh->DisplayMeshProperties(); if (numVertices == 0) numVertices = surfacePolyData->GetNumberOfPoints(); if (edgeSplitting != 0.0) mesh->SplitLongEdges(edgeSplitting); vtkSmartPointer<vtkIsotropicDiscreteRemeshing> remesher = vtkSmartPointer<vtkIsotropicDiscreteRemeshing>::New(); remesher->GetMetric()->SetGradation(gradation); remesher->SetBoundaryFixing(boundaryFixing); remesher->SetConsoleOutput(1); remesher->SetForceManifold(forceManifold); remesher->SetInput(mesh); remesher->SetNumberOfClusters(numVertices); remesher->SetNumberOfThreads(vtkMultiThreader::GetGlobalDefaultNumberOfThreads()); remesher->SetSubsamplingThreshold(subsampling); remesher->Remesh(); // Optimization: Minimize distance between input surface and remeshed surface if (optimizationLevel != 0) { ClustersQuadrics clustersQuadrics(numVertices); vtkSmartPointer<vtkIdList> faceList = vtkSmartPointer<vtkIdList>::New(); vtkSmartPointer<vtkIntArray> clustering = remesher->GetClustering(); vtkSmartPointer<vtkSurface> remesherInput = remesher->GetInput(); int clusteringType = remesher->GetClusteringType(); int numItems = remesher->GetNumberOfItems(); int numMisclassifiedItems = 0; for (int i = 0; i < numItems; ++i) { int cluster = clustering->GetValue(i); if (cluster >= 0 && cluster < numVertices) { if (clusteringType != 0) { remesherInput->GetVertexNeighbourFaces(i, faceList); int numIds = static_cast<int>(faceList->GetNumberOfIds()); for (int j = 0; j < numIds; ++j) vtkQuadricTools::AddTriangleQuadric(clustersQuadrics.Elements[cluster], remesherInput, faceList->GetId(j), false); } else { vtkQuadricTools::AddTriangleQuadric(clustersQuadrics.Elements[cluster], remesherInput, i, false); } } else { ++numMisclassifiedItems; } } if (numMisclassifiedItems != 0) std::cout << numMisclassifiedItems << " items with wrong cluster association" << std::endl; vtkSmartPointer<vtkSurface> remesherOutput = remesher->GetOutput(); double point[3]; for (int i = 0; i < numVertices; ++i) { remesherOutput->GetPoint(i, point); vtkQuadricTools::ComputeRepresentativePoint(clustersQuadrics.Elements[i], point, optimizationLevel); remesherOutput->SetPointCoordinates(i, point); } std::cout << "After quadrics post-processing:" << std::endl; remesherOutput->DisplayMeshProperties(); } vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New(); normals->SetInputData(remesher->GetOutput()); normals->AutoOrientNormalsOn(); normals->ComputeCellNormalsOff(); normals->ComputePointNormalsOn(); normals->ConsistencyOff(); normals->FlipNormalsOff(); normals->NonManifoldTraversalOff(); normals->SplittingOff(); normals->Update(); Surface::Pointer remeshedSurface = Surface::New(); remeshedSurface->SetVtkPolyData(normals->GetOutput()); MITK_INFO << "Finished remeshing"; return remeshedSurface; }
EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, draw, read, ctx); Display *display = static_cast<Display*>(dpy); gl::Context *context = static_cast<gl::Context*>(ctx); // If ctx is EGL_NO_CONTEXT and either draw or read are not EGL_NO_SURFACE, an EGL_BAD_MATCH // error is generated. if (ctx == EGL_NO_CONTEXT && (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } if (ctx != EGL_NO_CONTEXT && draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } // If either of draw or read is a valid surface and the other is EGL_NO_SURFACE, an // EGL_BAD_MATCH error is generated. if ((read == EGL_NO_SURFACE) != (draw == EGL_NO_SURFACE)) { SetGlobalError(Error( EGL_BAD_MATCH, "read and draw must both be valid surfaces, or both be EGL_NO_SURFACE")); return EGL_FALSE; } if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display)) { SetGlobalError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle")); return EGL_FALSE; } // EGL 1.5 spec: dpy can be uninitialized if all other parameters are null if (!display->isInitialized() && (ctx != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)) { SetGlobalError(Error(EGL_NOT_INITIALIZED, "'dpy' not initialized")); return EGL_FALSE; } if (ctx != EGL_NO_CONTEXT) { Error error = ValidateContext(display, context); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } if (display->isInitialized()) { if (display->testDeviceLost()) { display->notifyDeviceLost(); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } } Surface *drawSurface = static_cast<Surface*>(draw); if (draw != EGL_NO_SURFACE) { Error error = ValidateSurface(display, drawSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } Surface *readSurface = static_cast<Surface*>(read); if (read != EGL_NO_SURFACE) { Error error = ValidateSurface(display, readSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } if (readSurface) { Error readCompatError = ValidateCompatibleConfigs(readSurface->getConfig(), context->getConfig(), readSurface->getType()); if (readCompatError.isError()) { SetGlobalError(readCompatError); return EGL_FALSE; } } if (draw != read) { UNIMPLEMENTED(); // FIXME if (drawSurface) { Error drawCompatError = ValidateCompatibleConfigs(drawSurface->getConfig(), context->getConfig(), drawSurface->getType()); if (drawCompatError.isError()) { SetGlobalError(drawCompatError); return EGL_FALSE; } } } Error makeCurrentError = display->makeCurrent(drawSurface, readSurface, context); if (makeCurrentError.isError()) { SetGlobalError(makeCurrentError); return EGL_FALSE; } gl::Context *previousContext = GetGlobalContext(); SetGlobalDisplay(display); SetGlobalDrawSurface(drawSurface); SetGlobalReadSurface(readSurface); SetGlobalContext(context); // Release the surface from the previously-current context, to allow // destroyed surfaces to delete themselves. if (previousContext != nullptr && context != previousContext) { previousContext->releaseSurface(); } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", dpy, surface, attribute, value); Display *display = static_cast<Display*>(dpy); Surface *eglSurface = (Surface*)surface; Error error = ValidateSurface(display, eglSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { SetGlobalError(Error(EGL_BAD_SURFACE)); return EGL_FALSE; } switch (attribute) { case EGL_VG_ALPHA_FORMAT: UNIMPLEMENTED(); // FIXME break; case EGL_VG_COLORSPACE: UNIMPLEMENTED(); // FIXME break; case EGL_CONFIG_ID: *value = eglSurface->getConfig()->configID; break; case EGL_HEIGHT: *value = eglSurface->getHeight(); break; case EGL_HORIZONTAL_RESOLUTION: UNIMPLEMENTED(); // FIXME break; case EGL_LARGEST_PBUFFER: UNIMPLEMENTED(); // FIXME break; case EGL_MIPMAP_TEXTURE: UNIMPLEMENTED(); // FIXME break; case EGL_MIPMAP_LEVEL: UNIMPLEMENTED(); // FIXME break; case EGL_MULTISAMPLE_RESOLVE: UNIMPLEMENTED(); // FIXME break; case EGL_PIXEL_ASPECT_RATIO: *value = eglSurface->getPixelAspectRatio(); break; case EGL_RENDER_BUFFER: *value = eglSurface->getRenderBuffer(); break; case EGL_SWAP_BEHAVIOR: *value = eglSurface->getSwapBehavior(); break; case EGL_TEXTURE_FORMAT: *value = eglSurface->getTextureFormat(); break; case EGL_TEXTURE_TARGET: *value = eglSurface->getTextureTarget(); break; case EGL_VERTICAL_RESOLUTION: UNIMPLEMENTED(); // FIXME break; case EGL_WIDTH: *value = eglSurface->getWidth(); break; case EGL_POST_SUB_BUFFER_SUPPORTED_NV: if (!display->getExtensions().postSubBuffer) { SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } *value = eglSurface->isPostSubBufferSupported(); break; case EGL_FIXED_SIZE_ANGLE: if (!display->getExtensions().windowFixedSize) { SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } *value = eglSurface->isFixedSize(); break; default: SetGlobalError(Error(EGL_BAD_ATTRIBUTE)); return EGL_FALSE; } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
// EGL 1.1 EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { thread->setError(EglBadParameter()); return EGL_FALSE; } if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT) { thread->setError(EglBadSurface()); return EGL_FALSE; } if (eglSurface->getBoundTexture()) { thread->setError(EglBadAccess()); return EGL_FALSE; } if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) { thread->setError(EglBadMatch()); return EGL_FALSE; } gl::Context *context = thread->getContext(); if (context) { gl::Texture *textureObject = context->getTargetTexture(GL_TEXTURE_2D); ASSERT(textureObject != nullptr); if (textureObject->getImmutableFormat()) { thread->setError(EglBadMatch()); return EGL_FALSE; } error = eglSurface->bindTexImage(context, textureObject, buffer); if (error.isError()) { thread->setError(error); return EGL_FALSE; } } thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, draw, read, ctx); Display *display = static_cast<Display*>(dpy); gl::Context *context = static_cast<gl::Context*>(ctx); bool noContext = (ctx == EGL_NO_CONTEXT); bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE); if (noContext != noSurface) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } if (dpy == EGL_NO_DISPLAY) { SetGlobalError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle")); return EGL_FALSE; } // EGL 1.5 spec: dpy can be uninitialized if all other parameters are null if (dpy != EGL_NO_DISPLAY && !display->isInitialized() && (ctx != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE)) { SetGlobalError(Error(EGL_NOT_INITIALIZED, "'dpy' not initialized")); return EGL_FALSE; } if (ctx != EGL_NO_CONTEXT) { Error error = ValidateContext(display, context); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } if (dpy != EGL_NO_DISPLAY && display->isInitialized()) { if (display->testDeviceLost()) { display->notifyDeviceLost(); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } } Surface *drawSurface = static_cast<Surface*>(draw); if (draw != EGL_NO_SURFACE) { Error error = ValidateSurface(display, drawSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } Surface *readSurface = static_cast<Surface*>(read); if (read != EGL_NO_SURFACE) { Error error = ValidateSurface(display, readSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } if (draw != read) { UNIMPLEMENTED(); // FIXME } gl::Context *previousContext = GetGlobalContext(); SetGlobalDisplay(display); SetGlobalDrawSurface(drawSurface); SetGlobalReadSurface(readSurface); SetGlobalContext(context); display->makeCurrent(drawSurface, readSurface, context); // Release the surface from the previously-current context, to allow // destroyed surfaces to delete themselves. if (previousContext != nullptr && context != previousContext) { previousContext->releaseSurface(); } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, draw, read, ctx); Display *display = static_cast<Display*>(dpy); gl::Context *context = static_cast<gl::Context*>(ctx); bool noContext = (ctx == EGL_NO_CONTEXT); bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE); if (noContext != noSurface) { SetGlobalError(Error(EGL_BAD_MATCH)); return EGL_FALSE; } if (ctx != EGL_NO_CONTEXT) { Error error = ValidateContext(display, context); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } if (dpy != EGL_NO_DISPLAY && display->isInitialized()) { if (display->testDeviceLost()) { display->notifyDeviceLost(); return EGL_FALSE; } if (display->isDeviceLost()) { SetGlobalError(Error(EGL_CONTEXT_LOST)); return EGL_FALSE; } } Surface *drawSurface = static_cast<Surface*>(draw); if (draw != EGL_NO_SURFACE) { Error error = ValidateSurface(display, drawSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } Surface *readSurface = static_cast<Surface*>(read); if (read != EGL_NO_SURFACE) { Error error = ValidateSurface(display, readSurface); if (error.isError()) { SetGlobalError(error); return EGL_FALSE; } } if (draw != read) { UNIMPLEMENTED(); // FIXME } SetGlobalDisplay(display); SetGlobalDrawSurface(drawSurface); SetGlobalReadSurface(readSurface); SetGlobalContext(context); if (context != nullptr && display != nullptr && drawSurface != nullptr) { display->makeCurrent(drawSurface, readSurface, context); } SetGlobalError(Error(EGL_SUCCESS)); return EGL_TRUE; }