Backout 4987ffd173a4 (bug 687267) for bustage

This commit is contained in:
Ed Morley
2012-07-23 14:47:54 +01:00
parent 53da78ed82
commit c289f9f162
46 changed files with 1259 additions and 2362 deletions

View File

@@ -36,7 +36,6 @@ using mozilla::DefaultXDisplay;
#include "nsSize.h"
#include "nsDisplayList.h"
#include "ImageLayers.h"
#include "SharedTextureImage.h"
#include "nsIDOMEventTarget.h"
#include "nsObjectFrame.h"
#include "nsIPluginDocument.h"
@@ -85,6 +84,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include "AndroidBridge.h"
#include "AndroidMediaLayer.h"
#include "nsWindow.h"
static nsPluginInstanceOwner* sFullScreenInstance = nsnull;
@@ -170,38 +170,6 @@ static void OnDestroyImage(void* aPluginInstanceOwner)
already_AddRefed<ImageContainer>
nsPluginInstanceOwner::GetImageContainer()
{
#if MOZ_WIDGET_ANDROID
// Right now we only draw with Gecko layers on Honeycomb and higher. See Paint()
// for what we do on other versions.
if (AndroidBridge::Bridge()->GetAPIVersion() < 11)
return NULL;
nsRefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
Image::Format format = Image::SHARED_TEXTURE;
nsRefPtr<Image> img = container->CreateImage(&format, 1);
SharedTextureImage::Data data;
data.mHandle = mInstance->CreateSharedHandle();
data.mShareType = mozilla::gl::TextureImage::ThreadShared;
data.mInverted = mInstance->Inverted();
gfxRect r = GetPluginRect();
data.mSize = gfxIntSize(r.width, r.height);
SharedTextureImage* pluginImage = static_cast<SharedTextureImage*>(img.get());
pluginImage->SetData(data);
container->SetCurrentImage(img);
float xResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetXResolution();
float yResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetYResolution();
r.Scale(xResolution, yResolution);
mInstance->NotifySize(nsIntSize(r.width, r.height));
return container.forget();
#endif
if (mInstance) {
nsRefPtr<ImageContainer> container;
// Every call to nsIPluginInstance::GetImage() creates
@@ -338,7 +306,9 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
mWaitingForPaint = false;
#ifdef MOZ_WIDGET_ANDROID
mInverted = false;
mFullScreen = false;
mLayer = nsnull;
mJavaView = nsnull;
#endif
}
@@ -1754,6 +1724,26 @@ gfxRect nsPluginInstanceOwner::GetPluginRect()
return gfxRect(intBounds);
}
void nsPluginInstanceOwner::SendSize(int width, int height)
{
if (!mInstance)
return;
PRInt32 model = mInstance->GetANPDrawingModel();
if (model != kOpenGL_ANPDrawingModel)
return;
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = kDraw_ANPEventType;
event.data.draw.model = kOpenGL_ANPDrawingModel;
event.data.draw.data.surfaceSize.width = width;
event.data.draw.data.surfaceSize.height = height;
mInstance->HandleEvent(&event, nsnull);
}
bool nsPluginInstanceOwner::AddPluginView(const gfxRect& aRect /* = gfxRect(0, 0, 0, 0) */)
{
if (!mJavaView) {
@@ -1789,46 +1779,6 @@ void nsPluginInstanceOwner::RemovePluginView()
sFullScreenInstance = nsnull;
}
void nsPluginInstanceOwner::GetVideos(nsTArray<nsNPAPIPluginInstance::VideoInfo*>& aVideos)
{
if (!mInstance)
return;
mInstance->GetVideos(aVideos);
}
already_AddRefed<ImageContainer> nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo)
{
nsRefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
Image::Format format = Image::SHARED_TEXTURE;
nsRefPtr<Image> img = container->CreateImage(&format, 1);
SharedTextureImage::Data data;
data.mHandle = mInstance->GLContext()->CreateSharedHandle(gl::TextureImage::ThreadShared, aVideoInfo->mSurfaceTexture, gl::GLContext::SurfaceTexture);
data.mShareType = mozilla::gl::TextureImage::ThreadShared;
data.mInverted = mInstance->Inverted();
data.mSize = gfxIntSize(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height);
SharedTextureImage* pluginImage = static_cast<SharedTextureImage*>(img.get());
pluginImage->SetData(data);
container->SetCurrentImage(img);
return container.forget();
}
nsIntRect nsPluginInstanceOwner::GetVisibleRect()
{
gfxRect r = nsIntRect(0, 0, mPluginWindow->width, mPluginWindow->height);
float xResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetXResolution();
float yResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetYResolution();
r.Scale(xResolution, yResolution);
return nsIntRect(r.x, r.y, r.width, r.height);
}
void nsPluginInstanceOwner::Invalidate() {
NPRect rect;
rect.left = rect.top = 0;
@@ -2806,6 +2756,10 @@ nsPluginInstanceOwner::Destroy()
#if MOZ_WIDGET_ANDROID
RemovePluginView();
if (mLayer)
mLayer->SetVisible(false);
#endif
if (mWidget) {
@@ -2921,13 +2875,29 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
PRInt32 model = mInstance->GetANPDrawingModel();
gfxRect pluginRect = GetPluginRect();
if (model == kSurface_ANPDrawingModel) {
if (!AddPluginView(GetPluginRect())) {
if (!AddPluginView(pluginRect)) {
Invalidate();
}
return;
}
if (model == kOpenGL_ANPDrawingModel) {
if (!mLayer)
mLayer = new AndroidMediaLayer();
mLayer->UpdatePosition(pluginRect);
float xResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetXResolution();
float yResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetYResolution();
pluginRect.Scale(xResolution, yResolution);
SendSize((int)pluginRect.width, (int)pluginRect.height);
return;
}
if (model != kBitmap_ANPDrawingModel)
return;
@@ -3664,6 +3634,9 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive)
#ifdef MOZ_WIDGET_ANDROID
if (mInstance) {
if (mLayer)
mLayer->SetVisible(mPluginDocumentActiveState);
if (!mPluginDocumentActiveState)
RemovePluginView();