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

Unified Diff: skia/ext/alpha_proxy_canvas.cc

Issue 22867046: Optimize alpha software PictureDrawQuads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove default arguments Created 7 years, 4 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: skia/ext/alpha_proxy_canvas.cc
diff --git a/skia/ext/alpha_proxy_canvas.cc b/skia/ext/alpha_proxy_canvas.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b6c8120417506bbb6eb89a5be10cf9680ba3f9af
--- /dev/null
+++ b/skia/ext/alpha_proxy_canvas.cc
@@ -0,0 +1,153 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "skia/ext/alpha_proxy_canvas.h"
+
+namespace skia {
+
+AlphaProxyCanvas::AlphaProxyCanvas(SkCanvas* target,
+ float opacity,
+ bool allow_filter)
+ : SkProxyCanvas(target), opacity_(opacity), allow_filter_(allow_filter) {}
+
+AlphaProxyCanvas::~AlphaProxyCanvas() {}
+
+int AlphaProxyCanvas::saveLayer(const SkRect* bounds,
+ const SkPaint* paint,
+ SkCanvas::SaveFlags flags) {
+ SkPaint new_paint = AlphaPaint(paint);
+ return INHERITED::saveLayer(bounds, &new_paint, flags);
+}
+
+void AlphaProxyCanvas::drawPaint(const SkPaint& paint) {
+ INHERITED::drawPaint(AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawPoints(SkCanvas::PointMode mode,
+ size_t count,
+ const SkPoint pts[],
+ const SkPaint& paint) {
+ INHERITED::drawPoints(mode, count, pts, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
+ INHERITED::drawRect(rect, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawOval(const SkRect& oval, const SkPaint& paint) {
+ INHERITED::drawOval(oval, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
+ INHERITED::drawRRect(rrect, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
+ INHERITED::drawPath(path, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawBitmap(const SkBitmap& bitmap,
+ SkScalar left,
+ SkScalar top,
+ const SkPaint* paint) {
+ SkPaint new_paint = AlphaPaint(paint);
+ INHERITED::drawBitmap(bitmap, left, top, &new_paint);
+}
+
+void AlphaProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint) {
+ SkPaint new_paint = AlphaPaint(paint);
+ INHERITED::drawBitmapRectToRect(bitmap, src, dst, &new_paint);
+}
+
+void AlphaProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap,
+ const SkMatrix& m,
+ const SkPaint* paint) {
+ SkPaint new_paint = AlphaPaint(paint);
+ INHERITED::drawBitmapMatrix(bitmap, m, &new_paint);
+}
+
+void AlphaProxyCanvas::drawBitmapNine(const SkBitmap& bitmap,
+ const SkIRect& center,
+ const SkRect& dst,
+ const SkPaint* paint) {
+ SkPaint new_paint = AlphaPaint(paint);
+ INHERITED::drawBitmapNine(bitmap, center, dst, &new_paint);
+}
+
+void AlphaProxyCanvas::drawSprite(const SkBitmap& bitmap,
+ int left,
+ int top,
+ const SkPaint* paint) {
+ SkPaint new_paint = AlphaPaint(paint);
+ INHERITED::drawSprite(bitmap, left, top, &new_paint);
+}
+
+void AlphaProxyCanvas::drawText(const void* text,
+ size_t byteLength,
+ SkScalar x,
+ SkScalar y,
+ const SkPaint& paint) {
+ INHERITED::drawText(text, byteLength, x, y, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawPosText(const void* text,
+ size_t byteLength,
+ const SkPoint pos[],
+ const SkPaint& paint) {
+ INHERITED::drawPosText(text, byteLength, pos, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawPosTextH(const void* text,
+ size_t byteLength,
+ const SkScalar xpos[],
+ SkScalar constY,
+ const SkPaint& paint) {
+ INHERITED::drawPosTextH(text, byteLength, xpos, constY, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawTextOnPath(const void* text,
+ size_t byteLength,
+ const SkPath& path,
+ const SkMatrix* matrix,
+ const SkPaint& paint) {
+ INHERITED::drawTextOnPath(text, byteLength, path, matrix, AlphaPaint(&paint));
+}
+
+void AlphaProxyCanvas::drawVertices(SkCanvas::VertexMode vmode,
+ int vertexCount,
+ const SkPoint vertices[],
+ const SkPoint texs[],
+ const SkColor colors[],
+ SkXfermode* xmode,
+ const uint16_t indices[],
+ int indexCount,
+ const SkPaint& paint) {
+ INHERITED::drawVertices(vmode,
+ vertexCount,
+ vertices,
+ texs,
+ colors,
+ xmode,
+ indices,
+ indexCount,
+ AlphaPaint(&paint));
+}
+
+SkPaint AlphaProxyCanvas::AlphaPaint(const SkPaint* paint) const {
+ SkPaint alpha_paint;
+ if (paint)
+ alpha_paint = *paint;
+ if (opacity_ != 1.f) {
+ alpha_paint.setAlpha(alpha_paint.getAlpha() * opacity_);
+ alpha_paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
enne (OOO) 2013/08/27 00:25:52 I am most skeptical about this particular line. H
aelias_OOO_until_Jul13 2013/08/27 07:02:28 We can't. I added a DCHECK the mode is already Sr
+ }
+ if (!allow_filter_)
+ alpha_paint.setFilterBitmap(false);
+ return alpha_paint;
+}
+
+} // namespace skia

Powered by Google App Engine
This is Rietveld 408576698