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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/skia/SkiaUtils.h

Issue 2878333004: Use SkJpegEncoder in WebKit platform (Closed)
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 float width); 136 float width);
137 137
138 // TODO(fmalita): remove in favor of direct SrcRectConstraint use. 138 // TODO(fmalita): remove in favor of direct SrcRectConstraint use.
139 inline PaintCanvas::SrcRectConstraint WebCoreClampingModeToSkiaRectConstraint( 139 inline PaintCanvas::SrcRectConstraint WebCoreClampingModeToSkiaRectConstraint(
140 Image::ImageClampingMode clamp_mode) { 140 Image::ImageClampingMode clamp_mode) {
141 return clamp_mode == Image::kClampImageToSourceRect 141 return clamp_mode == Image::kClampImageToSourceRect
142 ? PaintCanvas::kStrict_SrcRectConstraint 142 ? PaintCanvas::kStrict_SrcRectConstraint
143 : PaintCanvas::kFast_SrcRectConstraint; 143 : PaintCanvas::kFast_SrcRectConstraint;
144 } 144 }
145 145
146 class VectorWStream : public SkWStream {
147 public:
148 VectorWStream(Vector<unsigned char>* dst) : dst_(dst) {
149 DCHECK(dst_);
150 DCHECK_EQ(0UL, dst->size());
151 }
152
153 bool write(const void* buffer, size_t size) override {
154 dst_->Append((const unsigned char*)buffer, size);
155 return true;
156 }
157
158 size_t bytesWritten() const override { return dst_->size(); }
159
160 private:
161 // Does not own
162 Vector<unsigned char>* dst_;
163 };
164
146 // Skia's smart pointer APIs are preferable over their legacy raw pointer 165 // Skia's smart pointer APIs are preferable over their legacy raw pointer
147 // counterparts. 166 // counterparts.
148 // 167 //
149 // General guidelines 168 // General guidelines
150 // 169 //
151 // When receiving ref counted objects from Skia: 170 // When receiving ref counted objects from Skia:
152 // 171 //
153 // 1) Use sk_sp-based Skia factories if available (e.g. SkShader::MakeFoo() 172 // 1) Use sk_sp-based Skia factories if available (e.g. SkShader::MakeFoo()
154 // instead of SkShader::CreateFoo()). 173 // instead of SkShader::CreateFoo()).
155 // 2) Use sk_sp<T> locals for all objects. 174 // 2) Use sk_sp<T> locals for all objects.
(...skipping 17 matching lines...) Expand all
173 // paint.setShader(SkShader::MakeFoo(...)); 192 // paint.setShader(SkShader::MakeFoo(...));
174 // 193 //
175 // b) shared ownership 194 // b) shared ownership
176 // 195 //
177 // sk_sp<SkShader> shader = SkShader::MakeFoo(...); 196 // sk_sp<SkShader> shader = SkShader::MakeFoo(...);
178 // paint.setShader(shader); 197 // paint.setShader(shader);
179 198
180 } // namespace blink 199 } // namespace blink
181 200
182 #endif // SkiaUtils_h 201 #endif // SkiaUtils_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698