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

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

Issue 168653002: Change device factories to take SkImageInfo instead of SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix PdfViewer Created 6 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/device/xps/SkXPSDevice.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 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
11 #define SkDevice_DEFINED 11 #define SkDevice_DEFINED
12 12
13 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkCanvas.h" 15 #include "SkCanvas.h"
16 #include "SkColor.h" 16 #include "SkColor.h"
17 #include "SkDeviceProperties.h" 17 #include "SkDeviceProperties.h"
18 18
19 //#define SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
20
19 class SkClipStack; 21 class SkClipStack;
20 class SkDraw; 22 class SkDraw;
21 struct SkIRect; 23 struct SkIRect;
22 class SkMatrix; 24 class SkMatrix;
23 class SkMetaData; 25 class SkMetaData;
24 class SkRegion; 26 class SkRegion;
25 27
26 class GrRenderTarget; 28 class GrRenderTarget;
27 29
28 class SK_API SkBaseDevice : public SkRefCnt { 30 class SK_API SkBaseDevice : public SkRefCnt {
29 public: 31 public:
30 SK_DECLARE_INST_COUNT(SkBaseDevice) 32 SK_DECLARE_INST_COUNT(SkBaseDevice)
31 33
32 /** 34 /**
33 * Construct a new device. 35 * Construct a new device.
34 */ 36 */
35 SkBaseDevice(); 37 SkBaseDevice();
36 38
37 /** 39 /**
38 * Construct a new device. 40 * Construct a new device.
39 */ 41 */
40 SkBaseDevice(const SkDeviceProperties& deviceProperties); 42 SkBaseDevice(const SkDeviceProperties& deviceProperties);
41 43
42 virtual ~SkBaseDevice(); 44 virtual ~SkBaseDevice();
43 45
46 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
44 /** 47 /**
45 * Creates a device that is of the same type as this device (e.g. SW-raster , 48 * Creates a device that is of the same type as this device (e.g. SW-raster ,
46 * GPU, or PDF). The backing store for this device is created automatically 49 * GPU, or PDF). The backing store for this device is created automatically
47 * (e.g. offscreen pixels or FBO or whatever is appropriate). 50 * (e.g. offscreen pixels or FBO or whatever is appropriate).
48 * 51 *
49 * @param width width of the device to create 52 * @param width width of the device to create
50 * @param height height of the device to create 53 * @param height height of the device to create
51 * @param isOpaque performance hint, set to true if you know that you will 54 * @param isOpaque performance hint, set to true if you know that you will
52 * draw into this device such that all of the pixels will 55 * draw into this device such that all of the pixels will
53 * be opaque. 56 * be opaque.
54 */ 57 */
55 SkBaseDevice* createCompatibleDevice(SkBitmap::Config config, 58 SkBaseDevice* createCompatibleDevice(SkBitmap::Config config,
56 int width, int height, 59 int width, int height,
57 bool isOpaque); 60 bool isOpaque);
61 #endif
62 SkBaseDevice* createCompatibleDevice(const SkImageInfo&);
58 63
59 SkMetaData& getMetaData(); 64 SkMetaData& getMetaData();
60 65
61 enum Capabilities { 66 enum Capabilities {
62 kVector_Capability = 0x1, //!< mask indicating a vector representation 67 kVector_Capability = 0x1, //!< mask indicating a vector representation
63 }; 68 };
64 virtual uint32_t getDeviceCapabilities() = 0; 69 virtual uint32_t getDeviceCapabilities() = 0;
65 70
66 /** Return the width of the device (in pixels). 71 /** Return the width of the device (in pixels).
67 */ 72 */
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 int scalarsPerPos, const SkPaint& paint) = 0; 277 int scalarsPerPos, const SkPaint& paint) = 0;
273 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, 278 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
274 const SkPath& path, const SkMatrix* matrix, 279 const SkPath& path, const SkMatrix* matrix,
275 const SkPaint& paint) = 0; 280 const SkPaint& paint) = 0;
276 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou nt, 281 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou nt,
277 const SkPoint verts[], const SkPoint texs[], 282 const SkPoint verts[], const SkPoint texs[],
278 const SkColor colors[], SkXfermode* xmode, 283 const SkColor colors[], SkXfermode* xmode,
279 const uint16_t indices[], int indexCount, 284 const uint16_t indices[], int indexCount,
280 const SkPaint& paint) = 0; 285 const SkPaint& paint) = 0;
281 /** The SkDevice passed will be an SkDevice which was returned by a call to 286 /** The SkDevice passed will be an SkDevice which was returned by a call to
282 onCreateCompatibleDevice on this device with kSaveLayer_Usage. 287 onCreateDevice on this device with kSaveLayer_Usage.
283 */ 288 */
284 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, 289 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
285 const SkPaint&) = 0; 290 const SkPaint&) = 0;
286 291
287 /** 292 /**
288 * On success (returns true), copy the device pixels into the bitmap. 293 * On success (returns true), copy the device pixels into the bitmap.
289 * On failure, the bitmap parameter is left unchanged and false is 294 * On failure, the bitmap parameter is left unchanged and false is
290 * returned. 295 * returned.
291 * 296 *
292 * The device's pixels are converted to the bitmap's config. The only 297 * The device's pixels are converted to the bitmap's config. The only
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 404
400 // used to change the backend's pixels (and possibly config/rowbytes) 405 // used to change the backend's pixels (and possibly config/rowbytes)
401 // but cannot change the width/height, so there should be no change to 406 // but cannot change the width/height, so there should be no change to
402 // any clip information. 407 // any clip information.
403 // TODO: move to SkBitmapDevice 408 // TODO: move to SkBitmapDevice
404 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0; 409 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0;
405 410
406 // just called by SkCanvas when built as a layer 411 // just called by SkCanvas when built as a layer
407 void setOrigin(int x, int y) { fOrigin.set(x, y); } 412 void setOrigin(int x, int y) { fOrigin.set(x, y); }
408 // just called by SkCanvas for saveLayer 413 // just called by SkCanvas for saveLayer
409 SkBaseDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config, 414 SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&);
410 int width, int height,
411 bool isOpaque);
412 415
416 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
413 /** 417 /**
414 * Subclasses should override this to implement createCompatibleDevice. 418 * Justs exists during the period where clients still "override" this
419 * signature. They are supported by our base-impl calling this old
420 * signature from the new one (using ImageInfo).
415 */ 421 */
416 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, 422 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config,
417 int width, int height, 423 int width, int height,
418 bool isOpaque, 424 bool isOpaque, Usage) {
419 Usage usage) = 0; 425 return NULL;
426 }
427 #endif
428 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) {
429 return NULL;
430 }
420 431
421 /** Causes any deferred drawing to the device to be completed. 432 /** Causes any deferred drawing to the device to be completed.
422 */ 433 */
423 virtual void flush() = 0; 434 virtual void flush() = 0;
424 435
425 SkIPoint fOrigin; 436 SkIPoint fOrigin;
426 SkMetaData* fMetaData; 437 SkMetaData* fMetaData;
427 438
428 #ifdef SK_DEBUG 439 #ifdef SK_DEBUG
429 bool fAttachedToCanvas; 440 bool fAttachedToCanvas;
430 #endif 441 #endif
431 442
432 typedef SkRefCnt INHERITED; 443 typedef SkRefCnt INHERITED;
433 }; 444 };
434 445
435 #endif 446 #endif
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/device/xps/SkXPSDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698