Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(820)

Side by Side Diff: skia/ext/bitmap_platform_device_win.cc

Issue 1396613006: Remove skia::PlatformBitmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « skia/ext/bitmap_platform_device_win.h ('k') | skia/ext/platform_canvas.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gdi_debug_util_win.h" 8 #include "base/debug/gdi_debug_util_win.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/win/win_util.h" 10 #include "base/win/win_util.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 SkCanvas* CreatePlatformCanvas(int width, 310 SkCanvas* CreatePlatformCanvas(int width,
311 int height, 311 int height,
312 bool is_opaque, 312 bool is_opaque,
313 HANDLE shared_section, 313 HANDLE shared_section,
314 OnFailureType failureType) { 314 OnFailureType failureType) {
315 skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef( 315 skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef(
316 BitmapPlatformDevice::Create(width, height, is_opaque, shared_section)); 316 BitmapPlatformDevice::Create(width, height, is_opaque, shared_section));
317 return CreateCanvas(dev, failureType); 317 return CreateCanvas(dev, failureType);
318 } 318 }
319 319
320 // Port of PlatformBitmap to win
321
322 PlatformBitmap::~PlatformBitmap() {
323 if (surface_) {
324 if (platform_extra_)
325 SelectObject(surface_, reinterpret_cast<HGDIOBJ>(platform_extra_));
326 DeleteDC(surface_);
327 }
328 }
329
330 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
331 void* data;
332 HBITMAP hbitmap = CreateHBitmap(width, height, is_opaque, 0, &data);
333 if (!hbitmap)
334 return false;
335
336 surface_ = CreateCompatibleDC(NULL);
337 InitializeDC(surface_);
338 // When the memory DC is created, its display surface is exactly one
339 // monochrome pixel wide and one monochrome pixel high. Save this object
340 // off, we'll restore it just before deleting the memory DC.
341 HGDIOBJ stock_bitmap = SelectObject(surface_, hbitmap);
342 platform_extra_ = reinterpret_cast<intptr_t>(stock_bitmap);
343
344 if (!InstallHBitmapPixels(&bitmap_, width, height, is_opaque, data, hbitmap))
345 return false;
346 bitmap_.lockPixels();
347
348 return true;
349 }
350
351 } // namespace skia 320 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_win.h ('k') | skia/ext/platform_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698