Bug 756601 - Setup our OpenGL surface before compositing. r=mstange
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -266,16 +266,19 @@ LayerManagerComposite::Render()
return;
}
if (mComposer2D && mComposer2D->TryRender(mRoot, mWorldMatrix)) {
mCompositor->EndFrameForExternalComposition(mWorldMatrix);
return;
}
+
+ mCompositor->GetWidget()->PreRender(this);
+
nsIntRect clipRect;
Rect bounds(mRenderBounds.x, mRenderBounds.y, mRenderBounds.width, mRenderBounds.height);
Rect actualBounds;
if (mRoot->GetClipRect()) {
clipRect = *mRoot->GetClipRect();
WorldTransformRect(clipRect);
Rect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
mCompositor->BeginFrame(&rect, mWorldMatrix, bounds, nullptr, &actualBounds);
--- a/gfx/layers/opengl/CompositingRenderTargetOGL.h
+++ b/gfx/layers/opengl/CompositingRenderTargetOGL.h
@@ -110,16 +110,24 @@ public:
*/
void BindRenderTarget()
{
if (mInitParams.mStatus != InitParams::INITIALIZED) {
InitializeImpl();
} else {
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mFBO);
+ GLenum result = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
+ if (result != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
+ nsAutoCString msg;
+ msg.AppendPrintf("Framebuffer not complete -- error 0x%x, aFBOTextureTarget 0x%x, aRect.width %d, aRect.height %d",
+ result, mInitParams.mFBOTextureTarget, mInitParams.mSize.width, mInitParams.mSize.height);
+ NS_WARNING(msg.get());
+ }
+
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
}
}
GLuint GetFBO() const
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
return mFBO;
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -319,16 +319,17 @@ typedef NSInteger NSEventGestureAxis;
- (BOOL)isPluginView;
// Are we processing an NSLeftMouseDown event that will fail to click through?
// If so, we shouldn't focus or unfocus a plugin.
- (BOOL)isInFailingLeftClickThrough;
- (void)setGLContext:(NSOpenGLContext *)aGLContext;
+- (void)preRender:(NSOpenGLContext *)aGLContext;
// Simple gestures support
//
// XXX - The swipeWithEvent, beginGestureWithEvent, magnifyWithEvent,
// rotateWithEvent, and endGestureWithEvent methods are part of a
// PRIVATE interface exported by nsResponder and reverse-engineering
// was necessary to obtain the methods' prototypes. Thus, Apple may
// change the interface in the future without notice.
@@ -512,16 +513,17 @@ public:
#ifdef ACCESSIBILITY
already_AddRefed<mozilla::a11y::Accessible> GetDocumentAccessible();
#endif
virtual void CreateCompositor();
virtual gfxASurface* GetThebesSurface();
virtual void PrepareWindowEffects() MOZ_OVERRIDE;
virtual void CleanupWindowEffects() MOZ_OVERRIDE;
+ virtual void PreRender(LayerManager* aManager) MOZ_OVERRIDE;
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) MOZ_OVERRIDE;
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries);
NS_IMETHOD BeginSecureKeyboardInput();
NS_IMETHOD EndSecureKeyboardInput();
void HidePlugin();
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1865,16 +1865,24 @@ nsChildView::PrepareWindowEffects()
void
nsChildView::CleanupWindowEffects()
{
mResizerImage = nullptr;
mCornerMaskImage = nullptr;
}
void
+nsChildView::PreRender(LayerManager* aManager)
+{
+ nsAutoPtr<GLManager> manager(GLManager::CreateGLManager(aManager));
+ NSOpenGLContext *glContext = (NSOpenGLContext *)manager->gl()->GetNativeData(GLContext::NativeGLContext);
+ [(ChildView*)mView preRender:glContext];
+}
+
+void
nsChildView::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
{
nsAutoPtr<GLManager> manager(GLManager::CreateGLManager(aManager));
if (!manager) {
return;
}
MaybeDrawResizeIndicator(manager, aRect);
@@ -2301,16 +2309,30 @@ NSEvent* gLastDragMouseDownEvent = nil;
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
mGLContext = aGLContext;
[mGLContext retain];
NS_OBJC_END_TRY_ABORT_BLOCK;
}
+-(void)preRender:(NSOpenGLContext *)aGLContext
+{
+ NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+ if (!mGLContext) {
+ [self setGLContext:aGLContext];
+ }
+
+ [aGLContext setView:self];
+ [aGLContext update];
+
+ NS_OBJC_END_TRY_ABORT_BLOCK;
+}
+
- (void)dealloc
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
[mGLContext release];
[mPendingDirtyRects release];
[mLastMouseDownEvent release];
[mClickThroughMouseDownEvent release];
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -87,18 +87,18 @@ typedef nsEventStatus (* EVENT_CALLBACK)
#ifdef XP_WIN
#define NS_NATIVE_TSF_THREAD_MGR 100
#define NS_NATIVE_TSF_CATEGORY_MGR 101
#define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
#define NS_NATIVE_ICOREWINDOW 103 // winrt specific
#endif
#define NS_IWIDGET_IID \
-{ 0x16da2e50, 0x0fee, 0x4719, \
- { 0x93, 0x37, 0xce, 0xd4, 0xdd, 0xd2, 0x22, 0x53 } }
+{ 0x37b67cb4, 0x140c, 0x4d46, \
+ { 0xa9, 0xf8, 0x28, 0xcc, 0x08, 0x3d, 0x1f, 0x54 } }
/*
* Window shadow styles
* Also used for the -moz-window-shadow CSS property
*/
#define NS_STYLE_WINDOW_SHADOW_NONE 0
#define NS_STYLE_WINDOW_SHADOW_DEFAULT 1
@@ -1164,16 +1164,18 @@ class nsIWidget : public nsISupports {
/**
* Called when shutting down the LayerManager to clean-up any cached resources.
*
* Always called from the compositing thread, which may be the main-thread if
* OMTC is not enabled.
*/
virtual void CleanupWindowEffects() = 0;
+ virtual void PreRender(LayerManager* aManager) = 0;
+
/**
* Called before the LayerManager draws the layer tree.
*
* Always called from the compositing thread, which may be the main-thread if
* OMTC is not enabled.
*/
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) = 0;
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -113,16 +113,17 @@ public:
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nullptr);
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
virtual void CreateCompositor();
virtual void CreateCompositor(int aWidth, int aHeight);
virtual void PrepareWindowEffects() {}
virtual void CleanupWindowEffects() {}
+ virtual void PreRender(LayerManager* aManager) {}
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) {}
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) {}
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) {}
virtual gfxASurface* GetThebesSurface();
NS_IMETHOD SetModal(bool aModal);
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
// Return whether this widget interprets parameters to Move and Resize APIs
// as "global display pixels" rather than "device pixels", and therefore