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

Side by Side Diff: ui/native_theme/native_theme_win.cc

Issue 2855503003: Replace uses of legacy SkBitmap::copyTo() API (Closed)
Patch Set: Remove braces Created 3 years, 7 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 | « ui/base/test/test_clipboard.cc ('k') | no next file » | 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 "ui/native_theme/native_theme_win.h" 5 #include "ui/native_theme/native_theme_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <uxtheme.h> 9 #include <uxtheme.h>
10 #include <vsstyle.h> 10 #include <vsstyle.h>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Confusing bit: we first create a temporary bitmap with our desired pattern, 68 // Confusing bit: we first create a temporary bitmap with our desired pattern,
69 // then copy it to another bitmap. The temporary bitmap doesn't take 69 // then copy it to another bitmap. The temporary bitmap doesn't take
70 // ownership of the pixel data, and so will point to garbage when this 70 // ownership of the pixel data, and so will point to garbage when this
71 // function returns. The copy will copy the pixel data into a place owned by 71 // function returns. The copy will copy the pixel data into a place owned by
72 // the bitmap, which is in turn owned by the shader, etc., so it will live 72 // the bitmap, which is in turn owned by the shader, etc., so it will live
73 // until we're done using it. 73 // until we're done using it.
74 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2); 74 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
75 SkBitmap temp_bitmap; 75 SkBitmap temp_bitmap;
76 temp_bitmap.installPixels(info, buffer, info.minRowBytes()); 76 temp_bitmap.installPixels(info, buffer, info.minRowBytes());
77 SkBitmap bitmap; 77 SkBitmap bitmap;
78 temp_bitmap.copyTo(&bitmap); 78 if (bitmap.tryAllocPixels(info))
79 temp_bitmap.readPixels(info, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
79 80
80 // Align the pattern with the upper corner of |align_rect|. 81 // Align the pattern with the upper corner of |align_rect|.
81 SkMatrix local_matrix; 82 SkMatrix local_matrix;
82 local_matrix.setTranslate(SkIntToScalar(align_rect.left), 83 local_matrix.setTranslate(SkIntToScalar(align_rect.left),
83 SkIntToScalar(align_rect.top)); 84 SkIntToScalar(align_rect.top));
84 paint->setShader( 85 paint->setShader(
85 SkShader::MakeBitmapShader(bitmap, SkShader::kRepeat_TileMode, 86 SkShader::MakeBitmapShader(bitmap, SkShader::kRepeat_TileMode,
86 SkShader::kRepeat_TileMode, &local_matrix)); 87 SkShader::kRepeat_TileMode, &local_matrix));
87 } 88 }
88 89
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 break; 2039 break;
2039 case LAST: 2040 case LAST:
2040 NOTREACHED(); 2041 NOTREACHED();
2041 break; 2042 break;
2042 } 2043 }
2043 theme_handles_[theme_name] = handle; 2044 theme_handles_[theme_name] = handle;
2044 return handle; 2045 return handle;
2045 } 2046 }
2046 2047
2047 } // namespace ui 2048 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/test/test_clipboard.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698