OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_LAYER_ALLOCATOR_WIN_H_ |
| 6 #define SKIA_EXT_LAYER_ALLOCATOR_WIN_H_ |
| 7 |
| 8 #include "skia/ext/platform_surface.h" |
| 9 |
| 10 #include "third_party/skia/include/core/SkRasterCanvasLayerAllocator.h" |
| 11 |
| 12 #include <unordered_map> |
| 13 |
| 14 namespace skia { |
| 15 |
| 16 /* |
| 17 * On Windows, a PlatformCanvas is backed by a CreateDIBSection()-allocated |
| 18 * bitmap; a PlatformSurface is an HDC. |
| 19 */ |
| 20 class LayerAllocator : public SkRasterCanvasLayerAllocator { |
| 21 public: |
| 22 LayerAllocator(); |
| 23 ~LayerAllocator() override; |
| 24 |
| 25 /// Returns HDC. |
| 26 void* getNativeContext(void* buffer, |
| 27 const SkMatrix& transform, |
| 28 const SkIRect& clip_bounds) override; |
| 29 |
| 30 protected: |
| 31 /// Expects a HANDLE to a Windows shared section as (optional) initialData. |
| 32 /// Returns the data pointer from an HBITMAP. |
| 33 /// |deallocator| will ...() and ...() |
| 34 /// the layer. |
| 35 void* allocateLayer(const SkImageInfo& info, size_t* rowBytes, |
| 36 void (**deallocator)(void*), |
| 37 void** deallocatorPayload, |
| 38 void* initialData) override; |
| 39 |
| 40 private: |
| 41 typedef std::unordered_map<void*, HDC> context_map_t; |
| 42 context_map_t contexts_; |
| 43 |
| 44 friend class BitmapPlatformDevice; |
| 45 }; |
| 46 |
| 47 } |
| 48 |
| 49 #endif // SKIA_EXT_LAYER_ALLOCATOR_WIN_H_ |
OLD | NEW |