| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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_SKIA_H_ | |
| 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "skia/ext/platform_device.h" | |
| 14 | |
| 15 namespace skia { | |
| 16 | |
| 17 // ----------------------------------------------------------------------------- | |
| 18 // For now we just use SkBitmap for SkBitmapDevice | |
| 19 // | |
| 20 // This is all quite ok for test_shell. In the future we will want to use | |
| 21 // shared memory between the renderer and the main process at least. In this | |
| 22 // case we'll probably create the buffer from a precreated region of memory. | |
| 23 // ----------------------------------------------------------------------------- | |
| 24 class BitmapPlatformDevice final : public SkBitmapDevice, | |
| 25 public PlatformDevice { | |
| 26 public: | |
| 27 // Construct a BitmapPlatformDevice. |is_opaque| should be set if the caller | |
| 28 // knows the bitmap will be completely opaque and allows some optimizations | |
| 29 // (the bitmap is not initialized to 0 when is_opaque == true). | |
| 30 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); | |
| 31 | |
| 32 // This doesn't take ownership of |data|. If |data| is null and |is_opaque| | |
| 33 // is false, the bitmap is initialized to 0. | |
| 34 // | |
| 35 // Note: historicaly, BitmapPlatformDevice impls have had diverging | |
| 36 // initialization behavior for null |data| (Cairo used to initialize, while | |
| 37 // the others did not). For now we stick to the more conservative Cairo | |
| 38 // behavior. | |
| 39 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | |
| 40 uint8_t* data); | |
| 41 | |
| 42 // Create a BitmapPlatformDevice from an already constructed bitmap; | |
| 43 // you should probably be using Create(). This may become private later if | |
| 44 // we ever have to share state between some native drawing UI and Skia, like | |
| 45 // the Windows and Mac versions of this class do. | |
| 46 explicit BitmapPlatformDevice(const SkBitmap& other); | |
| 47 ~BitmapPlatformDevice() override; | |
| 48 | |
| 49 protected: | |
| 50 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | |
| 51 | |
| 52 private: | |
| 53 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | |
| 54 }; | |
| 55 | |
| 56 } // namespace skia | |
| 57 | |
| 58 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_ | |
| OLD | NEW |