| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006,2007,2008, 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // is that NativeImagePtr = NativeImageSkia, yet callers have SkBitmap. | 46 // is that NativeImagePtr = NativeImageSkia, yet callers have SkBitmap. |
| 47 class BitmapImageSingleFrameSkia : public Image { | 47 class BitmapImageSingleFrameSkia : public Image { |
| 48 public: | 48 public: |
| 49 // Creates a new Image from the given SkBitmap. If "copyPixels" is true, a | 49 // Creates a new Image from the given SkBitmap. If "copyPixels" is true, a |
| 50 // deep copy is done. Otherwise, a shallow copy is done (pixel data is | 50 // deep copy is done. Otherwise, a shallow copy is done (pixel data is |
| 51 // ref'ed). | 51 // ref'ed). |
| 52 static PassRefPtr<BitmapImageSingleFrameSkia> create(const SkBitmap&, bool c
opyPixels); | 52 static PassRefPtr<BitmapImageSingleFrameSkia> create(const SkBitmap&, bool c
opyPixels); |
| 53 | 53 |
| 54 virtual bool isBitmapImage() const { return true; } | 54 virtual bool isBitmapImage() const { return true; } |
| 55 | 55 |
| 56 virtual bool currentFrameHasAlpha() { return !m_nativeImage.isOpaque(); } |
| 57 |
| 56 virtual IntSize size() const | 58 virtual IntSize size() const |
| 57 { | 59 { |
| 58 return IntSize(m_nativeImage.width(), m_nativeImage.height()); | 60 return IntSize(m_nativeImage.width(), m_nativeImage.height()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 // Do nothing, as we only have the one representation of data (decoded). | 63 // Do nothing, as we only have the one representation of data (decoded). |
| 62 virtual void destroyDecodedData(bool destroyAll = true) { } | 64 virtual void destroyDecodedData(bool destroyAll = true) { } |
| 63 | 65 |
| 64 virtual unsigned decodedSize() const | 66 virtual unsigned decodedSize() const |
| 65 { | 67 { |
| 66 return m_nativeImage.decodedSize(); | 68 return m_nativeImage.decodedSize(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 // We only have a single frame. | 71 // We only have a single frame. |
| 70 virtual NativeImagePtr nativeImageForCurrentFrame() | 72 virtual NativeImagePtr nativeImageForCurrentFrame() |
| 71 { | 73 { |
| 72 return &m_nativeImage; | 74 return &m_nativeImage; |
| 73 } | 75 } |
| 74 | 76 |
| 77 #if !ASSERT_DISABLED |
| 78 virtual bool notSolidColor() |
| 79 { |
| 80 return m_nativeImage.width() != 1 || m_nativeImage.height() != 1; |
| 81 } |
| 82 #endif |
| 83 |
| 75 protected: | 84 protected: |
| 76 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRec
t& srcRect, ColorSpace styleColorSpace, CompositeOperator); | 85 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRec
t& srcRect, ColorSpace styleColorSpace, CompositeOperator); |
| 77 | 86 |
| 78 private: | 87 private: |
| 79 NativeImageSkia m_nativeImage; | 88 NativeImageSkia m_nativeImage; |
| 80 | 89 |
| 81 // Creates a new Image from the given SkBitmap, using a shallow copy. | 90 // Creates a new Image from the given SkBitmap, using a shallow copy. |
| 82 explicit BitmapImageSingleFrameSkia(const SkBitmap&); | 91 explicit BitmapImageSingleFrameSkia(const SkBitmap&); |
| 83 }; | 92 }; |
| 84 | 93 |
| 85 FloatRect normalizeRect(const FloatRect&); | 94 FloatRect normalizeRect(const FloatRect&); |
| 86 | 95 |
| 87 } // namespace WebCore | 96 } // namespace WebCore |
| 88 | 97 |
| 89 #endif // BitmapImageSingleFrameSkia_h | 98 #endif // BitmapImageSingleFrameSkia_h |
| OLD | NEW |