Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
2010-03-17 Stephan Aßmus <superstippi@gmx.de>
Reviewed by Oliver Hunt. [Haiku] Implement ImageBuffer support https://bugs.webkit.org/show_bug.cgi?id=35288 Covered by existing tests. The StillImage class implements WebCore::Image by wrapping a native BBitmap. It will be needed to implement WebCore::ImageBuffer. This solution is just like it's done in the Qt port. * platform/graphics/haiku/StillImageHaiku.cpp: Added. (WebCore::StillImage::StillImage): (WebCore::StillImage::destroyDecodedData): (WebCore::StillImage::decodedSize): (WebCore::StillImage::size): (WebCore::StillImage::nativeImageForCurrentFrame): (WebCore::StillImage::draw): * platform/graphics/haiku/StillImageHaiku.h: Added. (WebCore::StillImage::create): Canonical link: https://commits.webkit.org/47443@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@56149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
3 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de> | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "StillImageHaiku.h" | ||
|
||
#include "GraphicsContext.h" | ||
#include "IntSize.h" | ||
#include <View.h> | ||
|
||
namespace WebCore { | ||
|
||
StillImage::StillImage(const BBitmap& bitmap) | ||
: m_bitmap(&bitmap) | ||
{ | ||
} | ||
|
||
void StillImage::destroyDecodedData(bool destroyAll) | ||
{ | ||
// This is used for "large" animations to free image data. | ||
// It appears it would not apply to StillImage. | ||
} | ||
|
||
unsigned StillImage::decodedSize() const | ||
{ | ||
// FIXME: It could be wise to return 0 here, since we don't want WebCore | ||
// to think we eat up memory, since we are not freeing any in | ||
// destroyDecodedData() either. | ||
return m_bitmap.BitsLength(); | ||
} | ||
|
||
IntSize StillImage::size() const | ||
{ | ||
return IntSize(m_bitmap.Bounds().IntegerWidth() + 1, m_bitmap.Bounds().IntegerHeight() + 1); | ||
} | ||
|
||
NativeImagePtr StillImage::nativeImageForCurrentFrame() | ||
{ | ||
return &m_bitmap; | ||
} | ||
|
||
void StillImage::draw(GraphicsContext* context, const FloatRect& destRect, | ||
const FloatRect& sourceRect, ColorSpace, CompositeOperator op) | ||
{ | ||
if (!m_bitmap.IsValid()) | ||
return; | ||
|
||
context->save(); | ||
context->setCompositeOperation(op); | ||
context->platformContext()->DrawBitmap(&m_bitmap, sourceRect, destRect); | ||
context->restore(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de> | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef StillImageHaiku_h | ||
#define StillImageHaiku_h | ||
|
||
#include "Image.h" | ||
#include <Bitmap.h> | ||
|
||
namespace WebCore { | ||
|
||
class StillImage : public Image { | ||
public: | ||
static PassRefPtr<StillImage> create(const BBitmap& bitmap) | ||
{ | ||
return adoptRef(new StillImage(bitmap)); | ||
} | ||
|
||
virtual void destroyDecodedData(bool destroyAll = true); | ||
virtual unsigned decodedSize() const; | ||
|
||
virtual IntSize size() const; | ||
virtual NativeImagePtr nativeImageForCurrentFrame(); | ||
virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator); | ||
|
||
private: | ||
StillImage(const BBitmap&); | ||
|
||
BBitmap m_bitmap; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
#endif // StillImageHaiku_h |