| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() : SkCanvas() { | |
| 80 } | |
| 81 | |
| 82 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) | 79 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) |
| 83 : SkCanvas() { | 80 : SkCanvas(SkNEW(SkBitmapPlatformDeviceFactory)) { |
| 84 bool initialized = initialize(width, height, is_opaque, NULL); | 81 bool initialized = initialize(width, height, is_opaque, NULL); |
| 85 if (!initialized) | 82 if (!initialized) |
| 86 CrashForBitmapAllocationFailure(width, height); | 83 CrashForBitmapAllocationFailure(width, height); |
| 87 } | 84 } |
| 88 | 85 |
| 89 PlatformCanvas::PlatformCanvas(int width, | 86 PlatformCanvas::PlatformCanvas(int width, |
| 90 int height, | 87 int height, |
| 91 bool is_opaque, | 88 bool is_opaque, |
| 92 HANDLE shared_section) | 89 HANDLE shared_section) |
| 93 : SkCanvas() { | 90 : SkCanvas(SkNEW(SkBitmapPlatformDeviceFactory)) { |
| 94 bool initialized = initialize(width, height, is_opaque, shared_section); | 91 bool initialized = initialize(width, height, is_opaque, shared_section); |
| 95 if (!initialized) { | 92 if (!initialized) { |
| 96 CrashIfInvalidSection(shared_section); | 93 CrashIfInvalidSection(shared_section); |
| 97 CrashForBitmapAllocationFailure(width, height); | 94 CrashForBitmapAllocationFailure(width, height); |
| 98 } | 95 } |
| 99 } | 96 } |
| 100 | 97 |
| 101 PlatformCanvas::~PlatformCanvas() { | 98 PlatformCanvas::~PlatformCanvas() { |
| 102 } | 99 } |
| 103 | 100 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 | 114 |
| 118 HDC PlatformCanvas::beginPlatformPaint() { | 115 HDC PlatformCanvas::beginPlatformPaint() { |
| 119 return getTopPlatformDevice().getBitmapDC(); | 116 return getTopPlatformDevice().getBitmapDC(); |
| 120 } | 117 } |
| 121 | 118 |
| 122 void PlatformCanvas::endPlatformPaint() { | 119 void PlatformCanvas::endPlatformPaint() { |
| 123 // we don't clear the DC here since it will be likely to be used again | 120 // we don't clear the DC here since it will be likely to be used again |
| 124 // flushing will be done in onAccessBitmap | 121 // flushing will be done in onAccessBitmap |
| 125 } | 122 } |
| 126 | 123 |
| 127 SkDevice* PlatformCanvas::createDevice(SkBitmap::Config config, | |
| 128 int width, | |
| 129 int height, | |
| 130 bool is_opaque, bool isForLayer) { | |
| 131 SkASSERT(config == SkBitmap::kARGB_8888_Config); | |
| 132 return BitmapPlatformDevice::create(width, height, is_opaque, NULL); | |
| 133 } | |
| 134 | |
| 135 } // namespace skia | 124 } // namespace skia |
| OLD | NEW |