OLD | NEW |
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 "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if (context) { | 78 if (context) { |
79 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width()); | 79 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width()); |
80 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height()); | 80 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height()); |
81 } else { | 81 } else { |
82 REPORTER_ASSERT(reporter, size == bitmap.width()); | 82 REPORTER_ASSERT(reporter, size == bitmap.width()); |
83 REPORTER_ASSERT(reporter, size == bitmap.height()); | 83 REPORTER_ASSERT(reporter, size == bitmap.height()); |
84 } | 84 } |
85 | 85 |
86 //-------------- | 86 //-------------- |
87 // Test that draw restricts itself to the subset | 87 // Test that draw restricts itself to the subset |
88 SkImageFilter::OutputProperties outProps(img->getColorSpace()); | 88 SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlph
aType); |
89 sk_sp<SkSpecialSurface> surf(img->makeSurface(outProps, SkISize::Make(kFullS
ize, kFullSize), | 89 |
90 kOpaque_SkAlphaType)); | 90 sk_sp<SkSpecialSurface> surf(img->makeSurface(info)); |
91 | 91 |
92 SkCanvas* canvas = surf->getCanvas(); | 92 SkCanvas* canvas = surf->getCanvas(); |
93 | 93 |
94 canvas->clear(SK_ColorBLUE); | 94 canvas->clear(SK_ColorBLUE); |
95 img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); | 95 img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); |
96 | 96 |
97 SkBitmap bm; | 97 SkBitmap bm; |
98 bm.allocN32Pixels(kFullSize, kFullSize, true); | 98 bm.allocN32Pixels(kFullSize, kFullSize, true); |
99 | 99 |
100 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0
, 0); | 100 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0
, 0); |
(...skipping 14 matching lines...) Expand all Loading... |
115 { | 115 { |
116 sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset)); | 116 sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset)); |
117 | 117 |
118 REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); | 118 REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); |
119 REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); | 119 REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); |
120 REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture(
)); | 120 REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture(
)); |
121 SkPixmap tmpPixmap; | 121 SkPixmap tmpPixmap; |
122 REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightImg->peekPixels(
&tmpPixmap)); | 122 REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightImg->peekPixels(
&tmpPixmap)); |
123 } | 123 } |
124 { | 124 { |
125 SkImageFilter::OutputProperties outProps(img->getColorSpace()); | 125 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), |
126 sk_sp<SkSurface> tightSurf(img->makeTightSurface(outProps, subset.size()
)); | 126 kPremul_SkAlphaType); |
| 127 sk_sp<SkSurface> tightSurf(img->makeTightSurface(info)); |
127 | 128 |
128 REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); | 129 REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); |
129 REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); | 130 REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); |
130 REPORTER_ASSERT(reporter, peekTextureSucceeds == | 131 REPORTER_ASSERT(reporter, peekTextureSucceeds == |
131 !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_Back
endHandleAccess)); | 132 !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_Back
endHandleAccess)); |
132 SkPixmap tmpPixmap; | 133 SkPixmap tmpPixmap; |
133 REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels
(&tmpPixmap)); | 134 REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels
(&tmpPixmap)); |
134 } | 135 } |
135 } | 136 } |
136 | 137 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 285 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
285 } | 286 } |
286 | 287 |
287 { | 288 { |
288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 289 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 290 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
290 } | 291 } |
291 } | 292 } |
292 | 293 |
293 #endif | 294 #endif |
OLD | NEW |