Skip to content

Commit

Permalink
Bug 1548484 - respect Cairo blit size limits when using BasicComposit…
Browse files Browse the repository at this point in the history
…or. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D30571

--HG--
extra : moz-landing-system : lando
  • Loading branch information
lsalzman committed May 10, 2019
1 parent 1100843 commit 85dc48d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gfx/2d/DrawTargetCairo.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class DrawTargetCairo final : public DrawTarget {
static cairo_surface_t* GetDummySurface();

// Cairo hardcodes this as its maximum surface size.
static size_t GetMaxSurfaceSize() { return 32767; }
static size_t GetMaxSurfaceSize() { return 32766; }

private: // methods
// Init cairo surface without doing a cairo_surface_reference() call.
Expand Down
9 changes: 8 additions & 1 deletion gfx/layers/basic/BasicCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,14 @@ BasicCompositor::BasicCompositor(CompositorBridgeParent* aParent,
mFullWindowRenderTarget(nullptr) {
MOZ_COUNT_CTOR(BasicCompositor);

mMaxTextureSize = Factory::GetMaxSurfaceSize(gfxVars::ContentBackend());
// The widget backends may create intermediate Cairo surfaces to deal with
// various window buffers, regardless of actual content backend type, when
// using the basic compositor. Ensure that the buffers will be able to fit
// in or blit with a Cairo surface.
mMaxTextureSize =
std::min(Factory::GetMaxSurfaceSize(gfxVars::ContentBackend()),
Factory::GetMaxSurfaceSize(BackendType::CAIRO));

}

BasicCompositor::~BasicCompositor() { MOZ_COUNT_DTOR(BasicCompositor); }
Expand Down
16 changes: 11 additions & 5 deletions widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ using namespace mozilla::widget;
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/KnowsCompositor.h"

#ifdef MOZ_X11
# include "GLContextGLX.h" // for GLContextGLX::FindVisual()
Expand Down Expand Up @@ -4236,13 +4237,18 @@ LayoutDeviceIntSize nsWindow::GetSafeWindowSize(LayoutDeviceIntSize aSize) {
// reads it as CARD16. Sizes of pixmaps, used for drawing, are (unsigned)
// CARD16 in the protocol, but the server's ProcCreatePixmap returns
// BadAlloc if dimensions cannot be represented by signed shorts.
// Because we are creating Cairo surfaces to represent window buffers,
// we also must ensure that the window can fit in a Cairo surface.
LayoutDeviceIntSize result = aSize;
const int32_t kInt16Max = 32767;
if (result.width > kInt16Max) {
result.width = kInt16Max;
int32_t maxSize = 32767;
if (mLayerManager && mLayerManager->AsKnowsCompositor()) {
maxSize = std::min(maxSize, mLayerManager->AsKnowsCompositor()->GetMaxTextureSize());
}
if (result.height > kInt16Max) {
result.height = kInt16Max;
if (result.width > maxSize) {
result.width = maxSize;
}
if (result.height > maxSize) {
result.height = maxSize;
}
return result;
}
Expand Down

0 comments on commit 85dc48d

Please sign in to comment.