| 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 #include "skia/ext/platform_canvas.h" |
| 7 | 7 |
| 8 namespace skia { | 8 namespace skia { |
| 9 | 9 |
| 10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, | 10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 void BitmapPlatformDevice::DrawToNativeContext( | 69 void BitmapPlatformDevice::DrawToNativeContext( |
| 70 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { | 70 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { |
| 71 // Should never be called on Android. | 71 // Should never be called on Android. |
| 72 SkASSERT(false); | 72 SkASSERT(false); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // PlatformCanvas impl | 75 // PlatformCanvas impl |
| 76 | 76 |
| 77 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, | 77 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, |
| 78 uint8_t* data, OnFailureType failureType) { | 78 uint8_t* data, OnFailureType failureType) { |
| 79 SkDevice* dev = BitmapPlatformDevice::Create(width, height, is_opaque, data); | 79 skia::RefPtr<SkDevice> dev = skia::AdoptRef( |
| 80 BitmapPlatformDevice::Create(width, height, is_opaque, data)); |
| 80 return CreateCanvas(dev, failureType); | 81 return CreateCanvas(dev, failureType); |
| 81 } | 82 } |
| 82 | 83 |
| 83 // Port of PlatformBitmap to android | 84 // Port of PlatformBitmap to android |
| 84 | 85 |
| 85 PlatformBitmap::~PlatformBitmap() {} | 86 PlatformBitmap::~PlatformBitmap() {} |
| 86 | 87 |
| 87 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 88 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
| 88 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 89 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 89 if (!bitmap_.allocPixels()) | 90 if (!bitmap_.allocPixels()) |
| 90 return false; | 91 return false; |
| 91 | 92 |
| 92 bitmap_.setIsOpaque(is_opaque); | 93 bitmap_.setIsOpaque(is_opaque); |
| 93 surface_ = bitmap_.getPixels(); | 94 surface_ = bitmap_.getPixels(); |
| 94 return true; | 95 return true; |
| 95 } | 96 } |
| 96 | 97 |
| 97 } // namespace skia | 98 } // namespace skia |
| OLD | NEW |