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_linux.h" | 5 #include "skia/ext/bitmap_platform_device_linux.h" |
6 #include "skia/ext/bitmap_platform_device_data.h" | 6 #include "skia/ext/bitmap_platform_device_data.h" |
7 #include "skia/ext/platform_canvas.h" | 7 #include "skia/ext/platform_canvas.h" |
8 | 8 |
9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
10 #include <cairo.h> | 10 #include <cairo.h> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // Should never be called on Linux. | 169 // Should never be called on Linux. |
170 SkASSERT(false); | 170 SkASSERT(false); |
171 } | 171 } |
172 | 172 |
173 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 173 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
174 const SkRegion& region, | 174 const SkRegion& region, |
175 const SkClipStack&) { | 175 const SkClipStack&) { |
176 data_->SetMatrixClip(transform, region); | 176 data_->SetMatrixClip(transform, region); |
177 } | 177 } |
178 | 178 |
| 179 // PlatformCanvas impl |
| 180 |
| 181 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, |
| 182 uint8_t* data, OnFailureType failureType) { |
| 183 SkDevice* dev = BitmapPlatformDevice::Create(width, height, is_opaque, data); |
| 184 return CreateCanvas(dev, failureType); |
| 185 } |
| 186 |
179 // Port of PlatformBitmap to linux | 187 // Port of PlatformBitmap to linux |
180 | 188 |
181 PlatformBitmap::~PlatformBitmap() { | 189 PlatformBitmap::~PlatformBitmap() { |
182 cairo_destroy(surface_); | 190 cairo_destroy(surface_); |
183 } | 191 } |
184 | 192 |
185 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 193 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
186 cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, | 194 cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
187 width, height); | 195 width, height); |
188 if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { | 196 if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { |
189 cairo_surface_destroy(surf); | 197 cairo_surface_destroy(surf); |
190 return false; | 198 return false; |
191 } | 199 } |
192 | 200 |
193 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, | 201 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, |
194 cairo_image_surface_get_stride(surf)); | 202 cairo_image_surface_get_stride(surf)); |
195 bitmap_.setPixels(cairo_image_surface_get_data(surf)); | 203 bitmap_.setPixels(cairo_image_surface_get_data(surf)); |
196 bitmap_.setIsOpaque(is_opaque); | 204 bitmap_.setIsOpaque(is_opaque); |
197 | 205 |
198 surface_ = cairo_create(surf); | 206 surface_ = cairo_create(surf); |
199 cairo_surface_destroy(surf); | 207 cairo_surface_destroy(surf); |
200 return true; | 208 return true; |
201 } | 209 } |
202 | 210 |
203 } // namespace skia | 211 } // namespace skia |
OLD | NEW |