| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_GFX_PLATFORM_DEVICE_WIN_H__ | 5 #ifndef BASE_GFX_PLATFORM_DEVICE_WIN_H__ |
| 6 #define BASE_GFX_PLATFORM_DEVICE_WIN_H__ | 6 #define BASE_GFX_PLATFORM_DEVICE_WIN_H__ |
| 7 | 7 |
| 8 #include <vector> | 8 // TODO(brettw) this file should be removed and the includes changed to this |
| 9 | 9 // new location. |
| 10 #include "SkDevice.h" | 10 #include "webkit/port/platform/graphics/skia/public/PlatformDeviceWin.h" |
| 11 | |
| 12 class SkMatrix; | |
| 13 class SkPath; | |
| 14 class SkRegion; | |
| 15 | |
| 16 namespace gfx { | |
| 17 | |
| 18 // A device is basically a wrapper around SkBitmap that provides a surface for | |
| 19 // SkCanvas to draw into. Our device provides a surface Windows can also write | |
| 20 // to. It also provides functionality to play well with GDI drawing functions. | |
| 21 // This class is abstract and must be subclassed. It provides the basic | |
| 22 // interface to implement it either with or without a bitmap backend. | |
| 23 class PlatformDeviceWin : public SkDevice { | |
| 24 public: | |
| 25 // The DC that corresponds to the bitmap, used for GDI operations drawing | |
| 26 // into the bitmap. This is possibly heavyweight, so it should be existant | |
| 27 // only during one pass of rendering. | |
| 28 virtual HDC getBitmapDC() = 0; | |
| 29 | |
| 30 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will | |
| 31 // temporarily create it. However, if you have created the bitmap DC, it will | |
| 32 // be more efficient if you don't free it until after this call so it doesn't | |
| 33 // have to be created twice. If src_rect is null, then the entirety of the | |
| 34 // source device will be copied. | |
| 35 virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect) = 0; | |
| 36 | |
| 37 // Invoke before using GDI functions. See description in platform_device.cc | |
| 38 // for specifics. | |
| 39 // NOTE: x,y,width and height are relative to the current transform. | |
| 40 virtual void prepareForGDI(int x, int y, int width, int height) { } | |
| 41 | |
| 42 // Invoke after using GDI functions. See description in platform_device.cc | |
| 43 // for specifics. | |
| 44 // NOTE: x,y,width and height are relative to the current transform. | |
| 45 virtual void postProcessGDI(int x, int y, int width, int height) { } | |
| 46 | |
| 47 // Sets the opacity of each pixel in the specified region to be opaque. | |
| 48 virtual void makeOpaque(int x, int y, int width, int height) { } | |
| 49 | |
| 50 // Call this function to fix the alpha channels before compositing this layer | |
| 51 // onto another. Internally, the device uses a special alpha method to work | |
| 52 // around problems with Windows. This call will put the values into what | |
| 53 // Skia expects, so it can be composited onto other layers. | |
| 54 // | |
| 55 // After this call, no more drawing can be done because the | |
| 56 // alpha channels will be "correct", which, if this function is called again | |
| 57 // will make them wrong. See the implementation for more discussion. | |
| 58 virtual void fixupAlphaBeforeCompositing() { } | |
| 59 | |
| 60 // Returns if the preferred rendering engine is vectorial or bitmap based. | |
| 61 virtual bool IsVectorial() = 0; | |
| 62 | |
| 63 // Initializes the default settings and colors in a device context. | |
| 64 static void InitializeDC(HDC context); | |
| 65 | |
| 66 // Loads a SkPath into the GDI context. The path can there after be used for | |
| 67 // clipping or as a stroke. | |
| 68 static void LoadPathToDC(HDC context, const SkPath& path); | |
| 69 | |
| 70 // Loads a SkRegion into the GDI context. | |
| 71 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, | |
| 72 const SkMatrix& transformation); | |
| 73 | |
| 74 protected: | |
| 75 // Arrays must be inside structures. | |
| 76 struct CubicPoints { | |
| 77 SkPoint p[4]; | |
| 78 }; | |
| 79 typedef std::vector<CubicPoints> CubicPath; | |
| 80 typedef std::vector<CubicPath> CubicPaths; | |
| 81 | |
| 82 // Forwards |bitmap| to SkDevice's constructor. | |
| 83 PlatformDeviceWin(const SkBitmap& bitmap); | |
| 84 | |
| 85 // Loads the specified Skia transform into the device context, excluding | |
| 86 // perspective (which GDI doesn't support). | |
| 87 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); | |
| 88 | |
| 89 // Transforms SkPath's paths into a series of cubic path. | |
| 90 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); | |
| 91 }; | |
| 92 | |
| 93 } // namespace gfx | |
| 94 | 11 |
| 95 #endif // BASE_GFX_PLATFORM_DEVICE_WIN_H__ | 12 #endif // BASE_GFX_PLATFORM_DEVICE_WIN_H__ |
| 96 | 13 |
| OLD | NEW |