Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup Embedlite api's
  • Loading branch information
tmeshkova committed Aug 3, 2014
1 parent 50240c7 commit 56f6c0d
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 125 deletions.
26 changes: 20 additions & 6 deletions embedding/embedlite/EmbedLiteMessagePump.cpp
Expand Up @@ -28,34 +28,44 @@ class MessagePumpEmbed : public MessagePump
, mLoop(NULL)
{
}

~MessagePumpEmbed()
{
}

virtual void Run(Delegate* delegate)
{
mLoop = MessageLoop::current();
if (mListener)
if (mListener) {
mListener->Run(delegate);
}
}

virtual void Quit()
{
if (mListener)
if (mListener) {
mListener->Quit();
}
}

virtual void ScheduleWork()
{
if (mListener)
if (mListener) {
mListener->ScheduleWork();
}
}

virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time)
{
delayed_work_time_ = delayed_work_time;
ScheduleDelayedWorkIfNeeded(delayed_work_time_);
}

virtual void ScheduleDelayedWorkIfNeeded(const TimeTicks& delayed_work_time)
{
if (!mListener)
if (!mListener) {
return;
}

if (delayed_work_time.is_null()) {
mListener->ScheduleDelayedWork(-1);
Expand All @@ -67,6 +77,7 @@ class MessagePumpEmbed : public MessagePump
std::numeric_limits<int>::max() : delay.InMilliseconds();
mListener->ScheduleDelayedWork(laterMsecs);
}

TimeTicks& DelayedWorkTime()
{
return delayed_work_time_;
Expand Down Expand Up @@ -112,7 +123,8 @@ bool EmbedLiteMessagePump::DoWork(void* aDelegate)

bool EmbedLiteMessagePump::DoDelayedWork(void* aDelegate)
{
bool retval = static_cast<base::MessagePump::Delegate*>(aDelegate)->DoDelayedWork(&mEmbedPump->DelayedWorkTime());
bool retval = static_cast<base::MessagePump::Delegate*>(aDelegate)->
DoDelayedWork(&mEmbedPump->DelayedWorkTime());
mEmbedPump->ScheduleDelayedWorkIfNeeded(mEmbedPump->DelayedWorkTime());
return retval;
}
Expand All @@ -123,7 +135,9 @@ bool EmbedLiteMessagePump::DoIdleWork(void* aDelegate)
}

void*
EmbedLiteMessagePump::PostTask(EMBEDTaskCallback callback, void* userData, int timeout)
EmbedLiteMessagePump::PostTask(EMBEDTaskCallback callback,
void* userData,
int timeout)
{
if (!mEmbedPump->GetLoop()) {
return nullptr;
Expand Down
34 changes: 0 additions & 34 deletions embedding/embedlite/EmbedLiteView.cpp
Expand Up @@ -193,13 +193,6 @@ EmbedLiteView::RenderToImage(unsigned char* aData, int imgW, int imgH, int strid
return NS_SUCCEEDED(mViewImpl->RenderToImage(aData, imgW, imgH, stride, depth));
}

bool
EmbedLiteView::RenderGL()
{
NS_ENSURE_TRUE(mViewImpl, false);
return NS_SUCCEEDED(mViewImpl->RenderGL());
}

char*
EmbedLiteView::GetImageAsURL(int aWidth, int aHeight)
{
Expand Down Expand Up @@ -296,33 +289,6 @@ EmbedLiteView::SetGLViewPortSize(int width, int height)
mViewImpl->SetGLViewPortSize(width, height);
}

void
EmbedLiteView::SetGLViewTransform(gfxMatrix matrix)
{
NS_ENSURE_TRUE(mViewImpl, );
gfx::Matrix m(matrix._11, matrix._12, matrix._21, matrix._22, matrix._31, matrix._32);
mViewImpl->SetGLViewTransform(m);
}

void
EmbedLiteView::SetViewClipping(float aX, float aY, float aWidth, float aHeight)
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->SetViewClipping(gfxRect(aX, aY, aWidth, aHeight));
}

void
EmbedLiteView::SetViewOpacity(float aOpacity)
{
}

void
EmbedLiteView::SetTransformation(float aScale, nsIntPoint aScrollOffset)
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->SetTransformation(aScale, aScrollOffset);
}

void
EmbedLiteView::ScheduleRender()
{
Expand Down
20 changes: 1 addition & 19 deletions embedding/embedlite/EmbedLiteView.h
Expand Up @@ -51,12 +51,6 @@ class EmbedLiteViewListener
// Invalidate notification
virtual bool Invalidate() { return false; }
virtual void CompositingFinished() { }
virtual void SetFirstPaintViewport(const nsIntPoint& aOffset, float aZoom,
const nsIntRect& aPageRect, const gfxRect& aCssPageRect) {}
virtual void SyncViewportInfo(const nsIntRect& aDisplayPort,
float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) {}
virtual void SetPageRect(const gfxRect& aCssPageRect) {}
virtual void IMENotification(int aEnabled, bool aOpen, int aCause, int aFocusChange, const char16_t* inputType, const char16_t* inputMode) {}
virtual void GetIMEStatus(int32_t* aIMEEnabled, int32_t* aIMEOpen, intptr_t* aNativeIMEContext) {}

Expand All @@ -68,8 +62,6 @@ class EmbedLiteViewListener
virtual bool AcknowledgeScrollUpdate(const uint32_t& aViewID, const uint32_t& aScrollGeneration) { return false; }
virtual bool SendAsyncScrollDOMEvent(const gfxRect& aContentRect,
const gfxSize& aScrollableSize) { return false; }
// Some GL Context implementations require Platform GL context to be active and valid
virtual bool RequestCurrentGLContext() { return false; }
};

class EmbedLiteApp;
Expand Down Expand Up @@ -118,19 +110,9 @@ class EmbedLiteView
// Render content into custom rgb image (SW Rendering)
virtual bool RenderToImage(unsigned char* aData, int imgW, int imgH, int stride, int depth);

// GL Rendering setuo
virtual bool RenderGL();
// Setup renderable GL/EGL window surface size
virtual void SetGLViewPortSize(int width, int height);
// GL world transform offset and simple rotation are allowed (orientation change)
virtual void SetGLViewTransform(gfxMatrix matrix);
// Setup Clipping on view area, required if view gl area need to be particulary clipped withing target widget area
virtual void SetViewClipping(float aX, float aY, float aWidth, float aHeight);
// Setup view opacity for direct GL rendering
virtual void SetViewOpacity(float aOpacity);

// Set Custom transform for compositor layers tree, Fast Scroll/Zoom
virtual void SetTransformation(float aScale, nsIntPoint aScrollOffset);

virtual void ScheduleRender();

// Scripting Interface, allow to extend embedding API by creating
Expand Down
4 changes: 0 additions & 4 deletions embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl
Expand Up @@ -40,16 +40,12 @@ interface EmbedLiteViewIface
void AddMessageListeners([const] in nsStringTArrayRef aNames);
void RemoveMessageListeners([const] in nsStringTArrayRef aNames);
void RenderToImage(in buffer aData, in int32_t aWidth, in int32_t aHeigth, in int32_t aStride, in int32_t aDepth);
void RenderGL();
void SetIsActive(in boolean isActive);
void SetIsFocused(in boolean isFocused);
void SuspendTimeouts();
void ResumeTimeouts();
void SetViewSize(in int32_t aWidth, in int32_t aHeight);
void SetGLViewPortSize(in int32_t aWidth, in int32_t aHeight);
void SetGLViewTransform(in gfxMatrix aMatrix);
void SetViewClipping([const] in gfxRect aClipRect);
void SetTransformation(in float aScale, in nsIntPoint aScrollOffset);
void ScheduleRender();
void ReceiveInputEvent([const] in InputData aEvent);
void TextEvent(in string aComposite, in string aPreEdit);
Expand Down
16 changes: 0 additions & 16 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp
Expand Up @@ -118,12 +118,6 @@ EmbedLiteCompositorParent::UpdateTransformState()
GLContext* context = static_cast<CompositorOGL*>(state->mLayerManager->GetCompositor())->gl();
NS_ENSURE_TRUE(context, );

state->mLayerManager->SetWorldTransform(mWorldTransform);

if (!mActiveClipping.IsEmpty() && state->mLayerManager->GetRoot()) {
state->mLayerManager->GetRoot()->SetClipRect(&mActiveClipping);
}

if (context->IsOffscreen() && context->OffscreenSize() != mLastViewSize) {
context->ResizeOffscreen(gfx::IntSize(mLastViewSize.width, mLastViewSize.height));
ScheduleRenderOnCompositorThread();
Expand Down Expand Up @@ -225,16 +219,6 @@ void EmbedLiteCompositorParent::SetSurfaceSize(int width, int height)
SetEGLSurfaceSize(width, height);
}

void EmbedLiteCompositorParent::SetWorldTransform(gfx::Matrix aMatrix)
{
mWorldTransform = aMatrix;
}

void EmbedLiteCompositorParent::SetClipping(const gfxRect& aClipRect)
{
gfxUtils::GfxRectToIntRect(aClipRect, &mActiveClipping);
}

} // namespace embedlite
} // namespace mozilla

6 changes: 1 addition & 5 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.h
Expand Up @@ -25,10 +25,7 @@ class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent
uint32_t id);

bool RenderToContext(gfx::DrawTarget* aTarget);
bool RenderGL();
void SetSurfaceSize(int width, int height);
void SetWorldTransform(gfx::Matrix);
void SetClipping(const gfxRect& aClipRect);

protected:
virtual ~EmbedLiteCompositorParent();
Expand All @@ -43,10 +40,9 @@ class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent
void PrepareOffscreen();
bool Invalidate();
void UpdateTransformState();
bool RenderGL();

uint32_t mId;
gfx::Matrix mWorldTransform;
nsIntRect mActiveClipping;
CancelableTask* mCurrentCompositeTask;
gfx::IntSize mLastViewSize;
short mInitialPaintCount;
Expand Down
36 changes: 0 additions & 36 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp
Expand Up @@ -526,16 +526,6 @@ EmbedLiteViewThreadParent::RenderToImage(unsigned char* aData, int imgW, int img
return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::RenderGL()
{
if (mCompositor) {
return mCompositor->RenderGL() ? NS_OK : NS_ERROR_FAILURE;
}

return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::SetViewSize(int width, int height)
{
Expand Down Expand Up @@ -565,32 +555,6 @@ EmbedLiteViewThreadParent::SetGLViewPortSize(int width, int height)
return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::SetGLViewTransform(mozilla::gfx::Matrix & aMatrix)
{
if (mCompositor) {
mCompositor->SetWorldTransform(aMatrix);
}

return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::SetViewClipping(const gfxRect& aClipRect)
{
if (mCompositor) {
mCompositor->SetClipping(aClipRect);
}

return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::SetTransformation(float aScale, nsIntPoint& aScrollOffset)
{
return NS_OK;
}

NS_IMETHODIMP
EmbedLiteViewThreadParent::ScheduleRender()
{
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/moz.build
Expand Up @@ -3,7 +3,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

TOOL_DIRS += ['tests']
DIRS += ['tests']

if CONFIG['ENABLE_TESTS']:
DIRS += ['tests/gtest']
Expand Down
6 changes: 3 additions & 3 deletions embedding/embedlite/tests/Makefile.in
Expand Up @@ -16,17 +16,17 @@ STL_FLAGS=

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

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

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

ifeq (1 ,$(MOZ_X11))
LIBS += \
OS_LIBS += \
-lX11 \
$(NULL)
endif
Expand Down
10 changes: 10 additions & 0 deletions embedding/embedlite/tests/moz.build
Expand Up @@ -8,10 +8,20 @@ SOURCES += [
'embedLiteViewInitTest.cpp',
]

DEFINES['XPCOM_GLUE'] = True

DISABLE_STL_WRAPPING = True

# SIMPLE_PROGRAMS compiles a single .cpp file into an executable
SIMPLE_PROGRAMS += [
"embedLiteCoreInitTest%s" % (CONFIG['BIN_SUFFIX']),
"embedLiteViewInitTest%s" % (CONFIG['BIN_SUFFIX']),
]

USE_LIBS += [
'xpcomglue',
]

JAR_MANIFESTS += ['jar.mn']

CXXFLAGS += CONFIG['TK_CFLAGS']
4 changes: 3 additions & 1 deletion gfx/cairo/cairo/src/moz.build
Expand Up @@ -220,9 +220,11 @@ if CONFIG['GNU_CC']:

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
CFLAGS += CONFIG['MOZ_QT_CFLAGS']
CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']

if CONFIG['MOZ_X11']:
CFLAGS += CONFIG['XCFLAGS']

if CONFIG['MOZ_ENABLE_CAIRO_FT']:
CFLAGS += CONFIG['CAIRO_FT_CFLAGS']
CFLAGS += CONFIG['CAIRO_FT_CFLAGS']
CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']

0 comments on commit 56f6c0d

Please sign in to comment.