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

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

Issue 2613583002: Remove skia::ScopedPlatformPaint (Closed)
Patch Set: Created 3 years, 11 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/platform_canvas.cc ('k') | skia/ext/platform_device.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 // TODO(awalker): clean up the const/non-const reference handling in this test 5 // TODO(awalker): clean up the const/non-const reference handling in this test
6 6
7 #include "skia/ext/platform_canvas.h" 7 #include "skia/ext/platform_canvas.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h); 129 return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h);
130 } 130 }
131 131
132 // Check that every pixel in the canvas is a single color. 132 // Check that every pixel in the canvas is a single color.
133 bool VerifyCanvasColor(const SkCanvas& canvas, uint32_t canvas_color) { 133 bool VerifyCanvasColor(const SkCanvas& canvas, uint32_t canvas_color) {
134 return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0); 134 return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0);
135 } 135 }
136 136
137 #if defined(OS_WIN) 137 #if defined(OS_WIN)
138 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 138 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
139 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); 139 HDC dc = skia::GetNativeDrawingContext(&canvas);
140 HDC dc = scoped_platform_paint.GetNativeDrawingContext();
141 140
142 RECT inner_rc; 141 RECT inner_rc;
143 inner_rc.left = x; 142 inner_rc.left = x;
144 inner_rc.top = y; 143 inner_rc.top = y;
145 inner_rc.right = x + w; 144 inner_rc.right = x + w;
146 inner_rc.bottom = y + h; 145 inner_rc.bottom = y + h;
147 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))) ; 146 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))) ;
148 } 147 }
149 #elif defined(OS_MACOSX) 148 #elif defined(OS_MACOSX)
150 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 149 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
151 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); 150 CGContextRef context = skia::GetNativeDrawingContext(&canvas);
152 CGContextRef context = scoped_platform_paint.GetNativeDrawingContext();
153 151
154 CGRect inner_rc = CGRectMake(x, y, w, h); 152 CGRect inner_rc = CGRectMake(x, y, w, h);
155 // RGBA opaque black 153 // RGBA opaque black
156 CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0); 154 CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0);
157 CGContextSetFillColorWithColor(context, black); 155 CGContextSetFillColorWithColor(context, black);
158 CGColorRelease(black); 156 CGColorRelease(black);
159 CGContextFillRect(context, inner_rc); 157 CGContextFillRect(context, inner_rc);
160 } 158 }
161 #elif defined(USE_CAIRO) 159 #elif defined(USE_CAIRO)
162 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 160 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
163 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); 161 cairo_t* context = skia::GetNativeDrawingContext(&canvas);
164 cairo_t* context = scoped_platform_paint.GetNativeDrawingContext();
165 162
166 cairo_rectangle(context, x, y, w, h); 163 cairo_rectangle(context, x, y, w, h);
167 cairo_set_source_rgb(context, 0.0, 0.0, 0.0); 164 cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
168 cairo_fill(context); 165 cairo_fill(context);
169 } 166 }
170 #else 167 #else
171 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 168 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
172 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
173 } 170 }
174 #endif 171 #endif
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 DrawNativeRect(*canvas, 0, 0, 100, 100); 400 DrawNativeRect(*canvas, 0, 0, 100, 100);
404 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH); 401 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH);
405 } 402 }
406 canvas->restore(); 403 canvas->restore();
407 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, 404 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK,
408 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); 405 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH));
409 #endif 406 #endif
410 } 407 }
411 408
412 } // namespace skia 409 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/platform_canvas.cc ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698