OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 SkPaint paint; | 64 SkPaint paint; |
65 // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shad
er | 65 // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shad
er |
66 // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here
. | 66 // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here
. |
67 SkBitmap bitmap; | 67 SkBitmap bitmap; |
68 bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2)); | 68 bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2)); |
69 bitmap.eraseColor(SK_ColorBLUE); | 69 bitmap.eraseColor(SK_ColorBLUE); |
70 *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN; | 70 *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN; |
71 SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp
_TileMode, | 71 SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp
_TileMode, |
72 SkShader::kClamp_TileMod
e); | 72 SkShader::kClamp_TileMod
e); |
73 paint.setShader(shader)->unref(); | 73 paint.setShader(shader)->unref(); |
74 REPORTER_ASSERT(reporter, | 74 REPORTER_ASSERT(reporter, shader->isABitmap()); |
75 shader->asABitmap(NULL, NULL, NULL) == SkShader::kDefaul
t_BitmapType); | |
76 | 75 |
77 canvas->drawRect(SkRect::MakeWH(10, 10), paint); | 76 canvas->drawRect(SkRect::MakeWH(10, 10), paint); |
78 } | 77 } |
79 picture.reset(recorder.endRecording()); | 78 picture.reset(recorder.endRecording()); |
80 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps()); | 79 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps()); |
81 } | 80 } |
82 | 81 |
83 | 82 |
84 #ifdef SK_DEBUG | 83 #ifdef SK_DEBUG |
85 // Ensure that deleting an empty SkPicture does not assert. Asserts only fire | 84 // Ensure that deleting an empty SkPicture does not assert. Asserts only fire |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 | 1354 |
1356 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); | 1355 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); |
1357 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr
eam)); | 1356 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr
eam)); |
1358 | 1357 |
1359 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); | 1358 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); |
1360 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); | 1359 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); |
1361 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); | 1360 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); |
1362 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); | 1361 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); |
1363 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); | 1362 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); |
1364 } | 1363 } |
OLD | NEW |