mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1530471 - remove Moz2D/thebes SkiaGL glue r=jrmuizel
Depends on D21052 Differential Revision: https://phabricator.services.mozilla.com/D21053 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e043d5b982
commit
a330f87601
@ -43,17 +43,6 @@ function IsAzureSkia() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
function IsAcceleratedSkia() {
|
||||
var enabled = false;
|
||||
|
||||
try {
|
||||
var props = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).getInfo();
|
||||
enabled = props.AzureCanvasBackend == "skia" && props.AzureCanvasAccelerated;
|
||||
} catch(e) { }
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
function IsAzureCairo() {
|
||||
var enabled = false;
|
||||
|
||||
@ -6585,9 +6574,6 @@ isPixel(ctx, 98,48, 0,255,0,255, 0);
|
||||
|
||||
function test_2d_gradient_radial_inside1() {
|
||||
|
||||
if (IsAcceleratedSkia())
|
||||
return;
|
||||
|
||||
var canvas = document.getElementById('c240');
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
|
13
gfx/2d/2D.h
13
gfx/2d/2D.h
@ -66,7 +66,6 @@ struct IDWriteRenderingParams;
|
||||
struct IDWriteFontFace;
|
||||
struct IDWriteFontCollection;
|
||||
|
||||
class GrContext;
|
||||
class SkCanvas;
|
||||
struct gfxFontStyle;
|
||||
|
||||
@ -1508,13 +1507,6 @@ class DrawTarget : public external::AtomicRefCounted<DrawTarget> {
|
||||
*/
|
||||
virtual void DetachAllSnapshots() = 0;
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
virtual bool InitWithGrContext(GrContext *aGrContext, const IntSize &aSize,
|
||||
SurfaceFormat aFormat) {
|
||||
MOZ_CRASH("GFX: InitWithGrContext");
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
UserData mUserData;
|
||||
Matrix mTransform;
|
||||
@ -1749,11 +1741,6 @@ class GFX2D_API Factory {
|
||||
static Config *sConfig;
|
||||
|
||||
public:
|
||||
#ifdef USE_SKIA_GPU
|
||||
static already_AddRefed<DrawTarget> CreateDrawTargetSkiaWithGrContext(
|
||||
GrContext *aGrContext, const IntSize &aSize, SurfaceFormat aFormat);
|
||||
#endif
|
||||
|
||||
static void PurgeAllCaches();
|
||||
|
||||
static already_AddRefed<DrawTarget> CreateDualDrawTarget(DrawTarget *targetA,
|
||||
|
@ -29,13 +29,6 @@
|
||||
#include "Swizzle.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
# include "GLDefs.h"
|
||||
# include "skia/include/gpu/GrContext.h"
|
||||
# include "skia/include/gpu/GrTexture.h"
|
||||
# include "skia/include/gpu/gl/GrGLInterface.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
# include "BorrowedContext.h"
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
@ -649,11 +642,6 @@ void DrawTargetSkia::DrawSurface(SourceSurface* aSurface, const Rect& aDest,
|
||||
}
|
||||
|
||||
DrawTargetType DrawTargetSkia::GetType() const {
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (mGrContext) {
|
||||
return DrawTargetType::HARDWARE_RASTER;
|
||||
}
|
||||
#endif
|
||||
return DrawTargetType::SOFTWARE_RASTER;
|
||||
}
|
||||
|
||||
@ -700,10 +688,9 @@ void DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface* aSurface,
|
||||
auto shadowDest = IntPoint::Round(aDest + aOffset);
|
||||
|
||||
SkBitmap blurMask;
|
||||
if (!UsingSkiaGPU() && ExtractAlphaBitmap(image, &blurMask)) {
|
||||
// Prefer using our own box blur instead of Skia's when we're
|
||||
// not using the GPU. It currently performs much better than
|
||||
// SkBlurImageFilter or SkBlurMaskFilter on the CPU.
|
||||
if (ExtractAlphaBitmap(image, &blurMask)) {
|
||||
// Prefer using our own box blur instead of Skia's. It currently performs
|
||||
// much better than SkBlurImageFilter or SkBlurMaskFilter on the CPU.
|
||||
AlphaBoxBlur blur(Rect(0, 0, blurMask.width(), blurMask.height()),
|
||||
int32_t(blurMask.rowBytes()), aSigma, aSigma);
|
||||
blur.Blur(reinterpret_cast<uint8_t*>(blurMask.getPixels()));
|
||||
@ -1587,18 +1574,6 @@ already_AddRefed<SourceSurface> DrawTargetSkia::CreateSourceSurfaceFromData(
|
||||
already_AddRefed<DrawTarget> DrawTargetSkia::CreateSimilarDrawTarget(
|
||||
const IntSize& aSize, SurfaceFormat aFormat) const {
|
||||
RefPtr<DrawTargetSkia> target = new DrawTargetSkia();
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (UsingSkiaGPU()) {
|
||||
// Try to create a GPU draw target first if we're currently using the GPU.
|
||||
// Mark the DT as cached so that shadow DTs, extracted subrects, and similar
|
||||
// can be reused.
|
||||
if (target->InitWithGrContext(mGrContext.get(), aSize, aFormat, true)) {
|
||||
return target.forget();
|
||||
}
|
||||
// Otherwise, just fall back to a software draw target.
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!IsBackedByPixels(mCanvas)) {
|
||||
// If our canvas is backed by vector storage such as PDF then we want to
|
||||
@ -1620,57 +1595,9 @@ bool DrawTargetSkia::CanCreateSimilarDrawTarget(const IntSize& aSize,
|
||||
return size_t(std::max(aSize.width, aSize.height)) < GetMaxSurfaceSize();
|
||||
}
|
||||
|
||||
bool DrawTargetSkia::UsingSkiaGPU() const {
|
||||
#ifdef USE_SKIA_GPU
|
||||
return !!mGrContext;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
already_AddRefed<SourceSurface> DrawTargetSkia::OptimizeGPUSourceSurface(
|
||||
SourceSurface* aSurface) const {
|
||||
// Check if the underlying SkImage already has an associated GrTexture.
|
||||
sk_sp<SkImage> image = GetSkImageForSurface(aSurface);
|
||||
if (!image || image->isTextureBacked()) {
|
||||
RefPtr<SourceSurface> surface(aSurface);
|
||||
return surface.forget();
|
||||
}
|
||||
|
||||
// Upload the SkImage to a GrTexture otherwise.
|
||||
sk_sp<SkImage> texture = image->makeTextureImage(mGrContext.get(), nullptr);
|
||||
if (texture) {
|
||||
// Create a new SourceSurfaceSkia whose SkImage contains the GrTexture.
|
||||
RefPtr<SourceSurfaceSkia> surface = new SourceSurfaceSkia();
|
||||
if (surface->InitFromImage(texture, aSurface->GetFormat())) {
|
||||
return surface.forget();
|
||||
}
|
||||
}
|
||||
|
||||
// The data was too big to fit in a GrTexture.
|
||||
if (aSurface->GetType() == SurfaceType::SKIA) {
|
||||
// It is already a Skia source surface, so just reuse it as-is.
|
||||
RefPtr<SourceSurface> surface(aSurface);
|
||||
return surface.forget();
|
||||
}
|
||||
|
||||
// Wrap it in a Skia source surface so that can do tiled uploads on-demand.
|
||||
RefPtr<SourceSurfaceSkia> surface = new SourceSurfaceSkia();
|
||||
surface->InitFromImage(image);
|
||||
return surface.forget();
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<SourceSurface>
|
||||
DrawTargetSkia::OptimizeSourceSurfaceForUnknownAlpha(
|
||||
SourceSurface* aSurface) const {
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (UsingSkiaGPU()) {
|
||||
return OptimizeGPUSourceSurface(aSurface);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aSurface->GetType() == SurfaceType::SKIA) {
|
||||
RefPtr<SourceSurface> surface(aSurface);
|
||||
return surface.forget();
|
||||
@ -1690,12 +1617,6 @@ DrawTargetSkia::OptimizeSourceSurfaceForUnknownAlpha(
|
||||
|
||||
already_AddRefed<SourceSurface> DrawTargetSkia::OptimizeSourceSurface(
|
||||
SourceSurface* aSurface) const {
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (UsingSkiaGPU()) {
|
||||
return OptimizeGPUSourceSurface(aSurface);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aSurface->GetType() == SurfaceType::SKIA) {
|
||||
RefPtr<SourceSurface> surface(aSurface);
|
||||
return surface.forget();
|
||||
@ -1714,48 +1635,9 @@ already_AddRefed<SourceSurface> DrawTargetSkia::OptimizeSourceSurface(
|
||||
return dataSurface.forget();
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
static inline GrGLenum GfxFormatToGrGLFormat(SurfaceFormat format) {
|
||||
switch (format) {
|
||||
case SurfaceFormat::B8G8R8A8:
|
||||
return LOCAL_GL_BGRA8_EXT;
|
||||
case SurfaceFormat::B8G8R8X8:
|
||||
// We probably need to do something here.
|
||||
return LOCAL_GL_BGRA8_EXT;
|
||||
case SurfaceFormat::R5G6B5_UINT16:
|
||||
return LOCAL_GL_RGB565;
|
||||
case SurfaceFormat::A8:
|
||||
return LOCAL_GL_ALPHA8;
|
||||
default:
|
||||
return LOCAL_GL_RGBA8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<SourceSurface>
|
||||
DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(
|
||||
const NativeSurface& aSurface) const {
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (aSurface.mType == NativeSurfaceType::OPENGL_TEXTURE && UsingSkiaGPU()) {
|
||||
// Wrap the OpenGL texture id in a Skia texture handle.
|
||||
GrGLTextureInfo texInfo;
|
||||
texInfo.fTarget = LOCAL_GL_TEXTURE_2D;
|
||||
texInfo.fID = (GrGLuint)(uintptr_t)aSurface.mSurface;
|
||||
texInfo.fFormat = GfxFormatToGrGLFormat(aSurface.mFormat);
|
||||
GrBackendTexture texDesc(aSurface.mSize.width, aSurface.mSize.height,
|
||||
GrMipMapped::kNo, texInfo);
|
||||
sk_sp<SkImage> texture = SkImage::MakeFromAdoptedTexture(
|
||||
mGrContext.get(), texDesc, kTopLeft_GrSurfaceOrigin,
|
||||
GfxFormatToSkiaColorType(aSurface.mFormat),
|
||||
GfxFormatToSkiaAlphaType(aSurface.mFormat));
|
||||
RefPtr<SourceSurfaceSkia> newSurf = new SourceSurfaceSkia();
|
||||
if (texture && newSurf->InitFromImage(texture, aSurface.mFormat)) {
|
||||
return newSurf.forget();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1838,55 +1720,6 @@ bool DrawTargetSkia::Init(SkCanvas* aCanvas) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
/** Indicating a DT should be cached means that space will be reserved in Skia's
|
||||
* cache for the render target at creation time, with any unused resources
|
||||
* exceeding the cache limits being purged. When the DT is freed, it will then
|
||||
* be guaranteed to be kept around for subsequent allocations until it gets
|
||||
* incidentally purged.
|
||||
*
|
||||
* If it is not marked as cached, no space will be purged to make room for the
|
||||
* render target in the cache. When the DT is freed, If there is space within
|
||||
* the resource limits it may be added to the cache, otherwise it will be freed
|
||||
* immediately if the cache is already full.
|
||||
*
|
||||
* If you want to ensure that the resources will be kept around for reuse, it is
|
||||
* better to mark them as cached. Such resources should be short-lived to ensure
|
||||
* they don't permanently tie up cache resource limits. Long-lived resources
|
||||
* should generally be left as uncached.
|
||||
*
|
||||
* In neither case will cache resource limits affect whether the resource
|
||||
* allocation succeeds. The amount of in-use GPU resources is allowed to exceed
|
||||
* the size of the cache. Thus, only hard GPU out-of-memory conditions will
|
||||
* cause resource allocation to fail.
|
||||
*/
|
||||
bool DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
|
||||
const IntSize& aSize,
|
||||
SurfaceFormat aFormat, bool aCached) {
|
||||
MOZ_ASSERT(aGrContext, "null GrContext");
|
||||
|
||||
if (size_t(std::max(aSize.width, aSize.height)) > GetMaxSurfaceSize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a GPU rendertarget/texture using the supplied GrContext.
|
||||
// MakeRenderTarget also implicitly clears the underlying texture on creation.
|
||||
mSurface = SkSurface::MakeRenderTarget(aGrContext, SkBudgeted(aCached),
|
||||
MakeSkiaImageInfo(aSize, aFormat));
|
||||
if (!mSurface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mGrContext = sk_ref_sp(aGrContext);
|
||||
mSize = aSize;
|
||||
mFormat = aFormat;
|
||||
mCanvas = mSurface->getCanvas();
|
||||
SetPermitSubpixelAA(IsOpaque(mFormat));
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool DrawTargetSkia::Init(unsigned char* aData, const IntSize& aSize,
|
||||
int32_t aStride, SurfaceFormat aFormat,
|
||||
bool aUninitialized) {
|
||||
@ -1914,16 +1747,6 @@ void DrawTargetSkia::SetTransform(const Matrix& aTransform) {
|
||||
}
|
||||
|
||||
void* DrawTargetSkia::GetNativeSurface(NativeSurfaceType aType) {
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (aType == NativeSurfaceType::OPENGL_TEXTURE && mSurface) {
|
||||
GrBackendTexture tex =
|
||||
mSurface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess);
|
||||
GrGLTextureInfo info;
|
||||
if (tex.getGLTextureInfo(&info)) {
|
||||
return (void*)(uintptr_t)info.fID;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -130,18 +130,6 @@ class DrawTargetSkia : public DrawTarget {
|
||||
SurfaceFormat aFormat, bool aUninitialized = false);
|
||||
bool Init(SkCanvas *aCanvas);
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
bool InitWithGrContext(GrContext *aGrContext, const IntSize &aSize,
|
||||
SurfaceFormat aFormat, bool aCached);
|
||||
virtual bool InitWithGrContext(GrContext *aGrContext, const IntSize &aSize,
|
||||
SurfaceFormat aFormat) override {
|
||||
return InitWithGrContext(aGrContext, aSize, aFormat, false);
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface> OptimizeGPUSourceSurface(
|
||||
SourceSurface *aSurface) const;
|
||||
#endif
|
||||
|
||||
// Skia assumes that texture sizes fit in 16-bit signed integers.
|
||||
static size_t GetMaxSurfaceSize() { return 32767; }
|
||||
|
||||
@ -163,8 +151,6 @@ class DrawTargetSkia : public DrawTarget {
|
||||
const StrokeOptions *aStrokeOptions = nullptr,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
|
||||
bool UsingSkiaGPU() const;
|
||||
|
||||
struct PushedLayer {
|
||||
PushedLayer(bool aOldPermitSubpixelAA, SourceSurface *aMask)
|
||||
: mOldPermitSubpixelAA(aOldPermitSubpixelAA), mMask(aMask) {}
|
||||
@ -173,10 +159,6 @@ class DrawTargetSkia : public DrawTarget {
|
||||
};
|
||||
std::vector<PushedLayer> mPushedLayers;
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
sk_sp<GrContext> mGrContext;
|
||||
#endif
|
||||
|
||||
IntSize mSize;
|
||||
sk_sp<SkSurface> mSurface;
|
||||
SkCanvas *mCanvas;
|
||||
|
@ -920,18 +920,6 @@ already_AddRefed<ScaledFont> Factory::CreateScaledFontForDWriteFont(
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
already_AddRefed<DrawTarget> Factory::CreateDrawTargetSkiaWithGrContext(
|
||||
GrContext* aGrContext, const IntSize& aSize, SurfaceFormat aFormat) {
|
||||
RefPtr<DrawTarget> newTarget = new DrawTargetSkia();
|
||||
if (!newTarget->InitWithGrContext(aGrContext, aSize, aFormat)) {
|
||||
return nullptr;
|
||||
}
|
||||
return newTarget.forget();
|
||||
}
|
||||
|
||||
#endif // USE_SKIA_GPU
|
||||
|
||||
#ifdef USE_SKIA
|
||||
already_AddRefed<DrawTarget> Factory::CreateDrawTargetWithSkCanvas(
|
||||
SkCanvas* aCanvas) {
|
||||
|
@ -125,16 +125,6 @@ uint8_t* SourceSurfaceSkia::GetData() {
|
||||
if (!mImage) {
|
||||
return nullptr;
|
||||
}
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (mImage->isTextureBacked()) {
|
||||
if (sk_sp<SkImage> raster =
|
||||
ReadSkImage(mImage, MakeSkiaImageInfo(mSize, mFormat), mStride)) {
|
||||
mImage = raster;
|
||||
} else {
|
||||
gfxCriticalError() << "Failed making Skia raster image for GPU surface";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SkPixmap pixmap;
|
||||
if (!mImage->peekPixels(&pixmap)) {
|
||||
gfxCriticalError() << "Failed accessing pixels for Skia raster image";
|
||||
|
@ -109,11 +109,6 @@
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
# endif
|
||||
# include "skia/include/core/SkGraphics.h"
|
||||
# ifdef USE_SKIA_GPU
|
||||
# include "skia/include/gpu/GrContext.h"
|
||||
# include "skia/include/gpu/gl/GrGLInterface.h"
|
||||
# include "SkiaGLGlue.h"
|
||||
# endif
|
||||
# ifdef MOZ_ENABLE_FREETYPE
|
||||
# include "skia/include/ports/SkTypeface_cairo.h"
|
||||
# endif
|
||||
@ -125,10 +120,6 @@ static const uint32_t kDefaultGlyphCacheSize = -1;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(USE_SKIA) || !defined(USE_SKIA_GPU)
|
||||
class mozilla::gl::SkiaGLGlue : public GenericAtomicRefCounted {};
|
||||
#endif
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
@ -448,7 +439,6 @@ void gfxPlatform::OnMemoryPressure(layers::MemoryPressureReason aWhy) {
|
||||
gfxGradientCache::PurgeAllCaches();
|
||||
gfxFontMissingGlyphs::Purge();
|
||||
PurgeSkiaFontCache();
|
||||
PurgeSkiaGPUCache();
|
||||
if (XRE_IsParentProcess()) {
|
||||
layers::CompositorManagerChild* manager =
|
||||
CompositorManagerChild::GetInstance();
|
||||
@ -475,8 +465,6 @@ gfxPlatform::gfxPlatform()
|
||||
mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
|
||||
mBidiNumeralOption = UNINITIALIZED_VALUE;
|
||||
|
||||
mSkiaGlue = nullptr;
|
||||
|
||||
InitBackendPrefs(GetBackendPrefs());
|
||||
|
||||
mTotalSystemMemory = PR_GetPhysicalMemorySize();
|
||||
@ -1185,7 +1173,6 @@ void gfxPlatform::Shutdown() {
|
||||
gPlatform->mMemoryPressureObserver->Unregister();
|
||||
gPlatform->mMemoryPressureObserver = nullptr;
|
||||
}
|
||||
gPlatform->mSkiaGlue = nullptr;
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
gPlatform->mVsyncSource->Shutdown();
|
||||
@ -1565,116 +1552,9 @@ bool gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
// Skia content rendering doesn't support GPU acceleration, so we can't
|
||||
// use the same backend if the current backend is accelerated.
|
||||
if ((aTarget->GetType() == DrawTargetType::HARDWARE_RASTER) &&
|
||||
(aTarget->GetBackendType() == BackendType::SKIA)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return SupportsAzureContentForType(aTarget->GetBackendType());
|
||||
}
|
||||
|
||||
bool gfxPlatform::AllowOpenGLCanvas() {
|
||||
// For now, only allow Skia+OpenGL, unless it's blocked.
|
||||
// Allow acceleration on Skia if the preference is set, unless it's blocked
|
||||
// as long as we have the accelerated layers
|
||||
|
||||
// The compositor backend is only set correctly in the parent process,
|
||||
// so we let content process always assume correct compositor backend.
|
||||
// The callers have to do the right thing.
|
||||
//
|
||||
// XXX Disable SkiaGL on WebRender, since there is a case that R8G8B8X8
|
||||
// is used, but WebRender does not support R8G8B8X8.
|
||||
bool correctBackend =
|
||||
!XRE_IsParentProcess() ||
|
||||
(mCompositorBackend == LayersBackend::LAYERS_OPENGL &&
|
||||
(GetContentBackendFor(mCompositorBackend) == BackendType::SKIA));
|
||||
|
||||
if (gfxPrefs::CanvasAzureAccelerated() && correctBackend) {
|
||||
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
||||
int32_t status;
|
||||
nsCString discardFailureId;
|
||||
return !gfxInfo || (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(
|
||||
nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION,
|
||||
discardFailureId, &status)) &&
|
||||
status == nsIGfxInfo::FEATURE_STATUS_OK);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void gfxPlatform::InitializeSkiaCacheLimits() {
|
||||
if (AllowOpenGLCanvas()) {
|
||||
#ifdef USE_SKIA_GPU
|
||||
bool usingDynamicCache = gfxPrefs::CanvasSkiaGLDynamicCache();
|
||||
int cacheItemLimit = gfxPrefs::CanvasSkiaGLCacheItems();
|
||||
uint64_t cacheSizeLimit =
|
||||
std::max(gfxPrefs::CanvasSkiaGLCacheSize(), (int32_t)0);
|
||||
|
||||
// Prefs are in megabytes, but we want the sizes in bytes
|
||||
cacheSizeLimit *= 1024 * 1024;
|
||||
|
||||
if (usingDynamicCache) {
|
||||
if (mTotalSystemMemory < 512 * 1024 * 1024) {
|
||||
// We need a very minimal cache on anything smaller than 512mb.
|
||||
// Note the large jump as we cross 512mb (from 2mb to 32mb).
|
||||
cacheSizeLimit = 2 * 1024 * 1024;
|
||||
} else if (mTotalSystemMemory > 0) {
|
||||
cacheSizeLimit = mTotalSystemMemory / 16;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure cache size doesn't overflow on 32-bit platforms.
|
||||
cacheSizeLimit = std::min(cacheSizeLimit, (uint64_t)SIZE_MAX);
|
||||
|
||||
# ifdef DEBUG
|
||||
printf_stderr("Determined SkiaGL cache limits: Size %" PRIu64
|
||||
", Items: %i\n",
|
||||
cacheSizeLimit, cacheItemLimit);
|
||||
# endif
|
||||
|
||||
mSkiaGlue->GetGrContext()->setResourceCacheLimits(cacheItemLimit,
|
||||
(size_t)cacheSizeLimit);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
SkiaGLGlue* gfxPlatform::GetSkiaGLGlue() {
|
||||
#ifdef USE_SKIA_GPU
|
||||
// Check the accelerated Canvas is enabled for the first time,
|
||||
// because the callers should check it before using.
|
||||
if (!mSkiaGlue && !AllowOpenGLCanvas()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mSkiaGlue) {
|
||||
/* Dummy context. We always draw into a FBO.
|
||||
*
|
||||
* FIXME: This should be stored in TLS or something, since there needs to be
|
||||
* one for each thread using it. As it stands, this only works on the main
|
||||
* thread.
|
||||
*/
|
||||
RefPtr<GLContext> glContext;
|
||||
nsCString discardFailureId;
|
||||
glContext = GLContextProvider::CreateHeadless(
|
||||
CreateContextFlags::REQUIRE_COMPAT_PROFILE |
|
||||
CreateContextFlags::ALLOW_OFFLINE_RENDERER,
|
||||
&discardFailureId);
|
||||
if (!glContext) {
|
||||
printf_stderr("Failed to create GLContext for SkiaGL!\n");
|
||||
return nullptr;
|
||||
}
|
||||
mSkiaGlue = new SkiaGLGlue(glContext);
|
||||
MOZ_ASSERT(mSkiaGlue->GetGrContext(), "No GrContext");
|
||||
InitializeSkiaCacheLimits();
|
||||
}
|
||||
#endif
|
||||
|
||||
return mSkiaGlue;
|
||||
}
|
||||
|
||||
void gfxPlatform::PurgeSkiaFontCache() {
|
||||
#ifdef USE_SKIA
|
||||
if (gfxPlatform::GetPlatform()->GetDefaultContentBackend() ==
|
||||
@ -1684,19 +1564,6 @@ void gfxPlatform::PurgeSkiaFontCache() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfxPlatform::PurgeSkiaGPUCache() {
|
||||
#ifdef USE_SKIA_GPU
|
||||
if (!mSkiaGlue) return;
|
||||
|
||||
mSkiaGlue->GetGrContext()->freeGpuResources();
|
||||
// GrContext::flush() doesn't call glFlush. Call it here.
|
||||
mSkiaGlue->GetGLContext()->MakeCurrent();
|
||||
mSkiaGlue->GetGLContext()->fFlush();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool gfxPlatform::HasEnoughTotalSystemMemoryForSkiaGL() { return true; }
|
||||
|
||||
already_AddRefed<DrawTarget> gfxPlatform::CreateDrawTargetForBackend(
|
||||
BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat) {
|
||||
// There is a bunch of knowledge in the gfxPlatform heirarchy about how to
|
||||
@ -3114,8 +2981,6 @@ void gfxPlatform::GetAzureBackendInfo(mozilla::widget::InfoObject& aObj) {
|
||||
GetBackendName(mFallbackCanvasBackend));
|
||||
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
|
||||
}
|
||||
|
||||
aObj.DefineProperty("AzureCanvasAccelerated", AllowOpenGLCanvas());
|
||||
}
|
||||
|
||||
void gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj) {
|
||||
|
@ -44,9 +44,6 @@ class gfxTextPerfMetrics;
|
||||
typedef struct FT_LibraryRec_* FT_Library;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
class SkiaGLGlue;
|
||||
} // namespace gl
|
||||
namespace layers {
|
||||
class FrameStats;
|
||||
}
|
||||
@ -276,15 +273,6 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
|
||||
return BackendTypeBit(aType) & mContentBackendBitmask;
|
||||
}
|
||||
|
||||
/// This function also lets us know if the current preferences/platform
|
||||
/// combination allows for both accelerated and not accelerated canvas
|
||||
/// implementations. If it does, and other relevant preferences are
|
||||
/// asking for it, we will examine the commands in the first few seconds
|
||||
/// of the canvas usage, and potentially change to accelerated or
|
||||
/// non-accelerated canvas.
|
||||
virtual bool AllowOpenGLCanvas();
|
||||
virtual void InitializeSkiaCacheLimits();
|
||||
|
||||
static bool AsyncPanZoomEnabled();
|
||||
|
||||
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject& aObj);
|
||||
@ -615,14 +603,10 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
|
||||
*/
|
||||
mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();
|
||||
|
||||
mozilla::gl::SkiaGLGlue* GetSkiaGLGlue();
|
||||
void PurgeSkiaGPUCache();
|
||||
static void PurgeSkiaFontCache();
|
||||
|
||||
static bool UsesOffMainThreadCompositing();
|
||||
|
||||
bool HasEnoughTotalSystemMemoryForSkiaGL();
|
||||
|
||||
/**
|
||||
* Whether we want to adjust gfx parameters (currently just
|
||||
* the framerate and whether we use software vs. hardware vsync)
|
||||
@ -934,7 +918,6 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
|
||||
nsTArray<mozilla::layers::FrameStats> mFrameStats;
|
||||
|
||||
RefPtr<mozilla::gfx::DrawEventRecorder> mRecorder;
|
||||
RefPtr<mozilla::gl::SkiaGLGlue> mSkiaGlue;
|
||||
|
||||
// Backend that we are compositing with. NONE, if no compositor has been
|
||||
// created yet.
|
||||
|
@ -585,11 +585,6 @@ void gfxWindowsPlatform::UpdateRenderMode() {
|
||||
}
|
||||
}
|
||||
|
||||
bool gfxWindowsPlatform::AllowOpenGLCanvas() {
|
||||
// OpenGL canvas is not supported on windows
|
||||
return false;
|
||||
}
|
||||
|
||||
mozilla::gfx::BackendType gfxWindowsPlatform::GetContentBackendFor(
|
||||
mozilla::layers::LayersBackend aLayers) {
|
||||
mozilla::gfx::BackendType defaultBackend =
|
||||
|
@ -167,8 +167,6 @@ class gfxWindowsPlatform : public gfxPlatform {
|
||||
void SchedulePaintIfDeviceReset() override;
|
||||
void CheckForContentOnlyDeviceReset();
|
||||
|
||||
bool AllowOpenGLCanvas() override;
|
||||
|
||||
mozilla::gfx::BackendType GetContentBackendFor(
|
||||
mozilla::layers::LayersBackend aLayers) override;
|
||||
|
||||
|
@ -426,13 +426,12 @@ function BuildConditionSandbox(aURL) {
|
||||
var info = gfxInfo.getInfo();
|
||||
var canvasBackend = readGfxInfo(info, "AzureCanvasBackend");
|
||||
var contentBackend = readGfxInfo(info, "AzureContentBackend");
|
||||
var canvasAccelerated = readGfxInfo(info, "AzureCanvasAccelerated");
|
||||
|
||||
sandbox.gpuProcess = gfxInfo.usingGPUProcess;
|
||||
sandbox.azureCairo = canvasBackend == "cairo";
|
||||
sandbox.azureSkia = canvasBackend == "skia";
|
||||
sandbox.skiaContent = contentBackend == "skia";
|
||||
sandbox.azureSkiaGL = canvasAccelerated; // FIXME: assumes GL right now
|
||||
sandbox.azureSkiaGL = false;
|
||||
// true if we are using the same Azure backend for rendering canvas and content
|
||||
sandbox.contentSameGfxBackendAsCanvas = contentBackend == canvasBackend
|
||||
|| (contentBackend == "none" && canvasBackend == "cairo");
|
||||
|
Loading…
Reference in New Issue
Block a user