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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 179 // PlatformCanvas impl |
180 | 180 |
181 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, | 181 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, |
182 uint8_t* data, OnFailureType failureType) { | 182 uint8_t* data, OnFailureType failureType) { |
183 SkDevice* dev = BitmapPlatformDevice::Create(width, height, is_opaque, data); | 183 skia::RefPtr<SkDevice> dev = skia::AdoptRef( |
| 184 BitmapPlatformDevice::Create(width, height, is_opaque, data)); |
184 return CreateCanvas(dev, failureType); | 185 return CreateCanvas(dev, failureType); |
185 } | 186 } |
186 | 187 |
187 // Port of PlatformBitmap to linux | 188 // Port of PlatformBitmap to linux |
188 | 189 |
189 PlatformBitmap::~PlatformBitmap() { | 190 PlatformBitmap::~PlatformBitmap() { |
190 cairo_destroy(surface_); | 191 cairo_destroy(surface_); |
191 } | 192 } |
192 | 193 |
193 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 194 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
194 cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, | 195 cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
195 width, height); | 196 width, height); |
196 if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { | 197 if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) { |
197 cairo_surface_destroy(surf); | 198 cairo_surface_destroy(surf); |
198 return false; | 199 return false; |
199 } | 200 } |
200 | 201 |
201 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, | 202 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, |
202 cairo_image_surface_get_stride(surf)); | 203 cairo_image_surface_get_stride(surf)); |
203 bitmap_.setPixels(cairo_image_surface_get_data(surf)); | 204 bitmap_.setPixels(cairo_image_surface_get_data(surf)); |
204 bitmap_.setIsOpaque(is_opaque); | 205 bitmap_.setIsOpaque(is_opaque); |
205 | 206 |
206 surface_ = cairo_create(surf); | 207 surface_ = cairo_create(surf); |
207 cairo_surface_destroy(surf); | 208 cairo_surface_destroy(surf); |
208 return true; | 209 return true; |
209 } | 210 } |
210 | 211 |
211 } // namespace skia | 212 } // namespace skia |
OLD | NEW |