Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tommy Webb
Tor Browser
Commits
f715a46d
Commit
f715a46d
authored
11 years ago
by
Steven Michaud
Browse files
Options
Downloads
Patches
Plain Diff
Bug 925448 - Stop CGImageRef external data being deleted prematurely. r=bgirard,bas a=bajaj
parent
2463a489
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gfx/2d/SourceSurfaceCG.cpp
+3
-20
3 additions, 20 deletions
gfx/2d/SourceSurfaceCG.cpp
gfx/2d/SourceSurfaceCG.h
+17
-0
17 additions, 0 deletions
gfx/2d/SourceSurfaceCG.h
with
20 additions
and
20 deletions
gfx/2d/SourceSurfaceCG.cpp
+
3
−
20
View file @
f715a46d
...
...
@@ -278,21 +278,8 @@ void SourceSurfaceCGBitmapContext::EnsureImage() const
// memcpy when the bitmap context is modified gives us more predictable
// performance characteristics.
if
(
!
mImage
)
{
void
*
info
;
if
(
mCg
)
{
// if we have an mCg than it owns the data
// and we don't want to tranfer ownership
// to the CGDataProviderCreateWithData
info
=
nullptr
;
}
else
{
// otherwise we transfer ownership to
// the dataProvider
info
=
mData
;
}
if
(
!
mData
)
abort
();
mImage
=
CreateCGImage
(
info
,
mData
,
mSize
,
mStride
,
mFormat
);
mImage
=
CreateCGImage
(
nullptr
,
mData
,
mSize
,
mStride
,
mFormat
);
}
}
...
...
@@ -310,8 +297,8 @@ SourceSurfaceCGBitmapContext::DrawTargetWillChange()
size_t
stride
=
CGBitmapContextGetBytesPerRow
(
mCg
);
size_t
height
=
CGBitmapContextGetHeight
(
mCg
);
//XXX: infalliable malloc?
mData
=
m
alloc
(
stride
*
height
)
;
mDataHolder
.
Realloc
(
stride
*
height
);
mData
=
m
DataHolder
;
// copy out the data from the CGBitmapContext
// we'll maintain ownership of mData until
...
...
@@ -330,10 +317,6 @@ SourceSurfaceCGBitmapContext::DrawTargetWillChange()
SourceSurfaceCGBitmapContext
::~
SourceSurfaceCGBitmapContext
()
{
if
(
!
mImage
&&
!
mCg
)
{
// neither mImage or mCg owns the data
free
(
mData
);
}
if
(
mImage
)
CGImageRelease
(
mImage
);
}
...
...
This diff is collapsed.
Click to expand it.
gfx/2d/SourceSurfaceCG.h
+
17
−
0
View file @
f715a46d
...
...
@@ -94,6 +94,20 @@ public:
virtual
SurfaceType
GetType
()
const
{
return
SURFACE_COREGRAPHICS_CGCONTEXT
;
}
virtual
IntSize
GetSize
()
const
;
virtual
SurfaceFormat
GetFormat
()
const
{
return
mFormat
;
}
virtual
TemporaryRef
<
DataSourceSurface
>
GetDataSurface
()
{
// This call to DrawTargetWillChange() is needed to make a local copy of
// the data from mDrawTarget. If we don't do that, the data can end up
// getting deleted before the CGImageRef it belongs to.
//
// Another reason we need a local copy of the data is that the data in
// mDrawTarget could change when someone touches the original DrawTargetCG
// object. But a SourceSurface object should be immutable.
//
// For more information see bug 925448.
DrawTargetWillChange
();
return
this
;
}
CGImageRef
GetImage
()
{
EnsureImage
();
return
mImage
;
}
...
...
@@ -119,6 +133,9 @@ private:
// mImage, mCg or SourceSurfaceCGBitmapContext
void
*
mData
;
// The image buffer, if the buffer is owned by this class.
AlignedArray
<
uint8_t
>
mDataHolder
;
int32_t
mStride
;
IntSize
mSize
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment