Skip to content

Commit

Permalink
Fixed Embedlite compilation with latest upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Aug 20, 2014
1 parent a44d999 commit 5bc8f08
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 15 deletions.
9 changes: 9 additions & 0 deletions embedding/embedlite/EmbedLiteView.cpp
Expand Up @@ -383,5 +383,14 @@ EmbedLiteView::GetPendingTexture(EmbedLiteRenderTarget* aContextWrapper, int* te
return NS_SUCCEEDED(mViewImpl->GetPendingTexture(aContextWrapper, textureID, width, height, textureTarget));
}

void*
EmbedLiteView::GetPlatformImage(int* width, int* height)
{
NS_ENSURE_TRUE(mViewImpl, nullptr);
void* aImage;
mViewImpl->GetPlatformImage(&aImage, width, height);
return aImage;
}

} // namespace embedlite
} // namespace mozilla
1 change: 1 addition & 0 deletions embedding/embedlite/EmbedLiteView.h
Expand Up @@ -131,6 +131,7 @@ class EmbedLiteView

virtual uint32_t GetUniqueID();
virtual bool GetPendingTexture(EmbedLiteRenderTarget* aContextWrapper, int* textureID, int* width, int* height, int* textureTarget = 0);
virtual void* GetPlatformImage(int* width, int* height);

private:
friend class EmbedLiteViewThreadParent;
Expand Down
2 changes: 2 additions & 0 deletions embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl
Expand Up @@ -23,6 +23,7 @@ class nsString;
[ref] native nsIntRect(nsIntRect);
[ref] native InputData(mozilla::InputData);
[ptr] native EmbedLiteRenderTarget(mozilla::embedlite::EmbedLiteRenderTarget);
[ptr] native PlatformImage(void);
[ptr] native buffer(unsigned char);

[scriptable, uuid(6d7750f8-e028-4445-a0cb-d9ce28fb03dd)]
Expand Down Expand Up @@ -58,4 +59,5 @@ interface EmbedLiteViewIface
void ViewAPIDestroyed();
void GetUniqueID(out uint32_t aId);
void GetPendingTexture(in EmbedLiteRenderTarget aContextWrapper, out int32_t aTextureID, out int32_t aTextureTarget, out int32_t aWidth, out int32_t aHeight);
void GetPlatformImage(out PlatformImage aImage, out int32_t aWidth, out int32_t aHeight);
};
29 changes: 26 additions & 3 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp
Expand Up @@ -93,17 +93,17 @@ EmbedLiteCompositorParent::PrepareOffscreen()
SurfaceStreamType streamType =
SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,
screen->PreserveBuffer());
SurfaceFactory* factory = nullptr;
UniquePtr<SurfaceFactory> factory;
if (context->GetContextType() == GLContextType::EGL) {
// [Basic/OGL Layers, OMTC] WebGL layer init.
factory = SurfaceFactory_EGLImage::Create(context, screen->mCaps);
} else {
// [Basic Layers, OMTC] WebGL layer init.
// Well, this *should* work...
factory = new SurfaceFactory_GLTexture(context, nullptr, screen->mCaps);
factory = MakeUnique<SurfaceFactory_GLTexture>(context, nullptr, screen->mCaps);
}
if (factory) {
screen->Morph(factory, streamType);
screen->Morph(Move(factory), streamType);
}
}
}
Expand Down Expand Up @@ -219,6 +219,29 @@ void EmbedLiteCompositorParent::SetSurfaceSize(int width, int height)
SetEGLSurfaceSize(width, height);
}

void*
EmbedLiteCompositorParent::GetPlatformImage(int* width, int* height)
{
const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(RootLayerTreeId());
NS_ENSURE_TRUE(state && state->mLayerManager, nullptr);

GLContext* context = static_cast<CompositorOGL*>(state->mLayerManager->GetCompositor())->gl();
NS_ENSURE_TRUE(context && context->IsOffscreen(), nullptr);

SharedSurface* sharedSurf = context->RequestFrame();
NS_ENSURE_TRUE(sharedSurf, nullptr);

*width = sharedSurf->mSize.width;
*height = sharedSurf->mSize.height;

if (sharedSurf->mType == SharedSurfaceType::EGLImageShare) {
SharedSurface_EGLImage* eglImageSurf = SharedSurface_EGLImage::Cast(sharedSurf);
return eglImageSurf->mImage;
}

return nullptr;
}

} // namespace embedlite
} // namespace mozilla

Expand Up @@ -26,6 +26,7 @@ class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent

bool RenderToContext(gfx::DrawTarget* aTarget);
void SetSurfaceSize(int width, int height);
void* GetPlatformImage(int* width, int* height);

protected:
virtual ~EmbedLiteCompositorParent();
Expand Down
8 changes: 8 additions & 0 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp
Expand Up @@ -807,5 +807,13 @@ EmbedLiteViewThreadParent::GetPendingTexture(EmbedLiteRenderTarget* aContextWrap
return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::GetPlatformImage(void* *aImage, int* width, int* height)
{
NS_ENSURE_TRUE(mCompositor, NS_ERROR_FAILURE);
*aImage = mCompositor->GetPlatformImage(width, height);
return NS_OK;
}

} // namespace embedlite
} // namespace mozilla
5 changes: 2 additions & 3 deletions embedding/embedlite/modules/EmbedLiteAppService.cpp
Expand Up @@ -28,11 +28,11 @@
#include "nsIWebBrowser.h"
#include "mozilla/layers/AsyncPanZoomController.h"
#include "mozilla/embedlite/EmbedLog.h"
#include "nsCxPusher.h"
#include "xpcprivate.h"
#include "nsPIDOMWindow.h"
#include "mozilla/AutoRestore.h"
#include "FrameMetrics.h"
#include "mozilla/dom/ScriptSettings.h"

using namespace mozilla;
using namespace mozilla::embedlite;
Expand Down Expand Up @@ -113,8 +113,7 @@ void EmbedLiteAppService::UnregisterView(uint32_t aId)
NS_IMETHODIMP
EmbedLiteAppService::GetIDByWindow(nsIDOMWindow* aWin, uint32_t* aId)
{
nsCxPusher pusher;
pusher.PushNull();
dom::AutoJSAPI jsapiChromeGuard;
nsCOMPtr<nsIDOMWindow> window;
nsCOMPtr<nsIWebNavigation> navNav(do_GetInterface(aWin));
nsCOMPtr<nsIDocShellTreeItem> navItem(do_QueryInterface(navNav));
Expand Down
9 changes: 0 additions & 9 deletions embedding/embedlite/tests/Makefile.in
Expand Up @@ -16,15 +16,6 @@ STL_FLAGS=

LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build

OS_LIBS += \
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
$(NULL)

OS_LIBS += \
$(TK_LIBS) \
$(MOZ_GTHREAD_LIBS) \
$(NULL)

ifeq (1 ,$(MOZ_X11))
OS_LIBS += \
-lX11 \
Expand Down
3 changes: 3 additions & 0 deletions embedding/embedlite/tests/moz.build
Expand Up @@ -22,6 +22,9 @@ USE_LIBS += [
'xpcomglue',
]

OS_LIBS += CONFIG['TK_LIBS']
OS_LIBS += CONFIG['MOZ_GTHREAD_LIBS']

JAR_MANIFESTS += ['jar.mn']

CXXFLAGS += CONFIG['TK_CFLAGS']

0 comments on commit 5bc8f08

Please sign in to comment.