| 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(); |
| 80 bool initialized = initialize(width, height, is_opaque, NULL); | 81 bool initialized = initialize(width, height, is_opaque, NULL); |
| 81 if (!initialized) | 82 if (!initialized) |
| 82 CrashForBitmapAllocationFailure(width, height); | 83 CrashForBitmapAllocationFailure(width, height); |
| 83 } | 84 } |
| 84 | 85 |
| 85 PlatformCanvas::PlatformCanvas(int width, | 86 PlatformCanvas::PlatformCanvas(int width, |
| 86 int height, | 87 int height, |
| 87 bool is_opaque, | 88 bool is_opaque, |
| 88 HANDLE shared_section) { | 89 HANDLE shared_section) { |
| 90 setDeviceFactory(SkNEW(BitmapPlatformDeviceFactory))->unref(); |
| 89 bool initialized = initialize(width, height, is_opaque, shared_section); | 91 bool initialized = initialize(width, height, is_opaque, shared_section); |
| 90 if (!initialized) { | 92 if (!initialized) { |
| 91 CrashIfInvalidSection(shared_section); | 93 CrashIfInvalidSection(shared_section); |
| 92 CrashForBitmapAllocationFailure(width, height); | 94 CrashForBitmapAllocationFailure(width, height); |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| 96 PlatformCanvas::~PlatformCanvas() { | 98 PlatformCanvas::~PlatformCanvas() { |
| 97 } | 99 } |
| 98 | 100 |
| 99 bool PlatformCanvas::initialize(int width, | 101 bool PlatformCanvas::initialize(int width, |
| 100 int height, | 102 int height, |
| 101 bool is_opaque, | 103 bool is_opaque, |
| 102 HANDLE shared_section) { | 104 HANDLE shared_section) { |
| 103 return initializeWithDevice(BitmapPlatformDevice::create( | 105 return initializeWithDevice(BitmapPlatformDevice::create( |
| 104 width, height, is_opaque, shared_section)); | 106 width, height, is_opaque, shared_section)); |
| 105 } | 107 } |
| 106 | 108 |
| 107 } // namespace skia | 109 } // namespace skia |
| OLD | NEW |