зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1464032 Part 11: Make SourceSurface from DrawTargetRecording::CreateSourceSurfaceFromData hold its data. r=jrmuizel
This means that GetData on the returned SourceSurface will function correctly.
This commit is contained in:
Родитель
9b1c422ff4
Коммит
2853ef8068
|
@ -85,23 +85,33 @@ class DataSourceSurfaceRecording : public DataSourceSurface {
|
||||||
public:
|
public:
|
||||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceRecording, override)
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceRecording, override)
|
||||||
DataSourceSurfaceRecording(UniquePtr<uint8_t[]> aData, IntSize aSize,
|
DataSourceSurfaceRecording(UniquePtr<uint8_t[]> aData, IntSize aSize,
|
||||||
int32_t aStride, SurfaceFormat aFormat)
|
int32_t aStride, SurfaceFormat aFormat,
|
||||||
|
DrawEventRecorderPrivate* aRecorder)
|
||||||
: mData(std::move(aData)),
|
: mData(std::move(aData)),
|
||||||
mSize(aSize),
|
mSize(aSize),
|
||||||
mStride(aStride),
|
mStride(aStride),
|
||||||
mFormat(aFormat) {}
|
mFormat(aFormat),
|
||||||
|
mRecorder(aRecorder) {
|
||||||
|
mRecorder->RecordEvent(RecordedSourceSurfaceCreation(
|
||||||
|
ReferencePtr(this), mData.get(), mStride, mSize, mFormat));
|
||||||
|
mRecorder->AddStoredObject(this);
|
||||||
|
}
|
||||||
|
|
||||||
~DataSourceSurfaceRecording() {}
|
~DataSourceSurfaceRecording() {
|
||||||
|
mRecorder->RemoveStoredObject(this);
|
||||||
|
mRecorder->RecordEvent(
|
||||||
|
RecordedSourceSurfaceDestruction(ReferencePtr(this)));
|
||||||
|
}
|
||||||
|
|
||||||
static already_AddRefed<DataSourceSurface> Init(uint8_t* aData, IntSize aSize,
|
static already_AddRefed<DataSourceSurface> Init(
|
||||||
int32_t aStride,
|
uint8_t* aData, IntSize aSize, int32_t aStride, SurfaceFormat aFormat,
|
||||||
SurfaceFormat aFormat) {
|
DrawEventRecorderPrivate* aRecorder) {
|
||||||
// XXX: do we need to ensure any alignment here?
|
// XXX: do we need to ensure any alignment here?
|
||||||
auto data = MakeUnique<uint8_t[]>(aStride * aSize.height);
|
auto data = MakeUnique<uint8_t[]>(aStride * aSize.height);
|
||||||
if (data) {
|
if (data) {
|
||||||
memcpy(data.get(), aData, aStride * aSize.height);
|
memcpy(data.get(), aData, aStride * aSize.height);
|
||||||
RefPtr<DataSourceSurfaceRecording> surf = new DataSourceSurfaceRecording(
|
RefPtr<DataSourceSurfaceRecording> surf = new DataSourceSurfaceRecording(
|
||||||
std::move(data), aSize, aStride, aFormat);
|
std::move(data), aSize, aStride, aFormat, aRecorder);
|
||||||
return surf.forget();
|
return surf.forget();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -117,6 +127,7 @@ class DataSourceSurfaceRecording : public DataSourceSurface {
|
||||||
IntSize mSize;
|
IntSize mSize;
|
||||||
int32_t mStride;
|
int32_t mStride;
|
||||||
SurfaceFormat mFormat;
|
SurfaceFormat mFormat;
|
||||||
|
RefPtr<DrawEventRecorderPrivate> mRecorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GradientStopsRecording : public GradientStops {
|
class GradientStopsRecording : public GradientStops {
|
||||||
|
@ -486,16 +497,9 @@ DrawTargetRecording::CreateSourceSurfaceFromData(unsigned char* aData,
|
||||||
const IntSize& aSize,
|
const IntSize& aSize,
|
||||||
int32_t aStride,
|
int32_t aStride,
|
||||||
SurfaceFormat aFormat) const {
|
SurfaceFormat aFormat) const {
|
||||||
RefPtr<SourceSurface> surf =
|
RefPtr<SourceSurface> surf = DataSourceSurfaceRecording::Init(
|
||||||
DataSourceSurfaceRecording::Init(aData, aSize, aStride, aFormat);
|
aData, aSize, aStride, aFormat, mRecorder);
|
||||||
|
return surf.forget();
|
||||||
RefPtr<SourceSurface> retSurf =
|
|
||||||
new SourceSurfaceRecording(aSize, aFormat, mRecorder);
|
|
||||||
|
|
||||||
mRecorder->RecordEvent(
|
|
||||||
RecordedSourceSurfaceCreation(retSurf, aData, aStride, aSize, aFormat));
|
|
||||||
|
|
||||||
return retSurf.forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<SourceSurface> DrawTargetRecording::OptimizeSourceSurface(
|
already_AddRefed<SourceSurface> DrawTargetRecording::OptimizeSourceSurface(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче