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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Image.cpp

Issue 1823133002: Use sk_sp-based picture recording APIs in Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 9 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 // Arbitrary tiling is currently only supported for SkPictureShader - so we use it instead 193 // Arbitrary tiling is currently only supported for SkPictureShader - so we use it instead
194 // of a plain bitmap shader to implement spacing. 194 // of a plain bitmap shader to implement spacing.
195 const SkRect tileRect = SkRect::MakeWH( 195 const SkRect tileRect = SkRect::MakeWH(
196 image->width() + spacing.width(), 196 image->width() + spacing.width(),
197 image->height() + spacing.height()); 197 image->height() + spacing.height());
198 198
199 SkPictureRecorder recorder; 199 SkPictureRecorder recorder;
200 SkCanvas* canvas = recorder.beginRecording(tileRect); 200 SkCanvas* canvas = recorder.beginRecording(tileRect);
201 canvas->drawImage(image, 0, 0, &paint); 201 canvas->drawImage(image, 0, 0, &paint);
202 sk_sp<SkPicture> picture(recorder.endRecordingAsPicture());
203 202
204 return SkShader::MakePictureShader( 203 return SkShader::MakePictureShader(recorder.finishRecordingAsPicture(),
205 std::move(picture), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMo de, &shaderMatrix, nullptr); 204 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix, n ullptr);
206 } 205 }
207 206
208 } // anonymous namespace 207 } // anonymous namespace
209 208
210 void Image::drawPattern(GraphicsContext& context, const FloatRect& floatSrcRect, const FloatSize& scale, 209 void Image::drawPattern(GraphicsContext& context, const FloatRect& floatSrcRect, const FloatSize& scale,
211 const FloatPoint& phase, SkXfermode::Mode compositeOp, const FloatRect& dest Rect, const FloatSize& repeatSpacing) 210 const FloatPoint& phase, SkXfermode::Mode compositeOp, const FloatRect& dest Rect, const FloatSize& repeatSpacing)
212 { 211 {
213 TRACE_EVENT0("skia", "Image::drawPattern"); 212 TRACE_EVENT0("skia", "Image::drawPattern");
214 213
215 RefPtr<SkImage> image = imageForCurrentFrame(); 214 RefPtr<SkImage> image = imageForCurrentFrame();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return image.release(); 263 return image.release();
265 } 264 }
266 265
267 bool Image::isTextureBacked() 266 bool Image::isTextureBacked()
268 { 267 {
269 RefPtr<SkImage> image = imageForCurrentFrame(); 268 RefPtr<SkImage> image = imageForCurrentFrame();
270 return image ? image->isTextureBacked() : false; 269 return image ? image->isTextureBacked() : false;
271 } 270 }
272 271
273 } // namespace blink 272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698