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

Side by Side Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 358893002: Use newImageSnapshot() to get an image from a Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Bitmap caching for Shaders/Patterns from StaticBitmapImage/SkImage Created 6 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) 260 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
261 { 261 {
262 if (contextDisabled()) 262 if (contextDisabled())
263 return; 263 return;
264 264
265 ASSERT(pattern); 265 ASSERT(pattern);
266 if (!pattern) { 266 if (!pattern) {
267 setStrokeColor(Color::black); 267 setStrokeColor(Color::black);
268 return; 268 return;
269 } 269 }
270 mutableState()->setStrokePattern(pattern); 270
271 SkShader::ShaderLocation preferredLocation = isAccelerated() ? SkShader::kGP U_ShaderLocation : SkShader::kCPU_ShaderLocation;
272
273 mutableState()->setStrokePattern(pattern, preferredLocation);
271 } 274 }
272 275
273 void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient) 276 void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
274 { 277 {
275 if (contextDisabled()) 278 if (contextDisabled())
276 return; 279 return;
277 280
278 ASSERT(gradient); 281 ASSERT(gradient);
279 if (!gradient) { 282 if (!gradient) {
280 setStrokeColor(Color::black); 283 setStrokeColor(Color::black);
281 return; 284 return;
282 } 285 }
283 mutableState()->setStrokeGradient(gradient); 286 mutableState()->setStrokeGradient(gradient);
284 } 287 }
285 288
286 void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern) 289 void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
287 { 290 {
288 if (contextDisabled()) 291 if (contextDisabled())
289 return; 292 return;
290 293
291 ASSERT(pattern); 294 ASSERT(pattern);
292 if (!pattern) { 295 if (!pattern) {
293 setFillColor(Color::black); 296 setFillColor(Color::black);
294 return; 297 return;
295 } 298 }
296 299
297 mutableState()->setFillPattern(pattern); 300 SkShader::ShaderLocation preferredLocation = isAccelerated() ? SkShader::kGP U_ShaderLocation : SkShader::kCPU_ShaderLocation;
301
302 mutableState()->setFillPattern(pattern, preferredLocation);
298 } 303 }
299 304
300 void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient) 305 void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
301 { 306 {
302 if (contextDisabled()) 307 if (contextDisabled())
303 return; 308 return;
304 309
305 ASSERT(gradient); 310 ASSERT(gradient);
306 if (!gradient) { 311 if (!gradient) {
307 setFillColor(Color::black); 312 setFillColor(Color::black);
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 // FIXME: This is to not break tests (it results in the filter bitmap fl ag 1906 // FIXME: This is to not break tests (it results in the filter bitmap fl ag
1902 // being set to true). We need to decide if we respect InterpolationNone 1907 // being set to true). We need to decide if we respect InterpolationNone
1903 // being returned from computeInterpolationQuality. 1908 // being returned from computeInterpolationQuality.
1904 resampling = InterpolationLow; 1909 resampling = InterpolationLow;
1905 } 1910 }
1906 resampling = limitInterpolationQuality(this, resampling); 1911 resampling = limitInterpolationQuality(this, resampling);
1907 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 1912 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
1908 } 1913 }
1909 1914
1910 } 1915 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698