Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: skia/ext/bitmap_platform_device_win.h

Issue 2618323005: override raster-allocator (Closed)
Patch Set: add new file Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "skia/ext/platform_device.h"
11
12 namespace skia {
13
14 // A device is basically a wrapper around SkBitmap that provides a surface for
15 // SkCanvas to draw into. Our device provides a surface Windows can also write
16 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a
17 // format that Skia supports and can then use this to draw ClearType into, etc.
18 // This pixel data is provided to the bitmap that the device contains so that it
19 // can be shared.
20 class SK_API BitmapPlatformDevice final : public SkBitmapDevice,
21 public PlatformDevice {
22 public:
23 // Factory function. is_opaque should be set if the caller knows the bitmap
24 // will be completely opaque and allows some optimizations.
25 //
26 // The |shared_section| parameter is optional (pass NULL for default
27 // behavior). If |shared_section| is non-null, then it must be a handle to a
28 // file-mapping object returned by CreateFileMapping. See CreateDIBSection
29 // for details. If |shared_section| is null, the bitmap backing store is not
30 // initialized.
31 static BitmapPlatformDevice* Create(int width, int height,
32 bool is_opaque, HANDLE shared_section,
33 bool do_clear = false);
34
35 // Create a BitmapPlatformDevice with no shared section. The bitmap is not
36 // initialized to 0.
37 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
38
39 ~BitmapPlatformDevice() override;
40
41 protected:
42 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
43
44 private:
45 // PlatformDevice override
46 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The
47 // bitmap DC may be lazily created.
48 NativeDrawingContext BeginPlatformPaint(const SkMatrix& transform,
49 const SkIRect& clip_bounds) override;
50
51 // Private constructor.
52 BitmapPlatformDevice(HBITMAP hbitmap, const SkBitmap& bitmap);
53
54 // Bitmap into which the drawing will be done. This bitmap not owned by this
55 // class, but by the BitmapPlatformPixelRef inside the device's SkBitmap.
56 // It's only stored here in order to lazy-create the DC (below).
57 HBITMAP hbitmap_;
58
59 // Previous bitmap held by the DC. This will be selected back before the
60 // DC is destroyed.
61 HBITMAP old_hbitmap_;
62
63 // Lazily-created DC used to draw into the bitmap; see GetBitmapDC().
64 HDC hdc_;
65
66 // Create/destroy hdc_, which is the memory DC for our bitmap data.
67 HDC GetBitmapDC(const SkMatrix& transform, const SkIRect& clip_bounds);
68 void ReleaseBitmapDC();
69 bool IsBitmapDCCreated() const;
70
71 // Loads the current transform and clip into the context. Can be called even
72 // when |hbitmap_| is NULL (will be a NOP).
73 void LoadConfig(const SkMatrix& transform, const SkIRect& clip_bounds);
74
75 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
76 };
77
78 } // namespace skia
79
80 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698