Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 #ifndef Image_h | 27 #ifndef Image_h |
| 28 #define Image_h | 28 #define Image_h |
| 29 | 29 |
| 30 #include "platform/PlatformExport.h" | 30 #include "platform/PlatformExport.h" |
| 31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 32 #include "platform/graphics/Color.h" | 32 #include "platform/graphics/Color.h" |
| 33 #include "platform/graphics/GraphicsTypes.h" | 33 #include "platform/graphics/GraphicsTypes.h" |
| 34 #include "platform/graphics/ImageAnimationPolicy.h" | 34 #include "platform/graphics/ImageAnimationPolicy.h" |
| 35 #include "platform/graphics/ImageOrientation.h" | 35 #include "platform/graphics/ImageOrientation.h" |
| 36 #include "platform/graphics/skia/NativeImageSkia.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
|
f(malita)
2015/03/15 00:32:45
Could this be a fwdecl if we move bitmapForCurrent
Stephen White
2015/03/15 16:49:31
Sadly no, since SkBitmap is returned by value. Out
f(malita)
2015/03/16 03:05:06
I think incomplete return types are allowed in dec
| |
| 37 #include "third_party/skia/include/core/SkXfermode.h" | 37 #include "third_party/skia/include/core/SkXfermode.h" |
| 38 #include "wtf/Assertions.h" | 38 #include "wtf/Assertions.h" |
| 39 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 40 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
| 41 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
| 42 #include "wtf/RetainPtr.h" | 42 #include "wtf/RetainPtr.h" |
| 43 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 44 | 44 |
| 45 class SkImage; | 45 class SkImage; |
| 46 | 46 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // Set animationPolicy | 119 // Set animationPolicy |
| 120 virtual void setAnimationPolicy(ImageAnimationPolicy) { } | 120 virtual void setAnimationPolicy(ImageAnimationPolicy) { } |
| 121 virtual ImageAnimationPolicy animationPolicy() { return ImageAnimationPolicy Allowed; } | 121 virtual ImageAnimationPolicy animationPolicy() { return ImageAnimationPolicy Allowed; } |
| 122 | 122 |
| 123 // Typically the ImageResource that owns us. | 123 // Typically the ImageResource that owns us. |
| 124 ImageObserver* imageObserver() const { return m_imageObserver; } | 124 ImageObserver* imageObserver() const { return m_imageObserver; } |
| 125 void setImageObserver(ImageObserver* observer) { m_imageObserver = observer; } | 125 void setImageObserver(ImageObserver* observer) { m_imageObserver = observer; } |
| 126 | 126 |
| 127 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; | 127 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; |
| 128 | 128 |
| 129 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() { return nu llptr; } | 129 virtual SkBitmap bitmapForCurrentFrame() { return SkBitmap(); } |
| 130 | 130 |
| 131 virtual PassRefPtr<Image> imageForDefaultFrame(); | 131 virtual PassRefPtr<Image> imageForDefaultFrame(); |
| 132 | 132 |
| 133 virtual void drawPattern(GraphicsContext*, const FloatRect&, | 133 virtual void drawPattern(GraphicsContext*, const FloatRect&, |
| 134 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, | 134 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, |
| 135 const FloatRect&, const IntSize& repeatSpacing = IntSize()); | 135 const FloatRect&, const IntSize& repeatSpacing = IntSize()); |
| 136 | 136 |
| 137 #if ENABLE(ASSERT) | 137 #if ENABLE(ASSERT) |
| 138 virtual bool notSolidColor() { return true; } | 138 virtual bool notSolidColor() { return true; } |
| 139 #endif | 139 #endif |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 Image(ImageObserver* = 0); | 142 Image(ImageObserver* = 0); |
| 143 | 143 |
| 144 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c onst Color&, SkXfermode::Mode); | 144 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c onst Color&, SkXfermode::Mode); |
| 145 static FloatRect adjustForNegativeSize(const FloatRect&); // A helper method for translating negative width and height values. | 145 static FloatRect adjustForNegativeSize(const FloatRect&); // A helper method for translating negative width and height values. |
| 146 | 146 |
| 147 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRec t& srcRect, SkXfermode::Mode, RespectImageOrientationEnum) = 0; | 147 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRec t& srcRect, SkXfermode::Mode, RespectImageOrientationEnum) = 0; |
| 148 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, | 148 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, |
| 149 SkXfermode::Mode, const IntSize& repeatSpacing); | 149 SkXfermode::Mode, const IntSize& repeatSpacing); |
| 150 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, SkXfe rmode::Mode); | 150 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, SkXfe rmode::Mode); |
| 151 static void drawBitmap(GraphicsContext*, const SkBitmap&, const SkRect& srcR ect, const SkRect& destRect, SkXfermode::Mode); | |
| 152 static void drawBitmapPattern(GraphicsContext*, const SkBitmap&, const Float Rect& srcRect, const FloatSize& scale, const FloatPoint& phase, SkXfermode::Mode , const FloatRect& destRect, const IntSize& repeatSpacing); | |
| 151 | 153 |
| 152 // Supporting tiled drawing | 154 // Supporting tiled drawing |
| 153 virtual bool mayFillWithSolidColor() { return false; } | 155 virtual bool mayFillWithSolidColor() { return false; } |
| 154 virtual Color solidColor() const { return Color(); } | 156 virtual Color solidColor() const { return Color(); } |
| 155 | 157 |
| 156 private: | 158 private: |
| 157 RefPtr<SharedBuffer> m_encodedImageData; | 159 RefPtr<SharedBuffer> m_encodedImageData; |
| 158 ImageObserver* m_imageObserver; | 160 ImageObserver* m_imageObserver; |
| 159 }; | 161 }; |
| 160 | 162 |
| 161 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ | 163 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ |
| 162 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), image.is##t ypeName()) | 164 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), image.is##t ypeName()) |
| 163 | 165 |
| 164 } // namespace blink | 166 } // namespace blink |
| 165 | 167 |
| 166 #endif | 168 #endif |
| OLD | NEW |