Fix ui/compositor/compositor.(h|cpp) based on http://crrev.com/738983002

Fix sky/engine based on current Blink code

R=qsr@chromium.org

Review URL: https://codereview.chromium.org/812543002
This commit is contained in:
Etienne Membrives 2014-12-16 13:56:09 +01:00
parent 1fb39d65dd
commit 404a0cc6db
12 changed files with 9 additions and 156 deletions

View File

@ -49,7 +49,6 @@
#include "sky/engine/core/rendering/style/RenderStyle.h"
#include "sky/engine/platform/geometry/FloatQuad.h"
#include "sky/engine/platform/geometry/TransformState.h"
#include "sky/engine/platform/graphics/GraphicsContextCullSaver.h"
#include "sky/engine/platform/graphics/GraphicsContextStateSaver.h"
#include "sky/engine/wtf/StdLibExtras.h"
#include "sky/engine/wtf/TemporaryChange.h"
@ -597,13 +596,6 @@ void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, contentsClipBehavior);
{
GraphicsContextCullSaver cullSaver(*paintInfo.context);
// Cull if we have more than one child and we didn't already clip.
bool shouldCull = document().settings()->containerCullingEnabled() && !pushedClip && !isDocumentElement()
&& firstChild() && lastChild() && firstChild() != lastChild();
if (shouldCull)
cullSaver.cull(overflowBox);
paintObject(paintInfo, adjustedPaintOffset);
}
if (pushedClip)

View File

@ -1471,25 +1471,6 @@ void GraphicsContext::clipRRect(const SkRRect& rect, AntiAliasingMode aa, SkRegi
m_canvas->clipRRect(rect, op, aa == AntiAliased);
}
void GraphicsContext::beginCull(const FloatRect& rect)
{
if (contextDisabled())
return;
realizeCanvasSave();
m_canvas->pushCull(rect);
}
void GraphicsContext::endCull()
{
if (contextDisabled())
return;
realizeCanvasSave();
m_canvas->popCull();
}
void GraphicsContext::rotate(float angleInRadians)
{
if (contextDisabled())

View File

@ -325,9 +325,6 @@ public:
void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, ColorFilter = ColorFilterNone, ImageFilter* = 0);
void endLayer();
void beginCull(const FloatRect&);
void endCull();
// Instead of being dispatched to the active canvas, draw commands following beginRecording()
// are stored in a display list that can be replayed at a later time.
void beginRecording(const FloatRect& bounds);

View File

@ -1,46 +0,0 @@
#ifndef GraphicsContextCullSaver_h
#define GraphicsContextCullSaver_h
#include "sky/engine/platform/graphics/GraphicsContext.h"
namespace blink {
class FloatRect;
class GraphicsContextCullSaver {
WTF_MAKE_FAST_ALLOCATED;
public:
GraphicsContextCullSaver(GraphicsContext& context)
: m_context(context)
, m_cullApplied(false)
{
}
GraphicsContextCullSaver(GraphicsContext& context, const FloatRect& rect)
: m_context(context)
, m_cullApplied(true)
{
context.beginCull(rect);
}
~GraphicsContextCullSaver()
{
if (m_cullApplied)
m_context.endCull();
}
void cull(const FloatRect& rect)
{
ASSERT(!m_cullApplied);
m_context.beginCull(rect);
m_cullApplied = true;
}
private:
GraphicsContext& m_context;
bool m_cullApplied;
};
} // namespace blink
#endif // GraphicsContextCullSaver_h

View File

@ -100,10 +100,9 @@ PassRefPtr<GraphicsContextSnapshot> GraphicsContextSnapshot::load(const char* da
PassOwnPtr<Vector<char> > GraphicsContextSnapshot::replay(unsigned fromStep, unsigned toStep, double scale) const
{
int width = ceil(scale * m_picture->width());
int height = ceil(scale * m_picture->height());
const SkIRect bounds = m_picture->cullRect().roundOut();
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height));
bitmap.allocPixels(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height()));
{
ReplayingCanvas canvas(bitmap, fromStep, toStep);
canvas.scale(scale, scale);
@ -122,8 +121,9 @@ PassOwnPtr<GraphicsContextSnapshot::Timings> GraphicsContextSnapshot::profile(un
{
OwnPtr<GraphicsContextSnapshot::Timings> timings = adoptPtr(new GraphicsContextSnapshot::Timings());
timings->reserveCapacity(minRepeatCount);
const SkIRect bounds = m_picture->cullRect().roundOut();
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(m_picture->width(), m_picture->height()));
bitmap.allocPixels(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height()));
OwnPtr<ProfilingCanvas> canvas = adoptPtr(new ProfilingCanvas(bitmap));
double now = WTF::monotonicallyIncreasingTime();
@ -144,7 +144,8 @@ PassOwnPtr<GraphicsContextSnapshot::Timings> GraphicsContextSnapshot::profile(un
PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog() const
{
LoggingCanvas canvas(m_picture->width(), m_picture->height());
const SkIRect bounds = m_picture->cullRect().roundOut();
LoggingCanvas canvas(bounds.width(), bounds.height());
m_picture->draw(&canvas);
return canvas.log();
}

View File

@ -48,7 +48,6 @@ public:
virtual void drawPath(const SkPath&, const SkPaint&) override = 0;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* = 0) override = 0;
virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, DrawBitmapRectFlags) override = 0;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, const SkPaint* = 0) override = 0;
virtual void drawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, const SkPaint*) override = 0;
virtual void drawSprite(const SkBitmap&, int left, int top, const SkPaint* = 0) override = 0;
virtual void drawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[],
@ -63,8 +62,6 @@ public:
virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&) override = 0;
virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint&) override = 0;
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*, const SkPaint&) override = 0;
virtual void onPushCull(const SkRect& cullRect) override = 0;
virtual void onPopCull() override = 0;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override = 0;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override = 0;
virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override = 0;

View File

@ -160,16 +160,6 @@ void LoggingCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* s
this->SkCanvas::drawBitmapRectToRect(bitmap, src, dst, paint, flags);
}
void LoggingCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, const SkPaint* paint)
{
AutoLogger logger(this);
RefPtr<JSONObject> params = logger.logItemWithParams("drawBitmapMatrix");
params->setObject("bitmap", objectForSkBitmap(bitmap));
params->setArray("matrix", arrayForSkMatrix(m));
params->setObject("paint", objectForSkPaint(*paint));
this->SkCanvas::drawBitmapMatrix(bitmap, m, paint);
}
void LoggingCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, const SkPaint* paint)
{
AutoLogger logger(this);
@ -288,21 +278,6 @@ void LoggingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const
this->SkCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
void LoggingCanvas::onPushCull(const SkRect& cullRect)
{
AutoLogger logger(this);
RefPtr<JSONObject> params = logger.logItemWithParams("pushCull");
params->setObject("cullRect", objectForSkRect(cullRect));
this->SkCanvas::onPushCull(cullRect);
}
void LoggingCanvas::onPopCull()
{
AutoLogger logger(this);
logger.logItem("popCull");
this->SkCanvas::onPopCull();
}
void LoggingCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle style)
{
AutoLogger logger(this);
@ -461,9 +436,10 @@ PassRefPtr<JSONArray> LoggingCanvas::arrayForSkPoints(size_t count, const SkPoin
PassRefPtr<JSONObject> LoggingCanvas::objectForSkPicture(const SkPicture& picture)
{
const SkIRect bounds = picture.cullRect().roundOut();
RefPtr<JSONObject> pictureItem = JSONObject::create();
pictureItem->setNumber("width", picture.width());
pictureItem->setNumber("height", picture.height());
pictureItem->setNumber("width", bounds.width());
pictureItem->setNumber("height", bounds.height());
return pictureItem.release();
}

View File

@ -49,7 +49,6 @@ public:
virtual void drawPath(const SkPath&, const SkPaint&) override;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* = 0) override;
virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, DrawBitmapRectFlags) override;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, const SkPaint* = 0) override;
virtual void drawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, const SkPaint*) override;
virtual void drawSprite(const SkBitmap&, int left, int top, const SkPaint* = 0) override;
virtual void drawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[],
@ -64,8 +63,6 @@ public:
virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&) override;
virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint&) override;
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*, const SkPaint&) override;
virtual void onPushCull(const SkRect& cullRect) override;
virtual void onPopCull() override;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;

View File

@ -118,12 +118,6 @@ void ProfilingCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
this->SkCanvas::drawBitmapRectToRect(bitmap, src, dst, paint, flags);
}
void ProfilingCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, const SkPaint* paint)
{
AutoStamper stamper(this);
this->SkCanvas::drawBitmapMatrix(bitmap, m, paint);
}
void ProfilingCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, const SkPaint* paint)
{
AutoStamper stamper(this);
@ -197,18 +191,6 @@ void ProfilingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, cons
this->SkCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
void ProfilingCanvas::onPushCull(const SkRect& cullRect)
{
AutoStamper stamper(this);
this->SkCanvas::onPushCull(cullRect);
}
void ProfilingCanvas::onPopCull()
{
AutoStamper stamper(this);
this->SkCanvas::onPopCull();
}
void ProfilingCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle)
{
AutoStamper stamper(this);

View File

@ -49,7 +49,6 @@ public:
virtual void drawPath(const SkPath&, const SkPaint&) override;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* = 0) override;
virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, DrawBitmapRectFlags) override;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, const SkPaint* = 0) override;
virtual void drawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, const SkPaint*) override;
virtual void drawSprite(const SkBitmap&, int left, int top, const SkPaint* = 0) override;
virtual void drawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[],
@ -64,8 +63,6 @@ public:
virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&) override;
virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint&) override;
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*, const SkPaint&) override;
virtual void onPushCull(const SkRect& cullRect) override;
virtual void onPopCull() override;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;

View File

@ -132,12 +132,6 @@ void ReplayingCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
this->SkCanvas::drawBitmapRectToRect(bitmap, src, dst, paint, flags);
}
void ReplayingCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, const SkPaint* paint)
{
AutoReplayer replayer(this);
this->SkCanvas::drawBitmapMatrix(bitmap, m, paint);
}
void ReplayingCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, const SkPaint* paint)
{
AutoReplayer replayer(this);
@ -211,18 +205,6 @@ void ReplayingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, cons
this->SkCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
void ReplayingCanvas::onPushCull(const SkRect& cullRect)
{
AutoReplayer replayer(this);
this->SkCanvas::onPushCull(cullRect);
}
void ReplayingCanvas::onPopCull()
{
AutoReplayer replayer(this);
this->SkCanvas::onPopCull();
}
void ReplayingCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle)
{
AutoReplayer replayer(this);

View File

@ -51,7 +51,6 @@ public:
virtual void drawPath(const SkPath&, const SkPaint&) override;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* = 0) override;
virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, DrawBitmapRectFlags) override;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, const SkPaint* = 0) override;
virtual void drawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, const SkPaint*) override;
virtual void drawSprite(const SkBitmap&, int left, int top, const SkPaint* = 0) override;
virtual void drawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[],
@ -66,8 +65,6 @@ public:
virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&) override;
virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint&) override;
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*, const SkPaint&) override;
virtual void onPushCull(const SkRect& cullRect) override;
virtual void onPopCull() override;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;