| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res
pectImageOrientationEnum, ImageClampingMode) override | 66 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res
pectImageOrientationEnum, ImageClampingMode) override |
| 67 { | 67 { |
| 68 // Image pure virtual stub. | 68 // Image pure virtual stub. |
| 69 } | 69 } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 TestImage(IntSize size, bool opaque) | 72 TestImage(IntSize size, bool opaque) |
| 73 : Image(0) | 73 : Image(0) |
| 74 , m_size(size) | 74 , m_size(size) |
| 75 { | 75 { |
| 76 RefPtr<SkSurface> surface = adoptRef(createSkSurface(size, opaque)); | 76 sk_sp<SkSurface> surface = createSkSurface(size, opaque); |
| 77 if (!surface) | 77 if (!surface) |
| 78 return; | 78 return; |
| 79 | 79 |
| 80 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | 80 surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
| 81 m_image = adoptRef(surface->newImageSnapshot()); | 81 m_image = adoptRef(surface->newImageSnapshot()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 static SkSurface* createSkSurface(IntSize size, bool opaque) | 84 static sk_sp<SkSurface> createSkSurface(IntSize size, bool opaque) |
| 85 { | 85 { |
| 86 return SkSurface::NewRaster(SkImageInfo::MakeN32(size.width(), size.heig
ht(), opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); | 86 return SkSurface::MakeRaster(SkImageInfo::MakeN32(size.width(), size.hei
ght(), opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 IntSize m_size; | 89 IntSize m_size; |
| 90 RefPtr<SkImage> m_image; | 90 RefPtr<SkImage> m_image; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // anonymous namespace | 93 } // anonymous namespace |
| 94 | 94 |
| 95 TEST(ImageLayerChromiumTest, imageLayerContentReset) | 95 TEST(ImageLayerChromiumTest, imageLayerContentReset) |
| 96 { | 96 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 129 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
| 130 | 130 |
| 131 graphicsLayer->setContentsToImage(opaqueImage.get()); | 131 graphicsLayer->setContentsToImage(opaqueImage.get()); |
| 132 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); | 132 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); |
| 133 | 133 |
| 134 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); | 134 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); |
| 135 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); | 135 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |