Bug 1421313 - Remove TexturePoolOGL r=nical

MozReview-Commit-ID: ADjiygVoHg3
This commit is contained in:
James Willcox 2017-12-04 08:56:08 -06:00
Родитель 111561414d
Коммит 06d689e11c
6 изменённых файлов: 0 добавлений и 234 удалений

Просмотреть файл

@ -14,7 +14,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/TimeStamp.h"
#include "TexturePoolOGL.h"
#include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/LayerManagerComposite.h"

Просмотреть файл

@ -41,7 +41,6 @@ EXPORTS += [
'LayerTreeInvalidation.h',
'LayerUserData.h',
'opengl/OGLShaderProgram.h',
'opengl/TexturePoolOGL.h',
'protobuf/LayerScopePacket.pb.h',
'ReadbackLayer.h',
'TiledLayerBuffer.h',
@ -453,7 +452,6 @@ UNIFIED_SOURCES += [
'opengl/OGLShaderProgram.cpp',
'opengl/TextureClientOGL.cpp',
'opengl/TextureHostOGL.cpp',
'opengl/TexturePoolOGL.cpp',
'PaintThread.cpp',
'ReadbackProcessor.cpp',
'RenderTrace.cpp',

Просмотреть файл

@ -46,7 +46,6 @@
#include "HeapCopyOfStackArray.h"
#if MOZ_WIDGET_ANDROID
#include "TexturePoolOGL.h"
#include "GeneratedJNIWrappers.h"
#endif
@ -674,7 +673,6 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
mPixelsFilled = 0;
#ifdef MOZ_WIDGET_ANDROID
TexturePoolOGL::Fill(gl());
java::GeckoSurfaceTexture::DestroyUnused((int64_t)mGLContext.get());
#endif

Просмотреть файл

@ -1,170 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#include "TexturePoolOGL.h"
#include <stdlib.h> // for malloc
#include "GLContext.h" // for GLContext
#include "mozilla/Logging.h"
#include "mozilla/Monitor.h" // for Monitor, MonitorAutoLock
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "mozilla/layers/CompositorThread.h"
#include "nsDebug.h" // for NS_ASSERTION, NS_ERROR, etc
#include "nsDeque.h" // for nsDeque
#include "nsThreadUtils.h"
static const unsigned int TEXTURE_POOL_SIZE = 10;
static const unsigned int TEXTURE_REFILL_THRESHOLD = TEXTURE_POOL_SIZE / 2;
static mozilla::LazyLogModule gTexturePoolLog("TexturePoolOGL");
#define LOG(arg, ...) MOZ_LOG(gTexturePoolLog, mozilla::LogLevel::Debug, ("TexturePoolOGL::%s: " arg, __func__, ##__VA_ARGS__))
namespace mozilla {
namespace gl {
static GLContext* sActiveContext = nullptr;
static Monitor* sMonitor = nullptr;
static nsDeque* sTextures = nullptr;
enum class PoolState : uint8_t {
NOT_INITIALIZE,
INITIALIZED,
SHUTDOWN
};
static PoolState sPoolState = PoolState::NOT_INITIALIZE;
static bool sHasPendingFillTask = false;
void TexturePoolOGL::MaybeFillTextures()
{
if (sTextures->GetSize() < TEXTURE_REFILL_THRESHOLD &&
!sHasPendingFillTask) {
LOG("need to refill the texture pool.");
sHasPendingFillTask = true;
MessageLoop* loop = mozilla::layers::CompositorThreadHolder::Loop();
MOZ_ASSERT(loop);
loop->PostTask(
NS_NewRunnableFunction(
"TexturePoolOGL::MaybeFillTextures",
[] () {
TexturePoolOGL::Fill(sActiveContext);
}));
}
}
GLuint TexturePoolOGL::AcquireTexture()
{
MOZ_ASSERT(sPoolState != PoolState::NOT_INITIALIZE, "not initialized");
MOZ_ASSERT(sPoolState != PoolState::SHUTDOWN, "should not be called after shutdown");
MonitorAutoLock lock(*sMonitor);
if (!sActiveContext) {
// Wait for a context
sMonitor->Wait();
if (!sActiveContext)
return 0;
}
GLuint texture = 0;
if (sActiveContext->IsOwningThreadCurrent()) {
sActiveContext->MakeCurrent();
sActiveContext->fGenTextures(1, &texture);
} else {
while (sTextures->GetSize() == 0) {
NS_WARNING("Waiting for texture");
sMonitor->Wait();
}
GLuint* popped = (GLuint*) sTextures->Pop();
if (!popped) {
NS_ERROR("Failed to pop texture pool item");
return 0;
}
texture = *popped;
delete popped;
NS_ASSERTION(texture, "Failed to retrieve texture from pool");
MaybeFillTextures();
LOG("remaining textures num = %zu", sTextures->GetSize());
}
return texture;
}
static void Clear()
{
const bool isCurrent = sActiveContext && sActiveContext->MakeCurrent();
GLuint* item;
while (sTextures->GetSize()) {
item = (GLuint*)sTextures->Pop();
if (isCurrent) {
sActiveContext->fDeleteTextures(1, item);
}
delete item;
}
}
void TexturePoolOGL::Fill(GLContext* aContext)
{
MOZ_ASSERT(aContext, "NULL GLContext");
MOZ_ASSERT(sPoolState != PoolState::NOT_INITIALIZE, "not initialized");
MOZ_ASSERT(sPoolState != PoolState::SHUTDOWN, "should not be called after shutdown");
MonitorAutoLock lock(*sMonitor);
sHasPendingFillTask = false;
if (sActiveContext != aContext) {
Clear();
sActiveContext = aContext;
}
if (sTextures->GetSize() == TEXTURE_POOL_SIZE)
return;
DebugOnly<bool> ok = sActiveContext->MakeCurrent();
MOZ_ASSERT(ok);
GLuint* texture = nullptr;
while (sTextures->GetSize() < TEXTURE_POOL_SIZE) {
texture = (GLuint*)malloc(sizeof(GLuint));
sActiveContext->fGenTextures(1, texture);
sTextures->Push((void*) texture);
}
LOG("fill texture pool to %d", TEXTURE_POOL_SIZE);
sMonitor->NotifyAll();
}
GLContext* TexturePoolOGL::GetGLContext()
{
return sActiveContext;
}
void TexturePoolOGL::Init()
{
MOZ_ASSERT(sPoolState != PoolState::INITIALIZED);
sMonitor = new Monitor("TexturePoolOGL.sMonitor");
sTextures = new nsDeque();
sPoolState = PoolState::INITIALIZED;
}
void TexturePoolOGL::Shutdown()
{
MOZ_ASSERT(sPoolState == PoolState::INITIALIZED);
sPoolState = PoolState::SHUTDOWN;
delete sMonitor;
delete sTextures;
}
} // namespace gl
} // namespace mozilla

Просмотреть файл

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef GFX_TEXTUREPOOLOGL_H
#define GFX_TEXTUREPOOLOGL_H
#include "GLContextTypes.h" // for GLContext, GLuint
namespace mozilla {
namespace gl {
// A texture pool for for the on-screen GLContext. The main purpose of this class
// is to provide the ability to easily allocate an on-screen texture from the
// content thread. The unfortunate nature of the SurfaceTexture API (see AndroidSurfaceTexture)
// necessitates this.
class TexturePoolOGL
{
public:
// Get a new texture from the pool. Will block
// and wait for one to be created if necessary
static GLuint AcquireTexture();
// Called by the active LayerManagerOGL to fill
// the pool
static void Fill(GLContext* aContext);
static GLContext* GetGLContext();
// Initializes the pool, but does not fill it. Called by gfxPlatform init.
static void Init();
// Clears all internal data structures in preparation for shutdown
static void Shutdown();
private:
// These methods are used to refill textures to avoid pool becomes dry
static void MaybeFillTextures();
};
} // namespace gl
} // namespace mozilla
#endif // GFX_TEXTUREPOOLOGL_H

Просмотреть файл

@ -92,10 +92,6 @@
#include "GLContextProvider.h"
#include "mozilla/gfx/Logging.h"
#ifdef MOZ_WIDGET_ANDROID
#include "TexturePoolOGL.h"
#endif
#ifdef USE_SKIA
# ifdef __GNUC__
# pragma GCC diagnostic push
@ -820,11 +816,6 @@ gfxPlatform::Init()
GLContext::PlatformStartup();
#ifdef MOZ_WIDGET_ANDROID
// Texture pool init
TexturePoolOGL::Init();
#endif
Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording");
CreateCMSOutputProfile();
@ -977,11 +968,6 @@ gfxPlatform::Shutdown()
gPlatform->mVsyncSource = nullptr;
#ifdef MOZ_WIDGET_ANDROID
// Shut down the texture pool
TexturePoolOGL::Shutdown();
#endif
// Shut down the default GL context provider.
GLContextProvider::Shutdown();