Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Unified Diff: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
index b7f8fa6918fe10df157761bd6d1bfae7ec446c6d..b749e8828bf1bc5a3f052884f05c55c182a165cb 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
@@ -34,14 +34,14 @@
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/Path.h"
#include "platform/graphics/paint/PaintController.h"
+#include "platform/graphics/paint/PaintRecord.h"
+#include "platform/graphics/paint/PaintRecorder.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
#include "platform/weborigin/KURL.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkAnnotation.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkData.h"
-#include "third_party/skia/include/core/SkPicture.h"
-#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/effects/SkLumaColorFilter.h"
@@ -81,8 +81,10 @@ GraphicsContext::GraphicsContext(PaintController& paintController,
m_paintState = m_paintStateStack.back().get();
if (contextDisabled()) {
- DEFINE_STATIC_LOCAL(SkCanvas*, nullCanvas, (SkMakeNullCanvas().release()));
- m_canvas = nullCanvas;
+ DEFINE_STATIC_LOCAL(SkCanvas*, nullSkCanvas,
+ (SkMakeNullCanvas().release()));
+ DEFINE_STATIC_LOCAL(PaintCanvasPassThrough, nullCanvas, (nullSkCanvas));
+ m_canvas = &nullCanvas;
}
}
@@ -140,12 +142,11 @@ unsigned GraphicsContext::saveCount() const {
}
#endif
-void GraphicsContext::saveLayer(const SkRect* bounds, const SkPaint* paint) {
+void GraphicsContext::saveLayer(const SkRect* bounds, const PaintFlags* paint) {
if (contextDisabled())
return;
ASSERT(m_canvas);
-
m_canvas->saveLayer(bounds, paint);
}
@@ -233,7 +234,7 @@ void GraphicsContext::beginLayer(float opacity,
if (contextDisabled())
return;
- SkPaint layerPaint;
+ PaintFlags layerPaint;
layerPaint.setAlpha(static_cast<unsigned char>(opacity * 255));
layerPaint.setBlendMode(xfermode);
layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter));
@@ -274,29 +275,30 @@ void GraphicsContext::beginRecording(const FloatRect& bounds) {
namespace {
-sk_sp<SkPicture> createEmptyPicture() {
- SkPictureRecorder recorder;
+sk_sp<PaintRecord> createEmptyPicture() {
+ PaintRecorder recorder;
recorder.beginRecording(SkRect::MakeEmpty(), nullptr);
return recorder.finishRecordingAsPicture();
}
} // anonymous namespace
-sk_sp<SkPicture> GraphicsContext::endRecording() {
+sk_sp<PaintRecord> GraphicsContext::endRecording() {
if (contextDisabled()) {
// Clients expect endRecording() to always return a non-null picture.
// Cache an empty SKP to minimize overhead when disabled.
- DEFINE_STATIC_LOCAL(sk_sp<SkPicture>, emptyPicture, (createEmptyPicture()));
+ DEFINE_STATIC_LOCAL(sk_sp<PaintRecord>, emptyPicture,
+ (createEmptyPicture()));
return emptyPicture;
}
- sk_sp<SkPicture> picture = m_pictureRecorder.finishRecordingAsPicture();
+ sk_sp<PaintRecord> picture = m_pictureRecorder.finishRecordingAsPicture();
m_canvas = nullptr;
ASSERT(picture);
return picture;
}
-void GraphicsContext::drawPicture(const SkPicture* picture) {
+void GraphicsContext::drawPicture(const PaintRecord* picture) {
if (contextDisabled() || !picture || picture->cullRect().isEmpty())
return;
@@ -304,7 +306,7 @@ void GraphicsContext::drawPicture(const SkPicture* picture) {
m_canvas->drawPicture(picture);
}
-void GraphicsContext::compositePicture(sk_sp<SkPicture> picture,
+void GraphicsContext::compositePicture(sk_sp<PaintRecord> picture,
const FloatRect& dest,
const FloatRect& src,
SkBlendMode op) {
@@ -312,7 +314,7 @@ void GraphicsContext::compositePicture(sk_sp<SkPicture> picture,
return;
ASSERT(m_canvas);
- SkPaint picturePaint;
+ PaintFlags picturePaint;
picturePaint.setBlendMode(op);
m_canvas->save();
SkRect sourceBounds = src;
@@ -322,7 +324,7 @@ void GraphicsContext::compositePicture(sk_sp<SkPicture> picture,
SkMatrix::kFill_ScaleToFit);
m_canvas->concat(pictureTransform);
picturePaint.setImageFilter(SkPictureImageFilter::MakeForLocalSpace(
- std::move(picture), sourceBounds,
+ ToSkPicture(picture), sourceBounds,
static_cast<SkFilterQuality>(imageInterpolationQuality())));
m_canvas->saveLayer(&sourceBounds, &picturePaint);
m_canvas->restore();
@@ -480,7 +482,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) {
// probably worth the speed up of no square root, which also won't be exact.
FloatSize disp = p2 - p1;
int length = SkScalarRoundToInt(disp.width() + disp.height());
- SkPaint paint(immutableState()->strokePaint(length));
+ PaintFlags paint(immutableState()->strokePaint(length));
if (getStrokeStyle() == DottedStroke || getStrokeStyle() == DashedStroke) {
// Do a rect fill of our endpoints. This ensures we always have the
@@ -497,7 +499,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) {
r1.offset(0, -width / 2);
r2.offset(-width, -width / 2);
}
- SkPaint fillPaint;
+ PaintFlags fillPaint;
fillPaint.setColor(paint.getColor());
drawRect(r1, fillPaint);
drawRect(r2, fillPaint);
@@ -626,10 +628,10 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& pt,
SkMatrix localMatrix;
localMatrix.setTranslate(originX, originY);
- SkPaint paint;
- paint.setShader(SkShader::MakeBitmapShader(
+ PaintFlags paint;
+ paint.setShader(WrapSkShader(SkShader::MakeBitmapShader(
*misspellBitmap[index], SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &localMatrix));
+ SkShader::kRepeat_TileMode, &localMatrix)));
SkRect rect;
rect.set(originX, originY,
@@ -652,7 +654,7 @@ void GraphicsContext::drawLineForText(const FloatPoint& pt, float width) {
if (width <= 0)
return;
- SkPaint paint;
+ PaintFlags paint;
switch (getStrokeStyle()) {
case NoStroke:
case SolidStroke:
@@ -701,9 +703,9 @@ void GraphicsContext::drawRect(const IntRect& rect) {
if (immutableState()->getStrokeData().style() != NoStroke &&
immutableState()->strokeColor().alpha()) {
// Stroke a width: 1 inset border
- SkPaint paint(immutableState()->fillPaint());
+ PaintFlags paint(immutableState()->fillPaint());
paint.setColor(strokeColor().rgb());
- paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStyle(PaintFlags::kStroke_Style);
paint.setStrokeWidth(1);
skRect.inset(0.5f, 0.5f);
@@ -714,7 +716,7 @@ void GraphicsContext::drawRect(const IntRect& rect) {
void GraphicsContext::drawText(const Font& font,
const TextRunPaintInfo& runInfo,
const FloatPoint& point,
- const SkPaint& paint) {
+ const PaintFlags& paint) {
if (contextDisabled())
return;
@@ -732,7 +734,7 @@ void GraphicsContext::drawTextPasses(const DrawTextFunc& drawText) {
if ((modeFlags & TextModeStroke) && getStrokeStyle() != NoStroke &&
strokeThickness() > 0) {
- SkPaint paintForStroking(immutableState()->strokePaint());
+ PaintFlags paintForStroking(immutableState()->strokePaint());
if (modeFlags & TextModeFill) {
paintForStroking.setLooper(
0); // shadow was already applied during fill pass
@@ -747,7 +749,7 @@ void GraphicsContext::drawText(const Font& font,
if (contextDisabled())
return;
- drawTextPasses([&font, &runInfo, &point, this](const SkPaint& paint) {
+ drawTextPasses([&font, &runInfo, &point, this](const PaintFlags& paint) {
if (font.drawText(m_canvas, runInfo, point, m_deviceScaleFactor, paint))
m_paintController.setTextPainted();
});
@@ -760,7 +762,8 @@ void GraphicsContext::drawEmphasisMarks(const Font& font,
if (contextDisabled())
return;
- drawTextPasses([&font, &runInfo, &mark, &point, this](const SkPaint& paint) {
+ drawTextPasses([&font, &runInfo, &mark, &point,
+ this](const PaintFlags& paint) {
font.drawEmphasisMarks(m_canvas, runInfo, mark, point, m_deviceScaleFactor,
paint);
});
@@ -775,7 +778,7 @@ void GraphicsContext::drawBidiText(
return;
drawTextPasses([&font, &runInfo, &point, customFontNotReadyAction,
- this](const SkPaint& paint) {
+ this](const PaintFlags& paint) {
if (font.drawBidiText(m_canvas, runInfo, point, customFontNotReadyAction,
m_deviceScaleFactor, paint))
m_paintController.setTextPainted();
@@ -806,7 +809,7 @@ void GraphicsContext::drawImage(
const FloatRect src = srcPtr ? *srcPtr : image->rect();
- SkPaint imagePaint = immutableState()->fillPaint();
+ PaintFlags imagePaint = immutableState()->fillPaint();
imagePaint.setBlendMode(op);
imagePaint.setColor(SK_ColorBLACK);
imagePaint.setFilterQuality(computeFilterQuality(image, dest, src));
@@ -836,7 +839,7 @@ void GraphicsContext::drawImageRRect(
if (dest.isEmpty() || visibleSrc.isEmpty())
return;
- SkPaint imagePaint = immutableState()->fillPaint();
+ PaintFlags imagePaint = immutableState()->fillPaint();
imagePaint.setBlendMode(op);
imagePaint.setColor(SK_ColorBLACK);
imagePaint.setFilterQuality(
@@ -856,7 +859,7 @@ void GraphicsContext::drawImageRRect(
m_canvas->drawRRect(dest, imagePaint);
} else {
// Clip-based fallback.
- SkAutoCanvasRestore autoRestore(m_canvas, true);
+ PaintCanvasAutoRestore autoRestore(m_canvas, true);
m_canvas->clipRRect(dest, imagePaint.isAntiAlias());
image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation,
Image::ClampImageToSourceRect, m_colorBehavior);
@@ -925,7 +928,7 @@ void GraphicsContext::drawTiledImage(Image* image,
m_paintController.setImagePainted();
}
-void GraphicsContext::drawOval(const SkRect& oval, const SkPaint& paint) {
+void GraphicsContext::drawOval(const SkRect& oval, const PaintFlags& paint) {
if (contextDisabled())
return;
ASSERT(m_canvas);
@@ -933,7 +936,7 @@ void GraphicsContext::drawOval(const SkRect& oval, const SkPaint& paint) {
m_canvas->drawOval(oval, paint);
}
-void GraphicsContext::drawPath(const SkPath& path, const SkPaint& paint) {
+void GraphicsContext::drawPath(const SkPath& path, const PaintFlags& paint) {
if (contextDisabled())
return;
ASSERT(m_canvas);
@@ -941,7 +944,7 @@ void GraphicsContext::drawPath(const SkPath& path, const SkPaint& paint) {
m_canvas->drawPath(path, paint);
}
-void GraphicsContext::drawRect(const SkRect& rect, const SkPaint& paint) {
+void GraphicsContext::drawRect(const SkRect& rect, const PaintFlags& paint) {
if (contextDisabled())
return;
ASSERT(m_canvas);
@@ -949,7 +952,7 @@ void GraphicsContext::drawRect(const SkRect& rect, const SkPaint& paint) {
m_canvas->drawRect(rect, paint);
}
-void GraphicsContext::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
+void GraphicsContext::drawRRect(const SkRRect& rrect, const PaintFlags& paint) {
if (contextDisabled())
return;
ASSERT(m_canvas);
@@ -977,7 +980,7 @@ void GraphicsContext::fillRect(const FloatRect& rect,
if (contextDisabled())
return;
- SkPaint paint = immutableState()->fillPaint();
+ PaintFlags paint = immutableState()->fillPaint();
paint.setColor(color.rgb());
paint.setBlendMode(xferMode);
@@ -999,7 +1002,7 @@ void GraphicsContext::fillRoundedRect(const FloatRoundedRect& rrect,
return;
}
- SkPaint paint = immutableState()->fillPaint();
+ PaintFlags paint = immutableState()->fillPaint();
paint.setColor(color.rgb());
drawRRect(rrect, paint);
@@ -1070,7 +1073,7 @@ void GraphicsContext::fillDRRect(const FloatRoundedRect& outer,
if (color == fillColor()) {
m_canvas->drawDRRect(outer, inner, immutableState()->fillPaint());
} else {
- SkPaint paint(immutableState()->fillPaint());
+ PaintFlags paint(immutableState()->fillPaint());
paint.setColor(color.rgb());
m_canvas->drawDRRect(outer, inner, paint);
}
@@ -1083,9 +1086,9 @@ void GraphicsContext::fillDRRect(const FloatRoundedRect& outer,
SkRRect strokeRRect = outer;
strokeRRect.inset(strokeWidth / 2, strokeWidth / 2);
- SkPaint strokePaint(immutableState()->fillPaint());
+ PaintFlags strokePaint(immutableState()->fillPaint());
strokePaint.setColor(color.rgb());
- strokePaint.setStyle(SkPaint::kStroke_Style);
+ strokePaint.setStyle(PaintFlags::kStroke_Style);
strokePaint.setStrokeWidth(strokeWidth);
m_canvas->drawRRect(strokeRRect, strokePaint);
@@ -1109,7 +1112,7 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth) {
if (contextDisabled())
return;
- SkPaint paint(immutableState()->strokePaint());
+ PaintFlags paint(immutableState()->strokePaint());
paint.setStrokeWidth(WebCoreFloatToSkScalar(lineWidth));
// Reset the dash effect to account for the width
immutableState()->getStrokeData().setupPaintDashPathEffect(&paint, 0);
@@ -1271,7 +1274,7 @@ void GraphicsContext::fillRectWithRoundedHole(
if (contextDisabled())
return;
- SkPaint paint(immutableState()->fillPaint());
+ PaintFlags paint(immutableState()->fillPaint());
paint.setColor(color.rgb());
m_canvas->drawDRRect(SkRRect::MakeRect(rect), roundedHoleRect, paint);
}

Powered by Google App Engine
This is Rietveld 408576698