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

Side by Side Diff: src/core/SkScan_AntiPath.cpp

Issue 387953005: Buffer four scanlines prior to blitting. We will eventually use this (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix debug code Created 6 years, 5 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 | « src/core/SkBlitter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkScanPriv.h" 10 #include "SkScanPriv.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 /// Run-length-encoded supersampling antialiased blitter. 103 /// Run-length-encoded supersampling antialiased blitter.
104 class SuperBlitter : public BaseSuperBlitter { 104 class SuperBlitter : public BaseSuperBlitter {
105 public: 105 public:
106 SuperBlitter(SkBlitter* realBlitter, const SkIRect& ir, 106 SuperBlitter(SkBlitter* realBlitter, const SkIRect& ir,
107 const SkRegion& clip); 107 const SkRegion& clip);
108 108
109 virtual ~SuperBlitter() { 109 virtual ~SuperBlitter() {
110 this->flush(); 110 this->flush();
111 sk_free(fRuns.fRuns); 111 sk_free(fRunsBuffer);
112 } 112 }
113 113
114 /// Once fRuns contains a complete supersampled row, flush() blits 114 /// Once fRuns contains a complete supersampled row, flush() blits
115 /// it out through the wrapped blitter. 115 /// it out through the wrapped blitter.
116 void flush(); 116 void flush();
117 117
118 /// Blits a row of pixels, with location and width specified 118 /// Blits a row of pixels, with location and width specified
119 /// in supersampled coordinates. 119 /// in supersampled coordinates.
120 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 120 virtual void blitH(int x, int y, int width) SK_OVERRIDE;
121 /// Blits a rectangle of pixels, with location and size specified 121 /// Blits a rectangle of pixels, with location and size specified
122 /// in supersampled coordinates. 122 /// in supersampled coordinates.
123 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 123 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
124 124
125 private: 125 private:
robertphillips 2014/07/16 12:33:11 Move this comment down into getRunsSz ?
krajcevski 2014/07/16 16:36:03 Done.
126 // extra one to store the zero at the end
robertphillips 2014/07/16 12:33:11 // The next 3 variables implement a circular buffe
krajcevski 2014/07/16 16:36:03 Done.
127 int fRunsToBuffer;
robertphillips 2014/07/16 12:50:33 void* ?
krajcevski 2014/07/16 16:36:03 Done.
128 void * fRunsBuffer;
129 int fCurrentRun;
126 SkAlphaRuns fRuns; 130 SkAlphaRuns fRuns;
131
132 int getRunsSz() const { return (fWidth + 1 + (fWidth + 2)/2) * sizeof(int16_ t); }
133
robertphillips 2014/07/16 12:33:11 // This updates 'fRuns' to point to the current bu
krajcevski 2014/07/16 16:36:03 Done.
134 void advanceRuns() {
135 const size_t kRunsSz = this->getRunsSz();
136 fCurrentRun = (fCurrentRun + 1) % fRunsToBuffer;
137 fRuns.fRuns = reinterpret_cast<int16_t*>(
138 reinterpret_cast<uint8_t*>(fRunsBuffer) + fCurrentRun * kRunsSz);
139 fRuns.fAlpha = reinterpret_cast<SkAlpha*>(fRuns.fRuns + fWidth + 1);
140 fRuns.reset(fWidth);
141 }
142
127 int fOffsetX; 143 int fOffsetX;
128 }; 144 };
129 145
130 SuperBlitter::SuperBlitter(SkBlitter* realBlitter, const SkIRect& ir, 146 SuperBlitter::SuperBlitter(SkBlitter* realBlitter, const SkIRect& ir,
131 const SkRegion& clip) 147 const SkRegion& clip)
132 : BaseSuperBlitter(realBlitter, ir, clip) { 148 : BaseSuperBlitter(realBlitter, ir, clip) {
133 const int width = fWidth; 149 fRunsToBuffer = realBlitter->requestRowsPreserved();
150 fRunsBuffer = sk_malloc_throw(fRunsToBuffer * this->getRunsSz());
151 fCurrentRun = -1;
134 152
135 // extra one to store the zero at the end 153 this->advanceRuns();
136 fRuns.fRuns = (int16_t*)sk_malloc_throw((width + 1 + (width + 2)/2) * sizeof (int16_t));
137 fRuns.fAlpha = (uint8_t*)(fRuns.fRuns + width + 1);
138 fRuns.reset(width);
139 154
140 fOffsetX = 0; 155 fOffsetX = 0;
141 } 156 }
142 157
143 void SuperBlitter::flush() { 158 void SuperBlitter::flush() {
144 if (fCurrIY >= fTop) { 159 if (fCurrIY >= fTop) {
160
161 SkASSERT(fCurrentRun < fRunsToBuffer);
145 if (!fRuns.empty()) { 162 if (!fRuns.empty()) {
robertphillips 2014/07/16 12:33:11 Usually we put the ';' inside the ')' of the SkDEB
krajcevski 2014/07/16 16:36:03 Done.
146 // SkDEBUGCODE(fRuns.dump();) 163 // SkDEBUGCODE(fRuns.dump());
147 fRealBlitter->blitAntiH(fLeft, fCurrIY, fRuns.fAlpha, fRuns.fRuns); 164 fRealBlitter->blitAntiH(fLeft, fCurrIY, fRuns.fAlpha, fRuns.fRuns);
148 fRuns.reset(fWidth); 165 this->advanceRuns();
149 fOffsetX = 0; 166 fOffsetX = 0;
150 } 167 }
168
151 fCurrIY = fTop - 1; 169 fCurrIY = fTop - 1;
152 SkDEBUGCODE(fCurrX = -1;) 170 SkDEBUGCODE(fCurrX = -1;)
153 } 171 }
154 } 172 }
155 173
156 /** coverage_to_partial_alpha() is being used by SkAlphaRuns, which 174 /** coverage_to_partial_alpha() is being used by SkAlphaRuns, which
157 *accumulates* SCALE pixels worth of "alpha" in [0,(256/SCALE)] 175 *accumulates* SCALE pixels worth of "alpha" in [0,(256/SCALE)]
158 to produce a final value in [0, 255] and handles clamping 256->255 176 to produce a final value in [0, 255] and handles clamping 256->255
159 itself, with the same (alpha - (alpha >> 8)) correction as 177 itself, with the same (alpha - (alpha >> 8)) correction as
160 coverage_to_exact_alpha(). 178 coverage_to_exact_alpha().
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 AntiFillPath(path, clip.bwRgn(), blitter); 750 AntiFillPath(path, clip.bwRgn(), blitter);
733 } else { 751 } else {
734 SkRegion tmp; 752 SkRegion tmp;
735 SkAAClipBlitter aaBlitter; 753 SkAAClipBlitter aaBlitter;
736 754
737 tmp.setRect(clip.getBounds()); 755 tmp.setRect(clip.getBounds());
738 aaBlitter.init(blitter, &clip.aaRgn()); 756 aaBlitter.init(blitter, &clip.aaRgn());
739 SkScan::AntiFillPath(path, tmp, &aaBlitter, true); 757 SkScan::AntiFillPath(path, tmp, &aaBlitter, true);
740 } 758 }
741 } 759 }
OLDNEW
« no previous file with comments | « src/core/SkBlitter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698