OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 "base/gfx/vector_canvas.h" | 5 #include "base/gfx/vector_canvas.h" |
6 | 6 |
7 #include "base/gfx/vector_device.h" | 7 #include "base/gfx/vector_device.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace gfx { | 10 namespace gfx { |
11 | 11 |
12 VectorCanvas::VectorCanvas() { | 12 VectorCanvas::VectorCanvas() { |
13 } | 13 } |
14 | 14 |
15 VectorCanvas::VectorCanvas(HDC dc, int width, int height) { | 15 VectorCanvas::VectorCanvas(HDC dc, int width, int height) { |
16 initialize(dc, width, height); | 16 bool initialized = initialize(dc, width, height); |
| 17 CHECK(initialized); |
17 } | 18 } |
18 | 19 |
19 VectorCanvas::~VectorCanvas() { | 20 VectorCanvas::~VectorCanvas() { |
20 } | 21 } |
21 | 22 |
22 void VectorCanvas::initialize(HDC context, int width, int height) { | 23 bool VectorCanvas::initialize(HDC context, int width, int height) { |
23 SkDevice* device = createPlatformDevice(width, height, true, context); | 24 SkDevice* device = createPlatformDevice(width, height, true, context); |
| 25 if (!device) |
| 26 return false; |
| 27 |
24 setDevice(device); | 28 setDevice(device); |
25 device->unref(); // was created with refcount 1, and setDevice also refs | 29 device->unref(); // was created with refcount 1, and setDevice also refs |
| 30 return true; |
26 } | 31 } |
27 | 32 |
28 SkBounder* VectorCanvas::setBounder(SkBounder* bounder) { | 33 SkBounder* VectorCanvas::setBounder(SkBounder* bounder) { |
29 if (!IsTopDeviceVectorial()) | 34 if (!IsTopDeviceVectorial()) |
30 return PlatformCanvasWin::setBounder(bounder); | 35 return PlatformCanvasWin::setBounder(bounder); |
31 | 36 |
32 // This function isn't used in the code. Verify this assumption. | 37 // This function isn't used in the code. Verify this assumption. |
33 NOTREACHED(); | 38 NOTREACHED(); |
34 return NULL; | 39 return NULL; |
35 } | 40 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 reinterpret_cast<HDC>(shared_section), width, height); | 81 reinterpret_cast<HDC>(shared_section), width, height); |
77 return device; | 82 return device; |
78 } | 83 } |
79 | 84 |
80 bool VectorCanvas::IsTopDeviceVectorial() const { | 85 bool VectorCanvas::IsTopDeviceVectorial() const { |
81 return getTopPlatformDevice().IsVectorial(); | 86 return getTopPlatformDevice().IsVectorial(); |
82 } | 87 } |
83 | 88 |
84 } // namespace gfx | 89 } // namespace gfx |
85 | 90 |
OLD | NEW |