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

Side by Side Diff: Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

Issue 9340004: Merge 104501 - [chromium win] Creating lots of temporary canvas contexts will crash. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 10 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 | « Source/WebCore/platform/graphics/ImageBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 SkCanvas* canvas = new SkCanvas(); 86 SkCanvas* canvas = new SkCanvas();
87 canvas->setDevice(new SkGpuDevice(gr, texture.get()))->unref(); 87 canvas->setDevice(new SkGpuDevice(gr, texture.get()))->unref();
88 data->m_platformContext.setGraphicsContext3D(context3D); 88 data->m_platformContext.setGraphicsContext3D(context3D);
89 #if USE(ACCELERATED_COMPOSITING) 89 #if USE(ACCELERATED_COMPOSITING)
90 data->m_platformLayer = Canvas2DLayerChromium::create(context3D); 90 data->m_platformLayer = Canvas2DLayerChromium::create(context3D);
91 data->m_platformLayer->setTextureId(texture.get()->getTextureHandle()); 91 data->m_platformLayer->setTextureId(texture.get()->getTextureHandle());
92 #endif 92 #endif
93 return canvas; 93 return canvas;
94 } 94 }
95 95
96 static SkCanvas* createNonPlatformCanvas(const IntSize& size)
97 {
98 SkCanvas* canvas = new SkCanvas();
99 canvas->setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), si ze.height()))->unref();
100 return canvas;
101 }
102
96 ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode renderin gMode, bool& success) 103 ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode renderin gMode, bool& success)
97 : m_data(size) 104 : m_data(size)
98 , m_size(size) 105 , m_size(size)
99 { 106 {
100 OwnPtr<SkCanvas> canvas; 107 OwnPtr<SkCanvas> canvas;
101 108
102 if (renderingMode == Accelerated) 109 if (renderingMode == Accelerated)
103 canvas = adoptPtr(createAcceleratedCanvas(size, &m_data)); 110 canvas = adoptPtr(createAcceleratedCanvas(size, &m_data));
111 else if (renderingMode == UnacceleratedNonPlatformBuffer)
112 canvas = adoptPtr(createNonPlatformCanvas(size));
104 113
105 if (!canvas) 114 if (!canvas)
106 canvas = adoptPtr(skia::TryCreateBitmapCanvas(size.width(), size.height( ), false)); 115 canvas = adoptPtr(skia::TryCreateBitmapCanvas(size.width(), size.height( ), false));
107 116
108 if (!canvas) { 117 if (!canvas) {
109 success = false; 118 success = false;
110 return; 119 return;
111 } 120 }
112 121
113 m_data.m_canvas = canvas.release(); 122 m_data.m_canvas = canvas.release();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 421
413 Vector<char> encodedImage, base64Data; 422 Vector<char> encodedImage, base64Data;
414 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) 423 if (!encodeImage(imageData, mimeType, quality, &encodedImage))
415 return "data:,"; 424 return "data:,";
416 425
417 base64Encode(encodedImage, base64Data); 426 base64Encode(encodedImage, base64Data);
418 return "data:" + mimeType + ";base64," + base64Data; 427 return "data:" + mimeType + ";base64," + base64Data;
419 } 428 }
420 429
421 } // namespace WebCore 430 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/ImageBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698