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

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

Issue 1915263002: Add guards for edge cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use proper call for trunc. Created 4 years, 8 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/SkBitmapProcShader.cpp ('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 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 #include "SkLinearBitmapPipeline.h" 8 #include "SkLinearBitmapPipeline.h"
9 9
10 #include "SkPM4f.h" 10 #include "SkPM4f.h"
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 Sk4i iXs = SkNx_cast<int>(xs); 577 Sk4i iXs = SkNx_cast<int>(xs);
578 Sk4i iYs = SkNx_cast<int>(ys); 578 Sk4i iYs = SkNx_cast<int>(ys);
579 *fDest++ = *this->pixelAddress(iXs[0], iYs[0]); 579 *fDest++ = *this->pixelAddress(iXs[0], iYs[0]);
580 *fDest++ = *this->pixelAddress(iXs[1], iYs[1]); 580 *fDest++ = *this->pixelAddress(iXs[1], iYs[1]);
581 *fDest++ = *this->pixelAddress(iXs[2], iYs[2]); 581 *fDest++ = *this->pixelAddress(iXs[2], iYs[2]);
582 *fDest++ = *this->pixelAddress(iXs[3], iYs[3]); 582 *fDest++ = *this->pixelAddress(iXs[3], iYs[3]);
583 } 583 }
584 584
585 void pointSpan(Span span) override { 585 void pointSpan(Span span) override {
586 SkASSERT(fDest + span.count() <= fEnd); 586 SkASSERT(fDest + span.count() <= fEnd);
587 int32_t x = (int32_t)span.startX(); 587 if (span.length() != 0.0f) {
588 int32_t y = (int32_t)span.startY(); 588 int32_t x = SkScalarTruncToInt(span.startX());
589 const uint32_t* src = this->pixelAddress(x, y); 589 int32_t y = SkScalarTruncToInt(span.startY());
590 memmove(fDest, src, span.count() * sizeof(uint32_t)); 590 const uint32_t* src = this->pixelAddress(x, y);
591 fDest += span.count(); 591 memmove(fDest, src, span.count() * sizeof(uint32_t));
592 fDest += span.count();
593 }
592 } 594 }
593 595
594 void repeatSpan(Span span, int32_t repeatCount) override { 596 void repeatSpan(Span span, int32_t repeatCount) override {
595 SkASSERT(fDest + span.count() * repeatCount <= fEnd); 597 SkASSERT(fDest + span.count() * repeatCount <= fEnd);
596 598
597 int32_t x = (int32_t)span.startX(); 599 int32_t x = SkScalarTruncToInt(span.startX());
598 int32_t y = (int32_t)span.startY(); 600 int32_t y = SkScalarTruncToInt(span.startY());
599 const uint32_t* src = this->pixelAddress(x, y); 601 const uint32_t* src = this->pixelAddress(x, y);
600 uint32_t* dest = fDest; 602 uint32_t* dest = fDest;
601 while (repeatCount --> 0) { 603 while (repeatCount --> 0) {
602 memmove(dest, src, span.count() * sizeof(uint32_t)); 604 memmove(dest, src, span.count() * sizeof(uint32_t));
603 dest += span.count(); 605 dest += span.count();
604 } 606 }
605 fDest = dest; 607 fDest = dest;
606 } 608 }
607 609
608 void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override { SkFAIL("Not Implemen ted"); } 610 void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override { SkFAIL("Not Implemen ted"); }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { 849 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) {
848 SkASSERT(count > 0); 850 SkASSERT(count > 0);
849 fLastStage->setDestination(dst, count); 851 fLastStage->setDestination(dst, count);
850 852
851 // The count and length arguments start out in a precise relation in order t o keep the 853 // The count and length arguments start out in a precise relation in order t o keep the
852 // math correct through the different stages. Count is the number of pixel t o produce. 854 // math correct through the different stages. Count is the number of pixel t o produce.
853 // Since the code samples at pixel centers, length is the distance from the center of the 855 // Since the code samples at pixel centers, length is the distance from the center of the
854 // first pixel to the center of the last pixel. This implies that length is count-1. 856 // first pixel to the center of the last pixel. This implies that length is count-1.
855 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); 857 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count});
856 } 858 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698