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

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

Issue 2855503003: Replace uses of legacy SkBitmap::copyTo() API (Closed)
Patch Set: image_info 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);
80 }
Evan Stade 2017/05/02 23:25:42 nit: no curlies
msarett1 2017/05/03 02:40:18 Done.
79 81
80 // Align the pattern with the upper corner of |align_rect|. 82 // Align the pattern with the upper corner of |align_rect|.
81 SkMatrix local_matrix; 83 SkMatrix local_matrix;
82 local_matrix.setTranslate(SkIntToScalar(align_rect.left), 84 local_matrix.setTranslate(SkIntToScalar(align_rect.left),
83 SkIntToScalar(align_rect.top)); 85 SkIntToScalar(align_rect.top));
84 paint->setShader( 86 paint->setShader(
85 SkShader::MakeBitmapShader(bitmap, SkShader::kRepeat_TileMode, 87 SkShader::MakeBitmapShader(bitmap, SkShader::kRepeat_TileMode,
86 SkShader::kRepeat_TileMode, &local_matrix)); 88 SkShader::kRepeat_TileMode, &local_matrix));
87 } 89 }
88 90
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 break; 2040 break;
2039 case LAST: 2041 case LAST:
2040 NOTREACHED(); 2042 NOTREACHED();
2041 break; 2043 break;
2042 } 2044 }
2043 theme_handles_[theme_name] = handle; 2045 theme_handles_[theme_name] = handle;
2044 return handle; 2046 return handle;
2045 } 2047 }
2046 2048
2047 } // namespace ui 2049 } // 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