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 SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlph
aType); | 88 SkImageFilter::OutputProperties outProps(img->getColorSpace()); |
89 | 89 sk_sp<SkSpecialSurface> surf(img->makeSurface(outProps, SkISize::Make(kFullS
ize, kFullSize), |
90 sk_sp<SkSpecialSurface> surf(img->makeSurface(info)); | 90 kOpaque_SkAlphaType)); |
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 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), | 125 SkImageFilter::OutputProperties outProps(img->getColorSpace()); |
126 kPremul_SkAlphaType); | 126 sk_sp<SkSurface> tightSurf(img->makeTightSurface(outProps, subset.size()
)); |
127 sk_sp<SkSurface> tightSurf(img->makeTightSurface(info)); | |
128 | 127 |
129 REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); | 128 REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); |
130 REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); | 129 REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); |
131 REPORTER_ASSERT(reporter, peekTextureSucceeds == | 130 REPORTER_ASSERT(reporter, peekTextureSucceeds == |
132 !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_Back
endHandleAccess)); | 131 !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_Back
endHandleAccess)); |
133 SkPixmap tmpPixmap; | 132 SkPixmap tmpPixmap; |
134 REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels
(&tmpPixmap)); | 133 REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels
(&tmpPixmap)); |
135 } | 134 } |
136 } | 135 } |
137 | 136 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 284 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
286 } | 285 } |
287 | 286 |
288 { | 287 { |
289 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 288 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
290 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 289 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
291 } | 290 } |
292 } | 291 } |
293 | 292 |
294 #endif | 293 #endif |
OLD | NEW |