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 #include "skia/ext/bitmap_platform_device_android.h" | 5 #include "skia/ext/bitmap_platform_device_android.h" |
6 #include "skia/ext/platform_canvas.h" | |
6 | 7 |
7 namespace skia { | 8 namespace skia { |
8 | 9 |
9 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, | 10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, |
10 bool is_opaque) { | 11 bool is_opaque) { |
11 SkBitmap bitmap; | 12 SkBitmap bitmap; |
12 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 13 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
13 if (bitmap.allocPixels()) { | 14 if (bitmap.allocPixels()) { |
14 bitmap.setIsOpaque(is_opaque); | 15 bitmap.setIsOpaque(is_opaque); |
15 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it | 16 // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 // pixels? Maybe this won't be called at all. | 65 // pixels? Maybe this won't be called at all. |
65 return accessBitmap(true).getPixels(); | 66 return accessBitmap(true).getPixels(); |
66 } | 67 } |
67 | 68 |
68 void BitmapPlatformDevice::DrawToNativeContext( | 69 void BitmapPlatformDevice::DrawToNativeContext( |
69 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { | 70 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { |
70 // Should never be called on Android. | 71 // Should never be called on Android. |
71 SkASSERT(false); | 72 SkASSERT(false); |
72 } | 73 } |
73 | 74 |
75 // Port of PlatformBitmap to android | |
76 | |
77 PlatformBitmap::~PlatformBitmap() {} | |
78 | |
79 bool PlatformBitmap::Allocate(int width, int height, bool isOpaque) { | |
brettw
2012/10/09 20:40:12
is_opaque. Same for other ports.
| |
80 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height); | |
81 if (!bitmap_.allocPixels()) | |
82 return false; | |
83 | |
84 bitmap_.setIsOpaque(isOpaque); | |
85 return true; | |
86 } | |
87 | |
88 PlatformSurface PlatformBitmap::LockSurface() { | |
89 return bitmap_.getPixels(); | |
90 } | |
91 | |
92 void PlatformBitmap::UnlockSurface() { | |
93 // nothing to do for our "surface", as it is just our pixel address. | |
94 } | |
95 | |
74 } // namespace skia | 96 } // namespace skia |
OLD | NEW |