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

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

Issue 787803004: Update from https://crrev.com/307664 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase. Created 6 years 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/bitmap_platform_device_mac.h ('k') | skia/ext/bitmap_platform_device_skia.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 #include "skia/ext/bitmap_platform_device_mac.h" 5 #include "skia/ext/bitmap_platform_device_mac.h"
6 6
7 #import <ApplicationServices/ApplicationServices.h> 7 #import <ApplicationServices/ApplicationServices.h>
8 #include <time.h> 8 #include <time.h>
9 9
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 LoadConfig(); 193 LoadConfig();
194 return bitmap_context_; 194 return bitmap_context_;
195 } 195 }
196 196
197 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, 197 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
198 const SkRegion& region, 198 const SkRegion& region,
199 const SkClipStack&) { 199 const SkClipStack&) {
200 SetMatrixClip(transform, region); 200 SetMatrixClip(transform, region);
201 } 201 }
202 202
203 void BitmapPlatformDevice::DrawToNativeContext(CGContextRef context, int x,
204 int y, const CGRect* src_rect) {
205 bool created_dc = false;
206 if (!bitmap_context_) {
207 created_dc = true;
208 GetBitmapContext();
209 }
210
211 // this should not make a copy of the bits, since we're not doing
212 // anything to trigger copy on write
213 CGImageRef image = CGBitmapContextCreateImage(bitmap_context_);
214 CGRect bounds;
215 bounds.origin.x = x;
216 bounds.origin.y = y;
217 if (src_rect) {
218 bounds.size.width = src_rect->size.width;
219 bounds.size.height = src_rect->size.height;
220 CGImageRef sub_image = CGImageCreateWithImageInRect(image, *src_rect);
221 CGContextDrawImage(context, bounds, sub_image);
222 CGImageRelease(sub_image);
223 } else {
224 bounds.size.width = width();
225 bounds.size.height = height();
226 CGContextDrawImage(context, bounds, image);
227 }
228 CGImageRelease(image);
229
230 if (created_dc)
231 ReleaseBitmapContext();
232 }
233
234 SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice( 203 SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
235 const CreateInfo& cinfo) { 204 const CreateInfo& cinfo) {
236 const SkImageInfo& info = cinfo.fInfo; 205 const SkImageInfo& info = cinfo.fInfo;
237 const bool do_clear = !info.isOpaque(); 206 const bool do_clear = !info.isOpaque();
238 SkASSERT(info.colorType() == kN32_SkColorType); 207 SkASSERT(info.colorType() == kN32_SkColorType);
239 return Create(NULL, info.width(), info.height(), info.isOpaque(), do_clear); 208 return Create(NULL, info.width(), info.height(), info.isOpaque(), do_clear);
240 } 209 }
241 210
242 // PlatformCanvas impl 211 // PlatformCanvas impl
243 212
(...skipping 28 matching lines...) Expand all
272 241
273 if (!is_opaque) 242 if (!is_opaque)
274 bitmap_.eraseColor(0); 243 bitmap_.eraseColor(0);
275 244
276 surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(), 245 surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(),
277 bitmap_.height()); 246 bitmap_.height());
278 return true; 247 return true;
279 } 248 }
280 249
281 } // namespace skia 250 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_mac.h ('k') | skia/ext/bitmap_platform_device_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698