| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res
pectImageOrientationEnum, ImageClampingMode) override | 73 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res
pectImageOrientationEnum, ImageClampingMode) override |
| 74 { | 74 { |
| 75 // Image pure virtual stub. | 75 // Image pure virtual stub. |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 TestImage(IntSize size, bool opaque) | 79 TestImage(IntSize size, bool opaque) |
| 80 : Image(0) | 80 : Image(0) |
| 81 , m_size(size) | 81 , m_size(size) |
| 82 { | 82 { |
| 83 RefPtr<SkSurface> surface = adoptRef(createSkSurface(size, opaque)); | 83 sk_sp<SkSurface> surface = createSkSurface(size, opaque); |
| 84 if (!surface) | 84 if (!surface) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | 87 surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
| 88 m_image = adoptRef(surface->newImageSnapshot()); | 88 m_image = adoptRef(surface->newImageSnapshot()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static SkSurface* createSkSurface(IntSize size, bool opaque) | 91 static sk_sp<SkSurface> createSkSurface(IntSize size, bool opaque) |
| 92 { | 92 { |
| 93 return SkSurface::NewRaster(SkImageInfo::MakeN32(size.width(), size.heig
ht(), opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); | 93 return SkSurface::MakeRaster(SkImageInfo::MakeN32(size.width(), size.hei
ght(), opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 IntSize m_size; | 96 IntSize m_size; |
| 97 RefPtr<SkImage> m_image; | 97 RefPtr<SkImage> m_image; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // anonymous namespace | 100 } // anonymous namespace |
| 101 | 101 |
| 102 TEST(ImageLayerChromiumTest, imageLayerContentReset) | 102 TEST(ImageLayerChromiumTest, imageLayerContentReset) |
| 103 { | 103 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 ASSERT_FALSE(graphicsLayer->contentsLayer()); | 136 ASSERT_FALSE(graphicsLayer->contentsLayer()); |
| 137 | 137 |
| 138 graphicsLayer->setContentsToImage(opaqueImage.get()); | 138 graphicsLayer->setContentsToImage(opaqueImage.get()); |
| 139 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); | 139 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); |
| 140 | 140 |
| 141 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); | 141 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); |
| 142 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); | 142 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |