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

Side by Side Diff: tests/BlitMaskClip.cpp

Issue 1453163002: Fix array overrun and add test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix long line Created 5 years, 1 month 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
« src/core/SkBlitter.cpp ('K') | « src/core/SkBlitter.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
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBlitter.h"
9 #include "SkMask.h"
10 #include "Test.h"
11
12 class TestBlitter : public SkBlitter {
13 public:
14 TestBlitter(SkIRect bounds, skiatest::Reporter* reporter)
15 : fBounds(bounds)
16 , fReporter(reporter) { }
17
18 virtual void blitH(int x, int y, int width) override {
reed1 2015/11/17 16:24:32 our new convention is to *not* say virtual when we
herb_g 2015/11/17 20:14:03 Done.
19
20 REPORTER_ASSERT(fReporter, x >= fBounds.fLeft && x < fBounds.fRight);
21 REPORTER_ASSERT(fReporter, y >= fBounds.fTop && y < fBounds.fBottom);
22 int right = x + width;
23 REPORTER_ASSERT(fReporter, right > fBounds.fLeft && right <= fBounds.fRi ght);
24 }
25
26 private:
27 SkIRect fBounds;
28 skiatest::Reporter* fReporter;
29 };
30
reed1 2015/11/17 16:24:32 Perhaps a small block-comment? // Exercise all co
herb_g 2015/11/17 20:14:03 Done.
31 DEF_TEST(BlitAndClip, reporter) {
32 const int originX = 100;
33 const int originY = 100;
34 for (int width = 1; width <= 32; width++) {
35 const int height = 2;
36 int rowBytes = (width + 7) >> 3;
37 uint8_t* bits = new uint8_t[rowBytes * height];
38
39 SkIRect b = {originX, originY, originX + width, originY + height};
40
41 SkMask mask;
42 mask.fFormat = SkMask::kBW_Format;
43 mask.fBounds = b;
44 mask.fImage = (uint8_t*)bits;
45 mask.fRowBytes = rowBytes;
46
47 TestBlitter tb(mask.fBounds, reporter);
48
49 for (int top = b.fTop; top < b.fBottom; top++) {
50 for (int bottom = top + 1; bottom <= b.fBottom; bottom++) {
51 for (int left = b.fLeft; left < b.fRight; left++) {
52 for (int right = left + 1; right <= b.fRight; right++) {
53 SkIRect clipRect = {left, top, right, bottom};
54 tb.blitMask(mask, clipRect);
55 }
56 }
57 }
58 }
59
60 delete [] bits;
61 }
62 }
OLDNEW
« src/core/SkBlitter.cpp ('K') | « src/core/SkBlitter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698