| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_skia.h" | 5 #include "skia/ext/bitmap_platform_device_skia.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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 BitmapPlatformDevice::~BitmapPlatformDevice() { | 42 BitmapPlatformDevice::~BitmapPlatformDevice() { |
| 43 } | 43 } |
| 44 | 44 |
| 45 SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 45 SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
| 46 const CreateInfo& info) { | 46 const CreateInfo& info) { |
| 47 SkASSERT(info.fInfo.colorType() == kN32_SkColorType); | 47 SkASSERT(info.fInfo.colorType() == kN32_SkColorType); |
| 48 return BitmapPlatformDevice::Create(info.fInfo.width(), info.fInfo.height(), | 48 return BitmapPlatformDevice::Create(info.fInfo.width(), info.fInfo.height(), |
| 49 info.fInfo.isOpaque()); | 49 info.fInfo.isOpaque()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const CreateInfo& cinfo, | |
| 53 const SkPaint*) { | |
| 54 // until skia lands its new virtual for this method | |
| 55 return onCreateCompatibleDevice(cinfo); | |
| 56 } | |
| 57 | |
| 58 PlatformSurface BitmapPlatformDevice::BeginPlatformPaint() { | 52 PlatformSurface BitmapPlatformDevice::BeginPlatformPaint() { |
| 59 // TODO(zhenghao): What should we return? The ptr to the address of the | 53 // TODO(zhenghao): What should we return? The ptr to the address of the |
| 60 // pixels? Maybe this won't be called at all. | 54 // pixels? Maybe this won't be called at all. |
| 61 return accessBitmap(true).getPixels(); | 55 return accessBitmap(true).getPixels(); |
| 62 } | 56 } |
| 63 | 57 |
| 64 // PlatformCanvas impl | 58 // PlatformCanvas impl |
| 65 | 59 |
| 66 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, | 60 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, |
| 67 uint8_t* data, OnFailureType failureType) { | 61 uint8_t* data, OnFailureType failureType) { |
| 68 skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef( | 62 skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef( |
| 69 BitmapPlatformDevice::Create(width, height, is_opaque, data)); | 63 BitmapPlatformDevice::Create(width, height, is_opaque, data)); |
| 70 return CreateCanvas(dev, failureType); | 64 return CreateCanvas(dev, failureType); |
| 71 } | 65 } |
| 72 | 66 |
| 73 // Port of PlatformBitmap to android | 67 // Port of PlatformBitmap to android |
| 74 PlatformBitmap::~PlatformBitmap() { | 68 PlatformBitmap::~PlatformBitmap() { |
| 75 // Nothing to do. | 69 // Nothing to do. |
| 76 } | 70 } |
| 77 | 71 |
| 78 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 72 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
| 79 if (!bitmap_.tryAllocN32Pixels(width, height, is_opaque)) | 73 if (!bitmap_.tryAllocN32Pixels(width, height, is_opaque)) |
| 80 return false; | 74 return false; |
| 81 | 75 |
| 82 surface_ = bitmap_.getPixels(); | 76 surface_ = bitmap_.getPixels(); |
| 83 return true; | 77 return true; |
| 84 } | 78 } |
| 85 | 79 |
| 86 } // namespace skia | 80 } // namespace skia |
| OLD | NEW |