| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 explicit TestImage(PassRefPtr<SkImage> image) | 91 explicit TestImage(PassRefPtr<SkImage> image) |
| 92 : m_image(image) | 92 : m_image(image) |
| 93 { | 93 { |
| 94 } | 94 } |
| 95 | 95 |
| 96 explicit TestImage(IntSize size) | 96 explicit TestImage(IntSize size) |
| 97 : m_image(nullptr) | 97 : m_image(nullptr) |
| 98 { | 98 { |
| 99 RefPtr<SkSurface> surface = adoptRef(createSkSurface(size)); | 99 sk_sp<SkSurface> surface = createSkSurface(size); |
| 100 if (!surface) | 100 if (!surface) |
| 101 return; | 101 return; |
| 102 | 102 |
| 103 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | 103 surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
| 104 m_image = adoptRef(surface->newImageSnapshot()); | 104 m_image = adoptRef(surface->newImageSnapshot()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 static SkSurface* createSkSurface(IntSize size) | 107 static sk_sp<SkSurface> createSkSurface(IntSize size) |
| 108 { | 108 { |
| 109 return SkSurface::NewRaster(SkImageInfo::MakeN32(size.width(), size.heig
ht(), kPremul_SkAlphaType)); | 109 return SkSurface::MakeRaster(SkImageInfo::MakeN32(size.width(), size.hei
ght(), kPremul_SkAlphaType)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 RefPtr<SkImage> m_image; | 112 RefPtr<SkImage> m_image; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 TEST(DragImageTest, NullHandling) | 115 TEST(DragImageTest, NullHandling) |
| 116 { | 116 { |
| 117 EXPECT_FALSE(DragImage::create(0)); | 117 EXPECT_FALSE(DragImage::create(0)); |
| 118 | 118 |
| 119 RefPtr<TestImage> nullTestImage(TestImage::create(IntSize())); | 119 RefPtr<TestImage> nullTestImage(TestImage::create(IntSize())); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 { | 228 { |
| 229 SkAutoLockPixels lock1(dragBitmap); | 229 SkAutoLockPixels lock1(dragBitmap); |
| 230 SkAutoLockPixels lock2(expectedBitmap); | 230 SkAutoLockPixels lock2(expectedBitmap); |
| 231 for (int x = 0; x < dragBitmap.width(); ++x) | 231 for (int x = 0; x < dragBitmap.width(); ++x) |
| 232 for (int y = 0; y < dragBitmap.height(); ++y) | 232 for (int y = 0; y < dragBitmap.height(); ++y) |
| 233 EXPECT_EQ(expectedBitmap.getColor(x, y), dragBitmap.getColor(x,
y)); | 233 EXPECT_EQ(expectedBitmap.getColor(x, y), dragBitmap.getColor(x,
y)); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |