mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1176363
- Make a raw copy of each Canvas::CaptureStream frame. r=mattwoodrow
--HG-- extra : rebase_source : 0658dae3991f6839d93aa3a7d4165330307b74a5
This commit is contained in:
parent
17358b10b8
commit
ba79b7b3e4
@ -8,9 +8,10 @@
|
||||
#include "gfxPlatform.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/dom/CanvasCaptureMediaStreamBinding.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using namespace mozilla::layers;
|
||||
@ -204,15 +205,42 @@ public:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> opt = gfxPlatform::GetPlatform()
|
||||
->ScreenReferenceDrawTarget()->OptimizeSourceSurface(snapshot);
|
||||
if (!opt) {
|
||||
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
|
||||
if (!data) {
|
||||
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;
|
||||
imageData.mSize = opt->GetSize();
|
||||
imageData.mSourceSurface = opt;
|
||||
imageData.mSize = copy->GetSize();
|
||||
imageData.mSourceSurface = copy;
|
||||
|
||||
RefPtr<CairoImage> image = new layers::CairoImage();
|
||||
image->SetData(imageData);
|
||||
|
Loading…
Reference in New Issue
Block a user