diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 2b423d2fe18e..fb30d7fa3ab9 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -341,13 +341,10 @@ nsPluginInstanceOwner::nsPluginInstanceOwner() mPluginFrame = nullptr; mWidgetCreationComplete = false; #ifdef XP_MACOSX - memset(&mCGPluginPortCopy, 0, sizeof(NP_CGContext)); - mInCGPaintLevel = 0; mSentInitialTopLevelWindowEvent = false; mLastWindowIsActive = false; mLastContentFocused = false; mLastScaleFactor = 1.0; - mColorProfile = nullptr; mShouldBlurOnActivate = false; #endif mContentFocused = false; @@ -1208,91 +1205,6 @@ void nsPluginInstanceOwner::RemoveFromCARefreshTimer() { } } -void nsPluginInstanceOwner::RenderCoreAnimation(CGContextRef aCGContext, - int aWidth, int aHeight) -{ - if (aWidth == 0 || aHeight == 0) - return; - - if (!mCARenderer) { - mCARenderer = new nsCARenderer(); - } - - // aWidth and aHeight are in "display pixels". In non-HiDPI modes - // "display pixels" are device pixels. But in HiDPI modes each - // display pixel corresponds to more than one device pixel. - double scaleFactor = 1.0; - GetContentsScaleFactor(&scaleFactor); - - if (!mIOSurface || - (mIOSurface->GetWidth() != (size_t)aWidth || - mIOSurface->GetHeight() != (size_t)aHeight || - mIOSurface->GetContentsScaleFactor() != scaleFactor)) { - mIOSurface = nullptr; - - // If the renderer is backed by an IOSurface, resize it as required. - mIOSurface = MacIOSurface::CreateIOSurface(aWidth, aHeight, scaleFactor); - if (mIOSurface) { - RefPtr attachSurface = MacIOSurface::LookupSurface( - mIOSurface->GetIOSurfaceID(), - scaleFactor); - if (attachSurface) { - mCARenderer->AttachIOSurface(attachSurface); - } else { - NS_ERROR("IOSurface attachment failed"); - mIOSurface = nullptr; - } - } - } - - if (!mColorProfile) { - mColorProfile = CreateSystemColorSpace(); - } - - if (mCARenderer->isInit() == false) { - void *caLayer = nullptr; - nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginCoreAnimationLayer, &caLayer); - if (NS_FAILED(rv) || !caLayer) { - return; - } - - // We don't run Flash in-process so we can unconditionally disallow - // the offliner renderer. - mCARenderer->SetupRenderer(caLayer, aWidth, aHeight, scaleFactor, - DISALLOW_OFFLINE_RENDERER); - - // Setting up the CALayer requires resetting the painting otherwise we - // get garbage for the first few frames. - FixUpPluginWindow(ePluginPaintDisable); - FixUpPluginWindow(ePluginPaintEnable); - } - - CGImageRef caImage = nullptr; - nsresult rt = mCARenderer->Render(aWidth, aHeight, scaleFactor, &caImage); - if (rt == NS_OK && mIOSurface && mColorProfile) { - nsCARenderer::DrawSurfaceToCGContext(aCGContext, mIOSurface, mColorProfile, - 0, 0, aWidth, aHeight); - } else if (rt == NS_OK && caImage != nullptr) { - // Significant speed up by resetting the scaling - ::CGContextSetInterpolationQuality(aCGContext, kCGInterpolationNone ); - ::CGContextTranslateCTM(aCGContext, 0, (double) aHeight * scaleFactor); - ::CGContextScaleCTM(aCGContext, scaleFactor, -scaleFactor); - - ::CGContextDrawImage(aCGContext, CGRectMake(0,0,aWidth,aHeight), caImage); - } else { - NS_NOTREACHED("nsCARenderer::Render failure"); - } -} - -void* nsPluginInstanceOwner::GetPluginPortCopy() -{ - if (GetDrawingModel() == NPDrawingModelCoreGraphics || - GetDrawingModel() == NPDrawingModelCoreAnimation || - GetDrawingModel() == NPDrawingModelInvalidatingCoreAnimation) - return &mCGPluginPortCopy; - return nullptr; -} - void nsPluginInstanceOwner::SetPluginPort() { void* pluginPort = GetPluginPort(); @@ -1300,18 +1212,6 @@ void nsPluginInstanceOwner::SetPluginPort() return; mPluginWindow->window = pluginPort; } - -void nsPluginInstanceOwner::BeginCGPaint() -{ - ++mInCGPaintLevel; -} - -void nsPluginInstanceOwner::EndCGPaint() -{ - --mInCGPaintLevel; - NS_ASSERTION(mInCGPaintLevel >= 0, "Mismatched call to nsPluginInstanceOwner::EndCGPaint()!"); -} - #endif // static @@ -2544,8 +2444,6 @@ nsPluginInstanceOwner::Destroy() #ifdef XP_MACOSX RemoveFromCARefreshTimer(); - if (mColorProfile) - ::CGColorSpaceRelease(mColorProfile); #endif nsCOMPtr content = do_QueryReferent(mContent); @@ -3136,11 +3034,7 @@ void nsPluginInstanceOwner::FixUpPluginWindow(int32_t inPaintState) return; } - // If we've already set up a CGContext in nsPluginFrame::PaintPlugin(), we - // don't want calls to SetPluginPort() to step on our work. - if (mInCGPaintLevel < 1) { - SetPluginPort(); - } + SetPluginPort(); nsIntSize widgetClip = mPluginFrame->GetWidgetlessClipRect().Size(); diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index b05cf7fd062c..31d2dfb88cfc 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -136,19 +136,9 @@ public: // This calls into the plugin (NPP_SetWindow) and can run script. void FixUpPluginWindow(int32_t inPaintState); void HidePluginWindow(); - // Return a pointer to the internal nsPluginPort structure that's used to - // store a copy of plugin port info and to detect when it's been changed. - void* GetPluginPortCopy(); // Set plugin port info in the plugin (in the 'window' member of the // NPWindow structure passed to the plugin by SetWindow()). void SetPluginPort(); - // Flag when we've set up a Thebes (and CoreGraphics) context in - // nsPluginFrame::PaintPlugin(). We need to know this in - // FixUpPluginWindow() (i.e. we need to know when FixUpPluginWindow() has - // been called from nsPluginFrame::PaintPlugin() when we're using the - // CoreGraphics drawing model). - void BeginCGPaint(); - void EndCGPaint(); #else // XP_MACOSX void UpdateWindowPositionAndClipRect(bool aSetWindow); void UpdateWindowVisibility(bool aVisible); @@ -293,11 +283,6 @@ private: RefPtr mPluginHost; #ifdef XP_MACOSX - NP_CGContext mCGPluginPortCopy; - int32_t mInCGPaintLevel; - RefPtr mIOSurface; - RefPtr mCARenderer; - CGColorSpaceRef mColorProfile; static nsCOMPtr *sCATimer; static nsTArray *sCARefreshListeners; bool mSentInitialTopLevelWindowEvent; diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 23ed1f86f8bb..377c25aa756a 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -1541,10 +1541,6 @@ nsPluginFrame::PaintPlugin(nsDisplayListBuilder* aBuilder, nsRenderingContext& aRenderingContext, const nsRect& aDirtyRect, const nsRect& aPluginRect) { -#if defined(XP_MACOSX) - DrawTarget& aDrawTarget = *aRenderingContext.GetDrawTarget(); -#endif - #if defined(MOZ_WIDGET_ANDROID) if (mInstanceOwner) { gfxRect frameGfxRect = @@ -1558,101 +1554,6 @@ nsPluginFrame::PaintPlugin(nsDisplayListBuilder* aBuilder, return; } #endif - - // Screen painting code -#if defined(XP_MACOSX) - // delegate all painting to the plugin instance. - if (mInstanceOwner) { - if (mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreGraphics || - mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreAnimation || - mInstanceOwner->GetDrawingModel() == - NPDrawingModelInvalidatingCoreAnimation) { - int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel(); - // Clip to the content area where the plugin should be drawn. If - // we don't do this, the plugin can draw outside its bounds. - nsIntRect contentPixels = aPluginRect.ToNearestPixels(appUnitsPerDevPixel); - nsIntRect dirtyPixels = aDirtyRect.ToOutsidePixels(appUnitsPerDevPixel); - nsIntRect clipPixels; - clipPixels.IntersectRect(contentPixels, dirtyPixels); - - // Don't invoke the drawing code if the clip is empty. - if (clipPixels.IsEmpty()) - return; - - gfxRect nativeClipRect(clipPixels.x, clipPixels.y, - clipPixels.width, clipPixels.height); - gfxContext* ctx = aRenderingContext.ThebesContext(); - - gfxContextAutoSaveRestore save(ctx); - ctx->NewPath(); - ctx->Rectangle(nativeClipRect); - ctx->Clip(); - gfxPoint offset(contentPixels.x, contentPixels.y); - ctx->SetMatrix( - ctx->CurrentMatrix().Translate(offset)); - - gfxQuartzNativeDrawing nativeDrawing(aDrawTarget, - ToRect(nativeClipRect - offset)); - - CGContextRef cgContext = nativeDrawing.BeginNativeDrawing(); - if (!cgContext) { - NS_WARNING("null CGContextRef during PaintPlugin"); - return; - } - - RefPtr inst; - GetPluginInstance(getter_AddRefs(inst)); - if (!inst) { - NS_WARNING("null plugin instance during PaintPlugin"); - nativeDrawing.EndNativeDrawing(); - return; - } - NPWindow* window; - mInstanceOwner->GetWindow(window); - if (!window) { - NS_WARNING("null plugin window during PaintPlugin"); - nativeDrawing.EndNativeDrawing(); - return; - } - NP_CGContext* cgPluginPortCopy = - static_cast(mInstanceOwner->GetPluginPortCopy()); - if (!cgPluginPortCopy) { - NS_WARNING("null plugin port copy during PaintPlugin"); - nativeDrawing.EndNativeDrawing(); - return; - } - - mInstanceOwner->BeginCGPaint(); - if (mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreAnimation || - mInstanceOwner->GetDrawingModel() == - NPDrawingModelInvalidatingCoreAnimation) { - // CoreAnimation is updated, render the layer and perform a readback. - mInstanceOwner->RenderCoreAnimation(cgContext, window->width, window->height); - } else { - mInstanceOwner->Paint(nativeClipRect - offset, cgContext); - } - mInstanceOwner->EndCGPaint(); - - nativeDrawing.EndNativeDrawing(); - } else { - gfxContext* ctx = aRenderingContext.ThebesContext(); - - // Translate the context: - gfxPoint devPixelPt = - nsLayoutUtils::PointToGfxPoint(aPluginRect.TopLeft(), - PresContext()->AppUnitsPerDevPixel()); - - gfxContextMatrixAutoSaveRestore autoSR(ctx); - ctx->SetMatrix(ctx->CurrentMatrix().Translate(devPixelPt)); - - // FIXME - Bug 385435: Doesn't aDirtyRect need translating too? - - // this rect is used only in the CoreGraphics drawing model - gfxRect tmpRect(0, 0, 0, 0); - mInstanceOwner->Paint(tmpRect, nullptr); - } - } -#endif } nsresult