| 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 <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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 CHECK(0); | 60 CHECK(0); |
| 61 } | 61 } |
| 62 CHECK(pmc.PagefileUsage < kLotsOfMem); | 62 CHECK(pmc.PagefileUsage < kLotsOfMem); |
| 63 | 63 |
| 64 // Everything else. | 64 // Everything else. |
| 65 CHECK(0); | 65 CHECK(0); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Crashes the process. This is called when a bitmap allocation fails but | 68 // Crashes the process. This is called when a bitmap allocation fails but |
| 69 // unlike its cousin CrashForBitmapAllocationFailure() it tries to detect if | 69 // unlike its cousin CrashForBitmapAllocationFailure() it tries to detect if |
| 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 : SkCanvas(SkNEW(BitmapPlatformDeviceFactory)) { | 80 : SkCanvas(SkNEW(BitmapPlatformDeviceFactory)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 PlatformCanvas::~PlatformCanvas() { | 98 PlatformCanvas::~PlatformCanvas() { |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool PlatformCanvas::initialize(int width, | 101 bool PlatformCanvas::initialize(int width, |
| 102 int height, | 102 int height, |
| 103 bool is_opaque, | 103 bool is_opaque, |
| 104 HANDLE shared_section) { | 104 HANDLE shared_section) { |
| 105 SkDevice* device = BitmapPlatformDevice::create(width, height, | 105 return initializeWithDevice(BitmapPlatformDevice::create( |
| 106 is_opaque, shared_section); | 106 width, height, is_opaque, shared_section)); |
| 107 if (!device) | |
| 108 return false; | |
| 109 | |
| 110 setDevice(device); | |
| 111 device->unref(); // was created with refcount 1, and setDevice also refs | |
| 112 return true; | |
| 113 } | 107 } |
| 114 | 108 |
| 115 HDC PlatformCanvas::beginPlatformPaint() { | 109 HDC PlatformCanvas::beginPlatformPaint() { |
| 116 return getTopPlatformDevice().getBitmapDC(); | 110 return getTopPlatformDevice().getBitmapDC(); |
| 117 } | 111 } |
| 118 | 112 |
| 119 void PlatformCanvas::endPlatformPaint() { | 113 void PlatformCanvas::endPlatformPaint() { |
| 120 // we don't clear the DC here since it will be likely to be used again | 114 // we don't clear the DC here since it will be likely to be used again |
| 121 // flushing will be done in onAccessBitmap | 115 // flushing will be done in onAccessBitmap |
| 122 } | 116 } |
| 123 | 117 |
| 124 } // namespace skia | 118 } // namespace skia |
| OLD | NEW |