| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/gfx/platform_canvas_linux.h" | |
| 6 | |
| 7 #include "base/gfx/platform_device_linux.h" | |
| 8 #include "base/gfx/bitmap_platform_device_linux.h" | |
| 9 #include "base/logging.h" | |
| 10 | |
| 11 namespace gfx { | |
| 12 | |
| 13 PlatformCanvasLinux::PlatformCanvasLinux() : SkCanvas() { | |
| 14 } | |
| 15 | |
| 16 PlatformCanvasLinux::PlatformCanvasLinux(int width, int height, bool is_opaque) | |
| 17 : SkCanvas() { | |
| 18 if (!initialize(width, height, is_opaque)) | |
| 19 CHECK(false); | |
| 20 } | |
| 21 | |
| 22 PlatformCanvasLinux::~PlatformCanvasLinux() { | |
| 23 } | |
| 24 | |
| 25 bool PlatformCanvasLinux::initialize(int width, int height, bool is_opaque) { | |
| 26 SkDevice* device = createPlatformDevice(width, height, is_opaque); | |
| 27 if (!device) | |
| 28 return false; | |
| 29 | |
| 30 setDevice(device); | |
| 31 device->unref(); // was created with refcount 1, and setDevice also refs | |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 PlatformDeviceLinux& PlatformCanvasLinux::getTopPlatformDevice() const { | |
| 36 // All of our devices should be our special PlatformDevice. | |
| 37 SkCanvas::LayerIter iter(const_cast<PlatformCanvasLinux*>(this), false); | |
| 38 return *static_cast<PlatformDeviceLinux*>(iter.device()); | |
| 39 } | |
| 40 | |
| 41 SkDevice* PlatformCanvasLinux::createDevice(SkBitmap::Config config, | |
| 42 int width, | |
| 43 int height, | |
| 44 bool is_opaque, bool isForLayer) { | |
| 45 DCHECK(config == SkBitmap::kARGB_8888_Config); | |
| 46 return createPlatformDevice(width, height, is_opaque); | |
| 47 } | |
| 48 | |
| 49 SkDevice* PlatformCanvasLinux::createPlatformDevice(int width, | |
| 50 int height, | |
| 51 bool is_opaque) { | |
| 52 return BitmapPlatformDeviceLinux::Create(width, height, is_opaque); | |
| 53 } | |
| 54 | |
| 55 } // namespace gfx | |
| OLD | NEW |