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

Side by Side Diff: src/utils/SkTextureCompressor_Blitter.h

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 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 unified diff | Download patch
« no previous file with comments | « src/utils/SkSHA1.h ('k') | src/utils/debugger/SkDebugCanvas.h » ('j') | 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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTextureCompressor_Blitter_DEFINED 8 #ifndef SkTextureCompressor_Blitter_DEFINED
9 #define SkTextureCompressor_Blitter_DEFINED 9 #define SkTextureCompressor_Blitter_DEFINED
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 , fHeight(height) 78 , fHeight(height)
79 , fBuffer(compressedBuffer) 79 , fBuffer(compressedBuffer)
80 { 80 {
81 SkASSERT((width % BlockDim) == 0); 81 SkASSERT((width % BlockDim) == 0);
82 SkASSERT((height % BlockDim) == 0); 82 SkASSERT((height % BlockDim) == 0);
83 } 83 }
84 84
85 virtual ~SkTCompressedAlphaBlitter() { this->flushRuns(); } 85 virtual ~SkTCompressedAlphaBlitter() { this->flushRuns(); }
86 86
87 // Blit a horizontal run of one or more pixels. 87 // Blit a horizontal run of one or more pixels.
88 virtual void blitH(int x, int y, int width) SK_OVERRIDE { 88 void blitH(int x, int y, int width) SK_OVERRIDE {
89 // This function is intended to be called from any standard RGB 89 // This function is intended to be called from any standard RGB
90 // buffer, so we should never encounter it. However, if some code 90 // buffer, so we should never encounter it. However, if some code
91 // path does end up here, then this needs to be investigated. 91 // path does end up here, then this needs to be investigated.
92 SkFAIL("Not implemented!"); 92 SkFAIL("Not implemented!");
93 } 93 }
94 94
95 // Blit a horizontal run of antialiased pixels; runs[] is a *sparse* 95 // Blit a horizontal run of antialiased pixels; runs[] is a *sparse*
96 // zero-terminated run-length encoding of spans of constant alpha values. 96 // zero-terminated run-length encoding of spans of constant alpha values.
97 virtual void blitAntiH(int x, int y, 97 virtual void blitAntiH(int x, int y,
98 const SkAlpha antialias[], 98 const SkAlpha antialias[],
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 fBufferedRuns[fNextRun].fY = y; 134 fBufferedRuns[fNextRun].fY = y;
135 135
136 // If we've output a block of scanlines in a row that don't violate our 136 // If we've output a block of scanlines in a row that don't violate our
137 // assumptions, then it's time to flush them... 137 // assumptions, then it's time to flush them...
138 if (BlockDim == ++fNextRun) { 138 if (BlockDim == ++fNextRun) {
139 this->flushRuns(); 139 this->flushRuns();
140 } 140 }
141 } 141 }
142 142
143 // Blit a vertical run of pixels with a constant alpha value. 143 // Blit a vertical run of pixels with a constant alpha value.
144 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE { 144 void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE {
145 // This function is currently not implemented. It is not explicitly 145 // This function is currently not implemented. It is not explicitly
146 // required by the contract, but if at some time a code path runs into 146 // required by the contract, but if at some time a code path runs into
147 // this function (which is entirely possible), it needs to be implemente d. 147 // this function (which is entirely possible), it needs to be implemente d.
148 // 148 //
149 // TODO (krajcevski): 149 // TODO (krajcevski):
150 // This function will be most easily implemented in one of two ways: 150 // This function will be most easily implemented in one of two ways:
151 // 1. Buffer each vertical column value and then construct a list 151 // 1. Buffer each vertical column value and then construct a list
152 // of alpha values and output all of the blocks at once. This only 152 // of alpha values and output all of the blocks at once. This only
153 // requires a write to the compressed buffer 153 // requires a write to the compressed buffer
154 // 2. Replace the indices of each block with the proper indices based 154 // 2. Replace the indices of each block with the proper indices based
155 // on the alpha value. This requires a read and write of the compress ed 155 // on the alpha value. This requires a read and write of the compress ed
156 // buffer, but much less overhead. 156 // buffer, but much less overhead.
157 SkFAIL("Not implemented!"); 157 SkFAIL("Not implemented!");
158 } 158 }
159 159
160 // Blit a solid rectangle one or more pixels wide. It's assumed that blitRec t 160 // Blit a solid rectangle one or more pixels wide. It's assumed that blitRec t
161 // is called as a way to bracket blitAntiH where above and below the path th e 161 // is called as a way to bracket blitAntiH where above and below the path th e
162 // called path just needs a solid rectangle to fill in the mask. 162 // called path just needs a solid rectangle to fill in the mask.
163 #ifdef SK_DEBUG 163 #ifdef SK_DEBUG
164 bool fCalledOnceWithNonzeroY; 164 bool fCalledOnceWithNonzeroY;
165 #endif 165 #endif
166 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE { 166 void blitRect(int x, int y, int width, int height) SK_OVERRIDE {
167 167
168 // Assumptions: 168 // Assumptions:
169 SkASSERT(0 == x); 169 SkASSERT(0 == x);
170 SkASSERT(width <= fWidth); 170 SkASSERT(width <= fWidth);
171 171
172 // Make sure that we're only ever bracketing calls to blitAntiH. 172 // Make sure that we're only ever bracketing calls to blitAntiH.
173 SkASSERT((0 == y) || (!fCalledOnceWithNonzeroY && (fCalledOnceWithNonzer oY = true))); 173 SkASSERT((0 == y) || (!fCalledOnceWithNonzeroY && (fCalledOnceWithNonzer oY = true)));
174 174
175 #if !(PEDANTIC_BLIT_RECT) 175 #if !(PEDANTIC_BLIT_RECT)
176 for (int i = 0; i < height; ++i) { 176 for (int i = 0; i < height; ++i) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // Blit a pattern of pixels defined by a rectangle-clipped mask; We make an 299 // Blit a pattern of pixels defined by a rectangle-clipped mask; We make an
300 // assumption here that if this function gets called, then it will replace a ll 300 // assumption here that if this function gets called, then it will replace a ll
301 // of the compressed texture blocks that it touches. Hence, two separate cal ls 301 // of the compressed texture blocks that it touches. Hence, two separate cal ls
302 // to blitMask that have clips next to one another will cause artifacts. Mos t 302 // to blitMask that have clips next to one another will cause artifacts. Mos t
303 // of the time, however, this function gets called because constructing the mask 303 // of the time, however, this function gets called because constructing the mask
304 // was faster than constructing the RLE for blitAntiH, and this function wil l 304 // was faster than constructing the RLE for blitAntiH, and this function wil l
305 // only be called once. 305 // only be called once.
306 #ifdef SK_DEBUG 306 #ifdef SK_DEBUG
307 bool fBlitMaskCalled; 307 bool fBlitMaskCalled;
308 #endif 308 #endif
309 virtual void blitMask(const SkMask& mask, const SkIRect& clip) SK_OVERRIDE { 309 void blitMask(const SkMask& mask, const SkIRect& clip) SK_OVERRIDE {
310 310
311 // Assumptions: 311 // Assumptions:
312 SkASSERT(!fBlitMaskCalled); 312 SkASSERT(!fBlitMaskCalled);
313 SkDEBUGCODE(fBlitMaskCalled = true); 313 SkDEBUGCODE(fBlitMaskCalled = true);
314 SkASSERT(SkMask::kA8_Format == mask.fFormat); 314 SkASSERT(SkMask::kA8_Format == mask.fFormat);
315 SkASSERT(mask.fBounds.contains(clip)); 315 SkASSERT(mask.fBounds.contains(clip));
316 316
317 // Start from largest block boundary less than the clip boundaries. 317 // Start from largest block boundary less than the clip boundaries.
318 const int startI = BlockDim * (clip.left() / BlockDim); 318 const int startI = BlockDim * (clip.left() / BlockDim);
319 const int startJ = BlockDim * (clip.top() / BlockDim); 319 const int startJ = BlockDim * (clip.top() / BlockDim);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 361 }
362 362
363 dst += EncodedBlockSize; 363 dst += EncodedBlockSize;
364 } 364 }
365 } 365 }
366 } 366 }
367 367
368 // If the blitter just sets a single value for each pixel, return the 368 // If the blitter just sets a single value for each pixel, return the
369 // bitmap it draws into, and assign value. If not, return NULL and ignore 369 // bitmap it draws into, and assign value. If not, return NULL and ignore
370 // the value parameter. 370 // the value parameter.
371 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE { 371 const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE {
372 return NULL; 372 return NULL;
373 } 373 }
374 374
375 /** 375 /**
376 * Compressed texture blitters only really work correctly if they get 376 * Compressed texture blitters only really work correctly if they get
377 * BlockDim rows at a time. That being said, this blitter tries it's best 377 * BlockDim rows at a time. That being said, this blitter tries it's best
378 * to preserve semantics if blitAntiH doesn't get called in too many 378 * to preserve semantics if blitAntiH doesn't get called in too many
379 * weird ways... 379 * weird ways...
380 */ 380 */
381 virtual int requestRowsPreserved() const SK_OVERRIDE { return BlockDim; } 381 int requestRowsPreserved() const SK_OVERRIDE { return BlockDim; }
382 382
383 private: 383 private:
384 static const int kPixelsPerBlock = BlockDim * BlockDim; 384 static const int kPixelsPerBlock = BlockDim * BlockDim;
385 385
386 // The longest possible run of pixels that this blitter will receive. 386 // The longest possible run of pixels that this blitter will receive.
387 // This is initialized in the constructor to 0x7FFE, which is one less 387 // This is initialized in the constructor to 0x7FFE, which is one less
388 // than the largest positive 16-bit integer. We make sure that it's one 388 // than the largest positive 16-bit integer. We make sure that it's one
389 // less for debugging purposes. We also don't make this variable static 389 // less for debugging purposes. We also don't make this variable static
390 // in order to make sure that we can construct a valid pointer to it. 390 // in order to make sure that we can construct a valid pointer to it.
391 const int16_t kLongestRun; 391 const int16_t kLongestRun;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 mask, BlockDim, mask); 724 mask, BlockDim, mask);
725 } 725 }
726 } 726 }
727 #endif // PEDANTIC_BLIT_RECT 727 #endif // PEDANTIC_BLIT_RECT
728 728
729 }; 729 };
730 730
731 } // namespace SkTextureCompressor 731 } // namespace SkTextureCompressor
732 732
733 #endif // SkTextureCompressor_Blitter_DEFINED 733 #endif // SkTextureCompressor_Blitter_DEFINED
OLDNEW
« no previous file with comments | « src/utils/SkSHA1.h ('k') | src/utils/debugger/SkDebugCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698