mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
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:
parent
9b1c422ff4
commit
2853ef8068
@ -85,23 +85,33 @@ class DataSourceSurfaceRecording : public DataSourceSurface {
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DataSourceSurfaceRecording, override)
|
||||
DataSourceSurfaceRecording(UniquePtr<uint8_t[]> aData, IntSize aSize,
|
||||
int32_t aStride, SurfaceFormat aFormat)
|
||||
int32_t aStride, SurfaceFormat aFormat,
|
||||
DrawEventRecorderPrivate* aRecorder)
|
||||
: mData(std::move(aData)),
|
||||
mSize(aSize),
|
||||
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,
|
||||
int32_t aStride,
|
||||
SurfaceFormat aFormat) {
|
||||
static already_AddRefed<DataSourceSurface> Init(
|
||||
uint8_t* aData, IntSize aSize, int32_t aStride, SurfaceFormat aFormat,
|
||||
DrawEventRecorderPrivate* aRecorder) {
|
||||
// XXX: do we need to ensure any alignment here?
|
||||
auto data = MakeUnique<uint8_t[]>(aStride * aSize.height);
|
||||
if (data) {
|
||||
memcpy(data.get(), aData, aStride * aSize.height);
|
||||
RefPtr<DataSourceSurfaceRecording> surf = new DataSourceSurfaceRecording(
|
||||
std::move(data), aSize, aStride, aFormat);
|
||||
std::move(data), aSize, aStride, aFormat, aRecorder);
|
||||
return surf.forget();
|
||||
}
|
||||
return nullptr;
|
||||
@ -117,6 +127,7 @@ class DataSourceSurfaceRecording : public DataSourceSurface {
|
||||
IntSize mSize;
|
||||
int32_t mStride;
|
||||
SurfaceFormat mFormat;
|
||||
RefPtr<DrawEventRecorderPrivate> mRecorder;
|
||||
};
|
||||
|
||||
class GradientStopsRecording : public GradientStops {
|
||||
@ -486,16 +497,9 @@ DrawTargetRecording::CreateSourceSurfaceFromData(unsigned char* aData,
|
||||
const IntSize& aSize,
|
||||
int32_t aStride,
|
||||
SurfaceFormat aFormat) const {
|
||||
RefPtr<SourceSurface> surf =
|
||||
DataSourceSurfaceRecording::Init(aData, aSize, aStride, aFormat);
|
||||
|
||||
RefPtr<SourceSurface> retSurf =
|
||||
new SourceSurfaceRecording(aSize, aFormat, mRecorder);
|
||||
|
||||
mRecorder->RecordEvent(
|
||||
RecordedSourceSurfaceCreation(retSurf, aData, aStride, aSize, aFormat));
|
||||
|
||||
return retSurf.forget();
|
||||
RefPtr<SourceSurface> surf = DataSourceSurfaceRecording::Init(
|
||||
aData, aSize, aStride, aFormat, mRecorder);
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface> DrawTargetRecording::OptimizeSourceSurface(
|
||||
|
Loading…
Reference in New Issue
Block a user