| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
| 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // Creates a context for |data| and calls Create. | 41 // Creates a context for |data| and calls Create. |
| 42 // If |data| is NULL, then the bitmap backing store is not initialized. | 42 // If |data| is NULL, then the bitmap backing store is not initialized. |
| 43 static BitmapPlatformDevice* CreateWithData(uint8_t* data, | 43 static BitmapPlatformDevice* CreateWithData(uint8_t* data, |
| 44 int width, int height, | 44 int width, int height, |
| 45 bool is_opaque); | 45 bool is_opaque); |
| 46 | 46 |
| 47 ~BitmapPlatformDevice() override; | 47 ~BitmapPlatformDevice() override; |
| 48 | 48 |
| 49 // PlatformDevice overrides | 49 // PlatformDevice overrides |
| 50 CGContextRef GetBitmapContext() override; | 50 CGContextRef GetBitmapContext(const SkMatrix& transform, |
| 51 | 51 const SkIRect& clip_bounds) override; |
| 52 // SkBaseDevice overrides | |
| 53 void setMatrixClip(const SkMatrix& transform, | |
| 54 const SkRegion& region, | |
| 55 const SkClipStack&) override; | |
| 56 | 52 |
| 57 protected: | 53 protected: |
| 58 BitmapPlatformDevice(CGContextRef context, | 54 BitmapPlatformDevice(CGContextRef context, |
| 59 const SkBitmap& bitmap); | 55 const SkBitmap& bitmap); |
| 60 | 56 |
| 61 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 57 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
| 62 | 58 |
| 63 private: | 59 private: |
| 64 void ReleaseBitmapContext(); | 60 void ReleaseBitmapContext(); |
| 65 | 61 |
| 66 // Sets the transform and clip operations. This will not update the CGContext, | |
| 67 // but will mark the config as dirty. The next call of LoadConfig will | |
| 68 // pick up these changes. | |
| 69 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region); | |
| 70 | |
| 71 // Loads the current transform and clip into the context. Can be called even | 62 // Loads the current transform and clip into the context. Can be called even |
| 72 // when |bitmap_context_| is NULL (will be a NOP). | 63 // when |bitmap_context_| is NULL (will be a NOP). |
| 73 void LoadConfig(); | 64 void LoadConfig(const SkMatrix& transform, const SkIRect& clip_bounds); |
| 74 | 65 |
| 75 // Lazily-created graphics context used to draw into the bitmap. | 66 // Lazily-created graphics context used to draw into the bitmap. |
| 76 CGContextRef bitmap_context_; | 67 CGContextRef bitmap_context_; |
| 77 | 68 |
| 78 // True when there is a transform or clip that has not been set to the | |
| 79 // context. The context is retrieved for every text operation, and the | |
| 80 // transform and clip do not change as much. We can save time by not loading | |
| 81 // the clip and transform for every one. | |
| 82 bool config_dirty_; | |
| 83 | |
| 84 // Translation assigned to the context: we need to keep track of this | |
| 85 // separately so it can be updated even if the context isn't created yet. | |
| 86 SkMatrix transform_; | |
| 87 | |
| 88 // The current clipping | |
| 89 SkRegion clip_region_; | |
| 90 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 69 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
| 91 }; | 70 }; |
| 92 | 71 |
| 93 } // namespace skia | 72 } // namespace skia |
| 94 | 73 |
| 95 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ | 74 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_MAC_H_ |
| OLD | NEW |