OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Draw something different to the same portion of the bitmap that w
e will extract as a | 154 // Draw something different to the same portion of the bitmap that w
e will extract as a |
155 // subset, so that comparing the pixels of the subset will be meanin
gful. | 155 // subset, so that comparing the pixels of the subset will be meanin
gful. |
156 SkIRect subsetRect = SkIRect::MakeLTRB(W/2, H/2, W, H); | 156 SkIRect subsetRect = SkIRect::MakeLTRB(W/2, H/2, W, H); |
157 SkCanvas drawingCanvas(device); | 157 SkCanvas drawingCanvas(device); |
158 SkPaint paint; | 158 SkPaint paint; |
159 paint.setColor(SK_ColorRED); | 159 paint.setColor(SK_ColorRED); |
160 drawingCanvas.drawRect(SkRect::Make(subsetRect), paint); | 160 drawingCanvas.drawRect(SkRect::Make(subsetRect), paint); |
161 | 161 |
162 // Extract a subset. If this succeeds we will test copying the subse
t. | 162 // Extract a subset. If this succeeds we will test copying the subse
t. |
163 SkBitmap subset; | 163 SkBitmap subset; |
| 164 #ifdef SK_SUPPORT_DEEPCOPYTO_CONFIG |
164 const bool extracted = src.extractSubset(&subset, subsetRect); | 165 const bool extracted = src.extractSubset(&subset, subsetRect); |
165 | 166 |
166 for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) { | 167 for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) { |
167 dst.reset(); | 168 dst.reset(); |
168 bool success = src.deepCopyTo(&dst, gPairs[j].fConfig); | 169 bool success = src.deepCopyTo(&dst, gPairs[j].fConfig); |
169 bool expected = gPairs[i].fValid[j] != '0'; | 170 bool expected = gPairs[i].fValid[j] != '0'; |
170 if (success != expected) { | 171 if (success != expected) { |
171 ERRORF(reporter, "SkBitmap::deepCopyTo from %s to %s. " | 172 ERRORF(reporter, "SkBitmap::deepCopyTo from %s to %s. " |
172 "expected %s returned %s", gConfigName[i], | 173 "expected %s returned %s", gConfigName[i], |
173 gConfigName[j], boolStr(expected), | 174 gConfigName[j], boolStr(expected), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // deepCopyTo copies the entire pixelref, even if the bitmap
only represents | 222 // deepCopyTo copies the entire pixelref, even if the bitmap
only represents |
222 // a subset. Therefore, the result should share the same gen
ID. | 223 // a subset. Therefore, the result should share the same gen
ID. |
223 subsetCopy.reset(); | 224 subsetCopy.reset(); |
224 success = trueSubset.deepCopyTo(&subsetCopy, gPairs[j].fConf
ig); | 225 success = trueSubset.deepCopyTo(&subsetCopy, gPairs[j].fConf
ig); |
225 REPORTER_ASSERT(reporter, success == expected); | 226 REPORTER_ASSERT(reporter, success == expected); |
226 REPORTER_ASSERT(reporter, success == canSucceed); | 227 REPORTER_ASSERT(reporter, success == canSucceed); |
227 TestIndividualCopy(reporter, gPairs[j].fConfig, success, tru
eSubset, subsetCopy, | 228 TestIndividualCopy(reporter, gPairs[j].fConfig, success, tru
eSubset, subsetCopy, |
228 true); | 229 true); |
229 } | 230 } |
230 } // for (size_t j = ... | 231 } // for (size_t j = ... |
| 232 #endif |
231 } // for (size_t i = ... | 233 } // for (size_t i = ... |
232 } // GrContextFactory::GLContextType | 234 } // GrContextFactory::GLContextType |
233 } | 235 } |
234 | 236 |
235 #endif | 237 #endif |
OLD | NEW |