зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1176363
- Make a raw copy of each Canvas::CaptureStream frame. r=mattwoodrow
--HG-- extra : rebase_source : 0658dae3991f6839d93aa3a7d4165330307b74a5
This commit is contained in:
Родитель
17358b10b8
Коммит
ba79b7b3e4
|
@ -8,9 +8,10 @@
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "MediaStreamGraph.h"
|
#include "MediaStreamGraph.h"
|
||||||
#include "mozilla/Mutex.h"
|
|
||||||
#include "mozilla/dom/CanvasCaptureMediaStreamBinding.h"
|
#include "mozilla/dom/CanvasCaptureMediaStreamBinding.h"
|
||||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||||
|
#include "mozilla/gfx/2D.h"
|
||||||
|
#include "mozilla/Mutex.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
|
||||||
using namespace mozilla::layers;
|
using namespace mozilla::layers;
|
||||||
|
@ -204,15 +205,42 @@ public:
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<SourceSurface> opt = gfxPlatform::GetPlatform()
|
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
|
||||||
->ScreenReferenceDrawTarget()->OptimizeSourceSurface(snapshot);
|
if (!data) {
|
||||||
if (!opt) {
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<DataSourceSurface> copy;
|
||||||
|
|
||||||
|
{
|
||||||
|
DataSourceSurface::ScopedMap read(data, DataSourceSurface::READ);
|
||||||
|
if (!read.IsMapped()) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
copy = Factory::CreateDataSourceSurfaceWithStride(data->GetSize(),
|
||||||
|
data->GetFormat(),
|
||||||
|
read.GetStride());
|
||||||
|
if (!copy) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataSourceSurface::ScopedMap write(copy, DataSourceSurface::WRITE);
|
||||||
|
if (!write.IsMapped()) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(read.GetStride() == write.GetStride());
|
||||||
|
MOZ_ASSERT(data->GetSize() == copy->GetSize());
|
||||||
|
MOZ_ASSERT(data->GetFormat() == copy->GetFormat());
|
||||||
|
|
||||||
|
memcpy(write.GetData(), read.GetData(),
|
||||||
|
write.GetStride() * copy->GetSize().height);
|
||||||
|
}
|
||||||
|
|
||||||
CairoImage::Data imageData;
|
CairoImage::Data imageData;
|
||||||
imageData.mSize = opt->GetSize();
|
imageData.mSize = copy->GetSize();
|
||||||
imageData.mSourceSurface = opt;
|
imageData.mSourceSurface = copy;
|
||||||
|
|
||||||
RefPtr<CairoImage> image = new layers::CairoImage();
|
RefPtr<CairoImage> image = new layers::CairoImage();
|
||||||
image->SetData(imageData);
|
image->SetData(imageData);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче