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 "base/debug/trace_event.h" |
8 #include "skia/ext/bitmap_platform_device_win.h" | 9 #include "skia/ext/bitmap_platform_device_win.h" |
9 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
10 | 11 |
11 namespace skia { | 12 namespace skia { |
12 | 13 |
13 // Disable optimizations during crash analysis. | 14 // Disable optimizations during crash analysis. |
14 #pragma optimize("", off) | 15 #pragma optimize("", off) |
15 | 16 |
16 // Crash on failure. | 17 // Crash on failure. |
17 #define CHECK(condition) if (!(condition)) __debugbreak(); | 18 #define CHECK(condition) if (!(condition)) __debugbreak(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // the issue was a non-valid shared bitmap handle. | 71 // the issue was a non-valid shared bitmap handle. |
71 void CrashIfInvalidSection(HANDLE shared_section) { | 72 void CrashIfInvalidSection(HANDLE shared_section) { |
72 DWORD handle_info = 0; | 73 DWORD handle_info = 0; |
73 CHECK(::GetHandleInformation(shared_section, &handle_info) == TRUE); | 74 CHECK(::GetHandleInformation(shared_section, &handle_info) == TRUE); |
74 } | 75 } |
75 | 76 |
76 // Restore the optimization options. | 77 // Restore the optimization options. |
77 #pragma optimize("", on) | 78 #pragma optimize("", on) |
78 | 79 |
79 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) { | 80 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) { |
| 81 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas", |
| 82 "width", width, "height", height); |
80 bool initialized = initialize(width, height, is_opaque, NULL); | 83 bool initialized = initialize(width, height, is_opaque, NULL); |
81 if (!initialized) | 84 if (!initialized) |
82 CrashForBitmapAllocationFailure(width, height); | 85 CrashForBitmapAllocationFailure(width, height); |
83 } | 86 } |
84 | 87 |
85 PlatformCanvas::PlatformCanvas(int width, | 88 PlatformCanvas::PlatformCanvas(int width, |
86 int height, | 89 int height, |
87 bool is_opaque, | 90 bool is_opaque, |
88 HANDLE shared_section) { | 91 HANDLE shared_section) { |
| 92 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas", |
| 93 "width", width, "height", height); |
89 bool initialized = initialize(width, height, is_opaque, shared_section); | 94 bool initialized = initialize(width, height, is_opaque, shared_section); |
90 if (!initialized) { | 95 if (!initialized) { |
91 CrashIfInvalidSection(shared_section); | 96 CrashIfInvalidSection(shared_section); |
92 CrashForBitmapAllocationFailure(width, height); | 97 CrashForBitmapAllocationFailure(width, height); |
93 } | 98 } |
94 } | 99 } |
95 | 100 |
96 PlatformCanvas::~PlatformCanvas() { | 101 PlatformCanvas::~PlatformCanvas() { |
97 } | 102 } |
98 | 103 |
99 bool PlatformCanvas::initialize(int width, | 104 bool PlatformCanvas::initialize(int width, |
100 int height, | 105 int height, |
101 bool is_opaque, | 106 bool is_opaque, |
102 HANDLE shared_section) { | 107 HANDLE shared_section) { |
103 return initializeWithDevice(BitmapPlatformDevice::create( | 108 return initializeWithDevice(BitmapPlatformDevice::create( |
104 width, height, is_opaque, shared_section)); | 109 width, height, is_opaque, shared_section)); |
105 } | 110 } |
106 | 111 |
107 } // namespace skia | 112 } // namespace skia |
OLD | NEW |