15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2007 Apple Inc.  All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef DragImage_h
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define DragImage_h
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
291e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/IntSize.h"
301e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/graphics/ImageOrientation.h"
31591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "third_party/skia/include/core/SkBitmap.h"
32591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "wtf/Forward.h"
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
34c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
35591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
36591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochclass FontDescription;
37591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochclass Image;
38591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochclass KURL;
39591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
4009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class PLATFORM_EXPORT DragImage {
41591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochpublic:
4209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    static PassOwnPtr<DragImage> create(Image*, RespectImageOrientationEnum = DoNotRespectImageOrientation, float deviceScaleFactor = 1);
43591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    static PassOwnPtr<DragImage> create(const KURL&, const String& label, const FontDescription& systemFont, float deviceScaleFactor);
44591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    ~DragImage();
45591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
46591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    const SkBitmap& bitmap() { return m_bitmap; }
47591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    float resolutionScale() const { return m_resolutionScale; }
48591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    IntSize size() const { return IntSize(m_bitmap.width(), m_bitmap.height()); }
49591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
50591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    void fitToMaxSize(const IntSize& srcSize, const IntSize& maxSize);
51591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    void scale(float scaleX, float scaleY);
52591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    void dissolveToFraction(float fraction);
53591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
54591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochprivate:
55591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    DragImage(const SkBitmap&, float resolutionScale);
56591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
57591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    SkBitmap m_bitmap;
58591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    float m_resolutionScale;
59591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch};
60591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
63591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#endif // DragImage_h
64