OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
6 #include <uxtheme.h> | 6 #include <uxtheme.h> |
7 #include <vsstyle.h> | 7 #include <vsstyle.h> |
8 #include <vssym32.h> | 8 #include <vssym32.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/resource_util.h" | 13 #include "base/win/resource_util.h" |
14 #include "grit/gfx_resources.h" | 14 #include "grit/gfx_resources.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gfx/brush.h" | 16 #include "ui/gfx/brush.h" |
17 #include "ui/gfx/canvas_direct2d.h" | 17 #include "ui/gfx/canvas_direct2d.h" |
18 #include "ui/gfx/canvas_skia.h" | 18 #include "ui/gfx/canvas_skia.h" |
19 #include "ui/gfx/codec/png_codec.h" | 19 #include "ui/gfx/codec/png_codec.h" |
20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
21 #include "ui/gfx/win_util.h" | 21 #include "ui/gfx/win_util.h" |
22 | 22 |
23 | 23 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 }; | 105 }; |
106 | 106 |
107 // Loads a png data blob from the data resources associated with this | 107 // Loads a png data blob from the data resources associated with this |
108 // executable, decodes it and returns a SkBitmap. | 108 // executable, decodes it and returns a SkBitmap. |
109 SkBitmap LoadBitmapFromResources(int resource_id) { | 109 SkBitmap LoadBitmapFromResources(int resource_id) { |
110 SkBitmap bitmap; | 110 SkBitmap bitmap; |
111 | 111 |
112 HINSTANCE resource_instance = GetModuleHandle(NULL); | 112 HINSTANCE resource_instance = GetModuleHandle(NULL); |
113 void* data_ptr; | 113 void* data_ptr; |
114 size_t data_size; | 114 size_t data_size; |
115 if (base::GetDataResourceFromModule(resource_instance, resource_id, &data_ptr, | 115 if (base::win::GetDataResourceFromModule(resource_instance, resource_id, |
116 &data_size)) { | 116 &data_ptr, &data_size)) { |
117 scoped_refptr<RefCountedMemory> memory(new RefCountedStaticMemory( | 117 scoped_refptr<RefCountedMemory> memory(new RefCountedStaticMemory( |
118 reinterpret_cast<const unsigned char*>(data_ptr), data_size)); | 118 reinterpret_cast<const unsigned char*>(data_ptr), data_size)); |
119 if (!memory) | 119 if (!memory) |
120 return bitmap; | 120 return bitmap; |
121 | 121 |
122 if (!gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) | 122 if (!gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) |
123 NOTREACHED() << "Unable to decode theme image resource " << resource_id; | 123 NOTREACHED() << "Unable to decode theme image resource " << resource_id; |
124 } | 124 } |
125 return bitmap; | 125 return bitmap; |
126 } | 126 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 return; | 323 return; |
324 TestWindow window; | 324 TestWindow window; |
325 gfx::CanvasDirect2D canvas(window.rt()); | 325 gfx::CanvasDirect2D canvas(window.rt()); |
326 | 326 |
327 SkBitmap bitmap = LoadBitmapFromResources(IDR_BITMAP_BRUSH_IMAGE); | 327 SkBitmap bitmap = LoadBitmapFromResources(IDR_BITMAP_BRUSH_IMAGE); |
328 | 328 |
329 canvas.Save(); | 329 canvas.Save(); |
330 canvas.TileImageInt(bitmap, 10, 10, 300, 300); | 330 canvas.TileImageInt(bitmap, 10, 10, 300, 300); |
331 canvas.Restore(); | 331 canvas.Restore(); |
332 } | 332 } |
OLD | NEW |