summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/port/platform/graphics/ImageBufferSkia.cpp3
-rw-r--r--webkit/port/platform/graphics/PlatformContextSkia.cpp9
-rw-r--r--webkit/port/platform/graphics/PlatformContextSkia.h8
3 files changed, 14 insertions, 6 deletions
diff --git a/webkit/port/platform/graphics/ImageBufferSkia.cpp b/webkit/port/platform/graphics/ImageBufferSkia.cpp
index 9b14c05..42e9a9f 100644
--- a/webkit/port/platform/graphics/ImageBufferSkia.cpp
+++ b/webkit/port/platform/graphics/ImageBufferSkia.cpp
@@ -48,7 +48,7 @@ namespace WebCore {
// the ownership easier to manage.
ImageBufferData::ImageBufferData(const IntSize& size)
: m_canvas()
- , m_platformContext(&m_canvas)
+ , m_platformContext(NULL) // Canvas is set in ImageBuffer constructor.
{
}
@@ -61,6 +61,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
return;
}
+ m_data.m_platformContext.setCanvas(&m_data.m_canvas);
m_context.set(new GraphicsContext(&m_data.m_platformContext));
// Make the background transparent. It would be nice if this wasn't
diff --git a/webkit/port/platform/graphics/PlatformContextSkia.cpp b/webkit/port/platform/graphics/PlatformContextSkia.cpp
index 351e8ea..dd50cb0 100644
--- a/webkit/port/platform/graphics/PlatformContextSkia.cpp
+++ b/webkit/port/platform/graphics/PlatformContextSkia.cpp
@@ -138,9 +138,7 @@ SkColor PlatformContextSkia::State::applyAlpha(SkColor c) const
// PlatformContextSkia ---------------------------------------------------------
-// Danger: the canvas is not guaranteed to be initialized yet, so we can't use
-// it in the constructor. In ImageBufferSkia, we pass a canvas in here that will
-// be initialized at a later phase.
+// Danger: canvas can be NULL.
PlatformContextSkia::PlatformContextSkia(gfx::PlatformCanvas* canvas)
: m_canvas(canvas)
, m_stateStack(sizeof(State))
@@ -153,6 +151,11 @@ PlatformContextSkia::~PlatformContextSkia()
{
}
+void PlatformContextSkia::setCanvas(gfx::PlatformCanvas* canvas)
+{
+ m_canvas = canvas;
+}
+
void PlatformContextSkia::save()
{
m_stateStack.append(*m_state);
diff --git a/webkit/port/platform/graphics/PlatformContextSkia.h b/webkit/port/platform/graphics/PlatformContextSkia.h
index ecc56020..a0c72e0 100644
--- a/webkit/port/platform/graphics/PlatformContextSkia.h
+++ b/webkit/port/platform/graphics/PlatformContextSkia.h
@@ -59,12 +59,16 @@
// state to be pushed and popped along with the bitmap.
class PlatformContextSkia {
public:
- // For printing, there shouldn't be any canvas. canvas can be NULL.
+ // For printing, there shouldn't be any canvas. canvas can be NULL. If you
+ // supply a NULL canvas, you can also call setCanvas later.
PlatformContextSkia(gfx::PlatformCanvas* canvas);
~PlatformContextSkia();
- void save();
+ // Sets the canvas associated with this context. Use when supplying NULL
+ // to the constructor.
+ void setCanvas(gfx::PlatformCanvas* canvas);
+ void save();
void restore();
// Sets up the common flags on a paint for antialiasing, effects, etc.