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

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

Issue 2400873002: keep only one typedef for the native drawing context (Closed)
Patch Set: native_drawing_context.h Created 4 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/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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
140 HDC dc = scoped_platform_paint.GetPlatformSurface(); 140 HDC dc = scoped_platform_paint.GetNativeDrawingContext();
141 141
142 RECT inner_rc; 142 RECT inner_rc;
143 inner_rc.left = x; 143 inner_rc.left = x;
144 inner_rc.top = y; 144 inner_rc.top = y;
145 inner_rc.right = x + w; 145 inner_rc.right = x + w;
146 inner_rc.bottom = y + h; 146 inner_rc.bottom = y + h;
147 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))) ; 147 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))) ;
148 } 148 }
149 #elif defined(OS_MACOSX) 149 #elif defined(OS_MACOSX)
150 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 150 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
151 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); 151 skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
152 CGContextRef context = scoped_platform_paint.GetPlatformSurface(); 152 CGContextRef context = scoped_platform_paint.GetNativeDrawingContext();
153 153
154 CGRect inner_rc = CGRectMake(x, y, w, h); 154 CGRect inner_rc = CGRectMake(x, y, w, h);
155 // RGBA opaque black 155 // RGBA opaque black
156 CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0); 156 CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0);
157 CGContextSetFillColorWithColor(context, black); 157 CGContextSetFillColorWithColor(context, black);
158 CGColorRelease(black); 158 CGColorRelease(black);
159 CGContextFillRect(context, inner_rc); 159 CGContextFillRect(context, inner_rc);
160 } 160 }
161 #elif defined(USE_CAIRO) 161 #elif defined(USE_CAIRO)
162 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 162 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
163 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); 163 skia::ScopedPlatformPaint scoped_platform_paint(&canvas);
164 cairo_t* context = scoped_platform_paint.GetPlatformSurface(); 164 cairo_t* context = scoped_platform_paint.GetNativeDrawingContext();
165 165
166 cairo_rectangle(context, x, y, w, h); 166 cairo_rectangle(context, x, y, w, h);
167 cairo_set_source_rgb(context, 0.0, 0.0, 0.0); 167 cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
168 cairo_fill(context); 168 cairo_fill(context);
169 } 169 }
170 #else 170 #else
171 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) { 171 void DrawNativeRect(SkCanvas& canvas, int x, int y, int w, int h) {
172 NOTIMPLEMENTED(); 172 NOTIMPLEMENTED();
173 } 173 }
174 #endif 174 #endif
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 DrawNativeRect(*canvas, 0, 0, 100, 100); 403 DrawNativeRect(*canvas, 0, 0, 100, 100);
404 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH); 404 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH);
405 } 405 }
406 canvas->restore(); 406 canvas->restore();
407 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, 407 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK,
408 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); 408 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH));
409 #endif 409 #endif
410 } 410 }
411 411
412 } // namespace skia 412 } // 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