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 | |
7 #include "skia/ext/bitmap_platform_device_data.h" | 6 #include "skia/ext/bitmap_platform_device_data.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> |
11 #else | 11 #else |
12 #include <cairo/cairo.h> | 12 #include <cairo/cairo.h> |
13 #endif | 13 #endif |
14 | 14 |
15 namespace skia { | 15 namespace skia { |
16 | 16 |
17 namespace { | 17 namespace { |
(...skipping 151 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 // Port of PlatformBitmap to linux |
| 180 |
| 181 PlatformBitmap::~PlatformBitmap() { |
| 182 cairo_destroy(surface_); |
| 183 } |
| 184 |
| 185 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
| 186 cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
| 187 width, height); |
| 188 if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { |
| 189 cairo_surface_destroy(surf); |
| 190 return false; |
| 191 } |
| 192 |
| 193 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, |
| 194 cairo_image_surface_get_stride(surf)); |
| 195 bitmap_.setPixels(cairo_image_surface_get_data(surf)); |
| 196 bitmap_.setIsOpaque(is_opaque); |
| 197 |
| 198 surface_ = cairo_create(surf); |
| 199 cairo_surface_destroy(surf); |
| 200 return true; |
| 201 } |
| 202 |
179 } // namespace skia | 203 } // namespace skia |
OLD | NEW |