Chromium Code Reviews| 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 isOpaque) { | |
| 186 cairo_surface_t* cairo_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, | |
| 187 width, height); | |
|
brettw
2012/10/09 20:40:12
Check indenting.
reed1
2012/10/09 21:06:43
Done.
| |
| 188 if (cairo_surface_status(cairo_surf) != CAIRO_STATUS_SUCCESS) { | |
| 189 cairo_surface_destroy(cairo_surf); | |
| 190 return false; | |
| 191 } | |
| 192 | |
| 193 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, | |
| 194 cairo_image_surface_get_stride(cairo_surf)); | |
| 195 bitmap_.setPixels(cairo_image_surface_get_data(cairo_surf)); | |
| 196 bitmap_.setIsOpaque(isOpaque); | |
| 197 | |
| 198 surface_ = cairo_create(cairo_surf); | |
| 199 cairo_surface_destroy(cairo_surf); | |
| 200 return true; | |
| 201 } | |
| 202 | |
| 203 PlatformSurface PlatformBitmap::LockSurface() { | |
| 204 return surface_; | |
| 205 } | |
| 206 | |
| 207 void PlatformBitmap::UnlockSurface() { | |
| 208 // nothing to do for our surface. It will be released in our destructor | |
|
brettw
2012/10/09 20:40:12
Check indenting.
reed1
2012/10/09 21:06:43
Done.
| |
| 209 } | |
| 210 | |
| 179 } // namespace skia | 211 } // namespace skia |
| OLD | NEW |