Chromium Code Reviews

Side by Side Diff: include/core/SkDevice.h

Issue 180113010: Add SkCanvas::writePixels that takes info+pixels directly (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 The Android Open Source Project 3 * Copyright 2010 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkDevice_DEFINED 10 #ifndef SkDevice_DEFINED
(...skipping 98 matching lines...)
109 virtual SkBitmap::Config config() const = 0; 109 virtual SkBitmap::Config config() const = 0;
110 110
111 /** Return the bitmap associated with this device. Call this each time you n eed 111 /** Return the bitmap associated with this device. Call this each time you n eed
112 to access the bitmap, as it notifies the subclass to perform any flushin g 112 to access the bitmap, as it notifies the subclass to perform any flushin g
113 etc. before you examine the pixels. 113 etc. before you examine the pixels.
114 @param changePixels set to true if the caller plans to change the pixels 114 @param changePixels set to true if the caller plans to change the pixels
115 @return the device's bitmap 115 @return the device's bitmap
116 */ 116 */
117 const SkBitmap& accessBitmap(bool changePixels); 117 const SkBitmap& accessBitmap(bool changePixels);
118 118
119 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
119 /** 120 /**
120 * DEPRECATED: This will be made protected once WebKit stops using it. 121 * DEPRECATED: This will be made protected once WebKit stops using it.
121 * Instead use Canvas' writePixels method. 122 * Instead use Canvas' writePixels method.
122 * 123 *
123 * Similar to draw sprite, this method will copy the pixels in bitmap onto 124 * Similar to draw sprite, this method will copy the pixels in bitmap onto
124 * the device, with the top/left corner specified by (x, y). The pixel 125 * the device, with the top/left corner specified by (x, y). The pixel
125 * values in the device are completely replaced: there is no blending. 126 * values in the device are completely replaced: there is no blending.
126 * 127 *
127 * Currently if bitmap is backed by a texture this is a no-op. This may be 128 * Currently if bitmap is backed by a texture this is a no-op. This may be
128 * relaxed in the future. 129 * relaxed in the future.
129 * 130 *
130 * If the bitmap has config kARGB_8888_Config then the config8888 param 131 * If the bitmap has config kARGB_8888_Config then the config8888 param
131 * will determines how the pixel valuess are intepreted. If the bitmap is 132 * will determines how the pixel valuess are intepreted. If the bitmap is
132 * not kARGB_8888_Config then this parameter is ignored. 133 * not kARGB_8888_Config then this parameter is ignored.
133 */ 134 */
134 virtual void writePixels(const SkBitmap& bitmap, int x, int y, 135 virtual void writePixels(const SkBitmap& bitmap, int x, int y,
135 SkCanvas::Config8888 config8888 = SkCanvas::kNative _Premul_Config8888) = 0; 136 SkCanvas::Config8888 config8888 = SkCanvas::kNative _Premul_Config8888);
137 #endif
138
139 bool writePixelsDirect(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
136 140
137 /** 141 /**
138 * Return the device's associated gpu render target, or NULL. 142 * Return the device's associated gpu render target, or NULL.
139 */ 143 */
140 virtual GrRenderTarget* accessRenderTarget() = 0; 144 virtual GrRenderTarget* accessRenderTarget() = 0;
141 145
142 146
143 /** 147 /**
144 * Return the device's origin: its offset in device coordinates from 148 * Return the device's origin: its offset in device coordinates from
145 * the default origin in its canvas' matrix/clip 149 * the default origin in its canvas' matrix/clip
(...skipping 234 matching lines...)
380 // either is identical to kNative_Premul_Config8888. Otherwise, -1. 384 // either is identical to kNative_Premul_Config8888. Otherwise, -1.
381 static const SkCanvas::Config8888 kPMColorAlias; 385 static const SkCanvas::Config8888 kPMColorAlias;
382 386
383 protected: 387 protected:
384 // default impl returns NULL 388 // default impl returns NULL
385 virtual SkSurface* newSurface(const SkImageInfo&); 389 virtual SkSurface* newSurface(const SkImageInfo&);
386 390
387 // default impl returns NULL 391 // default impl returns NULL
388 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes); 392 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
389 393
394 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i nt y);
395
390 /** 396 /**
391 * Leaky properties are those which the device should be applying but it is n't. 397 * Leaky properties are those which the device should be applying but it is n't.
392 * These properties will be applied by the draw, when and as it can. 398 * These properties will be applied by the draw, when and as it can.
393 * If the device does handle a property, that property should be set to the identity value 399 * If the device does handle a property, that property should be set to the identity value
394 * for that property, effectively making it non-leaky. 400 * for that property, effectively making it non-leaky.
395 */ 401 */
396 SkDeviceProperties fLeakyProperties; 402 SkDeviceProperties fLeakyProperties;
397 403
398 private: 404 private:
399 friend class SkCanvas; 405 friend class SkCanvas;
(...skipping 41 matching lines...)
441 SkMetaData* fMetaData; 447 SkMetaData* fMetaData;
442 448
443 #ifdef SK_DEBUG 449 #ifdef SK_DEBUG
444 bool fAttachedToCanvas; 450 bool fAttachedToCanvas;
445 #endif 451 #endif
446 452
447 typedef SkRefCnt INHERITED; 453 typedef SkRefCnt INHERITED;
448 }; 454 };
449 455
450 #endif 456 #endif
OLDNEW

Powered by Google App Engine