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

Side by Side 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: Add DCHECK for xfermode Created 7 years, 3 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 unified diff | Download patch
« no previous file with comments | « skia/ext/alpha_proxy_canvas.h ('k') | skia/skia_chrome.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "skia/ext/alpha_proxy_canvas.h"
6
7 #include "base/logging.h"
8
9 namespace skia {
10
11 AlphaProxyCanvas::AlphaProxyCanvas(SkCanvas* target,
12 float opacity,
13 bool allow_filter)
14 : SkProxyCanvas(target), opacity_(opacity), allow_filter_(allow_filter) {}
15
16 AlphaProxyCanvas::~AlphaProxyCanvas() {}
17
18 int AlphaProxyCanvas::saveLayer(const SkRect* bounds,
19 const SkPaint* paint,
20 SkCanvas::SaveFlags flags) {
21 SkPaint new_paint = AlphaPaint(paint);
enne (OOO) 2013/08/27 18:53:30 Shouldn't new_paint only be AlphaPaint for the top
aelias_OOO_until_Jul13 2013/08/28 02:38:40 Correct, and with the SkDrawFilter approach, this
22 return INHERITED::saveLayer(bounds, &new_paint, flags);
23 }
24
25 void AlphaProxyCanvas::drawPaint(const SkPaint& paint) {
26 INHERITED::drawPaint(AlphaPaint(&paint));
27 }
28
29 void AlphaProxyCanvas::drawPoints(SkCanvas::PointMode mode,
30 size_t count,
31 const SkPoint pts[],
32 const SkPaint& paint) {
33 INHERITED::drawPoints(mode, count, pts, AlphaPaint(&paint));
34 }
35
36 void AlphaProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
37 INHERITED::drawRect(rect, AlphaPaint(&paint));
38 }
39
40 void AlphaProxyCanvas::drawOval(const SkRect& oval, const SkPaint& paint) {
41 INHERITED::drawOval(oval, AlphaPaint(&paint));
42 }
43
44 void AlphaProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
45 INHERITED::drawRRect(rrect, AlphaPaint(&paint));
46 }
47
48 void AlphaProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
49 INHERITED::drawPath(path, AlphaPaint(&paint));
50 }
51
52 void AlphaProxyCanvas::drawBitmap(const SkBitmap& bitmap,
53 SkScalar left,
54 SkScalar top,
55 const SkPaint* paint) {
56 SkPaint new_paint = AlphaPaint(paint);
57 INHERITED::drawBitmap(bitmap, left, top, &new_paint);
58 }
59
60 void AlphaProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
61 const SkRect* src,
62 const SkRect& dst,
63 const SkPaint* paint,
64 DrawBitmapRectFlags flags) {
65 SkPaint new_paint = AlphaPaint(paint);
66 INHERITED::drawBitmapRectToRect(bitmap, src, dst, &new_paint, flags);
67 }
68
69 void AlphaProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap,
70 const SkMatrix& m,
71 const SkPaint* paint) {
72 SkPaint new_paint = AlphaPaint(paint);
73 INHERITED::drawBitmapMatrix(bitmap, m, &new_paint);
74 }
75
76 void AlphaProxyCanvas::drawBitmapNine(const SkBitmap& bitmap,
77 const SkIRect& center,
78 const SkRect& dst,
79 const SkPaint* paint) {
80 SkPaint new_paint = AlphaPaint(paint);
81 INHERITED::drawBitmapNine(bitmap, center, dst, &new_paint);
82 }
83
84 void AlphaProxyCanvas::drawSprite(const SkBitmap& bitmap,
85 int left,
86 int top,
87 const SkPaint* paint) {
88 SkPaint new_paint = AlphaPaint(paint);
89 INHERITED::drawSprite(bitmap, left, top, &new_paint);
90 }
91
92 void AlphaProxyCanvas::drawText(const void* text,
93 size_t byteLength,
94 SkScalar x,
95 SkScalar y,
96 const SkPaint& paint) {
97 INHERITED::drawText(text, byteLength, x, y, AlphaPaint(&paint));
98 }
99
100 void AlphaProxyCanvas::drawPosText(const void* text,
101 size_t byteLength,
102 const SkPoint pos[],
103 const SkPaint& paint) {
104 INHERITED::drawPosText(text, byteLength, pos, AlphaPaint(&paint));
105 }
106
107 void AlphaProxyCanvas::drawPosTextH(const void* text,
108 size_t byteLength,
109 const SkScalar xpos[],
110 SkScalar constY,
111 const SkPaint& paint) {
112 INHERITED::drawPosTextH(text, byteLength, xpos, constY, AlphaPaint(&paint));
113 }
114
115 void AlphaProxyCanvas::drawTextOnPath(const void* text,
116 size_t byteLength,
117 const SkPath& path,
118 const SkMatrix* matrix,
119 const SkPaint& paint) {
120 INHERITED::drawTextOnPath(text, byteLength, path, matrix, AlphaPaint(&paint));
121 }
122
123 void AlphaProxyCanvas::drawVertices(SkCanvas::VertexMode vmode,
124 int vertexCount,
125 const SkPoint vertices[],
126 const SkPoint texs[],
127 const SkColor colors[],
128 SkXfermode* xmode,
129 const uint16_t indices[],
130 int indexCount,
131 const SkPaint& paint) {
132 INHERITED::drawVertices(vmode,
133 vertexCount,
134 vertices,
135 texs,
136 colors,
137 xmode,
138 indices,
139 indexCount,
140 AlphaPaint(&paint));
141 }
142
143 SkPaint AlphaProxyCanvas::AlphaPaint(const SkPaint* paint) const {
144 SkPaint alpha_paint;
145 if (paint)
146 alpha_paint = *paint;
147 if (opacity_ != 1.f) {
148 DCHECK(!paint ||
149 SkXfermode::IsMode(paint->getXfermode(), SkXfermode::kSrc_Mode) ||
150 SkXfermode::IsMode(paint->getXfermode(), SkXfermode::kSrcOver_Mode));
enne (OOO) 2013/08/27 18:53:30 Unless I'm missing something, I am not sure that a
aelias_OOO_until_Jul13 2013/08/28 02:38:40 With further experimentation, it was unnecessary t
151 alpha_paint.setAlpha(alpha_paint.getAlpha() * opacity_);
152 alpha_paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
153 }
154 if (!allow_filter_)
155 alpha_paint.setFilterBitmap(false);
156 return alpha_paint;
157 }
158
159 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/alpha_proxy_canvas.h ('k') | skia/skia_chrome.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698