OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
6 #include <psapi.h> | 6 #include <psapi.h> |
7 | 7 |
8 #include "skia/ext/bitmap_platform_device_win.h" | 8 #include "skia/ext/bitmap_platform_device_win.h" |
9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // the issue was a non-valid shared bitmap handle. | 70 // the issue was a non-valid shared bitmap handle. |
71 void CrashIfInvalidSection(HANDLE shared_section) { | 71 void CrashIfInvalidSection(HANDLE shared_section) { |
72 DWORD handle_info = 0; | 72 DWORD handle_info = 0; |
73 CHECK(::GetHandleInformation(shared_section, &handle_info) == TRUE); | 73 CHECK(::GetHandleInformation(shared_section, &handle_info) == TRUE); |
74 } | 74 } |
75 | 75 |
76 // Restore the optimization options. | 76 // Restore the optimization options. |
77 #pragma optimize("", on) | 77 #pragma optimize("", on) |
78 | 78 |
79 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) { | 79 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) { |
80 setDeviceFactory(SkNEW(BitmapPlatformDeviceFactory))->unref(); | |
81 bool initialized = initialize(width, height, is_opaque, NULL); | 80 bool initialized = initialize(width, height, is_opaque, NULL); |
82 if (!initialized) | 81 if (!initialized) |
83 CrashForBitmapAllocationFailure(width, height); | 82 CrashForBitmapAllocationFailure(width, height); |
84 } | 83 } |
85 | 84 |
86 PlatformCanvas::PlatformCanvas(int width, | 85 PlatformCanvas::PlatformCanvas(int width, |
87 int height, | 86 int height, |
88 bool is_opaque, | 87 bool is_opaque, |
89 HANDLE shared_section) { | 88 HANDLE shared_section) { |
90 setDeviceFactory(SkNEW(BitmapPlatformDeviceFactory))->unref(); | |
91 bool initialized = initialize(width, height, is_opaque, shared_section); | 89 bool initialized = initialize(width, height, is_opaque, shared_section); |
92 if (!initialized) { | 90 if (!initialized) { |
93 CrashIfInvalidSection(shared_section); | 91 CrashIfInvalidSection(shared_section); |
94 CrashForBitmapAllocationFailure(width, height); | 92 CrashForBitmapAllocationFailure(width, height); |
95 } | 93 } |
96 } | 94 } |
97 | 95 |
98 PlatformCanvas::~PlatformCanvas() { | 96 PlatformCanvas::~PlatformCanvas() { |
99 } | 97 } |
100 | 98 |
101 bool PlatformCanvas::initialize(int width, | 99 bool PlatformCanvas::initialize(int width, |
102 int height, | 100 int height, |
103 bool is_opaque, | 101 bool is_opaque, |
104 HANDLE shared_section) { | 102 HANDLE shared_section) { |
105 return initializeWithDevice(BitmapPlatformDevice::create( | 103 return initializeWithDevice(BitmapPlatformDevice::create( |
106 width, height, is_opaque, shared_section)); | 104 width, height, is_opaque, shared_section)); |
107 } | 105 } |
108 | 106 |
109 } // namespace skia | 107 } // namespace skia |
OLD | NEW |