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

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

Issue 1168303006: Revert[2] SkDraw and all Blitters to use pixmap instead of bitmapi (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add dox to new test Created 5 years, 6 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/SkDraw.cpp ('k') | src/core/SkScan_Path.cpp » ('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 /* 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 "SkScalerContext.h" 10 #include "SkScalerContext.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 for (int y = mask.fBounds.height() - 1; y >= 0; --y) { 242 for (int y = mask.fBounds.height() - 1; y >= 0; --y) {
243 for (int x = mask.fBounds.width() - 1; x >= 0; --x) { 243 for (int x = mask.fBounds.width() - 1; x >= 0; --x) {
244 dst[x] = lut[dst[x]]; 244 dst[x] = lut[dst[x]];
245 } 245 }
246 dst += rowBytes; 246 dst += rowBytes;
247 } 247 }
248 } 248 }
249 249
250 template<bool APPLY_PREBLEND> 250 template<bool APPLY_PREBLEND>
251 static void pack4xHToLCD16(const SkBitmap& src, const SkMask& dst, 251 static void pack4xHToLCD16(const SkPixmap& src, const SkMask& dst,
252 const SkMaskGamma::PreBlend& maskPreBlend) { 252 const SkMaskGamma::PreBlend& maskPreBlend) {
253 #define SAMPLES_PER_PIXEL 4 253 #define SAMPLES_PER_PIXEL 4
254 #define LCD_PER_PIXEL 3 254 #define LCD_PER_PIXEL 3
255 SkASSERT(kAlpha_8_SkColorType == src.colorType()); 255 SkASSERT(kAlpha_8_SkColorType == src.colorType());
256 SkASSERT(SkMask::kLCD16_Format == dst.fFormat); 256 SkASSERT(SkMask::kLCD16_Format == dst.fFormat);
257 257
258 const int sample_width = src.width(); 258 const int sample_width = src.width();
259 const int height = src.height(); 259 const int height = src.height();
260 260
261 uint16_t* dstP = (uint16_t*)dst.fImage; 261 uint16_t* dstP = (uint16_t*)dst.fImage;
(...skipping 22 matching lines...) Expand all
284 static const unsigned int coefficients[LCD_PER_PIXEL][SAMPLES_PER_PIXEL*3] = { 284 static const unsigned int coefficients[LCD_PER_PIXEL][SAMPLES_PER_PIXEL*3] = {
285 //The red subpixel is centered inside the first sample (at 1/6 pixel), a nd is shifted. 285 //The red subpixel is centered inside the first sample (at 1/6 pixel), a nd is shifted.
286 { 0x03, 0x0b, 0x1c, 0x33, 0x40, 0x39, 0x24, 0x10, 0x05, 0x01, 0x00, 0x 00, }, 286 { 0x03, 0x0b, 0x1c, 0x33, 0x40, 0x39, 0x24, 0x10, 0x05, 0x01, 0x00, 0x 00, },
287 //The green subpixel is centered between two samples (at 1/2 pixel), so is symetric 287 //The green subpixel is centered between two samples (at 1/2 pixel), so is symetric
288 { 0x00, 0x02, 0x08, 0x16, 0x2b, 0x3d, 0x3d, 0x2b, 0x16, 0x08, 0x02, 0x 00, }, 288 { 0x00, 0x02, 0x08, 0x16, 0x2b, 0x3d, 0x3d, 0x2b, 0x16, 0x08, 0x02, 0x 00, },
289 //The blue subpixel is centered inside the last sample (at 5/6 pixel), a nd is shifted. 289 //The blue subpixel is centered inside the last sample (at 5/6 pixel), a nd is shifted.
290 { 0x00, 0x00, 0x01, 0x05, 0x10, 0x24, 0x39, 0x40, 0x33, 0x1c, 0x0b, 0x 03, }, 290 { 0x00, 0x00, 0x01, 0x05, 0x10, 0x24, 0x39, 0x40, 0x33, 0x1c, 0x0b, 0x 03, },
291 }; 291 };
292 292
293 for (int y = 0; y < height; ++y) { 293 for (int y = 0; y < height; ++y) {
294 const uint8_t* srcP = src.getAddr8(0, y); 294 const uint8_t* srcP = src.addr8(0, y);
295 295
296 // TODO: this fir filter implementation is straight forward, but slow. 296 // TODO: this fir filter implementation is straight forward, but slow.
297 // It should be possible to make it much faster. 297 // It should be possible to make it much faster.
298 for (int sample_x = -4, pixel_x = 0; sample_x < sample_width + 4; sample _x += 4, ++pixel_x) { 298 for (int sample_x = -4, pixel_x = 0; sample_x < sample_width + 4; sample _x += 4, ++pixel_x) {
299 int fir[LCD_PER_PIXEL] = { 0 }; 299 int fir[LCD_PER_PIXEL] = { 0 };
300 for (int sample_index = SkMax32(0, sample_x - 4), coeff_index = samp le_index - (sample_x - 4) 300 for (int sample_index = SkMax32(0, sample_x - 4), coeff_index = samp le_index - (sample_x - 4)
301 ; sample_index < SkMin32(sample_x + 8, sample_width) 301 ; sample_index < SkMin32(sample_x + 8, sample_width)
302 ; ++sample_index, ++coeff_index) 302 ; ++sample_index, ++coeff_index)
303 { 303 {
304 int sample_value = srcP[sample_index]; 304 int sample_value = srcP[sample_index];
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 dstRB = 0; // signals we need a copy 399 dstRB = 0; // signals we need a copy
400 break; 400 break;
401 default: 401 default:
402 SkDEBUGFAIL("unexpected mask format"); 402 SkDEBUGFAIL("unexpected mask format");
403 } 403 }
404 404
405 SkRasterClip clip; 405 SkRasterClip clip;
406 clip.setRect(SkIRect::MakeWH(dstW, dstH)); 406 clip.setRect(SkIRect::MakeWH(dstW, dstH));
407 407
408 const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH); 408 const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH);
409 SkBitmap bm; 409 SkAutoPixmapStorage dst;
410 410
411 if (0 == dstRB) { 411 if (0 == dstRB) {
412 if (!bm.tryAllocPixels(info)) { 412 if (!dst.tryAlloc(info)) {
413 // can't allocate offscreen, so empty the mask and return 413 // can't allocate offscreen, so empty the mask and return
414 sk_bzero(mask.fImage, mask.computeImageSize()); 414 sk_bzero(mask.fImage, mask.computeImageSize());
415 return; 415 return;
416 } 416 }
417 } else { 417 } else {
418 bm.installPixels(info, mask.fImage, dstRB); 418 dst.reset(info, mask.fImage, dstRB);
419 } 419 }
420 sk_bzero(bm.getPixels(), bm.getSafeSize()); 420 sk_bzero(dst.writable_addr(), dst.getSafeSize());
421 421
422 SkDraw draw; 422 SkDraw draw;
423 draw.fDst = dst;
423 draw.fRC = &clip; 424 draw.fRC = &clip;
424 draw.fClip = &clip.bwRgn(); 425 draw.fClip = &clip.bwRgn();
425 draw.fMatrix = &matrix; 426 draw.fMatrix = &matrix;
426 draw.fBitmap = &bm;
427 draw.drawPath(path, paint); 427 draw.drawPath(path, paint);
428 428
429 switch (mask.fFormat) { 429 switch (mask.fFormat) {
430 case SkMask::kBW_Format: 430 case SkMask::kBW_Format:
431 packA8ToA1(mask, bm.getAddr8(0, 0), bm.rowBytes()); 431 packA8ToA1(mask, dst.addr8(0, 0), dst.rowBytes());
432 break; 432 break;
433 case SkMask::kA8_Format: 433 case SkMask::kA8_Format:
434 if (maskPreBlend.isApplicable()) { 434 if (maskPreBlend.isApplicable()) {
435 applyLUTToA8Mask(mask, maskPreBlend.fG); 435 applyLUTToA8Mask(mask, maskPreBlend.fG);
436 } 436 }
437 break; 437 break;
438 case SkMask::kLCD16_Format: 438 case SkMask::kLCD16_Format:
439 if (maskPreBlend.isApplicable()) { 439 if (maskPreBlend.isApplicable()) {
440 pack4xHToLCD16<true>(bm, mask, maskPreBlend); 440 pack4xHToLCD16<true>(dst, mask, maskPreBlend);
441 } else { 441 } else {
442 pack4xHToLCD16<false>(bm, mask, maskPreBlend); 442 pack4xHToLCD16<false>(dst, mask, maskPreBlend);
443 } 443 }
444 break; 444 break;
445 default: 445 default:
446 break; 446 break;
447 } 447 }
448 } 448 }
449 449
450 static void extract_alpha(const SkMask& dst, 450 static void extract_alpha(const SkMask& dst,
451 const SkPMColor* srcRow, size_t srcRB) { 451 const SkPMColor* srcRow, size_t srcRB) {
452 int width = dst.fBounds.width(); 452 int width = dst.fBounds.width();
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, 869 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc,
870 bool allowFailure) const { 870 bool allowFailure) const {
871 SkScalerContext* c = this->onCreateScalerContext(desc); 871 SkScalerContext* c = this->onCreateScalerContext(desc);
872 872
873 if (!c && !allowFailure) { 873 if (!c && !allowFailure) {
874 c = SkNEW_ARGS(SkScalerContext_Empty, 874 c = SkNEW_ARGS(SkScalerContext_Empty,
875 (const_cast<SkTypeface*>(this), desc)); 875 (const_cast<SkTypeface*>(this), desc));
876 } 876 }
877 return c; 877 return c;
878 } 878 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkScan_Path.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698