Backed out changeset 56d4cef7ed00 (bug 880114) for m5 test failures

This commit is contained in:
Carsten "Tomcat" Book 2014-11-07 10:47:08 +01:00
parent ed7406f9ec
commit 9dd12e4e93
5 changed files with 1 additions and 161 deletions

View File

@ -116,7 +116,6 @@
#include "SkiaGLGlue.h"
#ifdef USE_SKIA
#include "SurfaceTypes.h"
#include "GLBlitHelper.h"
#endif
using mozilla::gl::GLContext;
@ -820,9 +819,6 @@ DrawTarget* CanvasRenderingContext2D::sErrorTarget = nullptr;
CanvasRenderingContext2D::CanvasRenderingContext2D()
: mRenderingMode(RenderingMode::OpenGLBackendMode)
#ifdef USE_SKIA_GPU
, mVideoTexture(0)
#endif
// these are the default values from the Canvas spec
, mWidth(0), mHeight(0)
, mZero(false), mOpaque(false)
@ -853,12 +849,6 @@ CanvasRenderingContext2D::~CanvasRenderingContext2D()
if (!sNumLivingContexts) {
NS_IF_RELEASE(sErrorTarget);
}
#ifdef USE_SKIA_GPU
if (mVideoTexture) {
MOZ_ASSERT(gfxPlatform::GetPlatform()->GetSkiaGLGlue(), "null SkiaGLGlue");
gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->fDeleteTextures(1, &mVideoTexture);
}
#endif
RemoveDemotableContext(this);
}
@ -1059,16 +1049,6 @@ bool CanvasRenderingContext2D::SwitchRenderingMode(RenderingMode aRenderingMode)
return false;
}
#ifdef USE_SKIA_GPU
if (mRenderingMode == RenderingMode::OpenGLBackendMode) {
if (mVideoTexture) {
gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext()->fDeleteTextures(1, &mVideoTexture);
}
mCurrentVideoSize.width = 0;
mCurrentVideoSize.height = 0;
}
#endif
RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
RefPtr<DrawTarget> oldTarget = mTarget;
mTarget = nullptr;
@ -1233,7 +1213,7 @@ CanvasRenderingContext2D::EnsureTarget(RenderingMode aRenderingMode)
}
if (layerManager) {
if (mode == RenderingMode::OpenGLBackendMode/* && CheckSizeForSkiaGL(size)*/) {
if (mode == RenderingMode::OpenGLBackendMode && CheckSizeForSkiaGL(size)) {
DemoteOldestContextIfNecessary();
SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
@ -4005,93 +3985,6 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
nsLayoutUtils::DirectDrawInfo drawInfo;
#ifdef USE_SKIA_GPU
if (mRenderingMode == RenderingMode::OpenGLBackendMode &&
!srcSurf &&
image.IsHTMLVideoElement() &&
gfxPlatform::GetPlatform()->GetSkiaGLGlue()) {
mozilla::gl::GLContext* gl = gfxPlatform::GetPlatform()->GetSkiaGLGlue()->GetGLContext();
HTMLVideoElement* video = &image.GetAsHTMLVideoElement();
if (!video) {
return;
}
uint16_t readyState;
if (NS_SUCCEEDED(video->GetReadyState(&readyState)) &&
readyState < nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA) {
// still loading, just return
return;
}
// If it doesn't have a principal, just bail
nsCOMPtr<nsIPrincipal> principal = video->GetCurrentPrincipal();
if (!principal) {
error.Throw(NS_ERROR_NOT_AVAILABLE);
return;
}
mozilla::layers::ImageContainer* container = video->GetImageContainer();
if (!container) {
error.Throw(NS_ERROR_NOT_AVAILABLE);
return;
}
nsRefPtr<mozilla::layers::Image> srcImage = container->LockCurrentImage();
if (!srcImage) {
error.Throw(NS_ERROR_NOT_AVAILABLE);
return;
}
gl->MakeCurrent();
if (!mVideoTexture) {
gl->fGenTextures(1, &mVideoTexture);
}
// skiaGL expect upload on drawing, and uses texture 0 for texturing,
// so we must active texture 0 and bind the texture for it.
gl->fActiveTexture(LOCAL_GL_TEXTURE0);
gl->fBindTexture(LOCAL_GL_TEXTURE_2D, mVideoTexture);
bool dimensionsMatch = mCurrentVideoSize.width == srcImage->GetSize().width &&
mCurrentVideoSize.height == srcImage->GetSize().height;
if (!dimensionsMatch) {
// we need to allocation
mCurrentVideoSize.width = srcImage->GetSize().width;
mCurrentVideoSize.height = srcImage->GetSize().height;
gl->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGB, srcImage->GetSize().width, srcImage->GetSize().height, 0, LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_SHORT_5_6_5, nullptr);
gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
}
bool ok = gl->BlitHelper()->BlitImageToTexture(srcImage.get(), srcImage->GetSize(), mVideoTexture, LOCAL_GL_TEXTURE_2D, 1);
if (ok) {
NativeSurface texSurf;
texSurf.mType = NativeSurfaceType::OPENGL_TEXTURE;
texSurf.mFormat = SurfaceFormat::R5G6B5;
texSurf.mSize.width = mCurrentVideoSize.width;
texSurf.mSize.height = mCurrentVideoSize.height;
texSurf.mSurface = (void*)((uintptr_t)mVideoTexture);
srcSurf = mTarget->CreateSourceSurfaceFromNativeSurface(texSurf);
imgSize.width = mCurrentVideoSize.width;
imgSize.height = mCurrentVideoSize.height;
}
srcImage = nullptr;
container->UnlockCurrentImage();
if (mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement,
principal, false,
video->GetCORSMode() != CORS_NONE);
}
int32_t displayWidth = video->VideoWidth();
int32_t displayHeight = video->VideoHeight();
sw *= (double)imgSize.width / (double)displayWidth;
sh *= (double)imgSize.height / (double)displayHeight;
}
#endif
if (!srcSurf) {
// The canvas spec says that drawImage should draw the first frame
// of animated images. We also don't want to rasterize vector images.

View File

@ -744,10 +744,6 @@ protected:
RenderingMode mRenderingMode;
// Texture informations for fast video rendering
unsigned int mVideoTexture;
nsIntSize mCurrentVideoSize;
// Member vars
int32_t mWidth, mHeight;

View File

@ -687,15 +687,6 @@ DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurfa
}
cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
return new SourceSurfaceCairo(surf, aSurface.mSize, aSurface.mFormat);
#if USE_SKIA_GPU
} else if (aSurface.mType == NativeSurfaceType::OPENGL_TEXTURE) {
RefPtr<SourceSurfaceSkia> newSurf = new SourceSurfaceSkia();
unsigned int texture = (unsigned int)((uintptr_t)aSurface.mSurface);
if (UsingSkiaGPU() && newSurf->InitFromTexture((DrawTargetSkia*)this, texture, aSurface.mSize, aSurface.mFormat)) {
return newSurf;
}
return nullptr;
#endif
}
return nullptr;

View File

@ -11,7 +11,6 @@
#include "HelpersSkia.h"
#include "DrawTargetSkia.h"
#include "DataSurfaceHelpers.h"
#include "skia/SkGrPixelRef.h"
namespace mozilla {
namespace gfx {
@ -50,7 +49,6 @@ SourceSurfaceSkia::InitFromCanvas(SkCanvas* aCanvas,
SkISize size = aCanvas->getDeviceSize();
mBitmap = (SkBitmap)aCanvas->getDevice()->accessBitmap(false);
mFormat = aFormat;
mSize = IntSize(size.fWidth, size.fHeight);
@ -91,32 +89,6 @@ SourceSurfaceSkia::InitFromData(unsigned char* aData,
return true;
}
bool
SourceSurfaceSkia::InitFromTexture(DrawTargetSkia* aOwner,
unsigned int aTexture,
const IntSize &aSize,
SurfaceFormat aFormat)
{
MOZ_ASSERT(aOwner, "null GrContext");
GrBackendTextureDesc skiaTexGlue;
mSize.width = skiaTexGlue.fWidth = aSize.width;
mSize.height = skiaTexGlue.fHeight = aSize.height;
skiaTexGlue.fFlags = kNone_GrBackendTextureFlag;
skiaTexGlue.fOrigin = kBottomLeft_GrSurfaceOrigin;
skiaTexGlue.fConfig = GfxFormatToGrConfig(aFormat);
skiaTexGlue.fSampleCnt = 0;
skiaTexGlue.fTextureHandle = aTexture;
GrTexture *skiaTexture = aOwner->mGrContext->wrapBackendTexture(skiaTexGlue);
SkImageInfo imgInfo = SkImageInfo::Make(aSize.width, aSize.height, GfxFormatToSkiaColorType(aFormat), kOpaque_SkAlphaType);
SkGrPixelRef *texRef = new SkGrPixelRef(imgInfo, skiaTexture, false);
mBitmap.setInfo(imgInfo, aSize.width*aSize.height*4);
mBitmap.setPixelRef(texRef);
mDrawTarget = aOwner;
return true;
}
unsigned char*
SourceSurfaceSkia::GetData()
{

View File

@ -11,10 +11,7 @@
#include "skia/SkCanvas.h"
#include "skia/SkBitmap.h"
class GrContext;
namespace mozilla {
namespace gfx {
class DrawTargetSkia;
@ -41,15 +38,6 @@ public:
SurfaceFormat aFormat,
DrawTargetSkia* aOwner);
/**
* NOTE: While wrapping a Texture for SkiaGL, the texture *must* be created
* with the same GLcontext of DrawTargetSkia
*/
bool InitFromTexture(DrawTargetSkia* aOwner,
unsigned int aTexture,
const IntSize &aSize,
SurfaceFormat aFormat);
virtual unsigned char *GetData();
virtual int32_t Stride() { return mStride; }