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 "skia/ext/bitmap_platform_device_win.h" | 5 #include "skia/ext/bitmap_platform_device_win.h" |
6 | 6 |
7 #include "base/gfx/gdi_util.h" | 7 #include "base/gfx/gdi_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
11 #include "SkUtils.h" | 11 #include "SkUtils.h" |
12 | 12 |
13 namespace gfx { | 13 namespace skia { |
14 | 14 |
15 // When Windows draws text, is sets the fourth byte (which Skia uses for alpha) | 15 // When Windows draws text, is sets the fourth byte (which Skia uses for alpha) |
16 // to zero. This means that if we try compositing with text that Windows has | 16 // to zero. This means that if we try compositing with text that Windows has |
17 // drawn, we get invalid color values (if the alpha is 0, the other channels | 17 // drawn, we get invalid color values (if the alpha is 0, the other channels |
18 // should be 0 since Skia uses premultiplied colors) and strange results. | 18 // should be 0 since Skia uses premultiplied colors) and strange results. |
19 // | 19 // |
20 // HTML rendering only requires one bit of transparency. When you ask for a | 20 // HTML rendering only requires one bit of transparency. When you ask for a |
21 // semitransparent div, the div itself is drawn in another layer as completely | 21 // semitransparent div, the div itself is drawn in another layer as completely |
22 // opaque, and then composited onto the lower layer with a transfer function. | 22 // opaque, and then composited onto the lower layer with a transfer function. |
23 // The only place an alpha channel is needed is to track what has been drawn | 23 // The only place an alpha channel is needed is to track what has been drawn |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 SkBitmap bitmap; | 235 SkBitmap bitmap; |
236 | 236 |
237 // CreateDIBSection appears to get unhappy if we create an empty bitmap, so | 237 // CreateDIBSection appears to get unhappy if we create an empty bitmap, so |
238 // just create a minimal bitmap | 238 // just create a minimal bitmap |
239 if ((width == 0) || (height == 0)) { | 239 if ((width == 0) || (height == 0)) { |
240 width = 1; | 240 width = 1; |
241 height = 1; | 241 height = 1; |
242 } | 242 } |
243 | 243 |
244 BITMAPINFOHEADER hdr = {0}; | 244 BITMAPINFOHEADER hdr = {0}; |
245 CreateBitmapHeader(width, height, &hdr); | 245 gfx::CreateBitmapHeader(width, height, &hdr); |
246 | 246 |
247 void* data = NULL; | 247 void* data = NULL; |
248 HBITMAP hbitmap = CreateDIBSection(screen_dc, | 248 HBITMAP hbitmap = CreateDIBSection(screen_dc, |
249 reinterpret_cast<BITMAPINFO*>(&hdr), 0, | 249 reinterpret_cast<BITMAPINFO*>(&hdr), 0, |
250 &data, | 250 &data, |
251 shared_section, 0); | 251 shared_section, 0); |
252 | 252 |
253 // If we run out of GDI objects or some other error occurs, we won't get a | 253 // If we run out of GDI objects or some other error occurs, we won't get a |
254 // bitmap here. This will cause us to crash later because the data pointer is | 254 // bitmap here. This will cause us to crash later because the data pointer is |
255 // NULL. To make sure that we can assign blame for those crashes to this code, | 255 // NULL. To make sure that we can assign blame for those crashes to this code, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 bitmap_start_x; | 435 bitmap_start_x; |
436 for (int i = 0; i < height; i++) { | 436 for (int i = 0; i < height; i++) { |
437 for (int j = 0; j < width; j++) { | 437 for (int j = 0; j < width; j++) { |
438 adjustor(data + j); | 438 adjustor(data + j); |
439 } | 439 } |
440 data += row_words; | 440 data += row_words; |
441 } | 441 } |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 } // namespace gfx | 445 } // namespace skia |
446 | 446 |
OLD | NEW |